Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
ChemicalState Class Reference

The chemical state of a chemical system. More...

#include <ChemicalState.hpp>

Classes

class  Equilibrium
 The access to the properties related to an equilibrium state in a ChemicalState object. More...
 

Public Member Functions

 ChemicalState (ChemicalSystem const &system)
 Construct a ChemicalState instance with standard conditions. More...
 
 ChemicalState (ChemicalState const &other)
 Construct a copy of a ChemicalState instance.
 
virtual ~ChemicalState ()
 Destroy this ChemicalState instance.
 
auto operator= (ChemicalState other) -> ChemicalState &
 Assign a ChemicalState instance to this instance.
 
auto setTemperature (real const &value) -> void
 Set the temperature of the chemical state. More...
 
auto setTemperature (real value, Chars unit) -> void
 Set the temperature of the chemical state with given unit. More...
 
auto temperature (real const &value) -> void
 Set the temperature of the chemical state. More...
 
auto temperature (real value, Chars unit) -> void
 Set the temperature of the chemical state with given unit. More...
 
auto temperature () const -> real
 Return the temperature in the chemical state (in K).
 
auto setPressure (real const &value) -> void
 Set the pressure of the chemical state. More...
 
auto setPressure (real value, Chars unit) -> void
 Set the pressure of the chemical state with given unit. More...
 
auto pressure (real const &value) -> void
 Set the pressure of the chemical state. More...
 
auto pressure (real value, Chars unit) -> void
 Set the pressure of the chemical state with given unit. More...
 
auto pressure () const -> real
 Return the pressure in the chemical state (in Pa).
 
auto setSpeciesAmounts (real const &value) -> void
 Set the amounts of all species in the chemical state to a common value (in mol).
 
auto setSpeciesAmounts (ArrayXrConstRef const &n) -> void
 Set the amounts of the species in the chemical state with given array (in mol).
 
auto setSpeciesAmounts (ArrayXdConstRef const &n) -> void
 Set the amounts of the species in the chemical state with given array (in mol).
 
auto setSpeciesAmount (Index ispecies, real const &amount) -> void
 Set the amount of a specific species in the system (in mol). More...
 
auto setSpeciesAmount (StringOrIndex const &species, real amount, Chars unit) -> void
 Set the amount of a specific species in the system. More...
 
auto setSpeciesMass (StringOrIndex const &species, real mass, Chars unit) -> void
 Set the mass of a specific species in the system. More...
 
auto set (StringOrIndex const &species, real value, Chars unit) -> void
 Set the amount or mass of a chemical species in the chemical state. More...
 
auto add (StringOrIndex const &species, real value, Chars unit) -> void
 Add a specified amount or mass of a chemical species in the chemical state. More...
 
auto speciesAmounts () const -> ArrayXrConstRef
 Return the amounts of the species in the chemical state (in mol).
 
auto speciesAmountsInPhase (StringOrIndex const &phase) const -> ArrayXrConstRef
 Return the amounts of the species from a phase in the chemical state (in mol). More...
 
auto speciesAmount (StringOrIndex const &species) const -> real
 Return the amount of a species in the chemical state (in mol). More...
 
auto speciesMass (StringOrIndex const &species) const -> real
 Return the mass of a species in the chemical state (in kg). More...
 
auto componentAmounts () const -> ArrayXr
 Return the amounts of the conservative components (elements and charge) in the chemical state (in mol).
 
auto elementAmounts () const -> ArrayXr
 Return the amounts of the elements in the chemical state (in mol).
 
auto charge () const -> real
 Return the electric charge in the chemical state (in mol).
 
auto scaleSpeciesAmounts (real const &scalar) -> void
 Scale the amounts of every species by a given factor. More...
 
auto scaleSpeciesAmounts (real const &scalar, Indices const &indices) -> void
 Scale the amounts of the species with given indices. More...
 
auto scaleSpeciesAmountsInPhase (StringOrIndex const &phase, real const &scalar) -> void
 Scale the amounts of the species in a phase by a given factor. More...
 
auto scaleAmount (real amount, Chars unit) -> void
 Scale the amount of the system to a new value. More...
 
auto scalePhaseAmount (StringOrIndex const &phase, real amount, Chars unit) -> void
 Scale the amount of a phase to a new value. More...
 
auto scaleFluidAmount (real amount, Chars unit) -> void
 Scale the total amount of fluids in the system to a new value. More...
 
auto scaleSolidAmount (real amount, Chars unit) -> void
 Scale the total amount of solids in the system to a new value. More...
 
auto scaleMass (real mass, Chars unit) -> void
 Scale the mass of the system to a new value. More...
 
auto scalePhaseMass (StringOrIndex const &phase, real mass, Chars unit) -> void
 Scale the mass of a phase to a new value. More...
 
auto scaleFluidMass (real mass, Chars unit) -> void
 Scale the total mass of fluids in the system to a new value. More...
 
auto scaleSolidMass (real mass, Chars unit) -> void
 Scale the total mass of solids in the system to a new value. More...
 
auto scaleVolume (real volume, Chars unit) -> void
 Scale the volume of the system to a new value. More...
 
auto scalePhaseVolume (StringOrIndex const &phase, real volume, Chars unit) -> void
 Scale the volume of a phase to a new value. More...
 
auto scaleFluidVolume (real volume, Chars unit) -> void
 Scale the total volume of fluids in the system to a new value. More...
 
auto scaleSolidVolume (real volume, Chars unit) -> void
 Scale the total volume of solids in the system to a new value. More...
 
auto update (real const &T, real const &P, ArrayXrConstRef const &n) -> void
 Update the chemical state and properties of the system. More...
 
auto updateIdeal (real const &T, real const &P, ArrayXrConstRef const &n) -> void
 Update the chemical state and properties of the system using ideal activity models. More...
 
auto system () const -> ChemicalSystem const &
 Return the underlying chemical system for this chemical state.
 
auto props () const -> ChemicalProps const &
 Return the chemical properties of the system. More...
 
auto props () -> ChemicalProps &
 Return the chemical properties of the system. More...
 
auto equilibrium () const -> Equilibrium const &
 Return the equilibrium properties of a calculated chemical equilibrium state.
 
auto equilibrium () -> Equilibrium &
 Return the equilibrium properties of a calculated chemical equilibrium state.
 
auto output (std::ostream &out) const -> void
 Output this ChemicalState instance to a stream.
 
auto output (String const &filename) const -> void
 Output this ChemicalState instance to a file.
 

Detailed Description

The chemical state of a chemical system.

See also
ChemicalSystem

Constructor & Destructor Documentation

◆ ChemicalState()

ChemicalState ( ChemicalSystem const &  system)
explicit

Construct a ChemicalState instance with standard conditions.

This constructor creates an instance of ChemicalState with temperature 25 °C, pressure 1 bar, and zero mole amounts for the species.

Member Function Documentation

◆ setTemperature() [1/2]

auto setTemperature ( real const &  value) -> void

Set the temperature of the chemical state.

Parameters
valueThe temperature value (in K).

◆ setTemperature() [2/2]

auto setTemperature ( real  value,
Chars  unit 
) -> void

Set the temperature of the chemical state with given unit.

Parameters
valueThe temperature value.
unitThe temperature unit (must be convertible to K).

◆ temperature() [1/2]

auto temperature ( real const &  value) -> void

Set the temperature of the chemical state.

Parameters
valueThe temperature value (in K).
Note
This method is equivalent to ChemicalState::setTemperature(real)

◆ temperature() [2/2]

auto temperature ( real  value,
Chars  unit 
) -> void

Set the temperature of the chemical state with given unit.

Parameters
valueThe temperature value.
unitThe temperature unit (must be convertible to K).
Note
This method is equivalent to ChemicalState::setTemperature(real, String)

◆ setPressure() [1/2]

auto setPressure ( real const &  value) -> void

Set the pressure of the chemical state.

Parameters
valueThe pressure value (in Pa).

◆ setPressure() [2/2]

auto setPressure ( real  value,
Chars  unit 
) -> void

Set the pressure of the chemical state with given unit.

Parameters
valueThe pressure value.
unitThe pressure unit (must be convertible to Pa).

◆ pressure() [1/2]

auto pressure ( real const &  value) -> void

Set the pressure of the chemical state.

Parameters
valueThe pressure value (in Pa).
Note
This method is equivalent to ChemicalState::setPressure(real)

◆ pressure() [2/2]

auto pressure ( real  value,
Chars  unit 
) -> void

Set the pressure of the chemical state with given unit.

Parameters
valueThe pressure value.
unitThe pressure unit (must be convertible to Pa).
Note
This method is equivalent to ChemicalState::setPressure(real, String)

◆ setSpeciesAmount() [1/2]

auto setSpeciesAmount ( Index  ispecies,
real const &  amount 
) -> void

Set the amount of a specific species in the system (in mol).

Parameters
ispeciesThe index of the species.
amountThe amount of the species

◆ setSpeciesAmount() [2/2]

auto setSpeciesAmount ( StringOrIndex const &  species,
real  amount,
Chars  unit 
) -> void

Set the amount of a specific species in the system.

Parameters
speciesThe name or index of the species.
amountThe amount of the species
unitThe amount unit (must be convertible to mol)

◆ setSpeciesMass()

auto setSpeciesMass ( StringOrIndex const &  species,
real  mass,
Chars  unit 
) -> void

Set the mass of a specific species in the system.

Parameters
speciesThe name or index of the species.
massThe mass of the species
unitThe mass unit (must be convertible to kg)

◆ set()

auto set ( StringOrIndex const &  species,
real  value,
Chars  unit 
) -> void

Set the amount or mass of a chemical species in the chemical state.

Parameters
speciesThe name or index of the species.
valueThe amount or mass value of the species.
unitThe amount or mass unit (must be convertible to mol or kg).
Warning
An error is thrown if the chemical system has no species with name species.

◆ add()

auto add ( StringOrIndex const &  species,
real  value,
Chars  unit 
) -> void

Add a specified amount or mass of a chemical species in the chemical state.

Parameters
speciesThe name or index of the species in the chemical system.
valueThe amount or mass value of the added species.
unitThe amount or mass unit (must be convertible to mol or kg).
Warning
An error is thrown if the chemical system has no species with name species.

◆ speciesAmountsInPhase()

auto speciesAmountsInPhase ( StringOrIndex const &  phase) const -> ArrayXrConstRef

Return the amounts of the species from a phase in the chemical state (in mol).

Parameters
phaseThe name or index of the phase in the system.

◆ speciesAmount()

auto speciesAmount ( StringOrIndex const &  species) const -> real

Return the amount of a species in the chemical state (in mol).

Parameters
speciesThe name or index of the species.

◆ speciesMass()

auto speciesMass ( StringOrIndex const &  species) const -> real

Return the mass of a species in the chemical state (in kg).

Parameters
speciesThe name or index of the species.

◆ scaleSpeciesAmounts() [1/2]

auto scaleSpeciesAmounts ( real const &  scalar) -> void

Scale the amounts of every species by a given factor.

Parameters
scalarThe scale factor

◆ scaleSpeciesAmounts() [2/2]

auto scaleSpeciesAmounts ( real const &  scalar,
Indices const &  indices 
) -> void

Scale the amounts of the species with given indices.

Parameters
scalarThe scale factor
indicesThe indices of the species

◆ scaleSpeciesAmountsInPhase()

auto scaleSpeciesAmountsInPhase ( StringOrIndex const &  phase,
real const &  scalar 
) -> void

Scale the amounts of the species in a phase by a given factor.

Parameters
phaseThe name or index of the phase in the system.
scalarThe scale factor

◆ scaleAmount()

auto scaleAmount ( real  amount,
Chars  unit 
) -> void

Scale the amount of the system to a new value.

Parameters
amountThe new amount of the system
unitThe amount unit (must be convertible to mol)

◆ scalePhaseAmount()

auto scalePhaseAmount ( StringOrIndex const &  phase,
real  amount,
Chars  unit 
) -> void

Scale the amount of a phase to a new value.

Parameters
phaseThe name or index of the phase in the system.
amountThe new amount of the phase
unitThe amount unit (must be convertible to mol)

◆ scaleFluidAmount()

auto scaleFluidAmount ( real  amount,
Chars  unit 
) -> void

Scale the total amount of fluids in the system to a new value.

Parameters
amountThe new total amount of fluids in the system
unitThe amount unit (must be convertible to mol)

◆ scaleSolidAmount()

auto scaleSolidAmount ( real  amount,
Chars  unit 
) -> void

Scale the total amount of solids in the system to a new value.

Parameters
amountThe new total amount of solids in the system
unitThe amount unit (must be convertible to mol)

◆ scaleMass()

auto scaleMass ( real  mass,
Chars  unit 
) -> void

Scale the mass of the system to a new value.

Parameters
massThe new mass of the system
unitThe mass unit (must be convertible to kg)

◆ scalePhaseMass()

auto scalePhaseMass ( StringOrIndex const &  phase,
real  mass,
Chars  unit 
) -> void

Scale the mass of a phase to a new value.

Parameters
phaseThe name or index of the phase in the system.
massThe new mass of the phase
unitThe mass unit (must be convertible to kg)

◆ scaleFluidMass()

auto scaleFluidMass ( real  mass,
Chars  unit 
) -> void

Scale the total mass of fluids in the system to a new value.

Parameters
massThe new total mass of fluids in the system
unitThe mass unit (must be convertible to kg)

◆ scaleSolidMass()

auto scaleSolidMass ( real  mass,
Chars  unit 
) -> void

Scale the total mass of solids in the system to a new value.

Parameters
massThe new total mass of solids in the system
unitThe mass unit (must be convertible to kg)

◆ scaleVolume()

auto scaleVolume ( real  volume,
Chars  unit 
) -> void

Scale the volume of the system to a new value.

Parameters
volumeThe new volume of the system
unitThe volume unit (must be convertible to m3)

◆ scalePhaseVolume()

auto scalePhaseVolume ( StringOrIndex const &  phase,
real  volume,
Chars  unit 
) -> void

Scale the volume of a phase to a new value.

Parameters
phaseThe name or index of the phase in the system.
volumeThe new volume of the phase
unitThe volume unit (must be convertible to m3)

◆ scaleFluidVolume()

auto scaleFluidVolume ( real  volume,
Chars  unit 
) -> void

Scale the total volume of fluids in the system to a new value.

Parameters
volumeThe new total volume of fluids in the system
unitThe volume unit (must be convertible to m3)

◆ scaleSolidVolume()

auto scaleSolidVolume ( real  volume,
Chars  unit 
) -> void

Scale the total volume of solids in the system to a new value.

Parameters
volumeThe new total volume of solids in the system
unitThe volume unit (must be convertible to m3)

◆ update()

auto update ( real const &  T,
real const &  P,
ArrayXrConstRef const &  n 
) -> void

Update the chemical state and properties of the system.

Parameters
TThe temperature condition (in K)
PThe pressure condition (in Pa)
nThe amounts of the species in the system (in mol)

◆ updateIdeal()

auto updateIdeal ( real const &  T,
real const &  P,
ArrayXrConstRef const &  n 
) -> void

Update the chemical state and properties of the system using ideal activity models.

Parameters
TThe temperature condition (in K)
PThe pressure condition (in Pa)
nThe amounts of the species in the system (in mol)

◆ props() [1/2]

auto props ( ) const -> ChemicalProps const &

Return the chemical properties of the system.

For performance reasons, the stored chemical properties are not updated at every change in the chemical state. For a ChemicalState object state, update its chemical properties using state.props().update(state).

◆ props() [2/2]

auto props ( ) -> ChemicalProps &

Return the chemical properties of the system.

For performance reasons, the stored chemical properties are not updated at every change in the chemical state. For a ChemicalState object state, update its chemical properties using state.props().update(state).


The documentation for this class was generated from the following file: