mirror of
https://github.com/nasa/trick.git
synced 2024-12-26 16:21:07 +00:00
496de8c7a9
* Disambiguate python use #1250 Changed all calls to /usr/bin/python to /usr/bin/env python3. Removed execute permissions on a lot of files that are not executable. closes #1250 |
||
---|---|---|
.. | ||
images | ||
.gitignore | ||
makefile | ||
MassSpringDamper.cpp | ||
plot_position.py | ||
README.md |
MassSpringDamper
The MassSpringDamper program uses the SA::EulerCromerIntegrator class to simulate a forced mass-spring-damper system.
The mass is chosen to be 1 kg. The damping constant is chosen to be 5 Ns/m. The spring constant is calculated for a frequency of 2 hz. Every 5 seconds, the system is given an impulse of 500 Newtons for 0.005 seconds.
For each numerical integration time-step, the simulation program prints
- time (s)
- position (m)
- velocity (m/s)
to stdout
, in Comma Separated Values (CSV) format.
Building & Running the Simulation Program
To compile MassSpringDamper:
$ make
To run it, and generate a CSV file:
$ ./MassSpringDamper > msd.csv
Plotting the Results
The Python script, plot_position.py
is provided to plot the results in msd.csv
using (Python) matplotlib.
Plot position vs. time as follows:
$ python plot_position.py