Modelica Standard Library
The workbench ships with the Modelica Standard Library 4.1.0: Modelica,
ModelicaServices and Complex appear in the package browser next to the bundled
Diokle library, with nothing to install. On the command line, pass an MSL checkout as
extra sources (see Command line).
In plain terms: the Modelica Standard Library is the common collection of ready-made model parts, and its examples come with reference results, the official answers published by the Modelica Association. An example "matches" when Diokle gives the same answers.
Coverage
532 of the 534 MSL 4.1.0 example models run to the end, and 513 of the 534 match the Modelica Association's reference results (see below). Seven more run but are documented exceptions: their reference results look wrong, not the simulation (see Reference exceptions). They include:
Mechanics(Rotational, Translational, MultiBody),Electrical(Analog, Digital, Machines, QuasiStatic machines, PowerConverters, Batteries),Thermal,Blocks,StateGraphand clocked synchronous models;Modelica.Media: IF97 water, R134a, ideal-gas mixtures, moist air and reference air, through compiled run-time functions with exact partial derivatives;- most
Modelica.Fluidsystems; ModelicaStandardTableslookups, replaced by native tables with linear, constant, Akima and Fritsch–Butland smoothness, hold, linear and periodic extrapolation, and time events at breakpoints.
The remaining failures, and what is being done about them, are listed in the Roadmap.
Reference exceptions
These seven examples run to the end but differ from the reference results, and the evidence says the reference is off. They are not counted as matches, and they are not tolerance changes: the comparison stays at the reference's own tolerance.
Fluid.Examples.AST_BatchPlant.Test.TankWithEmptyingPipe1: the reference is about 34 tube widths from the exact closed-form solution, while Diokle matches it.Fluid.Examples.AST_BatchPlant.Test.TanksWithEmptyingPipe1: the reference is about 3.8 tube widths from Diokle's converged solution.Fluid.Examples.AST_BatchPlant.Test.TwoTanksElectrical.Analog.Examples.Lines.CompareLineTrunks: OpenModelica 1.27.1 agrees with Diokle on the travelling-wave front at 716.3 µs, so the reference is the outlier.Magnetic.QuasiStatic.FundamentalWaveIMC_YDandIMC_Transformer: the reference holds rounding noise about 2e-8 where the analytic zero-sequence current is 0.Blocks.Examples.DemoSignalCharacteristic: the reference is offset by about 1.5e-4 from the analytic settled values.
Language features
Each row says what the compiler accepts and where it stops. The numbers count the MSL examples of the matching package that match the reference results (the table in Checked against the reference results has the full breakdown). A feature can be fully supported in the simulator and still be missing from the embedded or CasADi backends, so the last column lists those limits.
| Feature | MSL examples that match | Limits |
|---|---|---|
| Variables, records, arrays, enumerations, connectors and flow variables | Electrical.Analog 51 of 55, Rotational 15 of 17, MultiBody 38 of 42 | none found in the MSL sweep |
| Complex numbers | ComplexBlocks 2 of 2 | none found |
when, pre, edges, reinit, zero-crossing events |
Electrical.Digital 23 of 23 | when in functions is rejected; when equations are left out of the CasADi export with a warning |
Synchronous clocks (sample, Clock) |
Clocked 74 of 77 | clocked equations are rejected by the CasADi export |
State machines (MLS chapter 17: initialState, transition, activeState, …) |
not measured by the MSL examples; the tests are listed on State machines | see State machines for the supported operators and limits |
Streams in Modelica.Fluid |
Fluid 15 of 23 | most start-up transients of the bigger systems still fail or differ |
Modelica.Media (IF97, R134a, ideal-gas and moist-air mixtures) |
Media 21 of 21 | none found |
Tables: CombiTable1D, CombiTimeTable, CombiTable2D |
Blocks 29 of 31 | 2-D tables are rejected by the embedded and CasADi backends; usertab C functions and MATLAB v7.3 files are not supported |
| External C functions | Math 4 of 4, Utilities 3 of 3 | impure external functions are rejected in embedded code; string arrays cannot be arguments |
Functions with algorithms and while loops |
counted in the rows above | a break or return under a run-time condition inside a while loop is not supported; while loops are rejected by the CasADi and embedded backends |
delay() |
counted in the rows above | the simulator supports it; the embedded and CasADi backends reject it |
| FMI 2.0 and 3.0 export, FMU import | see FMI and SSP | a model with FMU components cannot be exported as an FMU, and steady states are not computed for it |
The seven StateGraph examples (a block library built from ordinary equations and events, in
Modelica.StateGraph) match the reference, but they do not exercise the chapter 17 operators.
Features with no row, such as expandable connectors and homotopy(), have not been measured
against the MSL yet, so this table does not claim them.
External C functions and lookup tables
Many MSL models call C functions from the MSL's own C libraries. Diokle implements these natively, following the reference C sources, so the same models run in the browser:
ModelicaRandom: the xorshift64*, xorshift128+ and xorshift1024* generators, the impure random generator and automatic seeds, behindModelica.Math.Randomand theBlocks.Noisesources;ModelicaFFT: the real FFT behindModelica.Math.FastFourierTransform;ModelicaIO: reading and writing real matrices in MATLAB v4, v6 and v7 files;ModelicaInternalandModelicaStrings: printing, files, time and string functions used byModelica.Utilities.
The browser bundle holds the .mo sources. The library's Resources/Data files (tables
and MATLAB files) are not in it: the site serves them next to the bundle, and the page
fetches each one the first time a model reads it, so Utilities.Examples.ReadRealMatrixFromFile
can read its .mat files in the browser too (see
How the browser loads it).
Functions with constant arguments are evaluated once at translation. Functions with hidden state, such as the impure random generator, are never folded or cached.
Lookup tables follow the C tables exactly:
CombiTable1DandCombiTimeTablewith every smoothness kind of the C tables, first and second derivatives, and the C time-event intervals;CombiTable2Dwith bilinear, constant and bivariate Akima interpolation;- tables read from text, CSV and MATLAB v4, v6 and v7 files.
Tables supplied through a usertab C function and MATLAB v7.3 (HDF5) files are not
supported. These additions made 21 more examples match their reference results:
- all
Blocks.Examples.Noisemodels; - the FFT examples,
Rectifier6pulseFFTandRectifier12pulseFFT; Math.Random.Examples.GenerateRandomNumbers;Utilities.Examples.ReadRealMatrixFromFileandWriteRealMatrixToFile;- the excited synchronous machines (
SMEE_*) andRollingWheelSetPulling, after a state-selection fix.
Open the uniform noise example
The state machines of chapter 17 are covered in State machines.
Checked against the reference results
Simulating is not enough: the results have to be right. A nightly CI job simulates every
MSL 4.1.0 example and compares its comparison signals with the Modelica Association's
reference results (MAP-LIB_ReferenceResults, generated with Dymola), and fails if a model
that passed in the committed baseline stops passing. Each example runs with the tolerance its
reference was generated with (the experiment tolerance times 0.1, as recorded in the
reference's creation.txt), on the reference's output grid.
| Result | Models |
|---|---|
| Matches the reference results | 513 |
| Simulates, but a signal differs | 19 |
| Hits the time limit | 2 |
| Does not translate or stops | 0 |
| Total | 534 |
The scoreboard lists every example with its status, the signals that differ and the error text, with a link to open it in the workbench.
The baseline is docs/conformance/msl-4.1.0.json, made by tools/refcompare.py.
Reference results that look wrong
Seven examples do not match, and the evidence says the Modelica Association reference is
off, not Diokle. Their closed-form or converged solutions are given in
the dispute notes in docs/conformance/reference-disputes.md. They are recorded as documented
exceptions and are not counted as matches. No tolerance was loosened to force a match.
- Fluid:
AST_BatchPlant.Test.TankWithEmptyingPipe1,TanksWithEmptyingPipe1,TwoTanks - Electrical:
Analog.Examples.Lines.CompareLineTrunks(OpenModelica agrees with Diokle) - Magnetic:
IMC_YDandIMC_Transformer(rounding noise in the zero-sequence current) - Blocks:
DemoSignalCharacteristic
Not exceptions, still open: Fluid.Examples.ControlledTankSystem.ControlledTanks (its
tolerance explanation did not reproduce) and Fluid.Examples.TraceSubstances.RoomCO2, whose
remaining miss is Diokle's own accuracy at the harness tolerance.
Examples to try
Each link opens the model in the workbench; press ▶ Simulate.
Rotational mechanics: CoupledClutches
Four inertias coupled by three clutches that open and close at set times: a classic test of friction events, stuck and sliding phases.


Open Modelica.Mechanics.Rotational.Examples.CoupledClutches
Analog electronics: ChuaCircuit
A chaotic oscillator. The second subplot plots C2.v against C1.v to show the double
scroll attractor.


Open Modelica.Electrical.Analog.Examples.ChuaCircuit
Control: PID_Controller
A drive train under a PI speed controller, following a kinematic reference profile while a load step hits it.


Open Modelica.Blocks.Examples.PID_Controller
Heat transfer: TwoMasses
Two masses at different temperatures that equalize through a thermal conductor.


Open Modelica.Thermal.HeatTransfer.Examples.TwoMasses
MultiBody: DoublePendulum
Two bodies on revolute joints, with the 3-D animation that every MultiBody result gets.


Open Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum
For full vehicle models built on MultiBody, see Multibody vehicles.
How the browser loads it
The MSL sources are not in the repository. At build time, web/scripts/fetch-msl.mjs
downloads the v4.1.0 release from GitHub and packs its .mo and package.order files into
one gzip bundle (about 2.6 MB; 14.8 MB unpacked) with a content hash in its name. The
workbench downloads it after the Diokle library, unpacks it with
DecompressionStream, and registers every file without parsing it. A light token scan
outlines each file so the package browser lists the whole library within seconds, and a
class is parsed only when it is opened, checked or simulated, together with the classes
it needs.
The same script copies the library's Resources/Data files unchanged to public/msl/data/,
where the site serves them. They are not part of the bundle, so they cost nothing at start-up.
When a translation or a run reads one, for example through Modelica.Utilities.Files.loadResource
and then ModelicaIO_readRealMatrix, the file system of the browser asks the page for it.
The page fetches it from msl/data/ once and keeps it for the session. A file that the
site does not have is reported as not found, as on the command line without the library.

