MP Example Files

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs ➔ Model Procedures ➔ MP Example Files

Model Procedures MP Example Files

Related Links: Example PGM Files, Example Model Procedure Files, Evaluation Blocks

Example projects using MP file: Demo Nickel Copper Project, Model Procedure Example


Model Procedure Example: Tank Volume

EXAMPLE MP FILE SysCAD ACCESS WINDOW
;EXAMPLE MODEL PROCEDURE SUBROUTINE
PageLabel("TankVolume")
  TextLabel()
  real ResidenceTimeReqd*("Time", "h")<<1>>
  real [email protected]("Qv", "m^3/h"){Comment("Slurry Only")}
  real [email protected]("Qv", "m^3/h"){Comment("Slurry Only")}
  real [email protected]("Vol", "m^3"), [email protected]("Vol", "m^3")
; ------------------------------------------------------------
Sub MP_TerminateSolution()
  Feed_Flowrate = ["QFeed.SLQv (m^3/h)"]
  Prod_Flowrate = ["QProd.SLQv (m^3/h)"]
  VolumeReqd = Max(Feed_Flowrate, Prod_Flowrate) * ResidenceTimeReqd
  Design_Volume = Roundup(VolumeReqd, 0)
  ["ResTime.Volume (m^3)"] = Design_Volume
EndSub
; ------------------------------------------------------------
$ ; --- end of file ---

MP EXAMPLE TankVol.png

Model Procedure Example: Set Demand Flow as Volume Flow

EXAMPLE MP FILE SysCAD ACCESS WINDOW
;EXAMPLE MODEL PROCEDURE SUBROUTINE
PageLabel("VolFlow")
  TextLabel()
  real VolFlowReqd*("Qv", "m^3/h")
  real [email protected]("Qm", "t/h")
  real [email protected]("Rho", "t/m^3")
; ------------------------------------------------------------
Sub MP_Eval_Before()
  ;--Convert volume flow to mass flow
  Density = Max(0.9, ["Qo.Rho (t/m^3)"])
  MassFlowReqd = VolFlowReqd * Density
  ["Qm_Demand.Reqd (t/h)"] = MassFlowReqd
EndSub
; ------------------------------------------------------------
$ ; --- end of file ---

MP EXAMPLE VolDemandFlow.png

Model Procedure Example: Agitator Power

EXAMPLE MP FILE SysCAD ACCESS WINDOW
PageLabel("AgitatorPower")
TextLabel(,, " --- Power = Po * N^3 * D^5 * Density -- ",)
memo AgDesc*
TextLabel()
real   Po{i, comment("dimensionless power number")} <<1>>
real   N{i, comment("Rotation per second")}<<0.3>>
real   D{i, ("L", "m"), comment("ImpellerDiameter")}<<1>>
real   [email protected]("Rho", "kg/m^3")
real   [email protected]("Pwr", "kW")

Sub MP_TerminateSolution()
  Density = ["QProd.SLRho (kg/m^3)"]
  Power = Po * N^3 * D^5 * Density
EndSub
; ------------------------------------------------------------
$ ; --- end of file ---

MP EXAMPLE AgitatorPower.png

Model Procedure Example: Pipe Sizing

The following example shows the use of Global User Defined Variables, located on the Plant Model access window, Project Tab. To make use of these variables, user can use the Predefined Plant Model Class to read in the values.

EXAMPLE MP FILE SysCAD ACCESS WINDOW
;EXAMPLE MODEL PROCEDURE SUBROUTINE

;--- Define Subroutine ---
PageLabel("Pipe Sizing")
TextLabel()
REAL	[email protected]("Qv", "m^3/s")
TextLabel(,"----User Defined Global Values - PlantModel - Project Tab")
REAL	VapourDesign_Vel*("Ldt", "m/s")
REAL	LiquidDesign_Vel*("Ldt", "m/s")
REAL	SlurryDesign_Vel*("Ldt", "m/s")
TextLabel(,"----For intermittent flows, Vol_Flow is", 
           "    the normalised flow over 24 hours.",  
	   "    to calculate the instantaneous flowrate,", 
           "    state the operating hours per day----",)
REAL	OperatingHoursPerDay*("Time", "h")
REAL	[email protected]
REAL	[email protected]("Qv", "m^3/s")
TextLabel()
STRING	[email protected]
TextLabel()
REAL	[email protected]("Ldt", "m/s")
REAL	[email protected]("L", "mm")
REAL	[email protected]("L", "mm")

;Local Variables
Real	Pipe_Vf, Pipe_Lf

Sub MP_TerminateSolution()
   ;Getting design velocities from the Plant Model Class - User Defined Global Values. 
	VapourDesign_Vel = PM.PUV(4)
	LiquidDesign_Vel = PM.PUV(5)
	SlurryDesign_Vel = PM.PUV(6)

	Pipe_Vf = Get("Qo.Vf (%)")
	Pipe_Lf = Get("Qo.Lf (%)")
		
	If Pipe_Vf > 50
		Design_Vel = VapourDesign_Vel
		Pipe_Type = "Vapour Line"
	Elseif	Pipe_Lf > 90
		Design_Vel = LiquidDesign_Vel
		Pipe_Type = "Liquid Line"
	Else
		Design_Vel = SlurryDesign_Vel
		Pipe_Type = "Slurry Line"
	Endif	

	intermittent_Factor = 24/OperatingHoursPerDay  		
	Vol_Flow = Get("Qv (m^3/s)")
	DesignFlow = Vol_Flow * intermittent_Factor
	Diameter = sqrt(4 / PI * DesignFlow / Design_Vel) * 1000
	Design_Diameter = Roundup(Diameter, -1)
EndSub		

$ ; --- end of file ---

MP EXAMPLE 2.png

Model Procedure Example: Thickener

;EXAMPLE MODEL PROCEDURE SUBROUTINE
 
TextLabel("Requirements")
REAL RqdUFSolids*("Frac", "Frac")<0.001, 0.99>
REAL RqdOFSolids*("Frac", "Frac")<0, 0.5>
REAL SolidsFeed, LiquidsFeed
REAL SolidstoUF, LiquidstoUF, SolidstoOF, LiquidstoOF
REAL FracSolidstoUF, FracLiquidstoUF
TextLabel("Results")
REAL [email protected]("Frac", "Frac")
REAL [email protected]("Frac", "Frac")
REAL [email protected]("Frac", "Frac")
 
; --- procedure declarations ---
Sub MP_Eval_AfterEB()
; calculate the massfrac split of solids and liquids to underflow
   SolidsFeed = Get("QFeed.SQm (kg/s)")
   LiquidsFeed = Get("QFeed.LQm (kg/s)")
   SolidstoUF = 0.0
   if (SolidsFeed > 0.001)
     SolidstoUF = Range(0.0, (SolidsFeed*(1.0-RqdOFSolids) - RqdOFSolids*LiquidsFeed)/(1.0-RqdOFSolids - RqdOFSolids/RqdUFSolids*(1.0-RqdUFSolids)), SolidsFeed)
   endif
   LiquidstoUF = Range(0.0, SolidstoUF * (1.0-RqdUFSolids)/RqdUFSolids, LiquidsFeed)
   FracSolidstoUF = iif(SolidstoUF > 0.001, SolidstoUF/SolidsFeed, 0.0)
   FracLiquidstoUF = iif(LiquidstoUF > 0.001, LiquidstoUF/LiquidsFeed, 0.0)
 	
; Split to UF:
   Set("GM.IOs.[P_003].Splt.Solids (%)", FracSolidstoUF * 100)
   Set("GM.IOs.[P_003].Splt.Liquids (%)", FracLiquidstoUF * 100)
; send all gases to overflow
   Set("GM.IOs.[P_003].Splt.Gasses (%)", 0)
EndSub	
; ------------------------------------------------------------

Sub MP_Eval_After()
; calculate some results
   SolidstoOF = SolidsFeed - SolidstoUF
   LiquidstoOF = LiquidsFeed - LiquidstoUF
   UFSolids = iif((SolidstoUF + LiquidstoUF) > 0.001, SolidstoUF / (SolidstoUF + LiquidstoUF), 0)
   OFSolids = iif((SolidstoOF + LiquidstoOF) > 0.001, SolidstoOF / (SolidstoOF + LiquidstoOF), 0)
   UFSolRec = FracSolidstoUF
EndSub		
 
$ ; --- end of file ---