1. Proprietary Information of Albemarle Corporation.
Using User Variables,
Scripts & Triggers
Alan Kramer
Global FCC Modeling Specialist
KBC Software User Group Conference
2018
Houston
2. Proprietary Information of Albemarle Corporation.
• Often we receive data with poor flue gas analysis.
• This leads to bad values for Hydrogen in Coke.
• For “simple” situations, we can use an equation to estimate the flue gas analysis to
give a reasonable H in Coke.
• For “complex” situations, we have to manually iterate each calibration case
individually for the flue gas estimate to give a reasonable H in Coke.
• We want to add H in Coke as an independent variable in calibration mode.
• We want the model to solve for the flue gas analysis.
The Problem
2
3. Proprietary Information of Albemarle Corporation.
• Create a user variable to hold the H in Coke target value.
– This can be input from Calibration Input
• Create a user variable script to calculate the flue gas CO2.
• Use triggers to start the script calculation.
• Use triggers to iterate the CO2 calculation until the H in Coke target is met.
The Solution
3
4. Proprietary Information of Albemarle Corporation.
Logic Schematic
4
Flue Gas CO2
H Content of Coke Stream
FCC
5. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
5
Flue Gas CO2
H Content of Coke Stream
FCC
6. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
Flue Gas CO2
H Content of Coke Stream
FCC
HinC Target
8. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC Script
Flue Gas CO2
H Content of Coke Stream
FCC
HinC Target
9. Proprietary Information of Albemarle Corporation.
Creating User Variables With Embedded Scripts
9
Type script here
10. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC Script
Flue Gas CO2
H Content of Coke Stream
FCC
HinC Target
12. Proprietary Information of Albemarle Corporation.
VB Script Hints
12
• All script variables are variant type
• No script variable declarations
– You do need to declare arrays with dimensions
• If a variable in a script refers to an object, you must SET it
• No GOTO, GOSUB, EXIT or END
– Handle this with (nested) IF blocks and lots of planning
– But you can have multiple functions in a single script
• Empty = -32767
13. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2
H Content of Coke Stream
FCC
15. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2
H Content of Coke Stream
FCC
17. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2
H Content of Coke Stream
FCC
HinC Current Error
19. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2
H Content of Coke Stream
FCC
HinC Current ErrorIf ~0 then stop
21. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2
H Content of Coke Stream
FCC HinC Stored Error
HinC Current Error
23. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error
H Content of Coke Stream
FCC
HinC Current ErrorIf = then stop
25. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error
H Content of Coke Stream
FCC
HinC Current Error
27. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error
H Content of Coke Stream
FCC T
28. Proprietary Information of Albemarle Corporation.
Setting Trigger to Solve Parent Object on Value Change
28
29. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error
H Content of Coke Stream
FCC T
30. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error
H Content of Coke Stream
FCC T
31. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
H Content of Coke Stream
Trigger 3
FCC
Value
33. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
H Content of Coke Stream
Trigger 3 T
FCC
34. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
Trigger 1
H Content of Coke Stream
Trigger 3 T
FCC
Value
35. Proprietary Information of Albemarle Corporation.
Setting Trigger to Solve Parent Object on Value Change
35
36. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
Trigger 1 T
H Content of Coke Stream
Trigger 3 T
FCC
37. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
37
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
Trigger 1 T
H Content of Coke Stream Trigger 2 T
Trigger 3 T
FCC
Compare
If different take on a random value
between 0 and 1
39. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
39
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
Trigger 1 T
H Content of Coke Stream Trigger 2 T
Trigger 3 T
FCC
40. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
40
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
Trigger 1 T
Trigger on Calib Start TH Content of Coke Stream Trigger 2 T
Trigger 3 T
FCC
41. Proprietary Information of Albemarle Corporation.
Setting Trigger to Run Script on Calibration Starting
41
42. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
42
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
Trigger 1 T
Trigger on Calib Start TH Content of Coke Stream Trigger 2 T
Trigger 3 T
FCC
-1
43. Proprietary Information of Albemarle Corporation.
Setting Trigger to Solve Parent Object on Value Change
43
44. Proprietary Information of Albemarle Corporation.
FCC-MeterFCC Coke-Meter
Logic Schematic
44
HinC TargetHinC Script
Flue Gas CO2 HinC Stored Error T
Trigger 1 T
Trigger on Calib Start TH Content of Coke Stream Trigger 2 T
Trigger 3 T
FCC
45. Proprietary Information of Albemarle Corporation.
• User variables and scripts aren’t really difficult or scary.
• You can use user variables and scripts to add important functionality.
• The ‘simplicity’ of VB Script has advantages and drawbacks.
• Triggers take some practice and patience to set up correctly.
• Save often. It’s easy to create infinite calculation loops.
• VB Script syntax examples on following slides.
Conclusions
45
46. Proprietary Information of Albemarle Corporation.
• Create a variable referencing an object in the flowsheet
Set CokeMeter = SimulationCase.GetObjectInCase("FCC Coke-Meter")
• Create a variable referencing a variable in a meter
Set HinCVariable = CokeMeter.ActiveDataSet.Variables.Find("Hydrogen Content", "")
• Store the value from the ‘screened’ column of a meter using a specific unit of
measure
HinC = HinCVariable.ScreenedValueWithUnits("wt %")
• Put a value into the ‘input’ column of a meter
HinCVariable.InputValue = 7
VB Script Syntax Examples
46
47. Proprietary Information of Albemarle Corporation.
• Get a user variable value from the same parent object
ThisScriptVariable = Me.GetUserVariable(“OtherUserVar").Variable.Value
• To set the value of a user variable value, flip the above statement around
• Get a user variable value with a specific UOM from another object (cokemeter)
ThisScriptVariable = CokeMeter.GetUserVariable(“OtherUserVar").Variable.GetValue(“UOM”)
• Set the value of the current user variable to xxx
Result = xxx
• Send something to the trace window
Application.Trace “Something = " & Something, True
VB Script Syntax Examples
47