OpenModelica on cloudHPC: The Essential Commands (and a Model to Try Them On)

Published by Ruggero Poletto on

Multi-domain physical system modeling โ€” electrical, mechanical, thermal, hydraulic, control โ€” often gets split across separate tools that don’t talk to each other well. OpenModelica, the open-source implementation of the Modelica language developed by the Open Source Modelica Consortium (OSMC), was built to solve exactly that problem: one equation-based language, one solver stack, and models that can mix domains freely (a motor with its control loop and its cooling circuit, for example, all in the same file).

It’s free, actively maintained (the current stable release is 1.26.3), and it scales naturally onto cloud infrastructure โ€” which is where it becomes genuinely useful for teams who don’t want to babysit a workstation through a long parameter sweep. Below is a practical walkthrough of the commands you’ll actually use day to day, followed by a working example you can drop straight into OpenModelica or into a cloudHPC session.

Three ways to talk to the compiler

OpenModelica’s compiler (omc) can be driven in three ways, and it’s worth knowing all three because they suit different stages of a project:

  • OMEdit โ€” the graphical editor. Best for building models visually, wiring up connectors, and browsing the Modelica Standard Library while you’re still exploring a system’s structure.
  • OMShell / .mos scripts โ€” a command-line interpreter that accepts the OpenModelica Scripting API directly. This is the workhorse for anything repeatable: batch runs, CI pipelines, remote execution on a cloud instance.
  • Language bindings (Python via OMPython, Julia via OMJulia, MATLAB) โ€” for when simulation needs to be embedded in a larger workflow: optimization loops, surrogate-model training, design-of-experiments sweeps.

For cloud and batch work โ€” which is most of what you’ll do on a headless instance โ€” the scripting API is the one to actually learn.

The commands that matter

A handful of scripting API calls cover the vast majority of real work:

CommandWhat it does
loadModel(Modelica)Loads the Modelica Standard Library (almost always your first line)
loadFile("path/to/File.mo")Loads your own model file(s)
checkModel(Model.Name)Validates that a model is well-formed before you spend time compiling it
instantiateModel(Model.Name)Flattens the model to its underlying equations โ€” useful for debugging structural issues
simulate(Model.Name, stopTime=10, tolerance=1e-6)Compiles and runs the simulation, returns a result record with the path to the results file
buildModel(Model.Name)Compiles to an executable without running it โ€” lets you launch it separately with -override flags for parameter sweeps
getErrorString()Prints the compiler’s error/warning buffer โ€” the first thing to call when something silently fails
plot({var1, var2})Quick-look plotting straight from the shell (OMShell/OMEdit only)

A minimal .mos script that loads, checks, and simulates a model looks like this:

loadModel(Modelica); getErrorString();
loadFile("MyLibrary.mo"); getErrorString();
checkModel(MyLibrary.MyModel); getErrorString();
simulate(MyLibrary.MyModel, stopTime=20, tolerance=1e-6, outputFormat="csv");
getErrorString();

Run it non-interactively with:

omc MyScript.mos

That last part โ€” non-interactive, scriptable, CSV output โ€” is exactly what makes OpenModelica a good fit for a cloud batch environment: you can queue dozens of parameter variations, each as its own .mos job, and let compute nodes chew through them in parallel instead of running them one at a time on a laptop.

A working example: RLC circuit with a switch

Here’s a small but non-trivial model โ€” an RLC circuit with a load that switches in halfway through the simulation. It exercises components from three domains-adjacent libraries at once (electrical components, a boolean-driven switch, and a simple event) and is a good sanity check that your environment is set up correctly.

model RLCSwitch
  "Series RLC circuit with a load that switches in at t = 0.5 s"

  Modelica.Electrical.Analog.Basic.Resistor R1(R=100)
    annotation(Placement(transformation(extent={{-40,20},{-20,40}})));
  Modelica.Electrical.Analog.Basic.Inductor L1(L=0.1)
    annotation(Placement(transformation(extent={{0,20},{20,40}})));
  Modelica.Electrical.Analog.Basic.Capacitor C1(C=1e-4)
    annotation(Placement(transformation(extent={{40,20},{60,40}})));
  Modelica.Electrical.Analog.Basic.Resistor R_load(R=50)
    annotation(Placement(transformation(extent={{40,-20},{60,0}})));
  Modelica.Electrical.Analog.Ideal.IdealClosingSwitch sw(Ron=1e-3, Goff=1e-6)
    annotation(Placement(transformation(extent={{0,-20},{20,0}})));
  Modelica.Electrical.Analog.Sources.StepVoltage V(V=12, startTime=0)
    annotation(Placement(transformation(extent={{-80,-10},{-60,10}})));
  Modelica.Electrical.Analog.Basic.Ground gnd
    annotation(Placement(transformation(extent={{-80,-40},{-60,-20}})));
  Modelica.Blocks.Sources.BooleanStep switchSignal(startTime=0.5, startValue=false)
    annotation(Placement(transformation(extent={{-40,-60},{-20,-40}})));

equation
  connect(V.p, R1.p);
  connect(R1.n, L1.p);
  connect(L1.n, C1.p);
  connect(C1.n, V.n);
  connect(V.n, gnd.p);
  connect(sw.p, L1.n);
  connect(sw.n, R_load.p);
  connect(R_load.n, V.n);
  connect(switchSignal.y, sw.control);

  annotation(experiment(StopTime=2, Tolerance=1e-6));
end RLCSwitch;

Save it as RLCSwitch.mo and run:

loadModel(Modelica);
loadFile("RLCSwitch.mo");
simulate(RLCSwitch, stopTime=2, tolerance=1e-6, outputFormat="csv");
getErrorString();

You should see current flow through R1, L1, C1 build up under the step voltage, then a visible transient at t = 0.5 s when the load switches in and the circuit’s time constant changes.

Where cloud infrastructure actually helps

A single circuit like the one above runs in well under a second on a laptop โ€” that’s not where OpenModelica needs a cloud platform. Where it matters is:

  • Parameter sweeps and Monte Carlo studies, where the same model needs to run hundreds or thousands of times with varying parameters, and each run is embarrassingly parallel across cores or nodes.
  • Large, stiff, or long-horizon models (detailed thermal-hydraulic plant models, multi-body drivetrains with many degrees of freedom) where a single run can be memory- or time-intensive.
  • Reproducible, versioned environments โ€” pinning an exact OpenModelica build and library set so a colleague’s simulation results match yours six months later, without “works on my machine” issues.
  • Headless CI-style validation, where every commit to a model library triggers checkModel and a regression simulation automatically.

On cloudHPC, an OpenModelica environment can be spun up on demand, sized to the job (more cores for a sweep, more RAM for a large model), and torn down when it’s done โ€” so you’re not paying for idle compute between simulation campaigns, and you’re not limited by whatever happens to be installed on a local workstation.


Working with Modelica-based system models and want to move batch simulation off individual laptops? cloudhpc.cloud provides on-demand, pre-configured simulation environments for OpenModelica alongside CFD and FEA workloads.


CloudHPC is a HPC provider to run engineering simulations on the cloud. CloudHPC provides from 1 to 224 vCPUs for each process in several configuration of HPC infrastructure - both multi-thread and multi-core. Current software ranges includes several CAE, CFD, FEA, FEM software among which OpenFOAM, FDS, Blender and several others.

New users benefit of a FREE trial of 300 vCPU/Hours to be used on the platform in order to test the platform, all each features and verify if it is suitable for their needs


Categories: openmodelica