How to perform an Overall Mass Balance

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs ➔ Example PGM Files ➔ Steady-State Mass Balance

Simple Examples Subroutines Examples Dynamic Examples Steady State Overall Mass Balance Array and Matrix Examples
Basic
Layout
Simple
Calculations
Initialise
PreStart
Multi-Step Trigger Checking
Project
Counter, While
and Random
Belt Filter
Wash Loss
Startup
Actions
Mass
Balance
Mass
Balance
Species
Balance
Elemental
Balance
Lookup
Value
Set
Values
Tridiagonal
System

Related Links: PGM Files using Class and Functions, TagSelect Class


Steady-State Project Overall Mass Balance

It is often important to perform an overall mass balance to account for the total inputs and total outputs. Here we will show how to obtain a quick balance of the overall mass by adding a PGM file using the TagSelect Class to sum up the total in and out and perform a balance.

The following two examples show how the Tag Select Class could be used to perform a simple mass balance in a steady-state project.

NOTES:

Example 1: Steady-State Project Mass Balance

PageLabel "MassBalance" 
TagSelect Inputs, Outputs
Array     InputFlows, OutputFlows
real      FlowIn@("Qm","t/h"), FlowOut@("Qm","t/h"), Balance@("Qm","t/h")
CheckBox  InOK@, OutOK@
 
Sub    CalcMassBalance()
  ; find all true feeders (not connected) and makeup sources 
  InOK = Inputs.Exec("([UnitType]=='FeederSink' AND ([State]==1 AND [Operation]!=11)) OR ([UnitType] == 'MakeupSource')", false, false)
  ; retrieve values of all individual inputs 
  Inputs.GetValues(".QProd.Qm (t/h)", InputFlows)
  ; sum all input flows 
  FlowIn = InputFlows.Sum()
 
  ; find all true sinks (not connected)
  OutOK = Outputs.Exec("(([UnitType]=='FeederSink' AND [State]==2) OR ([UnitType] == 'DiscardSink')  )", false, false)
  ; retrieve values of all individual outputs
  Outputs.GetValues(".QProd.Qm (t/h)", OutputFlows)
  ; sum all output flows
  FlowOut = OutputFlows.Sum()
  
  ; perform mass balance
  Balance = FlowIn - FlowOut
EndSub

Sub TerminateSolution() 
 ;--- Logic executed after last iteration (when solver is stopped)
  CalcMassBalance()
EndSub

$ ; --- end of file ---