43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
HAM: A PHYSICS SIMULATION FRAMEWORK
|
|
|
|
Ham is a physics simulation framework that takes a Lagrangian of a
|
|
system and a description of how to render it and produces a real-time,
|
|
Hamiltonian-based simulation of the system. It uses Maxima for the
|
|
symbolic mathematics and SDL2 for the graphics.
|
|
|
|
For example, for a simple harmonic oscillator:
|
|
|
|
(define-simulation simple-harmonic-oscillator
|
|
:lagrangian (- (* 1/2 m (^ (dot q) 2)) (* 1/2 k (^ q 2)))
|
|
:coords (q)
|
|
:render (translate (* q 100) 0 (circle 20 0 0))
|
|
:start (q 1.0 p_q 0.0)
|
|
:params (m 1.0 k 2.0))
|
|
|
|
To then run the simulation:
|
|
|
|
(make-instance 'simple-harmonic-oscillator)
|
|
|
|
|
|
SETUP
|
|
|
|
Before the ASDF system can be loaded, you must build the Maxima
|
|
sources locally and install them into a directory (I couldn't get
|
|
Maxima's ASDF system to load successfully otherwise, though I'm not
|
|
entirely sure why this fixes it). This can be done with:
|
|
|
|
cd maxima
|
|
mkdir $PWD-install
|
|
./bootstrap
|
|
./configure --prefix=$PWD-install
|
|
make -j
|
|
make install
|
|
|
|
I'll try to figure out if this step itself can be done with ASDF at
|
|
some point ;)
|
|
|
|
Once that's done you should be able to load the system with
|
|
(asdf:load-system :ham), given that the sources are in your ASDF
|
|
registry. The system also uses :sdl2, so make sure that's available
|
|
-- you can get it with (ql:quickload :sdl2) if you're so inclined.
|