Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Thumbs.db
*_init.xml

# Generated Modelica files
src/main/Simulator/Simulator/testFlowsheet.mos
Flowsheet.mo
simulateEQN.mos
FlowsheetSEQ.csv__pycache__/
Expand Down
24 changes: 13 additions & 11 deletions src/main/Simulator/Simulator/Streams/MaterialStream.mo
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ model MaterialStream "Model representing Material Stream"
Real T(unit = "K", start = Tg) "Temperature";
Real Pbubl(unit = "Pa", min = 0, start = Pmin) "Bubble point pressure";
Real Pdew(unit = "Pa", min = 0, start = Pmax) "dew point pressure";
Real xliq(unit = "-", start = xliqg, min = 0, max = 1) "Liquid Phase mole fraction";
Real xvap(unit = "-", start = xvapg, min = 0, max = 1) "Vapor Phase mole fraction";
Real xmliq(unit = "-", start = xliqg, min = 0, max = 1) "Liquid Phase mass fraction";
Real xmvap(unit = "-",start =xvapg, min = 0, max = 1) "Vapor Phase Mass fraction";
Real xliq(unit = "1", start = xliqg, min = 0, max = 1) "Liquid Phase mole fraction";
Real xvap(unit = "1", start = xvapg, min = 0, max = 1) "Vapor Phase mole fraction";
Real xmliq(unit = "1", start = xliqg, min = 0, max = 1) "Liquid Phase mass fraction";
Real xmvap(unit = "1",start =xvapg, min = 0, max = 1) "Vapor Phase Mass fraction";
Real F_p[3](each unit = "mol/s", each min = 0, start={Fg,Fliqg,Fvapg}) "Total molar flow in phase";
Real Fm_p[3](each unit = "kg/s", each min = 0, each start = Fg) "Total mass flow in phase";
Real MW_p[3](each unit = "-", each start = 0, each min = 0) "Average Molecular weight in phase";
Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1, start={xguess,xg,yg}) "Component mole fraction in phase";
Real xm_pc[3, Nc](each unit ="-", start={xguess,xg,yg}, each min = 0, each max = 1) "Component mass fraction in phase";
Real MW_p[3](each unit = "1", each start = 0, each min = 0) "Average Molecular weight in phase";
Real x_pc[3, Nc](each unit = "1", each min = 0, each max = 1, start={xguess,xg,yg}) "Component mole fraction in phase";
Real xm_pc[3, Nc](each unit = "1", start={xguess,xg,yg}, each min = 0, each max = 1) "Component mass fraction in phase";
Real F_pc[3, Nc](each unit = "mol/s", each start = Fg, each min = 0) "Component molar flow in phase";
Real Fm_pc[3, Nc](each unit = "kg/s", each min = 0, each start = Fg) "Component mass flow in phase";
Real Cp_p[3](each unit = "kJ/[kmol.K]",start={Hmixg,Hliqg,Hvapg}) "Phase molar specific heat";
Real Cp_pc[3, Nc](each unit = "kJ/[kmol.K]") "Component molar specific heat in phase";
Real Cp_p[3](each unit = "kJ/(kmol.K)",start={Hmixg,Hliqg,Hvapg}) "Phase molar specific heat";
Real Cp_pc[3, Nc](each unit = "kJ/(kmol.K)") "Component molar specific heat in phase";
Real H_p[3](each unit = "kJ/kmol",start={Hmixg,Hliqg,Hvapg}) "Phase molar enthalpy";
Real H_pc[3, Nc](each unit = "kJ/kmol") "Component molar enthalpy in phase";
Real S_p[3](each unit = "kJ/[kmol.K]") "Phase molar entropy";
Real S_pc[3, Nc](each unit = "kJ/[kmol.K]") "Component molar entropy in phase";
Real S_p[3](each unit = "kJ/(kmol.K)") "Phase molar entropy";
Real S_pc[3, Nc](each unit = "kJ/(kmol.K)") "Component molar entropy in phase";
Simulator.Files.Interfaces.matConn In(Nc = Nc) annotation(
Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Simulator.Files.Interfaces.matConn Out(Nc = Nc) annotation(
Expand Down Expand Up @@ -149,3 +149,5 @@ annotation(

end MaterialStream;



Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within Simulator.UnitOperations;
within Simulator.UnitOperations;

model AdiabaticCompressor "Model of an adiabatic compressor to provide energy to vapor stream in form of pressure"
extends Simulator.Files.Icons.AdiabaticCompressor;
Expand All @@ -13,7 +13,7 @@ model AdiabaticCompressor "Model of an adiabatic compressor to provide energy to
Real Tin(unit = "K", min = 0, start = Tg) "Inlet stream temperature";
Real Hin(unit = "kJ/kmol",start=Htotg) "Inlet stream molar enthalpy";
Real Sin(unit = "kJ/[kmol/K]") "Inlet stream molar entropy";
Real xvapin(unit = "-", min = 0, max = 1, start = xvapg) "Inlet stream vapor phase mol fraction";
Real xvapin(unit = "1", min = 0, max = 1, start = xvapg) "Inlet stream vapor phase mol fraction";

Real Fout(min = 0, start = Fg) "Outlet stream molar flow rate";
Real Q(unit = "W") "Power required";
Expand All @@ -23,11 +23,11 @@ model AdiabaticCompressor "Model of an adiabatic compressor to provide energy to
Real Pout(unit = "Pa", min = 0, start = Pg) "Outlet stream pressure";
Real Tout(unit = "Pa", min = 0, start = Tg) "Outlet stream temperature";
Real Hout(unit = "kJ/kmol",start=Htotg) "Outlet stream molar enthalpy";
Real Sout(unit = "kJ/[kmol.K]") "Outlet stream molar entropy";
Real xvapout(unit = "-", min = 0, max = 1, start = xvapg) "Outlet stream vapor phase mole fraction";
Real x_c[Nc](each unit = "-", each min = 0, each max = 1,start=xg) "Component mole fraction";
Real Sout(unit = "kJ/(kmol.K)") "Outlet stream molar entropy";
Real xvapout(unit = "1", min = 0, max = 1, start = xvapg) "Outlet stream vapor phase mole fraction";
Real x_c[Nc](each unit = "1", each min = 0, each max = 1,start=xg) "Component mole fraction";

parameter Real Eff(unit = "-") "Efficiency";
parameter Real Eff(unit = "1") "Efficiency";

//========================================================================================
Files.Interfaces.matConn In(Nc = Nc) annotation(
Expand Down Expand Up @@ -76,3 +76,5 @@ equation
annotation(
Documentation(info = "<html><head></head><body><div style=\"font-size: 12px;\">Adiabatic Compressor is generally used to provide energy to a vapor material stream. The energy supplied is in form of pressure.</div><div style=\"font-size: 12px;\"><br></div><span style=\"font-size: 12px;\">To simulate an adiabatic compressor, Efficiency of the compressor should be provided as calculation parameter. Additionally, one of the following variables must be defined:</span><div style=\"font-size: 12px;\"><ol><li>Outlet Pressure</li><li>Pressure Increase</li><li>Power Required</li></ol><div><br></div></div><div style=\"font-size: 12px;\">For example on simulating an adiabatic compressor, go to&nbsp;<i><b>Examples</b></i>&nbsp;&gt;&gt; <b><i>Compressor</i></b></div></body></html>"));
end AdiabaticCompressor;


16 changes: 9 additions & 7 deletions src/main/Simulator/Simulator/UnitOperations/AdiabaticExpander.mo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within Simulator.UnitOperations;
within Simulator.UnitOperations;

model AdiabaticExpander "Model of an adiabatic expander to extract energy from a vapor stream in form of pressure"
//=====================================================================================
Expand All @@ -7,15 +7,15 @@ model AdiabaticExpander "Model of an adiabatic expander to extract energy from a
extends Simulator.Files.Models.Flash;
parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc];
parameter Integer Nc "Number of components";
parameter Real Eff(unit = "-") "Expander efficiency";
parameter Real Eff(unit = "1") "Expander efficiency";
//====================================================================================
//Model Variables
Real Fin(unit = "mol/s", min = 0, start = Fg) "Inlet stream molar flow rate";
Real Tin(unit = "K", min = 0, start = Tg) "Inlet stream temperature";
Real Hin(unit = "kJ/kmol",start=Htotg) "Inlet stream molar enthalpy";
Real xvapin(unit = "-", min = 0, max = 1, start = xvapg) "Inlet stream vapor phase mole fraction";
Real xin_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Component mole fraction";
Real Sin(unit = "kJ/[kmol.K]") "Inlet stream molar entropy";
Real xvapin(unit = "1", min = 0, max = 1, start = xvapg) "Inlet stream vapor phase mole fraction";
Real xin_c[Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Component mole fraction";
Real Sin(unit = "kJ/(kmol.K)") "Inlet stream molar entropy";
Real Pin(unit = "Pa", min = 0, start = Pg) "Inlet stream pressure";
Real Q(unit = "W") "Generated Power";
Real Pdel(unit = "Pa") "Pressure drop";
Expand All @@ -24,8 +24,8 @@ model AdiabaticExpander "Model of an adiabatic expander to extract energy from a
Real Fout(unit = "mol/s", min = 0, start = Fg) "Outlet stream molar flow rate";
Real Tout(unit = "K", min = 0, start = Tg) "Outlet stream temperature";
Real Hout(unit = "kJ/kmol") "Outlet stream molar enthalpy";
Real Sout(unit = "kJ/[kmol.k]") "Outlet stream molar entropy";
Real xvapout(unit = "-", min = 0, max = 1, start = xvapg) "Outlet stream vapor phase mole fraction";
Real Sout(unit = "kJ/(kmol.K)") "Outlet stream molar entropy";
Real xvapout(unit = "1", min = 0, max = 1, start = xvapg) "Outlet stream vapor phase mole fraction";
//========================================================================================
//Instantiation of connectors
Files.Interfaces.matConn In(Nc = Nc) annotation(
Expand Down Expand Up @@ -73,3 +73,5 @@ equation
annotation(
Documentation(info = "<html><head></head><body><div style=\"font-size: 12px;\">Adiabatic Expander is generally used to extract energy from a vapor material stream. The energy extracted is in form of pressure.</div><div style=\"font-size: 12px;\"><br></div><span style=\"font-size: 12px;\">To simulate an adiabatic expander, Efficiency of the expander should be provided as calculation parameter. Additionally, one of the following variables must be defined:</span><div style=\"font-size: 12px;\"><ol><li>Outlet Pressure</li><li>Pressure Drop</li><li>Power Required</li></ol><div><br></div></div><div style=\"font-size: 12px;\">For example on simulating an adiabatic expander, go to&nbsp;<i><b>Examples</b></i>&nbsp;&gt;&gt;&nbsp;<b><i>Expander</i></b></div></body></html>"));
end AdiabaticExpander;


Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
within Simulator.UnitOperations;
within Simulator.UnitOperations;

model CentrifugalPump "Model of a centrifugal pump to provide energy to liquid stream in form of pressure"
//===========================================================================
//Header files and Parameters
extends Simulator.Files.Icons.CentrifugalPump;
parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc];
parameter Integer Nc = 2 "Number of components";
parameter Real Eff(unit = "-") "Efficiency";
parameter Real Eff(unit = "1") "Efficiency";
//===========================================================================
//Model Variables
Real Pin(unit = "Pa", min = 0, start = Pg) "Inlet stream pressure";
Real Tin(unit = "K", min = 0, start = Tg) "Inlet stream temperature";
Real Hin(unit = "kJ/kmol",start=Htotg) "Inlet stream molar enthalpy";
Real Fin(unit = "mol/s", min = 0, start = Fg) "Inlet stream molar flow";
Real xin_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Inlet stream components molar fraction";
Real xin_c[Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Inlet stream components molar fraction";
Real Tdel(unit = "K") "Temperature increase";
Real Pdel(unit = "K") "Pressure increase";
Real Q(unit = "W") "Power required";
Expand All @@ -25,7 +25,7 @@ model CentrifugalPump "Model of a centrifugal pump to provide energy to liquid s
Real Tout(unit = "K", min = 0, start = Tg) "Outlet stream temperature";
Real Hout(unit = "kJ/kmol",start=Htotg) "Outlet stream molar enthalpy";
Real Fout(unit = "mol/s", min = 0, start = Fg) "Outlet stream molar flow";
Real xout_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Outlet stream molar fraction";
Real xout_c[Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Outlet stream molar fraction";
//============================================================================
//Instantiation of Connectors
Simulator.Files.Interfaces.matConn In(Nc = Nc) annotation(
Expand Down Expand Up @@ -74,3 +74,4 @@ equation
Documentation(info = "<html><head></head><body><div>Centrifugal pump is generally used to provide energy to a liquid material stream. The energy supplied is in form of pressure.</div><div><br></div>To simulate a centrifugal pump, Efficiency of the pump should be provided as calculation parameter. Additional one of the following input variables must be defined:<div><ol><li>Outlet Pressure</li><li>Pressure Increase</li><li>Power Required</li></ol><div><br></div></div><div>For example on simulating a centrifual pum, go to <i><b>Examples</b></i> &gt;&gt; <i><b>Pump</b></i></div></body></html>"));

end CentrifugalPump;

16 changes: 9 additions & 7 deletions src/main/Simulator/Simulator/UnitOperations/Cooler.mo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within Simulator.UnitOperations;
within Simulator.UnitOperations;

model Cooler "Model of a cooler to heat a material stream"
extends Simulator.Files.Icons.Cooler;
Expand All @@ -10,22 +10,22 @@ model Cooler "Model of a cooler to heat a material stream"
Real Pin(unit = "Pa", min = 0, start =Pg) "Inlet stream pressure";
Real Tin(unit = "K", min = 0, start = Tg) "Inlet stream temperature";
Real Hin(unit = "kJ/kmol") "Inlet stream molar enthalpy";
Real Sin(unit = "kJ/[kmol.K]") "Inlet stream molar entropy";
Real xvapin(unit = "-", min = 0, max = 1, start = xvapg) "Inlet stream vapor phase mole fraction";
Real Sin(unit = "kJ/(kmol.K)") "Inlet stream molar entropy";
Real xvapin(unit = "1", min = 0, max = 1, start = xvapg) "Inlet stream vapor phase mole fraction";

Real Q(unit = "W") "Heat removed";
Real Tdel(unit = "K") "Temperature drop";

Real Fout(unit = "mol/s", min = 0, start = Fg) "Outlet stream molar flow rate";
Real Pout(unit = "Pa", min = 0, start = Pg) "Outlet stream pressure";
Real Tout(unit = "K", min = 0, start = Tg) "Outlet stream temperature";
Real xvapout(unit = "-", min = 0, max = 1, start = xvapg) "Outlet stream vapor phase mole fraction";
Real xvapout(unit = "1", min = 0, max = 1, start = xvapg) "Outlet stream vapor phase mole fraction";
Real Hout(unit = "kJ/kmol") "Outlet stream molar enthalpy";
Real Sout(unit = "kJ/[kmol.K]") "Outlet stream molar entropy";
Real x_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Component mole fraction";
Real Sout(unit = "kJ/(kmol.K)") "Outlet stream molar entropy";
Real x_c[Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Component mole fraction";
//========================================================================================
parameter Real Pdel(unit = "Pa") "Pressure drop";
parameter Real Eff(unit = "-") "Efficiency";
parameter Real Eff(unit = "1") "Efficiency";

//========================================================================================
Files.Interfaces.matConn In(Nc = Nc) annotation(
Expand Down Expand Up @@ -68,3 +68,5 @@ annotation(
Documentation(info = "<html><head></head><body><span style=\"font-size: 12px;\">The cooler is used to simulate the cooling process of a material stream.</span><div style=\"font-size: 12px;\"><br></div><div style=\"font-size: 12px;\">Following calculation parameters must be provided to the cooler:</div><div style=\"font-size: 12px;\"><ol><li>Pressure Drop</li><li>Efficiency</li></ol><div>In addition to the above parameters, any one additional variable from the below list must be provided for the model to simulate successfully:</div><div><ol><li>Outlet Temperature (Tout)</li><li>Temperature Drop (Tdel)</li><li>Heat Removed (Q)</li><li>Outlet Stream Vapor Phase Mole Fraction (xvapout)</li></ol><div><br></div></div><div>For example on simulating a cooler, go to <b><i>Examples</i></b> &gt;&gt; <i><b>Cooler</b></i></div></div></body></html>"));

end Cooler;


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within Simulator.UnitOperations.DistillationColumn;
within Simulator.UnitOperations.DistillationColumn;

model Cond "Model of a condenser used in distillation column"
import Simulator.Files.*;
Expand All @@ -8,22 +8,22 @@ within Simulator.UnitOperations.DistillationColumn;
Real P(unit = "K", min = 0, start = Pg) "Pressure";
Real T(unit = "Pa", min = 0, start = Tg) "Temperature";
Real Fin(unit = "mol/s", min = 0, start =Fg) "Feed molar flow rate";
Real xin_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Feed components mole fraction";
Real xvapin_c[Nc](each unit = "-", each min = 0, each max = 1, start=xvapg) "Inlet components vapor molar fraction";
Real xin_c[Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Feed components mole fraction";
Real xvapin_c[Nc](each unit = "1", each min = 0, each max = 1, start=xvapg) "Inlet components vapor molar fraction";
Real Hin(unit = "kJ/kmol",start=Htotg) "Feed inlet molar enthalpy";

Real Fout(unit = "mol/s", min = 0, start = Fg) "Side draw molar flow";
Real Fvapin(unit = "mol/s", min = 0, start = Fg) "Inlet vapor molar flow";
Real Fliqout(unit = "mol/s", min = 0, start = Fg) "Outlet liquid molar flow";
Real xout_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Side draw components mole fraction";
Real xliqout_c[Nc](each unit = "-", each min = 0, each max = 1, start=xliqg) "Outlet components liquid mole fraction";
Real xout_c[Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Side draw components mole fraction";
Real xliqout_c[Nc](each unit = "1", each min = 0, each max = 1, start=xliqg) "Outlet components liquid mole fraction";

Real Hvapin(unit = "kJ/kmol",start=Hvapg) "Inlet vapor molar enthalpy";
Real Hliqout(unit = "kJ/kmol",start=Hliqg) "Outlet liquid molar enthalpy";
Real Q(unit = "W") "Heat load";
Real Hout(unit = "kJ/kmol",start=Htotg) "Side draw molar enthalpy";
Real Hliqout_c[Nc](each unit = "kJ/kmol") "Outlet liquid components molar enthalpy";
Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1,start={xguess,xguess,xguess}) "Component mole fraction";
Real x_pc[3, Nc](each unit = "1", each min = 0, each max = 1,start={xguess,xguess,xguess}) "Component mole fraction";
Real Pdew(unit = "Pa", min = 0, start = Pmax) "Dew point pressure";
Real Pbubl(unit = "Pa", min = 0,start=Pmin) "Bubble point pressure";

Expand Down Expand Up @@ -107,3 +107,4 @@ within Simulator.UnitOperations.DistillationColumn;
Icon(coordinateSystem(extent = {{-100, -40}, {100, 40}})),
__OpenModelica_commandLineOptions = "");
end Cond;

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within Simulator.UnitOperations.DistillationColumn;
within Simulator.UnitOperations.DistillationColumn;

model DistTray "Model of a tray used in distillation column"
import Simulator.Files.*;
Expand All @@ -8,15 +8,15 @@ within Simulator.UnitOperations.DistillationColumn;
Real P(unit = "Pa", min = 0, start = Pg) "Pressure";
Real T(unit = "K", min = 0, start = Tg) "Temperature";
Real Fin(unit = "mol/s", min = 0, start = Fg) "Feed molar flow";
Real xin_c[Nc](each unit = "-", each min = 0, each max = 1,start=xg) "Feed components mole fraction";
Real xin_c[Nc](each unit = "1", each min = 0, each max = 1,start=xg) "Feed components mole fraction";
Real Hin(unit = "kJ/kmol",start=Htotg) "Feed molar enthalpy";

Real Fout(unit = "mol/s", min = 0, start = Fg) "Sidedraw molar flow";
Real Fvap_s[2](each unit = "mol/s", each min = 0,start={Fg,Fg}) "Vapor molar flow";
Real Fliq_s[2](each unit = "mol/s", each min = 0,start={Fg,Fg}) "Liquid molar flow";
Real xout_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Components mole fraction at sidedraw";
Real xvap_sc[2, Nc](each unit = "-", each min = 0, each max = 1, start=yg) "Components vapor mole fraction";
Real xliq_sc[2, Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Components liquid mole fraction";
Real xout_c[Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Components mole fraction at sidedraw";
Real xvap_sc[2, Nc](each unit = "1", each min = 0, each max = 1, start=yg) "Components vapor mole fraction";
Real xliq_sc[2, Nc](each unit = "1", each min = 0, each max = 1, start=xg) "Components liquid mole fraction";

Real Hvap_s[2](unit = "kJ/kmol",start=Hvapg) "Vapor molar enthalpy";
Real Hliq_s[2](unit = "kJ/kmol",start=Hliqg) "Liquid molar enthalpy";
Expand Down Expand Up @@ -135,3 +135,4 @@ within Simulator.UnitOperations.DistillationColumn;
Icon(coordinateSystem(extent = {{-100, -40}, {100, 40}})),
__OpenModelica_commandLineOptions = "");
end DistTray;

Loading