From 70a6f39433d92fef899548b689773d29f2e4e09d Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Fri, 23 Jun 2023 16:27:29 +0530 Subject: [PATCH 01/42] Modified MatStreamSimulation.mo --- Simulator/Examples/CompositeMS.mo | 2 +- Simulator/Examples/HeatExchanger.mo | 47 +++++++++---------- Simulator/Files/ChemsepDatabase/Benzene.mo | 2 +- .../ChemsepDatabase/GeneralProperties.mo | 6 +-- Simulator/Files/ChemsepDatabase/Toluene.mo | 2 +- .../ThermodynamicFunctions/PoyntingCF.mo | 2 +- .../ThermodynamicPackages/GraysonStreed.mo | 2 +- Simulator/Files/ThermodynamicPackages/NRTL.mo | 2 +- .../Files/ThermodynamicPackages/RaoultsLaw.mo | 18 ++++--- Simulator/GuessModels/InitialGuess.mo | 14 +++--- Simulator/Streams/MaterialStream.mo | 13 ++--- Simulator/UnitOperations/HeatExchanger.mo | 6 +-- 12 files changed, 60 insertions(+), 56 deletions(-) diff --git a/Simulator/Examples/CompositeMS.mo b/Simulator/Examples/CompositeMS.mo index 6f70299..91c5cdc 100644 --- a/Simulator/Examples/CompositeMS.mo +++ b/Simulator/Examples/CompositeMS.mo @@ -28,4 +28,4 @@ package CompositeMS "Example of Simulating a Material Stream" end MatStreamSimulation; annotation( Documentation(info = "
Following problem statement is simulated in this Material Stream example

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: 368 K

Simulate a material stream to compute all its thermo-physical properties at conditions mentioned above.

This package is created to demnostrate the simualtion of a Material Stream. 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. MatStreamSimulation (Executable model): All the components are defined, material stream specifications are declared to make the file executable.
")); -end CompositeMS; +end CompositeMS; \ No newline at end of file diff --git a/Simulator/Examples/HeatExchanger.mo b/Simulator/Examples/HeatExchanger.mo index 35df6f6..26d42dc 100644 --- a/Simulator/Examples/HeatExchanger.mo +++ b/Simulator/Examples/HeatExchanger.mo @@ -1,12 +1,13 @@ within Simulator.Examples; - + package HeatExchanger "Example of Simulating Heat Exchanger" //================================================================================================================ extends Modelica.Icons.ExamplesPackage; + model MS "Extension of Material Stream with Raoult's Law" extends Simulator.Streams.MaterialStream; extends Simulator.Files.ThermodynamicPackages.RaoultsLaw; - annotation( + annotation( Documentation(info = "This is a non-executable model is created inside the package Cooler to extend the MaterialStream model along with the necessary property method from ThermodynamicPackages which is RaoultsLaw in this case.

It will be instantiated in the HXSimulation and ShellnTubeHXSimulation model to create the required number of instances of the material stream model.
")); end MS; @@ -51,18 +52,15 @@ package HeatExchanger "Example of Simulating Heat Exchanger" end HXSimulation; model ShellnTubeHXSimulation "Calculating outlet temperatures of material stream by specifying the shell and tube side properties in a Heat Exchanger" - extends Modelica.Icons.Example; - import data = Simulator.Files.ChemsepDatabase; - + extends Modelica.Icons.Example; + import data = Simulator.Files.ChemsepDatabase; parameter data.Water wat; parameter data.Noctane oct; parameter data.Nnonane non; parameter data.Ndecane dec; - parameter Integer Nc = 4; - parameter data.GeneralProperties C[Nc] = {wat,oct,non,dec}; - - Simulator.UnitOperations.HeatExchanger B1( C = C,Cmode = "Design", Mode = "CounterCurrent", Nc = Nc, Pdelc = 0, Pdelh = 0, Qloss = 0) annotation( + parameter data.GeneralProperties C[Nc] = {wat, oct, non, dec}; + Simulator.UnitOperations.HeatExchanger B1(C = C, Cmode = "Design", Mode = "CounterCurrent", Nc = Nc, Pdelc = 0, Pdelh = 0, Qloss = 0) annotation( Placement(visible = true, transformation(origin = {-16, -2}, extent = {{-22, -22}, {22, 22}}, rotation = 0))); Simulator.Examples.HeatExchanger.MS S1(Nc = Nc, C = C) annotation( Placement(visible = true, transformation(origin = {-86, 38}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); @@ -72,27 +70,26 @@ package HeatExchanger "Example of Simulating Heat Exchanger" Placement(visible = true, transformation(origin = {-22, 64}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Simulator.Examples.HeatExchanger.MS S4(Nc = Nc, C = C) annotation( Placement(visible = true, transformation(origin = {46, -48}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - equation - connect(S1.Out, B1.In_Hot) annotation( + connect(S1.Out, B1.In_Hot) annotation( Line(points = {{-76, 38}, {-76, -2}, {-38, -2}})); - connect(B1.Out_Hot, S3.In) annotation( + connect(B1.Out_Hot, S3.In) annotation( Line(points = {{6, -2}, {6, 45}, {58, 45}, {58, 70}})); - connect(B1.Out_Cold, S4.In) annotation( + connect(B1.Out_Cold, S4.In) annotation( Line(points = {{-16, -24}, {-16, -48}, {36, -48}})); - connect(S2.Out, B1.In_Cold) annotation( + connect(S2.Out, B1.In_Cold) annotation( Line(points = {{-12, 64}, {-12, 38}, {-16, 38}, {-16, 20}})); - S1.x_pc[1, :] = {0, 0, 0.1, 0.9}; - S2.x_pc[1, :] = {1, 0, 0, 0}; - S1.F_p[1] = 212.94371; - S2.F_p[1] = 3077.38424; - S1.T = 377.03889; - S2.T = 304.26111; - S1.P = 1116948.66173; - S2.P = 606737.54464; - annotation( + S1.x_pc[1, :] = {0, 0, 0.1, 0.9}; + S2.x_pc[1, :] = {1, 0, 0, 0}; + S1.F_p[1] = 212.94371; + S2.F_p[1] = 3077.38424; + S1.T = 377.03889; + S2.T = 304.26111; + S1.P = 1116948.66173; + S2.P = 606737.54464; + annotation( Documentation(info = "This is an executable model to simualate the Heat Exchanger example where all the components are defined, material stream & heat exchanger specifications are declared, model instances are connected. Heat Exchanger model from the UnitOperations package has been instantiated here.

Material Stream Information

Hot Stream
Molar Flow Rate: 212.94371 mol/s
Mole Fraction (Water): 0
Mole Fraction (N-Octane): 0
Mole Fraction (N-Nonane): 0.1
Mole Fraction (N-Decane): 0.9
Pressure: 1116948.66 Pa
Temperature: 377.03889 K


Cold Stream
Molar Flow Rate: 3077.38424 mol/s
Mole Fraction (Water): 1
Mole Fraction (N-Octane): 0
Mole Fraction (N-Nonane): 1
Mole Fraction (N-Decane): 0
Pressure: 606737.54464 Pa
Temperature: 304.26111 K
")); - end ShellnTubeHXSimulation; + end ShellnTubeHXSimulation; annotation( Documentation(info = "
Following two problem statement are simulated in this Heat Exchanger example:

Problem Statement 1:

Component System: Styrene and Toluene
Thermodynamics: Raoult's Law

Material Stream Information

Hot Stream
Molar Flow Rate: 181.46776 mol/s
Mole Fraction (Styrene): 1
Mole Fraction (Toluene): 0
Pressure: 344737.24 Pa
Temperature: 422.03 K


Cold Stream
Molar Flow Rate: 170.93 mol/s
Mole Fraction (Styrene): 0
Mole Fraction (Toluene): 1
Pressure: 620527.03 Pa
Temperature: 310.93 K

Simulate a Heat Exchanger with above mentioned material streams as inlet streams. Find the outlet temperatures such that the overall heat transfer coefficient is 300 W/[m2.K] and amount of heat exchanged in 2.7 MW.


Problem Statement 2:

Component System: Water, N-Octane, N-Nonane and N-Decane
Thermodynamics: Raoult's Law

Material Stream Information

Hot Stream
Molar Flow Rate: 212.94371 mol/s
Mole Fraction (Water): 0
Mole Fraction (N-Octane): 0
Mole Fraction (N-Nonane): 0.1
Mole Fraction (N-Decane): 0.9
Pressure: 1116948.66 Pa
Temperature: 377.03889 K


Cold Stream
Molar Flow Rate: 3077.38424 mol/s
Mole Fraction (Water): 1
Mole Fraction (N-Octane): 0
Mole Fraction (N-Nonane): 1
Mole Fraction (N-Decane): 0
Pressure: 606737.54464 Pa
Temperature: 304.26111 K

Simulate a Heat Exchanger with above mentioned material streams as inlet streams. Find the outlet temperatures with the given shell and tube heat exchanger configuration.


This package is created to demnostrate the simualtion of a Heat Exchanger. 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. HXSimulation (Executable model for Problem Statement 1): All the components are defined, material stream & Heat Exchanger specifications are declared, model instances are connected to make the file executable.
  3. ShellnTubeHXSimulation (Executable model for Problem Statement 2): All the components are defined, material stream & Shell and Tube Heat Exchanger specifications are declared, model instances are connected to make the file executable.
")); -end HeatExchanger; +end HeatExchanger; \ No newline at end of file diff --git a/Simulator/Files/ChemsepDatabase/Benzene.mo b/Simulator/Files/ChemsepDatabase/Benzene.mo index 73a5082..5c40a07 100644 --- a/Simulator/Files/ChemsepDatabase/Benzene.mo +++ b/Simulator/Files/ChemsepDatabase/Benzene.mo @@ -1,6 +1,6 @@ within Simulator.Files.ChemsepDatabase; -model Benzene +record Benzene extends Modelica.Icons.Record; extends GeneralProperties(SN = 125, name = "Benzene", CAS = "71-43-2", Tc = 562.05, Pc = 4895000, Vc = 0.256, Cc = 0.268, Tb = 353.24, Tm = 278.68, TT = 278.68, TP = 4764.22, MW = 78.114, LVB = 0.08941, AF = 0.209, SP = 18700, DM = 0, SH = -168070000.0, IGHF = 8.288E+07, GEF = 1.296E+08, AS = 269300, HFMP = 9866000, HOC = -3.136E+09, LiqDen = {105, 0.99938, 0.26348, 562.05, 0.27856, 0}, VP = {101, 88.368, -6712.9, -10.022, 0.000007694, 2}, LiqCp = {16, 111460, -1854.3, 22.399, -0.028936, 0.000028991}, HOV = {106, 4.881E+07, 0.61066, -0.25882, 0.032238, 0.022475}, VapCp = {16, 34010.24, -588.0978, 12.81777, -0.000197306, 5.142899E-08}, LiqVis = {101, -24.61, 1576.5, 2.1698, -0.0000051366, 2}, VapVis = {102, 3.1366E-08, 0.9675, 8.0285, -35.629, 0}, LiqK = {16, 0.049539, -177.97, 0.19475, -0.0073805, 0.0000027938}, VapK = {102, 0.0000049549, 1.4519, 154.14, 26202, 0}, Racketparam = 0.2696, UniquacR = 3.1878, UniquacQ = 2.4, ChaoSeadAF = 0.213, ChaoSeadSP = 18736.78, ChaoSeadLV = 0.0894); end Benzene; diff --git a/Simulator/Files/ChemsepDatabase/GeneralProperties.mo b/Simulator/Files/ChemsepDatabase/GeneralProperties.mo index 4e0f1c2..a249eeb 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"; @@ -31,8 +31,8 @@ model GeneralProperties "Model to declare the variables for thermophysical prope parameter Real LiqCp[6] (each unit="J/kmol/K") "Liquid Heat Capacity Coefficients"; parameter Real HOV[6] (each unit="J/kmol") "Heat of Vaporization Coefficients"; parameter Real VapCp[6] (each unit="J/kmol/K") "Ideal Gas Heat Capacity Coefficients"; - parameter Real LiqVis[6] (each unit="Pa s") "Liquid Viscosity Coefficients"; - parameter Real VapVis[6] (each unit="Pa s") "Vapor Viscosity Coefficients"; + parameter Real LiqVis[6] (each unit="Pa.s") "Liquid Viscosity Coefficients"; + parameter Real VapVis[6] (each unit="Pa.s") "Vapor Viscosity Coefficients"; parameter Real LiqK[6] (each unit="W/m/K") "Liquid Thermal Conductivity Coefficients"; parameter Real VapK[6] (each unit="W/m/K") "Vapor Thermal Conductivity Coefficients"; parameter Real Racketparam (unit="-") "Racket Parameter"; diff --git a/Simulator/Files/ChemsepDatabase/Toluene.mo b/Simulator/Files/ChemsepDatabase/Toluene.mo index b70b061..731b65d 100644 --- a/Simulator/Files/ChemsepDatabase/Toluene.mo +++ b/Simulator/Files/ChemsepDatabase/Toluene.mo @@ -1,6 +1,6 @@ within Simulator.Files.ChemsepDatabase; -model Toluene +record Toluene extends Modelica.Icons.Record; extends GeneralProperties(SN = 140, name = "Toluene", CAS = "108-88-3", Tc = 591.75, Pc = 4108000, Vc = 0.316, Cc = 0.264, Tb = 383.79, Tm = 178.18, TT = 178.18, TP = 0.0475285, MW = 92.141, LVB = 0.10687, AF = 0.264, SP = 18250, DM = 1.2E-30, SH = -168070000.0, IGHF = 5.017E+07, GEF = 1.222E+08, AS = 320990, HFMP = 6636000, HOC = -3.734E+09, LiqDen = {105, 0.89799, 0.27359, 591.75, 0.30006, 0}, VP = {101, 32.89891, -5013.81, -1.348918, -1.869928E-06, 2}, LiqCp = {16, 28291, 48.171, 10.912, 0.0020542, 8.7875E-07}, HOV = {106, 5.3752E+07, 0.50341, 0.24755, -0.72898, 0.37794}, VapCp = {16, 47225, -565.85, 12.856, 0.000005535, -1.998E-08}, LiqVis = {101, -152.84, 5644.6, 22.826, -0.000040987, 2}, VapVis = {102, 8.5581E-07, 0.49514, 307.82, 1891.6, 0}, LiqK = {16, -0.072922, -23.153, -1.0277, -0.0017074, 3.6787E-07}, VapK = {102, 0.000006541, 1.4227, 190.97, 21890, 0}, Racketparam = 0.2646, UniquacR = 3.9228, UniquacQ = 2.968, ChaoSeadAF = 0.2591, ChaoSeadSP = 18245.86, ChaoSeadLV = 0.1068); end Toluene; diff --git a/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo b/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo index d59e3fa..c85a460 100644 --- a/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo +++ b/Simulator/Files/ThermodynamicFunctions/PoyntingCF.mo @@ -2,7 +2,7 @@ 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; diff --git a/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo b/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo index 5fbc14b..e646bc0 100644 --- a/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo +++ b/Simulator/Files/ThermodynamicPackages/GraysonStreed.mo @@ -4,7 +4,7 @@ within Simulator.Files.ThermodynamicPackages; //==================================================================== //Header Files and Parameters - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; parameter Real R = 8.314; parameter Real u = 1; import Simulator.Files.*; diff --git a/Simulator/Files/ThermodynamicPackages/NRTL.mo b/Simulator/Files/ThermodynamicPackages/NRTL.mo index cf4eba1..25bd85f 100644 --- a/Simulator/Files/ThermodynamicPackages/NRTL.mo +++ b/Simulator/Files/ThermodynamicPackages/NRTL.mo @@ -1,7 +1,7 @@ within Simulator.Files.ThermodynamicPackages; model NRTL - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; 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); diff --git a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo index ff3d394..bf3d03f 100644 --- a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo +++ b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo @@ -1,22 +1,26 @@ within Simulator.Files.ThermodynamicPackages; model RaoultsLaw - import Simulator.Files.Thermodynamic_Functions.*; - 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]; + import Simulator.Files.ThermodynamicFunctions.*; + import data = Simulator.Files.ChemsepDatabase; + parameter Integer Ncomp=2; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Ncomp]; + Real K_c[Ncomp](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; + Real gma_c[Ncomp], gmabubl_c[Ncomp], gmadew_c[Ncomp]; + Real philiqbubl_c[Ncomp], phivapdew_c[Ncomp], Pvap_c[Ncomp]; + Real T(unit = "K"), P; equation - for i in 1:Nc loop + for i in 1:Ncomp loop gma_c[i] = 1; gmabubl_c[i] = 1; gmadew_c[i] = 1; philiqbubl_c[i] = 1; phivapdew_c[i] = 1; end for; - for i in 1:Nc loop + for i in 1:Ncomp loop Pvap_c[i] = Simulator.Files.ThermodynamicFunctions.Psat(C[i].VP, T); end for; - for j in 1:Nc loop + for j in 1:Ncomp loop K_c[j] = Pvap_c[j] / P; end for; Cpres_p[:] = zeros(3); diff --git a/Simulator/GuessModels/InitialGuess.mo b/Simulator/GuessModels/InitialGuess.mo index a52288b..ee0c81c 100644 --- a/Simulator/GuessModels/InitialGuess.mo +++ b/Simulator/GuessModels/InitialGuess.mo @@ -3,11 +3,13 @@ within Simulator.GuessModels; model InitialGuess //Inputs Required to generate Guess Values - extends GuessInput; - //========================================================================================== - //Guess variables for Pressures and Temperatures + extends GuessInput; + + import data = Simulator.Files.ChemsepDatabase; + parameter input Integer Nc; + parameter data.GeneralProperties C[Nc]; protected - parameter Real xguess[Nc](each fixed = false); + parameter Real xguess[Nc](each fixed = false); parameter Real Tg(fixed = false); parameter Real Temp(fixed = false, start = 300); parameter Real Pxc[Nc](each fixed = false), Pxm[Nc](each fixed = false); @@ -82,8 +84,8 @@ model InitialGuess end if; Alpha = 1 - Beta; for i in 1:Nc loop - if xguess[i] <> 0 then - if Beta > 0 and Beta <> 1 then + if xguess[i] < 0 and xguess[i] > 0 then + if Beta > 0 and Beta < 1 and Beta > 1 then ymol[i] = xguess[i] * K_guess[i] / ((K_guess[i] - 1) * xvapg + 1); elseif Beta == 1 then ymol[i] = xguess[i]; diff --git a/Simulator/Streams/MaterialStream.mo b/Simulator/Streams/MaterialStream.mo index a781907..94db2d9 100644 --- a/Simulator/Streams/MaterialStream.mo +++ b/Simulator/Streams/MaterialStream.mo @@ -4,8 +4,9 @@ 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 Real Cpres_p[3], Hres_p[3], Sres_p[3], gmabubl_c[Nc], philiqbubl_c[Nc], gmadew_c[Nc], phivapdew_c[Nc], K_c[Nc]; + /*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")); Real P(unit = "Pa", min = 0, start = Pg) "Pressure"; @@ -23,12 +24,12 @@ model MaterialStream "Model representing Material Stream" Real xm_pc[3, Nc](each unit ="-", start={xguess,xg,yg}, each min = 0, each max = 1) "Component mass fraction in phase"; Real F_pc[3, Nc](each unit = "mol/s", each start = Fg, each min = 0) "Component molar flow in phase"; Real Fm_pc[3, Nc](each unit = "kg/s", each min = 0, each start = Fg) "Component mass flow in phase"; - Real Cp_p[3](each unit = "kJ/[kmol.K]",start={Hmixg,Hliqg,Hvapg}) "Phase molar specific heat"; - Real Cp_pc[3, Nc](each unit = "kJ/[kmol.K]") "Component molar specific heat in phase"; + Real Cp_p[3](each unit = "kJ/kmol.K",start={Hmixg,Hliqg,Hvapg}) "Phase molar specific heat"; + Real Cp_pc[3, Nc](each unit = "kJ/kmol.K") "Component molar specific heat in phase"; Real H_p[3](each unit = "kJ/kmol",start={Hmixg,Hliqg,Hvapg}) "Phase molar enthalpy"; Real H_pc[3, Nc](each unit = "kJ/kmol") "Component molar enthalpy in phase"; - Real S_p[3](each unit = "kJ/[kmol.K]") "Phase molar entropy"; - Real S_pc[3, Nc](each unit = "kJ/[kmol.K]") "Component molar entropy in phase"; + Real S_p[3](each unit = "kJ/kmol.K") "Phase molar entropy"; + Real S_pc[3, Nc](each unit = "kJ/kmol.K") "Component molar entropy in phase"; Simulator.Files.Interfaces.matConn In(Nc = Nc) annotation( Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Simulator.Files.Interfaces.matConn Out(Nc = Nc) annotation( diff --git a/Simulator/UnitOperations/HeatExchanger.mo b/Simulator/UnitOperations/HeatExchanger.mo index e60093e..9284af7 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( @@ -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; From d434a14b1ad5674dbb3b8df62e23b9c69fe5018b Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Mon, 31 Jul 2023 17:43:44 +0530 Subject: [PATCH 02/42] renamed the parameter and removed the initialisation --- .../Files/ThermodynamicPackages/RaoultsLaw.mo | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo index bf3d03f..da9fea4 100644 --- a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo +++ b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo @@ -3,24 +3,24 @@ within Simulator.Files.ThermodynamicPackages; model RaoultsLaw import Simulator.Files.ThermodynamicFunctions.*; import data = Simulator.Files.ChemsepDatabase; - parameter Integer Ncomp=2; - parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Ncomp]; - Real K_c[Ncomp](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; - Real gma_c[Ncomp], gmabubl_c[Ncomp], gmadew_c[Ncomp]; - Real philiqbubl_c[Ncomp], phivapdew_c[Ncomp], Pvap_c[Ncomp]; + parameter Integer Nc; + 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 T(unit = "K"), P; equation - for i in 1:Ncomp loop + for i in 1:Nc loop gma_c[i] = 1; gmabubl_c[i] = 1; gmadew_c[i] = 1; philiqbubl_c[i] = 1; phivapdew_c[i] = 1; end for; - for i in 1:Ncomp loop + for i in 1:Nc loop Pvap_c[i] = Simulator.Files.ThermodynamicFunctions.Psat(C[i].VP, T); end for; - for j in 1:Ncomp loop + for j in 1:Nc loop K_c[j] = Pvap_c[j] / P; end for; Cpres_p[:] = zeros(3); From b572c5bd5e9cd4623a9cc448c0c2062dc24ee424 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 9 Aug 2023 00:10:06 +0530 Subject: [PATCH 03/42] Uncommented two lines --- Simulator/Files/Models/ReactionManager/KineticReaction.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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( From 839d66d3718c9e087d86fd012a1c56ce3c9bcf68 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 9 Aug 2023 00:13:35 +0530 Subject: [PATCH 04/42] Declared BC_r array variable --- Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo b/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo index 8fa80c7..33136b2 100644 --- a/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo +++ b/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo @@ -23,7 +23,7 @@ model EquilibriumReaction "Model of an equilibrium reaction used in equilibrium //Returns whether the specified stoichiometry is correct Real Hf_c[Nc]; Real Hr_r[Nr]; - + Real BC_r[Nr]; //Equilibrium Constant Real K[Nr](start=xliqg); From f45eace87fba505a11bdf3ecaa720c01bd7b2e9a Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 9 Aug 2023 00:16:17 +0530 Subject: [PATCH 05/42] Declared BC_r as integer array --- Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo b/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo index 33136b2..dd06e72 100644 --- a/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo +++ b/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo @@ -23,7 +23,7 @@ model EquilibriumReaction "Model of an equilibrium reaction used in equilibrium //Returns whether the specified stoichiometry is correct Real Hf_c[Nc]; Real Hr_r[Nr]; - Real BC_r[Nr]; + Integer BC_r[Nr]; //Equilibrium Constant Real K[Nr](start=xliqg); From 5ba9543a23f7e487c3ad8ab8965eb6d9d5a02aa1 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 9 Aug 2023 00:19:17 +0530 Subject: [PATCH 06/42] Made non-array modification for array component possible --- Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo b/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo index dd06e72..c271d04 100644 --- a/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo +++ b/Simulator/Files/Models/ReactionManager/EquilibriumReaction.mo @@ -26,7 +26,7 @@ model EquilibriumReaction "Model of an equilibrium reaction used in equilibrium Integer BC_r[Nr]; //Equilibrium Constant - Real K[Nr](start=xliqg); + Real K[Nr](each start=xliqg); Real N[Nr](each start= Fg),D[Nr](each start=Fg); extends Simulator.GuessModels.InitialGuess; From 6421dcaf100f76fc347c5c01a94d162045cdfb10 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 9 Aug 2023 23:52:05 +0530 Subject: [PATCH 07/42] Declared parameters Nc and C --- Simulator/Files/ThermodynamicPackages/NRTL.mo | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Simulator/Files/ThermodynamicPackages/NRTL.mo b/Simulator/Files/ThermodynamicPackages/NRTL.mo index 25bd85f..cf0281c 100644 --- a/Simulator/Files/ThermodynamicPackages/NRTL.mo +++ b/Simulator/Files/ThermodynamicPackages/NRTL.mo @@ -2,6 +2,11 @@ within Simulator.Files.ThermodynamicPackages; model NRTL import Simulator.Files.ThermodynamicFunctions.*; + import data = Simulator.Files.ChemsepDatabase; + + parameter Integer Nc; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; + 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 47e133d0864e57e312126fee97672fbb66fbfcf1 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Thu, 10 Aug 2023 00:01:32 +0530 Subject: [PATCH 08/42] Declared the required real valued variables x_pc, T, P, Pdew --- Simulator/Files/ThermodynamicPackages/NRTL.mo | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Simulator/Files/ThermodynamicPackages/NRTL.mo b/Simulator/Files/ThermodynamicPackages/NRTL.mo index cf0281c..b50c348 100644 --- a/Simulator/Files/ThermodynamicPackages/NRTL.mo +++ b/Simulator/Files/ThermodynamicPackages/NRTL.mo @@ -7,6 +7,9 @@ within Simulator.Files.ThermodynamicPackages; parameter Integer Nc; parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; + Real x_pc[Nc, Nc], Pdew; + Real T(unit = "K"), P; + 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 28ec9661ed768f53ccec0b2adcec54796c3a28e0 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Thu, 10 Aug 2023 22:50:22 +0530 Subject: [PATCH 09/42] Declared the integer parameter Nr --- Simulator/UnitOperations/ConversionReactor.mo | 1 + 1 file changed, 1 insertion(+) diff --git a/Simulator/UnitOperations/ConversionReactor.mo b/Simulator/UnitOperations/ConversionReactor.mo index 1381147..903f994 100644 --- a/Simulator/UnitOperations/ConversionReactor.mo +++ b/Simulator/UnitOperations/ConversionReactor.mo @@ -9,6 +9,7 @@ model ConversionReactor "Model of a conversion reactor to calculate the outlet s Dialog(tab = "Reactor Specifications", group = "Component Parameters")); parameter Integer Nc "Number of components" annotation( Dialog(tab = "Reactor Specifications", group = "Component Parameters")); + parameter Integer Nr "Number of Reactions"; parameter String CalcMode = "Isothermal" "Required mode of operation: ''Isothermal'', ''Define_Out_Temperature'', ''Adiabatic''" annotation( Dialog(tab = "Reactor Specifications", group = "Calculation Parameters")); parameter Real Tdef(unit = "K") = 300 "Defined outlet temperature, applicable if Define_Out_Temperature mode is chosen" annotation( From 98cf075e11162f40614bacc89654da6ec98a5185 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 11:55:22 +0530 Subject: [PATCH 10/42] Array element modification --- Simulator/UnitOperations/HeatExchanger.mo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Simulator/UnitOperations/HeatExchanger.mo b/Simulator/UnitOperations/HeatExchanger.mo index 9284af7..a321a92 100644 --- a/Simulator/UnitOperations/HeatExchanger.mo +++ b/Simulator/UnitOperations/HeatExchanger.mo @@ -51,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](each unit = "mol/s", each 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](each unit = "mol/s", each 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"; From c3885b3665d9ee841c095fbe22f9cf201fc9f2bd Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 12:00:27 +0530 Subject: [PATCH 11/42] Modified subscripts of arrays --- Simulator/UnitOperations/HeatExchanger.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulator/UnitOperations/HeatExchanger.mo b/Simulator/UnitOperations/HeatExchanger.mo index a321a92..b8c55ed 100644 --- a/Simulator/UnitOperations/HeatExchanger.mo +++ b/Simulator/UnitOperations/HeatExchanger.mo @@ -724,7 +724,7 @@ Cph_pc[2, i] = ThermodynamicFunctions.LiqCpId(C[i].LiqCp, Thin); Cph_pc[3, i] = ThermodynamicFunctions.VapCpId(C[i].VapCp, Thin); end for; //================================================================================================== - for i in 2:3 loop + for i in 2:Nc loop Cph_p[i] = sum(xhin_pc[i, :] .* Cph_pc[i, :]); end for; Cph_p[1] = (1-xvaphin) * Cph_p[2] + xvaphin * Cph_p[3]; @@ -737,7 +737,7 @@ Cpc_pc[2, i] = ThermodynamicFunctions.LiqCpId(C[i].LiqCp, Tcin); Cpc_pc[3, i] = ThermodynamicFunctions.VapCpId(C[i].VapCp, Tcin); end for; - for i in 2:3 loop + for i in 2:Nc loop Cpc_p[i] = sum(xcin_pc[i, :] .* Cpc_pc[i, :]); end for; Cpc_p[1] = (1-xvapcin) * Cpc_p[2] + xvapcin * Cpc_p[3]; From 76478dd9f2c204d42d75ed0cd02d48fedccf7398 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 12:04:37 +0530 Subject: [PATCH 12/42] Modified subscripts of arrays --- Simulator/UnitOperations/HeatExchanger.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulator/UnitOperations/HeatExchanger.mo b/Simulator/UnitOperations/HeatExchanger.mo index b8c55ed..73ed776 100644 --- a/Simulator/UnitOperations/HeatExchanger.mo +++ b/Simulator/UnitOperations/HeatExchanger.mo @@ -724,7 +724,7 @@ Cph_pc[2, i] = ThermodynamicFunctions.LiqCpId(C[i].LiqCp, Thin); Cph_pc[3, i] = ThermodynamicFunctions.VapCpId(C[i].VapCp, Thin); end for; //================================================================================================== - for i in 2:Nc loop + for i in 1:2 loop Cph_p[i] = sum(xhin_pc[i, :] .* Cph_pc[i, :]); end for; Cph_p[1] = (1-xvaphin) * Cph_p[2] + xvaphin * Cph_p[3]; @@ -737,7 +737,7 @@ Cpc_pc[2, i] = ThermodynamicFunctions.LiqCpId(C[i].LiqCp, Tcin); Cpc_pc[3, i] = ThermodynamicFunctions.VapCpId(C[i].VapCp, Tcin); end for; - for i in 2:Nc loop + for i in 1:2 loop Cpc_p[i] = sum(xcin_pc[i, :] .* Cpc_pc[i, :]); end for; Cpc_p[1] = (1-xvapcin) * Cpc_p[2] + xvapcin * Cpc_p[3]; From 279d7e4978a5e434515ea60bcff6632afadd56ca Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 12:07:07 +0530 Subject: [PATCH 13/42] Array element modification --- 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 bb67df7aa4bc2a229c72b927012622a20569e008 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 20:07:50 +0530 Subject: [PATCH 14/42] Declared variables --- Simulator/UnitOperations/ShortcutColumn.mo | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Simulator/UnitOperations/ShortcutColumn.mo b/Simulator/UnitOperations/ShortcutColumn.mo index d841d1d..a7dabb8 100644 --- a/Simulator/UnitOperations/ShortcutColumn.mo +++ b/Simulator/UnitOperations/ShortcutColumn.mo @@ -42,6 +42,13 @@ model ShortcutColumn "Model of a shortcut column to calculate minimum reflux in Real Hliqcond_c[Nc](each unit = "kJ/kmol") "Component enthalpy of vapor in condenser"; Real xliqcond_c[Nc](each unit = "-", each min = 0, each max = 1, start = xg)"Component mole fraction in liquid phase in condenser"; Real xvapcond_c[Nc](each unit = "-", each min = 0, each max = 1, start = yg)"Component mole fraction in vapor phase in condenser"; + Real K_c[Nc]; + Real gmabubl_c[Nc]; + Real philiqbubl_c[Nc]; + Real gmadew_c[Nc]; + Real phivapdew_c[Nc]; + Real gma_c[Nc]; + Real K[Nc]; Real Pdew(unit = "Pa", min = 0, start = Pmax)"Dew point pressure"; Real Pbubl(unit = "Pa", min = 0, start = Pmin)"Bubble point pressure"; From 4c79c87e1422fab806eff6469fd2b19d9bbe6928 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 20:09:02 +0530 Subject: [PATCH 15/42] Array element modification --- Simulator/UnitOperations/ShortcutColumn.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/UnitOperations/ShortcutColumn.mo b/Simulator/UnitOperations/ShortcutColumn.mo index a7dabb8..9aa39e0 100644 --- a/Simulator/UnitOperations/ShortcutColumn.mo +++ b/Simulator/UnitOperations/ShortcutColumn.mo @@ -28,7 +28,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"; From 47e38310298456b8b3d81a79a21f3c65292eb35b Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 20:11:16 +0530 Subject: [PATCH 16/42] ShortcutColumn model file commit --- Simulator/Examples/ShortcutColumn.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/ShortcutColumn.mo b/Simulator/Examples/ShortcutColumn.mo index cf7c219..84ad94f 100644 --- a/Simulator/Examples/ShortcutColumn.mo +++ b/Simulator/Examples/ShortcutColumn.mo @@ -71,4 +71,4 @@ package ShortcutColumn "Example of Simulating a Shortcut Column" annotation( Documentation(info = "
Following problem statement is simulated in this Shortcut Column example

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: 370 K

Simulate a shortcut column such that benzene mole fraction at bottoms is 0.01 and toluene mole fraction at distillate is 0.01. The column is operated at 101325 Pa. Use Reflux ratio of 2.

This package is created to demnostrate the simualtion of a Flash 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. Shortcut (Non-executable model): created to extend the shortcut column along with the necessary thermodynamic package
  3. ShortcutSimulation (Executable model): All the components are defined, material stream & shortcut column specifications are declared, model instances are connected to make the file executable.
")); -end ShortcutColumn; +end ShortcutColumn; \ No newline at end of file From b72dd94c66e70fbd8e307b7e76dae5570af0f47e Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 20:12:13 +0530 Subject: [PATCH 17/42] Mixer model file commit --- Simulator/Examples/Mixer.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/Mixer.mo b/Simulator/Examples/Mixer.mo index cc87efa..402366a 100644 --- a/Simulator/Examples/Mixer.mo +++ b/Simulator/Examples/Mixer.mo @@ -155,4 +155,4 @@ package Mixer "Example of Simulating a Mixer" Simulate a Mixer to mix the above six material streams into a single output material stream where the pressure of the outlet stream is calculated as average of the inlet streams.

This package is created to demnostrate the simualtion of a Mixer. 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. mix (Executable model): All the components are defined, material stream & mixer specifications are declared, model instances are connected to make the file executable.

 

")); -end Mixer; +end Mixer; \ No newline at end of file From 87e39dfe5f348101ff2b8cb2f9d4b21526cdbb85 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Tue, 12 Dec 2023 20:17:59 +0530 Subject: [PATCH 18/42] Declared variables --- Simulator/UnitOperations/Flash.mo | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Simulator/UnitOperations/Flash.mo b/Simulator/UnitOperations/Flash.mo index 9a527c8..b2f9bbf 100644 --- a/Simulator/UnitOperations/Flash.mo +++ b/Simulator/UnitOperations/Flash.mo @@ -33,6 +33,15 @@ model Flash "Model of a flash column to separate vapor and liquid phases from a Real S_p[3](each unit = "kJ/[kmol.K]") "Molar entropy in phase"; Real xliq(unit = "-", min = 0, max = 1, start = xliqg)"Liquid phase mole fraction"; Real xvap(unit = "-", min = 0, max = 1, start = xvapg) "Vapor phase mole fraction"; + + Real gmabubl_c[Nc]; + Real philiqbubl_c[Nc]; + Real gmadew_c[Nc]; + Real phivapdew_c[Nc]; + Real K_c[Nc]; + Real Cpres_p[Nc]; + Real Hres_p[Nc]; + Real Sres_p[Nc]; //=============================================================================== //Instantiation of Connectors Simulator.Files.Interfaces.matConn In(Nc = Nc) annotation( From 62c33fe337008fc2403205b0c1f581e95b8dac41 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 17:06:45 +0530 Subject: [PATCH 19/42] Resolved type mismatch --- Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo index da9fea4..6132535 100644 --- a/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo +++ b/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo @@ -23,7 +23,7 @@ within Simulator.Files.ThermodynamicPackages; for j in 1:Nc loop K_c[j] = Pvap_c[j] / P; end for; - Cpres_p[:] = zeros(3); - Hres_p[:] = zeros(3); - Sres_p[:] = zeros(3); + Cpres_p[:] = fill(0.0, 3); + Hres_p[:] = fill(0.0, 3); + Sres_p[:] = fill(0.0, 3); end RaoultsLaw; From 230135a241a2e022570c251e7a5baaaffb6e5ea2 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 17:09:36 +0530 Subject: [PATCH 20/42] Flash model file commit --- Simulator/Examples/Flash.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/Flash.mo b/Simulator/Examples/Flash.mo index 33ab4ec..c0906d5 100644 --- a/Simulator/Examples/Flash.mo +++ b/Simulator/Examples/Flash.mo @@ -57,4 +57,4 @@ package Flash "Example of Simulating a Flash Separator" annotation( Documentation(info = "
Following problem statement is simulated in this Flash Column example

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: 368 K

Simulate a flash column operating at the feed temperature and pressure.

This package is created to demnostrate the simualtion of a Flash 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. FlashSep (Non-executable model): created to extend the flash column along with the necessary thermodynamic package.
  3. FlashSimulation (Executable model): All the components are defined, material stream & flash column specifications are declared, model instances are connected to make the file executable.
")); -end Flash; +end Flash; \ No newline at end of file From 3ff3256436618103d175fdb22cea9abe73717572 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 17:17:07 +0530 Subject: [PATCH 21/42] Array element modification --- 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..853052e 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 e2c547100866e4cd77edb16cd21042a332828b59 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 17:30:47 +0530 Subject: [PATCH 22/42] Declared variables --- Simulator/Files/Models/Flash.mo | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Simulator/Files/Models/Flash.mo b/Simulator/Files/Models/Flash.mo index c548260..955cf26 100644 --- a/Simulator/Files/Models/Flash.mo +++ b/Simulator/Files/Models/Flash.mo @@ -12,6 +12,14 @@ 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"; + Real gmabubl_c[Nc]; + Real philiqbubl_c[Nc]; + Real gmadew_c[Nc]; + Real phivapdew_c[Nc]; + Real K_c[Nc]; + Real Cpres_p[Nc]; + Real Hres_p[Nc]; + Real Sres_p[Nc]; extends GuessModels.InitialGuess; From 19fdca2eefb03bfdf6db1a86466c5f5f97f2aaef Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 17:33:11 +0530 Subject: [PATCH 23/42] Compressor model file commit --- Simulator/Examples/Compressor.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/Compressor.mo b/Simulator/Examples/Compressor.mo index 2f40a8d..c5df3c6 100644 --- a/Simulator/Examples/Compressor.mo +++ b/Simulator/Examples/Compressor.mo @@ -48,4 +48,4 @@ package Compressor "Example of Simulating an Adiabatic Compressor" end CompressorSimulation; annotation( Documentation(info = "
Following problem statement is simulated in this Adiabatic Compressor example

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

Material Stream Information

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

Simulate an adiabatic compressor to reduce the pressure of a vapor material stream such that the pressure increase is 10000 Pa. Assume the compressor to be operated at efficiency of 75%.

This package is created to demnostrate the simualtion of an Adiabatic Compressor. 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. AdiabComp (Non-executable model): created to extend the adiabatic compressor along with the necessary thermodynamic package.
  3. CompressorSimulation (Executable model): All the components are defined, material stream & compressor specifications are declared, model instances are connected to make the file executable.
")); -end Compressor; +end Compressor; \ No newline at end of file From 430720adf633110be9fb580d158de8eb5333bf4e Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 18:47:04 +0530 Subject: [PATCH 24/42] Expander model file commit --- Simulator/Examples/Expander.mo | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Simulator/Examples/Expander.mo b/Simulator/Examples/Expander.mo index aae24c6..197c2b8 100644 --- a/Simulator/Examples/Expander.mo +++ b/Simulator/Examples/Expander.mo @@ -36,16 +36,16 @@ package Expander "Example of Simulating an Adiabatic Expander" Simulator.Streams.EnergyStream E1 annotation( Placement(visible = true, transformation(origin = {-30, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation -//================================================================ -//Connections + //================================================================ + //Connections connect(E1.Out, B1.En) annotation( Line(points = {{-20, -60}, {-2, -60}, {-2, -16}, {-2, -16}}, color = {255, 0, 0})); connect(B1.Out, S2.In) annotation( Line(points = {{20, 0}, {52, 0}, {52, 0}, {52, 0}}, color = {0, 70, 70})); connect(S1.Out, B1.In) annotation( Line(points = {{-72, 0}, {-26, 0}, {-26, 0}, {-26, 0}}, color = {0, 70, 70})); -//================================================================ -//Inputs and Specifications + //================================================================ + //Inputs and Specifications S1.x_pc[1, :] = {0.5, 0.5}; S1.P = 131325; S1.T = 372; @@ -56,4 +56,4 @@ package Expander "Example of Simulating an Adiabatic Expander" end ExpanderSimulation; annotation( Documentation(info = "
Following problem statement is simulated in this Adiabatic Expander example

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

Material Stream Information

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

Simulate an adiabatic expander to reduce the pressure of a vapor material stream such that the pressure drop is 10000 Pa. Assume the expander to be operated at efficiency of 75%.

This package is created to demnostrate the simualtion of an Adiabatic Expander. 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. AdiabExp (Non-executable model): created to extend the adiabatic expander along with the necessary thermodynamic package.
  3. ExpanderSimulation (Executable model): All the components are defined, material stream & expander specifications are declared, model instances are connected to make the file executable.
")); -end Expander; +end Expander; \ No newline at end of file From d7f6f797b5df4f7ff91c315ddba5cff23f63fbc5 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 18:57:50 +0530 Subject: [PATCH 25/42] Declared Nc variable --- Simulator/Files/Interfaces/enConn.mo | 1 + 1 file changed, 1 insertion(+) diff --git a/Simulator/Files/Interfaces/enConn.mo b/Simulator/Files/Interfaces/enConn.mo index 64087be..c9168f0 100644 --- a/Simulator/Files/Interfaces/enConn.mo +++ b/Simulator/Files/Interfaces/enConn.mo @@ -2,6 +2,7 @@ within Simulator.Files.Interfaces; connector enConn "Connector to connect energy stream with unit operation" Real Q; + Integer Nc; annotation( Icon(coordinateSystem(initialScale = 0.1), graphics = {Rectangle(lineColor = {255, 0, 0}, fillColor = {255, 0, 0}, fillPattern = FillPattern.Solid, extent = {{-50, 50}, {50, -50}})})); end enConn; From 10be6fc4ae410ac499c0b629494d908ffa3cf8bf Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 19:13:03 +0530 Subject: [PATCH 26/42] Declared condenser variable --- Simulator/UnitOperations/DistillationColumn/DistCol.mo | 1 + 1 file changed, 1 insertion(+) diff --git a/Simulator/UnitOperations/DistillationColumn/DistCol.mo b/Simulator/UnitOperations/DistillationColumn/DistCol.mo index 106c2bd..8d834ad 100644 --- a/Simulator/UnitOperations/DistillationColumn/DistCol.mo +++ b/Simulator/UnitOperations/DistillationColumn/DistCol.mo @@ -22,6 +22,7 @@ within Simulator.UnitOperations.DistillationColumn; parameter String Ctype = "Total" "Condenser type: ''Total'' or ''Partial''" annotation( Dialog(tab = "Column Specifications", group = "Calculation Parameters")); + Simulator.Examples.Distillation.Condenser condenser; Real RR(min = 0); Simulator.Files.Interfaces.matConn In_s[Ni](each Nc = Nc) annotation( Placement(visible = true, transformation(origin = {-248, -40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-250, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); From 0e6a0fa813176f129564e241469329c8e8507fb8 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 19:15:36 +0530 Subject: [PATCH 27/42] Distillation model file commit --- Simulator/Examples/Distillation.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/Distillation.mo b/Simulator/Examples/Distillation.mo index 1afa644..72d7491 100644 --- a/Simulator/Examples/Distillation.mo +++ b/Simulator/Examples/Distillation.mo @@ -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 From 7f8c2d4b03256aee732acdfc85b05b59175c681f Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 19:18:34 +0530 Subject: [PATCH 28/42] Changed accessibility mode of the real parameter R --- Simulator/Files/ThermodynamicFunctions/DensityRacket.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 7c342cb89a32a801cfd07739a208b19529b21130 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 19:19:42 +0530 Subject: [PATCH 29/42] Declared the variable Nc as parameter --- Simulator/Files/ThermodynamicFunctions/DensityRacket.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo b/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo index c1acf2d..a4b299c 100644 --- a/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo +++ b/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo @@ -2,7 +2,7 @@ within Simulator.Files.ThermodynamicFunctions; function DensityRacket extends Modelica.Icons.Function; - input Integer Nc; + parameter Integer Nc; input Real T; input Real P; input Real Pc_c[Nc]; From a492e00e25f1cf7a53e6a383cc41d820e1e41a9c Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 19:21:42 +0530 Subject: [PATCH 30/42] Changed accessibility mode of the integer parameter Nc --- Simulator/Files/ThermodynamicFunctions/DensityRacket.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo b/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo index a4b299c..0ce1473 100644 --- a/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo +++ b/Simulator/Files/ThermodynamicFunctions/DensityRacket.mo @@ -2,7 +2,6 @@ within Simulator.Files.ThermodynamicFunctions; function DensityRacket extends Modelica.Icons.Function; - parameter Integer Nc; input Real T; input Real P; input Real Pc_c[Nc]; @@ -14,6 +13,7 @@ within Simulator.Files.ThermodynamicFunctions; output Real rho_c[Nc]; protected parameter Real R = 83.14; + parameter Integer Nc; 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 From 703aedf46a5b3ef17edff7fb80ad5885c6927d9a Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 19:23:34 +0530 Subject: [PATCH 31/42] Changed accessibility mode of the real variable Rate --- Simulator/UnitOperations/PFR/Integral.mo | 1 + 1 file changed, 1 insertion(+) diff --git a/Simulator/UnitOperations/PFR/Integral.mo b/Simulator/UnitOperations/PFR/Integral.mo index 8868634..76057f1 100644 --- a/Simulator/UnitOperations/PFR/Integral.mo +++ b/Simulator/UnitOperations/PFR/Integral.mo @@ -17,6 +17,7 @@ within Simulator.UnitOperations.PFR; input Real Bc[Nr]; input Real Fao; input Real k; + protected Real Rate; algorithm Rate := 1; From dabbf2e7496aea8377aaa00847a215165f0b6f03 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 19:25:51 +0530 Subject: [PATCH 32/42] Decalared the real variables Nc and Nr as parameters --- Simulator/UnitOperations/PFR/Integral.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulator/UnitOperations/PFR/Integral.mo b/Simulator/UnitOperations/PFR/Integral.mo index 76057f1..2d20def 100644 --- a/Simulator/UnitOperations/PFR/Integral.mo +++ b/Simulator/UnitOperations/PFR/Integral.mo @@ -3,8 +3,8 @@ within Simulator.UnitOperations.PFR; function Integral "Function to define the integral part used in the performance equation of a plug floiw reactor" extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction; - input Integer Nc; - input Integer Nr; + parameter Integer Nc; + parameter Integer Nr; input Integer Base_comp; input Real Co_dummy[Nc - 1]; input Real DO_dummy[Nc - 1, Nr]; From 2824a25c87a2d892782e9a48ab707551207980ad Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:20:43 +0530 Subject: [PATCH 33/42] Changed accessibility mode of the integer parameters Nc and Nr --- Simulator/UnitOperations/PFR/Integral.mo | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Simulator/UnitOperations/PFR/Integral.mo b/Simulator/UnitOperations/PFR/Integral.mo index 2d20def..74617df 100644 --- a/Simulator/UnitOperations/PFR/Integral.mo +++ b/Simulator/UnitOperations/PFR/Integral.mo @@ -3,8 +3,7 @@ within Simulator.UnitOperations.PFR; function Integral "Function to define the integral part used in the performance equation of a plug floiw reactor" extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction; - parameter Integer Nc; - parameter Integer Nr; + input Integer Base_comp; input Real Co_dummy[Nc - 1]; input Real DO_dummy[Nc - 1, Nr]; @@ -19,6 +18,8 @@ within Simulator.UnitOperations.PFR; input Real k; protected Real Rate; + parameter Integer Nc; + parameter Integer Nr; algorithm Rate := 1; for i in 2:Nc loop From 704f872ac145182884e8d249470402507384b8b1 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:21:49 +0530 Subject: [PATCH 34/42] PFR model file commit --- Simulator/Examples/PFR.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/PFR.mo b/Simulator/Examples/PFR.mo index 61ab4c9..eed0d2b 100644 --- a/Simulator/Examples/PFR.mo +++ b/Simulator/Examples/PFR.mo @@ -51,4 +51,4 @@ package PFR "Example of Simulating a PFR" 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 From c96f17aea4bef6bcfc44d03dfc07fe2d10cdea0c Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:25:34 +0530 Subject: [PATCH 35/42] Declared the variables Coef_cr, BC_r and Hr_r --- Simulator/UnitOperations/ConversionReactor.mo | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Simulator/UnitOperations/ConversionReactor.mo b/Simulator/UnitOperations/ConversionReactor.mo index 903f994..9150311 100644 --- a/Simulator/UnitOperations/ConversionReactor.mo +++ b/Simulator/UnitOperations/ConversionReactor.mo @@ -32,6 +32,10 @@ model ConversionReactor "Model of a conversion reactor to calculate the outlet s Real Pout(unit = "Pa", min = 0, start =Pg) "Outlet stream pressure"; Real Tout(unit = "K", min = 0, start = Tg) "Outlet stream temperature"; Real Fout_cr[Nc, Nr](each unit = "mol/s") "Molar flor rate of components after each reaction"; + + Real Coef_cr[Nc, Nr]; + Integer BC_r[Nr]; + Real Hr_r[Nr]; //============================================================================= //Instanstiation of Connectors Simulator.Files.Interfaces.matConn In(Nc = Nc) annotation( From cac63af6895a424d20a5b6e99430c41c9e644b48 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:36:25 +0530 Subject: [PATCH 36/42] Declared the parameters C and Nc --- Simulator/Files/Models/ReactionManager/ConversionReaction.mo | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Simulator/Files/Models/ReactionManager/ConversionReaction.mo b/Simulator/Files/Models/ReactionManager/ConversionReaction.mo index d11f4f8..a87b3a7 100644 --- a/Simulator/Files/Models/ReactionManager/ConversionReaction.mo +++ b/Simulator/Files/Models/ReactionManager/ConversionReaction.mo @@ -5,6 +5,8 @@ within Simulator.Files.Models.ReactionManager; import Simulator.Files.*; import data = Simulator.Files.Chemsep_Database; //Number of Reactions involved in the process + parameter ChemsepDatabase.GeneralProperties C[Nc] "Component instances array" annotation(Dialog(tab = "Flash Specifications", group = "Component Parameters")); + parameter Integer Nc "Number of components" annotation(Dialog(tab = "Flash Specifications", group = "Component Parameters")); 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( From 8872f762420d85ca3c5edfb48b53697f82a5bdce Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:37:49 +0530 Subject: [PATCH 37/42] ConversionReactor model file commit --- Simulator/Examples/ConversionReactor.mo | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Simulator/Examples/ConversionReactor.mo b/Simulator/Examples/ConversionReactor.mo index 214cce9..f02d5d1 100644 --- a/Simulator/Examples/ConversionReactor.mo +++ b/Simulator/Examples/ConversionReactor.mo @@ -16,9 +16,6 @@ package ConversionReactor "Example of Simulating a Conversion Reactor" annotation( Documentation(info = "This is a non-executable model is created inside the package CR to extend the ConversionReactor model along with the necessary reaction from Reaction Manager which is ConversionReaction in this case.

It will be instantiated in the ConvReactSimulation model to create the required number of instances of the adiabatic expander model.
")); end ConvReactor; - annotation( - Documentation(info = "
Following problem statement is simulated in this Conversion Reactor example

Component System: Ethyl Acetate, Water, Acetic Acid, Ethanol
Thermodynamics: NRTL

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Ethyl Acetate): 0
Mole Fraction (Water): 0
Mole Fraction (Acetic Acid): 0.4
Mole Fraction (Ethanol): 0.6
Pressure: 101325 Pa
Temperature: 300 K

Simulate a conversion reactor where Acetic Acid reacts with Ethanol to form Ethyl Acetate and Water. The conversion of acetic acid is 60%. Assume the reactor to be operated isothermally.

This package is created to demnostrate the simualtion of a Conversion 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. ConvReactor (Non-executable model): created to extend the conversion reactor along with the reaction manager.
  3. ConvReactSimulation (Executable model): All the components are defined, material stream & conversion reactor specifications are declared, model instances are connected to make the file executable.
")); - model ConvReactSimulation "Calculation of mole flows at outlet from given reaction conversion during production of Ethyl acetate by reacting Ethanol and Acetic Acid in a Conversion Reactor" extends Modelica.Icons.Example; @@ -52,8 +49,10 @@ package ConversionReactor "Example of Simulating a Conversion Reactor" S1.T = 300; S1.x_pc[1, :] = {0, 0, 0.4, 0.6}; S1.F_p[1] = 100; - annotation( + annotation( Documentation(info = "This is an executable model to simualate the CR example where all the components are defined, material stream, conversion reactor & conversion reaction specifications are declared, model instances are connected.

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Ethyl Acetate): 0
Mole Fraction (Water): 0
Mole Fraction (Acetic Acid): 0.4
Mole Fraction (Ethanol): 0.6
Pressure: 101325 Pa
Temperature: 300 K

Reaction
Acetic Acid + Ethanol ----> Ethyl Acetate + Water

Conversion Reactor Specification: Conversion of Acetic Acid: 30%
         Operation Mode: isothermal
")); - end ConvReactSimulation; + end ConvReactSimulation; + annotation( + Documentation(info = "
Following problem statement is simulated in this Conversion Reactor example

Component System: Ethyl Acetate, Water, Acetic Acid, Ethanol
Thermodynamics: NRTL

Material Stream Information

Molar Flow Rate: 100 mol/s
Mole Fraction (Ethyl Acetate): 0
Mole Fraction (Water): 0
Mole Fraction (Acetic Acid): 0.4
Mole Fraction (Ethanol): 0.6
Pressure: 101325 Pa
Temperature: 300 K

Simulate a conversion reactor where Acetic Acid reacts with Ethanol to form Ethyl Acetate and Water. The conversion of acetic acid is 60%. Assume the reactor to be operated isothermally.

This package is created to demnostrate the simualtion of a Conversion 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. ConvReactor (Non-executable model): created to extend the conversion reactor along with the reaction manager.
  3. ConvReactSimulation (Executable model): All the components are defined, material stream & conversion reactor specifications are declared, model instances are connected to make the file executable.
")); -end ConversionReactor; +end ConversionReactor; \ No newline at end of file From c1e7caccdc4562f81dc3a0106d3f63ee034c47f8 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:45:59 +0530 Subject: [PATCH 38/42] Declared AbsTray variable tray --- Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo | 1 + 1 file changed, 1 insertion(+) diff --git a/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo b/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo index 48142e5..3e21df5 100644 --- a/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo +++ b/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo @@ -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))); + Simulator.Examples.Absorption.Tray tray; equation //connector equation tray[1].Fliq_s[1] = In_Top.F; From 926ee943475c2931c73751e57af2854cbe0b4764 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:47:51 +0530 Subject: [PATCH 39/42] Declared real array variables gmabubl_c[Nc], philiqbubl_c[Nc], gmadew_c[Nc], phivapdew_c[Nc], K_c[Nc] and Hres_p[Nc] --- Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo b/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo index dcdf2bf..76ee326 100644 --- a/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo +++ b/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo @@ -14,6 +14,12 @@ model AbsTray "Model of a tray used in absorption column" 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 gmabubl_c[Nc]; + Real philiqbubl_c[Nc]; + Real gmadew_c[Nc]; + Real phivapdew_c[Nc]; + Real K_c[Nc]; + Real Hres_p[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 76f9a5e574ce18827ce715f12170b520bc9915de Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:49:56 +0530 Subject: [PATCH 40/42] Array element modification --- Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo b/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo index 76ee326..d63150e 100644 --- a/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo +++ b/Simulator/UnitOperations/AbsorptionColumn/AbsTray.mo @@ -8,10 +8,10 @@ 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 x_pc[3, Nc](each min =0, each max = 0, each start=xliqg); Real Pdew(min = 0, start =Pmax); Real Pbubl(min = 0, start =Pmin); Real gmabubl_c[Nc]; From ab9ea17ab01b4e95e61934a78f33907c2ec2c853 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:56:34 +0530 Subject: [PATCH 41/42] Declared tray variable --- Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo b/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo index 3e21df5..6e60313 100644 --- a/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo +++ b/Simulator/UnitOperations/AbsorptionColumn/AbsCol.mo @@ -18,7 +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))); - Simulator.Examples.Absorption.Tray tray; + Simulator.Examples.Absorption.Tray tray[Nt]; equation //connector equation tray[1].Fliq_s[1] = In_Top.F; From 0ae3c3bb357ce6a7af884928a7eee0c19e06ccc1 Mon Sep 17 00:00:00 2001 From: SarmithaVD Date: Wed, 13 Dec 2023 22:58:40 +0530 Subject: [PATCH 42/42] Absorption model file commit --- Simulator/Examples/Absorption.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/Examples/Absorption.mo b/Simulator/Examples/Absorption.mo index 901a9c8..a34a48c 100644 --- a/Simulator/Examples/Absorption.mo +++ b/Simulator/Examples/Absorption.mo @@ -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