Your First Model
This guide walks you through building a classic spring-mass-damper system in CoModel from scratch: setting an initial condition as the excitation, configuring parameters, running the simulation, and inspecting the results. Along the way you will become familiar with the editor's main operations and the simulation workflow.
The target model
We will build the following one-dimensional translational system:
- A fixed end,
Fixed; - A spring,
Spring; - A damper,
Damper; - A mass,
Mass.
The spring and the damper are in parallel: one end connects to the fixed end, the other to the mass. Instead of applying an external force, we give the spring a 0.2 m initial deformation as the excitation: after release, the spring's restoring force and the damper's dissipation act together, and the system returns to equilibrium through decaying oscillation—one of the most classic transient responses of a mechanical system.
Step 1: Create the model
- Sign in to CoModel and click Models in the left navigation.
- Click New Model.
- Fill in the dialog:
- Model name:
SpringMassDamper - Description:
Introductory example of a one-dimensional spring-mass-damper system
- Model name:
- Click Create; the graphical editor opens automatically.

Naming tip: the model name must be a valid Julia module name starting with an uppercase letter, e.g.
SpringMassDamper. If the name is reported as taken, append a number or a suffix.
Step 2: Drag in components
The editor is divided into three main areas:
- Left sidebar: the component library, browsable by physical domain or searchable;
- Center canvas: the modeling area, supporting drag-and-drop, connections, zoom, and pan;
- Right panel: the properties panel and the Code View, switchable.
Locate the following components in the library on the left and drag them onto the canvas one by one:
| Component | Category | Role |
|---|---|---|
Fixed |
Mechanical · Translational | Fixed reference end (anchors velocity) |
Spring |
Mechanical · Translational | Spring; provides the restoring force |
Damper |
Mechanical · Translational | Damper; provides the dissipative force |
Mass |
Mechanical · Translational | Movable mass |
While dragging, a translucent placeholder preview appears; release the mouse and the component is placed on the canvas. Each component gets a unique instance name automatically, e.g. spring1, mass1.

Category tip: the mechanical domain is subdivided by submodule (Mechanical · Translational, Mechanical · Rotational, etc.). Pick components under Mechanical · Translational—identically named components (such as
Spring,Damper) have different port types under different subcategories, and a rotational port cannot connect to a translational one.
Adjust component positions
Select a component and drag to move it. While moving:
- The canvas shows blue alignment guides automatically;
- If grid snapping is enabled (bottom status bar), the component snaps in 10 px steps;
- Connections re-route automatically to follow the port positions.
Place Fixed on the left, Spring and Damper in the middle, and Mass on the right so the physical topology is easy to read.
Step 3: Connect ports
Hover over a component port: it highlights and enlarges. Press and hold the mouse to pull out a rubber-band line. As the line approaches a compatible port, the target port highlights; release the mouse to complete the connection.
Connect as follows:
Fixedportflange→Springportflange_a.Fixedportflange→Damperportflange_a.Springportflange_b→Massportflange.Damperportflange_b→Massportflange.

Port compatibility tip: mechanical translational ports connect only to mechanical translational ports. If you try to connect to another physical domain (such as an electrical pin), the system warns in red and rejects the connection.
Once connected, the Code View on the right generates the corresponding connect(...) statements automatically, for example:
connect(fixed1.flange, spring1.flange_a)
connect(fixed1.flange, damper1.flange_a)
connect(spring1.flange_b, mass1.flange)
connect(damper1.flange_b, mass1.flange)
Step 4: Edit parameters and initial conditions
Edit parameters
- Click the
Springcomponent on the canvas; the properties panel on the right lists its parameters (with units). - Find the parameter
k(spring stiffness) and change the default value to1500.0, unitN/m. - Select
Damperand change the parameterd(damping coefficient) to50.0, unitN·s/m. - Select
Massand change the parameterm(mass) to5.0, unitkg; leave the parameterg(gravitational acceleration) at its default0—this example considers horizontal motion, with no gravity.
Parameter changes sync in real time to the instantiation statements in the Code View, for example:
@named damper1 = ModelingToolkitStandardLibrary.Mechanical.Translational.Damper(d=50)
@named mass1 = ModelingToolkitStandardLibrary.Mechanical.Translational.Mass(g=0, m=5)
@named spring1 = ModelingToolkitStandardLibrary.Mechanical.Translational.Spring(k=1500)

Set the initial condition (excitation)
Under zero initial conditions, a spring-mass-damper system with no deformation and no external force stays still forever—an object at equilibrium has no reason to move. We make the system start from a non-equilibrium state: select spring1 on the canvas, expand the Initial Conditions section in the properties panel on the right, and set an initial value for the state delta_s (the spring's internal deformation coordinate):
spring1.delta_s => 0.2 # initial spring deformation 0.2 m, i.e. an initial restoring force of k·delta_s = 300 N
The simulation is driven by this initial deformation: as the spring returns to its natural length, the mass undergoes decaying oscillation, and the system eventually settles back to equilibrium.
Rebuild tip: the initial condition is stored with the model's graphical state but is not part of the canvas topology—when you rebuild a model (e.g. re-create it on another machine, or redraw it after a reinstall), the components, connections, and parameters all come back, but the initial condition does not; it must be set again. This is the most common cause of "the same model produces only flat lines on another machine". To self-check, look at the
System(...)constructor in the Code View: it should contain the lineinitialization_eqs = [spring1.delta_s ~ 0.2]; if that line is missing, the excitation has not been set.Position semantics tip: the translational component library used here (
Mechanical.Translational) is velocity-based modeling—Fixedconstrains velocity only, no component carries absolute position information, and the mass positionmass1.sis merely the integral of velocity (no restoring force, no reference point). When the spring deformation is released,mass1.stherefore rests at "initial value + 0.2 m" (delta_s + s = constantis conserved throughout): this is the net slippage of the mass as the spring returns to its natural length. Whether the mass is "pulled toward" the wall or "pushed away" from it depends on the mounting orientation—the model itself does not encode that. If you want the position-based picture of "wall at the origin, known spring natural length, mass pulled back to the equilibrium position", use theMechanical.TranslationalModelicacomponent family instead: setspring.s_rel0 = 0and give the mass the initial conditionmass.s = 0.2, and you get the classic picture of "oscillating from 0.2 m of stretch back to 0".
The Initial Conditions box accepts either a number or the name of a model-level parameter (define the parameter under Model Properties first, then reference it by name)—the latter lets parameter sweeps vary the initial state in bulk. Clearing the box restores the component's default guess (all zeros here, so the system stays still).
Step 5: Save the model
Click Save in the top toolbar, or press Ctrl + S. On save, the system:
- Generates the complete
.jlsource file from the current canvas; - Persists the graphical state (nodes, connections, parameters, positions) to the instance database;
- Creates a version snapshot;
- Shows a Saved just now status at the top.
CoModel also autosaves every 5 minutes to prevent accidental loss.

Step 6: Configure and run the simulation
- Click Run Simulation in the top toolbar; the simulation configuration panel opens.
- Configure the following:
- Solver: choose
Tsit5(a non-stiff ODE solver, suitable for this example). - Stop Time:
10.0, units. - Step size / tolerances: keep the defaults.
- Solver: choose
- Click Submit; the simulation job enters the server-side queue.
If the model has unsaved changes, the system saves them first, then submits the simulation job.
How the simulation runs
After submission, you can watch the job status in the bottom status bar or the simulation panel on the right:
- Pending: the job is queued.
- Running: the server-side solving kernel is compiling the system and integrating it.
- Completed: the simulation finished and the results are ready to view.

The first compile is slower: CoModel compiles the model on the server and caches the result. The first run may take a dozen or so seconds; recomputation after parameter changes is significantly faster.
Step 7: View the results
When the simulation completes, the results load automatically. In the results panel you can:
- Select the variables to plot, e.g.
spring1₊delta_s(t)(spring deformation). - Inspect the curves over time.
- Zoom and pan the curves, or export the results as CSV / PNG.
For this example you should see:
- Spring deformation
delta_s: starts at 0.2 m and decays over several cycles (theoretical period about 0.38 s), approaching 0 after roughly 2 s—the spring has returned to its natural length; - Mass position
mass1.s: net slippage from 0 to 0.2 m (see the position-semantics tip in Step 4), a side effect of the deformation release; - Decay rate is set by damping and mass (with these parameters the amplitude drops to about 15% per cycle): the larger the damping, the faster the oscillation decays.

Step 8: Share the model
- Click Share in the top toolbar.
- Enter your colleague's registered email to share the model with them.
- After they sign in, the model appears under the Shared with Me tab on the Models page (read-only), with no local installation of any kind.
FAQ
Ports do not highlight / connection fails while drawing?
- Make sure both ports belong to the same physical domain (all are mechanical translational in this example).
- Make sure the components come from the same subcategory: only Mechanical · Translational components interconnect; Mechanical · Rotational components have different port types.
The simulation reports unconnected required ports?
- Check whether any component has a critical port left unconnected. For example, the
flangeofMassmust connect to at least one mechanical element. - Check the validation results in the bottom status bar; click an error entry to locate the component.
The result curve is a flat zero?
- The system is at equilibrium: with no initial deformation and no external force, a spring-mass-damper system stays still indefinitely.
- Confirm you set a nonzero initial value for
delta_s(e.g.0.2) in the Initial Conditions section ofspring1. - Rebuilt models are the classic trap: dragging a model back together (on a new machine, or after a reinstall) restores the components, connections, and parameters, but not the initial condition—set it again. Check the Code View: the
System(...)constructor should containinitialization_eqs = [spring1.delta_s ~ 0.2], which confirms the excitation is in place.
The result curve is empty?
- Confirm the simulation status is Completed, not Failed or Cancelled.
- Check that you selected the right variables to plot.
Next steps
You have completed your first CoModel model. From here you can:
- Change the initial value of
delta_sto-0.2and watch the response to deformation in the opposite direction, or increaseDamper'sdand watch the oscillation decay faster; - Define a model-level parameter under Model Properties, reference it in the initial condition, and use Parameter Sweeps to study the response across initial deformations in bulk;
- Swap component parameters and observe how the response changes;
- Add more components, such as a second mass or an external force source;
- Import an FMU or an ONNX model and try AI + physics hybrid modeling;
- Read Model Management to learn how to manage and share your models.