I want to simulate an impact between two bodies according to gravity, and eventually considering other forces to stick matter together. I'd like to use python to do this, but I am open to alternatives. What kind of tools or libraries can I use to perform this task ?
|
|
I recently did something like this, in order to simulate a system of two masses connected by a spring. Those masses lay horizontally on a frictionless plane. One of these masses got an initial impulse and thereafter the system was left alone. While the entire system (the controid to be precies) moves with constant velocity, the two masses are oscillating, while moving forward. Here is a short ASCII drawing of the system
After writing down the differential equations, I wrote a small python programm simulating the problem. This programm relies on the method of small steps (also called the Eueler Method). Here is the correspondig wikipedia article: http://en.wikipedia.org/wiki/Euler_method I implemented this alogorithm for the problem described above and plotted the results using gnuplot: gnuplot.info (I am only allowed to add one hyperlink, so please add www) But you are free to use any tool you like for this purpose. Here comes the sourcecode of my small programm:
Of course there are better alogorithmus than the euler one, but this one is definitly the easiest to implement (I failed implementing more advanced algorithms ;-)). So these are the steps you should probably follow:
I know that this is quite an extensive topic and that my answer is therefore just superficial. Just tell what you want to know more about, and I will try to add corresponding comments ;-) |
|||||
|
|
Check out the site of Ron Fedkiw; it is a good starting point with comprehensive set of keywords. |
|||
|
|
|
it depends on what kind of simulation you trying to build: if your simulation has the purpose build a simulative model, that, for example, avoids the experimental noise, maybe with a complex dynamics algorithm and so on, i think C or C++ are the best choices.. If on the other hand you want to create a quick simulation with graphical output and built-in analysis tools (maybe even for didactic purpose), python is your choice! in this case I suggest you check out the Enthought Python Distribution.. for accademic use it is freeware and it has a built-in release of scipy. |
|||
|