2000 AspenTech. All Rights Reserved.
Introduction to Aspen Custom Modeler
PresenterPresentation NotesNOTE ABOUT THE NOTES:- most are from version 10.0 and I never had the time to review them- they are for internal use only
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
PresenterPresentation Notes
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
PresenterPresentation NotesShow the GUI life, ie expand the models folder, and then pick the equations of the model
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
PresenterPresentation Notes
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
PresenterPresentation NotesTo build the flowsheet, you need to select the block model you want to use. Then, with the left mouse button down, move the mouse on the flowsheet area and release the mouse button at the point where you want to place the block.
To connect the blocks, you will use the stream types. Select the stream type you want to connect and with the left mouse button down, move the mouse on the flowsheet area. The ports compatible with the stream type selected will be displayed. Move the mouse close to the port you want to connect and click on the left mouse. Then move the mouse to the place where you can to connect the other end of the stream and again click on the left mouse button to select the connection.
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
PresenterPresentation NotesShow the status buttonShow the run mode
24 2000 AspenTech. All Rights Reserved. ACM intro
Help
Extensive on-line help available "How to" help Reference help Context sensitive
help Tool tips
PresenterPresentation NotesShow them how to use the help.Show them how to use the 'what's this' helpHow to : good for beginnnersReference : good for everyoneContext help : with the Demonstrate (but think about what you want to demonstrate...)
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
PresenterPresentation NotesShow how to hide and get it back. Mention that it is cleared when you close it (I don't like it, but this is working as designed, as they say)Show the Windows menu with the list of windowsShow the flowsheet as wall paper option.
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
PresenterPresentation NotesBased on Tom Epperly's comment. The whole section could be renamed "Equation Oriented Modeling Concepts". Ok, let's leave that for 10.2 or later. For people with a procedural programming background it is worth warning them about the non-procedural nature of ACM (hoping not to confuse those with no programming background at all). Again, I would *love* to have the time to talk about modeling techniques, but this is something people will have to learn by themselves as time is too limited in the 3 days ACM course.If all of them have a programming experience, then tell them that they can use "procedures" in ACM, which call some fortran or C routines they would have written and interface that with the rest of the resolution. If they are not lost, then tell them that the actual picture is a tiny bit more complicated as we have assignments and tasks, which are executed in yet another way.
30 2000 AspenTech. All Rights Reserved. ACM intro
Steady state example
Steady State model : 3 equations, 6 variables
h V
Fin
Fout Area k
hAVhkF
FF
out
outin
..
0
=
=
= Fin, Fout as flow_vol; k as realvariable; h as length; V as volume; A as area; 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 Fin Fout V A h k
1 0 = Fin-Fout * *2 Fout = k*sqrt(h) * * *3 V = A*h * * *4 spec 1 ?
5 spec 2 ?
6 spec 3 ?
PresenterPresentation NotesThe "*" indicates the incidence of a variable in the equation. So this is the incidence matrix. Usually this is a huge sparse matrix.One thing to find out the correct specification is to match every equation with a different variable. The obvious choice is the diagonal, so in this case this would be to specify A,h and k, which are the natural "design" variables. Don't spend too much time on this slide. I think this is a good mental picture to understand what ACM does, but ACM works even if you don't understand it (ok, sometimes it will do something else that you want -- but then, hey, do you really understand what you told it to do?).It could be a good slide to tell them that not every combination of spec is ok, like for example V,A,h leave only 2 equations to find Fin, Fout and k, so the resolution is not possible. Zero degree of freedom is a necessary condition, but not sufficient. The status button counts the dof, but during a run, the solvability is checked rigorously.
34 2000 AspenTech. All Rights Reserved. ACM intro
Specifications
Every variable has a "Spec" property which selects its specification mode
Valid values: Spec DescriptionFixed 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)
PresenterPresentation Notesnote that objective and vary are gone... they were defined in 10.0 as the objective function and the freed specificaitons for the optimization resp.STRESS that Free means the solver/acm solves the system to get the value of the free variables, while Fixed means that the user gives the value.
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
PresenterPresentation NotesFind shortcut : it launches find configured to find selected variables specs. Idea is "I must fix something, show me all the frees so I can fix one"
38 2000 AspenTech. All Rights Reserved. ACM intro
Analyze Tool
Button on the Specification Status dialog
Menu View, Specification Analysis...
PresenterPresentation NotesUnless you've done it already, this is a good time to demonstrate the feature. The index2 example is available in the demo directory.It finds the specs that make it ok wrt to specifications. Then it is up to you to make some sense... Instead of accepting blindly the changes, you can also make it more "smart".Encourage them to use the tool in the workshops, and don't spend too much time here. The logic is a mathematical matching algorithm, a bit like the one that groups the equations for the decomposition.Make them understand that they need to activate their intelligent deviceTM full gear, not have the damn machine tell them what to do and think! (ie the analyze picks a correct set of specs, not a physically meaningful one -- my recommendation is that you accept some specs from the analyze, then exchange them with physically sound ones -- that can be done in the analyze tool or after (ie to fix the typos in your model or connect streams are good examples of things the analyze will not do for you). YES -- failing to connect streams is the one mistake people do during the training course (and PFS odd behaviours [is is the stick to grid?] is probably not stranger to this...)
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 flow_vol; k as realvariable (fixed); h as length; V as volume; A as area (fixed); 0 = Fin - Fout; Fout = k*sqrt(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
Fin, Fout as flow_vol; k as realvariable; h as length; V as volume; A as area; $V = Fin - Fout; Fout = k*sqrt(h); V = A*h;
$variable in ACM language represents the time derivative of the variable
Equations
hAVhkF
FFdtdV
out
outin
..
=
=
=
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 Fin Fout V A h k $V
1 $V = Fin-Fout * * *2 Fout = k*sqrt(h) * * *3 V = A*h * * *4 spec 1 ?
5 spec 2 ?
6 spec 3 ?
7 initial 1 ?
44 2000 AspenTech. All Rights Reserved. ACM intro
Specifications
One of the possible specifications set
Variable type specificationFin algebraic FIXED
Fout algebraic FREEV state FREEk algebraic FIXEDh algebraic INITIALA 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
PresenterPresentation NotesFor lack of a better picture. This shows the spaghetti bolw that ACM maze can handle. Up to you on how to present this. I think I would just mention this slide as a road map (a crude one). It is quite approximative, as for example a stream model can refer to a model, a script to another script, which could be in a model, etc.
The slide show is actually quite good to repeat the template model of the previous slide and the relations to other types.
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 // definition of type 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 MyVariableType Value: 123.4; Lower: 50.0; Upper: 500.0; PhysicalQuantity: "kg/hr (dry)" ; END
PresenterPresentation NotesSee the on-line help for a full description. Of course variable type defines more... But these are the fundamental things, ok?The attributes are:value : default valueupper : upper boundlower: lower boundscale: scaling factorisconnected:true if a control signal is connected on the variabledescription: variable descrptionbaseuomname: base unit of measurement namespec: specification statusrecord:true means the value is saved in historyulagrange:???optimllagrange:???optimtag:???dmcplus and SAX
56 2000 AspenTech. All Rights Reserved. ACM intro
Variables properties inherits from RealVariable type Property Type DefinitionValue Real current variable valueUpper Real upper bound for variable valueLower 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 descriptionPhysicalQuantity String defines the category of physical unitsUnits String physical units currently usedSpec 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)
PresenterPresentation NotesSee next slide notes about rebuild vs. compile.
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
PresenterPresentation NotesCB.: What is the difference between Compile and Rebuild?Rebuild compiles everything in the order of creation. Compile compiles only the selected object. Because of the order the rebuild is performed, this command is useless (ie if you create a model, then a port, the rebuild will try to compile first the model, so it will fail saying the port type does not exist). My recommendation is that you compile after each edition and never use the rebuild. Note that a rebuild is done when you load the file (it works because the save sorts the sections in the correct order).
Tell them that if they get a green cross, they should call the hotline immediatly. :-) If they get a red cross, have them clear the simulation messages then recompile again. (this is to avoid looking at old error messages... make sure the simulation messages window is large enough...)
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 MainPort F as flow_mol; z(componentlist) as molefraction; T as temperature; P as pressure; h as enth_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 ModelName // variable and parameter declarations VariableName AS VariableTypeName; ParameterName AS ParameterTypeName; // port declarations PortName1 AS INPUT PortTypeName; PortName2 AS OUTPUT PortTypeName; // Assignments VariableName.property : expression; // Equations EquationName: expression1 = expression2; END
PresenterPresentation NotesMention this slide as a template, just read the various items. Mention the assignements and the equations. Then go to the next slide.
62 2000 AspenTech. All Rights Reserved. ACM intro
Variable Declaration
Variables are declared on variable types
Examples Tmetal as Temperature (25); Tamb as Temperature (FIXED, 25); Ttank as Temperature (INITIAL); Ptank as Pressure (upper:13); C as Conc_Mole (description:"conc. of X"); a,b as RealVariable;
VariableName AS VariableTypeName; VariableName AS VariableTypeName (AssignmentList);
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)
PresenterPresentation Notes
black if different from default valueblue if equal to default valuewill be updated if you have never edited it beforewill not be updated if you have edited before
64 2000 AspenTech. All Rights Reserved. ACM intro
Assignments
Examples T as temperature; T.value : 23; // changes the default value of T T.spec : FIXED; // changes default spec. type T.lower : -10; // changes the default lower 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 (description:"some description");
66 2000 AspenTech. All Rights Reserved. ACM intro
Accessing Port Variables in Models
Syntax : PortName.VariableName
MODEL tank In_F as input Fport; Out_P as output Fport; V as volume (initial); // material balance $V = In_F.F - Out_P.F; END
PORT Fport F as flow_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)
equationlabel: expression = anotherexpression; expression = anotherexpression;
PresenterPresentation NotesYou can use the following mathematical operators in equations and assignments:
OperatorUsageDescription+x + yAddition-x - ySubtraction*x * yMultiplication/x / yDivision^x ^ 3Raised to the power ofSINSIN(x)SineCOSCOS(x)CosineTANTAN(x)TangentASINASINx)Arc SineACOSACOS(x)Arc CosineATANATAN(x)Arc TangentSQRTSQRT(x)Square rootSQRSQR(x)Square ofEXPEXP(x)ExponentLOGeLOGe(x)Natural LogarithmLOG10LOG10(x)Logarithm to base 10ABSABS(x)Absolute value ofSIGMASIGMA(x,y,...)Sum values of an expressionPRODUCTPRODUCT(x,y,)Product of a list of arrays and variablesMAXMAX(x,y,)Maximum value in a list of arrays and variablesMINMIN(x,y,)Minimum value in a list of arrays and variablesTIMETIMECurrent simulation timeDELAYDELAY x BY lagApply a lag to the value of a variable
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
PresenterPresentation Notesyou can create a shape and not plane ports -> get universal ports for any port not placed graphicallyexplain difference in topology editor
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
PresenterPresentation NotesCB. Integerparameter,stringparameter are generic types for parameters as realvariable is for variables.
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 INTEGERPARAMETER Value : DefaultParameterValue ; Description : "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 Value : DefaultValue; Description : "description"; Upper : UpperParameterValue; Lower : LowerParameterValue; PhysicalQuantity: "physicalquantityname"; END
PresenterPresentation NotesCB.: Parameter types can be defined within the parameter object or directly in a model type, stream type, or port type?Where you want... However I think it is more useful to define them in the parameter types folder (to maintain some consistency). Note that I typically define a parameter type in a model when doing some debugging (ie to switch on/off some equations).
SPEEDUP users will appreciate the fact it is possible to define the units for the realparameter.
MAKE SURE EVERYONE UNDERSTANDS the difference between a parameter (fixed by nature) and a variable (up to the user). A variable is more flexible so I would recommend that in doubt to use a variable. (the only cost is memory usage -- but this should not be an issue when you start using ACM... leave this sort of code optimization for later -- ie be smart : make it run then make it run better (or make it run on larger problems)).
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 Meaning== (two equals signs) Equal to
> Greater than< Less than
>= Greater than or equal to
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 ModeOfOperation as stringparameter; IF ModeOfOperation "PressureDriven" THEN // ModeOfOperation has the value FlowDriven // Find minimum inlet pressure Pin = MIN(In1.P, In2.p); // 1 eq ELSE // ModeOfOperation has the value PressureDriven // Equate inlet pressures In1.P = Pin; // 2 inlets = 2 eqs In2.P = Pin; 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 MaterialPort; IF Out_Vent.IsConnected THEN // a stream is connected Out_Vent.F : free; ELSE // no stream connected - fix vent flow to zero 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: Atot, Aliq as area; level as length; h_low, h_tube as length; if level > h_low+h_tube then Aliq = Atot; // flooded elseif level < h_low then Aliq = 0; // dry else Aliq = Atot*(level-h_low)/h_tube; // between 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
if flow > 0 then dp = k*flow^2; chock = flow/fmax; else chock = 0; endif
PresenterPresentation NotesHow to correct? No idea! This is a made-up example, without real modelling background. This example should be changed. Any suggestion?I want to find the rules behind why some conditional equations are problematic while others are perfectly fine. Obviously this depends on how the system is specified and not only the equations. Force the model to use the equations of one side of the IF and see how it solves, then the other side, as when the IF switches from one branch to the other, there is a need for continuous robust solution.Examine how the system will be resolvedConvergence difficultiesif a step is large, then variables may move far from convergence region: convergence failureborder caseTroubleshooting: make sure the resolution try different integration methods
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
PresenterPresentation NotesCB.: can use online help to show definition of the 2 built-in stream type
89 2000 AspenTech. All Rights Reserved. ACM intro
Streams on the Flowsheet
Example
LItank 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
LItank 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 the destination of a control signal Q as INPUT enthflow; // Level can be the source of a control signal Level as OUTPUT length; // F can be the source or the destination of a // control signal F as INPUT,OUTPUT flow_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
processing connection between B1.out_p and B2.in_f, the following variables don't match B1.out_p.y
PresenterPresentation NotesNote in SPEEDUP it was the variable order that was used for matching the variables.
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
PresenterPresentation NotesLine style can be changedInheritance (STREAM ... USES ...)
94 2000 AspenTech. All Rights Reserved. ACM intro
Stream Equations
Stream variables
STREAM Fstream F as flow_vol; In_F as input Fport; Out_P as output Fport; Out_P.F = In_F.F; F = In_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 Flowrate PhysicalQuantity : "kg/hr"; upper : 10; lower : 0; END
VARIABLE Flowrate_big USES Flowrate upper : 1000; END
VARIABLE RealVariable // 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 temperature; Pamb as GLOBAL pressure; coef as HIDDEN realvariable;
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 fraction; deadtime as time_; y = DELAY x BY td;
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
First as integerparameter (4); Last as integerparameter (10); MySet as integerset ([First: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:
YourSet as stringset;
YourSet : ["alpha","beta"];
YourSet as stringset (["alpha","beta"]);
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 integerparameter (10); T([1:N]) as temperature; // array of vars w([1:N]) as realparameter;
T_in = T(1); // just a few examples! 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 (["paraffin", "olefin", "naphtene","aromatic"]); analysis(pona) as fraction; // example of accessing one element of the array rate = 11.04*exp(-1966/T)*analysis("aromatic")^0.34;
113 2000 AspenTech. All Rights Reserved. ACM intro
Multidimensional Arrays
You can declare multidimensional arrays
Example : 2D array M as integerparameter (10); N as integerparameter (3); Mset as integerset ([1:M]); Nset as integerset ([1:N]); T(Mset, Nset) as temperature; T(5,2) = T(1,3)+T(3,1); // just an example!
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(ComponentList) as molefraction; x : 1/(SIZE(ComponentList));
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 RealVariable; B1 = SIGMA (A1, A2, A3, 2.0 );
B1 = A1 + A2 + A3 + 2.0;
Components AS StringSet(["N2", "O2", "CO2"]); x(Components) AS Fraction; SIGMA(x(Components)) = 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 IntegerParameter(10); Sections AS IntegerSet([1:nsect]); Tmean, Temp(Sections) AS Temperature; 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
OrgFrac AS Fraction; x(ComponentList) AS Fraction; OrgFrac = SIGMA(x(ComponentList - ["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 integerparameter (3); A([1:n],[1:n]) as realvariable (fixed); s as realvariable; 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 integerparameter; position([1:n]) as realparameter; dx as realparameter; position(1) : 0; dx : 1/n; FOR i IN [2:n] DO position(i) : position(i-1) + dx; ENDFOR
position(1) position(i) dx position(n)
PresenterPresentation NotesMike comments: not sure it is a good example: assignement in loops may not do what is expected, ie you can't use a loop to accumlate a value.The example is correct. The point to make clear is that x : x + something is not allowed. Use a script!!! Use assignements for default values and simple things. Anything a bit involved should go in scripts, where you can control the order of execution of the assignements.
Note about the example : we could have said position(i) : position(1) + i/n. You should just say we used the form here on this slide to stress that position(i) : position(i-1); position(i) : position(i) + dx; is incorrect.
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 flowrate; ns as integerset ([1:3]); z(ns), x(ns), y(ns) as fraction; F*z = L*x + V*y;
PresenterPresentation NotesThe loop :for i in ns do F*z(i) = L*x(i) + V*y(i);endfor
is in fact:for i in ns*ns*ns do F*z(i) = L*x(i) + V*y(i);endfor
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 integerset ([1:3]); z(nsF) as fraction; ns as integerset ([1:2]) x(ns),y(ns) as fraction; 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 integerparameter (3); coef([0:n]) as realvariable (0, fixed); x as realvariable (fixed); y as realvariable; y = sigma(foreach (i in [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 MatrixModel1 ms as integerset ([1:2]); ns as integerset ([1:3]); a(ms,ns) as realvariable (FIXED); b(ms,ns) as realvariable (FIXED); c(ms,ns) as realvariable; for i in ms do for j in ns do c(i,j) = a(i,j)+b(i,j); endfor endfor END
PresenterPresentation Notesthe two for loops are not needed -- you can really write this as c = a + b. This is a good example to show the matching of the index (index 1 of C with index 1 of A and index 1 of b --- the matching works on the dummy index so c(1,ns) = a(ns, 1) + b(ns,2) would be a disaster...
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 MatrixModel2 ms as integerset ([1:2]); ns as integerset ([1:3]); a(ms,ns) as realvariable (FIXED); b(ms,ns) as realvariable (FIXED); c(ms,ns) as realvariable; c = a + b; END
PresenterPresentation Notesthe two for loops are not needed -- you can really write this as c = a + b. This is a good example to show the matching of the index (index 1 of C with index 1 of A and index 1 of b --- the matching works on the dummy index so c(1,ns) = a(ns, 1) + b(ns,2) would be a disaster...
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
kjk
ikij bac =MODEL MatrixModel3 ms as integerset ([1:2]); ns as integerset ([1:3]); ps as integerset ([1:4]); a(ms,ns) as realvariable (FIXED); b(ns,ps) as realvariable (FIXED); c(ms,ps) as realvariable; for i in ms do for j in ps do c(i,j) = SIGMA(a(i,ns)*b(ns,j)); endfor endfor END
PresenterPresentation NotesAlternative version (as in the help) for i in ms do for j in ps do c(i,j) = SIGMA(foreach(k in ns) a(i,k)*b(k,j)); endfor; endfor;
Explain the forms you prefer... the foreach is probably easier to explain
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 STRINGPARAMETER Valid AS STRINGSET( ValidList ); Value : 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 AgitatorType USES STRINGPARAMETER valid as stringset (["paddle", "pitched blade turbine", "disk", "propeller", "anchor", "anchor-high", "helical-ribbon"]); value : "paddle";// default value END MODEL Mixer agitator as AgitatorType; ... END
PresenterPresentation Notesvalid has a special meaning for table. It is not a built-in property for the parameter type, but it is detected by tables to populate the pull-down menu.
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
PortName AS INPUT MULTIPORT OF PortType; PortName AS OUTPUT MULTIPORT OF PortType;
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 PortName.connection("streamname").VariableName
PresenterPresentation NotesThe example is in strawberry box, because althrough the code is correct, it is not a good idea to hard-wire the name of a stream in a model.note that this is very bad as people renaming streams in AD have discovered
136 2000 AspenTech. All Rights Reserved. ACM intro
Typical FOR loop with Multiport
Accessing the variables of all the streams connected
FOR i IN PortName.connectionset DO PortName.connection(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 Fport F as flow_vol; END MODEL tank In_F as input Fport; Out_P as output Fport; V as volume (initial); // material balance $V = In_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 multitank In_F as input MULTIPORT OF Fport; Out_P as output Fport; V as volume (initial); // material balance $V = SIGMA(In_F.connection.F) - Out_P.F; END
139 2000 AspenTech. All Rights Reserved. ACM intro
Another Example
Steady state energy balances of a mixer: In_F as input multiport of MainPort; Out_P as output multiport of MainPort; hmix as enth_mol; // outlet enthalpy definition (mixing) SIGMA(In_F.connection.F)* hmix = SIGMA(In_F.connection.F*In_F.connection.h); for i in Out_P.connectionset do Out_P.connection(i).h = hmix; endfor
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
PresenterPresentation NotesIt is not possible to create a table in the Simulation folder, only Global.
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
Index0 4 8 12 16 20 24 28 32 36 40 44 48 52
solid
tem
pera
ture
C T
ime:
81.
0000
00ga
s te
mpe
ratu
re C
Tim
e: 8
1.00
0000
gas
tem
pera
ture
540
550
560
570
580
590
600
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
PresenterPresentation Notesthis dialog is not easy to use. Do the demo of the PDE bed, and tell them they will repeat the steps in the workshop.
2000 AspenTech. All Rights Reserved.
Handling Components
PresenterPresentation NotesExplain how to handle the components:- component sets- component lists (ie with properties)
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 Just to define the name of the components
PresenterPresentation NotesLaunch the section by saying why components are needed in process simulation. Examplesmaterial balancesreactions kineticsetc...In SPEEDUP 5, we had to map the components to numbers!!! That was very confusing! Now instead we can use meaningful (hum???) names.without phys proprs include very simple ones like constant densities, or things you write in a few lines in a submodels, not a full blown equation of state with Huron-Vidal mixing rules using UNIFAC group contribution method, if you see what I mean.
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"
PresenterPresentation NotesThe words "Set" and "List" are misused consistently in ACM. The problem is that a ComponentList as the name says seems to be a list, but we have just talked about sets a few sections ago. So what? To me this naming is still complete non-sense, but as the CDs have been burned, there is no way back. So just try to make it clear. The most painful thing is the dialog with the mysteryous questyon "Is a ComponentSet". Note that a ComponentList of type List is not actually linked t o Aspen Plus directly but via the gpp.dll. If you want (and a few customers do that) you can create your own gpp.dll (via something called GPI = Generalized Properties Interface) : the standard gpp.dll actually calls the Aspen Plus routines. See the help for further details. Maybe when a Aspen Properties would be available, we'll need to remove the reference to Aspen Plus (which is percieved more as a flowsheeting program -- but PropPlus runtype is just what we use here -- this is still Aspen Plus -- minus the flowsheet)
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+
PresenterPresentation NotesI would recommend that at this stage you demonstrate the steps. If they all know Aspen Plus, have them start the workshop.
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
PresenterPresentation NotesNote that the limitiation in 10.0 is removed -- you had to exit ACM to load another properties file.
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
// call to a procedure call (output list) = pProcedure_Name (input list);
call (hl) = pEnth_mol_liq(T, p, x);
162 2000 AspenTech. All Rights Reserved. ACM intro
Example of using the componentlist for a flash calculation
MODEL ExampleModel T as temperature (fixed); p as pressure (fixed); vf as vapfraction; hl as enth_mol_liq; hv as enth_mol_vap; h as enth_mol; z(Componentlist) as molefraction (fixed); x(Componentlist) as molefraction; y(Componentlist) as molefraction; sigma(z) = 1; h = vf*hv + (1-vf)*hl; call (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
PresenterPresentation NotesThe comment is just there to explain what the table shows. It shows the results, nothing more to explain.
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
call (hl) = pEnth_mol_liq(T, p, x) Out_P.Componentlist;
165 2000 AspenTech. All Rights Reserved. ACM intro
Using Several Componentlists
Explicitly state the componentlist to use MODEL HtxModel Cl_p1 as componentlistname; Cl_p2 as componentlistname; p1_in as input MainPort (ComponentList : Cl_p1); p1_out as output MainPort (ComponentList : Cl_p1); p2_in as input MainPort (ComponentList : Cl_p2); p2_out as output MainPort (ComponentList : Cl_p2); // properties call (p1_out.h) = penth_mol (p1_out.T, p1_out.p, p1_out.z) p1_out.ComponentList; call (p2_out.h) = penth_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)
PresenterPresentation NotesI know the dialogs are from 10.0 -- so what?
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 simpledist nstages as integerparameter (3); feedstage as integerparameter (2); cnd as condenser; drm as drum; reb as reboiler; stage([1:nstages]) as simpletray;
model
174 2000 AspenTech. All Rights Reserved. ACM intro
Syntax for the declaration of the port connectivity
MODEL simpledist ... feed as input processport; dist as output processport; rebo as output processport; link feed and stage(feedstage).feed; link dist and drm.out2; link rebo and reb.liq_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 stage(1).vap_ou AND cnd.vap_in; CONNECT stage(1).liq_ou AND stage(2).liq_in; CONNECT stage(1).liq_in AND drm.out1; CONNECT stage(1).vap_in AND stage(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 // internal streams connect stage(1).vap_ou and cnd.vap_in; connect cnd.liq_ou and drm.liq_in; connect stage(1).liq_in and drm.out1; for i in [2:nstages] do connect stage(i-1).liq_ou and stage(i).liq_in; connect stage(i-1).vap_in and stage(i).vap_ou; endfor connect stage(nstages).liq_ou and reb.liq_in; connect stage(nstages).vap_in and reb.vap_ou;
PresenterPresentation NotesNote that the feed port for the stage has to have some automatic specification like below to avoid hunting for missing specs.MODEL stage liq_in as input Fport; vap_in as input Fport; liq_ou as output Fport; vap_ou as output Fport; feed as input Fport;
liq_in.F + vap_in.F + feed.F = liq_ou.F + vap_ou.F; liq_ou.F = vap_ou.F;
if not feed.isconnected then feed.F : fixed; feed.F : 0; endifEND
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; // block AS model block.variable1 = variable2; block.parameter3 : parameter4; // some equation $variable5 = exp(-block.variable6/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
PresenterPresentation NotesJust a comment if user is concerned about this lots of variables and equations. The equivalence will get compress these equations and variables, so at the end there is no penalty in using the submodel. Use submodel to make your models more modular.
179 2000 AspenTech. All Rights Reserved. ACM intro
Heat Exchanger example
Flow pattern (counter current)
1 2 3
3 2 1
Q Q Q
PresenterPresentation NotesAnother example -- see the file htx.amcf for all the details.
180 2000 AspenTech. All Rights Reserved. ACM intro
Heat Exchanger example MODEL htx h_in as input fthcpPort; h_out as output fthcpPort; c_in as input fthcpPort; c_out as output fthcpPort; // modeling a counter-current heat exchanger n as integerparameter (3); ns as integerset ([1:n]); h_cell (ns) as cell; c_cell (ns) as cell; // see next slides ...
181 2000 AspenTech. All Rights Reserved. ACM intro
Heat Exchanger example
MODEL htx ... // linking model ports with sub-model ports link h_in and h_cell(1).p_in; link h_out and h_cell(n).p_out; link c_in and c_cell(1).p_in; link c_out and c_cell(n).p_out; ...
182 2000 AspenTech. All Rights Reserved. ACM intro
MODEL htx ... // internal heat stream q_intern (ns) as QTAstream; for i in ns do connect h_cell(i).q_out and c_cell(n-i+1).q_in with q_intern(i); endfor ...
Heat Exchanger example
Internal heat streams using stream type "QTAstream"
183 2000 AspenTech. All Rights Reserved. ACM intro
... // internal material stream h_cell_out (ns - [n]) as fthcpStream; for i in ns - [n] do connect h_cell(i).p_out and h_cell(i+1).p_in with h_cell_out(i); endfor c_cell_out (ns - [n]) as fthcpStream; for i in ns - [n] do connect c_cell(i).p_out and c_cell(i+1).p_in with c_cell_out(i); endfor
Heat Exchanger example
Internal material streams using stream type "fthcpStream"
184 2000 AspenTech. All Rights Reserved. ACM intro
VIRTUAL and EXTERNAL
Model AverageValue VIRTUAL ValueType USES RealVariable; NValues as external IntegerParameter; Value([1:NValues]) as external RealVariable; Average as ValueType; Average = sigma(Value)/NValues; End
Model Pipe NSections as integerParameter; T([1:NSections]) as Temperature; // Use submodel to calculate average T_Av as AverageValue(NValues is NSections, Value is T, ValueType is Temperature); Q = U * WallArea * (T_Wall - T_Av.Average); 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
PresenterPresentation NotesCB: Archived snapshots are binary files stored in a directory named with the name of the open ACM file. Can we control where these directories are stored or are they always stored in the working folder?No.
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
PresenterPresentation Noteslimitation: it is not the only limitation. Should we put this in instrruction notes because it will change (maybe, but when?) Or may be a list of known issues as appendix (this list is not available) or do the same as AP10 (what do we do for AP10, not document?)
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 tk1 active wait tk2 active done ...
PresenterPresentation NotesCB. Can you write a few tips to comment this slideThis is to show that when we run ACM we have in fact 3 programs running: the gui, the simulation server (the number cruncher) and the special guest of this section, the task server or manager (not sure about its name). So we know that the GUI talks to the sim server and back. The tasks that we define in the GUI are being sent to the task manager. It then says in the simulation messages what is going on, talks to the sim server to step to the time events and locate the implicit events. It maintains some sort of table of tasks, which can be active or not, and executed.
198 2000 AspenTech. All Rights Reserved. ACM intro
Event driven task
Syntax:
Condition: time == value expression1 >, =,
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)
task xmp runs when level > lev_alarm
time
level
lev_alarm
201 2000 AspenTech. All Rights Reserved. ACM intro
Tasks
"ONCE" qualifier
task bursting runs once when p > p_burst
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 TIME == 4.0 // Flow changes to 5.0 linearly // over a period of 2 time units RAMP (Input1.flow, 5.0, 2.0, continuous); // Temperature changes with an S-shaped curve // to 15.0 over a period of 3 time units SRAMP (Input1.temp, 15.0, 3.0); Input2.FlowX("water") : 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 (variable, finalvalue, duration, discrete);
RAMP (variable, finalvalue, duration, continuous);
SRAMP (variable, finalvalue, duration, discrete);
SRAMP (variable, finalvalue, duration, continuous);
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 Time == 10.0 CREATE SNAPSHOT "Task-Created Snapshot #1"; END
TASK Test3 RUNS WHEN Time == 1.0 PRINT "Start Task Test3"; RAMP (Input1.Flow, 2.5, 5.0); PRINT "Task Test3 Finished"; 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
WAIT FOR condition;
// wait for 2 hours from now WAIT 2.0; // start feed S34.F : 400; // wait now for 1 hour WAIT 1.0; // stop the feed S34.F : 0;
207 2000 AspenTech. All Rights Reserved. ACM intro
Task execution : RESTART WHEN
RESTART WHEN condition;
Example: $y = x - y
x
Time Hours0 1 2 3 4 5 6 7 8 9 10
B1.
x B
1.y
0.5
11.
52
2.5
33.
54
Task res runs when time == 1 // step change of x B1.x : 4; // wait 2 units of time wait 2; B1.x : 0; restart 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 ( ParameterList ) TaskStatements end
CALL TaskName (ParameterList);
PresenterPresentation NotesTask language is another world... It uses a ";" to separate the arguments. It is so odd... I don't mention it because I secretly hope that the language will be improved before users go in these arcanes... (and I am not the only one to do so, the help does not mention more...)
209 2000 AspenTech. All Rights Reserved. ACM intro
Callable task example
Flowsheet tasks: Task dorecipe runs when time == 0.5 final_x as realparameter; final_x : 10; call recipe (final_x); End
pt
Time Hours0 1 2 3 4 5 6 7 8
B1.y
B1.x1
510
15
Task recipe (x as realparameter) B1.x : 3; wait for time == 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 TIME == 1.25 PARALLEL CALL P1; // a ramp with duration=2 CALL P2; // another ramp with duration=1 ENDPARALLEL; Input4.Flow : 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
PresenterPresentation Notes"They" (you know who I mean) say this is because the snapshot is taken after the task does its job, but I say this is a flaw in the design of snapshots and tasks. Like it or not, the snapshot is flagged as non-converged. (I don't like it).
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
PresenterPresentation NotesGear locates the event. The difference is small. Note : strongly advise making the communication interval small. To me, this is a defiency, but the reason is that we have worked to improve the efficiency (at the expense of the user friendliness)
2000 AspenTech. All Rights Reserved.
Workshop
2000 AspenTech. All Rights Reserved.
Procedures
PresenterPresentation NotesThe procedures are used to interface ACM with external code, like a fortran subroutine. The presentation is split in two sections: first we show how to use an existing procedure. This case is important, as physical properties can be evaluated using the Properties Plus procedures. The next section covers how to create a new procedure.
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
PresenterPresentation Notesworking directory = my simulations\problem_namethat is really for short term kludge....
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
PresenterPresentation NotesCB: What do we mean by wrapper?That's the stuff to get ACM call to a FORTRAN subroutine to work properly (ie ACM is in C++ so some pointer casting is required). Nothing worth worrying about.
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
PresenterPresentation NotesCB: Name of the DLL with the corresponding pathUnless the dll is in your path. Note that things are more involved in client-server???
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 af