From a4c0622537d13f9277a18e6162893039f5a23e7f Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 01/28] Updated materials streams with Raoult law --- Simulator/Examples/MaterialStream.mo | 16 ++++++++-------- .../Files/ChemsepDatabase/GeneralProperties.mo | 2 +- .../Files/ThermodynamicPackages/RaoultsLaw.mo | 8 ++++++-- Simulator/GuessModels/InitialGuess.mo | 2 ++ Simulator/Streams/MaterialStream.mo | 10 ++++++---- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Simulator/Examples/MaterialStream.mo b/Simulator/Examples/MaterialStream.mo index 5e13052..a9ea203 100644 --- a/Simulator/Examples/MaterialStream.mo +++ b/Simulator/Examples/MaterialStream.mo @@ -10,7 +10,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M parameter data.Ethanol eth; parameter data.Water wat; extends Streams.MaterialStream(Nc = 3, C = {meth, eth, wat}); - extends Simulator.Files.ThermodynamicPackages.RaoultsLaw; + extends Simulator.Files.ThermodynamicPackages.RaoultsLaw(Nc = 3, C = {meth, eth, wat}); equation P = 101325; T = 351; @@ -22,12 +22,12 @@ package MaterialStream "Examples of Simulating Material Stream using Different M model TVFflash"Material Stream simulation with temperature and vapor fraction flash specifications" - Simulator.Files.ChemsepDatabase data; + import data = Simulator.Files.ChemsepDatabase; parameter data.Methanol meth; parameter data.Ethanol eth; parameter data.Water wat; extends Streams.MaterialStream(Nc = 3, C = {meth, eth, wat}); - extends Simulator.Files.ThermodynamicPackages.RaoultsLaw; + extends Simulator.Files.ThermodynamicPackages.RaoultsLaw(Nc = 3, C = {meth, eth, wat}); equation xvap = 0.036257; T = 351; @@ -44,7 +44,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M parameter data.Ethanol eth; parameter data.Water wat; extends Streams.MaterialStream(Nc = 3, C = {meth, eth, wat}); - extends Simulator.Files.ThermodynamicPackages.RaoultsLaw; + extends Simulator.Files.ThermodynamicPackages.RaoultsLaw(Nc = 3, C = {meth, eth, wat}); equation P = 101325; xvap = 0.036257; @@ -61,7 +61,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M parameter data.Ethanol eth; parameter data.Water wat; extends Streams.MaterialStream(Nc = 3, C = {meth, eth, wat}); - extends Simulator.Files.ThermodynamicPackages.RaoultsLaw; + extends Simulator.Files.ThermodynamicPackages.RaoultsLaw(Nc = 3, C = {meth, eth, wat}); equation P = 101325; H_p[1] = -34452; @@ -78,7 +78,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M parameter data.Ethanol eth; parameter data.Water wat; extends Streams.MaterialStream(Nc = 3, C = {meth, eth, wat}); - extends Simulator.Files.ThermodynamicPackages.RaoultsLaw; + extends Simulator.Files.ThermodynamicPackages.RaoultsLaw(Nc = 3, C = {meth, eth, wat}); equation P = 101325; S_p[1] = -84.39; @@ -95,7 +95,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M parameter data.Ethanol eth; parameter data.Water wat; extends Streams.MaterialStream(Nc = 3, C = {meth, eth, wat}); - extends Simulator.Files.ThermodynamicPackages.RaoultsLaw; + extends Simulator.Files.ThermodynamicPackages.RaoultsLaw(Nc = 3, C = {meth, eth, wat}); equation P = 202650; T = 320; @@ -180,4 +180,4 @@ NOTE: Please note that these examples are standalone examples of material stream CompositeMS.

")); -end MaterialStream; +end MaterialStream; \ No newline at end of file diff --git a/Simulator/Files/ChemsepDatabase/GeneralProperties.mo b/Simulator/Files/ChemsepDatabase/GeneralProperties.mo index 4e0f1c2..950d940 100644 --- a/Simulator/Files/ChemsepDatabase/GeneralProperties.mo +++ b/Simulator/Files/ChemsepDatabase/GeneralProperties.mo @@ -1,6 +1,6 @@ within Simulator.Files.ChemsepDatabase; -model GeneralProperties "Model to declare the variables for thermophysical properties" +record GeneralProperties "Model to declare the variables for thermophysical properties" extends Modelica.Icons.Record; parameter Integer SN "Serial Number"; parameter String name "Compound Name"; diff --git a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo index ff3d394..61386cc 100644 --- a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo +++ b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo @@ -1,10 +1,14 @@ within Simulator.Files.ThermodynamicPackages; model RaoultsLaw - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; + Real P(unit = "Pa", min = 0) "Pressure"; + Real T(unit = "K") "Temperature"; equation for i in 1:Nc loop gma_c[i] = 1; @@ -22,4 +26,4 @@ within Simulator.Files.ThermodynamicPackages; Cpres_p[:] = zeros(3); Hres_p[:] = zeros(3); Sres_p[:] = zeros(3); - end RaoultsLaw; + end RaoultsLaw; \ No newline at end of file diff --git a/Simulator/GuessModels/InitialGuess.mo b/Simulator/GuessModels/InitialGuess.mo index a52288b..0f58fef 100644 --- a/Simulator/GuessModels/InitialGuess.mo +++ b/Simulator/GuessModels/InitialGuess.mo @@ -4,6 +4,8 @@ model InitialGuess //Inputs Required to generate Guess Values extends GuessInput; + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; //========================================================================================== //Guess variables for Pressures and Temperatures protected diff --git a/Simulator/Streams/MaterialStream.mo b/Simulator/Streams/MaterialStream.mo index a781907..64302d4 100644 --- a/Simulator/Streams/MaterialStream.mo +++ b/Simulator/Streams/MaterialStream.mo @@ -4,10 +4,11 @@ model MaterialStream "Model representing Material Stream" //1 - Mixture, 2 - Liquid phase, 3 - Gas Phase extends Simulator.Files.Icons.MaterialStream; import Simulator.Files.*; - parameter Integer Nc "Number of components" annotation( - Dialog(tab = "Stream Specifications", group = "Component Parameters")); - parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] "Component instances array" annotation( - Dialog(tab = "Stream Specifications", group = "Component Parameters")); + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; + //Stream variables Real P(unit = "Pa", min = 0, start = Pg) "Pressure"; Real T(unit = "K", start = Tg) "Temperature"; Real Pbubl(unit = "Pa", min = 0, start = Pmin) "Bubble point pressure"; @@ -141,3 +142,4 @@ annotation(

For variables which are decalared as 1-D array, the array size represent the phase where the array element indices 1 represents mixed phase, 2 represents liquid phase and 3 represents vapor phase.

For example, variable F_p[3] represents Total molar flow in different phase. So when simulated, the variables in the results will be as follow:
F_p[1] is Molar flow in mixed phase
F_p[2] is Molar flow in liquid phase
F_p[3] is Molar flow in vapor phase


For variables which are decalared as 2-D array, the first indice represent phase and second indice represents components.

For example, variable F_pc[3,Nc] represents Component molar flow in different phase. So when simulated, the variables in the results will be as follow:
F_pc[1,Nc] is Molar flow of Ncth in mixed phase
F_pc[2,Nc] is Molar flow of Ncth in liquid phase
F_pc[3,Nc] is Molar flow of Ncth in vapor phase


For demonstration on how to use this model to simulate a Material Stream, go to Material Stream Example
")); end MaterialStream; + From 932568b33553e90651830546858f5a33d8879663 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 02/28] Updated Heat exchanger --- Simulator/UnitOperations/HeatExchanger.mo | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Simulator/UnitOperations/HeatExchanger.mo b/Simulator/UnitOperations/HeatExchanger.mo index e60093e..d157a3b 100644 --- a/Simulator/UnitOperations/HeatExchanger.mo +++ b/Simulator/UnitOperations/HeatExchanger.mo @@ -1,9 +1,10 @@ within Simulator.UnitOperations; model HeatExchanger "Model of a heat exchanger used for two streams heat exchange" - extends Simulator.Files.Icons.HeatExchanger; + extends Simulator.Files.Icons.HeatExchanger; + extends GuessModels.InitialGuess; import Simulator.Files.*; - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] "Component instances array" annotation( Dialog(tab = "Heat Exchanger Specifications", group = "Component Parameters")); parameter Integer Nc "Number of components" annotation( @@ -50,16 +51,16 @@ model HeatExchanger "Model of a heat exchanger used for two streams heat exchang //Cold Stream Inlet Real Pcin(unit = "Pa", start=Pg) "Cold inlet stream pressure"; Real Tcin(unit = "K", start=Tg) "Cold inlet stream temperature"; - Real Fcin[1](unit = "mol/s", start=Fg) "Cold inlet stream molar flow rate"; + Real Fcin[1](unit = {"mol/s"}, start={Fg}) "Cold inlet stream molar flow rate"; Real Hcin(unit = "kJ/kmol", start=Htotg) "Cold inlet stream molar enthalpy"; Real Scin(unit = "kJ/[kmol.K]") "Cold inlet stream molar entropy"; - Real xcin_pc[2, Nc](unit = "-") "Cold inlet stream component mole fraction"; + Real xcin_pc[2, Nc](each unit = "-") "Cold inlet stream component mole fraction"; Real xvapcin(unit = "-", start=xvapg) "Cold inlet stream vapor phase mole fraction"; //Cold Stream Outlet Real Pcout(unit = "Pa", start=Pg) "Cold outlet stream pressure"; Real Tcout(unit = "K", start=Tg)"Cold outlet stream temperature"; Real couttT(unit = "K", start=Tg) ; - Real Fcout[1](unit = "mol/s", start=Fg) "Cold outlet stream molar flow rate"; + Real Fcout[1](unit = {"mol/s"}, start={Fg}) "Cold outlet stream molar flow rate"; Real Hcout(unit = "kJ/kmol", start=Htotg) "Cold outlet stream molar enthalpy"; Real Scout(unit = "kJ/kmol.K") "Cold outlet stream molar entropy"; Real xcout_pc[2, Nc](each unit = "-", start={xg,xg}) "Cold outlet stream component mole fraction"; @@ -277,7 +278,6 @@ model HeatExchanger "Model of a heat exchanger used for two streams heat exchang parameter Real F =0.9828; parameter Real m = 0.96; //=========================================================================================================== - extends GuessModels.InitialGuess; equation //Hot Stream Inlet In_Hot.P = Phin; @@ -725,7 +725,7 @@ Cph_pc[3, i] = ThermodynamicFunctions.VapCpId(C[i].VapCp, Thin); end for; //================================================================================================== for i in 2:3 loop - Cph_p[i] = sum(xhin_pc[i, :] .* Cph_pc[i, :]); + Cph_p[i] = sum(xhin_pc[i-1, :] .* Cph_pc[i, :]); end for; Cph_p[1] = (1-xvaphin) * Cph_p[2] + xvaphin * Cph_p[3]; Cph_pc[1, :] = xhin_pc[1, :] .* Cph_p[1]; @@ -738,7 +738,7 @@ Cpc_pc[3, i] = ThermodynamicFunctions.VapCpId(C[i].VapCp, Tcin); end for; for i in 2:3 loop - Cpc_p[i] = sum(xcin_pc[i, :] .* Cpc_pc[i, :]); + Cpc_p[i] = sum(xcin_pc[i-1, :] .* Cpc_pc[i, :]); end for; Cpc_p[1] = (1-xvapcin) * Cpc_p[2] + xvapcin * Cpc_p[3]; Cpc_pc[1, :] = xcin_pc[1, :] .* Cpc_p[1]; From 2bf74ee75d2d6551e1f2a562bea85bd55d5f3416 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 03/28] Updated Mixer --- Simulator/UnitOperations/Mixer.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/UnitOperations/Mixer.mo b/Simulator/UnitOperations/Mixer.mo index 7f52dc8..ba22095 100644 --- a/Simulator/UnitOperations/Mixer.mo +++ b/Simulator/UnitOperations/Mixer.mo @@ -10,7 +10,7 @@ model Mixer "Model of a mixer to mix multiple material streams" parameter Integer NI = 6 "Number of inlet streams" annotation( Dialog(tab = "Mixer Specifications", group = "Calculation Parameters")); - Real Pin[NI](unit = "Pa", min = 0, start = Pg) "Inlet stream pressure"; + Real Pin[NI](each unit = "Pa", each min = 0, each start = Pg) "Inlet stream pressure"; Real xin_sc[NI, Nc](each unit = "-", each min = 0, each max = 1) "Inlet stream component mol fraction"; Real Fin_s[NI](each unit = "mol/s", each min = 0, each start = Fg) "Inlet stream Molar Flow"; Real Hin_s[NI](each unit = "kJ/kmol") "Inlet stream molar enthalpy"; From 0a04041e3e1412e33053a183e128da6050067558 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 04/28] Updated Separator --- Simulator/UnitOperations/CompoundSeparator.mo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Simulator/UnitOperations/CompoundSeparator.mo b/Simulator/UnitOperations/CompoundSeparator.mo index 943177d..53bf256 100644 --- a/Simulator/UnitOperations/CompoundSeparator.mo +++ b/Simulator/UnitOperations/CompoundSeparator.mo @@ -22,10 +22,10 @@ model CompoundSeparator Real Pout_s[2](each unit = "Pa", each min = 0, start={Pg,Pg}) "Outlet stream pressure"; Real Tout_s[2](each unit = "K", each min = 0, start={Tg,Tg}) "Outlet stream temperature"; - Real xout_sc[2, Nc](each unit = "-", each min = 0, each max = 1, start={xg,xg}) "Component mole fraction at outlet stream"; + Real xout_sc[2, Nc](each unit = "-", each min = 0, each max = 1,start = fill(xg,2)) "Component mole fraction at outlet stream"; Real Fout_s[2](each unit = "mol/s", each min = 0, start = {Fg,Fg}) "Outlet stream molar flow"; - Real Fout_sc[2, Nc](each unit = "mol/s", each min = 0, start = {Fg,Fg}) "Outlet compounds molar flow"; - Real Fmout_sc[2, Nc](each unit = "kg/s", each min = 0, start={Fg,Fg}) "Outlet compound mass flow"; + Real Fout_sc[2, Nc](each unit = "mol/s", each min = 0, each start = Fg) "Outlet compounds molar flow"; + Real Fmout_sc[2, Nc](each unit = "kg/s", each min = 0, each start = Fg) "Outlet compound mass flow"; Real Hout_s[2](each unit = "kJ/kmol", start={Hvapg,Hliqg}) "Outlet mixture molar enthalpy"; parameter String SepFact_c[Nc] "Separation factor: ''Molar_Flow'', ''Mass_Flow'', ''Inlet_Molar_Flow_Percent'', ''Inlet_Mass_Flow_Percent''" annotation( From eabaacff53070f4f1c6b118a305ca3d2e9dc3bfa Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 05/28] Updated Shortcut column --- Simulator/UnitOperations/ShortcutColumn.mo | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Simulator/UnitOperations/ShortcutColumn.mo b/Simulator/UnitOperations/ShortcutColumn.mo index d841d1d..93b7c9b 100644 --- a/Simulator/UnitOperations/ShortcutColumn.mo +++ b/Simulator/UnitOperations/ShortcutColumn.mo @@ -5,6 +5,7 @@ model ShortcutColumn "Model of a shortcut column to calculate minimum reflux in //============================================================================== //Header Files and Parameters extends Simulator.Files.Icons.DistillationColumn; + extends GuessModels.InitialGuess; import data = Simulator.Files.ChemsepDatabase; parameter data.GeneralProperties C[Nc] "Component instances array" annotation( Dialog(tab = "Column Specifications", group = "Component Parameters")); @@ -16,6 +17,10 @@ model ShortcutColumn "Model of a shortcut column to calculate minimum reflux in Dialog(tab = "Column Specifications", group = "Calculation Parameters")); parameter String Ctype = "Total" "Condenser type: Total or Partial" annotation( Dialog(tab = "Column Specifications", group = "Calculation Parameters")); + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; //============================================================================== //Model Variables Real F_p[3](each unit = "mol/s", each min = 0, each start = Fg) "Inlet stream molar flow"; @@ -28,7 +33,7 @@ model ShortcutColumn "Model of a shortcut column to calculate minimum reflux in Real Ntmin(unit = "-", min = 0, start = 10) "Minimum Number of trays"; Real RRmin(unit = "-", start = 1) "Minimum Reflux Ratio"; - Real alpha_c[Nc](unit = "-") "Relative Volatility"; + Real alpha_c[Nc](each unit = "-") "Relative Volatility"; Real theta(unit = "-", start = 1) "Fraction"; Real T(start=Tg) "Thermodynamic Adjustment", P(start=Pg) "Thermodynamic Adjustment"; Real Tcond(unit = "K", start = max(C[:].Tb), min = 0)"Condenser temperature"; @@ -70,7 +75,6 @@ model ShortcutColumn "Model of a shortcut column to calculate minimum reflux in Simulator.Files.Interfaces.enConn En2 annotation( Placement(visible = true, transformation(origin = {254, -592}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {250, -600}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - extends GuessModels.InitialGuess; equation //============================================================================== // Connector equations @@ -211,7 +215,7 @@ equation Hvapcond = sum(xvapcond_c[:] .* Hvapcond_c[:]); Fvaprec .* xvapcond_c[:] = Fliqrec .* xliqcond_c[:] + F_p[3] .* x_pc[3, :]; if Ctype == "Partial" then - x_pc[3, :] = K[:] .* xliqcond_c[:]; + x_pc[3, :] = K_c[:] .* xliqcond_c[:]; elseif Ctype == "Total" then x_pc[3, :] = xliqcond_c[:]; end if; From eb32f478fd7f3b3fce0ef819e8f7b67ea08954e3 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 06/28] Updated Flash --- Simulator/UnitOperations/Flash.mo | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Simulator/UnitOperations/Flash.mo b/Simulator/UnitOperations/Flash.mo index 9a527c8..96171b8 100644 --- a/Simulator/UnitOperations/Flash.mo +++ b/Simulator/UnitOperations/Flash.mo @@ -17,6 +17,10 @@ model Flash "Model of a flash column to separate vapor and liquid phases from a Dialog(tab = "Flash Specifications", group = "Calculation Parameters")); parameter Real Pdef(unit = "Pa") = 101325 "Separation pressure if BPdef is true" annotation( Dialog(tab = "Flash Specifications", group = "Calculation Parameters")); + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; //============================================================================== //Model Variables Real T(unit = "K", start = Tg, min = 0) "Flash column temperature"; From c9c280cb45315e353a377bf0b8ae3afc2f874f1a Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 07/28] Updated Splitter --- Simulator/UnitOperations/Splitter.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulator/UnitOperations/Splitter.mo b/Simulator/UnitOperations/Splitter.mo index e4e623c..14e28b8 100644 --- a/Simulator/UnitOperations/Splitter.mo +++ b/Simulator/UnitOperations/Splitter.mo @@ -26,8 +26,8 @@ model Splitter "Model of a splitter to split one material stream into multiple o Real Pout_s[No](each unit = "Pa", each min = 0, each start = Pg) "Outlet Pressure"; Real Tout_s[No](each unit = "K", each min = 0, each start = Tg) "Outlet Temperature"; Real xout_sc[No, Nc](each unit = "-", each min = 0, each max = 1) "Outlet Mixture Molar Fraction"; - Real Fout_c[No](each unit = "mol/s", each min = 0, start = Fg) "Outlet Mixture Molar Flow"; - Real Fmout_c[No](each unit = "kg/s", each min = 0, start = Fg) "Outlet Mixture Mass Flow"; + Real Fout_c[No](each unit = "mol/s", each min = 0, each start = Fg) "Outlet Mixture Molar Flow"; + Real Fmout_c[No](each unit = "kg/s", each min = 0, each start = Fg) "Outlet Mixture Mass Flow"; //============================================================================== //Instantiation of Connectors Simulator.Files.Interfaces.matConn In(Nc = Nc) annotation( From 1dbc4d3efc7d04f2cb651069e272f0560ccca339 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 08/28] Updated adabiatic compressor and expander --- Simulator/Files/Models/Flash.mo | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Simulator/Files/Models/Flash.mo b/Simulator/Files/Models/Flash.mo index c548260..236efb7 100644 --- a/Simulator/Files/Models/Flash.mo +++ b/Simulator/Files/Models/Flash.mo @@ -12,7 +12,10 @@ within Simulator.Files.Models; Real T(min = 0, start = Tg); Real Pbubl(start = Pmin, min = 0)"Bubble point pressure"; Real Pdew(start = Pmax, min = 0)"dew point pressure"; - + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; extends GuessModels.InitialGuess; equation From 0d7d92e1520e63a550cd065345b2d2a061bc7f04 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 09/28] Updated distillation column components --- .../UnitOperations/DistillationColumn/Cond.mo | 11 ++++++++--- .../DistillationColumn/DistTray.mo | 18 ++++++++++++------ .../UnitOperations/DistillationColumn/Reb.mo | 9 +++++++-- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Simulator/UnitOperations/DistillationColumn/Cond.mo b/Simulator/UnitOperations/DistillationColumn/Cond.mo index 9518248..9eff65b 100644 --- a/Simulator/UnitOperations/DistillationColumn/Cond.mo +++ b/Simulator/UnitOperations/DistillationColumn/Cond.mo @@ -3,20 +3,20 @@ within Simulator.UnitOperations.DistillationColumn; model Cond "Model of a condenser used in distillation column" import Simulator.Files.*; parameter ChemsepDatabase.GeneralProperties C[Nc]; - parameter Integer Nc = 2 "Number of components"; + parameter Integer Nc "Number of components"; parameter Boolean Bin = false; 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 xvapin_c[Nc](each unit = "-", each min = 0, each max = 1, each 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 xliqout_c[Nc](each unit = "-", each min = 0, each max = 1, each 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"; @@ -27,6 +27,11 @@ within Simulator.UnitOperations.DistillationColumn; Real Pdew(unit = "Pa", min = 0, start = Pmax) "Dew point pressure"; Real Pbubl(unit = "Pa", min = 0,start=Pmin) "Bubble point pressure"; + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; + //String sideDrawType(start = "Null"); //L or V parameter String Ctype "Condenser type: Partial or Total"; diff --git a/Simulator/UnitOperations/DistillationColumn/DistTray.mo b/Simulator/UnitOperations/DistillationColumn/DistTray.mo index fe2fbad..20a89fd 100644 --- a/Simulator/UnitOperations/DistillationColumn/DistTray.mo +++ b/Simulator/UnitOperations/DistillationColumn/DistTray.mo @@ -3,7 +3,7 @@ within Simulator.UnitOperations.DistillationColumn; model DistTray "Model of a tray used in distillation column" import Simulator.Files.*; parameter ChemsepDatabase.GeneralProperties C[Nc]; - parameter Integer Nc = 2 "Number of components"; + parameter Integer Nc "Number of components"; parameter Boolean Bin = true; Real P(unit = "Pa", min = 0, start = Pg) "Pressure"; Real T(unit = "K", min = 0, start = Tg) "Temperature"; @@ -18,17 +18,23 @@ within Simulator.UnitOperations.DistillationColumn; Real xvap_sc[2, Nc](each unit = "-", each min = 0, each max = 1, start={yg,yg}) "Components vapor mole fraction"; Real xliq_sc[2, Nc](each unit = "-", each min = 0, each max = 1, start={xg,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"; + Real Hvap_s[2](each unit = "kJ/kmol",each start=Hvapg) "Vapor molar enthalpy"; + Real Hliq_s[2](each unit = "kJ/kmol",each start=Hliqg) "Liquid molar enthalpy"; Real Q(unit = "W") "Heat load"; Real Hout(unit = "kJ/kmol",start=Htotg) "Side draw molar enthalpy"; - Real Hvapout_c[Nc](unit = "kJ/kmol",start=Hvapg) "Outlet components vapor molar enthalpy"; - Real Hliqout_c[Nc](unit = "kJ/kmol",start=Hliqg) "Outlet components liquid molar enthalpy"; + Real Hvapout_c[Nc](each unit = "kJ/kmol",each start=Hvapg) "Outlet components vapor molar enthalpy"; + Real Hliqout_c[Nc](each unit = "kJ/kmol",each start=Hliqg) "Outlet components liquid molar enthalpy"; Real x_pc[3, Nc](each min =0, each max = 0,start={xguess,xguess,xguess}); Real Pdew(unit = "Pa", min = 0, start = Pmax) "Dew pressure"; Real Pbubl(unit = "Pa", min = 0, start = Pmin) "Bubble pressure"; Real Pdmy1, Tdmy1, xdmy1_pc[3,Nc], Fdmy1,Hdmy1, Sdmy1, xvapdmy1; + + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; + //this is adjustment done since OpenModelica 1.11 is not handling array modification properly String OutType(start = "Null"); //L or V @@ -49,7 +55,7 @@ within Simulator.UnitOperations.DistillationColumn; Simulator.Files.Interfaces.enConn En annotation( Placement(visible = true, transformation(origin = {100, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); extends GuessModels.InitialGuess; - + equation //connector equation if Bin then diff --git a/Simulator/UnitOperations/DistillationColumn/Reb.mo b/Simulator/UnitOperations/DistillationColumn/Reb.mo index 21383aa..110d8c5 100644 --- a/Simulator/UnitOperations/DistillationColumn/Reb.mo +++ b/Simulator/UnitOperations/DistillationColumn/Reb.mo @@ -2,7 +2,7 @@ within Simulator.UnitOperations.DistillationColumn; model Reb "Model of a reboiler used in distillation column" import Simulator.Files.*; - parameter Integer Nc = 2 "Number of components"; + parameter Integer Nc "Number of components"; parameter ChemsepDatabase.GeneralProperties C[Nc]; parameter Boolean Bin = false; Real P(unit = "Pa", min = 0, start = Pg) "Pressure"; @@ -17,7 +17,7 @@ within Simulator.UnitOperations.DistillationColumn; Real Fout(unit = "mol/s", min = 0, start = Fg) "Side draw molar flow"; Real Fvapout(unit = "mol/s", min = 0, start =Fvapg) "Outlet vapor molar flow"; Real xout_c[Nc](each unit = "-", each min = 0, each max = 1, start=xg) "Side draw mole fraction"; - Real xvapout_c[Nc](each unit = "-", each min = 0, each max = 1, start=xvapg) "Outlet vapor component mole fraction"; + Real xvapout_c[Nc](each unit = "-", each min = 0, each max = 1, each start=xvapg) "Outlet vapor component mole fraction"; Real Hvapout(unit = "kJ/kmol",start=Hvapg) "Outlet vapor molar enthalpy"; Real Hvapout_c[Nc](each unit = "kJ/kmol") "Outlet vapor component molar enthalpy"; Real Q(unit = "W") "Heat load"; @@ -25,6 +25,11 @@ within Simulator.UnitOperations.DistillationColumn; Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1, each start = 1/(Nc + 1)) "Component mole fraction"; Real Pdew(unit = "Pa", min = 0, start = sum(C[:].Pc)/Nc) "Dew point pressure"; Real Pbubl(unit = "Pa", min = 0, start = sum(C[:].Pc)/Nc) "Bubble point pressure"; + + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; replaceable Simulator.Files.Interfaces.matConn In(Nc = Nc) if Bin 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))); From dbdff39f03754794132faf8f9d351dea90578fb4 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 10/28] Fixed typo in constraint --- Simulator/UnitOperations/DistillationColumn/DistTray.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/UnitOperations/DistillationColumn/DistTray.mo b/Simulator/UnitOperations/DistillationColumn/DistTray.mo index 20a89fd..7636a6b 100644 --- a/Simulator/UnitOperations/DistillationColumn/DistTray.mo +++ b/Simulator/UnitOperations/DistillationColumn/DistTray.mo @@ -24,7 +24,7 @@ within Simulator.UnitOperations.DistillationColumn; Real Hout(unit = "kJ/kmol",start=Htotg) "Side draw molar enthalpy"; Real Hvapout_c[Nc](each unit = "kJ/kmol",each start=Hvapg) "Outlet components vapor molar enthalpy"; Real Hliqout_c[Nc](each unit = "kJ/kmol",each start=Hliqg) "Outlet components liquid molar enthalpy"; - Real x_pc[3, Nc](each min =0, each max = 0,start={xguess,xguess,xguess}); + Real x_pc[3, Nc](each min =0, each max = 1,start={xguess,xguess,xguess}); Real Pdew(unit = "Pa", min = 0, start = Pmax) "Dew pressure"; Real Pbubl(unit = "Pa", min = 0, start = Pmin) "Bubble pressure"; From 1d93e3d00f09233021f4e9d26fe67ca4e421bf9b Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 11/28] Updated main distillation column. Updated example since update is not backwards compatible. --- Simulator/Examples/Distillation.mo | 12 ++++++------ .../UnitOperations/DistillationColumn/DistCol.mo | 9 +++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Simulator/Examples/Distillation.mo b/Simulator/Examples/Distillation.mo index 1afa644..09edf60 100644 --- a/Simulator/Examples/Distillation.mo +++ b/Simulator/Examples/Distillation.mo @@ -24,10 +24,10 @@ package Distillation "Example of Simulating a Distillation Column" end Reboiler; model DistColumn "Extension of Distillation Column along with instances of Condenser, Tray and Reboiler" - extends Simulator.UnitOperations.DistillationColumn.DistCol; - Condenser condenser(Nc = Nc, C = C, Ctype = Ctype, Bin = Bin_t[1]); - Reboiler reboiler(Nc = Nc, C = C, Bin = Bin_t[Nt]); - Tray tray[Nt - 2](each Nc = Nc, each C = C, Bin = Bin_t[2:Nt - 1]); + extends Simulator.UnitOperations.DistillationColumn.DistCol( + redeclare Condenser condenser(Nc = Nc, C = C, Ctype = Ctype), + redeclare Reboiler reboiler(Nc = Nc, C = C), + redeclare Tray tray[Nt - 2](each Nc = Nc, each C = C)); annotation( Documentation(info = "This is a non-executable model is created inside the package Distillation to extend the Distillation Column model along with the necessary property method from ThermodynamicPackages which is RaoultsLaw in this case.

Condenser, Tray and Reboiler models are also instantiated in this model to complete building of distillation column model.

It will be instantiated in the DistillationSimulation_Ex1
DistillationSimulation_Ex4DistillationSimulation_Ex5 model to create the required instance of the distillation column model.
")); end DistColumn; @@ -88,7 +88,7 @@ package Distillation "Example of Simulating a Distillation Column" parameter data.Benzene benz; parameter data.Toluene tol; parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] = {benz, tol}; - Simulator.Examples.Distillation.DistColumn B1(Nc = Nc, C = C, Nt = 12, Ni = 1, InT_s = {7}) annotation( + Simulator.Examples.Distillation.DistColumn B1(Nc = Nc, C = C, Nt = 12, Ni = 1, InT_s = {7}, Ctype = "Total") annotation( Placement(visible = true, transformation(origin = {-26, 6.66134e-16}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Simulator.Examples.Distillation.MS S1(Nc = Nc, C = C) annotation( Placement(visible = true, transformation(origin = {-76, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); @@ -260,4 +260,4 @@ package Distillation "Example of Simulating a Distillation Column" end DistillationSimulation_Ex5; annotation( Documentation(info = "
Following five problem statement are simulated in this Distillation Column example:

Problem Statement 1:

Component System: Benzene, Toluene
Thermodynamics: Raoult's Law

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Benzene): 0.5
Mole Fraction (Toluene): 0.5
Pressure: 101325 Pa
Temperature: 298.15 K

Simulate a distillation column with 4 stages (excluding condenser and reboiler) where the feed is entering the 3rd stage. The column is operated at uniform pressure of 101325 Pa and with a partial condenser. The column is specified to have reflux ratio of 2 and bottoms flow rate of 50 mol/s.


Problem Statement 2:

Component System: Benzene, Toluene
Thermodynamics: Raoult's Law

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Benzene): 0.5
Mole Fraction (Toluene): 0.5
Pressure: 101325 Pa
Temperature: 298.15 K

Simulate a distillation column with 12 stages (excluding condenser and reboiler) where the feed is entering the 7th stage. The column is operated at uniform pressure of 101325 Pa and with a total condenser. The column is specified to have reflux ratio of 2 and bottoms flow rate of 50 mol/s.


Problem Statement 3:

Component System: Benzene, Toluene
Thermodynamics: Raoult's Law

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Benzene): 0.3
Mole Fraction (Toluene): 0.7
Pressure: 101325 Pa
Temperature: 298.15 K

Simulate a distillation column with 22 stages (excluding condenser and reboiler) where the feed is entering the 10th stage. The column is operated at uniform pressure of 101325 Pa and with a total condenser. The column is specified to have reflux ratio of 1.5 and bottoms flow rate of 70 mol/s.


Problem Statement 4:

Component System: Benzene, Toluene
Thermodynamics: Raoult's Law

Material Stream Information

Molar Flow Rate: 96.8 mol/s
Mole Fraction (Benzene): 0.3
Mole Fraction (Toluene): 0.7
Pressure: 101325 Pa
Temperature: 298.15 K

Simulate a distillation column with 22 stages (excluding condenser and reboiler) where the feed is entering the 10th stage. The column is operated at top pressure of 151325 Pa and with a total condenser. The bottom pressure of the column is 101325 Pa. The column is specified to have reflux ratio of 1.5 and bottoms flow rate of 70 mol/s.


Problem Statement 5:

Component System: Benzene, Toluene
Thermodynamics: Raoult's Law

Material Stream Information

Feed Stream 1
Molar Flow Rate: 100 mol/s
Mole Fraction (Benzene): 0.5
Mole Fraction (Toluene): 0.5
Pressure: 101325 Pa
Temperature: 298.15 K

Feed Stream 2
Molar Flow Rate: 100 mol/s
Mole Fraction (Benzene): 0.5
Mole Fraction (Toluene): 0.5
Pressure: 101325 Pa
Temperature: 298.15 K

Simulate a distillation column with 5 stages (excluding condenser and reboiler) where the feed streams are entering the 3rd and 4th stage. The column is operated at uniform pressure of 101325 Pa and with a partial condenser. The column is specified to have reflux ratio of 2 and bottoms flow rate of 50 mol/s.


This package is created to demnostrate the simualtion of Distillation Column. Following models are created inside the package:
  1. Condenser (Non-executable model): created to extend the condenser along with the necessary thermodynamic package.
  2. Tray (Non-executable model): created to extend the tray along with the necessary thermodynamic package.
  3. Reboiler (Non-executable model): created to extend the reboiler along with the necessary thermodynamic package.
  4. DistColumn (Non-executable model): created to extend the Distillation Column along with the necessary thermodynamic package.
  5. MS (Non-executable model): created to extend the material stream along with the necessary thermodynamic package.
  6. DistillationSimulation_Ex1 (Executable model for Problem Statement 1): All the components are defined, material stream & Distillation Column specifications are declared, model instances are connected to make the file executable.
  7. DistillationSimulation_Ex2 (Executable model for Problem Statement 2): All the components are defined, material stream & Distillation Column specifications are declared, model instances are connected to make the file executable.
  8. DistillationSimulation_Ex3 (Executable model for Problem Statement 3): All the components are defined, material stream & Distillation Column specifications are declared, model instances are connected to make the file executable.
  9. DistillationSimulation_Ex4 (Executable model for Problem Statement 4): All the components are defined, material stream & Distillation Column specifications are declared, model instances are connected to make the file executable.
  10. DistillationSimulation_Ex5 (Executable model for Problem Statement 5): All the components are defined, material stream & Distillation Column specifications are declared, model instances are connected to make the file executable.
")); -end Distillation; +end Distillation; \ No newline at end of file diff --git a/Simulator/UnitOperations/DistillationColumn/DistCol.mo b/Simulator/UnitOperations/DistillationColumn/DistCol.mo index 106c2bd..d88cb16 100644 --- a/Simulator/UnitOperations/DistillationColumn/DistCol.mo +++ b/Simulator/UnitOperations/DistillationColumn/DistCol.mo @@ -35,8 +35,13 @@ within Simulator.UnitOperations.DistillationColumn; Placement(visible = true, transformation(origin = {252, -588}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {250, -598}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Simulator.Files.Interfaces.matConn Out_s[Nout](each Nc = Nc) annotation( Placement(visible = true, transformation(origin = {-36, 32}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-70, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - Simulator.Files.Interfaces.enConn En[NQ](each Nc = Nc) annotation( - Placement(visible = true, transformation(origin = {-34, -54}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-70, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + //Simulator.Files.Interfaces.enConn En[NQ](each Nc = Nc) annotation( + // Placement(visible = true, transformation(origin = {-34, -54}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-70, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); //Commented out since energy connectors don't have Nc parameters + replaceable Simulator.UnitOperations.DistillationColumn.Cond condenser(Nc = Nc, C = C, Ctype = Ctype, Bin = Bin_t[1]); + replaceable Simulator.UnitOperations.DistillationColumn.Reb reboiler(Nc = Nc, C = C, Bin = Bin_t[Nt]); + parameter Boolean Bin_tray[Nt-2] = Bin_t[2:Nt-1]; //Temporary workaround until bug is fixed + replaceable Simulator.UnitOperations.DistillationColumn.DistTray tray[2](each Nc = Nc, each C = C, Bin = Bin_tray); + equation for i in 1:Ni loop if InT_s[i] == 1 then From 456b3c6bef437b84ab54d1e116212e623a720bc6 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 12/28] Updated conversion reactor --- .../Files/Models/ReactionManager/ConversionReaction.mo | 5 +++-- Simulator/UnitOperations/ConversionReactor.mo | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Simulator/Files/Models/ReactionManager/ConversionReaction.mo b/Simulator/Files/Models/ReactionManager/ConversionReaction.mo index d11f4f8..276d69a 100644 --- a/Simulator/Files/Models/ReactionManager/ConversionReaction.mo +++ b/Simulator/Files/Models/ReactionManager/ConversionReaction.mo @@ -3,8 +3,9 @@ within Simulator.Files.Models.ReactionManager; model ConversionReaction "Model of a conversion reaction used in conversion reactor" //=================================================================================================== import Simulator.Files.*; - import data = Simulator.Files.Chemsep_Database; - //Number of Reactions involved in the process + parameter ChemsepDatabase.GeneralProperties C[Nc]; + parameter Integer Nc; + //Number of Reactions involved in the process parameter Integer Nr "Number of reactions" annotation( Dialog(tab = "Reactions", group = "Conversion Reaction Parameters")); parameter Integer BC_r[Nr] "Base component in the reactions" annotation( diff --git a/Simulator/UnitOperations/ConversionReactor.mo b/Simulator/UnitOperations/ConversionReactor.mo index 1381147..fad7c4f 100644 --- a/Simulator/UnitOperations/ConversionReactor.mo +++ b/Simulator/UnitOperations/ConversionReactor.mo @@ -17,6 +17,15 @@ model ConversionReactor "Model of a conversion reactor to calculate the outlet s Dialog(tab = "Reactor Specifications", group = "Calculation Parameters")); parameter Real X_r[Nr] = fill(0.4, Nr) "Conversion of base component" annotation( Dialog(tab = "Reactions", group = "Conversion Reaction Parameters")); + //Reactor variables + parameter Integer Nr "Number of reactions" annotation( + Dialog(tab = "Reactions", group = "Conversion Reaction Parameters")); + parameter Integer BC_r[Nr] "Base component in the reactions" annotation( + Dialog(tab = "Reactions", group = "Conversion Reaction Parameters")); + parameter Real Coef_cr[Nc, Nr] "Stoichiometric coefficient of components" annotation( + Dialog(tab = "Reactions", group = "Conversion Reaction Parameters")); + Real Hr_r[Nr]; + //============================================================================= //Model Variables Real Fin(unit = "mol/s", min = 0, start = Fg) "Inlet stream molar flow rate"; From e21cf814cb9e048b3d750e6a14efba58457524d0 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:20 -0400 Subject: [PATCH 13/28] Updated NRTL thermodynamic package --- Simulator/Files/ThermodynamicPackages/NRTL.mo | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Simulator/Files/ThermodynamicPackages/NRTL.mo b/Simulator/Files/ThermodynamicPackages/NRTL.mo index cf4eba1..7200676 100644 --- a/Simulator/Files/ThermodynamicPackages/NRTL.mo +++ b/Simulator/Files/ThermodynamicPackages/NRTL.mo @@ -1,7 +1,14 @@ within Simulator.Files.ThermodynamicPackages; model NRTL - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; + Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1); + Real P(unit = "Pa", min = 0) "Pressure"; + Real T(unit = "K") "Temperature"; + Real Pbubl(unit = "Pa", min = 0) "Bubble point pressure"; + Real Pdew(unit = "Pa", min = 0) "dew point pressure"; Simulator.Files.Models.gammaNRTL Gma(Nc = Nc, C = C, x_c = x_pc[2, :], T = T), GmaDew(Nc = Nc, C = C, x_c = xliqdew_c, T = T), GmaBubl(Nc = Nc, C = C, x_c = x_pc[1, :], T = T); Real xliqdew_c[Nc], rho_c[Nc]; Real Cpres_p[3] "residual specific heat", Hres_p[3] "residual enthalpy", Sres_p[3] "residual Entropy", K_c[Nc], gma_c[Nc](each start = 1), gmabubl_c[Nc](each start = 1), gmadew_c[Nc](each start = 1); From 0ea75cd84c5551101834246800e3a214bbfbe59b Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:21 -0400 Subject: [PATCH 14/28] Updated material stream NRTL example --- Simulator/Examples/MaterialStream.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/MaterialStream.mo b/Simulator/Examples/MaterialStream.mo index a9ea203..7ce3e9a 100644 --- a/Simulator/Examples/MaterialStream.mo +++ b/Simulator/Examples/MaterialStream.mo @@ -127,7 +127,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M parameter data.Onehexene ohex; parameter data.Ethanol eth; extends Simulator.Streams.MaterialStream(Nc = 2, C = {ohex, eth}, x_pc(each start = 0.33)); - extends Simulator.Files.ThermodynamicPackages.NRTL; + extends Simulator.Files.ThermodynamicPackages.NRTL(Nc = 2, C = {ohex, eth}); equation x_pc[1, :] = {0.5, 0.5}; F_p[1] = 100; From e10a35ec496335c01c4ac5818288273281fa073d Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:21 -0400 Subject: [PATCH 15/28] Updated GraysonStreed and material stream example --- Simulator/Examples/MaterialStream.mo | 4 ++-- .../ThermodynamicFunctions/EOSConstantII.mo | 2 +- .../Files/ThermodynamicFunctions/EOSConstants.mo | 2 +- .../Files/ThermodynamicPackages/GraysonStreed.mo | 16 ++++++++++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Simulator/Examples/MaterialStream.mo b/Simulator/Examples/MaterialStream.mo index 7ce3e9a..a0b6770 100644 --- a/Simulator/Examples/MaterialStream.mo +++ b/Simulator/Examples/MaterialStream.mo @@ -138,7 +138,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M end NRTL; model GraysonStreed "Material stream simulated with Grayson-Streed property package" - + //This example can be run using the homotopy non linear solver, the results differ from those obtained using the old frontend. import data = Simulator.Files.ChemsepDatabase; parameter data.Ethylene eth; parameter data.Acetylene acet; @@ -148,7 +148,7 @@ package MaterialStream "Examples of Simulating Material Stream using Different M //Sp = Solublity Parameter //V = Molar Volume //All the above three parameters have to be mentioned as arguments while extending the thermodynamic Package Grayson Streed as shown below - extends Simulator.Files.ThermodynamicPackages.GraysonStreed(W_c = {0.0949, 0.1841, 0.244612, 0.3125}, SP_c = {0.00297044, 0.00449341, 0.00437069, 0.00419199}, V_c = {61, 42.1382, 84.7207, 60.4292}); + extends Simulator.Files.ThermodynamicPackages.GraysonStreed(Nc = 4, C = {eth, acet, dich, prop}, W_c = {0.0949, 0.1841, 0.244612, 0.3125}, SP_c = {0.00297044, 0.00449341, 0.00437069, 0.00419199}, V_c = {61, 42.1382, 84.7207, 60.4292}); extends Simulator.Streams.MaterialStream(Nc = 4, C = {eth, acet, dich, prop}); //Equations equation diff --git a/Simulator/Files/ThermodynamicFunctions/EOSConstantII.mo b/Simulator/Files/ThermodynamicFunctions/EOSConstantII.mo index 0c72c52..80f0311 100644 --- a/Simulator/Files/ThermodynamicFunctions/EOSConstantII.mo +++ b/Simulator/Files/ThermodynamicFunctions/EOSConstantII.mo @@ -2,11 +2,11 @@ within Simulator.Files.ThermodynamicFunctions; function EOSConstantII extends Modelica.Icons.Function; - parameter Real R_gas = 8.314; input Integer NOC; input Real Tc[NOC], Pc[NOC]; input Real T; output Real b[NOC]; + protected parameter Real R_gas = 8.314; algorithm for i in 1:NOC loop b[i] := 0.08664 * R_gas * (Tc[i] / Pc[i]); diff --git a/Simulator/Files/ThermodynamicFunctions/EOSConstants.mo b/Simulator/Files/ThermodynamicFunctions/EOSConstants.mo index 443eccd..5d15a8b 100644 --- a/Simulator/Files/ThermodynamicFunctions/EOSConstants.mo +++ b/Simulator/Files/ThermodynamicFunctions/EOSConstants.mo @@ -2,11 +2,11 @@ within Simulator.Files.ThermodynamicFunctions; function EOSConstants extends Modelica.Icons.Function; - parameter Real R_gas = 8.314; input Integer NOC; input Real Tc[NOC], Pc[NOC]; input Real T; output Real a[NOC]; + protected parameter Real R_gas = 8.314; algorithm for i in 1:NOC loop a[i] := 0.42748 * R_gas ^ 2 * (Tc[i] ^ 2.5 / (Pc[i] * T ^ 0.5)); diff --git a/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo b/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo index 5fbc14b..1345363 100644 --- a/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo +++ b/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo @@ -4,7 +4,9 @@ within Simulator.Files.ThermodynamicPackages; //==================================================================== //Header Files and Parameters - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; parameter Real R = 8.314; parameter Real u = 1; import Simulator.Files.*; @@ -14,6 +16,12 @@ within Simulator.Files.ThermodynamicPackages; parameter Real T_c[Nc] = C.Tc; parameter Real Pc_c[Nc] = C.Pc; parameter Real Rgas = 8314470; + Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1); + Real P(unit = "Pa", min = 0) "Pressure"; + Real T(unit = "K") "Temperature"; + Real Pbubl(unit = "Pa", min = 0) "Bubble point pressure"; + Real Pdew(unit = "Pa", min = 0) "dew point pressure"; + //==================================================================== //Model Variables @@ -34,7 +42,7 @@ within Simulator.Files.ThermodynamicPackages; Real Cvapdew[4], ZRvapdew[3, 2], ZVapdew[3]; Real gmabubl_c[Nc](each start = 0.5), gmadew_c[Nc](each start = 2.06221); Real gmaliq_c[Nc], Pvap_c[Nc]; - Real A_c[Nc], B_c[Nc], C_c[Nc], D_c[Nc], E, G, H_c[Nc], I, J; + Real A_c[Nc], B_c[Nc], C_c[Nc], D_c[Nc], E, G, H_c[Nc] (each start = 1.2), I, J; Real xliqdew_c[Nc]; Real Tr_c[Nc]; Real Prbubl_c[Nc](each start = 2); @@ -193,7 +201,7 @@ within Simulator.Files.ThermodynamicPackages; Cvapdew[2] := -(1 + Bvapdew - u * Bvapdew); Cvapdew[3] := Avapdew - u * Bvapdew - u * Bvapdew ^ 2; Cvapdew[4] := -Avapdew * Bvapdew; - ZRvapdew := Modelica.Math.Vectors.Utilities.roots(Cvapdew); + ZRvapdew := Modelica.Math.Polynomials.roots(Cvapdew); ZVapdew := {ZRvapdew[i, 1] for i in 1:3}; Zvapdew := max({ZVapdew}); algorithm @@ -201,7 +209,7 @@ within Simulator.Files.ThermodynamicPackages; Cvap[2] := -(1 + Bvap - u * Bvap); Cvap[3] := Avap - u * Bvap - u * Bvap ^ 2; Cvap[4] := -Avap * Bvap; - ZRvap := Modelica.Math.Vectors.Utilities.roots(Cvap); + ZRvap := Modelica.Math.Polynomials.roots(Cvap); ZVap := {ZRvap[i, 1] for i in 1:3}; Zvap := max({ZVap}); //========================================================================================================== From 05588d7b802c57787cc11e04c12fa9ec5f223710 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:21 -0400 Subject: [PATCH 16/28] Updated NRTL Binary Phase Envelope --- Simulator/BinaryPhaseEnvelope/NRTL.mo | 70 +++++++++++++++------------ 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/Simulator/BinaryPhaseEnvelope/NRTL.mo b/Simulator/BinaryPhaseEnvelope/NRTL.mo index cc33480..80622a3 100644 --- a/Simulator/BinaryPhaseEnvelope/NRTL.mo +++ b/Simulator/BinaryPhaseEnvelope/NRTL.mo @@ -4,52 +4,58 @@ package NRTL extends Modelica.Icons.ExamplesPackage; model NRTLmodel import Simulator.Files.ThermodynamicFunctions.*; - gammaNRTLmodel Gamma(NOC = NOC, comp = comp, molFrac = x[:], T = T); - Real density[NOC], BIPS[NOC, NOC, 2]; + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] "Component instances array"; + gammaNRTLmodel Gamma(Nc = Nc, C = C, molFrac = x[:], T = T); + Real gamma[Nc]; + Real x[Nc]; + Real T(start = 300); + Real P; + Real K[Nc]; + Real density[Nc], BIPS[Nc, Nc, 2]; equation gamma = Gamma.gamma; BIPS = Gamma.BIPS; - for i in 1:NOC loop - density[i] = Dens(comp[i].LiqDen, comp[i].Tc, T, P); + for i in 1:Nc loop + density[i] = Dens(C[i].LiqDen, C[i].Tc, T, P); end for; - for i in 1:NOC loop - K[i] = gamma[i] * Psat(comp[i].VP, T) / P; + for i in 1:Nc loop + K[i] = gamma[i] * Psat(C[i].VP, T) / P; end for; end NRTLmodel; model gammaNRTLmodel - parameter Integer NOC; - parameter Simulator.Files.ChemsepDatabase.GeneralProperties comp[NOC]; - Real molFrac[NOC], T; - Real gamma[NOC]; - Real tau[NOC, NOC], G[NOC, NOC], alpha[NOC, NOC], A[NOC, NOC], BIPS[NOC, NOC, 2]; - Real sum1[NOC], sum2[NOC]; + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] "Component instances array"; + Real molFrac[Nc], T(start = 300); + Real gamma[Nc]; + Real tau[Nc, Nc], G[Nc, Nc], alpha[Nc, Nc], A[Nc, Nc], BIPS[Nc, Nc, 2]; + Real sum1[Nc], sum2[Nc]; constant Real R = 1.98721; equation A = BIPS[:, :, 1]; alpha = BIPS[:, :, 2]; tau = A ./ (R * T); - for i in 1:NOC loop - for j in 1:NOC loop + for i in 1:Nc loop + for j in 1:Nc loop G[i, j] = exp(-alpha[i, j] * tau[i, j]); end for; end for; - for i in 1:NOC loop + for i in 1:Nc loop sum1[i] = sum(molFrac[:] .* G[:, i]); sum2[i] = sum(molFrac[:] .* tau[:, i] .* G[:, i]); end for; - for i in 1:NOC loop + for i in 1:Nc loop log(gamma[i]) = sum(molFrac[:] .* tau[:, i] .* G[:, i]) / sum(molFrac[:] .* G[:, i]) + sum(molFrac[:] .* G[i, :] ./ sum1[:] .* (tau[i, :] .- sum2[:] ./ sum1[:])); end for; end gammaNRTLmodel; model base - import data = Simulator.Files.ChemsepDatabase; - parameter Integer NOC; - parameter Real BIP[NOC, NOC, 2]; - parameter data.GeneralProperties comp[NOC]; + parameter Integer Nc; + parameter Real BIP[Nc, Nc, 2]; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] "Component instances array"; extends NRTLmodel(BIPS = BIP); - Real P, T(start = 300), gamma[NOC], K[NOC], x[NOC](each start = 0.5), y[NOC]; + Real P, T(start = 300), gamma[Nc], K[Nc], x[Nc](each start = 0.5), y[Nc]; equation y[:] = K[:] .* x[:]; sum(x[:]) = 1; @@ -61,11 +67,11 @@ package NRTL import data = Simulator.Files.ChemsepDatabase; parameter data.Onehexene ohex; parameter data.Acetone acet; - parameter Integer NOC = 2; - parameter Real BIP[NOC, NOC, 2] = Simulator.Files.ThermodynamicFunctions.BIPNRTL(NOC, comp.CAS); - parameter data.GeneralProperties comp[NOC] = {ohex, acet}; - base points[41](each P = 1013250, each NOC = NOC, each comp = comp, each BIP = BIP); - Real x[41, NOC], y[41, NOC], T[41]; + parameter Integer Nc = 2; + parameter Real BIP[Nc, Nc, 2] = Simulator.Files.ThermodynamicFunctions.BIPNRTL(Nc, C.CAS); + parameter data.GeneralProperties C[Nc] = {ohex, acet}; + base points[41](each P = 1013250, each Nc = Nc, each C = C, each BIP = BIP); + Real x[41, Nc], y[41, Nc], T[41]; equation points[:].x = x; points[:].y = y; @@ -80,11 +86,11 @@ package NRTL import data = Simulator.Files.ChemsepDatabase; parameter data.Onehexene ohex; parameter data.Acetone acet; - parameter Integer NOC = 2; - parameter Real BIP[NOC, NOC, 2] = Simulator.Files.ThermodynamicFunctions.BIPNRTL(NOC, comp.CAS); - parameter data.GeneralProperties comp[NOC] = {ohex, acet}; - base points[41](each T = 424, each NOC = NOC, each comp = comp, each BIP = BIP); - Real x[41, NOC], y[41, NOC], P[41]; + parameter Integer Nc = 2; + parameter Real BIP[Nc, Nc, 2] = Simulator.Files.ThermodynamicFunctions.BIPNRTL(Nc, C.CAS); + parameter data.GeneralProperties C[Nc] = {ohex, acet}; + base points[41](each T = 424, each Nc = Nc, each C = C, each BIP = BIP); + Real x[41, Nc], y[41, Nc], P[41]; equation points[:].x = x; points[:].y = y; @@ -93,4 +99,4 @@ package NRTL x[i, 1] = 0 + (i - 1) * 0.025; end for; end Pxy; -end NRTL; +end NRTL; \ No newline at end of file From 47e0c91426297d2ab616d16f3a175822aec7f887 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:21 -0400 Subject: [PATCH 17/28] Updated PR Binary Phase Envelope --- Simulator/BinaryPhaseEnvelope/PR.mo | 130 ++++++++++++++-------------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/Simulator/BinaryPhaseEnvelope/PR.mo b/Simulator/BinaryPhaseEnvelope/PR.mo index f9fa542..ac646fa 100644 --- a/Simulator/BinaryPhaseEnvelope/PR.mo +++ b/Simulator/BinaryPhaseEnvelope/PR.mo @@ -4,12 +4,12 @@ package PR extends Modelica.Icons.ExamplesPackage; function CompresseblityFactor extends Modelica.Icons.Function; - input Real b[NOC]; - input Real aij[NOC, NOC]; + input Real b[Nc]; + input Real aij[Nc, Nc]; input Real P; input Real T; - input Integer NOC; - input Real m[NOC]; + input Integer Nc; + input Real m[Nc]; output Real am; output Real bm; output Real A; @@ -20,7 +20,7 @@ package PR Real C[4]; Real ZR[3, 2]; algorithm - am := sum({{m[i] * m[j] * aij[i, j] for i in 1:NOC} for j in 1:NOC}); + am := sum({{m[i] * m[j] * aij[i, j] for i in 1:Nc} for j in 1:Nc}); bm := sum(b .* m); A := am * P / (R * T) ^ 2; B := bm * P / (R * T); @@ -28,77 +28,79 @@ package PR C[2] := B - 1; C[3] := A - 3 * B ^ 2 - 2 * B; C[4] := B ^ 3 + B ^ 2 - A * B; - ZR := Modelica.Math.Vectors.Utilities.roots(C); + ZR := Modelica.Math.Polynomials.roots(C); Z := {ZR[i, 1] for i in 1:3}; end CompresseblityFactor; model PR - parameter Simulator.Files.ChemsepDatabase.GeneralProperties comp[NOC]; - parameter Integer NOC; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; + parameter Integer Nc; parameter Real R = 8.314; - parameter Real kij[NOC, NOC] = Simulator.Files.ThermodynamicFunctions.BIPPR(NOC, comp.name); - Real Tr[NOC]; - Real b[NOC]; - Real m[NOC]; - Real q[NOC]; - Real a[NOC]; - Real aij[NOC, NOC]; + parameter Real kij[Nc, Nc] = Simulator.Files.ThermodynamicFunctions.BIPPR(Nc, C.name); + Real x[Nc]; + Real y[Nc]; + Real Tr[Nc]; + Real b[Nc]; + Real m[Nc]; + Real q[Nc]; + Real a[Nc]; + Real aij[Nc, Nc]; Real amL, bmL; Real AL, BL, Z_L[3]; Real ZL; - Real sum_xa[NOC]; - Real liqfugcoeff[NOC]; + Real sum_xa[Nc]; + Real liqfugcoeff[Nc]; Real amV, bmV; Real AV, BV, Z_V[3]; Real ZV; - Real sum_ya[NOC]; - Real vapfugcoeff[NOC]; + Real sum_ya[Nc]; + Real vapfugcoeff[Nc]; Real P; Real T(start = 273); - Real Psat[NOC]; + Real Psat[Nc]; //Bubble and Dew Point Calculation - Real Tr_bubl[NOC]; - Real a_bubl[NOC]; - Real aij_bubl[NOC, NOC]; - Real Psat_bubl[NOC]; + Real Tr_bubl[Nc]; + Real a_bubl[Nc]; + Real aij_bubl[Nc, Nc]; + Real Psat_bubl[Nc]; Real amL_bubl, bmL_bubl; - Real AL_bubl, BL_bubl, Z_L_bubl[3]; - Real ZL_bubl; - Real sum_xa_bubl[NOC]; - Real liqfugcoeff_bubl[NOC]; - Real gammaBubl[NOC]; + Real AL_bubl, BL_bubl(start = 0.005), Z_L_bubl[3]; + Real ZL_bubl (each start = 0.005); + Real sum_xa_bubl[Nc]; + Real liqfugcoeff_bubl[Nc]; + Real gammaBubl[Nc]; Real Tbubl(start = 273); equation - for i in 1:NOC loop - Psat_bubl[i] = Simulator.Files.ThermodynamicFunctions.Psat(comp[i].VP, Tbubl); - Psat[i] = Simulator.Files.ThermodynamicFunctions.Psat(comp[i].VP, T); + for i in 1:Nc loop + Psat_bubl[i] = Simulator.Files.ThermodynamicFunctions.Psat(C[i].VP, Tbubl); + Psat[i] = Simulator.Files.ThermodynamicFunctions.Psat(C[i].VP, T); end for; -//Bubble Point and Dew Point Calculation Routine - Tr_bubl = Tbubl ./ comp.Tc; + //Bubble Point and Dew Point Calculation Routine + Tr_bubl = Tbubl ./ C.Tc; a_bubl = q .* (1 .+ m .* (1 .- sqrt(Tr_bubl))) .^ 2; - aij_bubl = {{(1 - kij[i, j]) * sqrt(a_bubl[i] * a_bubl[j]) for i in 1:NOC} for j in 1:NOC}; - (amL_bubl, bmL_bubl, AL_bubl, BL_bubl, Z_L_bubl) = CompresseblityFactor(b, aij_bubl, P, Tbubl, NOC, x[:]); + aij_bubl = {{(1 - kij[i, j]) * sqrt(a_bubl[i] * a_bubl[j]) for i in 1:Nc} for j in 1:Nc}; + (amL_bubl, bmL_bubl, AL_bubl, BL_bubl, Z_L_bubl) = CompresseblityFactor(b, aij_bubl, P, Tbubl, Nc, x[:]); ZL_bubl = min({Z_L_bubl}); - sum_xa_bubl = {sum({x[j] * aij_bubl[i, j] for j in 1:NOC}) for i in 1:NOC}; + sum_xa_bubl = {sum({x[j] * aij_bubl[i, j] for j in 1:Nc}) for i in 1:Nc}; liqfugcoeff_bubl = exp(AL_bubl / (BL_bubl * sqrt(8)) * log((ZL_bubl + 2.4142135 * BL_bubl) / (ZL_bubl - 0.414213 * BL_bubl)) .* (b / bmL_bubl .- 2 * sum_xa_bubl / amL_bubl) .+ (ZL_bubl - 1) * (b / bmL_bubl) .- log(ZL_bubl - BL_bubl)); liqfugcoeff_bubl[:] = gammaBubl[:] .* P ./ Psat_bubl[:]; - P = sum(gammaBubl[:] .* x[:] .* exp(comp[:].VP[2] + comp[:].VP[3] / Tbubl + comp[:].VP[4] * log(Tbubl) + comp[:].VP[5] .* Tbubl .^ comp[:].VP[6]) ./ liqfugcoeff_bubl[:]); -//Calculation of Temperatures at different compositions - Tr = T ./ comp.Tc; - b = 0.0778 * R * comp.Tc ./ comp.Pc; - m = 0.37464 .+ 1.54226 * comp.AF .- 0.26992 * comp.AF .^ 2; - q = 0.45724 * R ^ 2 * comp.Tc .^ 2 ./ comp.Pc; + P = sum(gammaBubl[:] .* x[:] .* exp(C[:].VP[2] + C[:].VP[3] / Tbubl + C[:].VP[4] * log(Tbubl) + C[:].VP[5] .* Tbubl .^ C[:].VP[6]) ./ liqfugcoeff_bubl[:]); + //Calculation of Temperatures at different compositions + Tr = T ./ C.Tc; + b = 0.0778 * R * C.Tc ./ C.Pc; + m = 0.37464 .+ 1.54226 * C.AF .- 0.26992 * C.AF .^ 2; + q = 0.45724 * R ^ 2 *C.Tc.^(2)./ C.Pc; a = q .* (1 .+ m .* (1 .- sqrt(Tr))) .^ 2; - aij = {{(1 - kij[i, j]) * sqrt(a[i] * a[j]) for i in 1:NOC} for j in 1:NOC}; -//Liquid Phase Calculation Routine - (amL, bmL, AL, BL, Z_L) = CompresseblityFactor(b, aij, P, T, NOC, x[:]); + aij = {{(1 - kij[i, j]) * sqrt(a[i] * a[j]) for i in 1:Nc} for j in 1:Nc}; + //Liquid Phase Calculation Routine + (amL, bmL, AL, BL, Z_L) = CompresseblityFactor(b, aij, P, T, Nc, x[:]); ZL = min({Z_L}); - sum_xa = {sum({x[j] * aij[i, j] for j in 1:NOC}) for i in 1:NOC}; + sum_xa = {sum({x[j] * aij[i, j] for j in 1:Nc}) for i in 1:Nc}; liqfugcoeff = exp(AL / (BL * sqrt(8)) * log((ZL + 2.4142135 * BL) / (ZL - 0.414213 * BL)) .* (b / bmL .- 2 * sum_xa / amL) .+ (ZL - 1) * (b / bmL) .- log(ZL - BL)); -//Vapour Phase Calculation Routine - (amV, bmV, AV, BV, Z_V) = CompresseblityFactor(b, aij, P, T, NOC, y[:]); + //Vapour Phase Calculation Routine + (amV, bmV, AV, BV, Z_V) = CompresseblityFactor(b, aij, P, T, Nc, y[:]); ZV = max({Z_V}); - sum_ya = {sum({y[j] * aij[i, j] for j in 1:NOC}) for i in 1:NOC}; + sum_ya = {sum({y[j] * aij[i, j] for j in 1:Nc}) for i in 1:Nc}; vapfugcoeff = exp(AV / (BV * sqrt(8)) * log((ZV + 2.4142135 * BV) / (ZV - 0.414213 * BV)) .* (b / bmV .- 2 * sum_ya / amV) .+ (ZV - 1) * (b / bmV) .- log(ZV - BV)); end PR; @@ -106,8 +108,8 @@ package PR import data = Simulator.Files.ChemsepDatabase; parameter data.Ethane eth; parameter data.Propane prop; - extends PR(NOC = 2, comp = {eth, prop}); - Real P, T(start = 273), K[NOC], x[NOC](each start = 0.5), y[NOC], Tbubl(start = 273); + extends PR(Nc = 2, C = {eth, prop}); + Real P, T(start = 273), K[Nc], x[Nc](each start = 0.5), y[Nc], Tbubl(start = 273); equation K[:] = liqfugcoeff[:] ./ vapfugcoeff[:]; y[:] = K[:] .* x[:]; @@ -120,13 +122,13 @@ package PR import data = Simulator.Files.ChemsepDatabase; parameter data.Ethane eth; parameter data.Propane prop; - parameter Integer NOC = 2; - parameter Integer N = 2; - parameter data.GeneralProperties comp[NOC] = {eth, prop}; - PhaseEquilibria points[N](each T = 210, each NOC = NOC, each comp = comp, each T(start = 273), each Tbubl(start = 273), each x(each start = 0.5), each y(each start = 0.5)); + parameter Integer Nc = 2; + parameter Integer N = 10; + parameter data.GeneralProperties C[Nc] = {eth, prop}; + PhaseEquilibria points[N](each T = 210, each Nc = Nc, each C = C, each T(start = 273), each Tbubl(start = 273), each x(each start = 0.5), each y(each start = 0.5)); Real x1[N], y1[N], x2[N], y2[N], P[N](each start = 101325), Tbubl[N], Temp[N]; equation -//Generation of Points to compute Bubble Temperature + //Generation of Points to Compute Bubble Temperature points[:].x[1] = x1[:]; points[:].y[1] = y1[:]; points[:].x[2] = x2[:]; @@ -148,11 +150,11 @@ package PR import data = Simulator.Files.ChemsepDatabase; parameter data.Ethane eth; parameter data.Propane prop; - parameter Integer NOC = 2; - parameter Integer N = 10; - parameter data.GeneralProperties comp[NOC] = {eth, prop}; - PhaseEquilibria points[N](each P = 101325, each NOC = NOC, each comp = comp, each T(start = 273), each Tbubl(start = 273), each x(each start = 0.5), each y(each start = 0.5)); - Real x[N, NOC], y[N, NOC], T[N], Tbubl[N], T_PR[N]; + parameter Integer Nc = 2; + parameter Integer N = 21; + parameter data.GeneralProperties C[Nc] = {eth, prop}; + PhaseEquilibria points[N](each P = 101325, each Nc = Nc, each C = C, each T(start = 273), each Tbubl(start = 273), each x(each start = 0.5), each y(each start = 0.5)); + Real x[N, Nc], y[N, Nc], T[N], Tbubl[N], T_PR[N]; equation points[:].x = x; points[:].y = y; @@ -164,7 +166,7 @@ package PR T_PR[i] = T[i]; end for; for i in 1:N loop - x[i, 1] = 0 + (i - 1) * 0.025; + x[i, 1] = 0.5 + (i - 1) * 0.025; end for; end Txy; -end PR; +end PR; \ No newline at end of file From f5d5362932d9af701b248a48ff406086ae3d70f2 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:52:21 -0400 Subject: [PATCH 18/28] Updated UNIFAC Binary Phase Envelope --- Simulator/BinaryPhaseEnvelope/UNIFAC.mo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Simulator/BinaryPhaseEnvelope/UNIFAC.mo b/Simulator/BinaryPhaseEnvelope/UNIFAC.mo index 59d3bc5..cd767ac 100644 --- a/Simulator/BinaryPhaseEnvelope/UNIFAC.mo +++ b/Simulator/BinaryPhaseEnvelope/UNIFAC.mo @@ -7,7 +7,7 @@ package UNIFAC //Libraries import Simulator.*; //Extension of Chemsep Database - Simulator.Files.ChemsepDatabase data; + import data = Simulator.Files.ChemsepDatabase; //Parameter Section //Selection of compounds parameter data.Methylethylketone meth; @@ -135,7 +135,7 @@ package UNIFAC //Libraries import Simulator.*; //Extension of Chemsep Database - Simulator.Files.ChemsepDatabase data; + import data = Simulator.Files.ChemsepDatabase; //Parameter Section //Selection of compounds parameter data.Methylethylketone meth; @@ -177,7 +177,7 @@ package UNIFAC //Mole Fractions (x-axis) of the T-x-y plot Real z1[N + 1], z2[N + 1]; //Bubble Temperature - Real T[N + 1](unit = "K", each start = 300); + Real T[N + 1](each unit = "K", each start = 300); //Distribution coefficient Real K1[N + 1]; //Vapour Phase Mole Fraction @@ -264,4 +264,4 @@ package UNIFAC end Txy; //================================================================================================================ -end UNIFAC; +end UNIFAC; \ No newline at end of file From 790edbd4d6c23b1be543be67a443029caf9614b0 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 28 May 2024 00:53:36 -0400 Subject: [PATCH 19/28] Updated UNIQUAC Binary Phase Envelope --- Simulator/BinaryPhaseEnvelope/UNIQUAC.mo | 12 ++++++------ Simulator/Files/ThermodynamicFunctions/BIPUNIQUAC.mo | 3 ++- Simulator/Files/ThermodynamicFunctions/TowUNIQUAC.mo | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Simulator/BinaryPhaseEnvelope/UNIQUAC.mo b/Simulator/BinaryPhaseEnvelope/UNIQUAC.mo index bb9367f..600563d 100644 --- a/Simulator/BinaryPhaseEnvelope/UNIQUAC.mo +++ b/Simulator/BinaryPhaseEnvelope/UNIQUAC.mo @@ -14,12 +14,12 @@ package UNIQUAC input Real R[NOC], Q[NOC]; input Real tow[NOC, NOC]; input Real towk[N + 1, NOC, NOC]; - parameter Real Z = 10 "Compresseblity Factor"; - parameter Real R_gas = 1.98721 "Gas Constant"; //Activity coefficients output Real gammaBubl1[N + 1], gammaBubl2[N + 1]; protected //Intermediate parameters used to calculate the Combinatorial and Residual contribution" + parameter Real Z = 10 "Compresseblity Factor"; + parameter Real R_gas = 1.98721 "Gas Constant"; Real r_bubl[N + 1], q_bubl[N + 1]; Real teta1_bubl[N + 1], teta2_bubl[N + 1]; Real S1_bubl[N + 1], S2_bubl[N + 1]; @@ -87,7 +87,7 @@ package UNIQUAC //Libraries import Simulator.*; //Extension of Chemsep Database - Simulator.Files.ChemsepDatabase data; + import data = Simulator.Files.ChemsepDatabase; //Parameter Section //Selection of compounds parameter data.Water wat; @@ -120,7 +120,7 @@ package UNIQUAC //Vapour Phase Mole Fraction Real y1[N + 1](each start = 0.5), y2[N + 1](each start = 0.5); //Vapour Pressure at the chosen temperature - Real Psat[NOC](unit = "Pa") "Vapour Pressure"; + Real Psat[NOC](each unit = "Pa") "Vapour Pressure"; //========================================================================================= //Equation Section equation @@ -170,7 +170,7 @@ package UNIQUAC //Libraries import Simulator.*; //Extension of Chemsep database - Simulator.Files.ChemsepDatabase data; + import data = Simulator.Files.ChemsepDatabase; //Parameter Section //Selection of compounds parameter data.Water wat; @@ -255,4 +255,4 @@ package UNIQUAC //================================================================================================ //============================================================================================================== //================================================================================================================ -end UNIQUAC; +end UNIQUAC; \ No newline at end of file diff --git a/Simulator/Files/ThermodynamicFunctions/BIPUNIQUAC.mo b/Simulator/Files/ThermodynamicFunctions/BIPUNIQUAC.mo index 9cd44e1..fcbe638 100644 --- a/Simulator/Files/ThermodynamicFunctions/BIPUNIQUAC.mo +++ b/Simulator/Files/ThermodynamicFunctions/BIPUNIQUAC.mo @@ -5,11 +5,12 @@ function BIPUNIQUAC "Function to contain the Binary Interaction Parameters for U input Integer Nc; input String C[Nc]; output Real BIP[Nc, Nc]; + protected constant String Us = "_"; String c_cc[Nc, Nc]; String d_cc[Nc, Nc]; constant String C1_C2[440] = {"Butane_Methanol", "Pentane_Ethanol", "Twomethylbutane_Ethanol", "Hexane_Ethanol", "Hexane_Onepropanol", "Cyclohexane_Onepropanol", "Methylcyclohexane_Phenol", "Isobutylene_Methanol", "Twomethyltwobutene_Methanol", "Twomethyltwobutene_Ethanol", "Onehexene_Methanol", "Onehexene_Ethanol", "Onethreebutadiene_Methanol", "Onethreepentadiene_Methanol", "Transonethreepentadiene_Methanol", "Isoprene_Methanol", "Isoprene_Ethanol", "Cyclopentadiene_Methanol", "Benzene_Chloroform", "Benzene_Phenol", "Benzene_Toluene", "Benzene_Pxylene", "Benzene_Onepropanol", "Toluene_Chloroform", "Toluene_Pxylene", "Acetaldehyde_Water", "Propionicaldehyde_Water", "Propionicaldehyde_Methanol", "Isobutyraldehyde_Water", "Acetone_Chloroform", "Acetone_Benzene", "Acetone_Phenol", "Acetone_Cyclohexane", "Acetone_Toluene", "Acetone_Ethanol", "Twobutanone_Benzene", "Twobutanone_Cyclohexane", "Twobutanone_Toluene", "Twobutanone_Nheptane", "Twobutanone_Water", "Twobutanone_Onepropanol", "Methanol_Water", "Methanol_Chloroform", "Methanol_Ethanol", "Methanol_Acetone", "Methanol_Benzene", "Methanol_Cyclohexane", "Methanol_Toluene", "Methanol_Nheptane", "Methanol_Tetrachloromethane", "Methanol_Tribromomethane", "Methanol_Acetonitrile", "Methanol_Onetwodichloroethane", "Methanol_Aceticacid", "Methanol_Dimethylsulfoxide", "Methanol_Propionicacid", "Methanol_Nndimethylformamide", "Methanol_Propanol", "Methanol_Thiophene", "Methanol_Methylacrylate", "Methanol_Twobutanone", "Methanol_Tetrahyrofuran", "Methanol_Onefourdioxane", "Methanol_Ethylacetate", "Methanol_Sulfolane", "Methanol_Onebutanol", "Methanol_Twobutanol", "Methanol_Tertbutanol", "Methanol_Onefourbutanediol", "Methanol_Pyridine", "Methanol_Methylmethacrylate", "Methanol_Methylisopropylketone", "Methanol_Threepentanone", "Methanol_Piperidine", "Methanol_Hexafluorobenzene", "Methanol_Chlorobenzene", "Methanol_Aniline", "Methanol_Twomethylpyridine", "Methanol_Threemethylpyridine", "Methanol_Fourmethylpyridine", "Methanol_Cyclohexene", "Methanol_Nbutylacetate", "Methanol_Hexane", "Methanol_Triethylamine", "Methanol_Twomethylphenol", "Methanol_Two6dimethylpyridine", "Methanol_Oneheptane", "Methanol_Methylcyclohexane", "Methanol_Heptane", "Methanol_Ethylbenzene", "Methanol_Mxylene", "Methanol_Pxylene", "Methanol_Oneoctene", "Methanol_Octane", "Methanol_Twotwofourtrimethylpentane", "Methanol_Onedodecanol", "Methanol_Oleic acid", "Ethanol_Water", "Ethanol_Chloroform", "Ethanol_Acetone", "Ethanol_Twobutanone", "Ethanol_Benzene", "Ethanol_Cyclohexane", "Ethanol_Toluene", "Ethanol_Nheptane", "Ethanol_Pxylene", "Ethanol_Tetrachloroethylene", "Ethanol_Acetonitrile", "Ethanol_Onetwodichloroethane", "Ethanol_Acetic acid", "Ethanol_Onetwoethanediol", "Ethanol_Twopropanol", "Ethanol_Onetwopropanediol", "Ethanol_Thiophene", "Ethanol_Onefourdioxane", "Ethanol_Sulfolane", "Ethanol_Morpholine", "Ethanol_Twobutanol", "Ethanol_Twomethylonepropanol", "Ethanol_Pyridine", "Ethanol_Methylmethacrylate", "Ethanol_Methylisopropyl", "Ethanol_Propylacetate", "Ethanol_Threemethylonebutanol", "Ethanol_Bromobenzene", "Ethanol_Chlorobezene", "Ethanol_Aniline", "Ethanol_Twomethylpyridine", "Ethanol_Threemethylpyridine", "Ethanol_Cyclohexanol", "Ethanol_Butylacetate", "Ethanol_Dipropylether", "Ethanol_Triethylamine", "Ethanol_Anisole", "Ethanol_Two6dimethylpyridine", "Ethanol_Pentylacetate", "Ethanol_Heptane", "Ethanol_Ethylbezene", "Ethanol_Octane", "Ethanol_Twotwofourtrimethylpentane", "Ethanol_Hexadecane", "Ethanol_Oleicacid", "Onepropanol_Water", "Onepropanol_Tetrachloroethylene", "Onepropanol_Aceticacid", "Onepropanol_Propionicacid", "Onepropanol_Twomethoxyethanol", "Propylamine_Onepropanol", "Onepropanol_Methacrylicacid", "Onepropanol_Twomethylonepropanol", "Onepropanol_Pyridine", "Onepropanol_Methylmethacrylate", "Onepropnaol_Propylacetate", "Onepropanol_Threemethylbutanol", "Onepropnaol_Chlorobenzene", "Onepropanol_Twomethylpyridine", "Onepropanol_Threemethylpyridine", "Onepropanol_Fourmethylpyridine", "Onepropanol_Propylpropionate", "Onepropanol_Dipropylamine", "Onepropanol_Hexamethyldisiloxane", "Onepropanol_Toluene", "Onepropnaol_Two6dimethylpyridine", "Onepropanol_Heptane", "Onepropanol_Pxylene", "Onepropanol_Octane", "Onepropanol_Decane", "Onepropanol_Onedecanol", "Twopropanol_Water", "Twopropanol_Onepropanol", "Isobutanol_Water", "Tertbutanol_Water", "Allylalcohol_Water", "Methylformate_Methanol", "Methylacetate_Water", "Methylacetate_Methanol", "Methylacetate_Ethanol", "Ethylacetate_Water", "Ethylacetate_Ethanol", "Vinylacetate_Ethanol", "Diethylether_Water", "Diethylether_Methanol", "Diethylether_Ethanol", "Diisopropylether_Water", "Methyltertbutylether_Methanol", "Dimethoxymethane_Water", "Dimethoxymethane_Methanol", "Ethyleneoxide_Water", "Propyleneoxide_Methanol", "Tetrahydrofuran_Water", "Tetrahydrofuran_Ethanol", "Tetrahydrofuran_Onepropanol", "Tetrachloromethane_Methanol", "Tertachloromethane_Onepropanol", "Vinylcloride_Methanol", "Dichloromethane_Methanol", "Dichloromethane_Ethanol", "Chloroform_Methanol", "Chloroform_Ethanol", "Onetwodichloroethane_Onepropanol", "Trichloroethylene_Onepropanol", "Threechloroonepropene_Water", "Butylchloride_Onepropanol", "Dimethylamine_Water", "Dimethylamine_Methanol", "Dimethylamine_Ethanol", "Dimethylamine_Onepropanol", "Ethylamine_Water", "Triethylamine_Water", "Triethylamine_Onepropanol", "Diethylamine_Water", "Diethylamine_Ethanol", "Propylamine_Water", "Nbutylamine_Water", "Butylamine_Ethanol", "Butylamine_Onepropanol", "Isopropylamine_Water", "Acetonitrile_Water", "Propionitrile_Water", "Acrylonitrile_Water", "Hexafluorobenzene_Onepropnaol", "Water_Acetone", "Water_Twobutanone", "Water_Phenol", "Water_Aceticacid", "Water_Nmethylformamide", "Water_Dimethylsulfoxide", "Water_Ethylenediamine", "Water_Acrylicacid", "Water_Propionicacid", "Water_Onethreefivetrioxane", "Water_Nndimethylformamide", "Water_Onefourdioxane", "Water_Sulfolane", "Water_Nndimethylacetamide", "Water_Morpholine", "Water_Nbutanol", "Water_Onefourbutanediol", "Water_Twothreebutanediol", "Water_Diethylenegylcol", "Water_Furfural", "Water_Pyridine", "Water_Nmethylpyrrolidone", "Water_Threemethylbutanol", "Water_Twomethyltwobutanol", "Water_Aniline", "Water_Twomethylpyridine", "Water_Threemethylpyridine", "Water_Fourmethylpyridine", "Water_Phenylhydrazine", "Water_Cyclohexanone", "Water_Mesityloxide", "Water_Cyclohexanol", "Water_Nbutylacetate", "Water_Diacetonealcohol", "Water_Onehexanol", "Water_Twohexanol", "Water_Twobutoxyethanol", "Water_Benzylalcohol", "Water_Two6dimethylpyridinr", "Water_Isopentylacetate", "Water_Acetophenone", "Water_Quinoline", "Water_Isopropylbenzene", "Halothane_Methanol", "Methanol_Formamide", "Methane_Acetone", "Methane_Propane", "Methane_Nbutane", "Methane_Npentane", "Methane_Benzene", "Methane_Nhexane", "Methane_Ndecane", "Ethane_Nheptane", "Ibutane_Nbutane", "Npentane_Acetone", "Nhexane_Nitroethane", "Nhexane_Aniline", "Nhexane_Methylcyclop", "Nhexane_Toluene", "Nheptane_Benzene", "Nheptane_Toluene", "Nctane_Nitroethane", "Nctane_Ipropanol", "Twotwofourtrimethylpentane_Nitroethane", "Twotwofourtrimethylpentane_Furfural", "Twotwofourtrimethylpentane_Benzene", "Twotwofourtrimethylpentane_Cyclohexane", "Twotwofourtrimethylpentane_Toluene", "Ndecane_Npropanol", "Ndecane_Nbutanol", "Ndecane_Ipropanol", "Cyclopentane_Benzene", "Methylcyclopentane_Benzene", "Methylcyclopentane_Toluene", "Cyclohexane_Nitromethan", "Cyclohexane_Npropanol", "Cyclohexane_Nbutanol", "Cyclohexane_Benzene", "Cyclohexane_Methylcyclop", "Cyclohexane_Nhexane", "Cyclohexane_Toluene", "Cyclohexane_Heptane", "Methylcyclohexane_Toluene", "Onebutene_Ibutane", "Onebutene_Propane", "Onebutene_Nbutane", "Benzene_Twobutanone", "Benzene_Nbutanol", "Benzene_Nhexane", "Benzene_Water", "Toluene_Furfural", "Hydrogen_Methanol", "Hydrogen_Acetone", "Hydrogen_Benzene", "Hydrogen_Nhexane", "Hydrogen_Mxylene", "Hydrogen_Nctane", "Hydrogen_Water", "Hydrogen_Ammonia", "Nitrogen_Nbutane", "Nitrogen_Nhexane", "Nitrogen_Water", "Nitrogen_Ammonia", "Carbonmonoxide_Methanol", "Carbonmonoxide_Acetone", "Carbonmonoxide_Benzene", "Carbonmonoxide_Nctane", "Acetaldehyde_Aceticacid", "Acetaldehyde_Vinylacetat", "Acetone_Carbontetra", "Acetone_Acetonitrile", "Acetone_Methanol", "Acetone_Aceticacid", "Acetone_Furfural", "Acetone_Nhexane", "Acetone_Water", "Acetone_Vinylacetat", "Methanol_Carbontetra", "Methanol_Ipropanol", "Methanol_Ethylacetat", "Methanol_Diethylamin", "Methanol_Methylisobut", "Methanol_Nhexane", "Methanol_Two.threedimethyl", "Methanol_Triethylamin", "Methanol_Anisole", "Ethanol_One.twodichloro", "Ethanol_Aceticacid", "Ethanol_Npropanol", "Ethanol_Tertbutanol", "Ethanol_Methylcyclop", "Ethanol_Nhexane", "Ethanol_Methylcyclo", "Ethanol_Nctane", "Ethanol_Twotwofourtrimethyl", "Ethanol_Ndecane", "Npropanol_Carbontetra", "Npropanol_Aceticacid", "Npropanol_Benzene", "Npropanol_Nhexane", "Npropanol_Toluene", "Npropanol_Nheptane", "Npropanol_Water", "Ipropanol_Ethylacetat", "Ipropanol_Benzene", "Ipropanol_Nheptane", "Ipropanol_Water", "Ipropanol_Twotwofourtrimethyl", "Nbutanol_Carbontetra", "Nbutanol_Aceticacid", "Nbutanol_Nhexane", "Nbutanol_Nheptane", "Nbutanol_Nctane", "Ibutanol_Benzene", "Secbutanol_Benzene", "Tertbutanol_Benzene", "Formicacid_Aceticacid", "Aceticacid_Toluene", "Aceticacid_Nheptane", "Propionicacid_Methylisobut", "Propionicacid_Nctane", "Methylacetate_Chloroform", "Methylacetate_Benzene", "Ethylacetate_Aceticacid", "Ethylacetate_Npropanol", "Ethylacetate_Furfural", "Ethylacetate_Benzene", "Ethylacetate_Toluene", "Ethylacetate_Ethylbenzen", "Vinylacetate_Aceticacid", "Vinylacetate_Water", "Dioxane_Benzene", "Carbontetrachloride_Acetonitrile", "Carbontetrachloride_Ethanol", "Carbontetrachloride_Furfural", "Carbontetrachloride_Benzene", "Carbontetrachloride_Cyclohexane", "Carbontetrachloride_Methylcyclop", "Carbontetrachloride_Toluene", "Carbontetrachloride_Nheptane", "Dichloromethane_Dichloroetan", "Chloroform_Carbontetra", "Chloroform_Formicacid", "Chloroform_Aceticacid", "Chloroform_Ethylacetate", "Chloroform_Benzene", "Nitromethane_Carbontetra", "Nitromethane_Benzene", "Nitroethane_Carbontetra", "Nitroethane_Npropanol", "Nitroethane_Benzene", "Onenitropropane_Carbontetra", "Onenitropropane_Benzene", "Twonitropropane_Carbontetra", "Twonitropropane_Benzene", "Twonitropropane_Nhexane", "Acetonitrile_Benzene", "Acetonitrile_Nheptane", "Acrylonitrile_Acetonitrile", "Aniline_Methylcyclop", "Furfural_Onebutene", "Furfural_Nbutane", "Furfural_Ibutane", "Furfural_Benzene", "Furfural_Cyclohexane", "Water_Formicacid", "Water_Acetonitrile", "Water_Nitroethane", "Water_Dioxane", "Water_Onebutene", "Water_Ibutane", "Water_Toluene", "Water_Acrylonitril", "Water_Cisbutenetwo", "Water_Transbutene", "Water_Isobutene", "Water_Butadiene", "Carbondisulfide_Methanol", "Carbondisulfide_Acetone"}; - constant Real BIPdb[440, 2] = {{1289.4881, 6.7114}, {938.0838, -112.7209}, {849.013, -56.7699}, {1056.8977, -135.5484}, {743.1034, -127.2476}, {1251.6417, -391.9511}, {1525.5351, -516.0584}, {1403.5125, -70.3003}, {1499.6766, -66.3796}, {983.1208, -123.8651}, {1329.9294, -21.5842}, {970.6914, -128.7022}, {1300.2481, -72.9715}, {1489.1438, -97.747}, {1477.5985, -92.9294}, {1514.3534, -144.3088}, {912.9208, -118.3758}, {1410.4509, -61.3753}, {-119.7224, -29.4499}, {72.2429, 197.453}, {70.7224, -58.3017}, {5.7397, 0.5699}, {378.6125, 20.5261}, {860.8206, -554.8868}, {121.3912, -119.706}, {-1132.16, -231.7521}, {735.9692, 208.343}, {416.3831, -377.9488}, {1263.005, -81.883}, {1566.0069, -781.5877}, {-358.9226, 604.28}, {-468.3882, 27.3851}, {-77.5361, 543.595}, {-315.279, 555.7418}, {94.5536, 117.867}, {-300.8429, 385.863}, {146.0313, 100.2596}, {366.3689, -250.2784}, {-184.485, 559.8999}, {775.153, 30.4806}, {147.6576, -8.2705}, {-337.1298, 549.2958}, {-271.0633, 1304.9835}, {-474.7791, 762.8153}, {-84.2364, 403.8524}, {-67.7213, 1117.8797}, {-32.2887, 1703.2055}, {-58.1103, 1190.6454}, {17.9144, 1360.0217}, {-95.2921, 1463.4548}, {-92.0642, 984.2538}, {101.9628, 334.9587}, {-80.7067, 1094.1304}, {-40.7254, -51.0491}, {-366.7607, 84.4189}, {7.1816, 0.3295}, {-156.3839, 103.9406}, {-26.2861, 113.5565}, {-265.3781, 1099.9741}, {-25.1614, 600.3028}, {-136.0158, 584.0634}, {-153.2518, 629.7314}, {-19.0988, 451.089}, {-138.9829, 770.3047}, {-28.6882, 675.1045}, {40.3898, 121.5049}, {471.807, -279.7321}, {-291.983, 403.6892}, {-286.6527, 490.8909}, {425.4563, -393.3415}, {-98.6602, 843.2593}, {-100.1669, 594.2312}, {-83.8392, 609.2057}, {-383.9791, 153.8253}, {-90.0876, 1245.166}, {-118.0717, 1402.7818}, {-144.7753, 517.8626}, {-603.5633, 950.103}, {-206.2407, 81.4664}, {-78.8509, -53.173}, {-38.5257, 1529.9926}, {-174.2617, 892.9417}, {38.3254, 1391.4917}, {-318.8007, 905.0708}, {-502.2428, 548.3889}, {-272.5909, 272.4921}, {-12.605, 1363.9261}, {1.0023, 1552.7297}, {-27.9877, 1578.6097}, {-57.095, 1259.4286}, {-41.7377, 1208.1529}, {-47.6694, 1231.2086}, {-32.2567, 1396.3019}, {-32.7911, 1561.8955}, {-59.6929, 1577.3145}, {18.9334, 484.2757}, {-149.1808, 952.0283}, {173.801, 109.8687}, {-305.3246, 881.3549}, {94.2417, 98.7523}, {-25.7234, 250.3958}, {-127.9893, 744.8826}, {-153.0128, 1100.3231}, {-97.5633, 698.6183}, {-150.277, 1127.5232}, {-63.9673, 664.259}, {-61.6485, 783.4873}, {392.2083, 91.3933}, {-39.1051, 669.688}, {-25.2901, -86.9343}, {818.093, -200.1567}, {437.5184, -324.6275}, {181.0206, -57.8238}, {-77.9585, 662.4746}, {50.8172, 212.2982}, {177.7675, 306.35}, {-712.473, 1116.7138}, {-311.9029, 474.5511}, {-117.4292, 220.9133}, {378.8209, -378.8991}, {-105.4041, 544.4089}, {-260.5944, 652.4019}, {-13.0186, 405.1733}, {82.3751, -18.3336}, {-169.9204, 998.8196}, {-205.6039, 1032.724}, {1262.584, -446.4834}, {139.4905, -225.4203}, {-578.9542, 942.9023}, {634.1484, -339.732}, {-38.4912, 384.6715}, {-177.4837, 780.0513}, {-305.4069, 674.3341}, {928.9185, -379.9781}, {-432.4206, 583.2958}, {-161.4264, 631.1662}, {-115.7807, 1040.2891}, {-127.6343, 841.5199}, {-152.8323, 1156.688}, {-165.9382, 1120.4853}, {-401.4408, 1783.7857}, {-180.7604, 627.9668}, {190.5947, 290.554}, {-13.5513, 473.6899}, {-729.0848, 1660.0903}, {-83.3064, -4.418}, {-300.7498, 511.0851}, {-274.4208, 15.9476}, {114.789, -169.5098}, {47.0059, -46.6524}, {423.4439, -423.9207}, {-27.435, 256.1456}, {-91.8942, 278.7259}, {-19.2402, 27.9161}, {1.3035, 311.4544}, {163.7157, -281.9383}, {199.1862, -290.3666}, {180.7309, -293.8268}, {-585.5214, 1186.3162}, {-1.1304, 48.1557}, {-218.4928, 677.0367}, {-1.7464, 340.4905}, {-595.2165, 936.7248}, {-91.2018, 743.266}, {-74.7475, 427.6292}, {-48.752, 525.9933}, {-175.9432, 744.763}, {89.4506, 31.0832}, {327.443, 64.4408}, {103.5993, -103.7179}, {350.1707, 309.5428}, {230.5098, 271.3048}, {281.7442, 47.6526}, {623.2636, -2.0107}, {830.7943, 47.5023}, {611.2312, -70.982}, {267.0169, -79.2922}, {1441.5619, -205.7336}, {436.0416, -98.562}, {483.9533, -67.6116}, {1198.9207, 102.271}, {906.3646, -157.3556}, {642.6982, -171.8091}, {1415.2748, 81.2811}, {1024.985, -203.711}, {1098.9416, -44.1418}, {657.2765, -4.6934}, {10542.2026, -344.1682}, {791.0185, -210.2403}, {835.2626, 10.5163}, {559.1539, -260.1951}, {381.8256, -244.669}, {1029.3332, -171.0842}, {957.274, -252.3762}, {7661.2894, -187.7083}, {1516.5558, -229.3734}, {796.2935, -172.0713}, {1295.4282, -271.461}, {981.7658, -335.4504}, {272.4952, 107.634}, {538.1802, -90.5235}, {1260.1312, 81.3308}, {748.22, -172.7007}, {-1070.3252, 1057.3916}, {-520.5358, -200.8021}, {-1071.4286, 1018.5371}, {-71.2521, -231.1124}, {149.3345, -412.065}, {242.4137, 2458.766}, {701.924, -371.1197}, {721.1889, -312.3228}, {-613.4553, 1006.1474}, {426.0894, -302.8076}, {-379.6694, 874.815}, {-17.1391, -220.6087}, {-188.4751, -68.9772}, {-553.685, 1001.0323}, {266.3109, 332.5988}, {367.0686, 510.5582}, {395.4004, 537.1531}, {535.7543, -38.2344}, {-110.3829, 698.7989}, {752.9217, 39.6746}, {934.8834, -501.3763}, {-251.6868, 407.0073}, {-867.7066, 2091.772}, {-292.3021, -523.6271}, {-175.0216, -724.876}, {-417.4722, 1189.9025}, {486.4688, -146.6582}, {-210.5536, 915.1339}, {639.5742, -556.8715}, {-444.013, 1302.0378}, {-397.8616, 997.3999}, {453.4841, -463.0383}, {933.6195, -802.5279}, {548.2453, 89.0444}, {-370.3689, 1635.7568}, {489.1312, -286.7611}, {-346.2827, 900.5916}, {537.7334, -36.221}, {-56.5403, -97.5005}, {-801.2765, 1402.6755}, {819.6231, -223.7898}, {-178.9352, 1021.7979}, {-91.7122, 485.3384}, {-657.2675, 1253.468}, {1280.6209, -655.1387}, {-358.5748, 333.911}, {-334.1695, 857.6208}, {316.6082, 95.0342}, {-56.9399, 1043.7692}, {-286.8493, 1023.7144}, {394.2396, 756.4163}, {-351.0861, 1188.5242}, {-9.7248, 802.6348}, {-172.0599, 1138.3704}, {-178.571, 670.1422}, {83.4921, 304.0167}, {-497.9465, 893.7955}, {-250.5667, 1438.236}, {234.4706, 641.1422}, {-847.2235, 663.5428}, {-310.5637, 1655.4649}, {1653.8373, -379.2679}, {319.3243, -34.2606}, {-0.26, 471}, {-2.01, 604}, {-2.05, 731}, {-1.32, 509}, {-0.38, 473}, {-0.06, 94}, {-0.24, 150}, {264.89, -112.61}, {1, 1}, {266.31, -22.83}, {230.64, -5.86}, {283.76, 34.82}, {-138.84, 162.13}, {34.27, 4.3}, {245.42, -135.93}, {108.24, -72.96}, {333.48, -30.98}, {1107.44, -166.18}, {236.48, 10.66}, {410.08, -4.98}, {80.91, -27.13}, {141.01, -112.66}, {141.11, -94.6}, {1137.2, -201.82}, {1430.77, -259.67}, {1074.76, -207.27}, {15.19, 33.15}, {56.47, -6.47}, {89.77, -48.05}, {517.19, 105.01}, {1284.75, -173.42}, {1393.11, -196.9}, {-32.57, 88.26}, {144.37, -118.82}, {172.73, -145.56}, {83.67, -44.04}, {-76.36, 98.22}, {210.35, -134.19}, {-23.03, 35.11}, {126.71, -98.63}, {-23.03, 35.11}, {350.47, -226.16}, {928.9, -181.24}, {-77.13, 132.43}, {2057.42, 115.13}, {74.87, 244.12}, {3.94, 218}, {3.23, 218}, {1.97, 810}, {2.99, -4}, {2.09, 765}, {-0.05, 1646}, {9.97, -880}, {0.68, 1344}, {-1.67, 814}, {0.07, 336}, {3.76, 913}, {-3.35, 2098}, {0.83, 552}, {0.48, 408}, {-1.04, 1062}, {-3.38, 1878}, {458.43, -212.77}, {-117.74, 243.51}, {-92.32, 246.68}, {-176.38, 261.53}, {359.1, -96.9}, {461.81, -262.3}, {-101.3, 195.63}, {-33.08, 261.51}, {530.99, -100.71}, {-82.48, 110.6}, {-29.64, 1127.95}, {-24.85, 31.22}, {-107.54, 579.61}, {-374.88, 676.42}, {-105.94, 688.03}, {-2.66, 1636.05}, {-7.18, 1463.9}, {-186.66, 664.29}, {-48.39, 782.28}, {-105.66, 929.71}, {-210.53, 244.67}, {210.95, -67.7}, {-2.62, 9.24}, {-118.27, 1383.93}, {-108.93, 1441.57}, {-117.57, 1340.56}, {-109.08, 1385.91}, {-120.42, 1449.61}, {-127.48, 1254.65}, {-166.93, 1336.03}, {299.33, 445.77}, {-155.1, 928.5}, {-144.11, 1326.05}, {-195.4, 818.34}, {-160.43, 1306.22}, {78.37, 583.03}, {-190.57, 522.07}, {-145.52, 854.75}, {-162.54, 1295.6}, {217.23, 11.59}, {-198.06, 994}, {-188.77, 1248.17}, {-296.3, 546.68}, {-159.24, 1370.74}, {-251.11, 1291.98}, {-236.21, 1098.91}, {-162.39, 861.06}, {784.99, -168.83}, {744.89, -165.4}, {-144.58, 241.64}, {-67.91, 298.09}, {-8.49, 342.57}, {-78.49, 136.46}, {-183.2, 556.12}, {-187.87, 121.17}, {203.46, -143.88}, {-214.39, 63.04}, {539.64, -190.31}, {-19.15, 48.52}, {233.81, -181.49}, {309.41, -214.26}, {137.11, -105.5}, {330.03, -124.12}, {1557.23, 131.36}, {363.78, -197.65}, {458.86, -40.18}, {1192.49, -135.27}, {476.85, -100.42}, {-37.52, 43.39}, {98.18, -84.82}, {161.96, -129.21}, {-168.53, 203.67}, {88.3, -59.13}, {1, 1}, {-14.74, 38.19}, {461.38, 90.36}, {346.43, -98.44}, {24.16, -119.49}, {4.98, -50.53}, {0.59, 398.4}, {73.79, 82.2}, {73.06, 295.06}, {574.22, -94.39}, {16.61, 46.05}, {-95.68, 267.13}, {535.16, -246.81}, {-134.32, 307.25}, {794.91, -344.15}, {-32.95, 252.2}, {60.28, 89.57}, {23.71, 545.79}, {183.65, -142.35}, {54.36, 228.71}, {49.12, 242.1}, {88.87, 257.71}, {97.14, 268}, {71, 12}, {41.17, 354.83}, {-508.85, 1019.29}, {122.02, 122.07}, {138.44, 920.08}, {-328.7, 927.26}, {590.17, 777.95}, {646.79, 1173.23}, {305.71, 1371.36}, {155.78, 471.21}, {356.45, -18.31}, {356.45, -18.31}, {346.74, 657.5}, {496.1, 270.6}, {1166.49, 138.15}, {157.31, 103.91}}; + constant Real BIPdb[440, 2] = {{1289.4881, 6.7114}, {938.0838, -112.7209}, {849.013, -56.7699}, {1056.8977, -135.5484}, {743.1034, -127.2476}, {1251.6417, -391.9511}, {1525.5351, -516.0584}, {1403.5125, -70.3003}, {1499.6766, -66.3796}, {983.1208, -123.8651}, {1329.9294, -21.5842}, {970.6914, -128.7022}, {1300.2481, -72.9715}, {1489.1438, -97.747}, {1477.5985, -92.9294}, {1514.3534, -144.3088}, {912.9208, -118.3758}, {1410.4509, -61.3753}, {-119.7224, -29.4499}, {72.2429, 197.453}, {70.7224, -58.3017}, {5.7397, 0.5699}, {378.6125, 20.5261}, {860.8206, -554.8868}, {121.3912, -119.706}, {-1132.16, -231.7521}, {735.9692, 208.343}, {416.3831, -377.9488}, {1263.005, -81.883}, {1566.0069, -781.5877}, {-358.9226, 604.28}, {-468.3882, 27.3851}, {-77.5361, 543.595}, {-315.279, 555.7418}, {94.5536, 117.867}, {-300.8429, 385.863}, {146.0313, 100.2596}, {366.3689, -250.2784}, {-184.485, 559.8999}, {775.153, 30.4806}, {147.6576, -8.2705}, {-337.1298, 549.2958}, {-271.0633, 1304.9835}, {-474.7791, 762.8153}, {-84.2364, 403.8524}, {-67.7213, 1117.8797}, {-32.2887, 1703.2055}, {-58.1103, 1190.6454}, {17.9144, 1360.0217}, {-95.2921, 1463.4548}, {-92.0642, 984.2538}, {101.9628, 334.9587}, {-80.7067, 1094.1304}, {-40.7254, -51.0491}, {-366.7607, 84.4189}, {7.1816, 0.3295}, {-156.3839, 103.9406}, {-26.2861, 113.5565}, {-265.3781, 1099.9741}, {-25.1614, 600.3028}, {-136.0158, 584.0634}, {-153.2518, 629.7314}, {-19.0988, 451.089}, {-138.9829, 770.3047}, {-28.6882, 675.1045}, {40.3898, 121.5049}, {471.807, -279.7321}, {-291.983, 403.6892}, {-286.6527, 490.8909}, {425.4563, -393.3415}, {-98.6602, 843.2593}, {-100.1669, 594.2312}, {-83.8392, 609.2057}, {-383.9791, 153.8253}, {-90.0876, 1245.166}, {-118.0717, 1402.7818}, {-144.7753, 517.8626}, {-603.5633, 950.103}, {-206.2407, 81.4664}, {-78.8509, -53.173}, {-38.5257, 1529.9926}, {-174.2617, 892.9417}, {38.3254, 1391.4917}, {-318.8007, 905.0708}, {-502.2428, 548.3889}, {-272.5909, 272.4921}, {-12.605, 1363.9261}, {1.0023, 1552.7297}, {-27.9877, 1578.6097}, {-57.095, 1259.4286}, {-41.7377, 1208.1529}, {-47.6694, 1231.2086}, {-32.2567, 1396.3019}, {-32.7911, 1561.8955}, {-59.6929, 1577.3145}, {18.9334, 484.2757}, {-149.1808, 952.0283}, {173.801, 109.8687}, {-305.3246, 881.3549}, {94.2417, 98.7523}, {-25.7234, 250.3958}, {-127.9893, 744.8826}, {-153.0128, 1100.3231}, {-97.5633, 698.6183}, {-150.277, 1127.5232}, {-63.9673, 664.259}, {-61.6485, 783.4873}, {392.2083, 91.3933}, {-39.1051, 669.688}, {-25.2901, -86.9343}, {818.093, -200.1567}, {437.5184, -324.6275}, {181.0206, -57.8238}, {-77.9585, 662.4746}, {50.8172, 212.2982}, {177.7675, 306.35}, {-712.473, 1116.7138}, {-311.9029, 474.5511}, {-117.4292, 220.9133}, {378.8209, -378.8991}, {-105.4041, 544.4089}, {-260.5944, 652.4019}, {-13.0186, 405.1733}, {82.3751, -18.3336}, {-169.9204, 998.8196}, {-205.6039, 1032.724}, {1262.584, -446.4834}, {139.4905, -225.4203}, {-578.9542, 942.9023}, {634.1484, -339.732}, {-38.4912, 384.6715}, {-177.4837, 780.0513}, {-305.4069, 674.3341}, {928.9185, -379.9781}, {-432.4206, 583.2958}, {-161.4264, 631.1662}, {-115.7807, 1040.2891}, {-127.6343, 841.5199}, {-152.8323, 1156.688}, {-165.9382, 1120.4853}, {-401.4408, 1783.7857}, {-180.7604, 627.9668}, {190.5947, 290.554}, {-13.5513, 473.6899}, {-729.0848, 1660.0903}, {-83.3064, -4.418}, {-300.7498, 511.0851}, {-274.4208, 15.9476}, {114.789, -169.5098}, {47.0059, -46.6524}, {423.4439, -423.9207}, {-27.435, 256.1456}, {-91.8942, 278.7259}, {-19.2402, 27.9161}, {1.3035, 311.4544}, {163.7157, -281.9383}, {199.1862, -290.3666}, {180.7309, -293.8268}, {-585.5214, 1186.3162}, {-1.1304, 48.1557}, {-218.4928, 677.0367}, {-1.7464, 340.4905}, {-595.2165, 936.7248}, {-91.2018, 743.266}, {-74.7475, 427.6292}, {-48.752, 525.9933}, {-175.9432, 744.763}, {89.4506, 31.0832}, {327.443, 64.4408}, {103.5993, -103.7179}, {350.1707, 309.5428}, {230.5098, 271.3048}, {281.7442, 47.6526}, {623.2636, -2.0107}, {830.7943, 47.5023}, {611.2312, -70.982}, {267.0169, -79.2922}, {1441.5619, -205.7336}, {436.0416, -98.562}, {483.9533, -67.6116}, {1198.9207, 102.271}, {906.3646, -157.3556}, {642.6982, -171.8091}, {1415.2748, 81.2811}, {1024.985, -203.711}, {1098.9416, -44.1418}, {657.2765, -4.6934}, {10542.2026, -344.1682}, {791.0185, -210.2403}, {835.2626, 10.5163}, {559.1539, -260.1951}, {381.8256, -244.669}, {1029.3332, -171.0842}, {957.274, -252.3762}, {7661.2894, -187.7083}, {1516.5558, -229.3734}, {796.2935, -172.0713}, {1295.4282, -271.461}, {981.7658, -335.4504}, {272.4952, 107.634}, {538.1802, -90.5235}, {1260.1312, 81.3308}, {748.22, -172.7007}, {-1070.3252, 1057.3916}, {-520.5358, -200.8021}, {-1071.4286, 1018.5371}, {-71.2521, -231.1124}, {149.3345, -412.065}, {242.4137, 2458.766}, {701.924, -371.1197}, {721.1889, -312.3228}, {-613.4553, 1006.1474}, {426.0894, -302.8076}, {-379.6694, 874.815}, {-17.1391, -220.6087}, {-188.4751, -68.9772}, {-553.685, 1001.0323}, {266.3109, 332.5988}, {367.0686, 510.5582}, {395.4004, 537.1531}, {535.7543, -38.2344}, {-110.3829, 698.7989}, {752.9217, 39.6746}, {934.8834, -501.3763}, {-251.6868, 407.0073}, {-867.7066, 2091.772}, {-292.3021, -523.6271}, {-175.0216, -724.876}, {-417.4722, 1189.9025}, {486.4688, -146.6582}, {-210.5536, 915.1339}, {639.5742, -556.8715}, {-444.013, 1302.0378}, {-397.8616, 997.3999}, {453.4841, -463.0383}, {933.6195, -802.5279}, {548.2453, 89.0444}, {-370.3689, 1635.7568}, {489.1312, -286.7611}, {-346.2827, 900.5916}, {537.7334, -36.221}, {-56.5403, -97.5005}, {-801.2765, 1402.6755}, {819.6231, -223.7898}, {-178.9352, 1021.7979}, {-91.7122, 485.3384}, {-657.2675, 1253.468}, {1280.6209, -655.1387}, {-358.5748, 333.911}, {-334.1695, 857.6208}, {316.6082, 95.0342}, {-56.9399, 1043.7692}, {-286.8493, 1023.7144}, {394.2396, 756.4163}, {-351.0861, 1188.5242}, {-9.7248, 802.6348}, {-172.0599, 1138.3704}, {-178.571, 670.1422}, {83.4921, 304.0167}, {-497.9465, 893.7955}, {-250.5667, 1438.236}, {234.4706, 641.1422}, {-847.2235, 663.5428}, {-310.5637, 1655.4649}, {1653.8373, -379.2679}, {319.3243, -34.2606}, {-0.26, 471}, {-2.01, 604}, {-2.05, 731}, {-1.32, 509}, {-0.38, 473}, {-0.06, 94}, {-0.24, 150}, {264.89, -112.61}, {1, 1}, {266.31, -22.83}, {230.64, -5.86}, {283.76, 34.82}, {-138.84, 162.13}, {34.27, 4.3}, {245.42, -135.93}, {108.24, -72.96}, {333.48, -30.98}, {1107.44, -166.18}, {236.48, 10.66}, {410.08, -4.98}, {80.91, -27.13}, {141.01, -112.66}, {141.11, -94.6}, {1137.2, -201.82}, {1430.77, -259.67}, {1074.76, -207.27}, {15.19, 33.15}, {56.47, -6.47}, {89.77, -48.05}, {517.19, 105.01}, {1284.75, -173.42}, {1393.11, -196.9}, {-32.57, 88.26}, {144.37, -118.82}, {172.73, -145.56}, {83.67, -44.04}, {-76.36, 98.22}, {210.35, -134.19}, {-23.03, 35.11}, {126.71, -98.63}, {-23.03, 35.11}, {350.47, -226.16}, {928.9, -181.24}, {-77.13, 132.43}, {2057.42, 115.13}, {74.87, 244.12}, {3.94, 218}, {3.23, 218}, {1.97, 810}, {2.99, -4}, {2.09, 765}, {-0.05, 1646}, {9.97, -880}, {0.68, 1344}, {-1.67, 814}, {0.07, 336}, {3.76, 913}, {-3.35, 2098}, {0.83, 552}, {0.48, 408}, {-1.04, 1062}, {-3.38, 1878}, {458.43, -212.77}, {-117.74, 243.51}, {-92.32, 246.68}, {-176.38, 261.53}, {359.1, -96.9}, {461.81, -262.3}, {-101.3, 195.63}, {-33.08, 261.51}, {530.99, -100.71}, {-82.48, 110.6}, {-29.64, 1127.95}, {-24.85, 31.22}, {-107.54, 579.61}, {-374.88, 676.42}, {-105.94, 688.03}, {-2.66, 1636.05}, {-7.18, 1463.9}, {-186.66, 664.29}, {-48.39, 782.28}, {-105.66, 929.71}, {-210.53, 244.67}, {210.95, -67.7}, {-2.62, 9.24}, {-118.27, 1383.93}, {-108.93, 1441.57}, {-117.57, 1340.56}, {-109.08, 1385.91}, {-120.42, 1449.61}, {-127.48, 1254.65}, {-166.93, 1336.03}, {299.33, 445.77}, {-155.1, 928.5}, {-144.11, 1326.05}, {-195.4, 818.34}, {-160.43, 1306.22}, {78.37, 583.03}, {-190.57, 522.07}, {-145.52, 854.75}, {-162.54, 1295.6}, {217.23, 11.59}, {-198.06, 994}, {-188.77, 1248.17}, {-296.3, 546.68}, {-159.24, 1370.74}, {-251.11, 1291.98}, {-236.21, 1098.91}, {-162.39, 861.06}, {784.99, -168.83}, {744.89, -165.4}, {-144.58, 241.64}, {-67.91, 298.09}, {-8.49, 342.57}, {-78.49, 136.46}, {-183.2, 556.12}, {-187.87, 121.17}, {203.46, -143.88}, {-214.39, 63.04}, {539.64, -190.31}, {-19.15, 48.52}, {233.81, -181.49}, {309.41, -214.26}, {137.11, -105.5}, {330.03, -124.12}, {1557.23, 131.36}, {363.78, -197.65}, {458.86, -40.18}, {1192.49, -135.27}, {476.85, -100.42}, {-37.52, 43.39}, {98.18, -84.82}, {161.96, -129.21}, {-168.53, 203.67}, {88.3, -59.13}, {1, 1}, {-14.74, 38.19}, {461.38, 90.36}, {346.43, -98.44}, {24.16, -119.49}, {4.98, -50.53}, {0.59, 398.4}, {73.79, 82.2}, {73.06, 295.06}, {574.22, -94.39}, {16.61, 46.05}, {-95.68, 267.13}, {535.16, -246.81}, {-134.32, 307.25}, {794.91, -344.15}, {-32.95, 252.2}, {60.28, 89.57}, {23.71, 545.79}, {183.65, -142.35}, {54.36, 228.71}, {49.12, 242.1}, {88.87, 257.71}, {97.14, 268}, {71, 12}, {41.17, 354.83}, {-508.85, 1019.29}, {122.02, 122.07}, {138.44, 920.08}, {-328.7, 927.26}, {590.17, 777.95}, {646.79, 1173.23}, {305.71, 1371.36}, {155.78, 471.21}, {356.45, -18.31}, {356.45, -18.31}, {346.74, 657.5}, {496.1, 270.6}, {1166.49, 138.15}, {157.31, 103.91}}; algorithm for i in 1:Nc loop for j in 1:Nc loop diff --git a/Simulator/Files/ThermodynamicFunctions/TowUNIQUAC.mo b/Simulator/Files/ThermodynamicFunctions/TowUNIQUAC.mo index 60209d3..f6349da 100644 --- a/Simulator/Files/ThermodynamicFunctions/TowUNIQUAC.mo +++ b/Simulator/Files/ThermodynamicFunctions/TowUNIQUAC.mo @@ -5,7 +5,7 @@ within Simulator.Files.ThermodynamicFunctions; input Integer Nc; input Real a_cc[Nc,Nc]; input Real T; - output Real tau_cc[Nc,Nc](start = 1); + output Real tau_cc[Nc,Nc](each start = 1); protected Real R = 1.98721; algorithm From f20612bbb23d463127efd128db0c240f32231433 Mon Sep 17 00:00:00 2001 From: Biananino Date: Wed, 29 May 2024 01:12:03 -0400 Subject: [PATCH 20/28] Updated PFR. Doesn't work correctly yet. --- Simulator/Examples/PFR.mo | 12 ++++++------ .../Files/Models/ReactionManager/KineticReaction.mo | 4 ++-- .../Files/ThermodynamicFunctions/DensityRacket.mo | 2 +- Simulator/UnitOperations/PFR/Integral.mo | 9 ++++++--- Simulator/UnitOperations/PFR/PFR.mo | 7 ++++--- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Simulator/Examples/PFR.mo b/Simulator/Examples/PFR.mo index 61ab4c9..a022c11 100644 --- a/Simulator/Examples/PFR.mo +++ b/Simulator/Examples/PFR.mo @@ -31,24 +31,24 @@ package PFR "Example of Simulating a PFR" Simulator.Streams.EnergyStream Energy annotation( Placement(visible = true, transformation(origin = {-14, -54}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation -//======================================================================== -//Connections + //======================================================================== + //Connections connect(Energy.Out, B1.En) annotation( Line(points = {{-4, -54}, {2, -54}, {2, 0}, {4, 0}}, color = {255, 0, 0})); connect(B1.Out, S2.In) annotation( Line(points = {{36, 0}, {80, 0}, {80, 0}, {80, 0}}, color = {0, 70, 70})); connect(S1.Out, B1.In) annotation( Line(points = {{-60, 0}, {-30, 0}, {-30, 0}, {-30, 0}}, color = {0, 70, 70})); -//======================================================================== -//Inputs and Specifications + //======================================================================== + //Inputs and Specifications S1.x_pc[1, :] = {0.2, 0.8, 0}; S1.P = 100000; S1.T = 360; S1.F_p[1] = 100; - B1.X_r[1] = 0.0991; +//B1.X_r[1] = 0.0991; This line makes the compilation fail. annotation( Documentation(info = "This is an executable model to simualate the PFR example where all the components are defined, material stream, plug flow reactor & kinetic reaction specifications are declared, model instances are connectedPFR model from the UnitOperations package has been instantiated here.

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Ethylene Oxide): 0.2
Mole Fraction (Water): 0.8
Mole Fraction (Ethylene Glycol): 0
Pressure: 100000 Pa
Temperature: 360 K

Reaction
Ethylene Oxide + Water ----> Ethylene Glycol

Compressor Specification: Conversion of Ethylene Oxide: 9.91%
   Operation Mode: isothermal
")); end PFRSimulation; annotation( Documentation(info = "
Following problem statement is simulated in this Plug Flow Reactor example

Component System: Ethylene Oxide, Water, Ethylene Glycol
Thermodynamics: Raoult's Law

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Ethylene Oxide): 0.2
Mole Fraction (Water): 0.8
Mole Fraction (Ethylene Glycol): 0
Pressure: 100000 Pa
Temperature: 360 K

Simulate a plug flow reactor where Ethylene Oxide reacts with Water to form Ethylene Glycol. The conversion of ethylene oxide is 9.91%. Assume the reactor to be operated isothermally. Pressure drop across the PFR is 90.56 Pa.

This package is created to demnostrate the simualtion of a Plug Flow Reactor. Following models are created inside the package:
  1. MS (Non-executable model): created to extend the material stream along with the necessary thermodynamic package.
  2. PFRSimulation (Executable model): All the components are defined, material stream & plug flow reactor specifications are declared, model instances are connected to make the file executable.
")); -end PFR; +end PFR; \ No newline at end of file diff --git a/Simulator/Files/Models/ReactionManager/KineticReaction.mo b/Simulator/Files/Models/ReactionManager/KineticReaction.mo index 628e86d..6d6fb38 100644 --- a/Simulator/Files/Models/ReactionManager/KineticReaction.mo +++ b/Simulator/Files/Models/ReactionManager/KineticReaction.mo @@ -4,8 +4,8 @@ within Simulator.Files.Models.ReactionManager; //=================================================================================================== import Simulator.Files.*; import data = Simulator.Files.Chemsep_Database; - // parameter ChemsepDatabase.GeneralProperties C[Nc]; - // parameter Integer Nc; + parameter ChemsepDatabase.GeneralProperties C[Nc]; + parameter Integer Nc; parameter Integer Nr "Number of reactions" annotation (Dialog(tab = "Reactions", group = "Kinetic Reaction Parameters")); parameter Integer BC_r[Nr] "Base component of reactions" annotation(Dialog(tab = "Reactions", group = "Kinetic Reaction Parameters")); // parameter Integer Comp annotation( diff --git a/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo b/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo index 15a2c77..c1acf2d 100644 --- a/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo +++ b/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo @@ -12,8 +12,8 @@ within Simulator.Files.ThermodynamicFunctions; input Real MW_c[Nc]; input Real Psat[Nc]; output Real rho_c[Nc]; - parameter Real R = 83.14; protected + parameter Real R = 83.14; Real Tr_c[Nc], Pcbar_c[Nc], temp[Nc], Tcor_c[Nc], a, b, c_c[Nc], d, e_c[Nc], Beta_c[Nc], f, g, h, j, k, RPnew_c[Nc]; algorithm for i in 1:Nc loop diff --git a/Simulator/UnitOperations/PFR/Integral.mo b/Simulator/UnitOperations/PFR/Integral.mo index 8868634..e93262e 100644 --- a/Simulator/UnitOperations/PFR/Integral.mo +++ b/Simulator/UnitOperations/PFR/Integral.mo @@ -1,6 +1,6 @@ within Simulator.UnitOperations.PFR; - function Integral "Function to define the integral part used in the performance equation of a plug floiw reactor" + function Integral "Function to define the integral part used in the performance equation of a plug flow reactor" extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction; input Integer Nc; @@ -17,14 +17,17 @@ within Simulator.UnitOperations.PFR; input Real Bc[Nr]; input Real Fao; input Real k; + protected Real Rate; algorithm Rate := 1; for i in 2:Nc loop if DO[Base_comp, 1] == 0 then - Rate := Rate * product((Co[i] + Sc[i, 1] / Bc[1] * Co[Base_comp] * u) ^ DO[i, 1]); +// Rate := Rate * product((Co[i] + Sc[i, 1] / Bc[1] * Co[Base_comp] * u) ^ DO[i, 1]); + Rate := Rate * (Co[i] + Sc[i, 1] / Bc[1] * Co[Base_comp] * u) ^ DO[i, 1]; else - Rate := Rate * product((Co_dummy[i - 1] * (1 - X_dummy[i - 1])) ^ DO_dummy[i - 1, 1]); +// Rate := Rate * product((Co_dummy[i - 1] * (1 - X_dummy[i - 1])) ^ DO_dummy[i - 1, 1]); + Rate := Rate * (Co_dummy[i - 1] * (1 - X_dummy[i - 1])) ^ DO_dummy[i - 1, 1]; end if; end for; y := Fao / (k * (Co[Base_comp] * (1 - u)) ^ DO[Base_comp, 1] * Rate); diff --git a/Simulator/UnitOperations/PFR/PFR.mo b/Simulator/UnitOperations/PFR/PFR.mo index 76e321c..6e9316a 100644 --- a/Simulator/UnitOperations/PFR/PFR.mo +++ b/Simulator/UnitOperations/PFR/PFR.mo @@ -31,7 +31,7 @@ within Simulator.UnitOperations.PFR; //Inlet Stream Variables Real Tin(unit = "K", min = 0, start = Tg) "Inlet stream temperature"; Real Pin(unit = "Pa", min = 0, start = Pg) "Inlet stream pressure"; - Real Fin_pc[3, Nc](each unit = "mol/s", each min = 0, start={Fg,Fliqg,Fvapg}) "Inlet stream components molar flow rate in phase"; + Real Fin_pc[3, Nc](each unit = "mol/s", each min = 0, start=transpose(fill({Fg,Fliqg,Fvapg},Nc))) "Inlet stream components molar flow rate in phase"; Real Fin_p[3](each unit = "mol/s", each min = 0,start={Fg,Fliqg,Fvapg}) "Inlet stream molar flow rate in phase"; Real xin_pc[3, Nc](each unit = "-", each min = 0, each max = 1, start={xg,xg,xg}) "Inlet stream mole fraction"; Real Hin(unit = "kJ/kmol",start=Htotg) "Inlet stream enthalpy"; @@ -43,7 +43,7 @@ within Simulator.UnitOperations.PFR; Real Tout(unit = "K", min = 0, start = Tg) "Outlet stream temperature"; Real Pout(unit = "Pa", min = 0, start = Pg) "Outlet stream pressure"; Real Fout_p[3](each unit = "mol/s", each min = 0, start={Fg,Fliqg,Fvapg}) "Outlet stream molar flow rate"; - Real Fout_pc[3, Nc](each unit = "mol/s", each min = 0, start={Fg,Fliqg,Fvapg}) "Outlet stream components molar flow rate"; + Real Fout_pc[3, Nc](each unit = "mol/s", each min = 0, start=transpose(fill({Fg,Fliqg,Fvapg},Nc))) "Outlet stream components molar flow rate"; Real xout_pc[3, Nc](each min = 0,start={xg,xg,xg}) "Mole Fraction of Component in outlet stream"; Real Hout(unit = "kJ/kmol",start=Htotg) "Outlet stream molar enthalpy"; Real Sout(unit = "kJ/[kmol.K]") "Outlet stream molar entropy"; @@ -96,8 +96,9 @@ within Simulator.UnitOperations.PFR; extends GuessModels.InitialGuess; equation + X_r[Base_C] = 0.0991; //Workaround for bug. Lets model compile, but doesn't simulate correctly. //connector-Equations - In.P = Pin; + In.P = Pin; In.T = Tin; In.F = Fin_p[1]; In.H = Hin; From e4aab4f7bd47883b78a4fc86fc770a9d43dc7dd2 Mon Sep 17 00:00:00 2001 From: Biananino Date: Thu, 13 Jun 2024 22:48:23 -0400 Subject: [PATCH 21/28] Fixed problems with PFR --- Simulator/Examples/PFR.mo | 2 +- Simulator/UnitOperations/PFR/Integral.mo | 2 +- Simulator/UnitOperations/PFR/PFR.mo | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Simulator/Examples/PFR.mo b/Simulator/Examples/PFR.mo index a022c11..632e97e 100644 --- a/Simulator/Examples/PFR.mo +++ b/Simulator/Examples/PFR.mo @@ -42,10 +42,10 @@ package PFR "Example of Simulating a PFR" //======================================================================== //Inputs and Specifications S1.x_pc[1, :] = {0.2, 0.8, 0}; + B1.X_r[1] = 0.0991; S1.P = 100000; S1.T = 360; S1.F_p[1] = 100; -//B1.X_r[1] = 0.0991; This line makes the compilation fail. annotation( Documentation(info = "This is an executable model to simualate the PFR example where all the components are defined, material stream, plug flow reactor & kinetic reaction specifications are declared, model instances are connectedPFR model from the UnitOperations package has been instantiated here.

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Ethylene Oxide): 0.2
Mole Fraction (Water): 0.8
Mole Fraction (Ethylene Glycol): 0
Pressure: 100000 Pa
Temperature: 360 K

Reaction
Ethylene Oxide + Water ----> Ethylene Glycol

Compressor Specification: Conversion of Ethylene Oxide: 9.91%
   Operation Mode: isothermal
")); end PFRSimulation; diff --git a/Simulator/UnitOperations/PFR/Integral.mo b/Simulator/UnitOperations/PFR/Integral.mo index e93262e..887e010 100644 --- a/Simulator/UnitOperations/PFR/Integral.mo +++ b/Simulator/UnitOperations/PFR/Integral.mo @@ -23,7 +23,7 @@ within Simulator.UnitOperations.PFR; Rate := 1; for i in 2:Nc loop if DO[Base_comp, 1] == 0 then -// Rate := Rate * product((Co[i] + Sc[i, 1] / Bc[1] * Co[Base_comp] * u) ^ DO[i, 1]); +// Rate := Rate * product((Co[i] + Sc[i, 1] / Bc[1] * Co[Base_comp] * u) ^ DO[i, 1]); Needs to be changed later when adding support for multiple reactions. Rate := Rate * (Co[i] + Sc[i, 1] / Bc[1] * Co[Base_comp] * u) ^ DO[i, 1]; else // Rate := Rate * product((Co_dummy[i - 1] * (1 - X_dummy[i - 1])) ^ DO_dummy[i - 1, 1]); diff --git a/Simulator/UnitOperations/PFR/PFR.mo b/Simulator/UnitOperations/PFR/PFR.mo index 6e9316a..b1f104c 100644 --- a/Simulator/UnitOperations/PFR/PFR.mo +++ b/Simulator/UnitOperations/PFR/PFR.mo @@ -24,7 +24,7 @@ within Simulator.UnitOperations.PFR; Dialog(tab = "Reactor Specifications", group = "Calculation Parameters")); parameter Real Pdel(unit = "Pa") "Pressure Drop" annotation( Dialog(tab = "Reactor Specifications", group = "Calculation Parameters")); - Integer Base_C "Base component"; + parameter Integer Base_C = BC_r[1] "Base component"; //========================================================================= //Model Variables Integer Phaseindex; @@ -96,7 +96,6 @@ within Simulator.UnitOperations.PFR; extends GuessModels.InitialGuess; equation - X_r[Base_C] = 0.0991; //Workaround for bug. Lets model compile, but doesn't simulate correctly. //connector-Equations In.P = Pin; In.T = Tin; @@ -116,7 +115,6 @@ within Simulator.UnitOperations.PFR; En.Q = Q; //Phase Equilibria //========================================================================================================== - Base_C = BC_r[1]; for i in 1:Nc loop Pvapin_c[i] = Simulator.Files.ThermodynamicFunctions.Psat(C[i].VP, Tin); Pvapout_c[i] = Simulator.Files.ThermodynamicFunctions.Psat(C[i].VP, Tout); From 892aef7afc6eaeaa42cd82c7a9a713b047fb0a9f Mon Sep 17 00:00:00 2001 From: Biananino Date: Thu, 13 Jun 2024 23:34:26 -0400 Subject: [PATCH 22/28] Updated Absorption Column. --- Simulator/Examples/Absorption.mo | 6 +++--- .../UnitOperations/AbsorptionColumn/AbsCol.mo | 3 ++- .../UnitOperations/AbsorptionColumn/AbsTray.mo | 14 +++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Simulator/Examples/Absorption.mo b/Simulator/Examples/Absorption.mo index 901a9c8..02e0e73 100644 --- a/Simulator/Examples/Absorption.mo +++ b/Simulator/Examples/Absorption.mo @@ -18,7 +18,7 @@ package Absorption "Example of Simulating an Absorption Column" model AbsColumn "Extension of Absorption COlumn with instance of Tray" extends Simulator.UnitOperations.AbsorptionColumn.AbsCol; - Tray tray[Nt](each Nc = Nc, each C = C); + redeclare Tray tray[Nt](each Nc = Nc, each C = C); annotation( Documentation(info = "This is a non-executable model is created inside the package Absorption to extend the Absorption Column model along with the necessary property method from ThermodynamicPackages which is RaoultsLaw in this case.

Tray model is also instantiated in this model to complete building of absorption column model.

It will be instantiated in the AbsorptionSimulation model to create the required instance of the absorption column model.
")); end AbsColumn; @@ -39,7 +39,7 @@ package Absorption "Example of Simulating an Absorption Column" Placement(visible = true, transformation(origin = {52, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Simulator.Examples.Absorption.MS S4(Nc = Nc, C = C) annotation( Placement(visible = true, transformation(origin = {52, -94}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - Simulator.Examples.Absorption.MS S2 annotation( + Simulator.Examples.Absorption.MS S2(Nc = Nc, C = C) annotation( Placement(visible = true, transformation(origin = {-88, -54}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation connect(B1.Out_Bot, S4.In) annotation( @@ -63,4 +63,4 @@ package Absorption "Example of Simulating an Absorption Column" end AbsorptionSimulation; annotation( Documentation(info = "
Following problem statement is simulated in this Absorption Column example:


Problem Statement:

Component System: Air, Water, Acetone
Thermodynamics: Raoult's Law

Material Stream Information

Feed Stream 1 (Solvent)
Molar Flow Rate: 30 mol/s
Mole Fraction (Water): 1
Pressure: 101325 Pa
Temperature: 325 K

Feed Stream 2 (Gas Mixture)
Molar Flow Rate: 30 mol/s
Mole Fraction (Air): 0.5
Mole Fraction (Acetone): 0.5
Pressure: 101325 Pa
Temperature: 335 K


Simulate an absorption column with 10 stages where the solvent enters from the top and gas mixture enters from bottom to remove acetone from air.


This package is created to demnostrate the simualtion of an Absorption Column. Following models are created inside the package:
  1. MS (Non-executable model): created to extend the material stream along with the necessary thermodynamic package.
  2. Tray (Non-executable model): created to extend the tray along with the necessary thermodynamic package.
  3. AbsColumn (Non-executable model): created to extend the Absorption Column along with the necessary thermodynamic package.
  4. AbsorptionSimulation (Executable model): All the components are defined, material stream & Absorption Column specifications are declared, model instances are connected to make the file executable.
")); -end Absorption; +end Absorption; \ No newline at end of file diff --git a/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo b/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo index 48142e5..20c9d79 100644 --- a/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo +++ b/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo @@ -1,6 +1,6 @@ within Simulator.UnitOperations.AbsorptionColumn; -model AbsCol "Model of an absorption column representing fractionating towers where mixture is separated in equilibrium stages" +model AbsCol "Model of an absorption column representing fractionating towers where mixture is separated in equilibrium stages" //Model seems to be broken, doesn't run on the old frontend either. extends Simulator.Files.Icons.AbsorptionColumn; import data = Simulator.Files.ChemsepDatabase; parameter data.GeneralProperties C[Nc] "Component instances array" annotation( @@ -18,6 +18,7 @@ model AbsCol "Model of an absorption column representing fractionating towers wh Placement(visible = true, transformation(origin = {100, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {250, 300}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Simulator.Files.Interfaces.matConn Out_Bot(Nc = Nc) annotation( Placement(visible = true, transformation(origin = {100, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {250, -300}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + replaceable Simulator.UnitOperations.AbsorptionColumn.AbsTray tray[2](each Nc = Nc); equation //connector equation tray[1].Fliq_s[1] = In_Top.F; diff --git a/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo b/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo index dcdf2bf..cff0037 100644 --- a/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo +++ b/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo @@ -8,12 +8,16 @@ model AbsTray "Model of a tray used in absorption column" Real T(min = 0, start = Tg); Real Fvap_s[2](each min = 0, start={Fg,Fg}); Real Fliq_s[2](each min = 0, start={Fliqg,Fliqg}); - Real xvap_sc[2, Nc](each min = 0, each max = 1, start=xvapg); - Real xliq_sc[2, Nc](each min = 0, each max = 1, start=xliqg); + Real xvap_sc[2, Nc](each min = 0, each max = 1, each start=xvapg); + Real xliq_sc[2, Nc](each min = 0, each max = 1, each start=xliqg); Real Hvap_s[2](start={Hvapg,Hvapg}), Hliq_s[2](start={Hliqg,Hliqg}), Hvapout_c[Nc], Hliqout_c[Nc]; - Real x_pc[3, Nc](each min =0, each max = 0,start=xliqg); - Real Pdew(min = 0, start =Pmax); - Real Pbubl(min = 0, start =Pmin); + Real x_pc[3, Nc](each min =0, each max = 1, each start=xliqg); + Real Pdew(min = 0, start = Pmax); + Real Pbubl(min = 0, start = Pmin); + //Thermodynamics packages variables + Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; + Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; Simulator.Files.Interfaces.trayConn In_Liq(Nc = Nc) annotation( Placement(visible = true, transformation(origin = {-50, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-50, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); From 2ba9e3b49b36b32f2987b2600e984157f8d61ba1 Mon Sep 17 00:00:00 2001 From: Biananino Date: Tue, 18 Jun 2024 01:11:27 -0400 Subject: [PATCH 23/28] Updated Equilibrium Reactor --- Simulator/Files/Models/ReactionManager/BaseCalc.mo | 10 ++-------- .../Models/ReactionManager/EquilibriumReaction.mo | 7 ++++--- Simulator/UnitOperations/EquilibriumReactor.mo | 1 - 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Simulator/Files/Models/ReactionManager/BaseCalc.mo b/Simulator/Files/Models/ReactionManager/BaseCalc.mo index 578ca9f..5ea5f5a 100644 --- a/Simulator/Files/Models/ReactionManager/BaseCalc.mo +++ b/Simulator/Files/Models/ReactionManager/BaseCalc.mo @@ -17,8 +17,6 @@ for i in 1:Nc loop if Sc[i]<0 then N:=i; break; - else - i:=i; end if; end for; @@ -30,11 +28,7 @@ if Sc[i]<0 then if v2 Date: Wed, 19 Jun 2024 01:54:10 -0400 Subject: [PATCH 24/28] Updated UNIQUAC and Material Stream example --- Simulator/Examples/MaterialStream.mo | 4 ++-- Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo | 4 ++-- Simulator/Files/ThermodynamicPackages/UNIQUAC.mo | 12 ++++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Simulator/Examples/MaterialStream.mo b/Simulator/Examples/MaterialStream.mo index a0b6770..3cfcce2 100644 --- a/Simulator/Examples/MaterialStream.mo +++ b/Simulator/Examples/MaterialStream.mo @@ -110,8 +110,8 @@ package MaterialStream "Examples of Simulating Material Stream using Different M import data = Simulator.Files.ChemsepDatabase; parameter data.Ethanol eth; parameter data.Water wat; - extends Simulator.Streams.MaterialStream(Nc = 2, C = {eth, wat}, Pbubl(start = 101325), Pdew(start = 101325), x_pc(each start = 0.33), xvap(start = 0.68)); - extends Simulator.Files.ThermodynamicPackages.UNIQUAC; + extends Simulator.Streams.MaterialStream(Nc = 2, C = {eth, wat}, Pbubl(start = 101325), Pdew(start = 101325), xvap(start = 0.68),gmadew_c(each start = 2.2), gmabubl_c(each start = 1)); + extends Simulator.Files.ThermodynamicPackages.UNIQUAC(Nc = 2, C = {eth, wat}); equation x_pc[1, :] = {0.5, 0.5}; F_p[1] = 50; diff --git a/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo b/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo index d59e3fa..ad67020 100644 --- a/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo +++ b/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo @@ -2,12 +2,12 @@ within Simulator.Files.ThermodynamicFunctions; function PoyntingCF "Function to compute the Poynting Correction Factor" extends Modelica.Icons.Function; - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; input Integer Nc; input Real Pc, Tc, RP, AF, MW; input Real T, P; input Real gma, Psat, rho; - parameter Integer Choice = 2; + input Integer Choice = 2; output Real PCF; protected Real vl; diff --git a/Simulator/Files/ThermodynamicPackages/UNIQUAC.mo b/Simulator/Files/ThermodynamicPackages/UNIQUAC.mo index 932c692..2ce7b33 100644 --- a/Simulator/Files/ThermodynamicPackages/UNIQUAC.mo +++ b/Simulator/Files/ThermodynamicPackages/UNIQUAC.mo @@ -3,6 +3,14 @@ within Simulator.Files.ThermodynamicPackages; model UNIQUAC //Libraries import Simulator.Files.*; + //Components parameters + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; + Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1); + Real P(unit = "Pa", min = 0) "Pressure"; + Real T(unit = "K") "Temperature"; + Real Pbubl(unit = "Pa", min = 0) "Bubble point pressure"; + Real Pdew(unit = "Pa", min = 0) "dew point pressure"; //Parameter Section //Binary Interaction Parameters //Function :BIP_UNIQUAC is used to obtain the interaction parameters @@ -14,7 +22,7 @@ within Simulator.Files.ThermodynamicPackages; //Variable Section Real tow[Nc, Nc] "Energy interaction parameter"; //Intermediate variables to calculate the combinatorial and residual part of activity coefficient at the input conditions - Real r(each start = 2, min = 0, max = 1), q(each start = 2); + Real r(start = 2), q(start = 2); Real theta_c[Nc]; Real S_c[Nc](each start = 1); Real Sum_c[Nc]; @@ -36,7 +44,7 @@ within Simulator.Files.ThermodynamicPackages; Real gmacdew_c[Nc](each start = 5) "Combinatorial Part of activity coefficent at dew point"; Real gmardew_c[Nc](each start = 2.5) "Residual part of activity coefficient at dew point"; Real gmaolddew_c[Nc](each start = 2.2) "Combinatorial Part of activity coefficent(without correction)"; - Real gmadew_c[Nc](each start = 2.2) "Activity coefficent at dew point"; + Real gmadew_c[Nc](each start = 2.2) "Activity coefficent at dew point"; //Fugacity coefficient Real phivapdew_c[Nc] "Vapour Fugacity coefficient at dew point"; Real phildew_c[Nc](each start = 0.5); From 1c037b6025a454d53a691dd887b5280e26bcfe79 Mon Sep 17 00:00:00 2001 From: Biananino Date: Wed, 19 Jun 2024 01:54:44 -0400 Subject: [PATCH 25/28] Updated Peng Robinson --- .../ThermodynamicPackages/PengRobinson.mo | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Simulator/Files/ThermodynamicPackages/PengRobinson.mo b/Simulator/Files/ThermodynamicPackages/PengRobinson.mo index e0f3ce9..fd740f9 100644 --- a/Simulator/Files/ThermodynamicPackages/PengRobinson.mo +++ b/Simulator/Files/ThermodynamicPackages/PengRobinson.mo @@ -9,6 +9,10 @@ within Simulator.Files.ThermodynamicPackages; parameter Real kij_c[Nc, Nc](each start = 1) = Simulator.Files.ThermodynamicFunctions.BIPPR(Nc, C.name); //====================================================================== + //Stream variables + Real T(unit = "K", start = Tg) "Temperature"; + Real P(unit = "Pa", min = 0, start = Pg) "Pressure"; + Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1, start={xguess,xg,yg}) "Component mole fraction in phase"; //Model Variables Real Tr_c[Nc](each start = Tg) "Reduced temperature"; Real b_c[Nc]; @@ -17,7 +21,7 @@ within Simulator.Files.ThermodynamicPackages; Real q_c[Nc]; Real aij_c[Nc, Nc]; Real K_c[Nc](start = K_guess); - Real Pvap_c[Nc](start=Pg) "Saturated Vapor Pressure"; + Real Pvap_c[Nc](each start=Pg) "Saturated Vapor Pressure"; Real philiq_c[Nc](each start = 5) "Liquid Phase Fugasity coefficient"; Real phivap_c[Nc](each start = 5) "Vapor Phase Fugasity coefficient"; Real gmabubl_c[Nc], gmadew_c[Nc]; @@ -26,14 +30,14 @@ within Simulator.Files.ThermodynamicPackages; Real aMliq, bMliq; Real Aliq(start=xliqg), Bliq(start=xvapg); Real Cliq[4]; - Real Z_RL[3, 2](start=xliqg); - Real Zliq[3](start=xliqg), Zll(start=xvapg); + Real Z_RL[3, 2](each start=xliqg); + Real Zliq[3](each start=xliqg), Zll(start=xvapg); Real sumxliq[Nc]; Real aMvap, bMvap; Real Avap(start=xliqg), Bvap(start=xvapg); Real Cvap[4]; - Real Z_RV[3, 2](start= xvapg); - Real Zvap[3](start=xvapg), Zvv; + Real Z_RV[3, 2](each start=xvapg); + Real Zvap[3](each start=xvapg), Zvv; Real sumxvap[Nc]; Real A, B, Cdummy, D_c[Nc], E, F, G, H_c[Nc], I_c[Nc], J_c[Nc]; Real gma[Nc]; @@ -69,7 +73,7 @@ within Simulator.Files.ThermodynamicPackages; Cliq[2] = Bliq - 1; Cliq[3] = Aliq - 3 * Bliq ^ 2 - 2 * Bliq; Cliq[4] = Bliq ^ 3 + Bliq ^ 2 - Aliq * Bliq; - Z_RL = Modelica.Math.Vectors.Utilities.roots(Cliq); + Z_RL = Modelica.Math.Polynomials.roots(Cliq); Zliq = {Z_RL[i, 1] for i in 1:3}; Zll = min({Zliq}); sumxliq = {sum({x_pc[2, j] * aij_c[i, j] for j in 1:Nc}) for i in 1:Nc}; @@ -114,7 +118,7 @@ within Simulator.Files.ThermodynamicPackages; Cvap[2] = Bvap - 1; Cvap[3] = Avap - 3 * Bvap ^ 2 - 2 * Bvap; Cvap[4] = Bvap ^ 3 + Bvap ^ 2 - Avap * Bvap; - Z_RV = Modelica.Math.Vectors.Utilities.roots(Cvap); + Z_RV = Modelica.Math.Polynomials.roots(Cvap); Zvap = {Z_RV[i, 1] for i in 1:3}; Zvv = max({Zvap}); sumxvap = {sum({x_pc[3, j] * aij_c[i, j] for j in 1:Nc}) for i in 1:Nc}; From 63127c7b6ec601699cc7ac86c24b088fbf2f8ba0 Mon Sep 17 00:00:00 2001 From: Biananino Date: Wed, 19 Jun 2024 03:18:53 -0400 Subject: [PATCH 26/28] Updated UNIFAC --- Simulator/Files/ThermodynamicPackages/UNIFAC.mo | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Simulator/Files/ThermodynamicPackages/UNIFAC.mo b/Simulator/Files/ThermodynamicPackages/UNIFAC.mo index e64210f..36aee2e 100644 --- a/Simulator/Files/ThermodynamicPackages/UNIFAC.mo +++ b/Simulator/Files/ThermodynamicPackages/UNIFAC.mo @@ -4,6 +4,14 @@ within Simulator.Files.ThermodynamicPackages; //Libraries import Simulator.Files.*; import Simulator.Files.ThermodynamicFunctions; + //Stream Parameters + parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; + Real x_pc[3, Nc](each unit = "-", each min = 0, each max = 1); + Real P(unit = "Pa", min = 0) "Pressure"; + Real T(unit = "K") "Temperature"; + Real Pbubl(unit = "Pa", min = 0) "Bubble point pressure"; + Real Pdew(unit = "Pa", min = 0) "dew point pressure"; //Parameter Section parameter Integer m = 4 "substitue of number of different group"; parameter Integer k = 4 "number of different group in component i"; @@ -55,6 +63,8 @@ within Simulator.Files.ThermodynamicPackages; Real gmardew_c[Nc] "residual activity coefficient of components at dew point"; Real sumdew_c[Nc]; Real xliqdew_c[Nc](each start = 0.5); + //?? Parameters + Real B[Nc, k]; //============================================================================== equation Cpres_c[:] = zeros(3); @@ -105,7 +115,7 @@ within Simulator.Files.ThermodynamicPackages; sum_c[:] := fill(0, Nc); for j in 1:k loop for i in 1:Nc loop - sum_c[i] := sum_c[i] + theta_k[j] * B_ck[i, j] / S_k[j] - e_kc[j, i] * log(B[i, j] / S_k[j]); + sum_c[i] := sum_c[i] + theta_k[j] * B_ck[i, j] / S_k[j] - e_kc[j, i] * log(B_ck[i, j] / S_k[j]); gmares_c[i] := exp(q[i] * (1 - sum_c[i])); end for; end for; From 4b30bddba7cc7baecc789ad545622193fabc98d9 Mon Sep 17 00:00:00 2001 From: Biananino Date: Wed, 19 Jun 2024 03:24:27 -0400 Subject: [PATCH 27/28] Fixed minor mistake in Valve, Centrifugal Pump --- Simulator/UnitOperations/CentrifugalPump.mo | 2 +- Simulator/UnitOperations/Valve.mo | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulator/UnitOperations/CentrifugalPump.mo b/Simulator/UnitOperations/CentrifugalPump.mo index 8d38019..0bdb02e 100644 --- a/Simulator/UnitOperations/CentrifugalPump.mo +++ b/Simulator/UnitOperations/CentrifugalPump.mo @@ -6,7 +6,7 @@ model CentrifugalPump "Model of a centrifugal pump to provide energy to liquid s extends Simulator.Files.Icons.CentrifugalPump; parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] "Component instances array" annotation( Dialog(tab = "Pump Specifications", group = "Component Parameters")); - parameter Integer Nc = 2 "Number of components" annotation( + parameter Integer Nc "Number of components" annotation( Dialog(tab = "Pump Specifications", group = "Component Parameters")); parameter Real Eff(unit = "-") "Efficiency" annotation( Dialog(tab = "Pump Specifications", group = "Calculation Parameters")); diff --git a/Simulator/UnitOperations/Valve.mo b/Simulator/UnitOperations/Valve.mo index 32d3783..d428702 100644 --- a/Simulator/UnitOperations/Valve.mo +++ b/Simulator/UnitOperations/Valve.mo @@ -4,7 +4,7 @@ model Valve "Model of a valve to regulate the pressure of a material stream" extends Simulator.Files.Icons.Valve; parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] "Component instances array" annotation( Dialog(tab = "Valve Specifications", group = "Component Parameters")); - parameter Integer Nc = 3 "Number of components" annotation( + parameter Integer Nc "Number of components" annotation( Dialog(tab = "Valve Specifications", group = "Component Parameters")); //==================================================================================== Real Fin(unit = "mol/s", min = 0, start = Fg) "Inlet stream molar flow rate"; From 1bef7cdd0d14877ce72dc0dfd75c2fc871ea1be6 Mon Sep 17 00:00:00 2001 From: Biananino Date: Thu, 20 Jun 2024 00:22:10 -0400 Subject: [PATCH 28/28] Fixed minor mistake in Absorbtion Column. Still doesn't simulate correctly. --- Simulator/Examples/Absorption.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulator/Examples/Absorption.mo b/Simulator/Examples/Absorption.mo index 02e0e73..d94419e 100644 --- a/Simulator/Examples/Absorption.mo +++ b/Simulator/Examples/Absorption.mo @@ -17,8 +17,8 @@ package Absorption "Example of Simulating an Absorption Column" end Tray; model AbsColumn "Extension of Absorption COlumn with instance of Tray" - extends Simulator.UnitOperations.AbsorptionColumn.AbsCol; - redeclare Tray tray[Nt](each Nc = Nc, each C = C); + extends Simulator.UnitOperations.AbsorptionColumn.AbsCol( + redeclare Tray tray[Nt](each Nc = Nc, each C = C)); annotation( Documentation(info = "This is a non-executable model is created inside the package Absorption to extend the Absorption Column model along with the necessary property method from ThermodynamicPackages which is RaoultsLaw in this case.

Tray model is also instantiated in this model to complete building of absorption column model.

It will be instantiated in the AbsorptionSimulation model to create the required instance of the absorption column model.
")); end AbsColumn;