Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
repository:charged_balloons [2020/03/24 02:16]
porcaro1 [Answer Key]
repository:charged_balloons [2020/03/24 02:37]
porcaro1
Line 29: Line 29:
   * Model two charged balloons hanging from strings, incorporating the effects of gravity   * Model two charged balloons hanging from strings, incorporating the effects of gravity
 ===Code=== ===Code===
 +<code Python [enable_line_numbers="​true"​]>​
 +GlowScript 2.7 VPython
 +
 +#​get_library('​https://​rawgit.com/​perlatmsu/​physutil/​master/​js/​physutil.js'​)
 +
 +#Define some things
 +k=9e9 #​electrostatic constant
 +t = 0 #time counter
 +dt = 0.00005 #time increment
 +
 +x1 = -5 #x location for charge 1
 +y1 = 0 #y location for charge 1
 +z1 = 0 #z location for charge 1
 +m1 = 9e-31 #mass or charge 1
 +
 +x2 = 5 #x location for charge 1
 +y2 = 0 #y location for charge 1
 +z2 = 0 #z location for charge 1
 +m2 = 9e-31 #mass or charge 2
 +
 +c1 = sphere(pos=vec(x1,​y1,​z1),​ color = vec(1,0,0)) #create charged particle 1
 +c2 = sphere(pos=vec(x2,​y2,​z2),​ color = vec(0,1,0)) #create charged particle 2
 +
 +r12 = c1.pos-c2.pos #​distance ​ between charge 1 and charge 2
 +
 +c1.charge = 1.6e-19 #charge on charge 1 - note the sign of the charge
 +c1.vel = vec(0,0,0) #initial velocity of charge 1
 +c1.accel = vec(0,0,0) #initial acceleration of charge 1
 +
 +c2.charge = -1.6e-19 #charge on charge 2 - note the sign of the charge
 +c2.vel = vec(0,0,0) #initial velocity of charge 2
 +c2.accel = vec(0,0,0) #initial acceleration of charge 2
 +
 +#loop to move charged objects
 +while mag(r12) = 0:
 +   ​rate(1000)
 +   
 +   ​c1.eforcec2 =       #​electrostatic force of charge 2 on charge 1
 +   ​c2.eforcec1 =       #​electrostatic force of charge 1 on charge 2
 +  ​
 +   #add electrostatic force arrow to charges
 +   ​attach_arrow (c1, "​eforcec2",​ shaftwidth = .2, scale = 1e30, color = vector (1,0,0))
 +   ​attach_arrow (c2, "​eforcec1",​ shaftwidth = .2, scale = 1e30, color = vector (0,1,0))
 +   
 +   ​c1.accel =          #​acceleration of charge 1
 +   ​c2.accel =          #​acceleration of charge 2
 +    ​
 +   ​c1.vel =            #new velocity of charge 1
 +   ​c2.vel =            #new velocity of charge 2
 +   
 +   ​c1.pos =            #new position of charge 1
 +   ​c2.pos =            #new position of charge 2
 +  ​
 +   r12 =               #new distance between charge 1 and charge 2
 + 
 +   ​t=t+dt #increment time variable </​code>​
  
 ====Answer Key=== ====Answer Key===
 ===Handout=== ===Handout===
 +
 +SEE CODE BELOW
 +CHARGE MAGNITUDE NANOCOULOMBS
 +
 ===Code=== ===Code===
-<code Python [enable_line_numbers="​true",​ highlight_lines_extra=""​]>​+<code Python [enable_line_numbers="​true",​ highlight_lines_extra="​36,​37,​43,​44,​46,​47,​49,​50,​52"]>
 GlowScript 2.7 VPython GlowScript 2.7 VPython
  
Line 72: Line 132:
    ​c2.eforcec1 = -c1.eforcec2 #​electrostatic force of charge 1 on charge 2    ​c2.eforcec1 = -c1.eforcec2 #​electrostatic force of charge 1 on charge 2
   ​   ​
-    ​ 
     #add electrostatic force arrow to charges     #add electrostatic force arrow to charges
    ​attach_arrow (c1, "​eforcec2",​ shaftwidth = .2, scale = 1e30, color = vector (1,0,0))    ​attach_arrow (c1, "​eforcec2",​ shaftwidth = .2, scale = 1e30, color = vector (1,0,0))
  • repository/charged_balloons.txt
  • Last modified: 2021/03/24 23:40
  • by porcaro1