# Electrostatics

### 2 collaborators

Uri Wilensky (Author)
Pratim Sengupta (Author)

### Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 277 times • Downloaded 38 times • Run 2 times

## WHAT IS IT?

This model displays the common natural phenomenon expressed by the Coulomb's inverse-square law. It shows what happens when the strength of the force between two charges varies inversely with the square of the distance between them.

## HOW IT WORKS

In this model the formula used to guide each charge's behavior is the standard formula for Coulomb's law:

F = (q1 * q2 * Permittivity) / (r^2)

In this formula:

• "F" is the force between the two charges q1 and q2.
• "Permittivity", the constant of proportionality here, is a property of the medium in which the two charges q1 and q2 are situated.
• "r" is the distance between the centers of the two charges.

This is a single force two body model, where we have a charge q1 (the blue particle that is created when you press SETUP) and a proton (q2) (the gray particle that appears when you press the mouse button in the view). The force is entirely one-way: only q1 is attracted towards (or repelled from) the proton (q2), while the proton (q2) remains unaffected. Note that this is purely for purposes of simulation. In the real world, Coulomb's force acts on all bodies around it.

Gravity is another example of an inverse square force. Roughly speaking, our solar system resembles a nucleus (sun) with electrons (planets) orbiting around it.

For certain values of q1 (which you can control by using the CHARGE slider), you can watch q1 form elliptic orbits around the mouse pointer (q2), or watch q1 slingshot around q2, similar to how a comet streaks past our sun. The charges q1 and q2 are always set equal in magnitude to each other, although they can differ in their sign.

## HOW TO USE IT

When you press the SETUP button, the charge q1 is created in a medium determined by the permittivity value from the PERMITTIVITY slider. When you click and hold down the mouse anywhere within the view, the model creates a unit of positive charge (q2) at the position of the mouse.

The CHARGE slider sets the value of the charge on q1. First, select the value of CHARGE on q1. (For simulation ease, value of the Charge on q2 is set to be +1 unit. Thus, it also determines at what distances the particles can safely orbit before they get sucked in by an overwhelming force.)

The FADE-RATE slider controls how fast the paths marked by the particles fade. At 100% there won't be any paths as they fade immediately, and at 0% the paths won't fade at all.

The PERMITTIVITY slider allows you to change values of the constant of proportionality in Coulomb's law. What does this variable depend on -- the charges, or the medium in which the charges are immersed?

When the sliders have been set to desirable levels, press the GO button to begin the simulation. Move the mouse to where you wish q2 to begin, and click and hold the mouse button. This will start the particles moving. If you wish to stop the simulation (say, to change the value of CHARGE), release the mouse button and the particles will stop moving. You may then change any settings you wish. Then, to continue the simulation, simply put your mouse in the window again and click and hold. Objects in the window will only move while the mouse button is pressed down within the window.

## THINGS TO NOTICE

The most important thing to observe is the behavior of the q1 (the blue charge).

What is the initial velocity for q1?

What happens as you change the value of q1 from negative to positive?

As you run the model, watch the graphs on the right hand side of the world. What can you infer from the graphs about the relationship between potential energy and distance between charges? What can you say about the relationship between Coulomb's force and distance between the charges from the graphs?

Move the mouse around -- watch what happens if you move it quickly or slowly. Jiggle it around in a single place, or let it sit still. Observe what patterns the particles fall into. (You may keep FADE-RATE low to watch this explicitly.)

## THINGS TO TRY

Run the simulation playing with different values of: a) charge -- make sure to watch how different values of the CHARGE slider impact the model for any fixed value of permittivity. b) permittivity -- make sure to watch how different values of the PERMITTIVITY slider impact the model for any fixed value of charge.

Can you make q1 revolve around q2? Imagine, if q1 would be an electron and q2 a proton, then you have just built a hydrogen atom...

As the simulation progresses, you can take data on how a) Force between the two charges varies with distance between charges; b) Potential energy changes with distance between charges; c) Force depends on permittivity.

In each case, take 8 to 10 data points. Plot your results by hand or by any plotting program.

## EXTENDING THE MODEL

Assign a fixed position to the proton (q1), i.e., make it independent of the mouse position. Assign a variable to its magnitude.

Now create another charge of the breed "centers", and assign a fixed position to it in the graphics window. Run the model for different positions, magnitude and signs (i.e., "+"ve or "-"ve) of the new "center".

Create many test-charges. Then place the two "centers", of opposite signs and comparable magnitudes, near the two horizontal edges of the world. Now run the model.

Gravitation

## NETLOGO FEATURES

When a particle moves off of the edge of the world, it doesn't re-appear by wrapping onto the other side (as in most other NetLogo models). The model stops when the particle exits the world.

## CREDITS AND REFERENCES

This model is a part of the NIELS curriculum. The NIELS curriculum has been and is currently under development at Northwestern's Center for Connected Learning and Computer-Based Modeling and the Mind, Matter and Media Lab at Vanderbilt University. For more information about the NIELS curriculum please refer to http://ccl.northwestern.edu/NIELS.

## HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

• Sengupta, P. and Wilensky, U. (2005). NetLogo Electrostatics model. http://ccl.northwestern.edu/netlogo/models/Electrostatics. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
• Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

To cite the NIELS curriculum as a whole, please use: Sengupta, P. and Wilensky, U. (2008). NetLogo NIELS curriculum. http://ccl.northwestern.edu/NIELS. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

Copyright 2005 Pratim Sengupta and Uri Wilensky.

To use this model for academic or commercial research, please contact Pratim Sengupta at mailto:pratim.sengupta@vanderbilt.edu or Uri Wilensky at mailto:uri@northwestern.edu for a mutual agreement prior to usage.

Click to Run Model

```breed [centers center]
breed [particles particle]

particles-own [
fx     ;; x-component of force vector
fy     ;; y-component of force vector
vx     ;; x-component of velocity vector
vy     ;; y-component of velocity vector
]

globals [
r          ;; distance between particle and center
potential  ;; potential energy of particle
force      ;; modulus of force vector
previous-permittivity ;; the last recorded value of permittivity
c-charge   ;; charge of the center particle
]

;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to setup
clear-all
set-default-shape turtles "circle"
ask patches [ set pcolor background ]
set previous-permittivity permittivity
set c-charge abs charge
create-centers 1 [
set size 20
set color gray
hide-turtle
]
create-particles 1 [
set color blue
set size 10
fd random-float (max-pxcor - 6)
]
reset-ticks
end

;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Runtime Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
if not any? particles [ stop ]
;; label the particles with the appropriate charge
ask particles [ set label charge ]
;; color the patches for the appropriate permittivity
;; if the permittivity slider has changed
if permittivity != previous-permittivity
[
ask patches [ set pcolor background ]
set previous-permittivity permittivity
]
set c-charge abs charge
if mouse-down?
[
every 0.1
[
;; Get the mouse(mass) position.
let m-xc mouse-xcor
let m-yc mouse-ycor
[
setxy m-xc m-yc
set label c-charge
]
update-force
move
]
tick
]
]
end

to update-force  ;; particle procedure
set r distance one-of centers
;; if r = 0, then it's at the mass, and then the model stops;
;; prevents divide by zero
if r = 0 [ die ]
;; Calculate force using inverse square law
set force (- charge) * c-charge / (r ^ 2)
;; Separate force into x and y components
face one-of centers
set fx force * dx
set fy force * dy
end

to move  ;; particle procedure
;; update the particle's velocity, by taking the old velocity and
;; adding the force to it.
set vx vx + fx * permittivity
set vy vy + fy * permittivity
;; disappear if we reached the edge
if patch-at vx vy = nobody [ die ]
;; update the particle's position
setxy (xcor + vx) (ycor + vy)
;; leave a trail
set pcolor background - 5
end

to calculate-potential-energy  ;; particle procedure
set r distance one-of centers
set potential charge / r
end

;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Visual Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;

to-report background
report permittivity * 8 + 5
end

ask patches with [pcolor != background] [
set pcolor min list (pcolor + fade-rate * 0.005) background
]
end

; Copyright 2005 Pratim Sengupta and Uri Wilensky.
```

There are 10 versions of this model.

Uri Wilensky over 10 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 11 years ago Updated version tag Download this version
Uri Wilensky almost 11 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 11 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 13 years ago Model from NetLogo distribution Download this version