OCSMP Model Builder Advanced study materials
OCSMP Model Builder Advanced study resources

Co-Simulating a Hybrid Powertrain with an Acausal Modelica Model

OCSMP Model Builder Advanced · Put your knowledge to work in context.

All case studies

Co-Simulating a Hybrid Powertrain with an Acausal Modelica Model

Voltaris is developing a hybrid powertrain. The SysML model has a «HybridPowertrain» block with value properties batteryVoltage, motorTorque, wheelSpeed, and an «Equation» constraint block with three equations. The team wants to co-simulate with a Modelica model from a supplier. The SysML ports are standard flow ports: «in» fuelRate, «out» torque. The Modelica model uses acausal connectors with potential/flow variables and has an algebraic loop. The first export failed: the tool generated a causal interface and the algebraic loop could not be resolved; units were missing on 12 value properties; and the Modelica connector names did not match the SysML port names. The team proposes to rename SysML ports to match Modelica and to add «Modelica» stereotypes to the block. A 2-week integration window remains and the supplier will not change the Modelica model. The co-simulation must run in the loop with the control software test bench.

1. Explain why renaming ports and adding «Modelica» stereotypes will not resolve the export failure. Address causality, units, and the algebraic loop.

Read the worked answer

SysML flow ports are causal: they declare direction and item flow, and the tool can generate a causal interface. Modelica connectors are acausal: a connector pairs potential and flow variables, and the equation system determines direction. Renaming ports to match connector names does not create that pairing, and it does not tell the tool which SysML value property corresponds to which Modelica variable. The «Modelica» stereotype alone is a marker; without a mapping of model elements to Modelica classes, connectors, and variables, it cannot drive a correct export. The algebraic loop is a property of the equation system, not of port names. A causal export tries to order the equations and fails when the loop is not broken; the Modelica side expects the loop to remain and be solved simultaneously or initialized. Units are also semantic: 12 value properties have no «unit», so dimensional consistency cannot be checked and the exporter cannot convert to SI. The failure is therefore a metamodel and mapping failure, not a naming failure.

2. Recommend specific changes to the SysML model that let the supplier's Modelica model be co-simulated unchanged. Include how to treat the 12 unitless value properties and the loop.

Read the worked answer

Model the block as a «ModelicaModel», or a «Block» with «isEncapsulated» and the Modelica profile applied, and represent each acausal connector as a «ModelicaConnector» with a potential variable and a flow variable. Map the SysML flow ports to connector variables explicitly: fuelRate and torque should not be treated as causal in/out at the Modelica boundary; they become variables in the connector. Define value types with «unit» for all 12 properties, using the ISO 80000 library, and type the properties accordingly. Keep the three equations in a «ConstraintBlock» with «Equation» and bind it to the block through «ConstraintProperty»; do not move equations into operations. For the loop, add start values and, if the tool supports it, an initial equation in the constraint block; the exported model should be acausal so the solver can handle the loop. Add a «Rationale» and a «trace» to the supplier model version. This lets the supplier model remain unchanged while the SysML side provides the mapping and units.

3. What integration risks remain, and what validation would you run before the two-week window closes?

Read the worked answer

Remaining risks are unit conversion and sign conventions at the connector, parameter versus variable mismatch, event handling, and solver settings. Before the window closes, build a port mapping table with one row per SysML port, Modelica connector, potential variable, flow variable, unit, and sign. Run a unit-consistency query on the 12 properties and fix any missing or incompatible units. Run a smoke test with a constant input and compare the SysML-side expected outputs with the supplier's standalone results; then run one transient case that exercises the algebraic loop. Check that the loop converges and that start values are honored. Record the mapping table and the test results in the CM baseline, and freeze the interface before the co-simulation with the control test bench. Do not wait for the full test bench to discover a sign error; the constant-input test will expose it cheaply.