Bayer Liquor Class

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs ➔ Example PGM Files ➔ Bayer Liquor Class

SysCAD Pre-Defined Classes and Examples EXAMPLES: User Defined Classes
Sp Databse
Class
PSD
Class
Array
Class
StrArray
Class
Matrix
Class
Tag Select
Class
Plant Model
Class
Noise
Class
Time
Class
Agitator
Power
Reaction
Finder
Aq Feed Conc
Calculator
Evaporation
Correlation
Bayer Liquor
Class
Check
Element Bal

Latest SysCAD Version: 26 October 2022 - SysCAD 9.3 Build 139.31866

Related Links: PGM Classes, PGM Functions, Alumina 3 Bayer Species Model, Bauxite Composition Example

NOTE: This example shows both the class definition and the use of Class in the same PGM file. In general, if the Class is useful for multiple PGM file or can be re-used, it is best to store the class definition in a separate file (eg: Gerenal_Class.pgm). The class definition can then be inserted into a PGM file using the include file syntax. (eg: >>General_Class.pgm) Please see Sharing Classes between Projects for more information on how to include the class definition into a pgm file.


;--- SysCAD General Controller (PGM) program logic file ---
; Revision: 3     Date:May 2016    Author:Kenwlat Updated to SysCAD 93 format

;=================================================================================
;                         DEFINING SUB ROUTINES                              
;================================================================================= 
Class BayerLiquor

;-----DEFINE Bayer Liquor VARIABLES--------------------------------------------
TextLabel("  -------------------") 
STRING StreamTagName{Tag}, MyTag, Liquor, Water
STRING NaAlOH4, Na2C2O4, Na2C5O7, Na2CO3, Na2SO4, NaCl, NaOH, Na2SiO3, Temp
REAL   TNa, TAl2O3, TNaOH, Density_25("Rho","kg/m^3")@
REAL   Density_T("Rho","kg/m^3")@, T("T","dC")
REAL   A("Conc","g/L")@, C("Conc","g/L")@, S("Conc","g/L")@, A_C@, C_S@ 

;----SUBROUTINE TO INITIALISE Tags----------------------------------------------
Sub InitTag()
 MyTag = StreamTagName
 Liquor   = Concatenate(MyTag, ".Qo.Liquids (kg/s)")
 Water    = Concatenate(MyTag, ".Qo.QM.H2O(l) (kg/s)")
 NaAlOH4  = Concatenate(MyTag, ".Qo.QM.NaAl[OH]4(aq) (kg/s)")
 Na2C2O4  = Concatenate(MyTag, ".Qo.QM.Na2C2O4(aq) (kg/s)")
 Na2C5O7  = Concatenate(MyTag, ".Qo.QM.Na2C5O7(aq) (kg/s)")
 Na2CO3   = Concatenate(MyTag, ".Qo.QM.Na2CO3(aq) (kg/s)")
 Na2SO4   = Concatenate(MyTag, ".Qo.QM.Na2SO4(aq) (kg/s)")
 NaCl     = Concatenate(MyTag, ".Qo.QM.NaCl(aq) (kg/s)")
 NaOH     = Concatenate(MyTag, ".Qo.QM.NaOH(aq) (kg/s)")
 Na2SiO3  = Concatenate(MyTag, ".Qo.QM.Na2SiO3(aq) (kg/s)")
 Temp     = Concatenate(MyTag, ".T (dC)")
EndSub
 
;----SUBROUTINE - DENSITY @ 25 dC------------------------------------------------
 Sub Density25()
   TAl2O3     = [NaAlOH4]*(MW("Al2O3(s)")/(2*MW("NaAl[OH]4(aq)")))*100/[Liquor]  
   TNaOH      = ([NaOH]*MW("Na2CO3(aq)")*0.5/MW("NaOH(aq)"))  
                + ([NaAlOH4]*0.5*MW("Na2CO3(aq)")/MW("NaAl[OH]4(aq)"))
   TNa        = ([Na2CO3] + TNaOH + ([Na2C2O4]/MW("Na2C2O4(aq)") + [Na2C5O7]/MW("Na2C5O7(aq)")
                + [NaCl]*0.5/MW("NaCl(aq)") + [Na2SO4]/MW("Na2SO4(aq)") + [Na2SiO3]/MW("Na2SiO3(aq)") )
                * MW("Na2CO3(aq)") ) * (100 / [Liquor])

   Density_25  = (0.982 + (0.01349855 * TNa) + (-0.00024948 * TNa * TNa) + 
                 (0.00000273* TNa * TNa * TNa) + (0.00208035* TAl2O3)+ 
                 (0.00004113* TAl2O3 * TAl2O3) + (-0.00000728* TAl2O3 * TAl2O3 * TAl2O3)+
                 (0.00033367* TNa * TAl2O3))*1000
 EndSub

;----SUBROUTINE - DENSITY @ Temp ------------------------------------------------
 Sub DensityT()
    T  = [Temp]
    Density_T  = Density_25 * (1 - (0.0005021858*0.85*(T-25))-(0.0000011881*0.85*(T-25)*(T-25)))
 EndSub

;----SUBROUTINE - Concentration ------------------------------------------------
 Sub Conc()
    A    = [NaAlOH4]*(MW("Al2O3(s)")/(2*MW("NaAl[OH]4(aq)"))) / [Liquor] * Density_25
    C    = TNaOH / [Liquor]* Density_25
    S    = [Na2CO3] / [Liquor] * Density_25 + C
    A_C  = A/C
    C_S  = C/S
 EndSub

;----SUBROUTINE - EXECUTE SUBROUTINES ---------------------------------------------
 Sub Exec()
    Density25()
    DensityT()
    Conc()
 EndSub
  
EndClass
 
;=================================================================================
; DEFINING EQUIPMENT IN THE PROJECT
;=================================================================================
;Example of Defining Classes individually
 PageLabel("Example1")
 BayerLiquor Pipe1, Pipe2, Pipe3, Pipe4
 
;Example of Defining Classes with an Array 
 PageLabel("Example2")
 BayerLiquor  Pipe[5]
 ExcludeWatch Pipe[0]

;=================================================================================
; DEFINING LOGIC IN THE PROJECT
;=================================================================================
 
Sub InitialiseSolution()
 ;------Initialise Tag Name(s)---------
   Pipe1.InitTag()
   Pipe2.InitTag()
   Pipe3.InitTag()
   Pipe4.InitTag() 
 ;Example of calling functions from classes defined with an array.
   pipe[1].initTag()
   pipe[2].initTag()
   pipe[3].initTag()
   pipe[4].initTag()
EndSub
 ;-------Executing Functions--------
   Pipe1.Exec()
   Pipe2.Exec()
   Pipe3.Exec()
   Pipe4.Exec()
 ;Example of calling functions from classes defined with an array.
   pipe[1].Exec()
   pipe[2].Exec()
   pipe[3].Exec()
   pipe[4].Exec()
;=================================================================================
ENDFILE
;=================================================================================

BayerClass1.png

BayerClass2.png