From 3c18f290ad2f0fe4c12ba713a1b2cb2b84d9ea2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Matej=C3=A1k?= Date: Fri, 24 Nov 2023 10:00:32 +0100 Subject: [PATCH] New interfaces: SubstanceInlet, SubstanceOutlet, SISIFlow --- Chemical/package.mo | 170 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 1 deletion(-) diff --git a/Chemical/package.mo b/Chemical/package.mo index b0bcc0e..e369686 100644 --- a/Chemical/package.mo +++ b/Chemical/package.mo @@ -5137,6 +5137,174 @@ end solution_temperature_;

Marek Matejak, Charles University, Prague, Czech Republic

")); end SubstanceMolarityPort_b; + + connector SubstanceInlet "Electro-chemical potential and molar change of the substance in the solution" + + Modelica.Units.SI.ChemicalPotential r + "Inertial Electro-chemical potential"; + + flow Modelica.Units.SI.MolarFlowRate n_flow + "Molar change of the substance"; + + input Modelica.Units.SI.ChemicalPotential u + "Electro-chemical potential"; + + input Modelica.Units.SI.MolarEnthalpy h + "Enthalphy of the substance"; + + annotation (Icon(coordinateSystem(preserveAspectRatio=true), graphics={ + Polygon( + points={{-100,100},{-40,0},{-100,-100},{100,0},{-100,100}}, + fillColor={194,138,221}, + fillPattern=FillPattern.Solid, + lineThickness=0.5, + lineColor={158,66,200})}), + Diagram(coordinateSystem(preserveAspectRatio=true), graphics={ + Polygon( + points={{52,0},{-48,50},{-28,0},{-48,-50},{52,0}}, + fillColor={194,138,221}, + fillPattern=FillPattern.Solid, + lineThickness=0.5, + lineColor={158,66,200})}), + Documentation(revisions=" +

2023

+

Marek Matejak

+", info=" + +

Chemical streams:

+

u = û + r

+

r = der(q)*L

+

u .. electro-chemical potential

+

û .. steady-state electro-chemical potential

+

r .. electro-chemical inertia

+

q .. molar flow rate

+

L .. electro-chemical inductance

+ +

Definition of electro-chemical potential of the substance:

+

u(x,T,v) = u°(T) + R*T*ln(gamma*x) + z*F*v

+

u°(T) = DfG(T) = DfH - T * DfS

+

where

+

x .. mole fraction of the substance in the solution

+

T .. temperature in Kelvins

+

v .. eletric potential of the solution

+

z .. elementary charge of the substance (like -1 for electron, +2 for Ca^2+)

+

R .. gas constant

+

F .. Faraday constant

+

gamma .. activity coefficient

+

u°(T) .. chemical potential of pure substance

+

DfG(T) .. free Gibbs energy of formation of the substance at current temperature T.

+

DfH .. free enthalpy of formation of the substance

+

DfS .. free entropy of formation of the substance

+


Be carefull, DfS is not the same as absolute entropy of the substance S° from III. thermodinamic law! It must be calculated from tabulated value of DfG(298.15 K) and DfH as DfS=(DfH - DfG)/298.15.

+")); + end SubstanceInlet; + + connector SubstanceOutlet "Electro-chemical potential and molar change of the substance in the solution" + + Modelica.Units.SI.ChemicalPotential r + "Inertial Electro-chemical potential"; + + flow Modelica.Units.SI.MolarFlowRate n_flow + "Molar change of the substance"; + + output Modelica.Units.SI.ChemicalPotential u + "Electro-chemical potential"; + + output Modelica.Units.SI.MolarEnthalpy h + "Enthalphy of the substance"; + + annotation ( + Icon(coordinateSystem(preserveAspectRatio=true), graphics={ + Polygon( + points={{100,0},{-100,100},{-40,0},{-100,-100},{100,0}}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + lineColor={158,66,200}, + lineThickness=0.5)}), + Diagram(coordinateSystem(preserveAspectRatio=true), graphics={ + Polygon( + points={{50,0},{-50,50},{-30,0},{-50,-50},{50,0}}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + lineColor={158,66,200}, + lineThickness=0.5)}), + Documentation(revisions=" +

2023

+

Marek Matejak

+", info=" + +

Chemical streams:

+

u = û + r

+

r = der(q)*L

+

u .. electro-chemical potential

+

û .. steady-state electro-chemical potential

+

r .. inertial electro-chemical potential

+

q .. molar flow rate

+

L .. electro-chemical inductance

+ +

Definition of electro-chemical potential of the substance:

+

u(x,T,v) = u°(T) + R*T*ln(gamma*x) + z*F*v

+

u°(T) = DfG(T) = DfH - T * DfS

+

where

+

x .. mole fraction of the substance in the solution

+

T .. temperature in Kelvins

+

v .. eletric potential of the solution

+

z .. elementary charge of the substance (like -1 for electron, +2 for Ca^2+)

+

R .. gas constant

+

F .. Faraday constant

+

gamma .. activity coefficient

+

u°(T) .. chemical potential of pure substance

+

DfG(T) .. free Gibbs energy of formation of the substance at current temperature T.

+

DfH .. free enthalpy of formation of the substance

+

DfS .. free entropy of formation of the substance

+


Be carefull, DfS is not the same as absolute entropy of the substance S° from III. thermodinamic law! It must be calculated from tabulated value of DfG(298.15 K) and DfH as DfS=(DfH - DfG)/298.15.

+")); + end SubstanceOutlet; + + partial model SISOFlow "Base Model with basic flow eqautions for SISO" + + parameter Real L=1 "Inertance of the molar flow" annotation (Dialog(tab="Advanced")); + parameter Modelica.Units.SI.MolarFlowRate n_flow_0=0 "Initial value for n_flow" + annotation (Dialog( + tab="Initialization", + group="Molar flow")); + parameter Real n_acceleration_0=0 "Initial value for der(n_flow)" + annotation (Dialog( + tab="Initialization", + group="Molar flow")); + SubstanceInlet inlet annotation (Placement(transformation(extent={{-120,-20},{-80,20}}))); + SubstanceOutlet outlet annotation (Placement(transformation(extent={{80,-20},{120,20}}))); + + Modelica.Units.SI.MolarFlowRate n_flow + =inlet.n_flow "Molar flow through component"; + Modelica.Units.SI.ChemicalPotential du; + + // inlet state quantities + protected + Modelica.Units.SI.ChemicalPotential u_in=inlet.u "Electro-chemical potential of substance entering"; + Modelica.Units.SI.MolarEnthalpy h_in=inlet.h "Enthalpy of substance enetering"; + + //outlet state quantities + Modelica.Units.SI.ChemicalPotential u_out "Electro-chemical potential of substance exiting"; + Modelica.Units.SI.MolarEnthalpy h_out "Enthalpy of substance exiting"; + + initial equation + n_flow = n_flow_0; + equation + + inlet.n_flow + outlet.n_flow = 0; + outlet.r = inlet.r - der(inlet.n_flow) * L; + + u_out = u_in + du; + + outlet.u = u_out; + outlet.h = h_out; + + annotation (Documentation(info=" +

Interface class for all components with an Inlet and an Outlet and a molarflow without a mass storage between.

+

This class already implements the equations that are common for such components, namly the conservation of mass, the intertance equation.

+")); + end SISOFlow; end Interfaces; annotation ( preferredView="info", @@ -5154,7 +5322,7 @@ conversion( to="1.4.1"), from(version="1.0.0", script="modelica://Chemical/Resources/Scripts/Dymola/ConvertChemical_from_1.0_to_1.4.mos", to="1.4.1")), - uses( Modelica(version="4.0.0")), + uses( Modelica(version="4.0.0"), ThermofluidStream(version="1.1.0")), Documentation(revisions="

Copyright (c) 2023, Marek Mateják, Ph.D.

All rights reserved.