Modelica
Modelica is a non-proprietary, object-oriented, equation-based language designed for modeling and simulating complex, heterogeneous physical systems, such as those in mechatronics, process engineering, and multi-domain applications including mechanical, electrical, hydraulic, and thermal components.[1] Developed by the Modelica Association, a non-profit organization based in Linköping, Sweden, it enables acausal modeling through declarative mathematical equations that describe system behavior from first principles, without specifying the direction of causality.[2] This approach facilitates the creation of reusable, modular components and libraries, supporting simulations of large-scale models with over 100,000 equations.[1]
Key features of Modelica include its support for continuous-time, discrete-time, and hybrid systems, including event handling and sampled data processing for control applications.[1] The language uses classes as the fundamental unit for defining models, connectors, functions, and records, with mechanisms like inheritance, redeclaration, and operator overloading to promote extensibility and maintainability.[1] It incorporates expandable connectors for graphical modeling, stream variables for bidirectional flows, and annotations for documentation, visualization, and tool-specific extensions, ensuring balanced models where the number of equations equals unknowns.[1] Additionally, Modelica integrates algorithmic constructs such as loops and conditional statements, alongside external interfaces to languages like C and Fortran, enhancing its versatility for hardware-in-the-loop simulations and embedded systems.[1]
The development of Modelica began in 1996 as a collaborative effort to address limitations in traditional simulation languages, leading to the first specification release in 1997.[2] Governed by the Modelica Association since 2000, the language has evolved through multiple revisions, with the current version 3.6 (as of 2025) released on March 9, 2023, introducing backward-compatible enhancements such as selective model extension, multi-language descriptions, and improved parameter and start-value handling.[1] Earlier milestones include version 3.3 in 2012, which added synchronous elements and state machines, building on foundational work documented in standards and conference proceedings.[1] The specification is maintained openly via GitHub, ensuring backward compatibility and community-driven improvements.[2]
Modelica's standardization promotes interoperability among tools and libraries, with the Modelica Standard Library providing pre-built components for common domains.[2] It is implemented in commercial and open-source tools like Dymola, OpenModelica, and Wolfram SystemModeler, enabling applications in industries such as automotive, aerospace, and energy systems.[2] By emphasizing numerical robustness, symbolic processing, and multi-domain integration, Modelica remains a cornerstone for engineering simulation, supporting efficient model exchange and collaborative development.[1]
Overview
Definition and Purpose
Modelica is an object-oriented, declarative, equation-based language designed for the modeling of cyber-physical systems. It enables the acausal connection of components governed by mathematical equations, allowing models to be constructed from first principles without predefined computational sequences.[3] This approach supports the development of reusable, hierarchical model libraries that can represent complex, heterogeneous systems across multiple physical domains.[4]
The primary purpose of Modelica is to facilitate the simulation and analysis of multi-domain systems, such as those involving mechanical, electrical, thermal, and hydraulic components, by emphasizing modularity and reusability. Unlike traditional imperative simulation languages that require users to specify explicit time-stepping algorithms or causal relationships between variables, Modelica's declarative nature permits modelers to focus on the underlying physics through equations, with the simulation environment handling the transformation into executable code.[3] This results in more maintainable and extensible models, particularly for large-scale engineering applications.[5]
Modelica further enhances interoperability through its integration with the Functional Mock-up Interface (FMI) standard, which allows for the export and exchange of compiled models as functional mock-up units (FMUs) between different tools and platforms.[6] Developed and maintained by the Modelica Association, FMI complements Modelica's equation-based paradigm by enabling co-simulation and model reuse in diverse software ecosystems.[7]
Key Characteristics
Modelica incorporates object-oriented programming principles to facilitate the development and reuse of complex models. It supports classes such as models, blocks, functions, packages, and partial classes, enabling hierarchical structuring and modular design. Inheritance allows derived classes to extend and modify base classes, promoting code reuse without duplication. Encapsulation is achieved through packages for organization and local components for parameterization, while polymorphism is realized via replaceable components that permit flexible substitutions during model instantiation. These features collectively enhance model maintainability and scalability in large-scale simulations.[3]
The language adopts a declarative paradigm, where models are expressed through mathematical equations and constraints rather than imperative algorithms or assignment statements. This approach allows modelers to describe system behavior at a high level of abstraction, leaving the resolution of variable dependencies and computational order to the compiler and solver. Equations can represent differential, algebraic, or discrete relations, supporting symbolic manipulation and transformation into a flat hybrid differential-algebraic equation (DAE) system for efficient simulation.[3]
Modelica's multi-domain capability enables the integrated modeling of heterogeneous physical systems across disciplines like mechanics, electrical engineering, and thermodynamics. This is bolstered by extensive libraries, notably the Modelica Standard Library (MSL), which provides reusable, standardized components for domains including multi-body mechanics (e.g., rigid body dynamics) and electrical circuits (e.g., resistors and inductors). The MSL, maintained by the Modelica Association, ensures compatibility and promotes interoperability among tools and user-contributed libraries.[8][3]
A core distinguishing feature is acausality, which permits equations to be written without specifying input-output causality or solving order. Variables are treated symmetrically, and the simulation environment simultaneously solves the entire system of equations to determine values, accommodating higher-index DAEs and avoiding the need for predefined signal flows. This contrasts with traditional causal modeling languages and aligns closely with physical principles.[3]
Hybrid modeling support allows seamless integration of continuous-time dynamics, discrete events, and finite state machines within a single framework. Continuous aspects are handled via differential equations, while discrete events are triggered using when-clauses for time or state-based conditions, enabling zero-crossing detection and event iteration. State machines are modeled through dedicated libraries like Modelica.StateGraph, which implement hierarchical, reactive behaviors for discrete-event systems. The resulting models are translated into a unified hybrid DAE representation for numerical solution.[3]
Interoperability is ensured through adherence to the Modelica Language Specification, with the latest version 3.7 (development as of November 2025) defining the syntax, semantics, and translation rules. Additionally, Modelica complies with the Functional Mock-up Interface (FMI) standard version 3.0, facilitating model exchange and co-simulation across diverse tools via exportable FMUs (Functional Mock-up Units). This standard, released in 2022 and enhanced in subsequent updates, supports advanced features like variable communication steps and digital signatures for robust system-level integration.[9][10][6]
History and Development
Origins and Early Development
The Modelica design effort originated in the fall of 1996 with the formation of an international design group, initiated by representatives from Lund Institute of Technology, ABB Corporate Research Center in Heidelberg, and Daimler-Benz, among other academic and industrial partners.[11] This group, operating initially under the ESPRIT project "Simulation in Europe Basic Research Working Group (SiE-WG)" and later as a technical committee within Eurosim, was chaired by Hilding Elmqvist of Dynasim AB and included key contributors such as Martin Otter from the German Aerospace Center (DLR) and Peter Fritzson from Linköping University.[12] The collaboration brought together experts in language design, physical modeling, and simulation tools to address fragmented approaches in multi-domain system modeling.[13]
The primary motivations for creating Modelica stemmed from the limitations of proprietary, domain-specific modeling tools prevalent in the 1990s, which hindered model exchange and reuse across different simulation environments.[12] Industry and academia sought a non-proprietary, equation-based language that would enable seamless interoperability, support acausal modeling of complex physical systems, and facilitate the integration of models from diverse domains like mechanics, electrical engineering, and thermodynamics.[14] This effort built on prior experiences with tools like Dymola for acausal, declarative modeling and object-oriented paradigms from languages such as Simula and Smalltalk, aiming to unify these concepts into a standardized framework.[11]
The first draft of the Modelica specification, version 1.0, was completed in September 1997, focusing on continuous-time modeling using differential-algebraic equations (DAEs) and incorporating object-oriented features for component composition.[14] Initial prototype implementations emerged in the late 1990s, including early tools from Dynasim AB and contributions from the design group that demonstrated practical applications, such as modeling automatic gearboxes and heat exchangers.[11] These prototypes validated the language's potential for multi-domain simulations while highlighting needs for further refinements in discrete-event handling and library development.[12]
Standardization and Evolution
The Modelica Association, a non-profit organization, was formed on February 5, 2000, to oversee the maintenance and evolution of the Modelica language specification, ensuring its ongoing development through collaborative efforts.[15] This marked the transition from informal prototypes to a formalized standardization process, with the association managing version releases and incorporating feedback from its members, which include academic institutions and industry partners.[16]
The standardization timeline began with the release of Modelica 1.4 in December 2000, which refined package structures for better organization of models and libraries, building on earlier informal versions from the late 1990s.[15] Subsequent major versions introduced significant enhancements: Modelica 2.0 in January 2002 added support for initialization and graphical annotations, while Modelica 2.2 in February 2005 incorporated arrays, expandable connectors, and conditional components to improve modeling flexibility.[15] Modelica 3.0, released in September 2007, enabled balanced models for handling overdetermined systems and introduced new operators for acausal modeling.[15]
Further evolution continued with Modelica 3.3 in May 2012 (revised July 2014), which added synchronous features and state machines while reducing restrictions on model definitions, and Modelica 3.5, approved in February 2021 with semantics finalized December 2020, which extended backward-compatible features including advanced mathematical functions and pure function refinements.[15] Modelica 3.6, released in March 2023, focused on clarifications and enhancements such as improved exponentiation definitions and predefined type handling to support more robust implementations.[1] As of November 2025, the development version 3.7-dev, updated November 6, 2025, emphasizes annotations for better interoperability and integration with standards like FMI (Functional Mock-up Interface).[9]
Key evolutionary milestones include the introduction of partial classes in early versions for reusable base components, refined package hierarchies in 1.4 for modular libraries, and mechanisms for overdetermined systems in 3.0 to ensure consistent equation balancing.[15] These changes have progressively supported heterogeneous modeling across domains like mechanical, electrical, and thermal systems.
The governance of Modelica standardization follows an open process managed by the Modelica Association, where contributions from industry (e.g., Dassault Systèmes, Siemens) and academia are reviewed via Modelica Change Proposals, ensuring transparency and broad adoption.[16] Recent developments, discussed at the 16th International Modelica and FMI Conference in Lucerne, Switzerland (September 8-10, 2025), highlight enhanced support for heterogeneous models and real-time simulation capabilities in ongoing 3.7 work, alongside proposals for layered standards integrating FMI and SSP (System Structure and Parameterization).[17] Proceedings from the conference, published October 27, 2025, document these advancements.[18]
Language Fundamentals
Syntax Basics
Modelica models are defined as classes using the keywords model or class, which encapsulate declarations, equations, and other elements. The basic structure begins with the keyword model or class followed by an optional identifier for the class name, then a composition section containing elements like declarations and equations, and ends with end followed by the class name if provided. For example:
model Example
// declarations and equations here
end Example;
model Example
// declarations and equations here
end Example;
This structure allows for hierarchical modeling where classes can extend others using the extends keyword to inherit components and behavior.[19]
Declarations within a model or class define variables and components, scoped to the enclosing class unless specified otherwise. Variable scoping follows lexical rules, where names are looked up starting from the current class and proceeding outward to enclosing classes, respecting public and protected visibility; public elements are accessible from enclosing scopes, while protected ones are not. Comments are supported using // for single-line remarks, which extend to the end of the line, or /* */ for multi-line comments that do not nest. Annotations, introduced with the annotation keyword, provide metadata such as graphical layout information, for example, annotation(Placement([transformation](/page/Transformation)(extent={{-10,-10},{10,10}})));.[20][21]
Modelica supports a range of operators for expressions. Arithmetic operators include + for addition, - for subtraction, * for multiplication, and / for division, applicable to numerical types with multiplicative operators having higher precedence than additive ones. Logical operators are and for conjunction, or for disjunction, and not for negation, with not having the highest precedence among them. Relational operators encompass == for equality, < for less than, > for greater than, <= for less than or equal, >= for greater than or equal, and <> for inequality, used for comparing simple types and non-associative with precedence above logical operators but below arithmetic.[22]
The equations section, delimited by the equation keyword, contains declarative equations that define relationships without specifying execution order. Equations use the = operator for equality, such as der(x) = v; to specify the derivative of position as velocity, and are solved simultaneously by the compiler. This section focuses on declarative forms, excluding imperative algorithm statements which are handled separately.[23]
Whitespace, including spaces, tabs, and newlines, serves as a separator and is otherwise ignored, allowing flexible formatting. Identifiers are case-sensitive, distinguishing Variable from variable, while keywords like model and end are case-insensitive.[20]
Types and Declarations
Modelica employs a class-based type system where all data objects, including variables and components, are instances of classes. The language is statically typed, meaning types are determined at compile time without support for dynamic type creation or modification. This ensures type safety and enables advanced features like unit checking during modeling.[24]
The built-in types in Modelica consist of four fundamental predefined classes: Real for floating-point numbers, Integer for whole numbers, Boolean for logical values, and String for text sequences. Additionally, enumeration types allow users to define ordered sets of named literals, such as type Colors = enumeration(red, green, blue);, which can be used to represent discrete states or categories in models. These types form the foundation for all declarations and can be extended or modified as needed.[25]
Derived types build upon the built-in types through modifiers and structures. For instance, units can be attached to Real types using the unit modifier like Real distance(unit="m");, enabling dimensional consistency. Arrays are declared with subscripts, such as Real vector[3]; for a one-dimensional array or Real matrix[2,2]; for multi-dimensional ones, supporting operations like indexing and concatenation. Records provide structured types for grouping related data, declared as record Point Real x; Real y; end Point;, allowing instances like Point p; to encapsulate multiple components.[26]
User-defined types are created using the type keyword to alias or extend existing types, for example, type [Temperature](/page/Temperature) = Real(unit="K");. Replaceable types enhance modularity by allowing customization in subclasses or instances, declared as replaceable type MyType = Real;, where redeclaration can specify a different compatible type during model extension. This mechanism supports polymorphic modeling without altering the core type structure.[24]
Declarations of variables and components include variability prefixes to specify behavior: [parameter](/page/Parameter) for compile-time constants that can be modified at instantiation, as in parameter Real springConstant = 1.0;, and constant for fixed values, often combined with final to prevent redeclaration, such as final constant Real pi = 3.14159;. These prefixes control evaluation timing and mutability, with final ensuring immutability across the model hierarchy.[27]
Modelica provides built-in support for dimensional analysis through unit attributes on types, automatically performing unit checking and implicit conversions during compilation to prevent errors in physical equations. For example, adding a Real with unit "m" and another with unit "cm" triggers conversion to ensure compatibility. This feature is integral to the language's equation-based paradigm, promoting reliable multi-domain modeling.[24]
Key restrictions in Modelica's type system include its static nature, prohibiting runtime type changes or creation of new types dynamically, which aligns with the declarative modeling approach and facilitates efficient compilation and simulation. Declaration order is generally flexible, except in cases like functions where dependencies must be resolved.[24]
Modeling Paradigms
Acausal and Equation-Based Modeling
Modelica's acausal modeling paradigm allows variables to be declared without predefined input or output designations, enabling the solver to determine causal relationships dynamically based on the system's equations. This contrasts with traditional causal languages where signal flow directions must be explicitly specified, freeing modelers to express physical laws naturally without worrying about computational order.[28] In acausal models, all variables are treated as unknowns, and the compiler analyzes dependencies to assign roles during simulation preparation.[1]
The equation-based approach in Modelica represents models as systems of differential-algebraic equations (DAEs), capturing the underlying physics through declarative equations rather than procedural assignments. For instance, a simple mechanical system might be defined by equations such as [m](/page/Mass) \cdot \mathrm{der}([v](/page/Velocity)) = [F](/page/Force) for Newton's second law and \mathrm{der}([s](/page/Position)) = [v](/page/Velocity) for position-velocity relation, where [m](/page/Mass) is mass, [v](/page/Velocity) is velocity, [s](/page/Position) is position, and [F](/page/Force) is force. These equations form a balanced system where the number of equations equals the number of unknowns, allowing symbolic manipulation to resolve the model.[28] The resulting DAEs typically have an index of 1 to 3, depending on the physical domain, and are solved numerically using methods like DASSL or IDA.[29]
To prepare hierarchical models for simulation, Modelica employs a flattening process that expands nested component structures into a single, flat set of equations for symbolic analysis. This involves recursive instantiation of components, substitution of local equations, and resolution of connections, producing an acausal equation system without explicit hierarchies. The flattened model undergoes matching algorithms to pair equations with variables, identifying structural singularities if present.[30]
High-index DAEs in Modelica, common in multibody or electrical systems, require index reduction to ensure numerical solvability, typically achieved via the Pantelides algorithm.[29] The Pantelides method systematically differentiates select equations and introduces derivative variables to lower the index to 1, using bipartite graph matching to detect dependencies.[31] For example, in a mechanical constraint like f(x, \dot{x}) = 0, differentiation yields \frac{d}{dt} f = 0, resolving hidden constraints.[32] This process preserves the model's physical meaning while enabling efficient integration.[29]
Modelica compilers detect and resolve over- and under-determined systems during the matching phase of flattening, ensuring structural balance.[30] An over-determined system, with more equations than variables, triggers redundancy analysis to identify and remove consistent duplicates or flag inconsistencies; symbolic methods propagate values to verify equality.[33] Under-determined systems, with fewer equations, are flagged for missing constraints, prompting modelers to add parameters or equations.[30] These diagnostics prevent simulation errors and maintain model integrity.[33]
Hybrid modeling in Modelica integrates continuous equations with discrete algorithms to handle systems with both smooth dynamics and event-driven behaviors.[34] Continuous equations define the ongoing evolution, while discrete algorithms, often within when-clauses, update variables at events like zero-crossings or clock ticks.[34] At event instants, the solver resolves a mixed system of continuous residuals and discrete assignments, potentially reinitializing states to ensure seamless transitions.[35] This synchronous approach yields deterministic hybrid DAEs, with discrete parts treated as piecewise constant between continuous integrations.[34]
Connectors and Interfaces
In Modelica, connectors are special classes that define interfaces for interacting components, declared using the connector keyword and consisting of public variables representing physical ports or signals.[36] These connectors enable graphical connections via the connect equation, such as connect(component1.port, component2.port), where the components must have compatible structures with matching named elements and dimensions.[37] For instance, an electrical pin connector might be defined as:
connector Pin
Real v;
flow Real i;
end Pin;
connector Pin
Real v;
flow Real i;
end Pin;
This declaration includes a potential variable v for voltage and a flow variable i for current.[38]
Flow variables, marked with the flow prefix, represent conserved quantities like electrical current or mechanical force, following the convention that their sum across a connection equals zero to enforce physical balance.[38] Non-flow (potential) variables, such as voltage or position, are instead equated across connections, ensuring continuity without directional flow.[38] When components are connected, Modelica automatically generates balance equations: for flow variables, the equation is z_1 + z_2 + (-z_3) + \dots + z_n = 0, where signs depend on the connector's inside/outside orientation; for potential variables, it is a_1 = a_2 = \dots = a_n.[38] This mechanism ensures conservation laws are upheld implicitly during simulation.[38]
Expandable connectors, qualified with the expandable keyword, allow dynamic augmentation with additional undeclared variables at connection time, facilitating flexible interfaces like buses.[39] For example, connecting connect(bus.speed, sensor.speed) to an expandable EngineBus connector adds a speed variable if not previously defined, enabling hierarchical signal aggregation without rigid predefined structures.[39] Non-expandable connectors, in contrast, require exact matches of all public elements for compatibility.[40]
Connections in Modelica are inherently acausal, lacking predefined directionality, which allows bidirectional interactions based solely on variable types and balance rules rather than input/output causality.[41] This design supports multi-domain modeling where the solver determines flow directions dynamically, as in connect(load.p, ground.p) for an electrical circuit, equating potentials and summing flows without assuming a source-sink orientation.[38]
For non-physical data exchange, such as control signals, Modelica supports signal connectors using input and output prefixes to impose causality, treating them as directed streams rather than conserved flows.[39] An example is a RealInput speed connector, where connect(source.speed, receiver.speed) propagates the value unidirectionally from output to input, suitable for discrete or event-based interactions outside physical domains.[39]
Component Hierarchies and Composition
In Modelica, components are instantiated within a class through declarations that specify the component's type and optional modifiers to customize its properties. For instance, a resistor component can be declared as Resistor R(R=10);, where Resistor is the class type, R is the instance name, and R=10 is a modifier setting the resistance parameter to 10 ohms. This instantiation process generates an object from the class definition, allowing reuse of predefined models while tailoring them to specific contexts. Component declarations support arrays, conditional inclusion via parameters, and structured types, enabling the composition of complex systems from simpler building blocks.[42]
Hierarchies in Modelica are constructed through nested classes, where components can contain other class instances, fostering modular and scalable model structures. Modifications allow overriding of default values during instantiation or inheritance, such as R(R=20) to adjust a nested resistor's resistance without altering the base class. Redeclarations, marked by the replaceable prefix in the base class, permit replacing entire component types or packages in derived models, enhancing flexibility in composition; for example, redeclare Real x changes a component's type while preserving its role. These mechanisms support deep nesting, where inner declarations can be modified from outer scopes, promoting reuse across model levels.[43][44]
Inheritance is achieved using the extends keyword, which incorporates all public and protected elements from a base class into a derived one, allowing specialization while inheriting behavior. A derived class can override non-final components from the base, such as redefining parameters or equations, and supports multiple inheritance from several base classes, provided name conflicts are resolved. This object-oriented approach enables the creation of extensible model families, where base classes define common interfaces and derived classes add domain-specific details.[45][46]
Packages serve as containers for organizing libraries of classes, functions, and subpackages, facilitating hierarchical structuring of reusable components. For example, the standard Modelica.Mechanics package contains subpackages like Rotational and Translational, allowing users to import and compose mechanical models systematically via clauses such as import Modelica.Mechanics;. Packages can inherit from other packages, ensuring consistent organization, and use protected elements for information hiding to maintain clean interfaces.[47]
Modifiers propagate through hierarchies during instantiation and inheritance, with outer modifications taking precedence over inner defaults to ensure consistent parameterization. The each keyword applies modifiers uniformly to array elements, as in Resistor R[2](each R=10);, streamlining the configuration of repeated components. This propagation mechanism supports balanced models by aligning parameters across nested levels without manual repetition.[48][49]
Partial models act as abstract templates that cannot be directly instantiated but serve as bases for specialization through extension. Declared with the partial prefix, such as partial model Base, they define shared structure and equations for subclasses, promoting reuse in library development; for instance, a partial lumped volume model might specify common thermodynamic parameters without concrete values. Derived models extend these to add specific implementations, ensuring modularity and avoiding redundancy in hierarchical compositions.[50]
Examples
Basic Types and Components
Modelica provides several predefined basic types for modeling, including Real for continuous real-valued quantities, [Integer](/page/Integer) for whole numbers, [String](/page/String) for text, and [Boolean](/page/Boolean) for logical values. These types form the foundation for declaring variables and parameters within models, enabling the representation of physical quantities and constants. For instance, a simple model can declare a Real variable with an initial value and a parameter for a fixed coefficient, as shown below.[51]
modelica
model Simple
Real x(start=0);
parameter Real a = 1;
equation
der(x) = a;
end Simple;
model Simple
Real x(start=0);
parameter Real a = 1;
equation
der(x) = a;
end Simple;
In this example, x is a continuous-time variable initialized to 0, while a is a tunable parameter that remains constant during simulation. The equation defines the derivative of x as equal to a, modeling a basic linear integrator. Such declarations follow the general syntax for components, where variability prefixes like parameter distinguish constants from dynamic variables.[51]
Users can extend the basic types by deriving custom types, often incorporating attributes such as units for dimensional consistency. A common practice is to define a type for electrical potential as follows:
modelica
type Voltage = Real(unit="V");
type Voltage = Real(unit="V");
This user-defined type inherits all properties of Real but adds a unit annotation, facilitating unit checking and documentation in larger models. Derived types promote reusability and clarity, especially in domain-specific libraries.[51]
A practical reusable component built from these types is a basic capacitor model, which relates voltage, charge, and current through fundamental equations. The model declares capacitance as a parameter and uses Real variables for state and inputs:
modelica
model Capacitor
parameter Real C = 1 "[Capacitance](/page/Capacitance) (Farad)";
Real v "Voltage across capacitor";
Real q(start=0) "Charge stored";
input Real i "Current through capacitor";
equation
C * v = q;
der(q) = i;
end Capacitor;
model Capacitor
parameter Real C = 1 "[Capacitance](/page/Capacitance) (Farad)";
Real v "Voltage across capacitor";
Real q(start=0) "Charge stored";
input Real i "Current through capacitor";
equation
C * v = q;
der(q) = i;
end Capacitor;
Here, the equations enforce the constitutive relation C \cdot v = q and the dynamic charge accumulation \frac{dq}{dt} = i, using built-in Real types without external dependencies. This component can be instantiated in simulations to represent electrical storage elements.[51]
To simulate such models, initial conditions are specified via the start attribute in variable declarations, ensuring a well-posed initial value problem for the solver. Conceptually, a tool translates the model equations into a system of differential-algebraic equations, then invokes a numerical solver (e.g., DAE solver) over a specified time interval, such as from 0 to 10 seconds, with adjustable tolerances. No explicit invocation syntax exists in the language itself, as this is handled by the simulation environment.[51]
Post-simulation, the results include time-series data for variables like x or q. Tools typically generate output files or in-memory results, allowing users to plot variables against time—for example, visualizing x as a ramp function in the Simple model or v versus q in the Capacitor—to analyze system behavior and validate the model. Annotations can guide plot configurations, but core output relies on the simulated variable values.[51]
Physical System Interactions
Modelica enables the modeling of physical interactions between components through connectors that define interfaces for effort and flow variables, allowing seamless connection of models across domains. A fundamental example is an electrical circuit comprising a voltage source and a resistor. The basic electrical connector, Pin, declares a potential variable v for voltage and a flow variable i for current, with the flow attribute ensuring conservation laws are applied at connections.[52]
The resistor component implements Ohm's law acausally, relating voltage across its terminals to current through it. The model is defined as follows:
modelica
model Resistor "Ideal linear electrical resistor"
import Modelica.SIunits;
parameter SI.Resistance R(start=1) "Resistance at temperature T_ref";
parameter SI.Temperature T_ref=300.15 "Reference temperature";
parameter SI.LinearTemperatureCoefficient alpha=0
"Temperature coefficient of resistance";
extends Modelica.Electrical.Analog.Interfaces.OnePort;
extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = T_ref);
SI.Resistance R_actual "Actual resistance";
equation
R_actual = R*(1 + alpha*(T_heatPort - T_ref));
v = R_actual * i;
LossPower = v * i;
end Resistor;
model Resistor "Ideal linear electrical resistor"
import Modelica.SIunits;
parameter SI.Resistance R(start=1) "Resistance at temperature T_ref";
parameter SI.Temperature T_ref=300.15 "Reference temperature";
parameter SI.LinearTemperatureCoefficient alpha=0
"Temperature coefficient of resistance";
extends Modelica.Electrical.Analog.Interfaces.OnePort;
extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = T_ref);
SI.Resistance R_actual "Actual resistance";
equation
R_actual = R*(1 + alpha*(T_heatPort - T_ref));
v = R_actual * i;
LossPower = v * i;
end Resistor;
To form a complete circuit, instantiate the resistor and a constant voltage source, connecting them via Pin interfaces and grounding the negative terminals. The connections implicitly enforce Kirchhoff's current law (KCL) through the flow variable i, as the solver generates equations summing currents to zero at each node; similarly, Kirchhoff's voltage law (KVL) arises from the potential variable v equating voltages around loops.[53][54]
For multi-domain interactions, consider a direct current (DC) motor where electrical and mechanical systems couple via an electromotive force (EMF) component. The electrical side includes a voltage source, resistor, and inductor connected to the motor's electrical pins, while the mechanical side features a rotational inertia attached to the motor's rotational flange connector rotFlange. The EMF model translates electrical power (voltage times current) into mechanical torque on the shaft, with the flange defining angular velocity as potential and torque as flow. A sample model connects these as:
modelica
model DCMotorCircuit
Modelica.Electrical.Analog.Basic.[Resistor](/page/Resistor) resistor1(R=10);
Modelica.Electrical.Analog.Basic.[Inductor](/page/Inductor) inductor1(L=0.2);
Modelica.Electrical.Analog.Basic.[Ground](/page/Ground) ground1;
Modelica.Mechanics.Rotational.Components.[Inertia](/page/Inertia) inertia1(J=1);
Modelica.Electrical.Machines.BasicMachines.Components.DCMachines.DCM_ElectricalExcitation emf1;
Modelica.Blocks.Sources.Step step1(height=12);
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage1;
equation
connect(step1.y, signalVoltage1.v);
connect(signalVoltage1.p, resistor1.p);
connect(resistor1.n, inductor1.p);
connect(inductor1.n, emf1.pin_p);
connect(emf1.pin_n, ground1.p);
connect(signalVoltage1.n, ground1.p);
connect(emf1.flange, inertia1.flange_a);
end DCMotorCircuit;
model DCMotorCircuit
Modelica.Electrical.Analog.Basic.[Resistor](/page/Resistor) resistor1(R=10);
Modelica.Electrical.Analog.Basic.[Inductor](/page/Inductor) inductor1(L=0.2);
Modelica.Electrical.Analog.Basic.[Ground](/page/Ground) ground1;
Modelica.Mechanics.Rotational.Components.[Inertia](/page/Inertia) inertia1(J=1);
Modelica.Electrical.Machines.BasicMachines.Components.DCMachines.DCM_ElectricalExcitation emf1;
Modelica.Blocks.Sources.Step step1(height=12);
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage1;
equation
connect(step1.y, signalVoltage1.v);
connect(signalVoltage1.p, resistor1.p);
connect(resistor1.n, inductor1.p);
connect(inductor1.n, emf1.pin_p);
connect(emf1.pin_n, ground1.p);
connect(signalVoltage1.n, ground1.p);
connect(emf1.flange, inertia1.flange_a);
end DCMotorCircuit;
This setup simulates the motor accelerating under applied voltage, demonstrating energy transfer from electrical to mechanical domains.[55]
Event handling in interactive models, such as a simple electrical switch, utilizes when clauses to detect and respond to discrete events like state changes. A basic switch model might monitor time or a control signal to toggle between open and closed states, reinitializing variables if needed to maintain continuity. For instance, the switch could use a when condition based on time exceeding a threshold to activate, combined with conditional equations for conductance. This approach allows hybrid modeling where continuous dynamics pause at events for discrete updates, preventing numerical issues in simulation.[56]
Simulating the voltage source-resistor circuit with a 10 V source and 1 Ω resistor yields a steady-state current of 10 A, as determined by i = \frac{V}{R}, with the solver resolving the acausal equations to balance flows at connections. In the DC motor example, the rotational speed reaches equilibrium based on load inertia and electrical parameters, typically stabilizing after transient buildup.[57]
Hierarchical Model Building
Hierarchical model building in Modelica enables the composition of complex systems by nesting components within higher-level models, leveraging inheritance and instantiation to promote reusability and modularity. This approach allows modelers to construct intricate simulations, such as electrical circuits or mechanical assemblies, by assembling predefined classes while customizing behaviors at each level. For instance, a base model can define common structure, which is then extended or instantiated with specific parameters to form larger systems.[13][58]
A practical example is constructing a full electrical circuit from sub-components. Consider a model for a simple resistor network:
modelica
model ResistorCircuit
import Modelica.Electrical.Analog.Basic;
Basic.Resistor R1(R=100);
Basic.Resistor R2(R=200);
Basic.Resistor R3(R=300);
Basic.Ground ground;
equation
connect(R1.p, R2.p);
connect(R1.p, R3.p);
connect(R2.n, ground.p);
connect(R3.n, ground.p);
end ResistorCircuit;
model ResistorCircuit
import Modelica.Electrical.Analog.Basic;
Basic.Resistor R1(R=100);
Basic.Resistor R2(R=200);
Basic.Resistor R3(R=300);
Basic.Ground ground;
equation
connect(R1.p, R2.p);
connect(R1.p, R3.p);
connect(R2.n, ground.p);
connect(R3.n, ground.p);
end ResistorCircuit;
This hierarchical model instantiates resistors from the library and connects them to simulate voltage division, demonstrating how sub-components form a cohesive circuit without rewriting low-level equations.[13]
Customization occurs through parameter modification in instances, allowing tailored behavior within hierarchies. In the above circuit, an instance might override values, such as ResistorCircuit myCircuit(R1(R=50)), which adjusts R1's resistance while retaining the structural connections. This flexibility supports scenario-specific adaptations, like varying component values for sensitivity analysis, without altering the base model definition.[58][13]
Library usage facilitates integration of validated components, such as those from the Modelica Standard Library (MSL). For mechanical systems, models can import springs or inductors; for example, a damped oscillator might instantiate Modelica.Mechanics.Rotational.Components.[Spring](/page/Spring) and Damper within a rotational frame, connected via flanges to simulate oscillatory motion. This draws on the hierarchical structure of MSL packages like Modelica.[Mechanics](/page/Mechanics).MultiBody.Parts for 3D elements, enabling rapid assembly of physical subsystems.[13][59]
Redeclaration allows swapping component types in hierarchies to explore variations. In an electrical-thermal model like TemperatureElectricalCircuit, resistors can be redeclared as temperature-dependent variants:
modelica
model TemperatureElectricalCircuit
parameter Modelica.SIunits.Temperature Temp = 300.15;
extends BaseCircuit(redeclare Modelica.Electrical.Analog.Semiconductors.TempResistor R1(RT=0.1, Temp=Temp));
// connections inherited from BaseCircuit
end TemperatureElectricalCircuit;
model TemperatureElectricalCircuit
parameter Modelica.SIunits.Temperature Temp = 300.15;
extends BaseCircuit(redeclare Modelica.Electrical.Analog.Semiconductors.TempResistor R1(RT=0.1, Temp=Temp));
// connections inherited from BaseCircuit
end TemperatureElectricalCircuit;
This replaces standard resistors with TempResistor instances, altering resistance based on temperature while preserving the overall circuit topology.[13]
During simulation, hierarchical models are flattened into a single set of equations for efficient numerical solution. For a multi-body system, such as a racing car model composed of chassis, suspensions, and wheels using MSL components like revolute joints and springs, flattening yields a differential-algebraic equation (DAE) system with approximately 30 states and 6,500 algebraic variables from an original structure of 73 bodies and 92 joints. This process, handled by tools like Dymola, enables accurate dynamic simulation of the vehicle's motion under forces, illustrating the scalability of hierarchical composition.[59][13]
Implementations
Compilers and Simulators
Modelica models are compiled and simulated using specialized tools that translate declarative, equation-based descriptions into executable code, enabling the solution of differential-algebraic equation (DAE) systems. These tools handle the complexities of acausal modeling by performing symbolic manipulations to generate efficient numerical solvers, supporting both open-source and commercial implementations. As of November 2025, the ecosystem includes robust options for large-scale simulations, with ongoing advancements in parallel processing and real-time capabilities.[60]
The primary open-source compiler and simulator is OpenModelica, developed by the Open Source Modelica Consortium (version 1.25.5 as of October 2025), which provides a complete environment for parsing, compiling, and simulating Modelica models compliant with the latest language specifications, including Modelica Standard Library (MSL) version 4.1.0.[61][62] Its OpenModelica Compiler (OMC) features a modular architecture with a frontend for parsing and instantiation, a backend for symbolic manipulation and optimization, and code generation to C for execution via integrated DAE solvers. Active development in 2025 has introduced enhancements such as improved parallel equation solving for faster simulations of complex systems, as demonstrated in recent workshops.[63][64][65]
Commercial tools offer advanced features tailored to industrial applications. Dymola (version 2025x as of November 2025), from Dassault Systèmes, excels in multi-body dynamics simulations and includes strong symbolic processing for efficient code generation in C, supporting real-time execution and handling of large hierarchical models.[66] MapleSim (version 2025 as of June 2025), developed by Maplesoft, leverages symbolic computation for equation analysis and integration, enabling customized model reduction and high-fidelity multi-domain simulations with seamless toolchain integration. SimulationX (version 2025 as of September 2025), by ITI GmbH (part of ESI Group), provides a graphically interactive environment for multi-physics modeling, with a Modelica compiler that generates C code for nonlinear system analysis across 1D to 3D domains.[67][68]
The compilation process in Modelica tools typically involves several stages to transform high-level models into simulatable forms. It begins with parsing the Modelica source code to build a symbol table of classes, components, and equations, followed by instantiation and flattening to resolve hierarchies into a single set of equations. Symbolic manipulation then indexes variables, sorts equations, and performs tearing to reduce the DAE system, often generating Jacobian matrices for efficient solving. Code generation produces C or Fortran executables, which are linked to numerical integrators like DASSL or IDA for time-stepping simulation of the resulting ODE or DAE systems. This process ensures scalability, though large models may require optimizations like sparse matrix handling to manage computational demands.[69][70][71]
Interoperability is facilitated through the Functional Mock-up Interface (FMI) standard, which allows Modelica tools to export models as Functional Mock-up Units (FMUs) for co-simulation or model exchange, independent of the originating tool. All major Modelica compilers, including OpenModelica, Dymola, MapleSim, and SimulationX, support FMI 2.0 and 3.0 for importing and exporting FMUs, enabling seamless integration with non-Modelica environments for hybrid simulations. This capability has been pivotal for distributed system modeling since FMI's inception under the Modelica Association.[72][73][74]
Performance considerations focus on managing large-scale models and enabling real-time applications. Tools like Dymola and OpenModelica employ advanced techniques such as dynamic tearing and parallel solving to simulate models with thousands of equations, achieving speeds up to 500 times faster than real-time for building energy systems. Real-time capabilities are supported through fixed-step solvers and code optimizations, as seen in chassis and powertrain benchmarks running on embedded hardware without overruns. For very large models, sparse linear algebra and event reduction further enhance efficiency, though challenges persist in highly nonlinear systems requiring careful model structuring.[75][76][77]
Development Environments
Development environments for Modelica provide integrated graphical and textual interfaces that facilitate the authoring, visualization, debugging, and management of complex models, enabling engineers to leverage the language's acausal and object-oriented capabilities without deep manual coding. These tools typically include diagram editors for component-based assembly, simulation orchestration, and result analysis, supporting both novice users through drag-and-drop workflows and experts via advanced scripting integration. Popular environments such as OMEdit, Dymola, and Wolfram SystemModeler (version 14.3 as of August 2025) dominate the ecosystem, each offering tailored features for industrial and research applications while ensuring compatibility with Modelica standards.[60][78]
OMEdit, the graphical user interface for OpenModelica, serves as an open-source development environment with comprehensive support for model creation, browsing, and simulation. It features a graphical editor for drag-and-drop assembly of components into hierarchical diagrams, a library browser for navigating and instantiating pre-built models, simulation controls for parameter setup and execution, and built-in plotting tools for visualizing results in real-time or post-simulation. OMEdit also supports textual editing of Modelica code alongside graphical views, allowing seamless switching between paradigms for debugging and refinement.[79][80]
Dymola offers a commercial development environment optimized for efficient model building and analysis in Modelica, emphasizing user productivity in multi-domain systems. Its interface includes drag-and-drop modeling for rapid component connection and hierarchy construction, animation capabilities for visualizing dynamic behaviors in mechanical and electrical systems, and integrated optimization tools for parameter tuning and design space exploration. These features enable iterative workflows where models can be tested, refined, and exported directly within the environment, supporting advanced post-processing like sensitivity analysis.[81][82]
Wolfram SystemModeler integrates Modelica modeling with the symbolic computation power of Mathematica, providing a unified platform for both simulation and analytical insights. Users can build models using a drag-and-drop canvas for component placement and connection, then leverage Mathematica's tools for symbolic analysis, such as linearization of system equations or derivation of analytical solutions for steady-state conditions. This tight integration allows for hybrid numerical-symbolic workflows, where simulation results can be automatically processed for optimization or control design without leaving the environment.[83][84]
Common features across Modelica development environments enhance usability and collaboration, including syntax highlighting for code readability, autocompletion for keywords, classes, and components to reduce errors, version control integration with systems like Git for tracking model evolutions, and graphical diagram editing with zoom, pan, and icon customization. These elements streamline the development process, from initial sketching to deployment, while maintaining Modelica's emphasis on reusable, modular designs.[85][86]
Extensibility in Modelica environments is achieved through plugins for adding custom functionalities, such as specialized visualization or export formats, and support for user-defined libraries that extend core Modelica packages. Handling of the Functional Mock-up Interface (FMI) is a key aspect, allowing seamless import and export of models as FMUs for co-simulation across tools, ensuring interoperability in heterogeneous workflows without recompilation.[87][88]
Applications and Use Cases
Industrial Domains
Modelica has found extensive application in the automotive industry for simulating vehicle dynamics and powertrain systems, enabling engineers to model complex interactions such as drivability and handling characteristics. For instance, at Volvo Cars, Modelica-based tools like Dymola are employed for vehicle dynamics simulations and active safety system development, allowing for the integration of multi-domain models that facilitate early-stage design validation.[89] Similarly, BMW utilizes Modelica and the Functional Mock-up Interface (FMI) standard to streamline model integration in powertrain and vehicle system development, reducing efforts in combining components from different domains.[90]
In the aerospace sector, Modelica supports the modeling of flight control systems and thermal management for aircraft, particularly in hybrid-electric propulsion architectures. NASA has applied Modelica to develop flexible model architectures for the X-57 Maxwell electric aircraft demonstrator, simulating distributed propulsion effects and supporting certification processes through multi-physics integration.[91] This approach allows for the hierarchical modeling of aero-propulsion systems, enabling rapid evaluation of control strategies and thermal behaviors in aviation environments.[92]
The energy industry leverages Modelica for simulating power plants and HVAC systems, optimizing efficiency in multi-energy setups. ABB employs Modelica in its OPTIMAX PowerFit platform for real-time control of virtual power plants, integrating diverse energy sources to enhance system flexibility and thermodynamic performance.[93] In HVAC applications, the Modelica Buildings library provides dynamic models for building energy systems, supporting simulations of district heating and cooling to reduce operational costs.[94] For power plants, Modelica models of combined-cycle systems aid in transient analysis and control tuning, as demonstrated in simulations of gas turbine operations.[95]
In manufacturing, Modelica is used for robotics and process control, enabling accurate simulations of industrial manipulators and production lines. Delta robots, common in high-speed assembly tasks, have been modeled and controlled using Modelica to handle dynamic trajectories and impedance adjustments, improving precision in pick-and-place operations.[96] For process control, Modelica implementations of the Tennessee Eastman benchmark process facilitate plant-wide monitoring and fault detection, supporting scalable simulations of chemical manufacturing workflows.[97]
A notable case study involves Modelica in electric vehicle battery modeling, where second-order equivalent circuit models simulate cell dynamics under varying loads, achieving high accuracy for thermal management and state-of-charge estimation in automotive applications.[98] Another example is wind turbine optimization, where Modelica-AeroDyn frameworks enable dynamic simulations of floating offshore wind turbines and multi-rotor configurations.[99]
The adoption of Modelica in these domains yields key benefits, including reduced prototyping time through object-oriented model reuse and rapid integration of multi-physics components, which cuts development cycles by allowing domain experts to collaborate efficiently without vendor lock-in.[28] This multi-physics capability supports seamless simulation of coupled phenomena like mechanical, electrical, and thermal interactions, leading to more robust industrial designs and up to 40% reductions in computational time for large-scale models.[100]
Research and Education
Modelica plays a significant role in academic research, particularly through extensions that enhance its capabilities in control systems and machine learning integration. For control systems, the DEVSLib library provides a framework for modeling hybrid discrete-event and continuous systems using Modelica's object-oriented paradigm, enabling multi-domain simulations of complex control architectures. Recent advancements include hybrid reinforcement learning approaches, such as FMI-based trajectory planning for satellite robotics, which combine Modelica models with learning algorithms to optimize control in dynamic environments. In machine learning, hybrid models blending physical equations from Modelica with trainable neural components have emerged by 2025, exemplified by the SMArtInt+ library that facilitates AI integration for improved simulation accuracy in applications like vehicle dynamics.[101][102][103]
In education, Modelica supports systems engineering curricula at universities, with tools like OpenModelica enabling hands-on student projects in modeling and simulation. At Lund University, Modelica-based environments such as Dymola are integrated into master-level courses on embedded control systems, allowing students to design and simulate multi-domain models. OpenModelica's open-source nature facilitates theses and projects, including translators from Python to Modelica for type-inferred modeling tasks. These applications emphasize practical learning of equation-based modeling for engineering disciplines.[104][105]
The Modelica community fosters research and education through annual conferences, user groups, and open libraries. The International Modelica Conference, held yearly, convenes researchers and educators; the 2025 edition in Lucerne, Switzerland, featured sessions on AI-Modelica hybrids and scalable simulations. Regional user groups, such as the North American Modelica Users Group (NAMUG), organize events and collaborations to advance pedagogical and research applications. Open libraries, hosted by the Modelica Association, provide reusable components across domains, supporting community-driven extensions.[17][106]
Community contributions extend Modelica to custom domains like biology and finance via user-developed libraries. The Physiolibrary offers open-source models for human physiology simulations, including cardiovascular and respiratory systems, enabling research in biomedical engineering. For finance and social systems, the BusinessSimulation library models dynamical processes in economics and ecology, such as stock-flow diagrams for policy analysis. These libraries demonstrate Modelica's adaptability beyond traditional engineering.[107][108]
Key challenges addressed in research and education include teaching acausality and developing scalable solvers. Acausality, a core Modelica feature allowing bidirectional variable flows without predefined inputs/outputs, is taught through tutorials emphasizing reusable components and equation-based reuse over causal assignments. Research on scalable solvers tackles large-scale models, with techniques like sparse linear algebra and array-preserving methods enabling simulations of systems up to one million equations, as in power grid analyses.[109][110]
Future directions in Modelica research explore deeper AI integration, such as zero-shot parameter estimation using transformer-based networks for rapid model calibration in building simulations, and potential interfaces for emerging paradigms like quantum-enhanced computations, building on current hybrid trends.[111]