Bonds & Chemical Energy

Bonds & Chemical Energy preview image

1 collaborator

Default-person Kerri Wingert (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.2.0 • Viewed 597 times • Downloaded 23 times • Run 0 times
Download the 'Bonds & Chemical Energy' modelDownload this modelEmbed this model

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


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.

RELATED MODELS

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:

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 University, Evanston, IL.

COPYRIGHT AND LICENSE

Copyright 2005 Pratim Sengupta and Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

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.

Comments and Questions

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

Click to Run Model

breed [tracks track]
breed [magnetic-shells magnetic-shell] ;;; plastic shell
breed [magnetic-centers magnetic-center] ;;; magnetic marbles
breed [particles particle]  ;;; steel ball
breed [force-vectors force-vector]
breed [stickers sticker]
breed [cursors cursor]
breed [portals portal]

magnetic-centers-own [id]
;magnetic-centers-own [which-shell]


force-vectors-own [
  which-force-field
  magnitude
]

particles-own [
  fx1     ;; x-component of force vector
  fy1     ;; y-component of force vector
  fx2     ;; x-component of force vector
  fy2     ;; y-component of force vector
  vx     ;; x-component of velocity vector
  vy     ;; y-component of velocity vector
  is-metal?
  id
  charge
]

stickers-own [id]

globals [
  r1          ;; distance between particle and magnetic-center 1
  r2          ;; distance between particle and magnetic-center 2
  potential  ;; potential energy of particle
  force-1      ;; magnitude of force vector 1
  force-2      ;; magnitude of force vector 2
  net-force
  previous-permittivity ;; the last recorded value of permittivity
  field-0-vector-color
  field-1-vector-color
  field-2-vector-color
  speed-particle-A
  speed-particle-B
  speed-particle-C
  stop-run?
  fade-rate
  %-of-metal-in-a
  %-of-metal-in-b
  %-of-metal-in-c
  particle-c-speed
  vector-field-size-scale
  vector-field-shapes
  show-particle-labels?
  total-particles-start
  avg-speed-particles
]

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

to setup
  clear-all
  set-default-shape turtles "circle"
  set field-0-vector-color [100 0 100 90]
  set field-1-vector-color [0 0 200 90]
  set field-2-vector-color [200 0 0 90]

  set speed-particle-A 0
  set speed-particle-B 0
  set speed-particle-C 0
  set stop-run? false
  set fade-rate 25
  set show-particle-labels? true
  set vector-field-size-scale "shape area = magnitude" ;"shape length = magnitude" ;"shape volume = magnitude"
  set vector-field-shapes "default"   ;;"iron filling"

  ask patches [ set pcolor background ]
 ;

  create-portals 1 [
    set size 50
    set color gray + 3
    setxy min-pxcor 0
    set shape "portal"
  ]

  create-portals 1 [
    set size 50
    set color gray + 3
    setxy max-pxcor 0
    set shape "portal"
  ]


  create-magnetic-centers 1 [
    set id 1
    set size 20
    set color blue + 2
    setxy position-magnet1 -15

    hatch 1 [set size 1 set breed stickers set shape "empty" create-link-from myself [tie]]
  ]


  create-magnetic-centers 2 [
    set id 2
    set size 20
    set color red + 2
    setxy position-magnet2 -15
    hatch 1 [set size 1 set breed stickers set shape "empty" create-link-from myself [tie]]
     ]
   if initial-speed-particle-A > 0 [
  create-particles 1 [
    set color green
    set size 10
    setxy min-pxcor 0
    set vx initial-speed-particle-A
    set is-metal? true
    set id "A"
    hatch 1 [set size 1 set breed stickers set shape "empty" create-link-from myself [tie]]
  ]
   ]
  create-particles 1 [
    set color gray + 1
    set size 10
    setxy initial-position-particle-B 0
    set vx 0
    set is-metal? true
    set id "B"
    hatch 1 [set size 1 set breed stickers set shape "empty" create-link-from myself [tie]]

  ]

  if initial-position-particle-C < 100 [
  create-particles 1 [
    set color orange
    set size 10
    setxy initial-position-particle-C 0
    set vx 0
    set is-metal? true
    set id "C"
    hatch 1 [set size 1 set breed stickers set shape "empty" create-link-from myself [tie]]
  ]
  ]
  set total-particles-start count particles

  create-tracks 1 [
    set shape "track"
    set color yellow - 2
    set size 300
    setxy 0 -5
  ]

  ask patches with [(pxcor mod 3 = 0 and pycor mod 3 = 0)] [
    ; make 3 different kinds of force-vectors at each of these patches
    sprout 1 [set breed force-vectors set which-force-field 0 set color field-0-vector-color]
    sprout 1 [set breed force-vectors set which-force-field 1 set color field-1-vector-color]
    sprout 1 [set breed force-vectors set which-force-field 2 set color field-2-vector-color]
  ]
 ; show-magnet-sizes

  ask particles [update-metal-composition]
  ask particles [update-force-on-particles]
  calculate-force-fields
  calculate-speeds
  show-force-fields

  show-particle-labels
  reset-ticks
end 



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

to go
  ;if stop:if:C:leaves:system? and not any? particles with [id = "C"] [stop]
 ; check-mouse-interactions
 ;; if not any? particles or stop-run? [ stop ]

;  if permittivity != previous-permittivity
 ; [
  ;  ask patches [ set pcolor background ]
   ; set previous-permittivity permittivity
  ;]
  ask particles [update-metal-composition]
  calculate-force-fields
  show-force-fields

  ask magnetic-centers [
      if id = 1 [set xcor position-magnet1]
      if id = 2 [set xcor position-magnet2]
  ]

  ask particles [
   if id = "A" [set charge %-of-metal-in-a / 10]
   if id = "B" [set charge %-of-metal-in-b / 10]
   if id = "C" [set charge %-of-metal-in-c / 10]
  ]

  ask particles [

        update-force-on-particles
        move
        check-collision

  ]


  calculate-speeds
  fade-patches
  show-particle-labels
  tick
end 

to show-particle-labels
  ask stickers [ifelse show-particle-labels? [set label (word "  " id) set label-color black][set label ""]]
end 

to check-collision

  if id  = "A" and any? particles with [id = "B"] [
    let this-distance-to-collision distance one-of particles with [id = "B"]

    if this-distance-to-collision  <= size  [
      let old-A-vx vx
      let old-B-vx [vx] of one-of particles with [id = "B"]

      if old-A-vx > old-B-vx   [

        ask particles with [id = "B"] [set vx old-A-vx]
        set vx old-B-vx
      ]
    ]
  ]

 if id  = "B" and any? particles with [id = "A"] [
    let this-distance-to-collision distance one-of particles with [id = "A"]

    if this-distance-to-collision  <= size  [
      let old-B-vx vx
      let old-A-vx [vx] of one-of particles with [id = "A"]



      if old-A-vx > old-B-vx and heading <= 90 [
        show (word "A moves: " old-B-vx)
        ask particles with [id = "A"] [set vx old-B-vx]
        set vx old-A-vx
      ;  show (word "B moves: " old-A-vx)
      ]
    ]
  ]

    if id  = "B" and any? particles with [id = "C"] [
    let this-distance-to-collision distance one-of particles with [id = "C"]

    if this-distance-to-collision  <= size  [
      let old-B-vx vx
      let old-C-vx [vx] of one-of particles with [id = "C"]

      if old-B-vx > old-C-vx  and heading > 90 [

        ask particles with [id = "C"] [set vx old-B-vx]
        set vx old-C-vx
      ]
    ]
  ]

 if id  = "C" and any? particles with [id = "B"] [
    let this-distance-to-collision distance one-of particles with [id = "B"]

    if this-distance-to-collision  <= size  [
      let old-C-vx vx
      let old-B-vx [vx] of one-of particles with [id = "B"]



      if old-B-vx > old-C-vx [

        ask particles with [id = "B"] [set vx old-C-vx]
        set vx old-B-vx
      ]
    ]
  ]
end 

to calculate-force-fields

  ask force-vectors with [which-force-field = 1] [

      let r-1 distance one-of magnetic-centers with [id = 1]
      set magnitude 0
      if r-1 >= 12 [
        set magnitude ( StrengthOf1) * 10 / (r-1 ^ 2)
        set heading towards one-of magnetic-centers with [id = 1]
        ]
    ]

    ask force-vectors with [which-force-field = 2] [
      let r-2 distance one-of magnetic-centers with [id = 2]
      set magnitude 0
      if r-2 >= 12 [
        set magnitude ( StrengthOf2) * 10 / (r-2 ^ 2)
        set heading towards one-of magnetic-centers with [id = 2]
        ]
    ]
   ask force-vectors with [which-force-field = 0] [

     let force-vector-1 force-vectors-here with [which-force-field = 1]
     let force-vector-2 force-vectors-here with [which-force-field = 2]
     let this-patch patch-here
     set heading (first [heading] of force-vector-1)
     fd (first [magnitude] of force-vector-1)
     set heading (first [heading] of force-vector-2)
     fd (first [magnitude] of force-vector-2)
     let this-magnitude distance patch-here
     set magnitude this-magnitude
     if distance this-patch > 0 [set heading towards patch-here set heading (heading + 180)]
     move-to this-patch
    ]
end 

to show-magnet-sizes
  ask magnetic-centers [
     if id = 1 [set size StrengthOf1]
     if id = 2 [set size StrengthOf2]
  ]
end 

to update-metal-composition
  if id = "A" [ifelse a-has-thin-metal-shell? [ set %-of-metal-in-a 5 set shape "shelled"][set %-of-metal-in-a 0 set shape "circle"]]
  if id = "C" [ifelse c-has-thin-metal-shell? [ set %-of-metal-in-c 5 set shape "circle"][set %-of-metal-in-c 0 set shape "circle"]]
  set %-of-metal-in-b 100
end 

to update-force-on-particles  ;; particle procedure
    if is-metal? [
    set r1 distance one-of magnetic-centers with [id = 1]
    set r2 distance one-of magnetic-centers with [id = 2]
   ; if r1 < 15 [set r1 15]
   ; if r2 < 15 [set r2 15]
    set force-1 0
    set force-2 0

        set force-1 ( StrengthOf1) * charge / (r1 ^ 2)
        set force-2 ( StrengthOf2) * charge / (r2 ^ 2)
        set heading towards one-of magnetic-centers with [id = 1]
        set fx1 ( force-1 * dx )
        set fy1 ( force-1 * dy )
        set heading towards one-of magnetic-centers with [id = 2]
        set fx2 (  force-2 * dx )
        set fy2  (  force-2 * dy )

     let fx (fx1 + fx2)
     let fy (fy1 + fy2)
   ;set net-force sqrt (((fx) ^ 2) + ((fy) ^ 2))
    ]
end 

to move  ;; particle procedure
  ;; update the particle's velocity, by taking the old velocity and
  ;; adding the force to it.

 ; if distance one-of magnetic-centers with [id = 1] >= 15 and distance one-of magnetic-centers with [id = 2] >= 15 [

  ;  if is-metal? [set vx vx + fx]
  if is-metal? [set vx vx + ((fx1 + fx2) )]
   set vx (vx * ((100 - track-friction-energy-loss) / 100))
 ; if not use-track? [set vy vy + fy * permittivity]
  ;; disappear if we reached the edge
  if patch-at vx vy = nobody [ set stop-run? true ask stickers-here [die] die ]
  ;; update the particle's position
  setxy (xcor + vx) (ycor + vy)
  ;; leave a trail
  set pcolor background - 5

 ; ]
end 

to calculate-speeds ;; particle procedure
  if any? particles with [id = "A"] [set speed-particle-A abs ([vx] of one-of particles with [id = "A"])]
  if any? particles with [id = "B"] [set speed-particle-B abs ([vx] of one-of particles with [id = "B"])]
  if any? particles with [id = "C"] [set speed-particle-C abs ([vx] of one-of particles with [id = "C"])]
   if any? particles [set avg-speed-particles ( (speed-particle-A + speed-particle-B + speed-particle-C) / total-particles-start)]
end 





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

to show-force-fields
  ask force-vectors [set hidden? true]
  if visualize-force-fields-on-B = "field 1" or visualize-force-fields-on-B = "both fields" [
    ask force-vectors with [magnitude > 0 and which-force-field = 1][set hidden? false]
  ]
  if visualize-force-fields-on-B = "field 2" or visualize-force-fields-on-B = "both fields" [
    ask force-vectors with [magnitude > 0 and which-force-field = 2] [set hidden? false]
  ]
   if visualize-force-fields-on-B = "net field" [
    ask force-vectors with [magnitude > 0 and which-force-field = 0] [set hidden? false]
  ]
   ask force-vectors [
     let this-scalar 1
     set shape vector-field-shapes
     if vector-field-size-scale = "none" [set this-scalar 4]
     if vector-field-size-scale = "shape length = magnitude" [set this-scalar magnitude * 20]
     if vector-field-size-scale = "shape area = magnitude" [set this-scalar sqrt (magnitude) * 10]
     if vector-field-size-scale = "shape volume = magnitude" [set this-scalar  ((magnitude)  ^ (1 / 3)) * 8]
     set size this-scalar
     if size  < 1 and not hidden?  [set hidden? true]

   ]
   ask magnetic-centers [ask force-vectors in-radius 10 [set hidden? true]]
end 

to-report background
  report 9
  ;report permittivity * 8 + 5
end 

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

;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Other reporters   ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;

to-report touching? [object-1 object-2]
    let radius-object-1 ([size] of object-1 / 2)
    let radius-object-2 ([size] of object-2 / 2)
    let touching-distance (radius-object-1 + radius-object-2)
    report touching-distance
end 


; Copyright 2005 Pratim Sengupta and Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created about 4 years ago by Kerri Wingert.

Attached files

File Type Description Last updated
Bonds & Chemical Energy.png preview Preview for 'Bonds & Chemical Energy' about 4 years ago, by Kerri Wingert Download

This model does not have any ancestors.

This model does not have any descendants.