gproms
TRANSCRIPT
Page 1 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
An introduction to gPROMSgPROMS training course
London27-29 September 2010
© 2010 Process Systems Enterprise Limited
Building your own models in gPROMS I. Lumped models
Page 2 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Building your own models in gPROMSI. Lumped models
1. The gPROMS ModelBuilder environment
2. Motivation: why build your own models?
3. First-principles mathematical modelling in gPROMS
4. Degrees of freedom and initial conditions
5. Running a simulation and viewing the results
6. Using the modelling support tools
7. Using arrays and intrinsic functions
8. Modelling systems with discontinuities
9. Constructing composite models
3
© 2010 Process Systems Enterprise Limited
1. The gPROMS ModelBuilder environment
Page 3 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
The working environment of gPROMS
5
Project tree area
Entity editor
Menus & toolbars
Topology/flowsheeting
Model Public Interface
© 2010 Process Systems Enterprise Limited
Project tree area
6
Library Projects (green colour) contain potentially re-usable components (usually) read-only projects Can be referred to by other libraries/projects Example: Process Model Libraries (PML)
Projects (yellow colour) developed by the user consist of several folders/groups each group contains entities used to construct
model-based applications
Cases (blue colour) created once an activity is executed read-only contain all input information and results a complete record of a model-based activity
Page 4 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Alternative representation: model palette
7More suitable in flowsheeting projects
© 2010 Process Systems Enterprise Limited
Entity editor formats
8
Text
Dialogs
TopologyFlowsheeting
Page 5 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
2. Motivation: why build your own models ?
Building your own models in gPROMS - I. Lumped models
© 2010 Process Systems Enterprise Limited
Why build your own models ?
1. New applications need to develop first-principle models from scratch
2. Library models are not suitable for each and every application need to customise them
Keep in mind: combination with other models need to comply to some standard: model libraries
gPROMS: an advanced and flexible environment for custom model development
custom model use mix & match with library models
10
Page 6 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
3. First-principles mathematical modelling in gPROMS
Building your own models in gPROMS - I. Lumped models
© 2010 Process Systems Enterprise Limited
An elementary MODEL: Buffer tank with gravity-driven outflow
outin
dMF F
dt
Equations
mass balance:
calculation of liquid level in the tank:
characterisation of the output flowrate:
Parameters: , A ,
Variables: M, Fin, Fout, h 12
M Ah
out
F h
h
Fout
M
Fin
Page 7 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
PARAMETERarea , density AS REALoutlet_flowrate_coefficient AS REAL
VARIABLEinlet_mass_flowrate AS mass_flowrateoutlet_mass_flowrate AS mass_flowratemass_holdup AS massheight AS length
EQUATION
# Mass balance$mass_holdup = inlet_mass_flowrate - outlet_mass_flowrate ;
# Relation of liquid level to mass holdupmass_holdup = density * area * height ;
# Relation of outlet mass flowrate to liquid leveloutlet_mass_flowrate = outlet_flowrate_coefficient * SQRT ( height ) ;
An elementary MODEL: Buffer tank with gravity-driven outflow
13
© 2010 Process Systems Enterprise Limited
Parameters
PARAMETERs must be given fixed values before a simulation begins
Supported types: REAL | INTEGER
... | LOGICAL | FOREIGN_OBJECT | ORDERED_SET
14
PARAMETERarea , density AS REALoutlet_flowrate_coefficient AS REAL
Page 8 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
gPROMS language – case convention
gPROMS language is case-insensitive
but...
Convention used by PSE:
all gPROMS keywords in CAPITALS
user-defined identifiers in MixedCase or by separating words with an underscore“_” E.g. ExternalHeatInput or external_heat_input
Use descriptive names!15
© 2010 Process Systems Enterprise Limited
PARAMETERarea , density AS REALoutlet_flowrate_coefficient AS REAL
VARIABLEinlet_mass_flowrate AS mass_flowrateoutlet_mass_flowrate AS mass_flowratemass_holdup AS massheight AS length
EQUATION
# Mass balance$mass_holdup = inlet_mass_flowrate - outlet_mass_flowrate ;
# Relation of liquid level to mass holdupmass_holdup = density * area * height ;
# Relation of outlet mass flowrate to liquid leveloutlet_mass_flowrate = outlet_flowrate_coefficient * SQRT ( height ) ;
An elementary MODEL: Buffer tank with gravity-driven outflow
16
Page 9 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
VARIABLEinlet_mass_flowrate AS mass_flowrateoutlet_mass_flowrate AS mass_flowratemass_holdup AS massheight AS length
Variables
VARIABLEs may vary with time
Can be either specified by user or calculated by the simulation
VARIABLEs are associated with a VARIABLE TYPE17
© 2010 Process Systems Enterprise Limited
Numerical definition:
Default value is used as initial guess for the initialisation calculation.
Lower and Upper bounds define the valid ranges for all Variables of this type: a Variable can never take a value outside this range
Units are not used in the calculation but are very important for model readability and maintainability
A set of commonly used Variable Types is defined in the PML Basics library
based on SI units
look there first before defining your own!
Variable types - II
18
Page 10 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
PARAMETERarea , density AS REALoutlet_flowrate_coefficient AS REAL
VARIABLEinlet_mass_flowrate AS mass_flowrateoutlet_mass_flowrate AS mass_flowratemass_holdup AS massheight AS length
EQUATION
# Mass balance$mass_holdup = inlet_mass_flowrate - outlet_mass_flowrate ;
# Relation of liquid level to mass holdupmass_holdup = density * area * height ;
# Relation of outlet mass flowrate to liquid leveloutlet_mass_flowrate = outlet_flowrate_coefficient * SQRT ( height ) ;
An elementary MODEL: Buffer tank with gravity-driven outflow
19
outin
dMF F
dt
M Ah
out
F h
h
Fout
M
Fin
© 2010 Process Systems Enterprise Limited
Equations
EQUATIONs can be partial, differential and algebraic
Time derivatives: $HoldUp
Use CTRL+space while typing to obtain list of valid completions
Comments
single line comments:# …
multiple line comments:{…}
20
Page 11 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Elementary MODELs – III
Arithmetic operators:
+ - / ^
Built-in functions:SQRT(Height)
Declarative language
order of equations not important !
form of equations (usually) not important !
21
© 2010 Process Systems Enterprise Limited
4. Degrees-of-freedom and initial conditions
Building your own models in gPROMS - I. Lumped models
Page 12 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Defining a simulation degrees of freedom - I
Number of variables: 4
Number of equations: 3
need 1 (=4-3) extra specification ("input"), e.g.:
23
, , , outin
M F F h
outin
out
dMF F
dt
M Ah
F h
20inF
© 2010 Process Systems Enterprise Limited
Defining a simulation degrees of freedom - II
Number of variables: 4
Number of equations: 3
or more generally...
24
, , , outin
M F F h
outin
out
dMF F
dt
M Ah
F h
( )in in
F F t
Page 13 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Defining a simulation degrees of freedom - III
25
Fin(t)
t
h(t)?
Fout(t)?M(t)?
© 2010 Process Systems Enterprise Limited
Defining a simulation initial conditions
At t = 0, we need to determine:
(N.B. Fin(0) already known from upstream unit)
Must satisfy equations at t = 0:
Need one extra equation at t = 0 (“initial condition"), e.g.:
(0) 2.1h
26
(0) , (0) , (0) , (0) , (0)outin
M M h F F
(0) (0) (0)
(0) (0)
(0) (0)
outin
out
M F F
M Ah
F h
Page 14 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Defining a simulation initial conditions
Initial conditions can be general equations:
Commonly used initial condition:
Usually …
27
(0) 3.2h
i.e. system initially at steady-state
(0)0
dM
dt
Number of Number ofInitial Conditions Differential Variables
=
© 2010 Process Systems Enterprise Limited
MODEL vs. PROCESS entities: generic vs specific
A typical MODEL...
Describes physical behaviour in equations, parameters, and variables
Is generic for all unit operations of that type
A typical PROCESS...
Contains all case-specific information needed for simulation Input specifications
Operating procedure
Solver settings (optional)
28
Page 15 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Defining a simulation – I
Create a new PROCESS: SimulateTank
29
© 2010 Process Systems Enterprise Limited
Defining a simulation – II
What MODEL(s) to simulate?
UNIT
T101 AS BufferTank
Simultaneous simulation with multiple instances of the same model :UNIT
T101 AS BufferTank
T102 AS BufferTank
T103 AS BufferTank
30
T101
T101 T102 T103
Page 16 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Defining a simulation – III
SET values of PARAMETERs:
SET # Parameter values
T101.area := 1 ; # m2
T101.outlet_flowrate_coefficient := 10 ;
T101.density := 1000 ; # kg/m3
Always need to refer to which model instance (e.g. T101)
Use WITHIN for more compact notation:
SET # Parameter values
WITHIN T101 DO
area := 1 ; # m2
outlet_flowrate_coefficient := 10 ;
density := 1000 ; # kg/m3
END # WITHIN T101
31
Assignment symbol in
gPROMS
© 2010 Process Systems Enterprise Limited
Defining a simulation – IV
ASSIGN degrees of freedom:
ASSIGN # Degrees of freedom
T101.inlet_mass_flowrate := 20 ;
Or
ASSIGN # Degrees of freedom
T101.inlet_mass_flowrate
:= 20 + 10.0 * SIN ( 22 * 3.14 * TIME / 100 ) ;
32
Page 17 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Defining a simulation – V
Initial conditions
INITIAL # Initial conditions
T101.Height = 2.1 ;
If initially at steady-state, specify:
INITIAL
T101.$mass_holdUp = 0 ;
Or:
INITIAL
STEADY_STATE
33
INITIAL conditions are equations,
not assignments
© 2010 Process Systems Enterprise Limited
Defining a simulation – VI
Specify the SCHEDULE of the operation procedure to be simulated:
SCHEDULE # Operating procedure
CONTINUE FOR 1800
34
Page 18 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
A complete PROCESS
35
UNIT # Equipment itemsT101 AS Buffer_tank
SET # Parameter valuesWITHIN T101 DO
area := 1 ; # m2outlet_flowrate_coefficient := 10 ;density := 1000 ; # kg/m3
END # WITHIN T101
ASSIGN # Degrees of freedomT101.inlet_mass_flowrate := 20 ; # kg/s
INITIAL # Initial conditionsT101.height = 2.1 ; # m
SCHEDULE # Operating procedureCONTINUE FOR 1800
© 2010 Process Systems Enterprise Limited
5. Running a simulation and viewing the results
Building your own models in gPROMS - I. Lumped models
Page 19 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Executing a simulation in gPROMS
37
Select the appropriate PROCESS entity
Press the “Simulate…” button to start the simulation (or press F5)
History of already performed simulations
© 2010 Process Systems Enterprise Limited
The execution control dialog
Execution specifications
Configuration of Case content
Miscellaneous execution controls
38
A Case project is automatically created at the start of the execution
Page 20 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Executing…
39
The gPROMS Results Management System (gRMS) is loaded (if selected)
Case project is created
A licence is reserved for the particular Case
Execution output
Stop execution button
© 2010 Process Systems Enterprise Limited
Interacting with the execution output:the diagnostics console
Reserve the licence after execution
40
The diagnostics console allows you to
query variables, equations, blocks,
units and create model reports and saved
variable sets
Page 21 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Case project structure
Original entities: contain full description of the problem Used to create a new project Easily reproduce results
Trajectories: simulation results Tables, graphs, stream tables, model reports
Problem description: complete definition of the activity in the gPROMS language Used for debugging in relation to the execution output
Execution output: displays all the messages relating to the solution of the Model-based activity
41
© 2010 Process Systems Enterprise Limited
Viewing the results
View results in Case
time variation of individual variables
stream tables
model reports
gRMS: more powerful environment for configuring graphs
Other output channels
Microsoft Excel®
gPLOT
your own output channels
42
Page 22 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Viewing variable results in Case projects
43
© 2010 Process Systems Enterprise Limited
Viewing results in gRMS
Results are organised in Processes
receive data from gPROMS during activity execution
Management tools: open, save...
Provides facilities for creating 2D & 3D plots
formatting tools and templates
management tools
print, save, export
viewing and exporting data sets
44
Page 23 © Process Systems Enterprise Ltd, 2010
© 2010 Process Systems Enterprise Limited
Constructing a plot in gRMS
45
Choose 2D, 3D, XY plot or plot
Template
Click Add line...
Choose a
variable
View/change
line properties
© 2010 Process Systems Enterprise Limited
Hands-on session: Simulation of isothermal buffer tankBuilding your own models in gPROMS - I. Lumped models