Skip to content

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 (y=f(u)), ModelScript models acausal physical interaction across multi-energy domains:

  • Electrical: Voltage v (potential) and Current i (flow).
  • Hydraulic & Pneumatic: Pressure p (potential) and Volume/Mass flow rate q (flow).
  • Translational Mechanics: Position/Velocity s,v (potential) and Force f (flow).
  • Rotational Mechanics: Angle/Angular velocity ϕ,ω (potential) and Torque τ (flow).
  • Thermal & Fluid Transport: Temperature/Enthalpy h (stream) and Heat/Mass flow m˙ (flow).

In acausal modeling, connection statements connect(a, b) do not dictate computational causality. The compiler must automatically generate:

  1. Potential Equality Equations: Enforcing that all across-variables in a connection set share an identical value.
  2. Kirchhoff Flow Equations: Enforcing conservation of mass, charge, or energy such that all through-variables sum to zero at the junction.
  3. Convective Stream Transport Equations: Resolving thermodynamic mixing when fluid direction reverses (mj≷0) without introducing singular divisions near zero mass flow.

Balancing Algorithm & Mathematical Formulation ​

Rendering diagram...

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:

α(N)≤4for all physical models

For each connection set S={c1,c2,…,cm} of size m:

2. Potential Variable Equalization ​

For every non-flow, non-stream variable v declared inside the connector type:

v(c1)=v(c2)=⋯=v(cm)

This yields exactly m−1 scalar equations. One variable is chosen as the canonical representative, eliminating m−1 redundant states during alias elimination.

3. Kirchhoff Flow Variable Balancing ​

For every flow variable f declared inside the connector type:

∑j=1mf(cj)=0

This yields exactly 1 scalar conservation equation per connection set. If an inside-outside connector hierarchy boundary is crossed, the outer flow sign is inverted to preserve directional conservation:

fouter=∑j∈innerf(cj)

4. Stream Variable Convective Transport ​

For fluid ports, transport enthalpy depends on flow direction:

htransported={hupstreamif m˙>0hdownstreamif m˙<0

Direct formulation introduces a discontinuous switch that causes Newton solvers to oscillate around m˙=0. ModelScript lowers stream variables using Franke's regularized inStream() and actualStream() operators:

inStream(ci.h)=∑j≠i,m˙j>0m˙j⋅cj.h∑j≠i,m˙j>0m˙j

Near zero flow (∥m˙j∥<ϵ), smooth polynomial regularization is applied to maintain C1-continuity of the residual Jacobian.


Upstream & Downstream Integration ​

Pipeline ComponentUpstream DependenciesDownstream Consumers
IntUnionFindAST connect clauses from CstConnection set partition groups
Potential EqualizerVariable causality & variability from QueryEngineAlias elimination (eliminateArenaAliases)
Flow BalancerConnector definitionsDAEBuilder linear equations
Stream FormulatorFluid connector declarationsPantelidesEngine, Nonlinear tearing loops

Open-Core under the GNU AGPL v3 License; Enterprise Edition (ee/) under the ModelScript Enterprise License. • Trademark Policy