PGM Example - Calculate Boiling Point Elevation Using TCE

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs ➔ Example PGM Files ➔ Calculate Boiling Point Elevation Using TCE

Example User Defined Classes
Set Species Splits Agitator
Power
Reaction
Finder
Aq Feed Conc
Calculator
Evaporation
Correlation
Bayer Liquor
Class
Check
Element Bal
Optimise Controllers
for sensitive PIDs
Relaxed Cross Page Connector Calculate BPE
using TCE
Set Pond Bed Slurry
Volumetric Flow using
TCE Density Basis

Related Links: Defining a Class


NOTE: Some PGM functions used by this example requires Build 139.32350 or later.

PGM Example - Calculate Boiling Point Elevation Using TCE

This example file calculates the boiling point elevation of water given the activity of water as predicted by a TCE-enabled unit operation. It is useful for more accurate estimation of boiling point elevation for water evaporation.

Warning: this is only suitable when water is the ONLY volatile species.

Class Class_CalcBPE
    ClassAsTextLabel
    TextBreak
    string  UnitName@{Tag}, aw_Tag, BPE_Tag, P_Tag
    integer SteamIdx
    Real    Tsat_Pure@("T","K")
    Real    aW@{Comment("TCE Water Activity")}
    Real    Psat@("P","kPa")
    Real    BPE@("dT","K")
    TextBreak
  
    Sub Initialise(bool SetBPEMethodToUser)
        UnitName = ClassTag()
        SteamIdx = SDB.FindSpecies("H2O(g)")
        P_Tag    = concatenate(UnitName,".Prod.P (kPa)")
        aw_Tag   = concatenate(UnitName,".Prod.WaterActivity")
        BPE_Tag  = concatenate(UnitName,".VLE.BPE.User (K)")
        if (SetBPEMethodToUser)
          [concatenate(UnitName,".VLE.BPE.Method")] = 2 ; set BPE.Method to User for VLE
        endif
    EndSub

    Sub CalcBPE()
        ;Warning: this is only suitable when water is the ONLY volatile species.
        Psat = [P_Tag]
        Tsat_Pure = SDB.SpVapourT(SteamIdx, Psat)

        ;protect from being zero values
        aW = max([aW_Tag], 1e-5)

        ;calculate BPE
        BPE = SDB.SpVapourT(SteamIdx, Psat/aW) - Tsat_Pure
    EndSub

    Sub UpdateBPE()
        CalcBPE()
        ;Set BPE to be used by VLE in the TCE unit model
        [BPE_Tag] = BPE
    EndSub

EndClass
;-----------------------------------------------------
;Using the CalcBPE Class in the project
;Declare the class instances, here we are using the names of the TCE-enabled unit operations.
PageLabel "BPE Calculations" 
    TextBreak
    Class_CalcBPE Evaporator_1, Evaporator_2, Evaporator_3, Evaporator_4

;Initialise the tags
Sub PreStart()
;This initialises tag names for BPE calculation for all the class instances, and set the BPE Method to User
    ForEachSub(Class_CalcBPE, Initialise(true))
EndSub  

;Do the BPE calculation based upon the water activity, this is done at each iteration
    ForEachSub(Class_CalcBPE, UpdateBPE())

$