Sunteți pe pagina 1din 367

2000 AspenTech. All Rights Reserved.

Introduction to Aspen Custom Modeler


3 2000 AspenTech. All Rights Reserved. ACM intro
Day 1
Overview of Aspen Custom Modeler
Description of the graphical user interface
Workshop
Review of specification
Modeling language description
Workshops
Non-isothermal reactor workshop
4 2000 AspenTech. All Rights Reserved. ACM intro
Day 2
Arrays and sets
Component properties
Submodels
Snapshots
Tasks

5 2000 AspenTech. All Rights Reserved. ACM intro
Day 3
Procedures
Scripts and Visual Basic
Scripts
Automation
introduction to PDE
introduction to Estimation
Information on solver settings

6 2000 AspenTech. All Rights Reserved. ACM intro
What is Aspen Custom Modeler?
A component of the Aspen Engineering Suite which
provides:
A language for writing equation based custom models
A graphical user interface for both the model developer and the
end user
7 2000 AspenTech. All Rights Reserved. ACM intro
What is Aspen Custom Modeler?
Solvers containing powerful numerical analysis
techniques for the resolution of:
Steady state
Dynamic integration and initialization
Steady state and dynamic optimization
Parameter estimation
Task language
Visual Basic Scripting and Automation
8 2000 AspenTech. All Rights Reserved. ACM intro
FAQ: What is the difference between Aspen
Custom Modeler and Dynamics?
These products are for 2 different types of situations:
Aspen Dynamics :
Running "off the shelf" models based on Aspen Plus
simulation flowsheet
Aspen Custom Modeler:
Create and run your own "custom" models
You can use the Custom Modeling feature simply by
activating the "Custom Modeling" option in Aspen
Dynamics program (if you have the both licenses)
9 2000 AspenTech. All Rights Reserved. ACM intro
Aspen Custom Modeler and Dynamics
Feature ACM AD ACM+AD
Run GUI and
calculations

Create new models

Use the Dynamics
library

Call Properties Plus yes yes yes
2000 AspenTech. All Rights Reserved.
A Simple Example
Objective : a quick tour of Aspen Custom
Modeler
11 2000 AspenTech. All Rights Reserved. ACM intro
Buffer Tank Flowsheet
Fin, Cain
Fout, Caout
height
diameter
level
time
time
?
12 2000 AspenTech. All Rights Reserved. ACM intro
Buffer Tank Dynamics
How to tackle this problem ?
Carefully state what are the objectives : i.e. what is the outlet
concentration as a function of time, in response to disturbances
in the feed composition and flowrate
Analyze the system to enumerate the different quantities
describing it (variables), and the relations that link all theses
quantities together (equations)
13 2000 AspenTech. All Rights Reserved. ACM intro
Modeling in Aspen Custom Modeler
Write the variables and equations
Variables
Decide on units, values, bounds : "Variable types" in ACM
Equations
Modeling assumptions : "Model" and "Blocks"
Specifications
Develop the simulation model
Model, stream and port types in ACM
Build the flowsheet and run
2000 AspenTech. All Rights Reserved.
Exploring the Graphical User Interface
15 2000 AspenTech. All Rights Reserved. ACM intro
Exploring the Graphical User Interface
Aspen Custom Modeler (ACM) files:
myflowsheet.acmf
ACM language file (ASCII file)
myflowsheet.acmd
ACM document (binary file)
mylibrary.acml
ACM library file (binary)
Note:
File extensions are displayed if you have let Windows Explorer
options do so.
16 2000 AspenTech. All Rights Reserved. ACM intro
Exploring the Graphical User Interface
To start ACM:
From the Start menu
Create a shortcut
To start ACM and open a file:
Double click on the file
Drag and drop the file onto the ACM program icon
To exit ACM : File/Exit
Allow a small delay before restarting

17 2000 AspenTech. All Rights Reserved. ACM intro
Running Aspen Custom Modeler
Client/Server architecture
Client : Graphical User Interface (GUI) running on Windows
NT/95/98 Intel PC
Servers : simulation and task servers
"sim_server"
"am_task_server"
Running on the same PC in background
May be run on another PC Windows NT Intel
18 2000 AspenTech. All Rights Reserved. ACM intro
Exploring the Graphical User Interface
menus
help
run mode
flowsheet
simulation messages
content of
selected
object
explorer
run buttons
specification status
19 2000 AspenTech. All Rights Reserved. ACM intro
Simulation Explorer operation is similar to
Windows Explorer
Expand/collapse
+ and -
Single click on the
icon to select
Content of
selected
object
a star = double click
launch action
20 2000 AspenTech. All Rights Reserved. ACM intro
Simulation Explorer
Flowsheet
Custom Modeling : your working space for new
definitions
Model types
Stream types
Port types
Variable types
Parameters types
Procedures
Tasks
21 2000 AspenTech. All Rights Reserved. ACM intro
Simulation Explorer
Libraries - "read only" type definitions
Modeler
System Library
22 2000 AspenTech. All Rights Reserved. ACM intro
Flowsheet Window
Building the flowsheet with Drag and Drop
23 2000 AspenTech. All Rights Reserved. ACM intro
Running the Simulation
Allowed only when the system is correctly specified
Check status button or the status window
Select run mode
Specification status depends on run mode
Run Pause
Restart
Rewind
Reset
Step
24 2000 AspenTech. All Rights Reserved. ACM intro
Help
Extensive on-line help available
"How to" help
Reference help
Context sensitive
help
Tool tips
25 2000 AspenTech. All Rights Reserved. ACM intro
Messages Window
Displays all messages
Loading files, building/compiling types, checking specifications,
diagnostic messages from solvers during solution, ...






Right mouse button to change messages options
View/Messages to hide/display window
2000 AspenTech. All Rights Reserved.
Workshop
User interface workshop
2000 AspenTech. All Rights Reserved.
Specification
28 2000 AspenTech. All Rights Reserved. ACM intro
Equation Oriented Modeling
The ACM language is declarative, i.e. you say "what"
you want, and leave it to ACM to find out "how"
Different numerical algorithms are applied to solve all the
equations simultaneously
29 2000 AspenTech. All Rights Reserved. ACM intro
Equation Oriented Modeling
The simulation model consists of:
Equations
Variables
Specifications
In a procedural language (like Basic, C or FORTRAN)
you would have to provide the calculation algorithm, i.e.
"how" to solve

30 2000 AspenTech. All Rights Reserved. ACM intro
Steady state example
Steady State model : 3 equations, 6 variables
h
V
Fin
Fout
Area
k
h A V
h k F
F F
out
out in
.
.
0
=
=
=
Fi n, Fout as f l ow_vol ;
k as r eal var i abl e;
h as l engt h;
V as vol ume;
A as ar ea;

0 = Fin - Fout;
Fout = k*sqrt(h);
V = A*h;
ACM language
note that the equations need not to be variable = expression,
they can be expression = another expression
Equations
31 2000 AspenTech. All Rights Reserved. ACM intro
Specifications
Degree of freedom




Every specification decreases the number of degrees of
freedom of the system by one
Example: for the tank model, if you give 3 variables
(fixed variables) out of the 6, ACM can resolve the
equations to find the other 3 (free variables)
Degree of Freedom = Number of variables
- Number of equations
- Number of Specifications
32 2000 AspenTech. All Rights Reserved. ACM intro
Specifications
Simulation must be have zero degree of freedom
We call this a "square" system (see next slide)
The equations and specifications must be independent
(i.e. not leading to a structurally singular system)
Not every combination of the 3 variables is allowed: for
example you can not fix both Fin and Fout (because Fin - Fout
= 0)

33 2000 AspenTech. All Rights Reserved. ACM intro
Tank specifications for steady state
"*" indicates the incidence of a variable in one equation
"Square" when we have 6 rows and 6 columns
variable 1 2 3 4 5 6
equation Fi n Fout V A h k
1 0 = Fi n-Fout
* *
2 Fout = k*sqrt(h)
* * *
3 V = A*h
* * *
4 spec 1 ?
5 spec 2 ?
6 spec 3 ?
34 2000 AspenTech. All Rights Reserved. ACM intro
Specifications
Every variable has a "Spec" property which selects its
specification mode
Valid values:
Spec Description
Fixed The variable value is specified by the user (A variable
whose value is not being solved for)
Initial A variable whose value is known at time zero for an
initialization or dynamic run
RateInitial A state variable whose time derivative is known at time
zero for an initialization or dynamic run
Free A variable whose value is being solved for (default)
35 2000 AspenTech. All Rights Reserved. ACM intro
Note
A variable is FIXED for the solver, but can be
manipulated during a dynamic run
manipulate the value in tables
define and activate tasks to implement ramps
time
FIXED
time
FIXED
user edition in a table or task
ramp in a task
36 2000 AspenTech. All Rights Reserved. ACM intro
Checking System Specification
Status button (depends on run mode)
Incomplete
Underspecified
Complete
Overspecified
Initial state underspecified
- initialization and dynamic runs only
Initial state overspecified (idem)
Singular
37 2000 AspenTech. All Rights Reserved. ACM intro
Checking System Specification
Double click on Status check button
Shortcut to Tools
Variable find with
preset options
Check legality of
specifications
Analyze
simulation
specifications
38 2000 AspenTech. All Rights Reserved. ACM intro
Analyze Tool
Button on the Specification Status dialog
Menu View, Specification Analysis...
39 2000 AspenTech. All Rights Reserved. ACM intro
Alternative to the analyze tool
Give sensible default to the specification property of the
variables in your models
Fin as flow_vol (fixed);
Fout as f l ow_vol ;
k as realvariable (fixed);
h as l engt h;
V as vol ume;
A as area (fixed);

0 = Fi n - Fout ;
Fout = k*sqr t ( h) ;
V = A*h;
default
specifications
that make the
model "square"
40 2000 AspenTech. All Rights Reserved. ACM intro
Dynamic example
Now we have 1 differential equation, 2 algebraic
equations, 1 state variable, 5 algebraic variables
Fi n, Fout as f l ow_vol ;
k as r eal var i abl e;
h as l engt h;
V as vol ume;
A as ar ea;

$V = Fin - Fout;
Fout = k*sqr t ( h) ;
V = A*h;
$variable in ACM language represents the time derivative of the variable
Equations
h A V
h k F
F F
dt
dV
out
out in
.
.
=
=
=
accumulation
41 2000 AspenTech. All Rights Reserved. ACM intro
Initial Conditions
Number of initial variables required = number of
differential equations
Initial variables : Initial or RateInitial
Natural choice : state variables
Engineering choice : levels, temperatures
42 2000 AspenTech. All Rights Reserved. ACM intro
Initial Conditions
INITIAL and FIXED are different things!
Initial conditions : the starting point for the dynamic
simulation
time
FIXED
time
INITIAL
0
43 2000 AspenTech. All Rights Reserved. ACM intro
Initialization run
Consider $V as a new variable
variable 1 2 3 4 5 6 7
equation Fi n Fout V A h k $V
1 $V = Fi n-Fout
* * *
2 Fout = k*sqrt(h)
* * *
3 V = A*h
* * *
4 spec 1 ?
5 spec 2 ?
6 spec 3 ?
7 i ni ti al 1 ?
44 2000 AspenTech. All Rights Reserved. ACM intro
Specifications
One of the possible specifications set
Vari abl e type speci fi cati on
Fin algebraic FIXED
Fout algebraic FREE
V state FREE
k algebraic FIXED
h algebraic INITIAL
A algebraic FIXED
45 2000 AspenTech. All Rights Reserved. ACM intro
Specification Status " Initial Changes"
Shortcut to specify all state variables
Defines all the derivatives in the
simulation as initialed to zero
(RATEINITIAL)
Defines all the state variables as
INITIAL to their current value
46 2000 AspenTech. All Rights Reserved. ACM intro
Steady State run with a dynamic model
Steady state is equivalent to time derivative equal to 0
In the example : dV/dt = 0
Specification types "Initial" and "RateInitial" are
equivalent as "Free" for a steady state run
47 2000 AspenTech. All Rights Reserved. ACM intro
Initialization Run
Solve the system's equations at time 0
Fixed variables
Initial variables
The value of variable time derivative gives an idea of the
direction of change and how fast the system will move in
the dynamic run
48 2000 AspenTech. All Rights Reserved. ACM intro
Dynamic run
Numerical integration proceeds step by step
Fixed time step for Implicit Euler method
Variable time step for Gear and VSIE
Settings in Run/Solver Options
Results are available at every communication intervals
Tables, plots, etc
Settings in Run/Run Options
49 2000 AspenTech. All Rights Reserved. ACM intro
Simulation settings
In Run/Solver Options
Selects the numerical resolution parameters
Integration method
Tolerance
Diagnostics
In Run/Run options
Communication interval
Pause simulation at

2000 AspenTech. All Rights Reserved.
Overview of the language
51 2000 AspenTech. All Rights Reserved. ACM intro
Syntax
ACM language is not CaSe SensiTIVE
Mark the end of each statement with ;
Free format
You can write over several lines and insert spaces for clarity
Comments :
// comment to the end of the line
/* multi lines
comments */
52 2000 AspenTech. All Rights Reserved. ACM intro
Overview of ACM Types
Flowsheet
Port Types
Port Types
Stream Types
Stream Types
Model Types
Model Types
Models
submodels
... is declared by ...
name AS type;
block
block
stream
stream
port
Parameter Types
Variable Types
variable or parameter
53 2000 AspenTech. All Rights Reserved. ACM intro
Language
Declaration of an instance


Type definition




Type indicator :
VARIABLE, PARAMETER, PORT, MODEL, STREAM, ...
instancename AS typename ;
TYPEINDICATOR typename
/ / def i ni t i on of t ype
END
54 2000 AspenTech. All Rights Reserved. ACM intro
Names
Names can be up to 27 characters
First character must be a letter
Characters allowed : a-z, A-Z, 0-9, "_"
Keywords are reserved
Keywords are displayed in blue in the editor
55 2000 AspenTech. All Rights Reserved. ACM intro
Variable Types define defaults for the variables
Value, lower and upper bound
PhysicalQuantity : base units of measurement in the
models
Either just a unit string to be displayed
Predefined names for unit conversion in GUI
VARIABLE MyVar i abl eType
Val ue: 123. 4;
Lower : 50. 0;
Upper : 500. 0;
Physi cal Quant i t y: " kg/ hr ( dr y) " ;
END
56 2000 AspenTech. All Rights Reserved. ACM intro
Variables properties
inherits from RealVariable type Property Type Defi ni ti on
Value Real current variable value
Upper Real upper bound for variable value
Lower Real lower bound for variable value
Scale Real
scaling for the variable (the solver sees the
value divided by scale)
Derivative Real time derivative (for state variables only)
Description String Variable description
PhysicalQuantity String defines the category of physical units
Units String physical units currently used
Spec SpecType free, fixed, initial or rateinitial
Tag String
variable tagname (ie for external interface like
SAX)
Record Boolean
controls whether the history of the variable is
recorded
57 2000 AspenTech. All Rights Reserved. ACM intro
Creating a Variable Type
Simulation/Custom Modeling/Variable types
1: Click here to create a new variable type
2: right mouse button (RMB)
58 2000 AspenTech. All Rights Reserved. ACM intro
Compiling Types
Compile = a lot of things
Analyze the code for syntax
Equations and variables
Check port connectivity
Etc...
Recommendation:
Compile as you
create new types
This type has not been
compiled successfully
59 2000 AspenTech. All Rights Reserved. ACM intro
Port Types
Port type:
Define the variables that can be passed between models
Syntax:
PORT PortTypeName
VariableName AS VariableTypeName ; . . .
END
60 2000 AspenTech. All Rights Reserved. ACM intro
Example
Pre-defined MainPort (in Modeler):
PORT Mai nPor t
F as f l ow_mol ;
z( component l i st ) as mol ef r act i on;
T as t emper at ur e;
P as pr essur e;
h as ent h_mol ;
END
This is an array
variable
(syntax to be
presented later)
61 2000 AspenTech. All Rights Reserved. ACM intro
Basic elements of a Model
MODEL Model Name
/ / var i abl e and par amet er decl ar at i ons
Var i abl eName AS Var i abl eTypeName;
Par amet er Name AS Par amet er TypeName;
/ / por t decl ar at i ons
Por t Name1 AS INPUT Por t TypeName;
Por t Name2 AS OUTPUT Por t TypeName;
/ / Assi gnment s
Var i abl eName. pr oper t y : expr essi on;
/ / Equat i ons
Equat i onName: expr essi on1 = expr essi on2;
END
62 2000 AspenTech. All Rights Reserved. ACM intro
Variable Declaration
Variables are declared on variable types


Examples
Tmet al as Temper at ur e ( 25) ;
Tamb as Temper at ur e ( FIXED, 25) ;
Tt ank as Temper at ur e ( INITIAL) ;
Pt ank as Pr essur e ( upper : 13) ;
C as Conc_Mol e ( descr i pt i on: " conc. of X" ) ;
a, b as Real Var i abl e;
Var i abl eName AS Var i abl eTypeName;
Var i abl eName AS Var i abl eTypeName ( Assi gnment Li st ) ;
63 2000 AspenTech. All Rights Reserved. ACM intro
Assignments
Assignment symbol ':'
Used to assign a default value to an object types
properties
Variables
Parameters
You can overwrite default values in tables for the
instance (i.e. the block, the stream)

64 2000 AspenTech. All Rights Reserved. ACM intro
Assignments
Examples
T as t emper at ur e;

T. val ue : 23; / / changes t he def aul t val ue of T
T. spec : FIXED; / / changes def aul t spec. t ype
T. l ower : - 10; / / changes t he def aul t l ower bound

65 2000 AspenTech. All Rights Reserved. ACM intro
Defining a Port in a Model
Declaration of a port (in a model type or stream type):




PortName : name of the port
Direction : INPUT or OUTPUT
Defines an anchor point for streams to be connected on a block
using this model
PortName AS Direction PortTypeName
( descr i pt i on: "some description") ;
66 2000 AspenTech. All Rights Reserved. ACM intro
Accessing Port Variables in Models
Syntax : PortName.VariableName
MODEL t ank
I n_F as input Fpor t ;
Out _P as output Fpor t ;
V as vol ume ( initial) ;
/ / mat er i al bal ance
$V = I n_F. F - Out _P. F;
END
PORT Fpor t
F as f l ow_vol ;
END
67 2000 AspenTech. All Rights Reserved. ACM intro
Equations
Equation syntax :




Optional "equationlabel" to document the equation
(optional but recommended)
Useful for diagnostics if things go wrong
$variable : time derivative of the variable
(variable.derivative)

equat i onl abel : expr essi on = anot her expr essi on;
expr essi on = anot her expr essi on;
68 2000 AspenTech. All Rights Reserved. ACM intro
Expressions
Operations:
Addition +
Subtraction -
Multiplication *
Division /
Exponent ^
Functions
LOGE( ), LOG10( ), ...
See on line help for details
69 2000 AspenTech. All Rights Reserved. ACM intro
Icon Editor
To create your own icons for blocks
user located
ports
port browser
universal
ports
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Parameters
72 2000 AspenTech. All Rights Reserved. ACM intro
Parameters
Use parameters to represent Structural values, e.g.
Number of trays, number of elements in an array
Alternative formulations in a model
Rigorous/simplified correlations
Values which are never solved, e.g.
Pi, conversion factors, acceleration due to gravity
73 2000 AspenTech. All Rights Reserved. ACM intro
Parameter Types
Create your own parameter types
IntegerParameter
LogicalParameter
RealParameter
StringParameter
Syntax presented later
74 2000 AspenTech. All Rights Reserved. ACM intro
Integer Parameter Type
Syntax
To change from the defaults of the integerparameter parameter
type
PARAMETER ParameterName USES I NTEGERPARAMETER
Val ue : DefaultParameterValue ;
Descr i pt i on : " description" ;
Upper : UpperParameterValue;
Lower : LowerParameterValue;
END
75 2000 AspenTech. All Rights Reserved. ACM intro
Real Parameter Type
Syntax
To change from the defaults of the realparameter parameter
type
PARAMETER ParameterName USES REALPARAMETER
Val ue : DefaultValue;
Descr i pt i on : " description" ;
Upper : UpperParameterValue;
Lower : LowerParameterValue;
Physi cal Quant i t y: " physicalquantityname" ;
END
2000 AspenTech. All Rights Reserved.
Conditions
77 2000 AspenTech. All Rights Reserved. ACM intro
Structural and Run-Time conditions
If the condition only uses parameters, then it is evaluated
before simulation
This is called a "structural IF"
Otherwise the condition is evaluated while running the
simulation
This is called a "Run-Time IF"
Can only change the equations forms
The syntax is very similar
78 2000 AspenTech. All Rights Reserved. ACM intro
Structural condition
Use to change model structure (equations) depending on
e.g.
Connections
Parameter values
This is called "Structural IF" because:
The parts of the model which are active can be determined
before running the simulation
These parts will remain the same during the whole simulation
79 2000 AspenTech. All Rights Reserved. ACM intro
Structural condition syntax
Simple:



Conditions can be nested e.g.
IF condition THEN
statements1;
ENDIF
IF condition THEN
statements1;
ELSE
statements2;
ENDIF
IF condition1 THEN
statements1;
IF conditions2 THEN
statements12;
ELSEIF conditions3 THEN
statements13;
ENDIF
ELSE
statements2;
ENDIF
80 2000 AspenTech. All Rights Reserved. ACM intro
Logical expressions in condition
Operators (in decreasing priority order)











Use parenthesis to change priority order
Operator Meani ng
== (two equals signs) Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to
AND Logical AND function
OR Logical OR function
NOT Logical NOT function
81 2000 AspenTech. All Rights Reserved. ACM intro
Structural condition
Conditions on parameters, connectivity
Fixed model structure at run time
Can have different number of equations
ModeOf Oper at i on as st r i ngpar amet er ;

IF ModeOf Oper at i on <> " Pr essur eDr i ven" THEN
/ / ModeOf Oper at i on has t he val ue Fl owDr i ven
/ / Fi nd mi ni mumi nl et pr essur e
Pi n = MIN( I n1. P, I n2. p) ; / / 1 eq
ELSE
/ / ModeOf Oper at i on has t he val ue Pr essur eDr i ven
/ / Equat e i nl et pr essur es
I n1. P = Pi n; / / 2 i nl et s = 2 eqs
I n2. P = Pi n;
ENDIF
82 2000 AspenTech. All Rights Reserved. ACM intro
Checking if a stream is connected on a Port
Built-in Port property "IsConnected"
true if a stream is connected on the port
false otherwise
Example
Out _Vent as output Mat er i al Por t ;

IF Out _Vent . I sConnect ed THEN
/ / a st r eami s connect ed
Out _Vent . F : free;
ELSE
/ / no st r eamconnect ed - f i x vent f l ow t o zer o
Out _Vent . F : 0, fixed;
ENDIF
83 2000 AspenTech. All Rights Reserved. ACM intro
Example of a run time condition: level of liquid
changes during simulation
VAPOR IN
LIQ OUT
VAPOR IN
LIQ OUT
VAPOR IN
LIQ OUT
flooded
dry
between
84 2000 AspenTech. All Rights Reserved. ACM intro
Run Time IF
Model:
At ot , Al i q as ar ea;
l evel as l engt h;
h_l ow, h_t ube as l engt h;

if l evel > h_l ow+h_t ube then
Al i q = At ot ; / / f l ooded
elseif l evel < h_l ow then
Al i q = 0; / / dr y
else
Al i q = At ot *( l evel - h_l ow) / h_t ube; / / bet ween
endif
85 2000 AspenTech. All Rights Reserved. ACM intro
Run-time Condition Must Be Balanced
Incorrect:







How to correct?
Need to have the same number of equations in all branches of
the IF
i f f l ow > 0 t hen
dp = k*f l ow^2;
chock = f l ow/ f max;
el se
chock = 0;
endi f
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Stream Types
88 2000 AspenTech. All Rights Reserved. ACM intro
Stream Types
Built-in stream types:
ControlSignal: connecting control variables
Connection: to connect blocks via ports
Define your own stream types to:
Define heat streams, work streams, etc
Handle heating/cooling, pressure drop along pipes
Handle feed streams
Control variables in streams
89 2000 AspenTech. All Rights Reserved. ACM intro
Streams on the Flowsheet
Example
LI
tank
lc
s_in
s_out
ControlSignal streams
Streams
90 2000 AspenTech. All Rights Reserved. ACM intro
Ports on the Flowsheet
Connect input port and output port with the selected
stream type
LI
tank
lc
s_in
s_out
Ports OUTPUT -INPUT
Variables
OUTPUT - INPUT
ControlSignal stream
91 2000 AspenTech. All Rights Reserved. ACM intro
ControlSignal Stream Type
ControlSignal is a built-in stream type used to connect a
variable marked for INPUT to a variable marked for
OUTPUT
Note that both the INPUT, OUTPUT qualifiers together can
be used only for variable declarations and not for port declarations
/ / Q can be t he dest i nat i on of a cont r ol si gnal
Q as INPUT ent hf l ow;
/ / Level can be t he sour ce of a cont r ol si gnal
Level as OUTPUT l engt h;
/ / F can be t he sour ce or t he dest i nat i on of a
/ / cont r ol si gnal
F as INPUT, OUTPUT f l ow_mol ;
92 2000 AspenTech. All Rights Reserved. ACM intro
Connection Stream Type
Connection stream type is a built-in stream type which
allows any input port to be connected to any output port
Port types can be different
Variables are matched by name
Unmatched variables reported in Simulation Messages window
pr ocessi ng connect i on bet ween B1. out _p and B2. i n_f ,
t he f ol l owi ng var i abl es don' t mat ch
B1. out _p. y

93 2000 AspenTech. All Rights Reserved. ACM intro
Stream Types
A stream type has the characteristics of a model, except;
One input port and/or
One output port
Like a model, a stream type can have:
Equations and variables
Tables, Plots
94 2000 AspenTech. All Rights Reserved. ACM intro
Stream Equations
Stream variables
STREAM Fst r eam
F as f l ow_vol ;
I n_F as i nput Fpor t ;
Out _P as out put Fpor t ;
Out _P. F = I n_F. F;
F = I n_F. F;
END
95 2000 AspenTech. All Rights Reserved. ACM intro
Stream Properties
You can change the line style for the streams
Select stream type, then
click on right mouse button
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Additional details
98 2000 AspenTech. All Rights Reserved. ACM intro
Note about assignments with expressions
Example : parameter : expression
Assignments work in a similar way as a spreadsheet
does.
Defining dependencies between the parameters
Example: Ntotal : Ntop + Nbottom
If you change the value of a parameter, then the list of
dependencies is examined and assignments executed
Do not use variables on the right hand side of
assignments
99 2000 AspenTech. All Rights Reserved. ACM intro
What is Inheritance in ACM?
Add properties
or override default values
VARIABLE Fl owr at e
Physi cal Quant i t y : " kg/ hr " ;
upper : 10; l ower : 0;
END
VARIABLE Fl owr at e_bi g USES Fl owr at e
upper : 1000;
END
VARIABLE Real Var i abl e
/ / content as on previous slide
END
keyword for inheritance
inherits from the
generic type
uses
uses
100 2000 AspenTech. All Rights Reserved. ACM intro
Variable Declaration Qualifiers
Additional flags
HIDDEN : does not show the variable on Forms
GLOBAL : makes the scope of variable "global"
Tamb as GLOBAL t emper at ur e;
Pamb as GLOBAL pr essur e;
coef as HIDDEN r eal var i abl e;
101 2000 AspenTech. All Rights Reserved. ACM intro
The Global Qualifier
GLOBAL makes the variable global (i.e. defined once)
for the whole simulation
Global
Simulation
102 2000 AspenTech. All Rights Reserved. ACM intro
Compatibility of Ports
You can connect ports which are of the same type or if
the type of one port inherits from the other port type
See example "PortCompatibility.acmf"
103 2000 AspenTech. All Rights Reserved. ACM intro
Delay Function
Implements a delay function
It saves the past history and plays it back later, depending on
the dead time
time
x
y
td
dead
time
x, y as f r act i on;
deadt i me as t i me_;
y = DELAY x BY t d;
2000 AspenTech. All Rights Reserved.
Model Development Workshop
105 2000 AspenTech. All Rights Reserved. ACM intro
Model Development Workshop
Build a model for a non-isothermal CSTR reactor,
cooled with a jacket
Suggested approach
Decide how to implement the problem i.e. how many models
Create your own variable types
Keep it simple!
2000 AspenTech. All Rights Reserved.
Modeling Language: Sets and Arrays
107 2000 AspenTech. All Rights Reserved. ACM intro
Sets
Set (group of elements) can be:
INTEGERSET : integer elements
STRINGSET : character string elements
Usage, e.g.
Declaration for arrays
Iteration index for equations
Validation of entries (i.e. string parameter types)
Options for a model
108 2000 AspenTech. All Rights Reserved. ACM intro
Integer Sets
Declaration of an integerset called "MySet":

Assignment ":" of elements to the set:
Enumeration


Range operator ":"
increment is always 1
Declaration and assignment in one line:

MySet as integerset;
MySet : [ 3, 4, 5, 6] ;
MySet : [ 3: 6] ;
MySet as integerset ( [ 3: 6] ) ;
This is the range operator
109 2000 AspenTech. All Rights Reserved. ACM intro
Integer Sets
Integer parameters can be used to specify the bounds of
the set
The parameters can be changed in tables, and the set will be
re-assigned automatically

Fi r st as i nt eger par amet er ( 4) ;
Last as i nt eger par amet er ( 10) ;
MySet as integerset ( [ Fi r st : Last ] ) ;
110 2000 AspenTech. All Rights Reserved. ACM intro
String Set
Declaration of a stringset called "YourSet":

Assignment ":" of elements to the set:
Enumeration

There is no range operator for stringsets
Declaration and assignment in one line:

Your Set as stringset;
Your Set : [ " al pha" , " bet a" ] ;
Your Set as stringset ( [ " al pha" , " bet a" ] ) ;
111 2000 AspenTech. All Rights Reserved. ACM intro
Arrays
One or more sets can be used to define the index values
for an array
Array of variables, array of parameters




Accessing elements of the array: array(index)
N as i nt eger par amet er ( 10) ;
T( [ 1: N] ) as t emper at ur e; / / ar r ay of var s
w( [ 1: N] ) as r eal par amet er ;
T_i n = T( 1) ; / / j ust a f ew exampl es!
T_out = T( N) ;
T = w;
112 2000 AspenTech. All Rights Reserved. ACM intro
Arrays
String sets can also be used to dimension the arrays:
pona as stringset ( [ " par af f i n" , " ol ef i n" ,
" napht ene" , " ar omat i c" ] ) ;
anal ysi s( pona) as f r act i on;

/ / exampl e of accessi ng one el ement of t he ar r ay
r at e = 11. 04*exp( - 1966/ T) *anal ysi s( " ar omat i c" ) ^0. 34;
113 2000 AspenTech. All Rights Reserved. ACM intro
Multidimensional Arrays
You can declare multidimensional arrays
Example : 2D array
M as i nt eger par amet er ( 10) ;
N as i nt eger par amet er ( 3) ;
Mset as integerset ( [ 1: M] ) ;
Nset as integerset ( [ 1: N] ) ;
T( Mset , Nset ) as t emper at ur e;

T( 5, 2) = T( 1, 3) +T( 3, 1) ; / / j ust an exampl e!
114 2000 AspenTech. All Rights Reserved. ACM intro
Operations between sets
Union :
A + B or UNION(A,B)
- Example : 1,2,3,4,5,6
Intersection :
A*B or INTERSECTION(A,B)
- Example : 3,4
Differences :
A - B or DIFFERENCE(A,B)
- Example : 1,2
A \ B or SYMDIFF(A,B)
- Example : 1,2,5,6
A B
1
2
3
4
5
6
115 2000 AspenTech. All Rights Reserved. ACM intro
SIZE function
SIZE (set) returns the number of elements in the set
Example to initialize molefractions





ComponentList is the set of components
SIZE(ComponentList) returns the number of components
"x : value" assigns the same value to all the elements of the
array x
x( Component Li st ) as mol ef r act i on;

x : 1/ ( SIZE( Component Li st ) ) ;
116 2000 AspenTech. All Rights Reserved. ACM intro
SIGMA function
Sums up a list of variables:


The SIGMA command is interpreted as:


More typically, SIGMA is used to sum elements of
arrays:



x("N2") + x("O2") + x("CO2") = 1.0
A1, A2, A3, B1 AS Real Var i abl e;
B1 = SIGMA ( A1, A2, A3, 2. 0 ) ;
B1 = A1 + A2 + A3 + 2. 0;
Component s AS StringSet( [ " N2" , " O2" , " CO2" ] ) ;
x( Component s) AS Fr act i on;
SIGMA( x( Component s) ) = 1. 0;
117 2000 AspenTech. All Rights Reserved. ACM intro
SIGMA function
The following statement is equivalent to the previous
SIGMA expression (index slice is implicit):


You can use SIGMA on the whole array, or a selected
slice of an array:
SIGMA( x) = 1. 0 ;
nsect AS I nt eger Par amet er ( 10) ;
Sect i ons AS IntegerSet( [ 1: nsect ] ) ;
Tmean, Temp( Sect i ons) AS Temper at ur e;

Tmean = SIGMA( Temp( [ 2: nsect ] ) ) / ( nsect - 1) ;
118 2000 AspenTech. All Rights Reserved. ACM intro
SIGMA function
Operations between sets can be used to select the
elements of the array
Example:
Sum the fractions of all the components in a component list except for
water






The minus sign "-" in the expression above is the set
difference operator
Or gFr ac AS Fr act i on;
x( Component Li st ) AS Fr act i on;

Or gFr ac = SIGMA( x( Component Li st - [ " WATER" ] ) ) ;
119 2000 AspenTech. All Rights Reserved. ACM intro
FOREACH
Gives more control on the enumeration of the elements
of a set in SIGMA function
Example
Evaluate the sum of the diagonal elements of a matrix which is the sum
of A(1,1), A(2,2), A(3,3), ..., A(n,n)
n as i nt eger par amet er ( 3) ;
A( [ 1: n] , [ 1: n] ) as r eal var i abl e ( fixed) ;

s as r eal var i abl e;

s = sigma( foreach( i in [ 1: n] ) A( i , i ) ) ;
120 2000 AspenTech. All Rights Reserved. ACM intro
Functions of arrays
Functions working in a similar way to SIGMA and return
a scalar:
PRODUCT(x,y,...)
MIN(x, y, ...)
MAX(x, y, ...)
Note : FOREACH can be used in all of these
The other functions apply element by element and return
an array:
EXP(x), SIN(x), LOGE(x), LOG10(x), etc...
121 2000 AspenTech. All Rights Reserved. ACM intro
FOR...DO...ENDFOR
Syntax:




"set" can also be an operation between sets of the same
kind
No declaration required for the index variable
It exists only within the FOR loop
FOR indexname IN set DO
statements;
ENDFOR
122 2000 AspenTech. All Rights Reserved. ACM intro
FOR...DO...ENDFOR
Example to repeat the assignments:
n as i nt eger par amet er ;
posi t i on( [ 1: n] ) as r eal par amet er ;
dx as r eal par amet er ;

posi t i on( 1) : 0;
dx : 1/ n;
FOR i IN [ 2: n] DO
posi t i on( i ) : posi t i on( i - 1) + dx;
ENDFOR
position(1) position(i)
dx
position(n)
123 2000 AspenTech. All Rights Reserved. ACM intro
Arrays in equations
Example:






This is repeated over the intersection of the sets that
dimension the arrays, so this defines several equations
(3 in this example)
F, L, V as f l owr at e;
ns as integerset ( [ 1: 3] ) ;
z( ns) , x( ns) , y( ns) as f r act i on;
F*z = L*x + V*y;
124 2000 AspenTech. All Rights Reserved. ACM intro
Arrays in equations
Same equations with a FOR loop:
FOR i IN ns DO
F*z( i ) = L*x( i ) + V*y( i ) ;
ENDFOR
125 2000 AspenTech. All Rights Reserved. ACM intro
Equations With Implicit Slices
Example with different dimensions:
nsF as i nt eger set ( [ 1: 3] ) ;
z( nsF) as f r act i on;
ns as i nt eger set ( [ 1: 2] )
x( ns) , y( ns) as f r act i on;

F*z = L*x + V*y;
F*z( 1) = L*x( 1) + V*y( 1) ;
F*z( 2) = L*x( 2) + V*y( 2) ;
/ / F*z( 3) = ???
126 2000 AspenTech. All Rights Reserved. ACM intro
How to control of the repetition of equations?

Write explicitly the index slices, unless all array variables
in the equation have the same index
Example : x(ComponentList) instead of x
Expand your equations in FOR...ENDFOR loops
Unless your code is simple, this makes your intentions more
clear
127 2000 AspenTech. All Rights Reserved. ACM intro
Examples
Evaluation of a polynomial:
MODEL pol
n as i nt eger par amet er ( 3) ;
coef ( [ 0: n] ) as r eal var i abl e ( 0, f i xed) ;
x as r eal var i abl e ( f i xed) ;
y as r eal var i abl e;

y = si gma( f or each ( i i n [ 0: n] ) coef ( i ) *x^i ) ;
END
128 2000 AspenTech. All Rights Reserved. ACM intro
Two Dimensional Arrays - Matrix
Sum of two matrices with FOR loops:
MODEL Mat r i xModel 1
ms as i nt eger set ( [ 1: 2] ) ;
ns as i nt eger set ( [ 1: 3] ) ;
a( ms, ns) as r eal var i abl e ( FI XED) ;
b( ms, ns) as r eal var i abl e ( FI XED) ;
c( ms, ns) as r eal var i abl e;

f or i i n ms do
f or j i n ns do
c( i , j ) = a( i , j ) +b( i , j ) ;
endf or
endf or
END
129 2000 AspenTech. All Rights Reserved. ACM intro
Two Dimensional Arrays - Matrix
Sum of two matrices with implicit repeat:








- Repeats over intersection of first index on left hand side with first
index on right hand side, and repeats over intersection of second
index of lhs with second index on rhs, etc...
MODEL Mat r i xModel 2
ms as i nt eger set ( [ 1: 2] ) ;
ns as i nt eger set ( [ 1: 3] ) ;
a( ms, ns) as r eal var i abl e ( FI XED) ;
b( ms, ns) as r eal var i abl e ( FI XED) ;
c( ms, ns) as r eal var i abl e;
c = a + b;
END
130 2000 AspenTech. All Rights Reserved. ACM intro
Matrix Product
Definition:










SIGMA lists the elements of arrays a and b using the set
"ns", like the dummy index k in the definition
kj
k
ik ij
b a c

=
MODEL Mat r i xModel 3
ms as i nt eger set ( [ 1: 2] ) ;
ns as i nt eger set ( [ 1: 3] ) ;
ps as i nt eger set ( [ 1: 4] ) ;
a( ms, ns) as r eal var i abl e ( FI XED) ;
b( ns, ps) as r eal var i abl e ( FI XED) ;
c( ms, ps) as r eal var i abl e;

f or i i n ms do
f or j i n ps do
c( i , j ) = SI GMA( a( i , ns) *b( ns, j ) ) ;
endf or
endf or
END
131 2000 AspenTech. All Rights Reserved. ACM intro
String Parameter Type Syntax
The declaration requires a stringset




See example on next slide
PARAMETER ParameterTypeName USES STRI NGPARAMETER
Val i d AS STRINGSET( ValidList ) ;
Val ue : DefaultParameterValue ;
END
132 2000 AspenTech. All Rights Reserved. ACM intro
String Parameters and Sets
The property 'valid' defines the pull-down list in tables
PARAMETER Agi t at or Type USES STRI NGPARAMETER
val i d as stringset ( [ " paddl e" ,
" pi t ched bl ade t ur bi ne" ,
" di sk" , " pr opel l er " , " anchor " ,
" anchor - hi gh" ,
" hel i cal - r i bbon" ] ) ;
val ue : " paddl e" ; / / def aul t val ue
END
MODEL Mi xer
agi t at or as Agi t at or Type;
. . .
END
2000 AspenTech. All Rights Reserved.
Multiports
134 2000 AspenTech. All Rights Reserved. ACM intro
Multiports
To allow several streams to be connected at the same
port
To make a port property a multiport use the
"MULTIPORT OF" declaration qualifier
Por t Name AS I NPUT MULTIPORT OF Por t Type;
Por t Name AS OUTPUT MULTIPORT OF Por t Type;
135 2000 AspenTech. All Rights Reserved. ACM intro
Multiports
A multiport has 2 special properties
ConnectionSet : a set, containing the names of streams
connected to the port
Connection : an array of port type, one for each stream
connected to the multiport
Accessing the variables


Por t Name. connect i on( " st r eamname" ) . Var i abl eName
136 2000 AspenTech. All Rights Reserved. ACM intro
Typical FOR loop with Multiport
Accessing the variables of all the streams connected
FOR i I N PortName. connect i onset DO
PortName. connect i on( i) . VariableName = . . .
ENDFOR
137 2000 AspenTech. All Rights Reserved. ACM intro
Changes in a model to declare a multiport
Example to make In_F a multiport (before changes)
PORT Fpor t
F as f l ow_vol ;
END
MODEL t ank
I n_F as i nput Fpor t ;
Out _P as out put Fpor t ;
V as vol ume ( i ni t i al ) ;
/ / mat er i al bal ance
$V = I n_F.F - Out _P. F;
END
138 2000 AspenTech. All Rights Reserved. ACM intro
Changes in a model to declare a multiport
Example to make In_F a multiport (after changes)
MODEL mul t i t ank
I n_F as i nput MULTIPORT OF Fpor t ;
Out _P as out put Fpor t ;
V as vol ume ( i ni t i al ) ;
/ / mat er i al bal ance
$V = SI GMA( I n_F. connection.F) - Out _P. F;
END
139 2000 AspenTech. All Rights Reserved. ACM intro
Another Example
Steady state energy balances of a mixer:
I n_F as i nput mul t i por t of Mai nPor t ;
Out _P as out put mul t i por t of Mai nPor t ;
hmi x as ent h_mol ;

/ / out l et ent hal py def i ni t i on ( mi xi ng)
SI GMA( I n_F. connect i on. F) * hmi x =
SI GMA( I n_F. connect i on. F*I n_F. connect i on. h) ;
f or i i n Out _P. connect i onset do
Out _P. connect i on( i ) . h = hmi x;
endf or
hmix
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Tables and Plots
(Forms)
142 2000 AspenTech. All Rights Reserved. ACM intro
What is a Form?
Standard "Forms"
Table
Plots
Plot : time series
Profile Plot (i.e. temperature profile in a reactor bed, etc)
History Table
Customized forms
143 2000 AspenTech. All Rights Reserved. ACM intro
Forms can be created at different levels
Forms can be created
At the model level
All the model instances will get this form
At the flowsheet level (from the Tools menu)
Global table in Simulation (top level)
Shows global variables and parameters


144 2000 AspenTech. All Rights Reserved. ACM intro
Table Forms
Useful to show a selection of variables
Forms in models types and streams types
AllVariables table shows all active variables and all parameters
(automatic)
User defined
Forms in flowsheet
LocalVariables table shows all active variables in flowsheet constraints
User defined
145 2000 AspenTech. All Rights Reserved. ACM intro
Time Series Plot Form
Plot the values of the variables vs. time
Must create the plot before running the simulation in
order to record the variable history
Unless you change the run options dialog (Run/Run Options) to
record the history for all variables
Or set the record property to true for the required variables
Can be viewed as a History Table
Plot properties to change various display options
146 2000 AspenTech. All Rights Reserved. ACM intro
Profile Plots
Plots the values of an array
t_profile
Index
0 4 8 12 16 20 24 28 32 36 40 44 48 52
s
o
l
i
d

t
e
m
p
e
r
a
t
u
r
e

C

T
i
m
e
:

8
1
.
0
0
0
0
0
0
g
a
s

t
e
m
p
e
r
a
t
u
r
e

C

T
i
m
e
:

8
1
.
0
0
0
0
0
0
g
a
s

t
e
m
p
e
r
a
t
u
r
e
5
4
0
5
5
0
5
6
0
5
7
0
5
8
0
5
9
0
6
0
0
147 2000 AspenTech. All Rights Reserved. ACM intro
Creating a Profile Plot
Go to Tools/New Profile Plot or the button
Selection of variables to plot - no drag&drop, sorry!
Definition of Profile
Variables, using RMB
148 2000 AspenTech. All Rights Reserved. ACM intro
Creating a Profile Plot
Name for
the curve
Curve number - increase to
create other curves on the
same plot
Variable
to plot
* stands
for the
whole
array
Values for
the X axis
* stands
for the
whole
array
2000 AspenTech. All Rights Reserved.
Handling Components
150 2000 AspenTech. All Rights Reserved. ACM intro
Components Lists
Define the components and properties
With "external" physical property calculations
Using Properties Plus
Or using your own package
Without physical property calculations
J ust to define the name of the components

151 2000 AspenTech. All Rights Reserved. ACM intro
Components Lists
Have these components defined "globally" i.e. at the
simulation level
So that any port, stream and model can use it
To declare arrays
To call procedures
152 2000 AspenTech. All Rights Reserved. ACM intro
Component Lists
Component Lists in Simulation
"Default" component list



"ComponentList" property in
Flowsheet
Blocks
Streams
Ports
153 2000 AspenTech. All Rights Reserved. ACM intro
ComponentLists with physical properties
reference
"List" : with "external" physical properties
Set of the component names
(component set)
Selection of thermodynamic options
- E.g. Property Method specifications for Properties Plus


A reference to a properties definition file
Only one file can be selected
prop.appdf
010101010
101010101
010101010
101010101
"CH4"
"H2O"
154 2000 AspenTech. All Rights Reserved. ACM intro
Components list without reference to physical
properties
"Set" :
Set of component names
"SALT"
"PEPPER"
155 2000 AspenTech. All Rights Reserved. ACM intro
ComponentList with physical properties
BKP file
APW file APPDF file
Aspen Plus
Aspen Custom Modeler
Properties
ComponentList
Procedure
Parameter databanks
gpp.dll
010101010
101010101
111100001
010110110
"CH4"
"H2O"
156 2000 AspenTech. All Rights Reserved. ACM intro
Creation of the properties definition file
Start Aspen Plus GUI
Select the Properties Plus run type
Select the components and physical property methods
Run the simulation
Save the simulation as an Aspen Document
Extension apw
This creates the properties definition file (extension appdf) at
the same time
A+
157 2000 AspenTech. All Rights Reserved. ACM intro
Component List Setup
Back in ACM, double click on the Default component list
Its initial type is a 'List' (with properties)
158 2000 AspenTech. All Rights Reserved. ACM intro
Properties definition file selection
Select the APPDF file you want to use
159 2000 AspenTech. All Rights Reserved. ACM intro
Selection of the components
You can define as many components as you like in the
Aspen Plus file and use just a few in ACM
160 2000 AspenTech. All Rights Reserved. ACM intro
Physical properties settings
Settings:
See on-line help for definition and defaults
161 2000 AspenTech. All Rights Reserved. ACM intro
Property calculations using procedures
Procedures are in Modeler library
See on-line help for details
See procedure code comments




Example : molar enthalpy for liquid phase
/ / cal l t o a pr ocedur e
cal l ( out put l i st ) = pPr ocedur e_Name ( i nput l i st ) ;
cal l ( hl ) = pEnt h_mol _l i q( T, p, x) ;
162 2000 AspenTech. All Rights Reserved. ACM intro
Example of using the componentlist for a flash
calculation
MODEL Exampl eModel
T as t emper at ur e ( f i xed) ;
p as pr essur e ( f i xed) ;
vf as vapf r act i on;
hl as ent h_mol _l i q;
hv as ent h_mol _vap;
h as ent h_mol ;
z( Componentlist) as mol ef r act i on ( f i xed) ;
x( Componentlist) as mol ef r act i on;
y( Componentlist) as mol ef r act i on;

si gma( z) = 1;
h = vf *hv + ( 1- vf ) *hl ;
cal l ( y, x, vf , hv, hl ) = pFlash( T, p, z) ;
END
163 2000 AspenTech. All Rights Reserved. ACM intro
Example
Result of a steady state run
Liquid Vapor equilibrium
calculated using
Properties Plus, i.e. RK-
SOAVE property method,
for the given T, P and
global composition z
164 2000 AspenTech. All Rights Reserved. ACM intro
Physical Property Calculation
If the componentlist is not explicitly specified in the
procedure call, the built-in ComponentList is used
Example

cal l ( hl ) = pEnt h_mol _l i q( T, p, x) Out _P. Component l i st ;
165 2000 AspenTech. All Rights Reserved. ACM intro
Using Several Componentlists
Explicitly state the componentlist to use
MODEL Ht xModel
Cl_p1 as componentlistname;
Cl_p2 as componentlistname;

p1_i n as i nput Mai nPor t (ComponentList : Cl_p1);
p1_out as out put Mai nPor t (ComponentList : Cl_p1);
p2_i n as i nput Mai nPor t (ComponentList : Cl_p2);
p2_out as out put Mai nPor t (ComponentList : Cl_p2);


/ / pr oper t i es
cal l ( p1_out . h) = pent h_mol ( p1_out . T, p1_out . p, p1_out . z)
p1_out.ComponentList;
cal l ( p2_out . h) = pent h_mol ( p2_out . T, p2_out . p, p2_out . z)
p2_out.ComponentList;

END
166 2000 AspenTech. All Rights Reserved. ACM intro
Component Sets
No physical properties



The Component set can be used as stringset, but
defined globally (i.e. at the simulation level)
ComponentSet
"SALT"
"PEPPER"
167 2000 AspenTech. All Rights Reserved. ACM intro
Creating a Component Set
If you want to use the "Default" component list, you need
to convert it to a "set"
RMB


Double click on "Add Component list"
Check "Is Component Set" to create a component set (without
properties)
168 2000 AspenTech. All Rights Reserved. ACM intro
Component Sets
Enter the name of the components
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Modeling Language - Submodels
171 2000 AspenTech. All Rights Reserved. ACM intro
What is a sub model?
Declaration of an instance of a model within another
model or stream type
The result is that all the equations and variables of the
submodel are integrated in the model of stream type
Benefit : modular approach to modeling
172 2000 AspenTech. All Rights Reserved. ACM intro
Example for a distillation column model
Blocks and streams within the model
feed
distillate
residue
condenser
drum
stage(1)
reboiler
stage(2)
stage(3)
173 2000 AspenTech. All Rights Reserved. ACM intro
Syntax for the declaration the blocks
block_name AS model_name
MODEL si mpl edi st
nst ages as i nt eger par amet er ( 3) ;
f eedst age as i nt eger par amet er ( 2) ;
cnd as condenser ;
dr mas dr um;
r eb as r eboi l er ;
st age( [ 1: nst ages] ) as si mpl et r ay;

model
174 2000 AspenTech. All Rights Reserved. ACM intro
Syntax for the declaration of the port
connectivity
MODEL si mpl edi st
. . .
f eed as i nput pr ocesspor t ;
di st as out put pr ocesspor t ;
r ebo as out put pr ocesspor t ;

l i nk f eed and st age( f eedst age) . f eed;
l i nk di st and dr m. out 2;
l i nk r ebo and r eb. l i q_ou;
link ports of
same direction
LINK port AND block_name.port

175 2000 AspenTech. All Rights Reserved. ACM intro
Syntax for the internal streams
CONNECT block.output AND block2.input
CONNECT st age( 1) . vap_ou AND cnd. vap_i n;
CONNECT st age( 1) . l i q_ou AND st age( 2) . l i q_i n;
CONNECT st age( 1) . l i q_i n AND dr m. out 1;
CONNECT st age( 1) . vap_i n AND st age( 2) . vap_ou;
cnd
drm
stage(1)
stage(2)
vap_ou
vap_in
out1
vap_in liq_ou
liq_in
vap_ou liq_in
176 2000 AspenTech. All Rights Reserved. ACM intro
Connectivity of the stages
Complete code
/ / i nt er nal st r eams
connect st age( 1) . vap_ou and cnd. vap_i n;
connect cnd. l i q_ou and dr m. l i q_i n;
connect st age( 1) . l i q_i n and dr m. out 1;

f or i i n [ 2: nst ages] do
connect st age( i - 1) . l i q_ou and st age( i ) . l i q_i n;
connect st age( i - 1) . vap_i n and st age( i ) . vap_ou;
endf or

connect st age( nst ages) . l i q_ou and r eb. l i q_i n;
connect st age( nst ages) . vap_i n and r eb. vap_ou;

177 2000 AspenTech. All Rights Reserved. ACM intro
Submodel Variables
Accessing variables in submodels



This is equivalent to :
block as model ( submodel variable = model variable
submodel parameter : model parameter) ;
block as model; / / bl ock AS model
bl ock. var i abl e1 = var i abl e2;
bl ock. par amet er 3 : par amet er 4;
/ / some equat i on
$var i abl e5 = exp( - bl ock. var i abl e6/ Rgas/ T) ;
178 2000 AspenTech. All Rights Reserved. ACM intro
Note
The equations required to access the variables in the
submodels will be eliminated when using the
equivalencing option
Significantly decreases the size of the mathematical system to
be solved
179 2000 AspenTech. All Rights Reserved. ACM intro
Heat Exchanger example
Flow pattern (counter current)
1 2 3
3 2 1
Q
Q
Q
180 2000 AspenTech. All Rights Reserved. ACM intro
Heat Exchanger example
MODEL ht x
h_i n as i nput f t hcpPor t ;
h_out as out put f t hcpPor t ;
c_i n as i nput f t hcpPor t ;
c_out as out put f t hcpPor t ;

/ / model i ng a count er - cur r ent heat exchanger
n as i nt eger par amet er ( 3) ;
ns as i nt eger set ( [ 1: n] ) ;

h_cel l ( ns) as cel l ;
c_cel l ( ns) as cel l ;

// see next slides
. . .
181 2000 AspenTech. All Rights Reserved. ACM intro
Heat Exchanger example
MODEL ht x
. . .
/ / l i nki ng model por t s wi t h sub- model por t s
l i nk h_i n and h_cel l ( 1) . p_i n;
l i nk h_out and h_cel l ( n) . p_out ;

l i nk c_i n and c_cel l ( 1) . p_i n;
l i nk c_out and c_cel l ( n) . p_out ;
. . .
182 2000 AspenTech. All Rights Reserved. ACM intro
MODEL ht x
. . .
/ / i nt er nal heat st r eam
q_i nt er n ( ns) as QTAst r eam;
f or i i n ns do
connect h_cel l ( i ) . q_out and
c_cel l ( n- i +1) . q_i n
wi t h q_i nt er n( i ) ;
endf or
. . .
Heat Exchanger example
Internal heat streams using stream type "QTAstream"
183 2000 AspenTech. All Rights Reserved. ACM intro
. . .
/ / i nt er nal mat er i al st r eam
h_cel l _out ( ns - [ n] ) as f t hcpSt r eam;
f or i i n ns - [ n] do
connect h_cel l ( i ) . p_out and
h_cel l ( i +1) . p_i n wi t h h_cel l _out ( i ) ;
endf or
c_cel l _out ( ns - [ n] ) as f t hcpSt r eam;
f or i i n ns - [ n] do
connect c_cel l ( i ) . p_out and
c_cel l ( i +1) . p_i n wi t h c_cel l _out ( i ) ;
endf or
Heat Exchanger example
Internal material streams using stream type
"fthcpStream"
184 2000 AspenTech. All Rights Reserved. ACM intro
VIRTUAL and EXTERNAL

Model Aver ageVal ue
VIRTUAL ValueType USES Real Var i abl e;
NVal ues as external I nt eger Par amet er ;
Val ue( [ 1: NVal ues] ) as external Real Var i abl e;
Aver age as ValueType;
Aver age = si gma( Val ue) / NVal ues;
End
Model Pi pe
NSect i ons as i nt eger Par amet er ;
T( [ 1: NSect i ons] ) as Temper at ur e;
/ / Use submodel t o cal cul at e aver age
T_Av as Aver ageVal ue( NVal ues is NSect i ons, Val ue is T,
ValueType is Temper at ur e) ;
Q = U * Wal l Ar ea * ( T_Wal l - T_Av. Aver age) ;
End
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Snapshots and Results
187 2000 AspenTech. All Rights Reserved. ACM intro
Snapshots
What is in a snapshot?
The name of the variables, their value and their specification
Internal data (delay function workspace and procedure
workspace)
How to create a snapshot?
Created automatically at specific events
Initialisation, file saving, ...
At user specified intervals
Taken manually by user
188 2000 AspenTech. All Rights Reserved. ACM intro
Snapshots vs. results
Snapshots
Relative to the current simulation structure
Results are "archived" snapshots
Once you change the simulation structure, all snapshots
become results
Differences:
Results contain only variable values, not delay nor procedures'
workspaces
Results can not be used for rewind
189 2000 AspenTech. All Rights Reserved. ACM intro
Snapshot vs. kept results
Tools/Settings/Snapshot for options on automatic
handling
We can "mark" a snapshot so that it will be kept as a
result
(kept) results : saved in the acmf file
Snapshots : archived in the simulation server working directory
(*.snp)
190 2000 AspenTech. All Rights Reserved. ACM intro
What's the use of snapshots?
To restart a simulation
To time 0 for dynamic simulation (snapshot 'Dynamic
Initialization')
To rewind the simulation
To any timed snapshot
To copy values from other results

snapshot management
191 2000 AspenTech. All Rights Reserved. ACM intro
Rewind and Restart
Rewind lets you select the snapshot to which you want to
go
Restart returns a dynamic simulation to its solved initial
state
Uses the 'Dynamic Initialization' snapshot


Run Pause
Restart Rewind
Reset
Step
192 2000 AspenTech. All Rights Reserved. ACM intro
Copy Values and Advanced Copy
To copy variables from one result/snapshot to the
simulation
Wildcards for selection of variables
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Tasks
195 2000 AspenTech. All Rights Reserved. ACM intro
Tasks
Implement actions during the simulation
Change the value of some variables
Write messages
Suspend the simulation
Create a snapshot
196 2000 AspenTech. All Rights Reserved. ACM intro
Tasks
Types of tasks
Event-driven tasks
Callable tasks (parameterized)
Definition of tasks
In the flowsheet
In a model
In the library task folder (callable task only)
197 2000 AspenTech. All Rights Reserved. ACM intro
Task manager
Overall picture
Graphical User Interface
Simulation server
Task manager
create/remove tasks
activate/deactivate tasks
query variable
limit time step
change variable value
tasks
task status action
t k1 act i ve wai t
t k2 act i ve done
. . .
198 2000 AspenTech. All Rights Reserved. ACM intro
Event driven task
Syntax:







Condition:
time == value
expression1 >, <, ==, <>, >=, <= expression2
TASK TaskName RUNS WHEN Condi t i on
TaskSt at ement s;
END
TASK TaskName RUNS ONCE WHEN Condi t i on
TaskSt at ement s;
END
199 2000 AspenTech. All Rights Reserved. ACM intro
Event driven task
You need to activate the event driven tasks before
running the simulation
Flowsheet tasks
For tasks defined in the models, you need to activate them in
the blocks using these models
200 2000 AspenTech. All Rights Reserved. ACM intro
Tasks
Event-driven task status is checked at communication
intervals
Task executed whenever the condition becomes true
(i.e. changes from false to true)
t ask xmp r uns when l evel > l ev_al ar m
time
level
lev_alarm
201 2000 AspenTech. All Rights Reserved. ACM intro
Tasks
"ONCE" qualifier
t ask bur st i ng r uns once when p > p_bur st
time
p
p_burst
202 2000 AspenTech. All Rights Reserved. ACM intro
Task statements
Variable assignment (variable must be fixed!)
Direct
Ramping functions (RAMP and SRAMP)
TASK Task4 RUNS WHEN TI ME == 4. 0
/ / Fl ow changes t o 5. 0 l i near l y
/ / over a per i od of 2 t i me uni t s
RAMP ( I nput 1. f l ow, 5. 0, 2. 0, cont i nuous) ;

/ / Temper at ur e changes wi t h an S- shaped cur ve
/ / t o 15. 0 over a per i od of 3 t i me uni t s
SRAMP ( I nput 1. t emp, 15. 0, 3. 0) ;

I nput 2. Fl owX( " wat er " ) : 0;
END
203 2000 AspenTech. All Rights Reserved. ACM intro
Ramp statements syntax
Linear ramp discrete


Linear ramp continuous


Sine ramp discrete


Sine ramp continuous
RAMP ( var i abl e, f i nal val ue, dur at i on, di scr et e) ;
RAMP ( var i abl e, f i nal val ue, dur at i on, cont i nuous) ;
SRAMP ( var i abl e, f i nal val ue, dur at i on, di scr et e) ;
SRAMP ( var i abl e, f i nal val ue, dur at i on, cont i nuous) ;
204 2000 AspenTech. All Rights Reserved. ACM intro
Task statements are executed in sequential
order
4
time
15
5
6
0
9
first ramp
(continuous)
second ramp
(sramp)
step change
(assignment)
205 2000 AspenTech. All Rights Reserved. ACM intro
Task statements
Create a snapshot



Print a message
Pause the simulation
TASK Task2 RUNS WHEN Ti me == 10. 0
CREATE SNAPSHOT " Task- Cr eat ed Snapshot #1" ;
END
TASK Test 3 RUNS WHEN Ti me == 1. 0
PRI NT " St ar t Task Test 3" ;
RAMP ( I nput 1. Fl ow, 2. 5, 5. 0) ;
PRI NT " Task Test 3 Fi ni shed" ;
PAUSE;
END
206 2000 AspenTech. All Rights Reserved. ACM intro
Task execution : WAIT FOR and WAIT
WAIT FOR : To hold the task execution until condition is
satisfied:


WAIT : To hold task execution for a given period

WAI T FOR condi t i on;
/ / wai t f or 2 hour s f r omnow
WAI T 2. 0;
/ / st ar t f eed
S34. F : 400;
/ / wai t now f or 1 hour
WAI T 1. 0;
/ / st op t he f eed
S34. F : 0;
207 2000 AspenTech. All Rights Reserved. ACM intro
Task execution : RESTART WHEN
RESTART WHEN condition;
Example: $y = x - y

x
Time Hours
0 1 2 3 4 5 6 7 8 9 10
B
1
.
x

B
1
.
y

0
.
5
1
1
.
5
2
2
.
5
3
3
.
5
4
Task r es r uns when t i me == 1
/ / st ep change of x
B1. x : 4;
/ / wai t 2 uni t s of t i me
wai t 2;
B1. x : 0;
r est ar t when B1. y < 1;
End
RESTART makes the task execution jump
back to the first line
208 2000 AspenTech. All Rights Reserved. ACM intro
Callable task
Syntax




Call
TASK TaskName ( Par amet er Li st )
TaskSt at ement s
end
CALL TaskName ( Par amet er Li st ) ;
209 2000 AspenTech. All Rights Reserved. ACM intro
Callable task example
Flowsheet tasks:
Task dor eci pe r uns when t i me == 0. 5
f i nal _x as r eal par amet er ;
f i nal _x : 10;
cal l r eci pe ( f i nal _x) ;
End
pt
Time Hours
0 1 2 3 4 5 6 7 8
B
1
.
y

B
1
.
x
1

5
1
0
1
5
Task r eci pe ( x as r eal par amet er )
B1. x : 3;
wai t f or t i me == 1;
B1. x : x;
End
210 2000 AspenTech. All Rights Reserved. ACM intro
Task execution : PARALLEL
PARALLEL
Each action is executed until it completes
The parallel section completes when all actions in it are
complete.
TASK Task1 RUNS WHEN TI ME == 1. 25
PARALLEL
CALL P1; / / a r amp wi t h dur at i on=2
CALL P2; / / anot her r amp wi t h dur at i on=1
ENDPARALLEL;
I nput 4. Fl ow : 0. 0;
END
211 2000 AspenTech. All Rights Reserved. ACM intro
Task notes
Values must be expressed in their base units of
measurement
Snapshots taken when a ramp is running will be flagged
as "Modified"
Only fixed variables can be ramped
An event-driven task must be activated
Inactive
Active
212 2000 AspenTech. All Rights Reserved. ACM intro
Task notes
Task state is checked at communication interval for all
methods, except Gear and time-based conditions
communication interval
task action
event
WAIT FOR x >3
x
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Procedures
215 2000 AspenTech. All Rights Reserved. ACM intro
What is a procedure?
An alternative way of performing calculations during the
simulation resolution
External code is called by ACM
Variables and Parameters as input
External code is executed
Results (output variables) returned to ACM
External code is in a Dynamic Link Library
DLL is the file extension in Windows

216 2000 AspenTech. All Rights Reserved. ACM intro
What is required to create new procedures?
A compiler:
Digital Visual Fortran
Visual C++
Do I need to know one of these languages to create new
procedures?
Yes!
217 2000 AspenTech. All Rights Reserved. ACM intro
Do you require a compiler to call procedures?
No!
Modeler library
Physical property and kinetics calculations
utility calculations for control models
Procedures created by your colleagues
To use (i.e. call) a procedure you just need the Dynamic Link
Library which contains the machine code (binary)
218 2000 AspenTech. All Rights Reserved. ACM intro
DLLs distribution and installation
Once it is built, ACM needs only the DLL, not the source
code
You can distribute the DLL without having to give out the
source code
Where to install the DLL
Give full path in the PROCEDURE definition
Or put the DLL in a directory that is listed in the command
PATH
Or in the working directory

219 2000 AspenTech. All Rights Reserved. ACM intro
Steps for creating a Procedure
Step 1 : Define the Procedure
this is done in ACM
Step 2 : Write/adapt the source code
use your favorite editor
Step 3 : Build the DLL library
ACM generates the required commands
to compile the source code
to link the objects and libraries with the linker
220 2000 AspenTech. All Rights Reserved. ACM intro
Step 1 - PROCEDURE Definition
Name of the procedure
Name of the subroutine to call
the path of the source file
List of input variable types
List of output variable types
Name of the DLL
Various options
221 2000 AspenTech. All Rights Reserved. ACM intro
Step 2 - Writing the Code
Arguments depend on the procedure definition
use the template generation to have ACM give you the correct
list of arguments:

input variables
output variables
additional arguments for communication with ACM

arrays: the dimensions are passed as integer after the array
itself
Double precision calculations
222 2000 AspenTech. All Rights Reserved. ACM intro
Step 3 - Generate Procedure Code
under Tools/Generate Procedure Code
Check to generate
template subroutine
Check to generate
command file to
build the DLLs
Working directory for
wrappers and Makefile
Debug : Check to get input and output arguments
printing lines added to any templates or wrappers that
are generated, and debug option for the compilation
Check to execute the
command file to
build the DLLs
223 2000 AspenTech. All Rights Reserved. ACM intro
Step 3 - Execute Makefile : Compilation of
source code and DLL build
"Make" command is invoked by ACM
compiles the source code
your routines
the wrappers
build the DLL
link the object files and
ACM support libraries
Result : the DLL
copy it in a directory in your PATH
unless specified in procedure definition

remember about Windows Explorer option to view/hide DLL
compile
source
object
link
DLL
224 2000 AspenTech. All Rights Reserved. ACM intro
Calling the Procedure in Your Models
Syntax:


cal l ( output arguments) =
ProcedureName ( input arguments) ;
225 2000 AspenTech. All Rights Reserved. ACM intro
Note about rebuilding the DLL
After a run, the DLLs remain locked by ACM and are
"read-only"
Run/Unload User's DLLs to unload the DLLs before you
can rebuild them

Check the DLLs you wish
to unload (i.e. to rebuild them)
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Scripts
228 2000 AspenTech. All Rights Reserved. ACM intro
Scripts
Scripts are Microsoft VBScripts (version 2)
invoked in Aspen Custom Modeler
created in the Flowsheet folder
created in the Models
- every block or stream using the model will have the script available to
them
invoked in another application
a macro in a spreadsheet
Visual Basic program (standalone application)
229 2000 AspenTech. All Rights Reserved. ACM intro
Scripts
Automatic creation of scripts
variable find
specification status check
230 2000 AspenTech. All Rights Reserved. ACM intro
Scripts
Syntax for variable assignments:
In the flowsheet:
- BlockName.VariableName.Property = Value
In models:
- VariableName.Property = value
Example
B1.Temp.Value = 550.0
B1.Temp.Spec = "Fixed"
B1.X("CO2").Value = 0.03
B1.X("CO2").Upper = 0.1
231 2000 AspenTech. All Rights Reserved. ACM intro
Blocks and Streams
Recommended syntax to access variables in blocks and
streams
BLOCKS("blockname").variable
STREAMS("streamname").variable
Example
assuming we have a stream and a block called FEED
Streams("FEED").Temp.Value = 550.0
Streams("FEED").Temp.Spec = "Free"
Blocks("FEED").P_drop.Spec = "Free"

232 2000 AspenTech. All Rights Reserved. ACM intro
Example of a Flowsheet Script
Script 'example' is changing the value of A in block "B3"
and stream "S6"
233 2000 AspenTech. All Rights Reserved. ACM intro
Flowsheet Script
Invoke script
234 2000 AspenTech. All Rights Reserved. ACM intro
Creating a Script With Variable Find
Script with current values and specification
Select the variables to put on the script
235 2000 AspenTech. All Rights Reserved. ACM intro
Specification Status to Create a Script
Script with all changes from models' defaults
236 2000 AspenTech. All Rights Reserved. ACM intro
Model and Stream Type Scripts
Created at the model/stream type level
Invoked from the block or stream using the model/stream
type
Variable path does not refer to object name
Example to write a message
' vi sual basi c scr i pt
i f ( p1_ou. T. val ue > p1_i n. T. val ue) t hen
MsgBox( " heat i ng st r eam1" )
el se
MsgBox( " cool i ng st r eam1" )
end i f
237 2000 AspenTech. All Rights Reserved. ACM intro
Visual Basic Scripting
Some more advanced VB Script features
Call another script
Execute Automation Methods
Visit on-line help (Automation) for more details



238 2000 AspenTech. All Rights Reserved. ACM intro
Calling Scripts
Calling a script from a script
flowsheet script to flowsheet script
model script to same model script




flowsheet script calling a model script





scr i pt name
bl ockname. scr i pt name
bl ockname. i nvoke( " scr i pt name" )
i nvoke( " scr i pt name" )
239 2000 AspenTech. All Rights Reserved. ACM intro
Execute Automation Methods
Example
B2. V. val ue = 15
' set s t he r un mode
Appl i cat i on. Si mul at i on. RunMode = " Dynami c"
' set s t he end t i me
Appl i cat i on. Si mul at i on. EndTi me = 13
' st ar t s t he si mul at i on
Appl i cat i on. Si mul at i on. Run( t r ue)
240 2000 AspenTech. All Rights Reserved. ACM intro
Write to Simulation Messages Window
Example
Appl i cat i on. Msg " Hel l o Wor l d"
Appl i cat i on. Msg Appl i cat i on. Si mul at i on. RunMode
Appl i cat i on. Msg " Run Mode i s " & _
Appl i cat i on. Si mul at i on. RunMode
Appl i cat i on. Msg " Run compl et e at t i me " & Ti me
241 2000 AspenTech. All Rights Reserved. ACM intro
For Loop in a Script
Example
di mi

f or i = 1 t o Bed. Nel ement s. value
Bed. Tg( I ) . spec = " i ni t i al "
Bed. Tg( I ) . value = 600
Bed. Ts( I ) . spec = " i ni t i al "
Bed. Ts( I ) . value = 600
next
Don't forget the
property,
e.g. value...
242 2000 AspenTech. All Rights Reserved. ACM intro
Visual Basic Scripting
Scripts are not time based
Can change structure of the simulation
Invoked manually, by other scripts or by external VB
For time based changes, use Tasks
Visual Basic Scripting includes extensive features in its
language
2000 AspenTech. All Rights Reserved.
Scripting Workshop
2000 AspenTech. All Rights Reserved.
Automation
Visual Basic interface
245 2000 AspenTech. All Rights Reserved. ACM intro
Example : Sensitivity analysis
Run the simulation for various values of a specification
and tabulate the results in Excel
Demonstration
Load the "Reactions.xls" file
Click on the "Open Simulation" button
Click on the "Run" button
Change the value of the reaction constants
Click on the "Run" button again
Explanation
Look at the Macro code


246 2000 AspenTech. All Rights Reserved. ACM intro
Guided example
How to link ACM and Excel
How to set some values from Excel to ACM
How to run the simulation
How to get back the results in Excel
247 2000 AspenTech. All Rights Reserved. ACM intro
Create a macro in Excel
Start Excel
Go to Tools/Macros and select Visual Basic Editor
Double click on Sheet1
This is where we'll enter the code for our Visual Basic program
Type the following code: Sub FirstExample
Sub Fi r st Exampl e( )

End Sub
248 2000 AspenTech. All Rights Reserved. ACM intro
Start ACM from Excel
GetObject returns an object which is the ACM
application, with the simulation that we have selected
Sub Fi r st Exampl e( )
Dim objACM
Set objACM = GetObject("c:\Course\Example.acmf")
End
Declare the variable "objACM"
the name of the the simulation
we want to use
Don't forget the "Set"
249 2000 AspenTech. All Rights Reserved. ACM intro
Make ACM visible
objACM is the ACM object
objACM.Application is the Application object in the ACM
object
Add the line to make ACM visible (by default ACM starts
"invisible")
Sub Fi r st Exampl e( )
Di mobj ACM
Set obj ACM = Get Obj ect ( " c: \ cour se\ Exampl e. acmf " )
objACM.Application.Visible = True

End Sub
250 2000 AspenTech. All Rights Reserved. ACM intro
Copy some values from Excel to ACM
Make x in B1 fixed
Copy the value from cell on row 1, column 2 to x in the
block B1
Sub Fi r st Exampl e( )
Di mobj ACM
Set obj ACM = Get Obj ect ( " c: \ cour se\ Exampl e. acmf " )
obj ACM. Appl i cat i on. Vi si bl e = Tr ue
objACM.flowsheet.B1.x.Spec = "fixed"
objACM.flowsheet.B1.x.Value = _
Sheet1.Cells(1, 2).Value
End Sub
Underscore is the continuation
character in Visual Basic
251 2000 AspenTech. All Rights Reserved. ACM intro
Run the simulation
Run(True) completes the simulation run before giving
back the control to Excel
Sub Fi r st Exampl e( )
Di mobj ACM
Set obj ACM = Get Obj ect ( " c: \ cour se\ Exampl e. acmf " )
obj ACM. Appl i cat i on. Vi si bl e = Tr ue
obj ACM. f l owsheet . B1. x. Spec = " f i xed"
obj ACM. f l owsheet . B1. x. Val ue = _
Sheet 1. Cel l s( 1, 2) . Val ue
objACM.Application.Simulation.Run (True)
End Sub
252 2000 AspenTech. All Rights Reserved. ACM intro
Get some values from ACM to Excel
Copy the value of y in B1 into the cell on row 2, in
column 2
Sub Fi r st Exampl e( )
Di mobj ACM
Set obj ACM = Get Obj ect ( " c: \ cour se\ Exampl e. acmf " )
obj ACM. Appl i cat i on. Vi si bl e = Tr ue
obj ACM. f l owsheet . B1. x. Spec = " f i xed"
obj ACM. f l owsheet . B1. x. Val ue = _
Sheet 1. Cel l s( 1, 2) . Val ue
obj ACM. Appl i cat i on. Si mul at i on. Run ( Tr ue)
Sheet1.Cells(2, 2).Value = _
objACM.flowsheet.B1.y.Value
End Sub
253 2000 AspenTech. All Rights Reserved. ACM intro
Run the example
Go back to Excel (save your file)
Go to Tools/Macro and select Sheet1.FirstExample
shortcut : alt-F8
Run
254 2000 AspenTech. All Rights Reserved. ACM intro
Adding a command button
In Excel, go to View/Toolbars and select the Control
Toolbox toolbar




Design
mode
Command button
255 2000 AspenTech. All Rights Reserved. ACM intro
Adding a command button
Enter in design mode (click on Design mode button)
Create a button
click on Command button
draw the button
256 2000 AspenTech. All Rights Reserved. ACM intro
Properties for the button
Click on the button, then RMB and select Properties
change the name
cmdExample
change the BackColor
any color you like
change the Caption
Run Example
257 2000 AspenTech. All Rights Reserved. ACM intro
Code executed when you click on button
Select the button, RMB, View Code



Quit design mode
Click on button
to run
Pr i vat e Sub cmdExampl e_Cl i ck( )
Call FirstExample
End Sub
258 2000 AspenTech. All Rights Reserved. ACM intro
Exposed tree
Go to the on-line help, Automation Reference,
Automation methods and properties in the Aspen
Custom Modeler help
Tips:
try your examples in a script in ACM
to use the same statements in an external Visual Basic code,
just add the name of the object in front of the ones you used in
the ACM script (CreateObject or GetObject)
2000 AspenTech. All Rights Reserved.
Units of Measurement
260 2000 AspenTech. All Rights Reserved. ACM intro
Units of Measurement
Selection in Tools/Units of Measurement
selects the units for input/output in the variable tables
Models must be written in the base units
PhysicalQuantity property when declaring variable type

261 2000 AspenTech. All Rights Reserved. ACM intro
Units of Measurement
Unit conversions are defined using scripting language
Default unit sets are defined in OnNewDocumentScript.vb
(located in \Program Files\AspenTech\AMsystem 10.2\Bin)
262 2000 AspenTech. All Rights Reserved. ACM intro
Units of Measurement
UOM : Units of Measurement
PhysicalQuantity
base units
alternative units and conversion
for writing the models (base units)
UOM set
selection of the units of measurement for the different
PhysicalQuantities
for displaying the values (input/output)
263 2000 AspenTech. All Rights Reserved. ACM intro
Units of Measurement
Alternative Units Factor Offset
F 0.56 -17.78
K 1 -273.15
UOM set PhysicalQuantity Units for Display
Metric Temperature C
Eng Temperature F
SI Temperature K
PhysicalQuantity Base Units
Temperature C
UOM set
Metric
Eng
SI
ActiveDocument.UOM
AddPhysicalQuantity
DefinePhysicalConversion
AddUOMSet
DefaultDisplayUOM
PhysicalQuantity
UOMsets
Value in base units =
FACTOR * value in alt units +OFFSET
2000 AspenTech. All Rights Reserved.
Partial Differential Equations
265 2000 AspenTech. All Rights Reserved. ACM intro
PDE Modeling Overview
Capabilities
1, 2, and 3 spatial dimensions
Rectangular and polar coordinates
Linear and nonlinear PDEs
1st and 2nd-order spatial derivatives
Domain and distribution sub-models
Method of Lines (MOL) for space discretization
Finite Differences
Orthogonal Collocation on Finite Elements
266 2000 AspenTech. All Rights Reserved. ACM intro
PDAEs
DAES Solution
Phase 1
Discretization of
Spatial Domains
Phase 2
Integration
Over Time
PDE Modeling Solution Method
Method of Lines (MOL)
Phase 1: Discretize PDEs
Finite Differences
Orthogonal Collocation on Finite Elements (OCFE)
Phase 2: Integrate DAEs
267 2000 AspenTech. All Rights Reserved. ACM intro
Easier Formulation of PDE Models
Extensive information in on-line help:
Modeling, Modeling Language Reference, Modeling PDE
systems
268 2000 AspenTech. All Rights Reserved. ACM intro
Steps for the formulation of a model
Create a model
Declare one or more domains
Declare distribution(s)
Write PDEs over the domain
Write boundary conditions
Write initial conditions for dynamics
269 2000 AspenTech. All Rights Reserved. ACM intro
Domain Sub-Model
Defines one-dimensional space over which variables
are distributed
Example: Axis of tubular reactor
Contains discretization method, order of
approximation, domain length, and element spacing
Built-in Domain types:
Domain
LengthDomain
AngleDomain
270 2000 AspenTech. All Rights Reserved. ACM intro
Declaring Domains
For each domain, you can specify the following
properties:
discretization method
highest order derivative
domain length
element spacing preference
number of sections
section location and spacing

271 2000 AspenTech. All Rights Reserved. ACM intro
Declaring Domain Sections
Uniform spacing within a given section
Multiple sections for handling sharp fronts
Different spacing allowed in each section
Example with two sections
Length
Left-Hand Right-Hand
Domain Element Domain
Boundary Spacing Element Boundaries Boundary
Value[0] Value[EndNode]
Section(1).Location Section(2).Location
X AS Lengt hDomai n ( Lengt h: 16. 0, NumSect i ons: 2,
Spaci ngPr ef er ence: 1. 0, Sect i on( 2) . Locat i on: 8. 0,
Sect i on( 2) . Spaci ngPr ef er ence: 0. 5) ;
272 2000 AspenTech. All Rights Reserved. ACM intro
Di st r i but i on (Set , Set, ...) AS
Di st r i but i onModel (DomainSubModel IS Domain, ... ,
Property : PropertyValue, ...)
OF VariableType;
Distribution Name you give to this distribution.
DistributionModel Name of a built-in distribution model
(Distribution1D, Distribution2D, or
Distribution3D).
DomainSubModel Name of a built-in domain.
Domain Name you give to this domain.
VariableType Name of a defined variable type.
Declaring Distributions
Syntax:

273 2000 AspenTech. All Rights Reserved. ACM intro
Declaring Distributions
For each distribution, you can specify the following
properties:
highest order derivative for a specific domain in the distribution
HighestOrder*Derivative
- where * is X, Y, or Z
Example
T AS Di st r i but i on2D( XDomai n I S Axi al , YDomai n I S Radi al ,
Hi ghest Or der XDer i vat i ve: 2,
Hi ghest Or der YDer i vat i ve: 2)
of Temper at ur e;
274 2000 AspenTech. All Rights Reserved. ACM intro
Writing PDEs in Models
Use the Interior set for writing model equations
defined automatically in domain model
Access partial derivatives:
ddx, ddy, ddz for first order
d2dx2, d2dy2, d2dz2 for second order
275 2000 AspenTech. All Rights Reserved. ACM intro
Advection equation for flow in a tube





Fouriers second law for heat conduction

T
t
V
T
x
$Temp( Axi s. I nt er i or + Axi s. EndNode) =
- v*Temp( Axi s. I nt er i or + Axi s. EndNode) . ddx;
$T( X. I nt er i or ) = k/ ( r ho*cp) *T( X. I nt er i or ) . d2dx2;
2
2
.
. x
T
c
k
t
T
p

Examples of PDEs in Models


276 2000 AspenTech. All Rights Reserved. ACM intro
Write initial conditions using the Interior set


Write boundary conditions using an explicit list of
contiguous nodes
Dirichlet


Neumann
/ / exampl e of st eady st at e i ni t i al condi t i on
T( X. I nt er i or , Y. I nt er i or ) : Rat eI ni t i al ;
/ / Neumann condi t i ons
T( [ 1: X. EndNode- 1] , 0) . ddy = 0. ;
/ / boundar y condi t i ons Di r i chl et t ype
T( X. EndNot e, [ 0: Y. EndNode] ) = 300. ;
Writing Auxiliary Conditions (2nd order PDE)
277 2000 AspenTech. All Rights Reserved. ACM intro
Example: Heat Transfer between a gas and a
porous bed
heat balance and heat transfer equations:






model in the file PDE.acmf

) ( _
) ( _
s g
s
s g
g g
T T const S
t
T
T T const G
z
T
e
V
t
T
=

2000 AspenTech. All Rights Reserved.


Workshop
2000 AspenTech. All Rights Reserved.
Estimation
Demonstration (using the examples) of
estimation capabilities
280 2000 AspenTech. All Rights Reserved. ACM intro
What is Estimation?
Estimation is used when a model is required to be fitted
to a set of experimental/actual process data
The model is fitted by finding the appropriate values for
the adjustable parameters
Models : as in other run types
Experimental data : defined via GUI or scripting
Regressed Parameters : selected via GUI or scripting
281 2000 AspenTech. All Rights Reserved. ACM intro
How to define an estimation problem?
Main steps:
Step 1 : Selection of variables
Step 2 : Definition of experimental data
Step 3 : Running the estimation case
Step 4 : Reviewing the results
Step 5 : Saving the estimation scenario
More information in on-line help under "Improving your
simulations, Using Estimation" and in the solver options
282 2000 AspenTech. All Rights Reserved. ACM intro
r = k
0
.e
-E/RT
.C
A
a
dC
A
/dt = -r
dC
B
/dt = r
Experi mental Data (i e Exp #1)
Initial concentration of A = ...
Temperature = ...
Time CA CB
... ... ...
... ... ...
... ... ...
A B
r
Illustration example
We want to estimate k
0
for the reaction data below
283 2000 AspenTech. All Rights Reserved. ACM intro
0
0.2
0.4
0.6
0.8
1
1.2
0 2 4 6 8 10 12
ti me
C
o
n
c
e
n
t
r
a
t
i
o
n
Ca
Ti me Ca
Hours kmol/m3
0 1
1 0.76
2 0.48
3 0.42
4 0.32
5 0.25
6 0.14
7 0.09
8 0.12
9 0.1
10 0.004
Experimental data
284 2000 AspenTech. All Rights Reserved. ACM intro
Results for the example
k0 = 9.74 (deviation 0.39)
Estimation: Measured Variable - DynamicExp_1
Time: Hours
R
c
t
.
C
a

k
m
o
l
/
m
3
0 1 2 3 4 5 6 7 8 9 10
0
.
2
5
0
.
5
0
.
7
5
1
Observed
Predicted
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Sensitivity calculation
Useful before estimation, to study the
influence of the variables for steady state and
dynamic models
287 2000 AspenTech. All Rights Reserved. ACM intro
Sensitivity calculation
The sensitivity s is the partial derivative of a calculated
variable y with respect to a fixed variable




Available in the following run modes:
Steady state
Initialization
Dynamic (at final time)
Defined using scripts
|
|
.
|

\
|

=
j
i
ij
y
s

288 2000 AspenTech. All Rights Reserved. ACM intro


Definition of a sensitivity run
Summary
Di mSi m
Set Si m= Appl i cat i on. Si mul at i on
Si m. ClearSensitivities
Si m. EnableSensitivities
Si m. AddSensitivityParameter " Cst . k0" ' f i xed var.
Si m. AddSensitivityVariable " Cst . Ca" ' free
' Run t he si mul at i on
Si m. RunMode = " Dynami c"
Si m. Run( Tr ue)
' Get t he r esul t s free f i xed
Sens1 = Si m. GetSensitivityValue( " Rct . Ca" , " Rct . k0" )
Si m. DisableSensitivities
2000 AspenTech. All Rights Reserved.
Optimization
(option)
Demonstration (using the examples) of ACM
optimization capabilities
290 2000 AspenTech. All Rights Reserved. ACM intro
About Dynamic Optimization
To perform a dynamic optimization, you must specify:
At least one objective variable
Whether the final time is Fixed or Free
At least one variable that is either a decision, initial, or control
variable
You can also optionally specify:
Additional equality and inequality constraints
A maximum move value for control variables
291 2000 AspenTech. All Rights Reserved. ACM intro
Value1
Time
Value2
Value3
Control
variable
Element1 Element2 Element3
Value1
Time
Value2
Value3
Element1 Element2 Element3
Value 4
Value 5
Element 4
Dynamic Optimization
Profile for the control variables
Piece-wise constant
Piece-wise linear
2000 AspenTech. All Rights Reserved.
Solution Methods (optional)
293 2000 AspenTech. All Rights Reserved. ACM intro
Steady State Solution Methods
Key concepts
Linear systems
Non linear systems
Group decomposition
294 2000 AspenTech. All Rights Reserved. ACM intro
Linear System
A linear system is a system in which all the constraints
are linear equalities
Linear systems can be small or large
n = system dimension
Full storage space would require n
2
elements for storage
a sparse method is used as many elements of the matrix are
zero (MA28 and MA48 : direct sparse matrix methods)
no change recommended
295 2000 AspenTech. All Rights Reserved. ACM intro
Non-Linear System
Base methods
Newton: Newton, Fast Newton and Hybrid
J acobian calculation and update policy
Dog-Leg method
can improve robustness of convergence for poor initial guesses
296 2000 AspenTech. All Rights Reserved. ACM intro
Non-Linear System
J acobian calculation
"analytical" : evaluation of the derivatives by analytical
differentiation of the equations
"numerical" : using step disturbances on the variables to
evaluate the derivatives (inaccurate and slow, but the only
method for procedures and some expressions)

297 2000 AspenTech. All Rights Reserved. ACM intro
Important Options
In the solver non-linear tab
Diagnostic
Use Highest residuals and highest variables steps to try to
identify the convergence problem
General
Convergence criterion (try residual and variable if solution does
not look right)
variable and equation scaling
example: 1E-6*(x - y) = 0 vs. x-y = 0


298 2000 AspenTech. All Rights Reserved. ACM intro
Group Decomposition
Improves robustness and speed
Example on next slide
Groups
Explicit
Linear
Non-linear
Analytical
Numerical
Torn group : subdecomposition
299 2000 AspenTech. All Rights Reserved. ACM intro
Example of group decomposition with
procedure tearing
tearing off
tearing on
torn group
300 2000 AspenTech. All Rights Reserved. ACM intro
Another Example
Model code:
MODEL m1
x1, x2, x3, x4, x5 as r eal var i abl e;

x1 : 1, f i xed;
x2 : 2. 71;
x3 : 7. 3441;
x4 : 8. 3441;
x5 : 10. 3;

eq1: x2 / exp( x1) = 1;

eq2: x4 = x2^2 + x3;
eq3: 5*x4 + 3*x3 = 44. 72;

eq4: x5 = x1 + x3 + x4;
END
301 2000 AspenTech. All Rights Reserved. ACM intro
Group Decomposition Example
Group decomposition with x1 fixed : 3 groups
solving eq1, we find x2
solving both eq2 and eq3, we find x3 and x4
solving eq4, we find x5
problem solved
302 2000 AspenTech. All Rights Reserved. ACM intro
Group Decomposition Example
Same system with x5 fixed instead of x1 : 1 group
we need to solve all the equations in one group
303 2000 AspenTech. All Rights Reserved. ACM intro
Group Decomposition
See next slide for explanation
X F B
=
1 1 1
1 1 1
1 1 1
torn procedure
2
3
T
4
2
2
2
3
3
3
T
T T
T T
T T
4 4
4 4 4
4 4 4
Xa
Xb
Xc
Xd
Xe
Xf
Xg
Xh
Xi
Xj
Xk
Xl
304 2000 AspenTech. All Rights Reserved. ACM intro
Group Decomposition
Solve group 1 : gives Xa, Xb, Xc
Call torn procedure with current variable values
(Xh, Xi) = pProc (Xd, Xe, Xf, Xg) TEAR
output variables Xh and Xi are temporarily fixed
solve subgroup 2
solve subgroup 3
call procedure again
compare new output variables Xh and Xi to previous
values
if difference larger than tolerance - repeat with new Xh
and Xi
Solve group 4
Note : loop only for initialization and steady state runs

305 2000 AspenTech. All Rights Reserved. ACM intro
Variable Equivalencing
Applied before group decomposition
Idea : x = y then replace every occurrence of x with y
or every occurrence of y with x
see help for decision rules
ideally initial values should be identical
Cause convergence path to be different
try turning it off if you suspect the equivalence to cause the
problem
equivalence tolerance
2000 AspenTech. All Rights Reserved.
Integration Methods (optional)
307 2000 AspenTech. All Rights Reserved. ACM intro
Integration Methods
Aspen Custom Modeler integration methods
explicit methods

(Explicit) Euler
Runge Kutta

implicit methods

Implicit fixed step Euler
Variable step implicit Euler (VSIE)
Gear
308 2000 AspenTech. All Rights Reserved. ACM intro
Key Concepts
Numerical
stability
type of method : implicit or explicit
limit on step size
accuracy
error control for variable step size and order
event detection and handling (Gear only)
309 2000 AspenTech. All Rights Reserved. ACM intro
Key Concepts
User's point of view
Which method to use
Which solver options to change
What to do if the integration fails
310 2000 AspenTech. All Rights Reserved. ACM intro
Explicit and Implicit Methods
Explicit method
Example : Explicit Euler



Implicit method
Example : Implicit Euler
h
dt
t dy
t y h t y
) (
) ( ) ( + = +
h
dt
h t dy
t y h t y
) (
) ( ) (
+
+ = +
"now",
already known
"future",
being calculated
311 2000 AspenTech. All Rights Reserved. ACM intro
Stability : explicit methods are unstable if the
step size is too large
compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y
_
a
n
a


y


0
.
5

1

compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y
_
a
n
a


y


-
1
0

0

1
0

2
0

3
0

compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y
_
a
n
a


y


0

0
.
2
5

0
.
5

0
.
7
5

1

compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y
_
a
n
a


y


0

0
.
5

1

Euler (explicit)
Implicit Euler
step =0.5
step =0.5 step =2
step >1
unstable!
analytical solution
$y =x - y
312 2000 AspenTech. All Rights Reserved. ACM intro
Accuracy and Step Size : reducing the time
step increases the accuracy
compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y


y
_
a
n
a


-
2

-
1

0

1

compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y


y
_
a
n
a


-
1

-
0
.
5

0

0
.
5

1

$y =cos t
Implicit Euler
step =1
Implicit Euler
step =0.1
analytical solution
numerical solution
313 2000 AspenTech. All Rights Reserved. ACM intro
Error Control
How to control the step size?
the analytical solution is unknown
making the step size too small increases the calculation time -
try to make it as large as acceptable
314 2000 AspenTech. All Rights Reserved. ACM intro
Error Control
Error : difference between the predicted values
(approximation) and the final values after the corrector
iterations (solution)
monitor the error and adjust the time step and order
h ?
e
predictor
corrector
f(t)
f(t+h)
dx/dt =f(t)
x
time
315 2000 AspenTech. All Rights Reserved. ACM intro
Effect of Error Control
Example with VSIE
compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y


y
_
a
n
a


-
0
.
5

0

0
.
5

1

compare
Time Hours
0 1 2 3 4 5 6 7 8 9 10
y


y
_
a
n
a


-
1

-
0
.
5

0

0
.
5

1

1
.
5

error tolerance =1E-4
(default)
error tolerance =0.1
316 2000 AspenTech. All Rights Reserved. ACM intro
Event Detection
Time of occurrence known : step to that time
Time of occurrence unknown
Event detection via error control (VSIE)
317 2000 AspenTech. All Rights Reserved. ACM intro
Event detection
Event detection with Gear
Lock the conditional equations
Locate the discontinuity
Reinitialize from that point
Example

I F ( l evel > 0 ) THEN
F = k*sqr t ( l evel ) ;
ELSE
F = 0;
ENDI F
level could
become negative!
318 2000 AspenTech. All Rights Reserved. ACM intro
Solutions for the condition locking
Change the expression to avoid the problem





Implicit Euler : use the pLimit procedure
Another solution is to use a procedure
the conditional is hidden in the procedure
I F ( l evel > 0 ) THEN
F^2 = k^2*l evel ;
ELSE
F = 0;
ENDI F
319 2000 AspenTech. All Rights Reserved. ACM intro
Gear
Use bounds and turn on bound checking
Hide the condition in a procedure


the procedure should return the derivatives
see next slide
cal l ( F) = pFl owCal c( l evel , k) ;
320 2000 AspenTech. All Rights Reserved. ACM intro
Procedure returning the derivatives
SUBROUTI NE FLOWCALC( LEVEL, DK, F, I FL, D, NO, NI , I CALL)
DOUBLE PRECI SI ON LEVEL, DK, F, I FL, D( NO, NI )
I F ( I CALL . EQ. 0 . OR. I CALL . EQ. 4) THEN
I F( LEVEL. GT. 0) THEN
F=DK*SQRT( LEVEL)
ELSE
F=0D0
ENDI F
ENDI F
I F ( I CALL . EQ. 3 . OR. I CALL . EQ. 4) THEN
I F( LEVEL. GT. 0) THEN
D( 1, 1) =DK/ ( 2D0*SQRT( LEVEL) )
D( 1, 2) =SQRT( LEVEL)
ENDI F
ENDI F
RETURN
END
321 2000 AspenTech. All Rights Reserved. ACM intro
Comparison of the Methods
GEAR
potentially most accurate
VSIE
becomes fixed step if error above tolerance and and min step
is large
discontinuities make Gear reinitialize and switch to first order
VSIE has some "robustness" features
- decomposition
- small step size after disturbances
Use Gear as a cross-checking method

322 2000 AspenTech. All Rights Reserved. ACM intro
Comparison of the Integration Methods
Implicit Euler
alternative to VSIE, but step size must be carefully selected
(crude integration technique)
Explicit methods
typically not recommended
323 2000 AspenTech. All Rights Reserved. ACM intro
Gear Important Options
Gear tends to be more sensitive to modeling errors
either try to fix your models
or use another method (you can do both!)
Leave options to their defaults
maybe tweak event tolerance
maybe tweak reinitialization and bounds
Show highest...
can be useful to debug
324 2000 AspenTech. All Rights Reserved. ACM intro
VSIE Important Options
Initial integration step
important if initial state is far from steady state
Minimum integration step
default value can be a bit too large
Maximum integration step
making maximum and minimum integration steps equals
makes VSIE to emulate fixed step implicit Euler
325 2000 AspenTech. All Rights Reserved. ACM intro
Implicit Euler Important Options
Integration step
compare different integration steps
compare with VSIE or Gear
2000 AspenTech. All Rights Reserved.
Equations and Specifications for
Dynamic Systems
A concept proper to initialization and dynamic
simulation is exposed in this section
327 2000 AspenTech. All Rights Reserved. ACM intro
Concept of Index
The index of a differential algebraic system (DAE) is the
number of times you need to differentiate the algebraic
equations to convert the system to an ordinary
differential equation system (ODE)
index of ODE = 0
ACM mathematical algorithms can integrate systems of
index 0 and 1
Note that the index of a system depends on the equations and
the specifications (fixed variables)
328 2000 AspenTech. All Rights Reserved. ACM intro
Example of Index>1 Problem
Feed flow and pressure are specified
F
1

P
4
P
3
P
2
P
1

F
4
F
3
F
2

h
V
l

P
0

dp =k
A
.F
2
dp =k
B
.F
2

A
T
0

329 2000 AspenTech. All Rights Reserved. ACM intro
Equations for the System
10 Equations :
2
3 3 4
3 4
0 0
0 3
3 2
3 2
2
1 1 2
1 2
. .
F k P P
F F
Ah V
V V V
nRT V P
h g P P
P P
F F
dt
dV
F k P P
F F
B
l
l v
v
l
A
=
=
=
= +
=
+ =
=
=
=
=

pressure link
330 2000 AspenTech. All Rights Reserved. ACM intro
Specifications
19 variables and 10 equations
we need 19 - 10 = 9 specifications
Stream 1
F
1
and P
1
fixed
Valve 1
k
A
fixed
Tank
V, A, n, rho and T
o
fixed
Valve 2
k
B
fixed

331 2000 AspenTech. All Rights Reserved. ACM intro
Resolution
Steady state resolution :
Set dV
l
/dt = 0
Solve the system - ok!
Initialization run :
Need one initial condition : for example V
l

Not possible to solve

ACM detects that the
system is singular
332 2000 AspenTech. All Rights Reserved. ACM intro
Incorrect Specification for initialization run
Check status dialog with F
1
and P
1
set
333 2000 AspenTech. All Rights Reserved. ACM intro
Physical explanation
It is not possible to set both the feed flowrate and
pressure (because the pressure is the driving force for
the flow, so they are not independent)
Need to use another specification scenario
For example free F
1
and fix P
4
334 2000 AspenTech. All Rights Reserved. ACM intro
Initialization for Singular Systems
Initialization is singular due to index > 1 system
Aspen Custom Modeler can integrate systems up to index 1
335 2000 AspenTech. All Rights Reserved. ACM intro
Frequent causes of index>1 problems
Trying to do something which is not physically possible
(specifications)
Fixing the liquid level of a tank (perfect level control?)
Fixing the pressure of a gas holdup
Fixing a state variable or equivalent...
Modeling issues
Over-simplifications
An algebraic variable which is Free and which appears only in
differential equations
336 2000 AspenTech. All Rights Reserved. ACM intro
Recommendation
Be proactive : try to make your models look after
themselves
Fixed, Initial, RateInitial and Free in variable declaration
Define Conditions testing parameter values, connectivity
Use Visual Basic scripts to specify your system
Use the Analyze tool
It is not always simple
2000 AspenTech. All Rights Reserved.
Convergence and Troubleshooting
(optional)
338 2000 AspenTech. All Rights Reserved. ACM intro
Convergence Problems
Steady-state
check for typos, missing conversion factors, etc...
improve your initial guesses and bounds on variables
high residuals (equations and variables)

339 2000 AspenTech. All Rights Reserved. ACM intro
Convergence Problems
Non-Linear/Tolerances
maximum variable step
maximum range fraction
Improve equation scaling
Try initialization run and look at time derivatives
Analyze smaller systems
Simplify the model, open recycle loops
340 2000 AspenTech. All Rights Reserved. ACM intro
Integration Problems
Check model for missing conversion factors, etc...
signs in balances and controller action
Non-convergence
discontinuity?
system not physically realistic
Unexpected results
check modeling assumptions
minimum time step too large
try open loop or other control schemes
2000 AspenTech. All Rights Reserved.
Switches (optional)
342 2000 AspenTech. All Rights Reserved. ACM intro
Switches
The switch construct implements two concepts:
conditional equations
state may depend on past history
343 2000 AspenTech. All Rights Reserved. ACM intro
Example
Rudimentary level control:
pump off until level goes under lower level
pumps full rate until level goes above high level
stop
pump
start
pump
344 2000 AspenTech. All Rights Reserved. ACM intro
Example
State diagram:
pump off
pump on
if volume <low
if volume >high
345 2000 AspenTech. All Rights Reserved. ACM intro
Example
ACM language:
pump_cont r ol :
swi t ch
i ni t i al st at e pump_of f
p_i n. F = 0;
i f V < Vmi n st at e : pump_on;
endst at e
st at e pump_on
p_i n. F = f l ow_max;
i f V > Vmax st at e : pump_of f ;
endst at e
endswi t ch

346 2000 AspenTech. All Rights Reserved. ACM intro
SWITCH Syntax
Syntax as follows:
INITIAL keyword to specify initial state
Swi t chName: SWI TCH
I NI TI AL STATE St at eName
Swi t chSt at ement s;
I F Condi t i on STATE : NewSt at eName;
ENDSTATE
.
.
ENDSWI TCH
2000 AspenTech. All Rights Reserved.
Modeling Review (optional)
Review briefly the fundamental principles of
modeling
348 2000 AspenTech. All Rights Reserved. ACM intro
Modeling Review
Modeling helps you
understand your process phenomena
get relevant useful data for accurate simulation
approach what is relevant and what is not
improve unit operation or flowsheet performance and safety
May bring some surprising conclusions giving radical
solutions to problems with huge financial savings
349 2000 AspenTech. All Rights Reserved. ACM intro
Problem Types
Steady state
Initialization and Dynamic runs
Steady state optimization
Dynamic optimization
Steady state parameter estimation and data
reconciliation
Dynamic parameter estimation
350 2000 AspenTech. All Rights Reserved. ACM intro
Variables
Two categories of variables:

State variables :
a variable that is differentiated with respect to time
example : the holdup in a tank
Algebraic variables :
additional variables to write the model
example : temperature, pressure, flowrate

351 2000 AspenTech. All Rights Reserved. ACM intro
Equations
Balances
material balances
energy balances
Pressure/flow relations - hydrodynamics
Kinetics
mass and heat transfer (e.g. diffusion, convection, radiative)

352 2000 AspenTech. All Rights Reserved. ACM intro
Equations
Thermodynamic equilibrium
Geometric constraints
Physical properties
Control system
353 2000 AspenTech. All Rights Reserved. ACM intro
Models
Detailed modeling
leads to distributed parameter models
which leads to partial differential equation systems
Engineering or lumped approach
working out position to lead to lumped parameters
e.g. perfectly mixed tank
354 2000 AspenTech. All Rights Reserved. ACM intro
Material Balances
Steady state balance:


Dynamic or unsteady state balance:



For multicomponent mixtures: one material balance per
component
d(content)/dt = in - out + generation
0 = in - out + generation
355 2000 AspenTech. All Rights Reserved. ACM intro
Energy Balance
Energy content : internal energy
Energy flow : usually enthalpy/time




internal energy : U
internal energy for flow: h + v
2
/2 + z.g
h = u + pv : internal energy + compression work
kinetic energy
potential energy
d(internal energy content)/dt =
internal energy in - internal energy out + Q -W
356 2000 AspenTech. All Rights Reserved. ACM intro
Other Fundamental Laws
Equations of motion (conservation of momentum)
Kinds of forces
normal forces : e.g. pressure
shear forces : e.g. viscous forces
body forces : e.g. gravity
357 2000 AspenTech. All Rights Reserved. ACM intro
Transport Equations
Transport equations have the form:


flux : rate of transfer per unit area
driving force : gradient in temperature, concentration, etc
Examples at microscopic scale:
thermal conductivity : Fourier's law
component diffusion : Fick's law
momentum : Newton's law of viscosity
[flux] = [coefficient] . [driving force]
358 2000 AspenTech. All Rights Reserved. ACM intro
Transport Equations
Examples at macroscopic scale
Heat:
Q = U.A.DT (convection)
- Q : heat duty
- U : convective heat transfer coefficient
- DT : temperature difference
Q = .T
4
(radiation)
- Q : heat duty
- : radiative heat transfer coefficient
- T : temperature of the source
359 2000 AspenTech. All Rights Reserved. ACM intro
Transport Equations
Examples at macroscopic scale
Fluid dynamic:
flow rate = [DP].[area]/[resistance]
- resistance in general depends on flow rate
- laminar flow: F = k.DP (k constant)
- turbulent flow: F = k'.sqrt(DP)
- DP : pressure difference
- F : flowrate
- k, k' : dependent on the system
More details required for sonic flows, quick transients
360 2000 AspenTech. All Rights Reserved. ACM intro
Physical Properties
Evaluation of quantities involved in the previous
equations:
density, enthalpy, viscosity, ...
Thermodynamic equilibrium
liquid-vapor equilibrium, liquid-liquid equilibrium
general
phase temperature equality
phase pressure equality
phase component fugacity (or chemical potential) equalities
361 2000 AspenTech. All Rights Reserved. ACM intro
Physical Properties
Non-equilibrium models
application of transfer/transport equations

362 2000 AspenTech. All Rights Reserved. ACM intro
Process Control
Sensor - Controller - Control valve
Control valve
Sensor
Controller
set point
363 2000 AspenTech. All Rights Reserved. ACM intro
Sensors
Measure important variables: generate signal to
controller
Dynamic response usually much faster than that of the
process, rarely modeled rigorously
exceptions: chromatographs (periodic measurements), some
thermocouple (high pressure; thermal well), pH (delay)
364 2000 AspenTech. All Rights Reserved. ACM intro
Controllers
A form of the PID general equation (library) :
error = setpoint - signal
(or signal - setpoint)

(

+ + + =

t
d
I
c bias
dt
de
edt e K X X
0
1

derivative time constant


integral or reset time constant
error
gain
365 2000 AspenTech. All Rights Reserved. ACM intro
Controller
Wide variety of Commercial controllers
e.g. variable gain, dead band, reset/wind up

366 2000 AspenTech. All Rights Reserved. ACM intro
Valves
Output from controller used to throttle the flow of a
manipulated variable
Typical valve equation (subsonic liquid)
/ ). ( . P x f C F
v
=
flowrate
valve size
coefficient
characteristic curve: linear x, square root x
1/2
,
equal percentage
x-1
, where x is the stem position (0-1)
pressure drop
specific gravity
367 2000 AspenTech. All Rights Reserved. ACM intro
Valves
Dynamic response usually not a concern unless valve is
very large, discontinuous ("sticks") or process is very fast
(e.g. pressure relief system)

S-ar putea să vă placă și