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

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

Thanks

(x-post from /r/physics)

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.

Have you tried Algodoo ( http://www.algodoo.com/ )? It's very easy to use and at the same time, also lets you script things. I think it's limited to 2D problems only though.

If you find any good tools, please do send a pull request to add them here: https://github.com/learn-awesome/learn-awesome/blob/master/p...

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 [https://openmodelica.org/] is the most popular free IDE for Modelica. You also have commercial IDEs like Dymola (I use this), SimulationX etc.

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] http://pundit.pratt.duke.edu/wiki/Python:Ordinary_Differenti...

[1] http://csc.ucdavis.edu/~cmg/Group/readings/pythonissue_3of4....

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

The MATLAB toolbox "Simscape Multibody" (formerly SimMechanics) does exactly what you're asking. It comes free with student editions of MATLAB, but for home use you need to buy Simulink & Simscape Mechanics.

An alternative that does not support animation as easily as Simscape, but will generate 2D/3D plots, is OpenModelica.

https://www.mathworks.com/products/simmechanics.html

https://openmodelica.org/

https://www.myphysicslab.com/

Classical Mechanics with Mathematica: https://www.amazon.com/Classical-Mathematica%C2%AE-Simulatio...

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.

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