Ask HN: Toolbox or library for simulating classical mechanics problems?

36 points by ducktective 9 days ago

I'm looking for a toolbox or library to simulate classical mechanics problems usually found in textbooks.

I want to for example see the oscillations of a usual double pendulum problem with ability to plot angles and forces at arbitrary positions. Or physical parameters of "box on a cart with friction" problem or real-time animation of a N-body problem. It'd be nice if it also supports 3d.

1- In summary, suppose someone wants to go through Landau-Lifshitz or Goldstein books and simulate the problems on his computer. What tools should he be looking for?

2- What is the keyword I should be searching for? Rigid Body Solver? Physics Engine? Numerical solvers of Lagrange (or Hamilton?) differential equations formulations? or should I be looking for Finite Element Methods?

3- It would be great if there is a MATLAB/python/C++ solution and not a full-blown software like COMSOL


(x-post from /r/physics)

enriquto 8 days ago

It will certainly not satisfy all your needs, but you cannot avoid spending some time with "Structure and Interpretation of Classical Mechanics" and its companion scheme code.

There is also a neat appendix, slightly simpler and more modern, aimed at the mathematical details, titled "Functional Differential Geometry", by the same authors.

vsskanth 8 days ago

Modelica is an object-oriented language specifically created for simulating physical systems. It is used to formally describe and simulate complex mechanical (or even electrical or thermal) systems with multiple interacting parts (automobiles, flight control systems).

OpenModelica [] is the most popular free IDE for Modelica. You also have commercial IDEs like Dymola (I use this), SimulationX etc.

occamschainsaw 8 days ago

If you want to gain a deeper understanding of classical mechanics, starting with a good diff eq package and then implementing the physical phenomena in terms of diff eq code would also be a good exercise.

Plots would be easy, but I don't think implementing animation from scratch won't be worth the time and effort imo.

Python: [0]


If you are familiar with Matlab or Mathematica, diff eqs are fairly easy to play around with in those environments.

marmaduke 8 days ago

Have you looked at XPP AUT? It provides a mathematically oriented DSL which also allows you to generated GIFs. IIRC one of the examples is a pendulum, but there's no reason you couldn't do an N-body problem.

mhh__ 8 days ago

You might need to just solve them then write MATLAB or Mathematica code to plot the solutions.