Skip to content

Commit

Permalink
bidirectional stream flows
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekMatejak committed Feb 6, 2014
1 parent ddd6b1a commit d6df2bb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
28 changes: 14 additions & 14 deletions Physiolibrary/Chemical.mo
Expand Up @@ -862,7 +862,7 @@ package Chemical "Domain with Molar Concentration and Molar Flow"
"Flux from/to compartment" annotation (Placement(transformation(extent={{-10,
-10},{10,10}})));
equation
q_out.conc = solute/volume;
q_out.conc = solute/volume; //TODO: solute/(solvent+solute)?

state = solute; // der(solute)=q_out.q
change = q_out.q;
Expand Down Expand Up @@ -1249,14 +1249,13 @@ It works in two modes:
-100},{100,100}}), graphics));
end Degradation;

model Stream "One-directional flow of solution"
//- Solute flowing together with solvent - One-directional stream (only zero or positive solvent flow values are allowed!)"
model Stream "Flow of whole solution"
extends Physiolibrary.Chemical.Interfaces.OnePort;
extends Physiolibrary.Chemical.Interfaces.ConditionalSolutionFlow;

equation
// assert(q>=-Modelica.Constants.eps,"In MolarStream must be always the forward flow in forward direction! Not 'solventFlow<0'!");
q_in.q = q*q_in.conc;
q_in.q = if
(q>0) then q*q_in.conc else q*q_out.conc;

annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
Expand All @@ -1281,7 +1280,7 @@ It works in two modes:
lineColor={0,0,255},
origin={2,-74},
rotation=180)}),
Diagram(coordinateSystem(preserveAspectRatio=true,
Diagram(coordinateSystem(preserveAspectRatio=false,
extent={{-100,-100},{100,100}}), graphics),
Documentation(revisions="<html>
<table>
Expand All @@ -1307,25 +1306,26 @@ It works in two modes:
<p>Possible field values: </p>
<table cellspacing=\"2\" cellpadding=\"0\" border=\"0.1\"><tr>
<td></td>
<td><p align=\"center\">forward flow</p></td>
<td><p align=\"center\">backward flow</p></td>
<td><p align=\"center\"><h4>forward flow</h4></p></td>
<td><p align=\"center\"><h4>backward flow</h4></p></td>
</tr>
<tr>
<td><p align=\"center\"><h4>solventFlow</h4></p></td>
<td><p align=\"center\"><h4>solutionFlow</h4></p></td>
<td><p align=\"center\">&GT;=0</p></td>
<td><p align=\"center\">&LT;0</p></td>
<td><p align=\"center\">&LT;=0</p></td>
</tr>
<tr>
<td><p align=\"center\"><h4>q_in.q</h4></p></td>
<td><p align=\"center\">=solventFlow*q_in.conc</p></td>
<td><p align=\"center\">=solventFlow*q_out.conc</p></td>
<td><p align=\"center\">=solutionFlow*q_in.conc</p></td>
<td><p align=\"center\">=-q_out.q</p></td>
</tr>
<tr>
<td><p align=\"center\"><h4>q_out.q</h4></p></td>
<td><p align=\"center\">=-q_in.q</p></td>
<td><p align=\"center\">=-q_in.q</p></td>
<td><p align=\"center\">=solutionFlow*q_out.conc</p></td>
</tr>
</table>
<br/>
</html>"));
end Stream;

Expand Down Expand Up @@ -1436,7 +1436,7 @@ It works in two modes:
</html>"));
end Speciation;

model Dilution "Adding the solvent to solution"
model Dilution "Adding/removing of the solvent to/from solution"
extends Physiolibrary.Chemical.Interfaces.OnePort;

parameter Boolean useDilutionInput = false
Expand Down
34 changes: 29 additions & 5 deletions Physiolibrary/Thermal.mo
Expand Up @@ -291,16 +291,15 @@ package Thermal
{100,100}}), graphics));
end Conductor;

model Stream "One-directional flow of heated mass"
model Stream "Flow of whole heated mass"
extends Interfaces.OnePort;
extends Interfaces.ConditionalMassFlow;

parameter Physiolibrary.Types.SpecificHeatCapacity SpecificHeat
"Of flow circuit medium";

equation
// assert(substanceFlow>=-Modelica.Constants.eps,"In HeatStream must be always the forward flow direction! Not 'substanceFlow<0'!");
q_in.Q_flow = q*q_in.T*SpecificHeat;
q_in.Q_flow = if (q>0) then q*q_in.T*SpecificHeat else q*q_out.T*SpecificHeat;

annotation (
Icon(coordinateSystem(preserveAspectRatio=false,extent={{-100,-100},{
Expand All @@ -323,6 +322,31 @@ package Thermal
Documentation(revisions="<html>
<p><i>2009-2010</i></p>
<p>Marek Matejak, Charles University, Prague, Czech Republic </p>
</html>", info="<html>
<p><h4><font color=\"#008000\">Bidirectional heated mass flow by temperature</font></h4></p>
<p>Possible field values: </p>
<table cellspacing=\"2\" cellpadding=\"0\" border=\"0.1\"><tr>
<td></td>
<td><p align=\"center\"><h4>forward flow</h4></p></td>
<td><p align=\"center\"><h4>backward flow</h4></p></td>
</tr>
<tr>
<td><p align=\"center\"><h4>massFlow</h4></p></td>
<td><p align=\"center\">&GT;=0</p></td>
<td><p align=\"center\">&LT;=0</p></td>
</tr>
<tr>
<td><p align=\"center\"><h4>q_in.q</h4></p></td>
<td><p align=\"center\">=massFlow*q_in.T*SpecificHeat</p></td>
<td><p align=\"center\">=-q_out.q</p></td>
</tr>
<tr>
<td><p align=\"center\"><h4>q_out.q</h4></p></td>
<td><p align=\"center\">=-q_in.q</p></td>
<td><p align=\"center\">=massFlow*q_out.T*SpecificHeat</p></td>
</tr>
</table>
<br/>
</html>"), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,
-100},{100,100}}), graphics));
end Stream;
Expand Down Expand Up @@ -585,7 +609,7 @@ i.e., it defines a fixed temperature as a boundary condition.
lineColor={191,0,0},
fillColor={191,0,0},
fillPattern=FillPattern.Solid),
Text(extent={{-160,110},{40,50}}, lineColor= {191,0,0}, textString= "%name")}));
Text(extent={{-160,110},{40,50}}, lineColor = {191,0,0}, textString = "%name")}));
end HeatPort_a;

connector HeatPort_b "Heat outflow"
Expand All @@ -608,7 +632,7 @@ i.e., it defines a fixed temperature as a boundary condition.
lineColor={191,0,0},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Text(extent={{-160,110},{40,50}}, lineColor= {191,0,0}, textString= "%name")}));
Text(extent={{-160,110},{40,50}}, lineColor = {191,0,0}, textString = "%name")}));

end HeatPort_b;

Expand Down

0 comments on commit d6df2bb

Please sign in to comment.