You are browsing as a guest. Sign up (or log in) to start making projects!

MechSim

  • 14 Devlogs
  • 29 Total hours

Mechanical system simulator using Lagrangian mechanics and Runge-Kutta methods

Open comments for this post

48m 27s logged

Website structure rewrite

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/

0
0
12
Open comments for this post

5h 26m 43s logged

Circular Disks

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

0
0
7
Open comments for this post

5h 24m 56s logged

LaTeX and more simplification

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:

  • Added a label to show kinetic and potential energies (and demonstrating conservation of energy!)
  • Finally implemented combining like terms (3x + 2x = 5x) and like powers (sin(x) * sin(x) = sin^2(x)), which provides a huge speed increase since the equations of motion are now simpler
  • Fixed a BUNCH of bugs that were cropping up under MicroPython (annoyingly CPython’s dict keys in order of assignment is an implementation detail that isn’t in MicroPython, and the hashing function in MicroPython is completely unreliable)
  • Added LaTeX mode for converting expressions into strings, which automatically handles subscripts and symbols
  • Added labels to the diagram also with LaTeX, tweaked for visibility
0
0
38
Open comments for this post

3h 26m 46s logged

Officially brought to web!

I had to wrestle with PyScript for an incredibly long time, but it’s finally running smoothly!

Two big changes to the code are:

  1. micropython support, which runs and loads SO much faster than Pyodide (but meant I had to rewrite itertools.product and np.linalg.solve)
  2. helper classes to create a mechanical system and create energy formulae, which abstracts the math away into much more of an intuitive system!

The code for setting up the system gets simpler and simpler each time…

0
0
11
Open comments for this post

53m 1s logged

PyScript testing

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.

0
0
15
Open comments for this post

1h 33m 40s logged

Better syntax and other tests

The expressions can now be written in a much simpler syntax, making it easier to read! Below is also a test run simulating the angle of a rocking semicircle.

0
0
7
Open comments for this post

46m 47s logged

Optimisations

The old code used to substitute values and perform thousands of simplifications when they weren’t even necessary. Now the values are directly calculated, resulting in much better execution times.

0
0
17
Open comments for this post

1h 47m 14s logged

More complicated math

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

0
0
19
Open comments for this post

25m 34s logged

Basic expression manipulation

The goal of this project is to write a library that can perform symbolic differentiation and solve for an “equation of motion” which can be used to run a simulation.

The code for substituting variables is now complete. Here is a sample of how the substitution works.

0
1
24

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…