KEMBAR78
Hands-On - Implementing A Lumped Model | PDF | Enthalpy | Mole (Unit)
0% found this document useful (0 votes)
41 views21 pages

Hands-On - Implementing A Lumped Model

This document outlines the implementation of a lumped model for a gas-phase valve and methanol synthesis using gPROMS Process. It provides step-by-step instructions for creating a mathematical model, defining parameters and variables, and running simulations. The document also includes exercises to enhance understanding of the modeling process and the underlying chemical reactions involved in methanol production.

Uploaded by

Jesus Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views21 pages

Hands-On - Implementing A Lumped Model

This document outlines the implementation of a lumped model for a gas-phase valve and methanol synthesis using gPROMS Process. It provides step-by-step instructions for creating a mathematical model, defining parameters and variables, and running simulations. The document also includes exercises to enhance understanding of the modeling process and the underlying chemical reactions involved in methanol production.

Uploaded by

Jesus Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Implementing a

lumped model in
gPROMS
gPROMS Process Training
Implementing a lumped model in gPROMS

Implementing a lumped model in gPROMS


Simple valve model

Background
We want to model a steady state operation of a gas-phase valve as shown below.

The valve has a single inlet and outlet. The outlet flowrate is driven by the pressure difference between
the inlet and the outlet. The valve constant, Cv will be provided as model input. The outlet flowrate is
determined by the model based on the inlet pressure, the outlet flowrate and the valve constant.

Exercise 0
Objectives
The purpose of this hands-on session is to develop a mathematical model for a gas-phase valve model.
By the end of this exercise, you will know:

• How to build a model from scratch


• How to write equations using gPROMS language

• How to run a simulation

Things to do
1. Open gPROMS Process® from the Windows start menu by clicking on the relevant icon. Now, check

that the Basics libraries are open. You can do this by clicking this icon on the menu
toolbar, going into Standard and ticking the checkbox for Basics. This is also shown in the
screenshot below.

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 2


Implementing a lumped model in gPROMS

2. Create a new project file by going to the menu File > New. Save the newly created project under a
different name. Make sure the name is highlighted in the project tree and go to the menu File >
Save as... Choose an appropriate location and name for the file, e.g. gas_valve.gPJ-PB

Concept > gPROMS Process project tree. gPROMS Process uses a Windows Explorer-like
“project tree” structure to organise the different sections of the model description. To open an entity,
navigate to it, by expanding the tree if necessary, and then double-click it. It will open in the
workspace to the right.

3. To ensure that the new project links to the correct libraries right click on the project entity. On the
menu that appears go to Open on Tab > Cross-references and click Add after selecting gML Basics
Interface in the left pane to move gML Basics Interface into the right pane. Close the cross-
references window.
4. Create a new model entity by right-clicking on the “Models” folder (in the left-hand pane) and
selecting “New entity…”. In the “New entity…” dialog box, provide a name for the new entity (e.g.
gas_valve) and make sure that the correct entity is selected (MODEL). Leave the “Use template?”
box checked and click OK. A new model “gas_valve” will appear. Click on the “gPROMS language”
tab of this new model to see the template for gPROMS language.

A practical tip > The template shows you a list of sections (e.g. PARAMETER,
DISTRIBUTION_DOMAIN, UNIT, etc.) and the general syntax to be used when writing a gPROMS
model.

5. Define parameters for the gas_valve model in the gPROMS language tab based on the following
table.
Default
Symbol Description Units gPROMS identifier Size Type
value
Cv Valve constant - valve_constant - REAL 300
T Temperature K temperature - REAL -

Start by adding the keyword PARAMETER (or by removing the comment identifier, #, in front of the
PARAMETER keyword) and in the following lines type:

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 3


Implementing a lumped model in gPROMS

PARAMETER
valve_constant AS REAL DEFAULT 300
temperature AS REAL

6. Complete the VARIABLE section (create this section by adding the keyword VARIABLE after the
PARAMETER section) using information given in the following table (note that the variable types
required are available through the cross-referenced gML Basics Interface library):
Symbol Description Units gPROMS identifier Size Variable Type
F Outlet mass flowrate kg/s outlet_mass_flowrate - mass_flowrate_gML
α Valve position - valve_position - no_type_gML
Pin Inlet pressure bar inlet_pressure - pressure_bar_gML
Pout Outlet pressure bar outlet_pressure - pressure_bar_gML
P Pressure drop bar pressure_drop - pressure_bar_gML

VARIABLE
outlet_mass_flowrate AS mass_flowrate_gML
valve_position AS no_type_gML
inlet_pressure AS pressure_bar_gML
outlet_pressure AS pressure_bar_gML
pressure_drop AS pressure_bar_gML

7. Populate the EQUATION section (create this section by adding the keyword EQUATION after the
VARIABLE section) with the mathematical representation of the system given below:
Description Equation form Size
1
Outlet flowrate 𝐹 = 𝛼 ∙ 𝐶𝑣 ∙ ∙ ∆𝑃 -
√𝑇
Pressure drop ∆𝑃 = 𝑃𝑖𝑛 − 𝑃𝑜𝑢𝑡 -

EQUATION
# Calculate the mass flowrate through the valve
outlet_mass_flowrate =
valve_position*valve_constant/SQRT(temperature) * pressure_drop ;

# Pressure drop calculation


pressure_drop = inlet_pressure - outlet_pressure ;

8. You have now created a generic model for a gas-phase valve. Next, you will set up a simulation
using this MODEL. The input information specific to this simulation is provided in a PROCESS
entity. To create a PROCESS around the newly created MODEL, right click on the gas_valve model
and select “Edit PROCESS” option. A new process gas_valve will appear.

Concept > Relation between process and model entities. A mathematical representation of the
system is defined within the model entity. Case specific information of the model is relayed in the
process entity.

The model, however, needs to referenced for the simulation and is done so in the UNIT section of
the process which defines the model (or models) to be used in the simulation.

9. In the gPROMS language tab of the gas_valve process notice the predefined UNIT section where
the model that will be used in the simulation is automatically defined with the name Flowsheet.

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 4


Implementing a lumped model in gPROMS

UNIT
Flowsheet AS gas_valve

Next, you need to provide a value for the temperature in the SET section of the process (add the SET
keyword after the UNIT section):

SET
Flowsheet.temperature := 300 ; # K

10. Assign values to the degrees of freedom in the ASSIGN section of the process (add the ASSIGN
keyword after the SET section) according to the following information:
Symbol gPROMS identifiers Values Units
F outlet_mass_flowrate 10 kg/s
α valve_position 0.2 -
Pin inlet_pressure 20 bar

ASSIGN
Flowsheet.valve_position := 0.2 ;
Flowsheet.inlet_pressure := 20 ; # bar
Flowsheet.outlet_mass_flowrate := 10 ; # kg/s

The simulation is ready to be executed. To execute the simulation, select the process in the project
tree and in the toolbar, click the simulate button ( ). The Simulate dialog box will appear. Accept
the default settings and run the simulation by clicking OK.

Concept > Analysing simulation results. The execution output appears as a new
window. Also, note that a new case is being created – this is the green folder in the project
tree. By default, the name of the case is a concatenation of the process name (i.e.
gas_valve) plus a date and time stamp.

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 5


Implementing a lumped model in gPROMS

11. Results may be viewed at a glance within the gPROMS Process environment through expanding
the Trajectories folder of the case created to reveal the variables within the UNIT Flowsheet.
Observe the results for the outlet pressure.

12. Change the value of the valve position in the PROCESS, using the values in the table below, and
notice the effect on the outlet pressure.
Valve position Outlet pressure (bar)
0.1
0.2
0.5
0.7
1.0

13. Although it is typical to specify the position of the valve and determine the outlet pressure, it is
possible to perform a reverse calculation in gPROMS: specify the desired outlet pressure and
determine instead the valve position. This way, replace the ASSIGN section in the PROCESS to
specify a value for the outlet pressure (instead of specifying the valve position):

ASSIGN
# Flowsheet.valve_position := 0.2 ;
Flowsheet.outlet_pressure := 18 ; # bar
Flowsheet.inlet_pressure := 20 ; # bar
Flowsheet.outlet_mass_flowrate := 10 ; # kg/s

Run a simulation and observe the results for the valve position required for an outlet pressure of 18 bar.

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 6


Implementing a lumped model in gPROMS

Implementing a lumped model in gPROMS


Methanol synthesis

Background
The catalytic hydrogenation of carbon monoxide is nowadays the most important route to methanol
production. A perfectly mixed gas-phase continuous stirred tank reactor is used to carry out the following
methanol synthesis reaction:

(1)

The reaction is carried out in the presence of a solid catalyst held within a cage integrated with the
stirring mechanism of the reactor system, as shown schematically below.

Copper catalyst basket


Fin, CO, xin, CO, Tin, CO

Fin, H2, xin, H2, Tin, H2

Fout, xi, T

The heterogeneous gas/solid catalytic reactor system.

For methanol synthesis over this Cu/ZnO catalyst, the surface reaction is rate-limiting, giving rise to a
Langmuir-Hinshelwood-type rate expression [r is in kmol/kg-cat·hr and partial pressures in kPa]:
𝑝CH OH
2 3
𝑘𝑟 (𝑝CO∙𝑝𝐻 2
− 𝐾𝑒𝑞
)
𝑟= 3 (2)
(1+𝐾CO∙𝑝CO+𝐾H2 ∙𝑝H2 +𝐾CH3 OH ∙𝑝CH3 OH )

where the thermodynamic equilibrium constant Keq is found by:

𝐾𝑒𝑞 = exp −5+500⁄𝑇


(3)

with the other kinetic parameters (𝑘𝑟 , 𝐾𝐶𝑂 , 𝐾𝐻2 and 𝐾𝐶𝐻3𝑂𝐻 ) found through the following Arrhenius
expressions:
−135000
𝑘𝑟 = 9.93 × 1010 ∙ exp 𝑅𝑇 (4)
COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 7


Implementing a lumped model in gPROMS

−74000
𝐾𝐶𝑂 = 5.6 × 106 ∙ exp 𝑅𝑇 (5)
−54955.5
𝐾𝐻2 = 1.35 × 104 ∙ exp 𝑅𝑇 (6)
−74000
𝐾𝐶𝐻3𝑂𝐻 = 5.97 × 106 ∙ exp 𝑅𝑇 (7)

Objectives
The purpose of this hands-on session is to develop a full mathematical model for a gas-phase
continuous stirred tank reactor for the synthesis of methanol from hydrogen and carbon monoxide
through the following stage-wise approach:

• Exercise 1: Create an isothermal model for steady-state and dynamic calculations

• Exercise 2: Implement outlet valve dynamics through a proportional-integral controller


• Exercise 3: Extend fidelity to include an energy balance and to allow for thermodynamic
property calls for component fugacity coefficients and stream enthalpies.
• Exercise 4: Troubleshoot basic errors

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 8


Implementing a lumped model in gPROMS

Exercise 1
Creating an isothermal model of a gas-phase CSTR

Objectives
By the end of the exercise, you will know how to:

• Take advantage of the gML Basics Interface library


• Build a model from scratch
• Write equations using the gPROMS language
• Run a simulation
• Simulate for steady-state simple operational activities

Things to do
13. Open gPROMS Process from the Windows start menu by clicking on the appropriate icon. When it

opens, load the Basics library by clicking this icon on the menu toolbar.
14. Open the starter project ‘Starter 202 Exercise 1.gPJ’ and save it with a different name. Make sure
the name is highlighted in the project tree and go to the menu File > Save as... Choose an
appropriate location and name for the file, e.g. CSTR_methanol.gPJ
15. Expand the “Models” folder (in the left-hand pane) and open the model gas_phase_CSTR

Concept > gPROMS Process project tree. The software uses a Windows Explorer-like
“project tree” structure to organise the different sections of the model description. To open
an entity, navigate to it, by expanding the tree if necessary, and then double-click it. It will
open in the workspace to the right.

16. Go to the gPROMS language tab and notice within the model entity the predefined sections for
addition of PARAMETERs, VARIABLEs, SET values for PARAMETERs and EQUATIONs.

A practical tip > Upon opening the model there are greyed-out commented lines under each
section to indicate the syntax convention.

17. Complete the PARAMETER section adding the parameters given in the following table with grey
background:
Symbol Description Units gPROMS identifier Size Type
NC Components - components - ORDERED_SET
NF Number of inlet streams - number_of_inlets - INTEGER
MWi Molecular weight of component i kg/kmol molecular_weight components REAL
𝛎𝐢 Stoichiometry of component i - reaction_stoichiometry components INTEGER
Pre-exponential factor in 𝑘𝑟 reaction
𝐤 𝐫,𝟎 kmol/hr/kgcat pre_constant_r - REAL
kinetic expression
𝐄𝐚𝐫 Activation energy for 𝑘𝑟 reaction kJ/kmol activation_energy_r - REAL
Pre-exponential factor in
𝐤 𝐢,𝟎 reaction kinetic expression for each kPa-1 pre_constant components REAL
component i
Activation energy for reaction of
𝐄𝐚𝐢 kJ/kmol activation_energy components REAL
each component i
Equilibrium constants for 𝐾𝑒𝑞 kinetic
𝐤 𝟏𝐞𝐪 , 𝐤 𝟐𝐞𝐪 - equilibrium_constants 2 REAL
expression
Patm Atmospheric pressure kPa Patm - REAL

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 9


Implementing a lumped model in gPROMS

R Ideal gas constant kJ/kmol/K ideal_gas_constant - REAL


mcat Weight of catalyst kg catalyst_weight - REAL
V Volume of reactor m3 volume - REAL

18. Complete the VARIABLE section adding the variables given in the following table with grey
background. Note that the variable types required will be available through the cross-referenced
gML Basics Interface library.
Symbol Description Units gPROMS identifier Size Variable type
Amount of mass contained
Mmassi kg mass_holdup components mass_holdup_gML
in the tank of component i
Inlet mass flowrate for
Fin, j kg/s inlet_mass_flowrate number_of_inlets mass_flowrate_gML
stream j
Inlet mass fraction of components
win, i,j - inlet_mass_fraction mass_fraction_gML
component i for stream j number_of_inlets
Fout Overall outlet mass flowrate kg/s outlet_mass_flowrate - mass_flowrate_gML
wi Mass fraction of component i - mass_fraction components mass_fraction_gML
kmol/s/k reaction_rate_kmol_per_s_
r Molar reaction rate molar_reaction_rate -
gcat kg_gML
Total amount of mass in
MmassT kg total_mass_holdup - mass_holdup_gML
system
Keq Equilibrium constant - k_eq - no_type_gML
Kinetic parameters for -1
Ki kPa k components no_type_gML
component i
Kinetic parameter for main kmol/hr/
kr kr - no_type_gML
reaction kgcat
pT Total pressure kPa total_pressure - pressure_kPa_gML
Vp Stem position of outlet valve - valve_position - no_type_gML
Valve proportionality
Cv - valve_constant - no_type_gML
constant
T Reactor temperature K temperature - temperature_gML
pi Pressure of component i kPa partial_pressure components pressure_partial_kPa_gML
Molar fraction of component
xi - molar_fraction components molar_fraction_gML
i
Total amount of moles in
MmolarT kmol total_molar_holdup - molar_holdup_kmol_gML
system

19. Complete the EQUATION section adding the equations given in the following table with grey
background:
Description Equation form Size
𝑁𝐹

Mass balance 0 = ∑(𝐹𝑖𝑛,𝑗 ∙ 𝑤𝑖𝑛,𝑖,𝑗 ) − 𝐹𝑜𝑢𝑡 ∙ 𝑤𝑖 + 𝑚𝑐𝑎𝑡 ∙ 𝜈𝑖 ∙ 𝑟 ∙ 𝑀𝑊𝑖 𝑖 = CO, H2 , CH3 OH


𝑗=1

Langmuir-Hinshelwood reaction rate 𝑘𝑟 (𝑝CO ∙ 𝑝H2 2 − 1⁄𝐾 ∙ 𝑝CH3OH )


𝑒𝑞 -
expression 𝑟= 3
(1 + 𝐾CO ∙ 𝑝CO + 𝐾H2 ∙ 𝑝H2 + 𝐾CH3OH ∙ 𝑝CH3OH )
2
𝑘𝑒𝑞
1 ⁄
Equilibrium constant 𝐾𝑒𝑞 = exp−𝑘𝑒𝑞+ 𝑇 -
−𝐸𝑎𝑟
Reaction constant 𝑘𝑟 = 𝑘𝑟,0 ∙ exp 𝑅𝑇 -
−𝐸𝑎𝑖
Reaction constants 𝐾𝑖 = 𝑘𝑖,0 ∙ exp 𝑅𝑇 𝑖 = CO, H2 , CH3 OH

Ideal Gas Relation 𝑝𝑇 ∙ 𝑉 = 𝑀𝑇𝑚𝑜𝑙𝑎𝑟 ∙ 𝑅 ∙ 𝑇 -


𝑉𝑝 ∙ 𝐶𝑣
Outlet Flowrate 𝐹𝑜𝑢𝑡 = ∙ (𝑝𝑇 − 𝑝𝑎𝑡𝑚 ) -
√𝑇

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 10


Implementing a lumped model in gPROMS

𝑁𝐶
Total mass holdup 𝑀𝑇𝑚𝑎𝑠𝑠 = ∑(𝑀𝑖𝑚𝑎𝑠𝑠 ) -
𝑖=1
𝑁𝐶
𝑀𝑖𝑚𝑎𝑠𝑠
Total molar holdup 𝑀𝑇𝑚𝑜𝑙𝑎𝑟 = ∑ ( ) -
𝑀𝑊𝑖
𝑖=1

Holdup to total Holdup relation 𝑀𝑖𝑚𝑎𝑠𝑠 = 𝑤𝑖 ∙ 𝑀𝑇𝑚𝑎𝑠𝑠 𝑖 = CO, H2 , CH3 OH

Partial pressure calculation 𝑝𝑖 = 𝑥𝑖 ∙ 𝑝𝑇 𝑖 = CO, H2 , CH3 OH

𝑁𝐶
Mass fraction to molar fraction 𝑤𝑖 𝑤𝑖
𝑥𝑖 ∙ ∑ ( )= 𝑖 = CO, H2 , CH3 OH
relation 𝑀𝑊𝑖 𝑀𝑊𝑖
𝑖=1

20. The model is now complete. Next, you will set up a simulation using this model.
The input information specific to this simulation is provided in a process entity. Open the process
called gas_phase_CSTR and notice the following predefined sections:
• UNIT
• SET
• ASSIGN
• INITIAL

Concept > Relation between process and model entities. A mathematical representation of the
system is defined within the model entity. Case specific information of the model is relayed in the
process entity.

The model however needs to referenced for the simulation and is done so in the UNIT section of
the process which defines the model (or models) to be used in the simulation.

21. To run a simulation, the full set of PARAMETERs is to be defined in the SET section according to
the following information:
Symbol gPROMS identifier Values Units
NF number_of_inlets 2 -
MWi molecular_weight [28.011, 2.0158, 32.0421] kg/kmol
mcat catalyst_weight 10 kg
V volume 5 m3
NC components ['CARBON MONOXIDE', 'HYDROGEN', 'METHANOL'] -
𝝂𝒊 reaction_stoichiometry [-1, -2, +1] -
𝒌𝒓,𝟎 pre_constant_r 9.93 x 1010 kmol/hr/kgcat
𝑬𝐚𝒓 activation_energy_r 135000 kJ/kmol
𝒌𝒊,𝟎 pre_constant 6 4 6
[5.60 x 10 , 1.35 x 10 , 5.97 x 10 ] kPa-1
𝑬𝒂𝒊 activation_energy [74000, 54955.5, 74000] kJ/kmol
𝒌𝟏𝒆𝒒 , 𝒌𝟐𝒆𝒒 equilibrium_constants [5, 500] -

22. Then move to the ASSIGN section to specify the degrees of freedom.
Symbol gPROMS identifiers Values Units
Fin, 1 inlet_mass_flowrate(1) 7.78E-04 kg/s
Fin, 2 inlet_mass_flowrate(2) 1.40E-05 kg/s
win, i,1 inlet_mass_fraction(,1) [1, 0, 0] kg/kg
win, i,2 inlet_mass_fraction(,2) [0, 1, 0] kg/kg

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 11


Implementing a lumped model in gPROMS

Vp valve_position 0.5 -

pT total_pressure 1300 kPa


T temperature 475.15 K

23. The system is to be operated under steady-state conditions, and thus the state of the model is
specified as such in the INITIAL section:

INITIAL
STEADY_STATE

24. The simulation is ready to be executed. To execute the simulation, select the process in the project
tree and in the toolbar, click the simulate button ( ).
The Simulate dialog box will appear. Accept the default settings and run the simulation with “OK”.

Concept > Analysing simulation results. The execution output appears and gRMS is started.
Also, note that a new case is being created – this is the blue folder in the project tree. By default,
the name of the case is a concatenation of the process name (i.e. gas_phase_CSTR) plus a date
and time stamp.

25. Results may be viewed at a glance within the gPROMS Process environment through expanding
the Trajectories folder of the case created to reveal the variables within the UNIT Reactor.
Take note of the values for the following variables:

• valve constant Cv
• mass holdup Mmass of each component.
Symbol gPROMS identifiers Values Units
Cv valve_constant -
𝐦𝐚𝐬𝐬
𝐌𝐂𝐎 mass_holdup(‘'CARBON MONOXIDE'’) kg
𝐌𝐇𝐦𝐚𝐬𝐬
𝟐
mass_holdup(‘HYDROGEN’) kg
𝐦𝐚𝐬𝐬
𝐌𝐌𝐞𝐎𝐇 mass_holdup(‘METHANOL’) kg

26. Starting from steady state we will now perform a dynamic simulation of the reactor.
Go to the gPROMS language tab of the model gas_phase_CSTR and in the mass balance
𝑑
equation, replace the zero on left hand side of the equation with 𝑑𝑡 (𝑀𝑖𝑚𝑎𝑠𝑠 ).

A practical tip > Useful intrinsic functions:


“$” to represent 𝑑⁄𝑑𝑡

27. The simulation requires INITIAL values for all differential variables (i.e. at time equals zero).
Go to the process and in the INITIAL section, replace the STEADY_STATE reference with the
steady-state values of the mass holdup for each component.

INITIAL
WITHIN Reactor DO
mass_holdUp('CARBON MONOXIDE') = ;
mass_holdUp('HYDROGEN') = ;
mass_holdUp('METHANOL') = ;
END

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 12


Implementing a lumped model in gPROMS

28. In the ASSIGN section, remove the specification of the total pressure and add a specification for
the value found in the steady-state simulation for the valve constant (Cv).
29. Add the following operating procedure to the process:

Time [s]: 0 - 3600 3,600 – 36,000 36,000 – 436,000


-4 -5
Fin(1) [kg/s] 7.78 x 10 7.78 x 10 9.34 x 10-4
Fin(2) [kg/s] 1.4 x 10-5 1.54 x 10-4 1.4 x 10-5

To do so add the gPROMS keyword “SCHEDULE” at the bottom of the process, and use the tasks
CONTINUE and REASSIGN to describe the given operating procedure.

Concept > Defining schedules. Schedules can be generated by entering gPROMS language, by
using a graphical interface or by using a combination of the two. Both methods are entirely
equivalent and interchangeable: when a schedule is modified using the graphical interface, the
equivalent change is automatically made to the language and, similarly, changes made to the
gPROMS language are automatically applied to the graphical representation of the Schedule.

30. Execute the simulation.


31. Read the result trajectories in the case file and take note of the values for the mass holdup Mmass of
each component in different times.
Symbol gPROMS identifiers Time (s) Values Units
0 kg
𝐦𝐚𝐬𝐬
𝐌𝐂𝐎 mass_holdup(‘'CARBON MONOXIDE'’) 50,000 kg
360,000 kg
0 kg
𝐌𝐇𝐦𝐚𝐬𝐬
𝟐 mass_holdup(‘HYDROGEN’) 50,000 kg
360,000 kg
0 kg
𝐦𝐚𝐬𝐬
𝐌𝐌𝐞𝐎𝐇 mass_holdup(‘METHANOL’) 50,000 kg
360,000 kg

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 13


Implementing a lumped model in gPROMS

Exercise 2
Adding discontinuities to the isothermal model of a gas-phase
CSTR

Objectives

By the end of this exercise, you will know how to handle discontinuities in gPROMS. This will be
demonstrated through regulating the pressure in the reactor through controlling the stem position of the
outlet valve using a proportional integral (PI) controller, as shown below:

Copper catalyst basket


Fin, CO, xin, CO, Tin, CO

PI
Fin, H2, xin, H2, Tin, H2

Fout, xi, T

The heterogeneous gas/solid catalytic reactor system with PI controller.

The setpoint pressure is 1300 kPa. The valve has hysteresis in that the valve opens when the pressure
reaches 1305 kPa and closes when pressure falls below 1295 kPa.

Things to do
1. Open the starter project ‘Starter 202 Exercise 2.gPJ’ and save it with a different name. Alternatively,
use the project file created in Exercise 1.
2. Add the following PARAMETERs in the model gas_phase_CSTR:
Symbol Description Units gPROMS identifier Size Parameter type
Pressure that opens outlet
popen kPa p_open - REAL
valve
Pressure that closes outlet
pclose kPa p_close - REAL
valve
Psp Pressure setpoint kPa total_pressure_setpoint - REAL

3. Between the VARIABLE and EQUATION sections, add a SELECTOR named ValveState having
the states Open and Closed.
Go to the equation that represents the outlet flowrate and incorporate the current equation to be
active when the valve is Open and when the valve is Closed, the outlet flowrate is zero.
Remember: A state within a SELECTOR may be switched if conditional arguments are true, for
example, if the ValveState is currently set as Closed, ValveState can switch to Open if pT > popen.
4. To implement a PI controller, the following VARIABLEs are to be defined:

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 14


Implementing a lumped model in gPROMS

Symbol Description Units gPROMS identifier Size Variable type


ε Error term kPa error - no_type_gML
ε* Integral error term - integral_error - no_type_gML
aux
Vp Auxiliary valve position - valve_position_aux - no_type_gML
ss
Vp Steady-state valve position - st_st_valve_position - no_type_gML
Kc Proportional gain - proportional_gain - no_type_gML
τ Time constant - time_constant - no_type_gML

5. Then go to the EQUATION section and implement the following PI controller equations for valve
position control:

Description Equation form


Error term 𝜀 = 𝑝 𝑠𝑝 − 𝑝𝑇
1
Proportional Integral controller 𝑉𝑝aux = 𝑉𝑝𝑠𝑠 + 𝐾𝑐 ∙ (𝜀 + 𝜀 ∗ )
𝜏
𝑡
𝑑𝜀 ∗
Integral error term =𝜀 𝑜𝑟 (𝜀 ∗ = ∫ 𝜀(𝑡′) 𝑑𝑡 ′ )
𝑑𝑡
0
To limit actual valve position between 0 and 1 𝑉𝑝 = MAX(MIN(1, 𝑉𝑝aux ), 0)

6. Go to the process simulate_gas_phase_CSTR and ensure the PARAMETERs and VARIABLEs


defined above are SET and ASSIGNed the following values:

Symbol gPROMS identifier Type Values Units


open
p p_open Parameter 1305 kPa
close
p p_close Parameter 1295 kPa
Psp total_pressure_setpoint Parameter 1300 kPa
SS
Vp st_st_valve_position Variable 0.5 -
Kc proportional_gain Variable -171 -
τ time_constant Variable 1.48 x 108 -

7. As the valve position is now calculated, remove its assignment in the process.
8. The SELECTOR specified in the model needs to be given an initial value. Add the gPROMS
keyword INITIALSELECTOR between the ASSIGN and INITIAL section and specify the valve as
initially Open.

9. Finally, as a further differential variable (i.e., integral_error) has been added to the model, an initial
value for this variable needs to be given. Set the integral error initially to zero.
10. Run the simulation.
11. Observe the trajectories of the following variables to visualise the dynamics of the controller:
• Total pressure
• Outlet flowrate
• Valve position
12. Modify the controller’s time constant to 400 and simulate the process again. What is the effect of
the time constant on the controller’s response and the dynamics of the model?

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 15


Implementing a lumped model in gPROMS

Exercise 3
Extending the gas-phase CSTR model to include
thermodynamics

Objectives

By the end of the exercise, you will know how to:

• Use the user interface gPROMS Properties to define a material in a project


• Write calls to a physical property foreign object in the gPROMS language

Things to do
1. Open the starter project ‘Starter 202 Exercise 3.gPJ’ and save it with a different name. Alternatively,
add energy balance in the project file created in Exercise 2.
2. Open the model gas_phase_CSTR and observe the following changes that were introduced since
the last exercise:
• A PARAMETER phys_prop has been defined as a foreign object
• A PARAMETER reaction_enthalpy has been defined and given a value in the set section

• VARIABLEs have been added for enthalpies, fugacity coefficients and energy holdup

• An energy balance has been added


• The reaction rate term includes fugacity coefficients

• A section in the EQUATION section for physical property calls to be added


3. The first task will be to create the material entity.
Right click anywhere on the project file and click ‘New Entity’. Select ‘Material’ and name the entity
Mixture_PengRobinson. Select the type ‘gPROMS Properties’ from the drop-down menu here,
press ‘OK’.

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 16


Implementing a lumped model in gPROMS

4. The gPROMS Properties user interface should open in a few seconds as shown below:

5. Select carbon monoxide, hydrogen, and methanol from the list of components. You can scroll
through the list of components, or you can use the search bar shown in the image above. Press
‘Next’. The ‘Perform speciation’ section suggests additional species to consider under
Compounds based on any speciation reactions added in the databank for the selected
components. For e.g., if NaOH is selected as a components, the dissociation reaction would
result in a Sodium ion (Na+) and a Hydroxide ion (OH-). Since we do not have such components,
press ‘Next’.
6. In the ‘Define chemical reactions’ menu, you can define chemical reactions that you might need to
consider in your mixture. For this exercise, we will not consider any chemical reaction, so press
‘Next’ again.
7. In the ‘Define phases’ tab, please select that carbon monoxide and hydrogen should appear in the
gas and that methanol may appear in both phases. It should look like the window below:

8. In the ‘Select thermodynamic models’ tab click on ‘Select...’ and a drop-down will appear. Choose
the Peng-Robinson model for both the gas and liquid phase as this model is appropriate for the
system.
9. Press ‘Next’ and pick the ‘Chung-Ajlan-Lee-Starling’ method for viscosity and thermal conductivity
in the gas phase. Select the ‘Macleod-Sudgen’ for surface tension between the gas and liquid
phases.
10. Press ‘Finish’. The new Material entity will be shown in your Project tree.

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 17


Implementing a lumped model in gPROMS

A practical tip > The component names for the gPROMS Properties physical property packages can
also be defined through a file located within the Miscellaneous Files folder of the Project.

Open the Material folder and then open the newly created ‘.gproperties file’.

11. Observe that the enthalpy datum (or reference state) is using an element basis. This implies that
the reaction energy term is implicitly specified; however, we have already defined this term in the
model with gPROMS language. In order to avoid calculating this twice, in the ‘.gproperties’ file,
manually change the line below to switch to a compound basis.
<datum>element</datum> to <datum>species</datum>

Concept > For a CSTR the energy balance can be written in two equivalent ways, where:

𝐻 = 𝐻𝑠 − ∆𝐻𝑓0

1) The enthalpy datum of an element basis gives total enthalpy:


𝑇
𝐻 = ∆𝐻𝑓0 + ∫ 𝐶𝑝 𝑑𝑇
𝑇0

2) The enthalpy datum of a compound basis gives sensible enthalpy:


𝑇
𝐻𝑠 = ∫ 𝐶𝑝 𝑑𝑇
𝑇0

12. In the gas_phase_CSTR model, complete the physical property calls for fugacity and enthalpies
using the following information:

Method name Description Input Arguments and units Output units


T [K]
Returns a list of values of fugacity
VapourFugacityCoefficient PT [Pa] -
of component i in the vapour phase
wi [-]
T [K]
Returns a scalar value for the
VapourEnthalpy PT [Pa] J/kg
enthalpy in the vapour phase
wi [-]

Remember to take note of the units of the input arguments and of the required form of the output
variable.
13. Go to the process simulate_gas_phase_CSTR and provide the correct string setting to the
phys_prop PARAMETER.
14. Obtain the list of components and the molecular weights from the foreign object by using the
following information:
Input Arguments and Output
Method name Description
units units
Components Returns a list of strings for the names of the components - -
Returns a list of values for the molecular weight of each
Molecularweight - kg/kmol
component

15. Run the simulation.


16. Observe the trajectories of the following variables to visualise effects of including thermodynamics:

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 18


Implementing a lumped model in gPROMS

• Temperature

• Partial pressures

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 19


Implementing a lumped model in gPROMS

Exercise 4
Troubleshooting basic errors

Objectives

By the end of this exercise, you will know how to diagnose, recognise, and overcome basic
errors.

Things to do
1. Open the starter project ‘Starter 202 Exercise 4.gPJ’ and save it with a different name.
2. Go to process gas_phase_CSTR_1 and simulate the process.
An error will occur.
3. In the Execution output window, diagnose the error message and action accordingly.
4. Repeat for the remaining processes.

Practical tip > Output level of solvers. The amount of information provided to the user in the
Execution Output of the case file can be increased by increasing the OutputLevel parameter of
specific solvers in the Process entity (Solution Parameters tab) – e.g., NumericalSolvers >
DASolver > OutputLevel := 2

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 20


Implementing a lumped model in gPROMS

COMMERCIAL IN CONFIDENCE

© Siemens Industry Software Limited 21

You might also like