Simple simulations for Physics in Python?

Léo Léopold Hertz 준영 picture Léo Léopold Hertz 준영 · Feb 2, 2009 · Viewed 18.3k times · Source

I would like to know similar, concrete simulations, as the simulation about watering a field here.

What is your favorite library/internet page for such simulations in Python?

I know little Simpy, Numpy and Pygame. I would like to get examples about them.

Answer

sastanin picture sastanin · Feb 2, 2009

If you are looking for some game physics (collisions, deformations, gravity, etc.) which looks real and is reasonably fast consider re-using some physics engine libraries.

As a first reference, you may want to look into pymunk, a Python wrapper of Chipmunk 2D physics library. You can find a list of various Open Source physics engines (2D and 3D) in Wikipedia.

If you are looking for physically correct simulations, no matter what language you want to use, it will be much slower (almost never real-time), and you need to use some numerical analysis software (and probably to write something yourself). Exact answer depends on the problem you want to solve. It is a fairly complicated field (of math).

For example, if you need to do simulations in continuum mechanics or electromagnetism, you probably need Finite Difference, Finite Volume or Finite Element methods. For Python, there are some ready-to-use libraries, for example: FiPy (FVM), GetFem++ (FEM), FEniCS/DOLFIN (FEM), and some other.