PGM Example - Set Bed Slurry Volumetric Flow in TCE Pond using TCE Density

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs ➔ Example PGM Files ➔ Set Pond Bed Slurry Volumetric Flow using TCE Density Basis

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, Defining a Function


Example Class to Control Bed Level in a TCE Pond using TCE Density as a basis

This PGM class can be used to set the pond bed flowrate from a TCE Pond using density calculated by the TCE. This is useful for controlling the pond level based upon bed height in the pond, where the user wishes to use the densities predicted by the TCE.

Similar logic could be implemented with the TCE tank. This is intended to show the general methodology for controlling flow using volume calculated by TCE.

class Class_SetTCEBedVolumetricFlow

	;string variables for tags, not seen by user
	string SolDensTag, AqDensTag, BedSolFracTag
	string BedFlowTag, TotVolTag, BedMassTag

	;variables exposed to user
	real Qv_Reqd*("Qv","m3/s")<0,>	;don't allow this below zero
	real BedDensity@("Rho","kg/m3")
	real BedMassFlowRate@("Qm","kg/s")
	real BedLevel@("Frac","Frac")

	sub PreInitialise()
		;ensure bed is set to composition control
		if ([concatenate(ClassTag(),".Bed.Filter")] <> 4)
			LogError("Pond bed filter must be set to composition.  Set to composition and then set the bed solids composition")
			StopSolver()
		endif
		;ensure that bed outlet is in mass flow control
		[concatenate(ClassTag(),".Bed_Out.CapacityControl")] = 1 ;by mass flow
	EndSub

	sub Initialise()
		SolDensTag = concatenate(ClassTag(),".TCE.Prod.SolRho (kg/m^3)")
		AqDensTag = concatenate(ClassTag(),".TCE.Prod.AqRho (kg/m^3)")
		BedSolFracTag = concatenate(ClassTag(),".Bed.Composition.Sf (Frac)")
		BedFlowTag = concatenate(ClassTag(),".Bed_Out.Qm.Capacity (kg/s)")
		TotVolTag = concatenate(ClassTag(),".Capacity.Volume (m^3)")
		BedMassTag = concatenate(ClassTag(),".BedLayer.Mt (kg)")
	EndSub

	Function CalcBedDensity()
		double BedSolFrac
		BedSolFrac = [BedSolFracTag]
		BedDensity =  1.0 / (BedSolFrac / max([SolDensTag],1e-10) + (1.0-BedSolFrac) / max([AqDensTag],1e-10))
		Return BedDensity
	EndFunct

	Function GetLevel()
		Return [BedMassTag] / CalcBedDensity() / max([TotVolTag],1.0e-10)
	EndFunct

	sub Execute()
		BedLevel = GetLevel()
	EndSub

	sub StartFlow()
		;calculate density of the bed

		;calculate equivalent mass flow from desired volumetric flow and TCE bed density
		BedMassFlowRate = Qv_Reqd * CalcBedDensity()	;m3/s * kg/m3 = kg/s
		[BedFlowTag] = BedMassFlowRate
	EndSub

	sub StopFlow()
		[BedFlowTag] = 0
	EndSub

EndClass

;-----------------------------------------------------
;Using the Class_SetTCEBedVolumetricFlowClass in the project
;Declare the class instances, here we are using the names of the TCE-enabled unit operations.
PageLabel "Pond Bed Flow Control" 
    TextBreak
    Class_SetTCEBedVolumetricFlow Pond_1, Pond_2, Pond_3

Sub PreStart()
    ;This initialises tag names for Bed Volume and flow calculations for all the class instances
    ForEachSub(Class_SetTCEBedVolumetricFlow, Initialise())
EndSub

Sub InitialisePreStart()
    ;This initialises tag names for Bed Volume and flow calculations for all the class instances
    ForEachSub(Class_SetTCEBedVolumetricFlow, PreInitialise())
EndSub

;in the part of the code executed every step, you can optionally call this

ForEachSub(Class_SetTCEBedVolumetricFlow, Execute())

;elsewhere in the code, you can use GetLevel(), StartFlow(), StopFlow() of the class to manage bed level using the density predicted by TCE as a basis for volume-based calculations

$