Skip to content

Commit

Permalink
displayInstanceName for Unidirected Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGebhart committed Mar 4, 2024
1 parent 925d3e7 commit 484d2c2
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 51 deletions.
4 changes: 2 additions & 2 deletions ThermofluidStream/Boundaries/Reservoir.mo
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ equation
extent={{-150,140},{150,100}},
textString="%name",
textColor={0,0,255}),
Line(visible= not displayInstanceName and pEnvFromInput, points={{0,130},{0,80}}, color={0,0,127}),
Ellipse(
extent={{-54,-26},{54,26}},
lineColor={28,108,200},
Expand All @@ -77,8 +78,7 @@ equation
lineColor={28,108,200},
lineThickness=0.5,
fillColor={170,213,255},
fillPattern=FillPattern.Solid),
Line(visible= not displayInstanceName and pEnvFromInput, points={{0,130},{0,80}}, color={0,0,127})}),
fillPattern=FillPattern.Solid)}),
Diagram(coordinateSystem(preserveAspectRatio=false)),
Documentation(info="<html>
<p>
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/Sensors/MultiSensor_Tpm.mo
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ equation

annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Text(visible=displayInstanceName,
extent={{-150,140},{150,100}},
extent={{-150,-160},{150,-120}},
textString="%name",
textColor={0,0,255}),
Rectangle(
Expand Down
109 changes: 107 additions & 2 deletions ThermofluidStream/TestIcons.mo
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,60 @@ model TestIcons
Topology.Variants.JunctionX1v2 junctionX1new annotation (Placement(transformation(extent={{-280,60},{-260,80}})));
Topology.Variants.JunctionX2v2 junctionX2v2 annotation (Placement(transformation(extent={{-280,20},{-260,40}})));
Topology.Variants.JunctionX3v2 junctionX3new annotation (Placement(transformation(extent={{-280,-20},{-260,0}})));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-540,-300},{420,520}}), graphics={
Undirected.Interfaces.Rear rear annotation (Placement(transformation(extent={{-200,420},{-160,460}})));
Undirected.Interfaces.Fore fore annotation (Placement(transformation(extent={{-160,420},{-120,460}})));
Undirected.Boundaries.BoundaryRear boundaryRear annotation (Placement(transformation(extent={{-520,-440},{-500,-420}})));
Undirected.Boundaries.BoundaryFore boundaryFore annotation (Placement(transformation(extent={{-480,-440},{-460,-420}})));
Undirected.Boundaries.TerminalRear terminalRear annotation (Placement(transformation(extent={{-440,-440},{-420,-420}})));
Undirected.Boundaries.TerminalFore terminalFore annotation (Placement(transformation(extent={{-400,-440},{-380,-420}})));
Undirected.Boundaries.Volume volume1 annotation (Placement(transformation(extent={{-360,-440},{-340,-420}})));
Undirected.Boundaries.VolumeFlex volumeFlex1 annotation (Placement(transformation(extent={{-320,-440},{-300,-420}})));
Undirected.Boundaries.VolumeMix volumeMix1 annotation (Placement(transformation(extent={{-520,-480},{-500,-460}})));
Undirected.Boundaries.PhaseSeparator phaseSeparator1 annotation (Placement(transformation(extent={{-478,-480},{-458,-460}})));
Undirected.Boundaries.Reservoir reservoir3 annotation (Placement(transformation(extent={{-440,-480},{-420,-460}})));
Undirected.Boundaries.Reservoir reservoir4(pEnvFromInput=true) annotation (Placement(transformation(extent={{-400,-480},{-380,-460}})));
Undirected.Boundaries.Reservoir reservoir5(displayInstanceName=false, pEnvFromInput=true) annotation (Placement(transformation(extent={{-360,-480},{-340,-460}})));
Boundaries.CreateState createState1 annotation (Placement(transformation(extent={{-320,-480},{-300,-460}})));
Undirected.Topology.JunctionMN junctionMN annotation (Placement(transformation(extent={{-240,-440},{-220,-420}})));
Undirected.Topology.ConnectInletFore connectInletFore annotation (Placement(transformation(extent={{-200,-440},{-180,-420}})));
Undirected.Topology.ConnectInletRear connectInletRear annotation (Placement(transformation(extent={{-160,-440},{-140,-420}})));
Undirected.Topology.ConnectRearOutlet connectRearOutlet annotation (Placement(transformation(extent={{-120,-440},{-100,-420}})));
Undirected.Topology.ConnectForeOutlet connectForeOutlet annotation (Placement(transformation(extent={{-80,-440},{-60,-420}})));
Undirected.Topology.ConnectForeFore connectForeFore annotation (Placement(transformation(extent={{-40,-440},{-20,-420}})));
Undirected.Topology.ConnectRearRear connectRearRear annotation (Placement(transformation(extent={{0,-440},{20,-420}})));
Undirected.Topology.ConnectorInletOutletFore connectorInletOutletFore annotation (Placement(transformation(extent={{40,-440},{60,-420}})));
Undirected.Topology.JunctionRFF junctionRFF annotation (Placement(transformation(extent={{-240,-480},{-220,-460}})));
Undirected.Topology.JunctionRFF2 junctionRFF2_1 annotation (Placement(transformation(extent={{-200,-480},{-180,-460}})));
Undirected.Topology.JunctionRRF junctionRRF annotation (Placement(transformation(extent={{-160,-480},{-140,-460}})));
Undirected.Topology.JunctionRRF2 junctionRRF2_1 annotation (Placement(transformation(extent={{-120,-480},{-100,-460}})));
Undirected.Topology.JunctionRFFF junctionRFFF annotation (Placement(transformation(extent={{-80,-480},{-60,-460}})));
Undirected.Topology.JunctionRRFF junctionRRFF annotation (Placement(transformation(extent={{-40,-480},{-20,-460}})));
Undirected.Topology.JunctionRRFF2 junctionRRFF2_1 annotation (Placement(transformation(extent={{0,-480},{20,-460}})));
Undirected.Topology.JunctionRRRF junctionRRRF annotation (Placement(transformation(extent={{40,-480},{60,-460}})));
Undirected.Processes.FlowResistance flowResistance1 annotation (Placement(transformation(extent={{120,-440},{140,-420}})));
Undirected.Processes.TransportDelay transportDelay1 annotation (Placement(transformation(extent={{160,-440},{180,-420}})));
Undirected.Processes.ConductionElement conductionElement1 annotation (Placement(transformation(extent={{200,-440},{220,-420}})));
Undirected.HeatExchangers.DiscretizedCrossFlowHEX discretizedCrossFlowHEX1 annotation (Placement(transformation(extent={{280,-440},{300,-420}})));
Undirected.HeatExchangers.DiscretizedCounterFlowHEX discretizedCounterFlowHEX1 annotation (Placement(transformation(extent={{320,-440},{340,-420}})));
Undirected.FlowControl.BasicControlValve basicControlValve1 annotation (Placement(transformation(extent={{-500,-580},{-480,-560}})));
Undirected.FlowControl.SpecificValveType specificValveType1 annotation (Placement(transformation(extent={{-460,-580},{-440,-560}})));
Undirected.FlowControl.TanValve tanValve1 annotation (Placement(transformation(extent={{-420,-580},{-400,-560}})));
Undirected.FlowControl.MCV mCV3(setpointFromInput=true, enableClippingOutput=true) annotation (Placement(transformation(extent={{-500,-620},{-480,-600}})));
Undirected.FlowControl.CheckValve checkValve1 annotation (Placement(transformation(extent={{-420,-620},{-400,-600}})));
Undirected.FlowControl.MCV mCV4(
displayInstanceName=false,
setpointFromInput=true,
enableClippingOutput=true) annotation (Placement(transformation(extent={{-460,-620},{-440,-600}})));
Undirected.Sensors.SingleSensorSelect singleSensorSelect3(outputValue=true) annotation (Placement(transformation(extent={{-360,-560},{-340,-540}})));
Undirected.Sensors.TwoPhaseSensorSelect twoPhaseSensorSelect2(outputValue=true) annotation (Placement(transformation(extent={{-320,-560},{-300,-540}})));
Undirected.Sensors.SensorState sensorState2 annotation (Placement(transformation(extent={{-280,-560},{-260,-540}})));
Undirected.Sensors.SingleSensorX singleSensorX2 annotation (Placement(transformation(extent={{-360,-590},{-340,-570}})));
Undirected.Sensors.MultiSensor_Tpm multiSensor_Tpm2 annotation (Placement(transformation(extent={{-320,-590},{-300,-570}})));
Undirected.Sensors.MultiSensor_Tpm multiSensor_Tpm3(
outputTemperature=true,
outputPressure=true,
outputMassFlowRate=true) annotation (Placement(transformation(extent={{-280,-590},{-260,-570}})));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-540,-780},{420,520}}), graphics={
Rectangle(
extent={{-566,390},{430,344}},
lineColor={28,108,200},
Expand Down Expand Up @@ -286,5 +339,57 @@ are marked with the red square?"),
Text(
extent={{-558,400},{418,340}},
textColor={28,108,200},
textString="Mark everything exept interfaces to check if displayInstanceName works")}));
textString="Mark everything exept interfaces to check if displayInstanceName works"),
Text(
extent={{-540,-280},{420,-340}},
textColor={28,108,200},
textString="Undirected"),
Text(
extent={{-200,500},{-120,480}},
textColor={28,108,200},
textString="Interfaces"),
Rectangle(
extent={{-120,400},{-200,480}},
lineColor={28,108,200},
lineThickness=1),
Rectangle(
extent={{-280,-500},{-540,-400}},
lineColor={28,108,200},
lineThickness=1),
Text(
extent={{-540,-380},{-280,-400}},
textColor={28,108,200},
textString="Boundaries"),
Rectangle(
extent={{80,-502},{-260,-400}},
lineColor={28,108,200},
lineThickness=1),
Text(
extent={{-260,-380},{80,-400}},
textColor={28,108,200},
textString="Topology"),
Rectangle(
extent={{240,-460},{100,-400}},
lineColor={28,108,200},
lineThickness=1),
Text(
extent={{100,-380},{240,-400}},
textColor={28,108,200},
textString="Processes"),
Rectangle(
extent={{360,-460},{260,-400}},
lineColor={28,108,200},
lineThickness=1),
Text(
extent={{260,-360},{360,-400}},
textColor={28,108,200},
textString="HeatExchangers"),
Text(
extent={{-520,-522},{-380,-540}},
textColor={28,108,200},
textString="FlowControl"),
Rectangle(
extent={{-380,-640},{-520,-540}},
lineColor={28,108,200},
lineThickness=1)}));
end TestIcons;
7 changes: 5 additions & 2 deletions ThermofluidStream/Undirected/Boundaries/Reservoir.mo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ model Reservoir "Model of a reservoir"
Modelica.Blocks.Interfaces.RealInput pEnv_input(unit="Pa") = p_env if pEnvFromInput "Environmental pressure [Pa]"
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=270,
origin={0,100})));
origin={0,100}), iconTransformation(
extent={{-20,-20},{20,20}},
rotation=270,
origin={0,145})));

SI.Height height;

Expand Down Expand Up @@ -50,7 +53,7 @@ equation
extent={{-150,140},{150,100}},
textString="%name",
textColor={0,0,255}),
Line(visible= not displayInstanceName and pEnvFromInput, points={{0,130},{0,80}}, color={0,0,127}),
Line(visible= not displayInstanceName and pEnvFromInput, points={{0,130},{0,80}}, color={0,0,127}),
Ellipse(
extent={{-54,-26},{54,26}},
lineColor={28,108,200},
Expand Down
4 changes: 4 additions & 0 deletions ThermofluidStream/Undirected/FlowControl/TanValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ equation
Xi_rear_out = Xi_fore_in;

annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Text(visible=displayInstanceName,
extent={{-150,-60},{150,-100}},
textString="%name",
textColor={0,0,255}),
Line(
points={{-84,0},{-40,0}},
color={28,108,200},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,9 @@ fluid long-term. While this enforces long-term conservation of energy, it
changes the medium-/short-term dynamics of the system and is, therefore,
disabled by default.
</p>
</html>"));
</html>"), Icon(graphics={
Text(visible=displayInstanceName,
extent={{-150,150},{150,110}},
textString="%name",
textColor={0,0,255})}));
end PartialDiscretizedHEX;
104 changes: 83 additions & 21 deletions ThermofluidStream/Undirected/Sensors/MultiSensor_Tpm.mo
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
within ThermofluidStream.Undirected.Sensors;
model MultiSensor_Tpm "Undirected Sensor for Temperature, pressure and mass-flow"
extends Internal.PartialSensor;
extends ThermofluidStream.Utilities.DisplayInstanceNameIndividually; //Define the display of the instance name for your component.

replaceable package Medium = Media.myMedia.Interfaces.PartialMedium
"Medium model" annotation (choicesAllMatching=true, Documentation(
info="<html>
<p>Replaceable medium package for the sensor.</p>
</html>"));

parameter Integer digits(min=0) = 1 "Number of displayed digits"
annotation(Dialog(group="Sensor display"));
parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "Regularization threshold of mass flow rate"
annotation(Dialog(tab="Advanced", group="Regularization"));

Interfaces.Rear rear(redeclare package Medium = Medium)
annotation (Placement(transformation(extent={{-20,-20},{20,20}}, origin={-100,-100}),iconTransformation(extent={{-120,-120},{-80,-80}})));
Interfaces.Fore fore(redeclare package Medium = Medium)
annotation (Placement(transformation(extent={{-20,-20},{20,20}}, origin={100,-100}),iconTransformation(extent={{80,-120},{120,-80}})));

/* function regStepSt = Undirected.Internal.regStepState (
redeclare package Medium = Medium) "RegStep function for a state"
annotation (Documentation(info="<html>
<p><span style=\"font-family: Courier New;\">RegStep function for a state. The medium of the sensor is used and given to the function.</span></p>
</html>"));
*/
Medium.ThermodynamicState state = Medium.setState_phX(p_reg, h_reg, Xi_reg); //= regStepSt(rear.m_flow, rear.state_forwards, rear.state_rearwards, m_flow_reg);

protected
SI.Pressure p_reg= Undirected.Internal.regStep(rear.m_flow, Medium.pressure(rear.state_forwards), Medium.pressure(rear.state_rearwards), m_flow_reg);
SI.SpecificEnthalpy h_reg = Undirected.Internal.regStep(rear.m_flow, Medium.specificEnthalpy(rear.state_forwards), Medium.specificEnthalpy(rear.state_rearwards), m_flow_reg);
Medium.MassFraction Xi_reg[Medium.nXi];

Medium.MassFraction Xi_forwards[Medium.nXi] = Medium.massFraction(rear.state_forwards);
Medium.MassFraction Xi_rearwards[Medium.nXi] = Medium.massFraction(rear.state_rearwards);



import InitMode = ThermofluidStream.Sensors.Internal.Types.InitializationModelSensor;

public
parameter ThermofluidStream.Sensors.Internal.Types.TemperatureUnit temperatureUnit="K" "Unit for the temperature output"
annotation (
Dialog(group="Units"),
Expand Down Expand Up @@ -37,14 +72,14 @@ model MultiSensor_Tpm "Undirected Sensor for Temperature, pressure and mass-flow

Modelica.Blocks.Interfaces.RealOutput T_out(final quantity="ThermodynamicTemperature", final unit=temperatureUnit) = T if outputTemperature "Measured temperature [variable]"
annotation (Placement(transformation(extent={{-20,-20},{20,20}}, origin={100,60}),
iconTransformation(extent={{70,70},{90,90}})));
iconTransformation(extent={{70,50},{90,70}})));
Modelica.Blocks.Interfaces.RealOutput p_out(final quantity="Pressure", final unit=pressureUnit) = p if outputPressure "Measured pressure [variable]"
annotation (Placement(transformation(extent={{-10,-10},{10,10}}, origin={82,20}),
iconTransformation(extent={{72,10},{92,30}})));
annotation (Placement(transformation(extent={{-10,-10},{10,10}}, origin={82,0}),
iconTransformation(extent={{72,-10},{92,10}})));
Modelica.Blocks.Interfaces.RealOutput m_flow_out(unit="kg/s") = m_flow if outputMassFlowRate
"Measured mass-flow [kg/s]"
annotation (Placement(transformation(extent={{-20,-20},{20,20}}, origin={100,-60}),
iconTransformation(extent={{72,-50},{92,-30}})));
iconTransformation(extent={{72,-70},{92,-50}})));

output Real p(final quantity="Pressure", final unit=pressureUnit);
output Real T(final quantity="ThermodynamicTemperature", final unit=temperatureUnit);
Expand All @@ -67,6 +102,16 @@ initial equation
end if;

equation
for i in 1:Medium.nXi loop
Xi_reg[i] = Undirected.Internal.regStep(rear.m_flow, Xi_forwards[i], Xi_rearwards[i], m_flow_reg);
end for;

fore.state_forwards = rear.state_forwards;
rear.state_rearwards = fore.state_rearwards;
fore.r = rear.r;
fore.m_flow + rear.m_flow = 0;


if temperatureUnit == "K" then
direct_T =Medium.temperature(state);
elseif temperatureUnit == "degC" then
Expand Down Expand Up @@ -96,54 +141,71 @@ equation
end if;

annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Text(visible=displayInstanceName,
extent={{-150,-160},{150,-120}},
textString="%name",
textColor={0,0,255}),
Rectangle(
extent={{-54,94},{66,-66}},
extent={{-54,74},{66,-86}},
lineColor={0,0,0},
fillColor={215,215,215},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Rectangle(
extent={{-60,100},{60,-60}},
extent={{-60,80},{60,-80}},
lineColor={0,0,0},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(points={{0,-60},{0,-80}}, color={0,0,0}),
Ellipse(
extent={{-6,-74},{6,-86}},
lineColor={28,108,200},
fillColor={170,213,255},
fillPattern=FillPattern.Solid,
lineThickness=0.5),
Line(points={{0,-80},{0,-100}},color={0,0,0}),
Text(
extent={{-60,100},{60,50}},
extent={{-60,80},{60,30}},
textColor={28,108,200},
textString=DynamicSelect("T", String(
T,
format="1."+String(digits)+"f"))),
Text(
extent={{-60,50},{60,0}},
extent={{-60,30},{60,-20}},
textColor={28,108,200},
textString=DynamicSelect("p", String(
p,
format="1."+String(digits)+"f"))),
Text(
extent={{-60,0},{60,-50}},
extent={{-60,-20},{60,-70}},
textColor={28,108,200},
textString=DynamicSelect("m", String(
m_flow,
format="1."+String(digits)+"f"))),
Text(
extent={{-120,100},{-60,48}},
extent={{-120,80},{-60,28}},
textColor={175,175,175},
textString="%temperatureUnit"),
Text(
extent={{-120,52},{-60,0}},
extent={{-120,32},{-60,-20}},
textColor={175,175,175},
textString="%pressureUnit"),
Text(
extent={{-120,0},{-60,-52}},
extent={{-120,-20},{-60,-72}},
textColor={175,175,175},
textString="%massFlowUnit")}),
textString="%massFlowUnit"),
Line(
points={{-100,-100},{100,-100}},
color={28,108,200},
thickness=0.5),
Ellipse(
extent={{-6,-94},{6,-106}},
lineColor={28,108,200},
fillColor={170,213,255},
fillPattern=FillPattern.Solid,
lineThickness=0.5),
Line(visible=outputTemperature,
points={{60,60},{78,60}},
color={0,0,127}),
Line(visible=outputPressure,
points={{60,0},{78,0}},
color={0,0,127}),
Line(visible=outputMassFlowRate,
points={{60,-60},{78,-60}},
color={0,0,127})}),
Diagram(coordinateSystem(preserveAspectRatio=false)),
Documentation(info="<html>
<p>Undirected&nbsp;sensor&nbsp;for&nbsp;temperature,&nbsp;pressure&nbsp;and&nbsp;mass-flow. Units can be selected.</p>
Expand Down
Loading

0 comments on commit 484d2c2

Please sign in to comment.