Class - Introduction
Navigation: PGMs ➔ Classes
Functions | Subroutines | Classes | |||||
---|---|---|---|---|---|---|---|
Defining a Function | Predefined Functions | Tag Functions | Mathematical Functions | String Functions | Defining a Subroutine | Trigger Subroutines | Defining a Class |
Related Links: User Defined Class and Functions, Example PGM Files
Class - Introduction | Class - Defining a Class | Class - Using a Class | Class - Macros | Class - Examples |
---|
Global Predefined Class Instances: Species Database Class, Particle Size Definition Class, Plant Model Class
Predefined Classes: Array Class, StrArray Class, Matrix Class, TagSelect Class, Noise Class, TimeClass
Understanding when to use Class
Adding class control into PGM code can help a user simplify the handling of multiple related variables or objects. Class control can be used in most scenarios where the PGM code carries out a similar/identical control or calculations multiple times in the same iteration. This has applications both in ProBal and Dynamic modelling. Classes are used to define multiple instances of the same object. The two main scenarios when a class should be used in process simulation is either when the object is a repeating variable or repeating procedure that needs calculation.
Examples of when to use Class
There are two main instances when a class should be used:
- Repeating Variable Calculations
- Multiple units require the same residence time calculations
- Multiple units require an agitator power calculation
- Setting multiple species splits
- Repeating Procedure Calculations
- Batch unit operations for a set of units (eg. multiple ion exchange columns, filtration units, reaction tanks, vacuum pans, etc.)
- Repeating the same control calculation on a set of units?
Understanding “Class” and Its Usage
- Define a Class: Start by defining a class, which is a way to group variables and functions or subroutines together. This definition acts as a “class template”.
- Create Instances: Use this class definition to create any number of “instances” or “objects”.
- Example Scenario: Imagine you need to calculate the tank slurry volume based on a defined residence time. Without a class, you would have to write and repeat the same code each time you perform this calculation. This repetition could become extensive, especially with a large number of tanks in your project. Moreover, any change in logic would require updates in all instances of the repeated code, making it hard to maintain.
- Use a Class for Efficiency: To avoid this, write your code in the form of a class. Define all necessary variables and functions in a template, for instance, “Class_Tank”.
- Implement the Class: Instruct SysCAD to use this template to create as many “instances” or “objects” of type Class_Tank as needed. You can then perform the volume calculations multiple times without repeating the code.
- Example Class: A simple example is provide below, showing how this can be implemented in SysCAD.
- For further understanding, please refer to one of the following topics:
Simple Example
NOTE: A variation of this file can be found in the Demo Nickel Copper Project from Build 139.37023.
Predefined Classes in SysCAD
Predefined Class | Brief Description |
Useful class instances include: | |
SDB - Species Database Class | The SDB class instance gives access to information about species and phases within a project. For example, users can obtain species Density, Saturated Temperature or Pressure, number of solid species in a project, etc. |
PSD - Particle Size Definition Class | The PSD class instance gives access to information about the Particle Size Definition (PSD) within a project. For example, users can find the number of Size Intervals in a PSD, the Top and bottom Size, etc. |
PM - Plant Model Class | The PM class instance provides a function to retrieve a list of global tags available in the Plant Model (PM), can be used in PGM or MP files. |
Useful classes include: | |
Array Class | This Class lets user define an array to read or store numeric values. |
StrArray Class | This Class lets user define an array to read or store (in memory) string values. |
Matrix Class | This Class lets user define an matrix to read or store values. |
TagSelect Class | This Class provides a function to retrieve a list of model tags meeting a SQL type select query, similar to the Excel Tag Select Reports. |
Time Class | This Class contains some function to manipulate the time readings. |
Some Old but still usable classes include: | |
Noise Class | This has been implemented into SysCAD as the Noise Process unit. |
Example User Defined Classes
- Demo Nickel Copper Project - Various PGM files utilising Class. These include calculations for tank volume, elemental balance, species balance, process block (BFD) mass balance checks and Optimise Controller.
- Gold Project - demonstrates the use of Classes in the CSTR pgm file. This is used to calculate the gold and copper leaching and adsorption values in a number of individual tanks.
- Lime Preparation (Makeup) Example - demonstrates the use of two user defined Classes: Set Species Splits and Optimise Controller.
- Milling and Flotation Project - demonstrate the use of Classes to display flotation recoveries at the end of project solve.
- Milling and Magnetic Separation Project - demonstrate the use of Classes to display cyclone splits and magnetic separator recoveries.
- Size Distribution Project - demonstrate the use of Classes to display some cyclone split information.
- Digestion with Direct Heating - demonstrates the use of Classes to calculate user defined properties.
- Demo Ammonia Project - demonstrates the use of Classes to calculate water shift.
- SOP Example Project - demonstrate the use of Classes to add rainfall and evaporation to the tank model (emulating a pond).
- FerroManganese Furnace Example Project - demonstrates use of Classes to set flow in feeders, perform heat loss calculations, and to calculate and set reactions extents.
- See Example Class Files for more examples of user defined class definitions.