Acausal Connector Balancing & Stream Mixing
Implementation: ConnectionSetResolver & IntUnionFind in languages/modelica/src/connections.ts
Academic Citations
Acausal Physical Modeling & Connection Sets
- Mattsson, S. E., Elmqvist, H., & Otter, M. (1998). "Physical system modeling with Modelica."
Control Engineering Practice, 6(4), pp. 501–510.
DOI: 10.1016/S0967-0661(98)00047-1 - Tarjan, R. E. (1975). "Efficiency of a good but not linear set union algorithm."
Journal of the ACM, 22(2), pp. 215–225.
DOI: 10.1145/321879.321884 (Disjoint-Set Union-Find)
Stream Connectors & Convective Transport
- Franke, R., Casella, F., Otter, M., Sielemann, M., Elmqvist, H., Mattsson, S. E., & Olsson, H. (2009). "Stream Connectors - An Extension of Modelica for Device-Oriented Modeling of Convective Transport."
Proceedings of the 7th Modelica Conference, pp. 116–123.
DOI: 10.3384/ecp09430076
Expandable Connectors & Multi-Domain Bus Modeling
- Otter, M., Elmqvist, H., & Mattsson, S. E. (2005). "Object-oriented modeling of bus systems with Modelica."
Proceedings of the 4th Modelica Conference, pp. 295–308.
Paper PDF
ModelScript Architectural Rationale
Unlike classical block diagrams (such as causal signal-flow block diagrams) where connections represent directional causal signal flows (
- Electrical: Voltage
(potential) and Current (flow). - Hydraulic & Pneumatic: Pressure
(potential) and Volume/Mass flow rate (flow). - Translational Mechanics: Position/Velocity
(potential) and Force (flow). - Rotational Mechanics: Angle/Angular velocity
(potential) and Torque (flow). - Thermal & Fluid Transport: Temperature/Enthalpy
(stream) and Heat/Mass flow (flow).
In acausal modeling, connection statements connect(a, b) do not dictate computational causality. The compiler must automatically generate:
- Potential Equality Equations: Enforcing that all across-variables in a connection set share an identical value.
- Kirchhoff Flow Equations: Enforcing conservation of mass, charge, or energy such that all through-variables sum to zero at the junction.
- Convective Stream Transport Equations: Resolving thermodynamic mixing when fluid direction reverses (
) without introducing singular divisions near zero mass flow.
Balancing Algorithm & Mathematical Formulation
1. Disjoint Connection Set Resolution (Union-Find)
The set of all declared connect(c_a, c_b) statements forms an undirected graph. ModelScript partitions all connector references into disjoint equivalence classes using an integer array-based Union-Find with path compression and rank heuristics:
For each connection set
2. Potential Variable Equalization
For every non-flow, non-stream variable
This yields exactly
3. Kirchhoff Flow Variable Balancing
For every flow variable
This yields exactly
4. Stream Variable Convective Transport
For fluid ports, transport enthalpy depends on flow direction:
Direct formulation introduces a discontinuous switch that causes Newton solvers to oscillate around inStream() and actualStream() operators:
Near zero flow (
Upstream & Downstream Integration
| Pipeline Component | Upstream Dependencies | Downstream Consumers |
|---|---|---|
| IntUnionFind | AST connect clauses from Cst | Connection set partition groups |
| Potential Equalizer | Variable causality & variability from QueryEngine | Alias elimination (eliminateArenaAliases) |
| Flow Balancer | Connector definitions | DAEBuilder linear equations |
| Stream Formulator | Fluid connector declarations | PantelidesEngine, Nonlinear tearing loops |

