Wednesday 15 August 2012

Fizzbox's Second Sim

Last time I promised I'd get started on an ideal and non-ideal gas movement simulator. Well I didn't. I got distracted working on my new website (not online yet...) which is looking super cool now. Keep an eye out for news on that! I've been using Bootstrap, a beautiful web design tool made by the creators of Twitter (see shameless link to my own twitter page). It's pretty much done thanks to Bootstrap's simplicity but it's lacking in content. I think I'll fork out for a domain name once I have another two sims to show off.

With that in mind I've been working on a very simple simulation of a mass-spring system. Writing a second sim was a million times easier than the first - not much more work than deleting all the code that had anything to do with gravity and sticking some springy stuff in there instead. This is just first draft, and its not interactive at all at the moment. There are two mass-spring systems with slightly different initial conditions. The idea will eventually be that you can choose the setup yourself and see the effects of the changes you've made by comparing the two systems. Here it is in all its simplish simpleness:

http://pastehtml.com/view/c8cbm9i4f.html.

As this sim is much simpler I thought that before it gets more complicated should share the source code. All of the interesting physics happens in the function called 'step'. If you're an A-level standard physicists or above should be able to see what that function is doing using a bit of your integration knowledge. BoxA and boxB are the two masses. I'm not going to annotate this line by line but I'll happily answer any questions posted as comments if I'm able. Here it is:


No comments:

Post a Comment

About Me

My photo
Manchester, United Kingdom
Second year physics student at the University of Manchester, interested in simulation and education.