trick/trick_sims/SIM_msd
jmpenn ee2f824550
Disable unneeded SimObjects from default_trick_sys.sm in Trick exampl… (#1719)
* Disable unneeded SimObjects from default_trick_sys.sm in Trick example sims.

* Take out unit test disable. Add some S_defines I forgot.
2024-05-23 10:12:27 -05:00
..
images added new mass-spring-damper sim and graphics client (#555) 2018-01-31 13:37:14 -06:00
models example sim SIM_msd add init body 2018-12-21 14:01:48 -06:00
Modified_data added new mass-spring-damper sim and graphics client (#555) 2018-01-31 13:37:14 -06:00
RUN_critdamp Python3 exec open (#907) 2019-11-14 13:35:57 -06:00
RUN_nodamp Python3 exec open (#907) 2019-11-14 13:35:57 -06:00
RUN_overdamp Python3 exec open (#907) 2019-11-14 13:35:57 -06:00
RUN_test Maven, offline mode, and --enable-mongoose (#939) 2020-02-05 14:31:58 -06:00
RUN_underdamp Python3 exec open (#907) 2019-11-14 13:35:57 -06:00
README.md added new mass-spring-damper sim and graphics client (#555) 2018-01-31 13:37:14 -06:00
S_define Disable unneeded SimObjects from default_trick_sys.sm in Trick exampl… (#1719) 2024-05-23 10:12:27 -05:00
S_overrides.mk Maven, offline mode, and --enable-mongoose (#939) 2020-02-05 14:31:58 -06:00

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)