File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88x = np .array ([0.0 , 0.0 ]) # position of particle
99v = np .array ([0.0 , 0.0 ]) # velocity of particle
1010g = np .array ([0.0 , - 10.0 ]) # gravitational acceleration
11- h = 0.01 # time step size in seconds
11+ h = 0.01 # time step size in seconds
1212
1313# visualization/rendering setup
1414pygame .init ()
@@ -39,13 +39,13 @@ def screen_projection(x): # convert simulated coordinates to window co
3939 pygame .display .flip () # flip the display
4040 pygame .time .wait (int (1000.0 / render_FPS )) # wait to render the next frame
4141
42- # step forward the simulation by updating particle velocity and position
43- v += h * g
44- x += h * v
45-
4642 # pause the simulation when the particle touches on the ground
4743 if x [1 ] <= - 1 :
4844 input ()
4945 break
5046
47+ # step forward the simulation by updating particle velocity and position
48+ v += h * g
49+ x += h * v
50+
5151 time_step += 1 # update time step counter
Original file line number Diff line number Diff line change 66
77# simulation setup
88m = 1000 # mass of particle
9- x = np .array ([0.3 , 0.0 ]) # position of particle
9+ x = np .array ([0.4 , 0.0 ]) # position of particle
1010v = np .array ([0.0 , 0.0 ]) # velocity of particle
1111g = np .array ([0.0 , - 10.0 ]) # gravitational acceleration
1212spring_rest_len = 0.3 # rest length of the spring ###
Original file line number Diff line number Diff line change 66import square_mesh # for generating a square mesh
77
88# simulation setup
9- m = 1000 # mass of each particle
109side_length = 1 # side length of the square
1110n_seg = 4 # number of springs per side of the square
11+ m = 1000 # mass of each particle
1212[x , e ] = square_mesh .generate (side_length , n_seg ) # array of particle positions and springs ###
1313v = np .array ([[0.0 , 0.0 ]] * len (x )) # velocity array of particles ###
1414g = np .array ([0.0 , - 10.0 ]) # gravitational acceleration
You can’t perform that action at this time.
0 commit comments