Specie Database Class
From SysCAD Documentation
Contents |
Description
The SDB (Specie Data Base) class provides member functions for users to access the details of the species within a project. 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 |
Return Type |
Parameters |
Functionality |
Example |
|
Functions to return the total number (or count) of species or phases | ||||
|
SpecieCount( ) |
long |
None |
This returns the total number of species defined in the project configuration. |
Numspecies = SDB.SpecieCount( ) Numspecies = 12 |
|
PhaseCount( ) |
long |
None |
This returns the total number of phases defined in the project configuration, normally 3 – solid, liquid and gas. |
NumPhases = SDB.PhaseCount( ) NumPhases = 3 |
|
IPhaseCount( ) |
long |
None |
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. |
NumIPhases = SDB.IPhaseCount( ) NumIPhases = 5 |
|
Functions to return the index of a specified phase | ||||
|
SolidPhase( ) |
long |
None |
This returns the index of the solid phase for the project. |
SolidIndex = SDB.SolidPhase( ) SolidIndex = 0 |
|
LiquidPhase( ) |
long |
None |
This returns the index of the liquid phase for the project. |
LiquidIndex = SDB.LiquidPhase( ) LiquidIndex = 1 |
|
GasPhase( ) |
long |
None |
This returns the index of the gas phase for the project. This is normally 2. |
GasIndex = SDB.GasPhase( ) GasIndex = 2 |
|
Functions to return the tag or symbol of a specified Phase | ||||
|
PhaseTag(PhIndex) |
string |
PhIndex is type long |
This returns the tag of the required phase index. |
RequiredPhase = SDB.PhaseTag(1) RequiredPhase = "liquid" |
|
IPhaseTag(IPhIndex) |
string |
IPhIndex is type long |
This returns the tag of the required individual phase index. |
ReqdIndPhase = SDB.IPhaseTag(4) ReqdIndPhase = "aq" |
|
PhaseSymbol(PhIndex) |
string |
PhIndex is type long |
This returns the symbol of the required phase index. |
RequiredPhase = SDB.PhaseSymbol(1) RequiredPhase = "l" |
|
IPhaseSymbol(IPhIndex) |
string |
IPhIndex is type long |
This returns the symbol of the required phase index. |
ReqdIndPhase = SDB.IPhaseSymbol(4) ReqdIndPhase = "aq" |
|
Functions to return the index of a specified specie or phase | ||||
|
FindSpecie(Symbol/Tag) |
long |
The user may specify either the specie symbol or tag |
This returns the index of the required specie. |
SpecieIndex = SDB.FindSpecie("H2O(l)") or SpecieIndex = SDB.FindSpecie("Water(l)") SpecieIndex = 3 |
|
FindPhase(PhaseName) |
long |
PhaseName is type string |
This returns the index of the required phase. |
PhaseIndex = SDB.FindPhase("s") PhaseIndex = 0 |
|
FindIPhase(IPhaseName) |
long |
IPhaseName is type string |
This returns the index of the required individual phase. |
IndPhIndex = SDB.FindIPhase("aq") IndPhIndex = 4 |
|
Functions to return the symbol or tag of a specie with a specified index | ||||
|
SpSymbol(SpIndex) |
string |
SpIndex is type long |
This returns the symbol of the specie with the specified specie index. |
SpecieSymbol = SDB.SpSymbol(3) SpecieSymbol = "H2O(l)" |
|
SpTag(SpIndex) |
string |
SpIndex is type long |
This returns the tag of the specie with the specified specie index. |
SpecieTag = SDB.SpTag(3) SpecieTag = "Water(l)" |
|
Functions to return the information about the phase or individual phase of a specie with a specified index | ||||
|
SpPhaseNo(SpIndex) |
long |
SpIndex is type long |
This returns the index of the phase with the specified specie index. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 SpPhIndex = SDB.SpPhaseNo(RNiIndex) or SpPhIndex = SDB.SpPhaseNo(11) SpPhIndex = 1 |
|
SpIPhaseNo(SpIndex) |
long |
SpIndex is type long |
This returns the index of the individual phase with the specified specie index. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 IndPhIndex = SDB.SpIPhaseNo(RNiIndex) or IndPhIndex = SDB.SpIPhaseNo(11) IndPhIndex = 5 |
|
SpPhaseTag(SpIndex) |
string |
SpIndex is type long |
This returns the tag of the phase with the specified specie index. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 PhaseName = SDB.SpPhaseTag(RNiIndex) or PhaseName = SDB.SpPhaseTag(11) PhaseName = "liquid" |
|
SpIPhaseTag(SpIndex) |
string |
SpIndex is type long |
This returns the tag of the individual phase with the specified specie index. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 IndPhName = SDB.SpIPhaseTag(RNiIndex) or IndPhName = SDB.SpIPhaseTag(11) IndPhName = "org" |
|
SpPhaseSymbol(SpIndex) |
string |
SpIndex is type long |
This returns the symbol of the phase with the specified specie index. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 PhaseSymbol = SDB.SpPhaseSymbol(RNiIndex) or PhaseSymbol = SDB.SpPhaseSymbol(11) PhaseSymbol = "l" |
|
SpIPhaseSymbol(SpIndex) |
string |
SpIndex is type long |
This returns the symbol of the individual phase with the specified specie index. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 IndPhSymbol = SDB.SpIPhaseSymbol(RNiIndex) or IndPhSymbol = SDB.SpIPhaseSymbol(11) IndPhSymbol = "org" |
|
SpIsSolid(SpIndex) |
bit |
SpIndex is type long |
This checks if a specie with the specified specie index is a solid and returns True if it is a solid, False otherwise. |
FeOH2Index = SDB.FindSpecie("Fe[OH]2(s)") = 8 SolidSpecie = SDB.SpIsSolid(FeOH2Index) or SolidSpecie = SDB.SpIsSolid(8) SolidSpecie = True |
|
SpIsLiquid(SpIndex) |
bit |
SpIndex is type long |
This checks if a specie with the specified specie index is a liquid and returns True if it is a liquid, False otherwise. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 LiquidSpecie = SDB.SpIsLiquid(RNiIndex) or LiquidSpecie = SDB.SpIsLiquid(11) LiquidSpecie = True |
|
SpIsGas(SpIndex) |
bit |
SpIndex is type long |
This checks if a specie with the specified specie index is a gas and returns True if it is a gas, False otherwise. |
RNiIndex = SDB.FindSpecie("RNi(org)") = 11 GasSpecie = SDB.SpIsGas(RNiIndex) or GasSpecie = SDB.SpIsGas(11) GasSpecie = False |
|
Functions to return the information about a specie with a specified index | ||||
|
SpMolecularWt(SpIndex) |
double |
SpIndex is type long |
This returns the molecular weight of the specie with the specified specie index. |
O2Index = SDB.FindSpecie("O2(g)") = 1 O2MW = SDB.SpMolecularWt(O2Index) or O2MW = SDB.SpMolecularWt(1) O2MW = 31.999 |
|
SpDensity(SpIndex, temperature, pressure) |
double |
SpIndex is type long temperature in degrees Kelvin pressure in kPa |
This returns the density, in kg/m^3, of the specie with the specified specie index at the specified temperature and pressure. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 H2ORho = SDB.SpDensity(H2OIndex,298.15,101.325) or H2ORho = SDB.SpDensity(3,298.15,101.325) H2ORho = 997.05 kg/m^3 |
|
SpmlHf(SpIndex, temperature, pressure) |
double |
SpIndex is type long temperature in degrees Kelvin pressure in kPa |
This returns the molecular heat of formation, in J/mol, of the specie with the specified specie index at the specified temperature and pressure. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WatermlHf = SDB.SpmlHf(H2OIndex,298.15,101.325) or WatermlHf = SDB.SpmlHf(3,298.15,101.325) WatermlHf = -285830.72 J/mol |
|
SpmsHf(SpIndex, temperature, pressure) |
double |
SpIndex is type long temperature in degrees Kelvin pressure in kPa |
This returns the mass heat of formation, in kJ/kg, of the specie with the specified specie index at the specified temperature and pressure. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WatermsHf = SDB.SpmsHf(H2OIndex,298.15,101.325) or WatermsHf = SDB.SpmsHf(3,298.15,101.325) WatermsHf = -15866.02 kJ/kg |
|
SpmlHz(SpIndex, temperature, pressure) |
double |
SpIndex is type long temperature in degrees Kelvin pressure in kPa |
This returns the molecular enthalpy (including phase change), in J/mol, of the specie with the specified specie index at the specified temperature and pressure. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WatermlHz = SDB.SpmlHz(H2OIndex,298.15,101.325) or WatermlHz = SDB.SpmlHz(3,298.15,101.325) WatermlHz = 1888.47 J/mol |
|
SpmsHz(SpIndex, temperature, pressure) |
double |
SpIndex is type long temperature in degrees Kelvin pressure in kPa |
This returns the mass enthalpy (including phase change), in kJ/kg, of the specie with the specified specie index at the specified temperature and pressure. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WatermsHz = SDB.SpmsHz(H2OIndex,298.15,101.325) or WatermsHz = SDB.SpmsHz(3,298.15,101.325) WatermsHz = 104.83 kJ/kg |
|
SpmlHs(SpIndex, temperature, pressure) |
double |
SpIndex is type long temperature in degrees Kelvin pressure in kPa |
This returns the molecular enthalpy (excluding phase change), in J/mol, of the specie with the specified specie index at the specified temperature and pressure. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WatermlHs = SDB.SpmlHs(H2OIndex,298.15,101.325) or WatermlHs = SDB.SpmlHs(3,298.15,101.325) WatermlHs = 1888.47 J/mol |
|
SpmsHs(SpIndex, temperature, pressure) |
double |
SpIndex is type long temperature in degrees Kelvin pressure in kPa |
This returns the mass enthalpy (excluding phase change), in kJ/kg, of the specie with the specified specie index at the specified temperature and pressure. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WatermsHs = SDB.SpmsHs(H2OIndex,298.15,101.325) or WatermsHs = SDB.SpmsHs(3,298.15,101.325) WatermsHs = 104.83 kJ/kg |
|
SpVapourP(SpIndex, temperature) |
double |
SpIndex is type long temperature in degrees Kelvin |
This returns the vapour pressure, in kPa, of the required specie at the specified temperature, in K. Note: If the specie has no data for calculating the vapour pressure, this will return 0. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WaterVP = SDB.SpVapourP(H2OIndex,350) or WaterVP = SDB.SpVapourP(3,350) WaterVP = 41.68 kPa |
|
SpVapourT(SpIndex, temperature) |
double |
SpIndex is type long pressure in kPa (absolute) |
This returns the vapour temperature, in degrees Kelvin, of the required specie at the specified pressure, in kPa. Note: If the specie has no data for calculating the vapour temperature, this will return 0. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 WaterVT = SDB.SpVapourT(H2OIndex,101.13) or WaterVT = SDB.SpVapourT(3,101.13) WaterVT = 373.07 K |
|
Functions related to elements | ||||
|
ElemAtmWeight(EleName) |
double |
EleName is string of required element |
This returns the molecular weight of the specified element. |
Weight = SDB.ElemAtmWeight("Ni") Weight = 58.69 |
|
SpElemMoles(SpIndex, EleName) |
double |
SpIndex is type long, EleName is type string |
This returns the number of moles of the specified element in the specified specie. Returns 0 if element is not found. |
H2OIndex = SDB.FindSpecie("H2O(l)") = 3 Moles = SDB.SpElemMoles(H2OIndex,"H") or Moles = SDB.SpElemMoles(3,"H") Moles = 2 |
Example 1
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_14, to a user specified value, RequiredValue.
Str ReqdSpecie, SplitUnitTag
long NumSpecies, NumAqSpecies, AqPhaseIndex, SpeciePhase, i
NumSpecies = SDB.SpecieCount() ; 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)
SpeciePhase = sdb.SpIPhaseNo(i) ; Find the individual phase index of specie with index i
if (SpeciePhase == AqPhaseIndex)
ReqdSpecie = sdb.SpSymbol(Spindex) ; Find the tag of the specie with index i
SplitUnitTag = StrCat2("RO_Plant.GM.IOs.[P_14].Splt.", ReqdSpecie , " (%)")
SetDynTag(SplitUnitTag, RequiredValue)
endif
i = i + 1
endwhile
Example 2
The following example retrieves molecular weights at initialisation for use in functions:
double MW_H2O, MW_NaCl
if (Oninitialise)
;------Retrieve Molecular Weights from SysCAD---------
long SpIndex ;in all cases assume specie is found (i.e. SpIndex>=0)
SpIndex = SDB.FindSpecie("H2O(l)")
MW_H2O = SDB.SpMolecularWt(SpIndex)
SpIndex = SDB.FindSpecie("NaCl(aq)")
MW_NaCl = SDB.SpMolecularWt(SpIndex)
;...
else
;...
endif
Example 3
The following example returns some Water and Steam properties at a user specified Temperature:
double StreamT_K*("T", "K")
double WaterVP@("P", "kPa")
double Water_MW@
long WaterIndex, SteamIndex
double Water_Enthalpy("H(Ms)", "kJ/kg")@, Steam_Enthalpy("H(Ms)", "kJ/kg")@, LatentHeat@("H(Ms)", "kJ/kg")
double Water_Density@("Rho", "kg/m^3"), Steam_Density@("Rho", "kg/m^3")
WaterIndex = SDB.FindSpecie("H2O(l)")
SteamIndex = SDB.FindSpecie("H2O(g)")
Water_MW = SDB.SpMolecularWt(WaterIndex)
WaterVP = SDB.SpVapourP(WaterIndex,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
$ ; --- end of file ---
Other Examples
See also example functions to split by specie
