Coulomb's Law - Electric Force Model

Coulomb's Law - Electric Force Model preview image

1 collaborator

Redpanda Joshua Abraham (Author)


(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.1.0 • Viewed 963 times • Downloaded 47 times • Run 0 times
Download the 'Coulomb's Law - Electric Force Model' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


This model is used to quantitatively simulate the intereactions between two particles with the electric force (F). The simulation uses initial conditions and Coloumb's Equation for the elctric force in order to model particle-particle interaction.


This model utilizes multiple equations in order to function. The basis of these equations are dictated by the globals defined within the code and in the User Interface (UI):

  • [charge1] are [charge2] are globals defined in the UI and correspond to the given charge (in Coloumbs). Charge1 defines the left particle's charge and Charge2 defines the right paricle's charge. The color (via the globals [color1] and [color2]) of each particle also corresponds to its charge, with neutral displaying gray, negative displaying black, and positive displaying red.

  • [D] is a UI-defined global that represents distance.

  • [Mass] is defined in the UI and is uniform between the two particles.

  • [Initial_Velocity] is the beginning velocity of the rightmost particle.

  • [F] is defined as the electric force and is defined by Coloumb's Equation embedded into the code: F = k(charge1)(charge2)/(D ^ 2)

  • [A] is defined as the acceleration of the rightmost particle, defined by Newton's Second Law, embedded in the code: F = mA A = F / m

  • [V] is the given velocity of the rightmost particle, defined as a function of time and acceleration: V = (initial_velocity) + (A * T))

  • [X] is the position of the rightmost particle's position. It changes depending on the velocity defined above.

  • [T] represents time, as a replacement of ticks. Within the code, the value for T increases by 0.01 every 0.01 seconds. As such, T represents time in the real-world.

  • [R] is the distance between two particles, which is identical to X.

  • [k] is Coloumb's constant, defined as 9 * (10 ^ 9) at the setup phase of the code.


(1) Select values for the particle's charges and the distance between them. Choose values for their mass and the rightmost particle's initial velocity. (2) Hit the setup button. (3) Hit the go button to begin the simulation.

At any point during the model, the "go" button can be deslected to stop the model manually.


As the simulation is running, notice the velocity of the right particle. Is it constant or does it change? How does the movement of the particle relate to its distance from the left particle?


1) Make one or both charges neutral. What happens?

2) If both charges are positive, do the particles repel or attract?

3) How does the mass affect velocity? Try increasing the mass and using the graph provided to examine this relationship.


This is a simplistic model of the electric force, with only one particle moving at a time. To extend this model, both particles can be allowed movement. In addition, more than two particles can be included in the model to demonstrate the addition of force vectors.


Note the use of [globals] at the top of the code to define variables not present in the user interface.

The most important part of this model are the relationships defined by the equations embedded in the simulation. View the "How it Works" section to see more.


This model is most like the "Traffic Basic" model in the NetLogo Model Library. It utilizes a similar interaction between acceleration, velocity, and position for the right particle.


Programmed by: Joshua Abraham, Joe Garcia, Ryan Wang, and Jace Marcos Teacher: Mr. Reese Tracy High School IB Physics Period 1

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

  F           ;Global variable: Electrical Force
  A           ;Global variable: Acceleration
  V           ;Global variable: Velocity
  X           ;Global variable: Displacement
  T           ;Global variable: Time
  R           ;Global variable: Distance
  k           ;Global variable: Coloumb's Constant
  color1      ;Global variable: Color of Turtle 0
  color2]     ;Gloval variable: Color of Turtle 1

to setup
  ask patches[set pcolor white]             ;Sets the world to the color white
  ifelse charge1 >= 0                       ;If the charge is greater than or equal to zero, check if...
    [if charge1 = 0 [set color1 gray]       ;the charge of turtle 0 is 0 the color with be grey
     if charge1 > 0 [set color1 red] ]      ;the charge is greater than 0 the color will be red
    [set color1 black]                      ;If the charge is less than zero, color will be black
  ifelse charge2 >= 0                       ;If the charge is greater than or equal to zero, check if...              
    [if charge2 = 0 [set color2 gray]       ;the charge of turtle 1 is 0 the color with be grey               
     if charge2 > 0 [set color2 red] ]      ;the charge is greater than 0 the color will be red                
    [set color2 black]                      ;If the charge is less than zero, color will be black              
  ask patch 0 0 [sprout 1                   ;Sprout a turtle at patch coordinate: (0,0)          
    [set size 1                             ;Set turtle size to 1           
      set color color1                      ;Set color to whatever color 1 is                 
      set shape "circle"                    ;Set shape of turtle to "circle"                 
  ask patch (0 + D) 0 [sprout 1             ;Sprout a turtle at patch coordinant: (0 + Displacement,0)                 
    [set size 1                             ;Set turtle size to 1           
      set color color2                      ;Set color to whatever color 2 is                  
      set shape "circle"                    ;Set shape of turtle to "circle"                   
  set x D                                   ;Set the x value as the slider's for distance               
  set k (9 * (10 ^ 9))                      ;Defines Coloumb's Constant in a numberic value                  

to go
  wait 0.001                                            ;Wait 0.001 of a second between ticks                        
  every .01 [set T T + .01]                             ;Every 0.01 seconds, set the time up by 0.01                           
  set R x                                               ;Set the distance between the two particles x                    
  set F ((- (k) * (charge1) * (Charge2)) / (R ^ 2))     ;Defines the equation for the Electrical force                            
  set A (F / mass)                                      ;Defines the equation for Acceleration         
  set v (initial_velocity + (A * T) )                   ;Defines the equation for Velocity                         
  set x (x - v)                                         ;Defines the equation for Displacement                  
  ask turtle 1 [setxy x 0]                              ;Positions the turtle at the given x value                 
  if x <= 1 [ask turtle 1 [set xcor 0]                  ;If the displacement is equal to or less then 1, the turtle will stop                         
  if x >= 55 [stop]                                     ;If the displacement is equal to or greater than 55, the turtle will stop      

There is only one version of this model, created over 7 years ago by Joshua Abraham.

Attached files

File Type Description Last updated
Coulomb's Law - Electric Force Model.png preview Preview for 'Coulomb's Law - Electric Force Model' over 7 years ago, by Joshua Abraham Download

This model does not have any ancestors.

This model does not have any descendants.