Write models for backwards mode transition
- Last UpdatedAug 13, 2024
- 2 minute read
Simulation Builders may want to evolve simulations from Process Mode to Fluid Flow Mode to Dynamics Mode and then back to Process Mode. However, improper selection of default specification variables for each mode can lead to bad behavior when going back, which may overwrite calculated values. Saving a snapshot will help overcome this problem, but the practice documented here does not require the use of snapshots.
Example: A model with poor backwards mode transition behavior
The following set of equations represent flow through a valve with a first order lag for an actuator.
|
der(A) = ( Sig – A ) / TC |
(1) |
|
W = 2.73 * A * Cv * Y * sqrt(x * P * R) / 3600 |
(2) |
Where:
-
Sig = Signal to the controller, fraction
-
A = Current valve position, fraction
-
TC = Time Constant, seconds
The variables A and Sig have the following definition in the variables section of the Model Editor:
Name
Type
Units
Process Spec
Fluid Flow Spec
Dynamics Spec
Dynamic
A
Fraction
Fraction
State
Sig
Fraction
Fraction
x
x
x
This will only work correctly if the transition back to Process Mode is made at steady state condition when Sig is equal to A. If the transition back to Process Mode is made during transient (not at steady state) conditions, the valve Cv will be sized in Process Mode by using variable A, which will be at an arbitrary condition.
Example: A model with good backwards mode transition
Change the default specifications in Process Mode and Fluid Flow Mode so that variable A is specified rather than Sig:
|
Name |
Type |
Units |
Process Spec |
Fluid Flow Spec |
Dynamics Spec |
Dynamic |
|---|---|---|---|---|---|---|
|
A |
Fraction |
Fraction |
x |
x |
State |
|
|
Sig |
Fraction |
Fraction |
x |
In this case, the variable A used for calculating the valve Cv in Process Mode will always be the expected value set by the user.
Best practice recommendation
Use the dynamic state parameter or a variable algebraically related as the specified variable in Process Mode so that the transition back to Process Mode works even if made during a transient. Do not use variables linked through the der() function. Snapshots are not needed if this process is followed.