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 FUNCTION
PageLabel("TankVolume")
  TextLabel()
  real ResidenceTimeReqd*("Time", "h")<<1>>
  real Feed_Flowrate@("Qv", "m^3/h"){Comment("Slurry Only")}
  real Prod_Flowrate@("Qv", "m^3/h"){Comment("Slurry Only")}
  real VolumeReqd@("Vol", "m^3"), Design_Volume@("Vol", "m^3")
; ------------------------------------------------------------
Function 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
 return 0
EndFunct
; ------------------------------------------------------------
$ ; --- 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 FUNCTION
PageLabel("VolFlow")
  TextLabel()
  real VolFlowReqd*("Qv", "m^3/h")
  real MassFlowReqd@("Qm", "t/h")
  real Density@("Rho", "t/m^3")
; ------------------------------------------------------------
Function 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
  return 0
EndFunct
; ------------------------------------------------------------
$ ; --- 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   Density@("Rho", "kg/m^3")
real   Power@("Pwr", "kW")

Function MP_TerminateSolution()
  Density = ["QProd.SLRho (kg/m^3)"]
  Power = Po * N^3 * D^5 * Density
  return 0
EndFunct
; ------------------------------------------------------------
$ ; --- 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 FUNCTION

;--- Define Function ---
PageLabel("Pipe Sizing")
TextLabel()
REAL	Vol_Flow@("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	Intermittent_Factor@
REAL	DesignFlow@("Qv", "m^3/s")
TextLabel()
STRING	Pipe_Type@
TextLabel()
REAL	Design_Vel@("Ldt", "m/s")
REAL	Diameter@("L", "mm")
REAL	Design_Diameter@("L", "mm")

;Local Variables
Real	Pipe_Vf, Pipe_Lf

Function 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)
Return  0
EndFunct		

$ ; --- end of file ---

MP EXAMPLE 2.png

Model Procedure Example: Thickener

;EXAMPLE MODEL PROCEDURE FUNCTION
 
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 UFSolids@("Frac", "Frac")
REAL OFSolids@("Frac", "Frac")
REAL UFSolRec@("Frac", "Frac")
 
; --- procedure declarations ---
Function 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)
	
Return  0
EndFunct	
; ------------------------------------------------------------

Function 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
  
Return  0
EndFunct		
 
$ ; --- end of file ---