Mass-Spring-Damper
On this page
Introduction
This tutorial builds a mass-spring-damper in a uniform gravitational field, the fundamental problem of linear vibration. By the end you will have derived its equation of motion, simulated it and exported it as Python.
Two ways to build the same model
MOMDYN has two kinematics interfaces, and they build exactly the same oscillator. You only need one of them. Path A: Classic is like a pencil-and-paper derivation: you create a coordinate, a vector, a point and a spring one at a time. Path B: Joints replaces those four steps with one prismatic joint. Both paths start at Step 1 and continue at Step 6.
Set up the model
Step 1: Create the new model



From the Welcome screen, tap Create. A dialog titled “Create - Specify Settings” opens (see the settings reference). Most settings can keep their defaults. Enter the following:
model_name: Oscillator
model_description: Simple mass-spring-damper as is common in linear vibration analysis
gravity_method: Uniform
gravity_constant: 9.8
gravity_direction: -Y
time_duration: 5
tol: 0.00001
Tap the green check in the lower right to create the model. Then save it (menu drawer, then Export, with Save File on), because the Joints path returns to this point.
Path A: Classic interface
The Classic interface gives direct control over the building blocks of the kinematics. Here you define a generalized coordinate for the displacement, attach it to a vector, create a point at the end of that vector, and connect the origin and that point with a spring. If you prefer fewer steps, jump to Path B: Joints.
Step 2: Create the displacement coordinate



Open the navigation drawer, then the Classic menu. Tap the plus sign under Generalized Coordinate and enter
name: h
initial: 1
description: displacement
and tap Ok. This creates the displacement , the model’s one translational DOF. The spring’s stiffness, damping and equilibrium constants are created automatically with the spring in Step 5. See Generalized Coordinate.
Step 3: Create the vector



With the Classic panel open, tap the plus sign under Vector and enter
name: h
y: h(t)
and tap Ok. This creates the vector along the (y) axis of the inertial frame, with a length equal to the coordinate . Return to the diagram to see it as a gray line. See Vector.
Step 4: Create the point



Tap the plus sign under Point and enter
vector_key: h
and tap Ok to create point a at the end of the vector . In the diagram, the point is a blue sphere. See Point.
Step 5: Add the translational spring




The only load in this model is a spring-damper between the origin and the point. Open the navigation drawer, then the Loads menu, and tap the plus sign under Translational Spring. Enter
end_point: a
k: 50
c: 1
equilibrium: 1
and tap Ok. MOMDYN also creates the parameters , and for the stiffness, damping and equilibrium length. The spring appears between the two points. See Translational Spring. Continue at Step 6.
Path B: Joints interface
The Joints interface consolidates the building blocks into common mechanical joints. Here the displacement coordinate, the vector, the point and the spring all live in one prismatic joint.
Step 2 (Joints path): Add a prismatic joint



Tap the Welcome tab at the bottom of the screen, then Import, and choose the saved Oscillator model. This returns the model to its state after Step 1. Open the navigation drawer, open the Joints menu and tap the plus sign under Prismatic. Enter (items not listed keep their defaults)
y: 1
value: 1
k: 50
c: 1
equilibrium: 1
and tap Ok. The diagram shows the same point and spring as the Classic path. See Prismatic Joint.
Add the mass
Step 6: Add the point mass




A single particle (a point mass) is attached to the created point. Its inertial force is proportional to its mass times its acceleration. Open the navigation drawer and the Bodies menu, tap the plus sign under Particle, and enter
name: bob
ref_point_key: a
mass: 1
This creates the bob with mass 1 at point a, and the parameter . See Particle.
Simulate and analyze
Step 7: Derive the equations and simulate
On the Diagram tab, tap the right-arrow button in the lower left to derive the equations of motion. This model is small, so the derivation runs nearly instantly, and the icon changes to the outline of a play button. Tap again to run the simulation, and once more to play the animation. The mass bounces with a period of about 0.9 seconds, as in the animation at the top of this page. The on-screen controls are described in On-Screen Controls.
Step 8: Export the model




Open the menu drawer and tap Export. Switch on the items you want, then export:
Save File (model.py): the model, in the format MOMDYN imports.
Python File (python_model.py): code you can run and extend on a desktop Python environment.
Tabular Data (simulation.csv): the time series of the generalized coordinates and speeds that drive the animation.
Plot Images (plots.pdf): plots of the simulation results.
See Import/Export for the file formats.
Step 9: Read the report
Tap the Report tab to see the model as text, equations and plots. The buttons at the top choose the section: symbols, frames, points, bodies, loads, equations and plots. The images show these sections for the oscillator (there are no frames other than the inertial frame).






What you built
The model has one coordinate , one particle of mass , gravity in the direction, and one spring-damper with stiffness , damping and equilibrium length . Its equation of motion is
With , , , and , the natural frequency is rad/s, and the damped period is s. The mass starts at the spring’s equilibrium length, so gravity pulls it down and it oscillates around the static equilibrium m.
Exported Python
The Python File export contains the equations of motion and a short simulation script. This is an excerpt:
python_model.py (placeholder excerpt)
# TODO (owner): paste a short excerpt of the exported oscillator code here
# (the equations of motion and the simulation call).
Next steps
Reference pages for the components used here: Generalized Coordinate, Vector, Point, Translational Spring, Prismatic Joint and Particle.
Build this model in MOMDYN, free on iPhone & iPad
Everything in this tutorial runs in the app. No license required.
Next tutorial: Simple Pendulum →