PrecipControl.pgm

From SysCAD Documentation
Redirect page
Jump to navigation Jump to search

Navigation: User Guide -> Python Automation - Getting Started -> Python Example - Optimization

Python Setup Python Examples
Installation &
Troubleshooting
Python
Utilities
Basic Usage & Scenarios Constrained FEM
(numpy|scipy|matplotlib)
Optimisation
(COM | scipy tools)
Model Testing
Framework
Dynamic
with GUI
Dynamic
External DLL
Programmatic
Model Generation
Importing data
to SysCAD

Full PGM code for Python Example - Optimization:

;--- variable declarations ---
PageLabel(Precip)
    TextLabel(,"Recycle mass flows")
    REAL 	FS_SolidRecovery*("Frac", "%")
    REAL 	FS_Solids_Moisture*("Frac", "%")
    REAL 	CS_SolidRecovery*("Frac", "%")
    REAL 	CS_Solids_Moisture*("Frac", "%")
    TextLabel(,"Global Agglomeration correction")
    Long	i, NumberofTanks*<<14>>
    REAL 	AggRateCorrection*
    TextLabel(,"Yield Calculations")
    REAL 	Production@("Qm", "t/d")
    REAL 	Yield@("Conc", "g/L")
    REAL 	ProductD50@("L", "um")
    TextLabel(,"Check SysCAD Version", "Function IntStr0 available in SysCAD9.3 Build136.19015")
    Checkbox BuildOK@
 
;; Constant Array with desired product size distribution	
Array z = {2.97869e-05, 3.93492e-05, 5.69551e-05, 8.58349e-05, 0.00013228, 0.00020766,
0.00033343, 0.00055317, 0.00096398, 0.0018091, 0.0037611, 0.0087440, 0.022172,
0.058889, 0.159535, 0.440231, 1.256861, 3.695465, 10.19094, 21.37749, 27.96972,
21.47619, 9.873492, 2.837389, 0.542968, 0.073854, 0.0080610 }
    
;; Work array 
Array x
PageLabel(Analysis)
TextLabel(, "Error difference between product PSD and desired PSD") 
real PSDError@
    	
Sub InitialiseSolution()
    ["X_003.Separ.SolidsToUFReqd (%)"]    = FS_SolidRecovery
    ["X_003.Separ.UFSolidFracReqd (%)"] = 100 - FS_Solids_Moisture
    ["X_001.Separ.SolidsToUFReqd (%)"]    = CS_SolidRecovery
    ["X_001.Separ.UFSolidFracReqd (%)"] = 100 - CS_Solids_Moisture
    
    i = 1
    While i <= NumberofTanks
    	[Concatenate("PC_", IntStr0(i, 3), ".Agglom.Rate.Correction")] = AggRateCorrection
    	i = i + 1
    EndWhile
    x.SetLen(27)
EndSub

    Production =  ["P_011.Qo.SQm (t/d)"] 
    Yield = Production/["P_012.Qv (kL/d)"]*1000.*102./156.
    ProductD50 = ["P_011.Qo.Sz.d50.Al[OH]3(s) (um)"]
    i = 1
    while (i<=27) 
       x[i-1] = [Concatenate("P_011.Qo.Sz.I", IntToStr(i), ".FP.Al[OH]3(s) (%)")]
       i = i+1
    endwhile
    x.Div(z)
    x.Offset(-1)
    PSDError = x.inner(x)
        
$ ; --- end of file ---