modelInversion2

Example - Inversion with temperature as iteration variable

Extends from ThermofluidStream.Idealized.Tests.Inversion.BaseClasses.PartialInverse (Base model defining the mixing problem), Modelica.Icons.Example (Icon for runnable examples).

Information

Mixing of two fluid flows A and B. Assuming constant specific heat capacities c_p, the mixing equation is:

      m_flow_A * T_A + m_flow_B * T_B = (m_flow_A + m_flow_B) * T_mix;
    

This equation can be easily solved for a single unknown.

In this test, we solve for the temperature T_B such that the mixing temperature is T_mix = 25 °C. The solution is:

      T_B = ((m_flow_A + m_flow_B) * T_mix - m_flow_A * T_A) / m_flow_B
    = (2*25 - 1*20) / 1 °C
    = 30 °C
    

Dymola uses the temperature sourceB.T0 as the iteration variable and defaults the start value to T0 = 0, which causes the simulation to fail. By specifying sourceB(T0(start=Medium.T_default)), Dymola can solve the 'nonlinear' equation.

Since T0 is protected, giving it a start value generates a warning, and removing the protected modifier would cause an error due to the current implementation of the source. However, using sourceB(T0_var(start=Medium.T_default)) (which is not protected) allows Dymola to solve the nonlinear equation correctly.

Components

TypeNameDefaultDescription
ThermofluidStream.DropOfCommonsdropOfCommons (from PartialInverse)
ThermofluidStream.Boundaries.SourcesourceA (from PartialInverse)
.ThermofluidStream.Idealized.Boundaries.Sink_freesink (from PartialInverse)
ThermofluidStream.Idealized.Topology.JunctionT2junction (from PartialInverse)
ThermofluidStream.Boundaries.SourcesourceB (from PartialInverse)
.ThermofluidStream.Idealized.Boundaries.MassFlowRatemassFlowRateB (from PartialInverse)
.ThermofluidStream.Idealized.Boundaries.MassFlowRatemassFlowRateA (from PartialInverse)
ThermofluidStream.Sensors.SingleSensorSelectsingleSensorSelect (from PartialInverse)
Modelica.Blocks.Math.InverseBlockConstraintsinverseBlockConstraints
Modelica.Blocks.Sources.RealExpressiontemperatureSetpoint

Revisions

  • 2026, by Raphael Gebhart (raphael.gebhart@dlr.de):
    Initial version.