Numerical calculations aren’t the scientific method of the future. No, they are the methods of the present and past. Humans have been using numerical models for quite some time now. What is a numerical model? Here is my definition:
Numerical Model: The process of modeling a complex (or not so complex) physical situation by breaking the problem into tiny and simpler problems. Typically, there will be numerous tiny problems to solve such that it’s practical to have a computer perform the calculations. You could also call this a numerical calculation.
That’s about as generic as I can get. But now it’s your turn. I know people get a little intimidated when looking at computer code, but you can’t break anything with this program. Below is a numerical model of a mass on a spring. The code is in the format of GlowScript (very much like VPython) but it is embedded using Trinket. The cool thing is that you don’t have to do anything except modify the code and see what happens. You can change the code and then just press “play”to see what happens. Pretty awesome. If you want to edit the code again, just click the little “pencil” icon to go into edit mode. If you click the yellow-green key icon, you can open this trinket on trinket.io. This will let you see the code on the left and the runtime on the right at the same time.
I’m not going to go over all the details of the model. If you want to learn about modeling a mass on a spring, this previous post goes over all the details – also I have a bunch of other tutorials to get you started with GlowScript.
Now for some suggestions. Look through the code above. Try playing with the following ideas:
- What happens if you increase the mass? The mass is in line 14. It’s currently set to 0.1 (100 grams). Try putting a value of 0.2. Does the mass oscillate faster or slower? What do you think it should do? What about the amplitude of oscillation?
- Will a stiff spring change things? Try changing the spring constant from 15 to 30 and also try 8. The spring constant is defined in line 4.
- There is a gravitational force on the ball. What happens if there is no gravity? What happens if the spring is on a planet with a very high gravitational field? The gravitational field is set in line 20.
- In my model, the ball starts from rest. The velocity is part of the momentum as declared in line 15. Will the mass oscillate faster if the initial velocity is moving down? What if it’s moving up?
- Ok, now for something cool. Are you ready for this? Go to line 11. This is where the ball is first created along with the initial position of the ball. Look at the part that says “pos=vec(-.1,-L0+.1,0)”. This says that the ball starts at x=-.1, y=-L0_.1, and z=0 which makes it right underneath the point where the spring is attached. What if you start it on the side a little bit? Try changing it to vec(-.2, -L0+.1, 0) – now run it. What happens? Is it awesome? Try another starting position.
Changing code is coding. If you did any of the above suggestions (or anything else), then you are now a programmer. See. That wasn’t so bad, was it? It might even have been fun.