trick/trick_sims/SIM_msd/README.md
Scott Fennell aa36c31231 added new mass-spring-damper sim and graphics client (#555)
* added new mass-spring-damper sim and graphics client

* changed math model image for README.md

* updated math model image for README.md
2018-01-31 13:37:14 -06:00

2.2 KiB

SIM_MSD

SIM_MSD is a simulator for a mass-spring-damper system.

Picture of MSD

The system is described by the equation mẍ + bẋ + kx = F, where:

m is the mass of an object.

x is the position of the mass.

b is the damping coefficient.

k is the spring coefficient.

F is an external force applied to the mass.


Building the Simulation

In the SIM_MSD directory, execute trick-CP to build the simulation executable. When it's complete, you should see:

=== Simulation make complete ===

Now cd into models/Graphics/ and type make. This builds the display client for the simulation.

Running the Simulation

In the SIM_MSD directory:

% ./S_main_*.exe RUN_test/input.py

The following windows should appear:

Picture of MSD

Picture of Control

Controlling the Simulation

Click Start to begin the simulation.

Click Reset to freeze the simulation and reset the position and velocity to their initial conditions.

Change Position and Velocity to adjust the initial conditions for those attributes.

Change Mass, Spring Coefficient, Damping Coefficient, and Applied Force to adjust initial conditions and also update the sim in real-time.


The following inputs can be set in any of the RUN_*/input.py files to change the inputs on startup

Inputs

Variable Type Units Default Value
dyn.msd.x_0 double m 5.0
dyn.msd.v_0 double m/s 0.0
dyn.msd.b double N.s/m 0.5
dyn.msd.k double N/m 2.0
dyn.msd.F double N 5.0
dyn.msd.m double kg 1.0

Some sample input.py files have been created to demonstrate different mass-spring-damper conditions

Samples

Path Type
RUN_underdamp/input.py Underdamped Harmonic Oscillator
RUN_critdamp/input.py Critically Damped Harmonic Oscillator
RUN_overdamp/input.py Overdamped Harmonic Oscillator
RUN_nodamp/input.py Simple Harmonic Oscillator (No Damping Force)