Python Interface Reference

class xgems.PyxGEMS.ChemicalEngine

Bases: pybind11_object

Eh(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the redox potential (Eh) of the system (V).

Example:

eh_value = engine.Eh()
print(eh_value)
aqueousPhaseName(self: xgems.PyxGEMS.ChemicalEngine) str

Returns the aqueous phase name. If empty, the aqueous phase is not in system.

Example:

name = engine.aqueousPhaseName()
print(name)
chemicalPotentials(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the chemical potentials of all species in the system (J/mol).

Example:

potentials = engine.chemicalPotentials()
print(potentials)
converged(self: xgems.PyxGEMS.ChemicalEngine) bool

Checks if the equilibrium computation has converged.

Return bool:

True if the computation has converged, False otherwise.

Example:

is_converged = engine.converged()
print(is_converged)
elapsedTime(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the elapsed time for the last equilibrium computation (in seconds).

Return float:

Elapsed time in seconds.

Example:

time = engine.elapsedTime()
print(time)
elementAmounts(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the amounts of all elements in the system (mol).

Example:

amounts = engine.elementAmounts()
print(amounts)
elementAmountsInPhase(self: xgems.PyxGEMS.ChemicalEngine, phase_index: int) numpy.ndarray[numpy.float64[m, 1]]

Returns the amounts of all elements in a specific phase (mol).

Parameters:

phase_index (int) – Index of the phase.

Example:

amounts = engine.elementAmountsInPhase(0)
print(amounts)
elementAmountsInSpecies(self: xgems.PyxGEMS.ChemicalEngine, species_index: numpy.ndarray[numpy.int32[m, 1]]) numpy.ndarray[numpy.float64[m, 1]]

Returns the amounts of all elements in a specific species (mol).

Parameters:

species_index (int) – Index of the species.

Example:

amounts = engine.elementAmountsInSpecies(0)
print(amounts)
elementMolarMasses(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the molar masses of all elements in the system (kg/mol).

Example:

molar_masses = engine.elementMolarMasses()
print(molar_masses)
elementName(self: xgems.PyxGEMS.ChemicalEngine, index: int) str

Returns the name of an element by its index.

Parameters:

index (int) – Index of the element.

Example:

element_name = engine.elementName(0)
print(element_name)
equilibrate(self: xgems.PyxGEMS.ChemicalEngine, arg0: float, arg1: float, arg2: numpy.ndarray[numpy.float64[m, 1]]) int

Compute the chemical equilibrium state from temperature, pressure, and element amounts.

This method resets any existing state and computes a new equilibrium based on the provided temperature (in Kelvin), pressure (in Pascals), and vector of element amounts (in mol). The order of the elements in the vector must match the chemical system’s element ordering.

Parameters:
  • T (float) – Temperature in Kelvin.

  • P (float) – Pressure in Pascals.

  • b (numpy.ndarray or Eigen::VectorXd) – Vector of element amounts (in mol). Must be a NumPy array or Eigen vector of correct length.

Returns:

Integer return code indicating the status of the equilibrium computation.

Return type:

int

Example

import numpy as np

# Element amounts in mol (order: C, Ca, Cl, H, Mg, O, Zz)
b = np.array([0.001, 1e-9, 0.004, 110.6837, 0.002, 55.34405, 0.0])

# Compute equilibrium
ret = engine.equilibrate(298.15, 101325, b)

Return Codes

The function returns an integer code indicating the status:

  • 0: No GEM re-calculation needed

  • 1: Need GEM calculation with LPP (automatic) initial approximation (AIA)

  • 2: OK after GEM calculation with LPP AIA

  • 3: Bad (not fully trustful) result after GEM calculation with LPP AIA

  • 4: Failure (no result) in GEM calculation with LPP AIA

  • 5: Need GEM calculation with no-LPP (smart) IA, SIA using the previous speciation

  • 6: OK after GEM calculation with SIA

  • 7: Bad (not fully trustful) result after GEM calculation with SIA

  • 8: Failure (no result) in GEM calculation with SIA

  • 9: Terminal error in GEMS3K (e.g., memory corruption). Restart required.

Note

Ensure the b vector is properly ordered and matches the number of elements defined in the chemical system.

formulaMatrix(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, n], flags.f_contiguous]

Returns the formula matrix of the system.

The formula matrix represents the stoichiometric coefficients of elements in species.

Example:

formula_matrix = engine.formulaMatrix()
print(formula_matrix)
gasPhaseName(self: xgems.PyxGEMS.ChemicalEngine) str

Returns the gaseous phase name. If empty, the gaseous phase is not in system.

Example:

name = engine.gasPhaseName()
print(name)
indexElement(self: xgems.PyxGEMS.ChemicalEngine, name: str) int

Returns the index of an element by its name.

Parameters:

name (str) – Name of the element.

Example:

index = engine.indexElement("O")
print(index)
indexFirstSpeciesInPhase(self: xgems.PyxGEMS.ChemicalEngine, phase_index: int) int

Returns the index of the first species in a specified phase.

Parameters:

phase_index (int) – Index of the phase.

Example:

species_index = engine.indexFirstSpeciesInPhase(0)
print(species_index)
indexPhase(self: xgems.PyxGEMS.ChemicalEngine, name: str) int

Returns the index of a phase by its name.

Parameters:

name (str) – Name of the phase.

Example:

index = engine.indexPhase("aq_gen")
print(index)
indexPhaseAll(self: xgems.PyxGEMS.ChemicalEngine, name: str) numpy.ndarray[numpy.int32[m, 1]]

Returns all indices of phases matching the specified name.

Parameters:

name (str) – Name of the phase.

Example:

indices = engine.indexPhaseAll("aq_gen")
print(indices)
indexPhaseWithSpecies(self: xgems.PyxGEMS.ChemicalEngine, species_index: int) int

Returns the index of the phase containing a given species.

Parameters:

species_index (int) – Index of the species.

Example:

phase_index = engine.indexPhaseWithSpecies(0)
print(phase_index)
indexSpecies(self: xgems.PyxGEMS.ChemicalEngine, name: str) int

Returns the index of a species by its name.

Parameters:

name (str) – Name of the species.

Example:

index = engine.indexSpecies("H2O@")
print(index)
indexSpeciesAll(self: xgems.PyxGEMS.ChemicalEngine, name: str) numpy.ndarray[numpy.int32[m, 1]]

Returns all indices of species matching the specified name.

Parameters:

name (str) – Name of the species.

Example:

indices = engine.indexSpeciesAll("H2O@")
print(indices)
initialize(self: xgems.PyxGEMS.ChemicalEngine, filename: str) None

Initializes the ChemicalEngine from a GEM-Selektor project file.

Parameters:

filename (str) – Path to the system definition file (e.g., “my-system-dat.lst”).

Example:

engine.initialize("my-system-dat.lst")
initializeFromJsonStrings(self: xgems.PyxGEMS.ChemicalEngine, dch_json: str, ipm_json: str, dbr_json: str) None

Initializes the ChemicalEngine using JSON strings.

Parameters:
  • dch_json (str) – JSON string describing the chemical system.

  • ipm_json (str) – JSON string with parameter and algorithm settings.

  • dbr_json (str) – JSON string containing node composition details.

Example:

engine.initializeFromJsonStrings(dch, ipm, dbr)
ionicStrength(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the ionic strength of the system (mol/L).

Example:

ionic_strength = engine.ionicStrength()
print(ionic_strength)
lnActivities(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the natural logarithms of activities for all species.

Example:

ln_activities = engine.lnActivities()
print(ln_activities)
lnActivityCoefficients(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the natural logarithms of activity coefficients for all species.

Example:

ln_coeffs = engine.lnActivityCoefficients()
print(ln_coeffs)
lnConcentrations(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the natural logarithms of concentrations for all species.

Example:

ln_concentrations = engine.lnConcentrations()
print(ln_concentrations)
moleFractions(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the mole fractions of all species in the system.

Example:

fractions = engine.moleFractions()
print(fractions)
numElements(self: xgems.PyxGEMS.ChemicalEngine) int

Returns the number of elements in the chemical system.

Example:

num_elements = engine.numElements()
print(num_elements)
numIterations(self: xgems.PyxGEMS.ChemicalEngine) int

Returns the number of iterations performed during the last equilibrium computation.

Return int:

Number of iterations.

Example:

iterations = engine.numIterations()
print(iterations)
numPhases(self: xgems.PyxGEMS.ChemicalEngine) int

Returns the number of phases in the chemical system.

Example:

num_phases = engine.numPhases()
print(num_phases)
numSpecies(self: xgems.PyxGEMS.ChemicalEngine) int

Returns the number of species in the chemical system.

Example:

num_species = engine.numSpecies()
print(num_species)
numSpeciesInPhase(self: xgems.PyxGEMS.ChemicalEngine, iphase: int) int

Returns the number of species in a given phase.

Parameters:

iphase (int) – Index of the phase.

Example:

num_species_in_phase = engine.numSpeciesInPhase(0)
print(num_species_in_phase)
property options

Gets or sets the options used by the ChemicalEngine.

Type:

ChemicalEngineOptions

Example (get):

opts = engine.options
print("Warmstart:", opts.warmstart)

Example (set):

opts = engine.options
opts.warmstart = False
opts.print_zero_amounts = True # prints phases and species with zero amounts
engine.options = opts
pH(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the pH of the system (dimensionless).

Example:

ph_value = engine.pH()
print(ph_value)
pe(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the pe (electron activity) of the system (dimensionless).

Example:

pe_value = engine.pe()
print(pe_value)
phaseAmount(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the amount of a specific phase by its index (mol).

Parameters:

index (int) – Index of the phase.

Example:

amount = engine.phaseAmount(0)
print(amount)
phaseAmounts(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the amounts of all phases in the system (mol).

Example:

amounts = engine.phaseAmounts()
print(amounts)
phaseDensities(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the densities of all phases in the system (kg/m³).

Example:

densities = engine.phaseDensities()
print(densities)
phaseDensity(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the density of a specific phase by its index (kg/m³).

Parameters:

index (int) – Index of the phase.

Example:

density = engine.phaseDensity(0)
print(density)
phaseEnthalpies(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the enthalpies of all phases in the system (J).

Example:

enthalpies = engine.phaseEnthalpies()
print(enthalpies)
phaseEnthalpy(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the enthalpy of a specific phase by its index (J).

Parameters:

index (int) – Index of the phase.

Example:

enthalpy = engine.phaseEnthalpy(0)
print(enthalpy)
phaseEntropies(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the entropies of all phases in the system (J/K).

Example:

entropies = engine.phaseEntropies()
print(entropies)
phaseEntropy(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the entropy of a specific phase by its index (J/K).

Parameters:

index (int) – Index of the phase.

Example:

entropy = engine.phaseEntropy(0)
print(entropy)
phaseHeatCapacitiesConstP(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the isobaric heat capacities of all phases in the system (J/K).

Example:

heat_capacities = engine.phaseHeatCapacitiesConstP()
print(heat_capacities)
phaseHeatCapacityConstP(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the isobaric heat capacity of a specific phase by its index (J/K).

Parameters:

index (int) – Index of the phase.

Example:

heat_capacity = engine.phaseHeatCapacityConstP(0)
print(heat_capacity)
phaseMass(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the mass of a specific phase by its index (kg).

Parameters:

index (int) – Index of the phase.

Example:

mass = engine.phaseMass(0)
print(mass)
phaseMasses(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the masses of all phases in the system (kg).

Example:

masses = engine.phaseMasses()
print(masses)
phaseMolarEnthalpy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the molar enthalpy of a specific phase by its index (J/mol).

Parameters:

index (int) – Index of the phase.

Example:

molar_enthalpy = engine.phaseMolarEnthalpy(0)
print(molar_enthalpy)
phaseMolarEntropy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the molar entropy of a specific phase by its index (J/K/mol).

Parameters:

index (int) – Index of the phase.

Example:

molar_entropy = engine.phaseMolarEntropy(0)
print(molar_entropy)
phaseMolarGibbsEnergy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the molar Gibbs energy of a specific phase by its index (J/mol).

Parameters:

index (int) – Index of the phase.

Example:

molar_gibbs_energy = engine.phaseMolarGibbsEnergy(0)
print(molar_gibbs_energy)
phaseMolarHeatCapacityConstP(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the molar heat capacity at constant pressure of a specific species by its index (J/K/mol).

Parameters:

index (int) – Index of the species.

Example:

molar_heat_capacity = engine.phaseMolarHeatCapacityConstP(0)
print(molar_heat_capacity)
phaseMolarVolume(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the molar volume of a specific phase by its index (m³/mol).

Parameters:

index (int) – Index of the phase.

Example:

molar_volume = engine.phaseMolarVolume(0)
print(molar_volume)
phaseName(self: xgems.PyxGEMS.ChemicalEngine, index: int) str

Returns the name of a phase by its index.

Parameters:

index (int) – Index of the phase.

Example:

phase_name = engine.phaseName(0)
print(phase_name)
phaseSatIndex(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the saturation index of a specific phase by its index.

Parameters:

index (int) – Index of the phase.

Example:

sat_index = engine.phaseSatIndex(0)
print(sat_index)
phaseSatIndices(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the saturation indices of all phases in the system.

Example:

sat_indices = engine.phaseSatIndices()
print(sat_indices)
phaseSpecificEnthalpy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the specific enthalpy of a specific phase by its index (J/kg).

Parameters:

index (int) – Index of the phase.

Example:

specific_enthalpy = engine.phaseSpecificEnthalpy(0)
print(specific_enthalpy)
phaseSpecificEntropy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the specific entropy of a specific phase by its index (J/K/kg).

Parameters:

index (int) – Index of the phase.

Example:

specific_entropy = engine.phaseSpecificEntropy(0)
print(specific_entropy)
phaseSpecificGibbsEnergy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the specific Gibbs energy of a specific phase by its index (J/kg).

Parameters:

index (int) – Index of the phase.

Example:

specific_gibbs_energy = engine.phaseSpecificGibbsEnergy(0)
print(specific_gibbs_energy)
phaseSpecificHeatCapacityConstP(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the specific heat capacity at constant pressure of a specific phase by its index (J/K/kg).

Parameters:

index (int) – Index of the phase.

Example:

specific_heat_capacity = engine.phaseSpecificHeatCapacityConstP(0)
print(specific_heat_capacity)
phaseSpecificVolume(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the specific volume of a specific phase by its index (m³/kg).

Parameters:

index (int) – Index of the phase.

Example:

specific_volume = engine.phaseSpecificVolume(0)
print(specific_volume)
phaseVolume(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the volume of a specific phase by its index (m³).

Parameters:

index (int) – Index of the phase.

Example:

volume = engine.phaseVolume(0)
print(volume)
phaseVolumes(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the volumes of all phases in the system (m³).

Example:

volumes = engine.phaseVolumes()
print(volumes)
pressure(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the current pressure of the system (Pa).

Return float:

Pressure in Pascals.

Example:

pressure = engine.pressure()
print(pressure)
readDbrFromFile(self: xgems.PyxGEMS.ChemicalEngine, filename: str) None

Reads the input node composition (DBR) from a file.

Parameters:

filename (str) – Path to the DBR file.

Example:

engine.readDbrFromFile("input.dbr")
readDbrFromJsonString(self: xgems.PyxGEMS.ChemicalEngine, dbr_json: str) None

Reads the input node composition (DBR) from a JSON string.

Parameters:

dbr_json (str) – JSON string containing DBR composition data.

Example:

engine.readDbrFromJsonString("{}")
reequilibrate(*args, **kwargs)

Overloaded function.

  1. reequilibrate(self: xgems.PyxGEMS.ChemicalEngine) -> int

    Re-equilibrates the system using the current state as the initial guess. Default with automatic inital guess.

    Example:

    engine.reequilibrate()
    

    Return Codes

    The function returns an integer code indicating the status:

    • 0: No GEM re-calculation needed

    • 1: Need GEM calculation with LPP (automatic) initial approximation (AIA)

    • 2: OK after GEM calculation with LPP AIA

    • 3: Bad (not fully trustful) result after GEM calculation with LPP AIA

    • 4: Failure (no result) in GEM calculation with LPP AIA

    • 5: Need GEM calculation with no-LPP (smart) IA, SIA using the previous speciation

    • 6: OK after GEM calculation with SIA

    • 7: Bad (not fully trustful) result after GEM calculation with SIA

    • 8: Failure (no result) in GEM calculation with SIA

    • 9: Terminal error in GEMS3K (e.g., memory corruption). Restart required.

  2. reequilibrate(self: xgems.PyxGEMS.ChemicalEngine, arg0: bool) -> int

    Re-equilibrates the system using the current state as the initial guess.

    param bool warmstart:

    equilibration with smart initial guess.

    Example:

    engine.reequilibrate(True)
    

    Return Codes

    The function returns an integer code indicating the status:

    • 0: No GEM re-calculation needed

    • 1: Need GEM calculation with LPP (automatic) initial approximation (AIA)

    • 2: OK after GEM calculation with LPP AIA

    • 3: Bad (not fully trustful) result after GEM calculation with LPP AIA

    • 4: Failure (no result) in GEM calculation with LPP AIA

    • 5: Need GEM calculation with no-LPP (smart) IA, SIA using the previous speciation

    • 6: OK after GEM calculation with SIA

    • 7: Bad (not fully trustful) result after GEM calculation with SIA

    • 8: Failure (no result) in GEM calculation with SIA

    • 9: Terminal error in GEMS3K (e.g., memory corruption). Restart required.

setB(self: xgems.PyxGEMS.ChemicalEngine, composition: numpy.ndarray[numpy.float64[m, 1]]) None

Sets the bulk composition of the system.

Parameters:

composition (list[float]) – List of element amounts (mol).

Set element amounts of a solution with 0.001 M MgCl2 and 0.001 M CO2: - elements order: C, Ca, Cl, H, Mg, O, Zz (charge) - Note: The order of elements in the list should match the order in the chemical system.

Example:

engine.setB([0.001, 1e-09, 0.004, 110.6837, 0.002, 55.34405, 0])
setColdStart(self: xgems.PyxGEMS.ChemicalEngine) None

Enables cold start for the ChemicalEngine.

Cold start resets the initial guess to default values for robust convergence.

Example:

engine.setColdStart()
setPT(self: xgems.PyxGEMS.ChemicalEngine, temperature: float, pressure: float) bool

Sets the temperature and pressure of the system.

Parameters:
  • temperature (float) – Temperature in Kelvin (K).

  • pressure (float) – Pressure in Pascals (Pa).

Example:

engine.setPT(298.15, 101325)
setSpeciesAmount(*args, **kwargs)

Overloaded function.

  1. setSpeciesAmount(self: xgems.PyxGEMS.ChemicalEngine, name: str, amount: float) -> None

Sets the amount of a species by its name.

Parameters:
  • name (str) – Name of the species.

  • amount (float) – Amount of the species in moles.

Example:

engine.setSpeciesAmount("SiO2", 1.0)
  1. setSpeciesAmount(self: xgems.PyxGEMS.ChemicalEngine, index: int, amount: float) -> None

Sets the amount of a species by its index.

Parameters:
  • index (int) – Index of the species.

  • amount (float) – Amount of the species in moles.

Example:

engine.setSpeciesAmount(0, 1.0)
setSpeciesAmounts(self: xgems.PyxGEMS.ChemicalEngine, amounts: numpy.ndarray[numpy.float64[m, 1]]) None

Sets the amounts of all species in the system (mol).

Parameters:

amounts (list[float]) – List of species amounts.

Example:

engine.setSpeciesAmounts([1.0, 0.5, 0.2])
setSpeciesLowerLimit(*args, **kwargs)

Overloaded function.

  1. setSpeciesLowerLimit(self: xgems.PyxGEMS.ChemicalEngine, name: str, limit: float) -> None

Sets the lower limit for a species by its name.

Parameters:
  • name (str) – Name of the species.

  • limit (float) – Lower limit for the species amount.

Example:

engine.setSpeciesLowerLimit("SiO2", 0.1)
  1. setSpeciesLowerLimit(self: xgems.PyxGEMS.ChemicalEngine, index: int, limit: float) -> None

Sets the lower limit for a species by its index.

Parameters:
  • index (int) – Index of the species.

  • limit (float) – Lower limit for the species amount.

Example:

engine.setSpeciesLowerLimit(0, 0.1)
setSpeciesLowerLimits(self: xgems.PyxGEMS.ChemicalEngine, limits: numpy.ndarray[numpy.float64[m, 1]]) None

Sets the lower limits for all species in the system (mol).

Parameters:

limits (list[float]) – List of lower limits for species amounts.

Example:

engine.setSpeciesLowerLimits([0.1, 0.05, 0.02])
setSpeciesUpperLimit(*args, **kwargs)

Overloaded function.

  1. setSpeciesUpperLimit(self: xgems.PyxGEMS.ChemicalEngine, name: str, limit: float) -> None

Sets the upper limit for a species by its name.

Parameters:
  • name (str) – Name of the species.

  • limit (float) – Upper limit for the species amount.

Example:

engine.setSpeciesUpperLimit("H2O@", 10.0)
  1. setSpeciesUpperLimit(self: xgems.PyxGEMS.ChemicalEngine, index: int, limit: float) -> None

Sets the upper limit for a species by its index.

Parameters:
  • index (int) – Index of the species.

  • limit (float) – Upper limit for the species amount.

Example:

engine.setSpeciesUpperLimit(0, 10.0)
setSpeciesUpperLimits(self: xgems.PyxGEMS.ChemicalEngine, limits: numpy.ndarray[numpy.float64[m, 1]]) None

Sets the upper limits for all species in the system (mol).

Parameters:

limits (list[float]) – List of upper limits for species amounts.

Example:

engine.setSpeciesUpperLimits([10.0, 5.0, 2.0])
setStandardMolarGibbsEnergy(self: xgems.PyxGEMS.ChemicalEngine, index: str, value: float) None

Sets the standard molar Gibbs energy for a species (J/mol).

Parameters:
  • index (int) – Index of the species.

  • value (float) – Standard molar Gibbs energy value (J/mol).

Example:

engine.setStandardMolarGibbsEnergy(0, -237.13)
setWarmStart(self: xgems.PyxGEMS.ChemicalEngine) None

Enables warm start for the ChemicalEngine.

Warm start uses the previous solution as an initial guess for faster convergence.

Example:

engine.setWarmStart()
speciesAmount(*args, **kwargs)

Overloaded function.

  1. speciesAmount(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) -> float

    Returns the amount of a species by its index (mol).

    param int index:

    Index of the species.

    Example:

    amount = engine.speciesAmount(0)
    print(amount)
    
  2. speciesAmount(self: xgems.PyxGEMS.ChemicalEngine, arg0: str) -> float

    Returns the amount of a species by its name (mol).

    param str name:

    Name of the species.

    Example:

    amount = engine.speciesAmount("H2O@")
    print(amount)
    
speciesAmounts(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the amounts of all species in the system (mol).

Example:

amounts = engine.speciesAmounts()
print(amounts)
speciesCharge(self: xgems.PyxGEMS.ChemicalEngine, index: int) float

Returns the electrical charge of a species by its index.

Parameters:

index (int) – Index of the species.

Example:

charge = engine.speciesCharge(0)
print(charge)
speciesLowerLimits(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the lower limits for all species in the system (mol).

Example:

limits = engine.speciesLowerLimits()
print(limits)
speciesMolalities(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the molalities of all species in the system (mol/kg).

Example:

molalities = engine.speciesMolalities()
print(molalities)
speciesMolarMasses(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the molar masses of all species in the system (kg/mol).

Example:

species_molar_masses = engine.speciesMolarMasses()
print(species_molar_masses)
speciesName(self: xgems.PyxGEMS.ChemicalEngine, index: int) str

Returns the name of a species by its index.

Parameters:

index (int) – Index of the species.

Example:

species_name = engine.speciesName(0)
print(species_name)
speciesUpperLimits(self: xgems.PyxGEMS.ChemicalEngine) numpy.ndarray[numpy.float64[m, 1]]

Returns the upper limits for all species in the system (mol).

Example:

limits = engine.speciesUpperLimits()
print(limits)
standardMolarEnthalpy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the standard molar enthalpy of a specific species by its index (J/mol).

Parameters:

index (int) – Index of the species.

Example:

enthalpy = engine.standardMolarEnthalpy(0)
print(enthalpy)
standardMolarEntropy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the standard molar entropy of a specific species by its index (J/K/mol).

Parameters:

index (int) – Index of the species.

Example:

entropy = engine.standardMolarEntropy(1)
print(entropy)
standardMolarGibbsEnergy(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the standard molar Gibbs energy of a specific species by its index (J/mol).

Parameters:

index (int) – Index of the species.

Example:

gibbs_energy = engine.standardMolarGibbsEnergy(0)
print(gibbs_energy)
standardMolarHeatCapacityConstP(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the standard molar heat capacity at constant pressure for all species (J/K/mol).

Example:

heat_capacity = engine.standardMolarHeatCapacityConstP()
print(heat_capacity)
standardMolarVolume(self: xgems.PyxGEMS.ChemicalEngine, arg0: int) float

Returns the standard molar volume of a species by its index. (m³/mol).

Parameters:

index (int) – Index of the species.

Example:

volume = engine.standardMolarVolume(0)
print(volume)
systemEnthalpy(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the total enthalpy of the system (J).

Example:

enthalpy = engine.systemEnthalpy()
print(enthalpy)
systemEntropy(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the total entropy of the system (J/K).

Example:

entropy = engine.systemEntropy()
print(entropy)
systemGibbsEnergy(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the total Gibbs energy of the system (J).

Example:

gibbs_energy = engine.systemGibbsEnergy()
print(gibbs_energy)
systemHeatCapacityConstP(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the total isobaric heat capacity of the system (J/K).

Example:

heat_capacity = engine.systemHeatCapacityConstP()
print(heat_capacity)
systemMass(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the total mass of the system (kg).

Example:

mass = engine.systemMass()
print(mass)
systemVolume(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the total volume of the system (m³).

Example:

volume = engine.systemVolume()
print(volume)
temperature(self: xgems.PyxGEMS.ChemicalEngine) float

Returns the current temperature of the system (K).

Return float:

Temperature in Kelvin.

Example:

temp = engine.temperature()
print(temp)
writeDbrToFile(self: xgems.PyxGEMS.ChemicalEngine, filename: str) None

Writes the current node composition (DBR) to a file.

Parameters:

filename (str) – Path to the output DBR file.

Example:

engine.writeDbrToFile("output.dbr")
writeDbrToJsonString(self: xgems.PyxGEMS.ChemicalEngine) str

Returns the current DBR as a JSON string.

Returns:

JSON string representing the system composition.

Return type:

str

Example:

json_state = engine.writeDbrToJsonString()
print(json_state)