Species Database Class
Navigation: PGMs ➔ Classes ➔ Species Database Class
Global Pre-Defined Class Instances | SysCAD Pre-Defined Classes | |||||||
---|---|---|---|---|---|---|---|---|
Sp Database SDB Class | Particle Size Defn PSD Class | Plant Model PM Class | Array Class | StrArray Class | Matrix Class | TagSelect Class | Time Class | Noise Class |
Latest SysCAD Version: 25 October 2024 - SysCAD 9.3 Build 139.36522
Related Links: Defining a Class, Example PGM Files
Description
The name of the single global instance of the Species Database class is SDB and can be referenced directly.
The Species Data Base (SDB) class is very useful as it provides member functions that allow users to access the details and properties of the species within a project.
- The information for species that users may obtain using the SDB class includes Molecular Weight, Density, Saturated Temperature and Pressure, etc.
- The user may also obtain the total number of species in a project, number of solid, liquid or gaseous species, etc.
- The user does not have to declare the SDB class before using it.
Data Members
None
Member Functions
The examples in the following table are all based upon a project containing the following species:
- H2O(g), O2(g), N2(g)
- H2O(l), H2SO4(aq), NaCl(aq), NiSO4(aq)
- Fe2O3(s), Fe[OH]2(s), NiO(s)
- RH2(org), RNi(org)
Call | Functionality | Return Type | Parameters | Example |
Species Index | ||||
FindSpecies(Symbol/Tag) |
This returns the index of the required species, or -1 if it is not found. |
integer |
The user may specify either the species symbol or tag |
SpeciesIndex = SDB.FindSpecies("H2O(l)") or |
Species Information | ||||
SpShortName(SpIndex) |
This returns the short name (symbol) of the species with the specified species index. Previous function name (Build 135) was SpSymbol. |
string |
SpIndex is type integer |
SpeciesName = SDB.SpShortName(3) |
SpLongName(SpIndex) |
This returns the long name of the species with the specified species index. Previous function name (Build 135) was SpTag. |
string |
SpIndex is type integer |
SpeciesName = SDB.SpLongName(3) |
SpMolecularWt(SpIndex) |
This returns the Molecular Weight of the species with the specified species index. |
real |
SpIndex is type integer |
O2Index = SpI("O2(g)") = 1 |
SpCharge(SpIndex) |
This returns the Charge of the species with the specified species index. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(g)") = 7 |
SpDensity(SpIndex, temperature, pressure) |
This returns the Density, in kg/m^3, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpVapourP(SpIndex, temperature) |
This returns the Saturated Vapour Pressure, in kPa, of the required vapour species at the specified temperature, in K.
|
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(g)") = 7 |
SpVapourT(SpIndex, Pressure) |
This returns the Saturated Vapour Temperature, in degrees Kelvin, of the required vapour species at the specified pressure, in kPa. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(g)") = 7 |
SpTc(SpIndex) |
This returns the Critical Temperature, in degrees Kelvin, of the required vapour species. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(g)") = 7 |
SpmlHf(SpIndex, temperature, pressure) |
This returns the Molecular Heat of Formation, in J/mol, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmsHf(SpIndex, temperature, pressure) |
This returns the Mass Heat of Formation, in kJ/kg, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmlHz(SpIndex, temperature, pressure) |
This returns the Molecular Enthalpy (including phase change), in J/mol, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmsHz(SpIndex, temperature, pressure) |
This returns the Mass Enthalpy (including phase change), in kJ/kg, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmlHs(SpIndex, temperature, pressure) |
This returns the Molecular Enthalpy (excluding phase change), in J/mol, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmsHs(SpIndex, temperature, pressure) |
This returns the Mass Enthalpy (excluding phase change), in kJ/kg, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmlCp(SpIndex, temperature, pressure) |
This returns the Molecular Specific Heat, in kJ/kmol.C, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmsCp(SpIndex, temperature, pressure) |
This returns the Mass Specific Heat, in kJ/kg.C, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmlSf(SpIndex, temperature, pressure) |
This returns the Molecular Entropy, in kJ/kmol.C, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmsSf(SpIndex, temperature, pressure) |
This returns the Mass Entropy, in kJ/kg.C, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmlGf(SpIndex, temperature, pressure) |
Implemented in Build 138. This returns the Molecular Gibbs Free Energy, in kJ/kmol, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpmsGf(SpIndex, temperature, pressure) |
Implemented in Build 138. This returns the Mass Gibbs Free Energy, in kJ/kg, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpViscosity(SpIndex, temperature, pressure) |
This returns the Viscosity, in Pas, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
SpThermalCond(SpIndex, temperature, pressure) |
This returns the Thermal Conductivity, in kW/m.K, of the species with the specified species index at the specified temperature and pressure. |
real |
SpIndex is type integer |
H2OIndex = SpI("H2O(l)") = 3 |
Elemental Information | ||||
ElemCount() |
This returns the total number of elements defined in the project configuration. |
integer |
None |
NumElements = SDB.ElemCount() |
FindElem(Symbol/Tag) |
Available from Build 139.29999. This returns the index of the required element, or -1 if it is not found. |
integer |
The user needs to specify the element name. |
ElementIndex = SDB.FindElem("Na") |
ElemName(ElemIndex) |
Available from Build 139.29999. This returns the name of the element with the specified element index. |
string |
ElemIndex is type integer |
ElName = SDB.ElemName(3) |
ElemAtmWeight(EleName) |
This returns the atomic weight of the specified element. |
real |
EleName is string of required element |
Weight = SDB.ElemAtmWeight("Ni") |
ElemAW(ElemIndex) |
Available from Build 139.29999. This returns the atomic weight of the element with the specified element index. |
real |
ElemIndex is type integer |
NaIndex = ElemI("Na") = 3 |
SpElemMoles(SpIndex, EleName) |
This returns the number of moles of the specified element in the specified species. Returns 0 if element is not found. |
real |
SpIndex is type long, EleName is type string |
H2OIndex = SpI("H2O(l)") = 3 |
Information about the Phase or Individual Phase of Species | ||||
SpPhaseNo(SpIndex) |
This returns the index of the phase with the specified species index. |
integer |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
SpIPhaseNo(SpIndex) |
This returns the index of the individual phase with the specified species index. |
integer |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
SpPhaseTag(SpIndex) |
This returns the tag of the phase with the specified species index. |
string |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
SpIPhaseTag(SpIndex) |
This returns the tag of the individual phase with the specified species index. |
string |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
SpPhaseSymbol(SpIndex) |
This returns the symbol of the phase with the specified species index. |
string |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
SpIPhaseSymbol(SpIndex) |
This returns the symbol of the individual phase with the specified species index. |
string |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
SpIsSolid(SpIndex) |
This checks if a species with the specified species index is a solid and returns True if it is a solid, False otherwise. |
bit |
SpIndex is type integer |
FeOH2Index = SpI("Fe[OH]2(s)") = 8 |
SpIsLiquid(SpIndex) |
This checks if a species with the specified species index is a liquid and returns True if it is a liquid, False otherwise. |
bit |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
SpIsGas(SpIndex) |
This checks if a species with the specified species index is a gas and returns True if it is a gas, False otherwise. |
bit |
SpIndex is type integer |
RNiIndex = SpI("RNi(org)") = 11 |
Total Number of Species or Phases | ||||
SpeciesCount( ) |
This returns the total number of species defined in the project configuration. |
integer |
None |
Numspecies = SDB.SpeciesCount( ) |
PhaseCount( ) |
This returns the total number of phases defined in the project configuration, normally 3 – solid, liquid and gas. |
integer |
None |
NumPhases = SDB.PhaseCount( ) |
IPhaseCount( ) |
This returns the total number of Individual phases defined in the project configuration. This may be the same as above, i.e solids, liquids and gases, but often there are more such as aqueous, organic, slag, etc. |
integer |
None |
NumIPhases = SDB.IPhaseCount( ) |
Phase indexes | ||||
SolidPhase( ) |
This returns the index of the solid phase for the project. |
integer |
None |
SolidIndex = SDB.SolidPhase( ) |
LiquidPhase( ) |
This returns the index of the liquid phase for the project. |
integer |
None |
LiquidIndex = SDB.LiquidPhase( ) |
GasPhase( ) |
This returns the index of the gas phase for the project. This is normally 2. |
integer |
None |
GasIndex = SDB.GasPhase( ) |
FindPhase(PhaseName) |
This returns the index of the required phase, or -1 if it is not found. |
integer |
PhaseName is type string |
PhaseIndex = SDB.FindPhase("s") |
FindIPhase(IPhaseName) |
This returns the index of the required individual phase, or -1 if it is not found. |
integer |
IPhaseName is type string |
IndPhIndex = SDB.FindIPhase("aq") |
Phase Tag or Symbol | ||||
PhaseTag(PhIndex) |
This returns the tag of the required phase index. |
string |
PhIndex is type integer |
RequiredPhase = SDB.PhaseTag(1) |
IPhaseTag(IPhIndex) |
This returns the tag of the required individual phase index. |
string |
IPhIndex is type integer |
ReqdIndPhase = SDB.IPhaseTag(4) |
PhaseSymbol(PhIndex) |
This returns the symbol of the required phase index. |
string |
PhIndex is type integer |
RequiredPhase = SDB.PhaseSymbol(1) |
IPhaseSymbol(IPhIndex) |
This returns the symbol of the required phase index. |
string |
IPhIndex is type integer |
ReqdIndPhase = SDB.IPhaseSymbol(4) |
Examples
Species Names defined as String Variable
If the species name / index is to be defined as a variable, then functions SDB.FindSpecies() and SDB.SpMolecularWt() must be used to find the species index and molecular weights.
Predefined functions SpI() and MW() are more efficient but only work if the species name is defined directly (literal strings) into the functions, they will not work with variables.
For example:
String ReqdSpecies*
Long SpeciesIndex@
Real MW_ReqdSpecies@
ReqdSpecies = "H2O(l)"
SpeciesIndex = SDB.FindSpecies(ReqdSpecies)
MW_ReqdSpecies = SDB.SpMolecularWt(SpeciesIndex)
|
Compared With:
Long SpeciesIndex_Water@
Real MW_Water@
SpeciesIndex_Water = SpI("H2O(l)")
MW_Water = MW("H2O(l)")
|
Element Names defined as String Variable
If the element name / index is to be defined as a variable, then functions SDB.FindElem() and SDB.ElemAW() must be used to find the element index and atomic weights.
Predefined functions ElemI() and MW() are more efficient but only work if the element name is defined directly (literal strings) into the functions, they will not work with variables.
For example:
String ReqdElement*
Long ElementIndex@
Real AW_ReqdElement@
ReqdElement = "Na"
ElementIndex = SDB.FindElem(ReqdElement)
AW_ReqdElement = SDB.ElemAW(ElementIndex)
|
Compared With:
Long ElementIndex_Sodium@
Real AW_Sodium@
ElementIndex_Sodium = ElemI("Na")
AW_Sodium = MW("Na")
|
Find and Manipulate Species in a Given Phase
The following example uses the same species as in the above section. It finds all of the aqueous species and sets the split in a unit, RO_Plant, to stream P_014, to a user specified value, RequiredValue.
Real RequiredValue*
String ReqdSpecies, SplitUnitTag
Long NumSpecies, NumAqSpecies, AqPhaseIndex, SpeciesPhase, i
NumSpecies = SDB.SpeciesCount() ; Find the number of species in the project, in this case 12
AqPhaseIndex = sdb.FindIPhase("aq") ; Find the index of the aqueous phase
i = 0
while (i < NumSpecies)
SpeciesPhase = sdb.SpIPhaseNo(i) ; Find the individual phase index of species with index i
if (SpeciesPhase == AqPhaseIndex)
ReqdSpecies = sdb.SpShortTag(i) ; Find the tag of the species with index i
SplitUnitTag = Concatenate("RO_Plant.GM.IOs.[P_014].Splt.", ReqdSpecies, " (%)")
[SplitUnitTag] = RequiredValue
endif
i = i + 1
endwhile
Find Species Molecular Weights
The following example retrieves molecular weights at initialisation for use in functions:
Real MW_H2O, MW_NaCl
Sub InitialiseSolution()
;------Retrieve Molecular Weights from SysCAD---------
MW_H2O = MW("H2O")
MW_NaCl = MW("NaCl")
EndSub
Find Water and Steam Properties
The following example returns some Water and Steam properties at a user specified Temperature:
Real StreamT_K*("T", "K")
Real WaterVP@("P", "kPa")
Real Water_MW@
Long WaterIndex, SteamIndex
Real Water_Enthalpy("H(Ms)", "kJ/kg")@, Steam_Enthalpy@("H(Ms)", "kJ/kg"), LatentHeat@("H(Ms)", "kJ/kg")
Real Water_Density@("Rho", "kg/m^3"), Steam_Density@("Rho", "kg/m^3")
Real Steam_Critical_T@("T", "K")
Real Water_Viscosity@("Visc", "Pas"), Steam_Viscosity@("Visc", "Pas")
Real Water_ThermalCond@("HCond", "kW/m.K"), Steam_ThermalCond@("HCond", "kW/m.K")
WaterIndex = SpI("H2O(l)")
SteamIndex = SpI("H2O(g)")
Water_MW = MW("H2O")
WaterVP = SDB.SpVapourP(SteamIndex,StreamT_K)
Water_Density = SDB.SpDensity(WaterIndex,StreamT_K,WaterVP)
Steam_Density = SDB.SpDensity(SteamIndex,StreamT_K,WaterVP)
Water_Enthalpy = SDB.SpmsHz(WaterIndex,StreamT_K,WaterVP)
Steam_Enthalpy = SDB.SpmsHz(SteamIndex,StreamT_K,WaterVP)
LatentHeat = Steam_Enthalpy - Water_Enthalpy
Steam_Critical_T = SDB.SpTc(SteamIndex)
Water_Viscosity = SDB.SpViscosity(WaterIndex, StreamT_K, WaterVP)
Steam_Viscosity = SDB.SpViscosity(SteamIndex, StreamT_K, WaterVP)
Water_ThermalCond = SDB.SpThermalCond(WaterIndex, StreamT_K, WaterVP)
Steam_ThermalCond = SDB.SpThermalCond(SteamIndex, StreamT_K, WaterVP)
$ ; --- end of file ---
Other Examples
See also Example Functions to split by species, Example PGM - Species Check