This is a python script I used to teach myself and explore some of the possibilities offed by sympy
and scipy
(especially ODE numerical integration and optimization)
- Derive differential equations with analytical mechanics in
sympy
- Turn symbolic expressions into functions with
lambdify()
- Simulate the system with conditional floor constraint and using an event to detect launch at 45 degrees with
scipy.integrate
- Optimize model parameters to increase energy transfer with
scipy.optimize
- Animate with
matplotlib.animation
I am quite amazed by all the things free software now has to offer for scientific computing...
The trebuchet I'm simulating has an axle free to move on a horizontal line. It seems to naturally have a quite good transfer ratio. In fact the optimization improves it only a little.
Before otpimisation:
After optimisation
I hate all weapons in the world. But I can't help it, trebuchets are fun...