MechSim
- 14 Devlogs
- 29 Total hours
Mechanical system simulator using Lagrangian mechanics and Runge-Kutta methods
Mechanical system simulator using Lagrangian mechanics and Runge-Kutta methods
New simulations added:
Temporary deployments can be found at https://rayzchen.github.io/mechsim/
To make adding new simulations easier, I restructured the file layout and added more dynamic code to the shared JS to create the elements required rather than copy pasting everything in every file. Also added labels to the tab title and bottom right corner. Also rewrote the drawing code for the rolling disk to add more details.
Temporary deployments can be found at https://rayzchen.github.io/mechsim/disk/
This system contains a semicircular anulus rocking on a rough plane, with a circular disk inside attached to a compound pendulum, and constrained with three springs. Adjusting the parameters took an awfully long time…
Temporary deployments can be found at https://rayzchen.github.io/mechsim/disk.html
After much headache, two new constraints have been implemented: disk rolling on a plane and disk rolling in a circle. There were also lots of bugs in the LaTeX output, which I just kept encountering one by one, but hopefully they should now all be fixed.
Temporary deployments can be found at https://rayzchen.github.io/mechsim/disk.html
Temporary deployments can be found at https://rayzchen.github.io/mechsim/pend.html
This devlog was supposed to be two separate ones, but Stardance was refusing to calculate logged hours :(
There’s a big list of changes here:
I had to wrestle with PyScript for an incredibly long time, but it’s finally running smoothly!
Two big changes to the code are:
The code for setting up the system gets simpler and simpler each time…
Spent some time reading through the documentation of PyScript (https://pyscript.net/) to see how well the code will run in the browser. Got the double pendulum code to run in the browser, and I will start writing a full demo soon.
I have implemented a class that handles solving, susbtitution and iteration of a system from the lagrangian and tested it with a pendulum-cart setup like the one found at https://www.myphysicslab.com/pendulum/cart-pendulum-en.html.
The solver can now handle sin and cos, as well as expanding brackets! Also added the equation of motion solver to obtain a value for acceleration. Tested with a different rendering tool with a double pendulum setup.
I will eventually create my own simulation using more math and rendering, this window is not part of the project.
TODO: collecting like terms and cancelling down, optimising value substitution
The symbol engine is now capable of performing partial differentiation with respect to any variable, allowing the use of Euler-Lagrange to form differential equations. See https://en.wikipedia.org/wiki/Euler%E2%80%93Lagrange_equation