Example Class - Check Elemental Balance of a Process Unit Operation
Jump to navigation
Jump to search
Navigation: PGMs ➔ Example PGM Files ➔ Check Elemental Balance
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: 17 May 2022 - SysCAD 9.3 Build 139.30918
Related Links: PGM Classes, PGM Functions
Example Class to Check Elemental Balance of a Process Unit Operation
; ---- Define the CLASS and its Functions ---- Class UnitElemMB TextLabel() String UnitName{Tag} String Element*{Comment("If unspecified, defalut to 'O' for Oxygen")} String Stream, FlowTag Real [email protected]("Qm", "kg/h"), [email protected]("Qm", "kg/h") Real [email protected]@("Qm", "kg/h"), TotFlow integer Count, [email protected]@, [email protected]@, i Checkbox [email protected] StrFunction GetStreamName(integer i, String InOrOut) if IsEmpty(Element) element = "O" Endif return [Concatenate(UnitName,".Links.",InOrOut,".[",IntToStr(i),"].Flange")] EndFunct Function GetFlow(String InOrOut) Count = [Concatenate(UnitName,".Links.",InOrOut,".Count")] TotFlow = 0.0 i = 0 while (i < Count) Stream = GetStreamName(i,InOrOut) FlowTag = Concatenate(Stream,".Qo.QEl.",Element," (kg/h)") TotFlow = TotFlow + [FlowTag] i = i + 1 EndWhile return TotFlow EndFunct Sub CalculateBalance() FlowIn = GetFlow("In") inCount = Count FlowOut = GetFlow("Out") outCount = Count MassDiff = FlowOut - FlowIn ElemBal_OK = iif(Abs(MassDiff) < 0.00001, 1, 0) EndSub EndClass ; ---- Using the Class ---- PageLabel(ElemBal) ; Define the required number of Elemental Balance Calculations UnitElemMB Element_balance[6] integer j ; Perform the Elemental Balance Calculations at the end of project solve Sub TerminateSolution() j = 0 while (j < 6) Element_balance[j].CalculateBalance() j = j + 1 EndWhile EndSub $ |
Example General Controller results for the Nickel Copper Demo Project. ![]() |
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.