EquilibriumSpecs.hpp
46 using ChemicalPotentialFn = Fn<real(ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w)>;
95 using Func1 = Fn<real(ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w)>;
113 EquationConstraintFn(Func2 const& f) : _fn([=](ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w) -> real { return f(props, w); }) {}
116 EquationConstraintFn(Func3 const& f) : _fn([=](ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w) -> real { return f(props); }) {}
122 auto operator()(ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w) const -> real { return _fn(props, p, w); }
154 struct [[deprecated("ConstraintEquation has been renamed to EquationConstraint. Please make this change in your code.")]] ConstraintEquation : EquationConstraint
164 using Func = Fn<VectorXr(ChemicalProps const& props, VectorXrConstRef const& w, VectorXrConstRef const& p)>;
296 //=================================================================================================
300 //=================================================================================================
320 //=================================================================================================
324 //=================================================================================================
417 //=================================================================================================
421 //=================================================================================================
435 //=================================================================================================
439 //=================================================================================================
561 //=================================================================================================
565 //=================================================================================================
603 //=================================================================================================
607 //=================================================================================================
624 //=================================================================================================
628 //=================================================================================================
666 //=================================================================================================
670 //=================================================================================================
702 //=================================================================================================
706 //=================================================================================================
732 //=================================================================================================
736 //=================================================================================================
804 //=================================================================================================
806 // METHODS THAT ASSEMBLE CONSTRAINTS AND MATRICES FOR CURRENT STATE OF EQUILIBRIUM SPECIFICATIONS
808 //=================================================================================================
A type used to represent the chemical formula of a chemical species.
Definition: ChemicalFormula.hpp:27
The class that computes chemical properties of a chemical system.
Definition: ChemicalProps.hpp:34
The class used to represent a chemical system and its attributes and properties.
Definition: ChemicalSystem.hpp:70
The class used to define conditions to be satisfied at chemical equilibrium.
Definition: EquilibriumSpecs.hpp:291
auto addUnknownActivity(String const &species) -> void
Specify that the activity of a species is unknown at equilibrium and must be computed.
static auto SV(ChemicalSystem const &system) -> EquilibriumSpecs
Return specifications for a chemical equilbrium problem with given entropy (S) and volume (V).
auto entropy() -> void
Specify that the entropy of the system is given at chemical equilibrium.
auto elementMass(StringOrIndex const &element) -> void
Specify that the mass of an element is given at chemical equilibrium.
auto lnActivity(Species const &species) -> void
Specify that the ln activity of a species is given at chemical equilibrium.
auto helmholtzEnergy() -> void
Specify that the Helmholtz energy of the system is given at chemical equilibrium.
auto lnActivity(String species) -> void
Specify that the ln activity of a species is given at chemical equilibrium.
static auto HP(ChemicalSystem const &system) -> EquilibriumSpecs
Return specifications for a chemical equilbrium problem with given enthalpy (H) and pressure (P).
auto volume() -> void
Specify that the volume of the system is given at chemical equilibrium.
static auto UV(ChemicalSystem const &system) -> EquilibriumSpecs
Return specifications for a chemical equilbrium problem with given internal (U) energy and volume (V)...
auto elementMassInPhase(StringOrIndex const &element, StringOrIndex const &phase) -> void
Specify that the mass of an element in a phase is given at chemical equilibrium.
static auto TP(ChemicalSystem const &system) -> EquilibriumSpecs
Return specifications for a chemical equilbrium problem with given temperature (T) and pressure (P).
auto phaseAmount(StringOrIndex const &phase) -> void
Specify that the amount of a phase is given at chemical equilibrium.
static auto SP(ChemicalSystem const &system) -> EquilibriumSpecs
Return specifications for a chemical equilbrium problem with given entropy (S) and pressure (P).
auto chemicalPotential(String substance) -> void
Specify that the chemical potential of a substance is given at chemical equilibrium.
auto openTo(ChemicalFormula const &substance) -> void
Specify that the chemical system is open to a substance.
auto activity(String species) -> void
Specify that the activity of a species is given at chemical equilibrium.
auto phaseVolume(StringOrIndex const &phase) -> void
Specify that the volume of a phase is given at chemical equilibrium.
auto pH() -> void
Specify that the pH is given at chemical equilibrium.
auto pressure() -> void
Specify that the pressure of the system is given at chemical equilibrium.
auto fugacity(String gas) -> void
Specify that the fugacity of a gaseous species is given at chemical equilibrium.
auto unknownTemperature() -> void
Specify that the temperature of the system is unknown in the chemical equilibrium calculation.
auto unknownPressure() -> void
Specify that the pressure of the system is unknown in the chemical equilibrium calculation.
auto lgActivity(String species) -> void
Specify that the lg activity of a species is given at chemical equilibrium.
auto numInputs() const -> Index
Return the number of introduced input variables.
auto elementAmountInPhase(StringOrIndex const &element, StringOrIndex const &phase) -> void
Specify that the amount of an element in a phase is given at chemical equilibrium.
auto phaseMass(StringOrIndex const &phase) -> void
Specify that the mass of a phase is given at chemical equilibrium.
EquilibriumSpecs(ChemicalSystem const &system)
Construct an EquilibriumSpecs object.
static auto TV(ChemicalSystem const &system) -> EquilibriumSpecs
Return specifications for a chemical equilbrium problem with given temperature (T) and volume (V).
auto charge() -> void
Specify that the electric charge is given at chemical equilibrium.
auto addUnknownStandardChemicalPotential(String const &species) -> void
Specify that the standard chemical potential of a species is unknown at equilibrium and must be compu...
auto internalEnergy() -> void
Specify that the internal energy of the system is given at chemical equilibrium.
auto enthalpy() -> void
Specify that the enthalpy of the system is given at chemical equilibrium.
auto elementAmount(StringOrIndex const &element) -> void
Specify that the amount of an element is given at chemical equilibrium.
auto addUnknownChemicalPotential(String const &species) -> void
Specify that the chemical potential of a species is unknown at equilibrium and must be computed.
auto gibbsEnergy() -> void
Specify that the Gibbs energy of the system is given at chemical equilibrium.
auto addUnknownActivityCoefficient(String const &species) -> void
Specify that the activity coefficient of a species is unknown at equilibrium and must be computed.
auto addUnknownTitrantAmount(ChemicalFormula const &substance) -> void
Specify that the chemical system is open to a given chemical state. // TODO: Implement EquilibriumSpe...
auto temperature() -> void
Specify that the temperature of the system is given at chemical equilibrium.
A type used to represent the value of a parameter and its lower and upper bounds.
Definition: Param.hpp:32
A type used to represent a chemical species and its attributes.
Definition: Species.hpp:35
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:28
Eigen::Ref< const VectorXr > VectorXrConstRef
Convenient alias to Eigen type.
Definition: Matrix.hpp:60
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
std::vector< std::string > Strings
Convenient alias for std::vector<String>.
Definition: Types.hpp:55
std::variant< Index, int, std::string > StringOrIndex
The type used to accept either a name or an index.
Definition: Types.hpp:58
autodiff::VectorXreal VectorXr
Convenient alias to Eigen type.
Definition: Matrix.hpp:58
std::function< F > Fn
Convenient alias for std::function<R(Args...)>.
Definition: Types.hpp:110
Used to define equation constraints in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:155
Used to define a p control variable in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:69
ChemicalFormula substance
The chemical formula of the substance associated to this p control variable (optional).
Definition: EquilibriumSpecs.hpp:79
Index ispecies
The index of the species whose chemical potential is unknown and defined in terms of this p control v...
Definition: EquilibriumSpecs.hpp:82
ChemicalPotentialFn fn
The function that introduces association between this p control variable and the chemical potential o...
Definition: EquilibriumSpecs.hpp:85
String name
The unique name for this p control variable (required).
Definition: EquilibriumSpecs.hpp:76
Fn< real(ChemicalProps const &props, real const &pk)> ChemicalPotentialFn
The signature of functions that evaluate the chemical potential of a species in terms of a p control ...
Definition: EquilibriumSpecs.hpp:73
Used to define a q control variable in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:41
Fn< real(ChemicalProps const &props, VectorXrConstRef const &p, VectorXrConstRef const &w)> ChemicalPotentialFn
The signature of functions that evaluate the prescribed chemical potential of a substance.
Definition: EquilibriumSpecs.hpp:46
ChemicalFormula substance
The chemical formula of the substance associated to this q control variable (required).
Definition: EquilibriumSpecs.hpp:52
String id
The unique identifier for the chemical potential constraint associated to this q control variable (re...
Definition: EquilibriumSpecs.hpp:55
ChemicalPotentialFn fn
The chemical potential function associated to this q control variable (required).
Definition: EquilibriumSpecs.hpp:58
String name
The unique name for this q control variable (required).
Definition: EquilibriumSpecs.hpp:49
Used to define the function that evaluates the residual of an equation constraint in a chemical equil...
Definition: EquilibriumSpecs.hpp:90
Fn< real(ChemicalProps const &props)> Func3
An alternative signature of functions that evaluate the residual of an equation constraint.
Definition: EquilibriumSpecs.hpp:104
EquationConstraintFn()=default
Construct a default EquationConstraintFn object.
auto operator=(Func1 const &f)
Assign an equilibrium constraint function with signature EquationConstraintFn::Func1 to this Equation...
Definition: EquilibriumSpecs.hpp:125
EquationConstraintFn(Func3 const &f)
Construct an EquationConstraintFn object with given equilibrium constraint function with signature Fu...
Definition: EquilibriumSpecs.hpp:116
auto operator=(Func3 const &f)
Assign an equilibrium constraint function with signature EquationConstraintFn::Func3 to this Equation...
Definition: EquilibriumSpecs.hpp:131
EquationConstraintFn(Func1 const &f)
Construct an EquationConstraintFn object with given equilibrium constraint function with signature Fu...
Definition: EquilibriumSpecs.hpp:110
EquationConstraintFn(Func2 const &f)
Construct an EquationConstraintFn object with given equilibrium constraint function with signature Fu...
Definition: EquilibriumSpecs.hpp:113
Func1 _fn
The function that evaluates the residual of the equation constraint.
Definition: EquilibriumSpecs.hpp:140
auto operator=(Func2 const &f)
Assign an equilibrium constraint function with signature EquationConstraintFn::Func2 to this Equation...
Definition: EquilibriumSpecs.hpp:128
auto initialized() const
Return true if this EquationConstraintFn object has been initialized with an equilibrium constraint f...
Definition: EquilibriumSpecs.hpp:134
auto operator()(ChemicalProps const &props, VectorXrConstRef const &p, VectorXrConstRef const &w) const -> real
Evaluate the residual of the equation constraint.
Definition: EquilibriumSpecs.hpp:122
Fn< real(ChemicalProps const &props, VectorXrConstRef const &p, VectorXrConstRef const &w)> Func1
The main signature of functions that evaluate the residual of an equation constraint.
Definition: EquilibriumSpecs.hpp:95
Fn< real(ChemicalProps const &props, VectorXrConstRef const &w)> Func2
An alternative signature of functions that evaluate the residual of an equation constraint.
Definition: EquilibriumSpecs.hpp:100
Used to define equation constraints in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:145
String id
The unique identifier for this equation constraint.
Definition: EquilibriumSpecs.hpp:147
EquationConstraintFn fn
The function defining the equation to be satisfied at chemical equilibrium.
Definition: EquilibriumSpecs.hpp:150
Used to define a system of equation constraints in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:159
Fn< VectorXr(ChemicalProps const &props, VectorXrConstRef const &w, VectorXrConstRef const &p)> Func
The signature of functions that evaluate the residual of the system of equation constraints.
Definition: EquilibriumSpecs.hpp:164
Strings ids
The unique identifier for each equation constraint.
Definition: EquilibriumSpecs.hpp:167
Func fn
The function defining the system of equations to be satisfied at chemical equilibrium.
Definition: EquilibriumSpecs.hpp:170
Used to define reactivity restrictions among species in the chemical equilibrium calculation.
Definition: EquilibriumSpecs.hpp:177
VectorXd Kn
The linear equation coefficients in the constraint corresponding to the species amounts variables n.
Definition: EquilibriumSpecs.hpp:182
String id
The unique identifier for this reactivity constraint.
Definition: EquilibriumSpecs.hpp:179
VectorXd Kp
The linear equation coefficients in the constraint corresponding to the introduced control variables ...
Definition: EquilibriumSpecs.hpp:185
Used to define a system of reactivity restrictions among species in the chemical equilibrium calculat...
Definition: EquilibriumSpecs.hpp:192
MatrixXd Kp
The coefficient matrix of the linear reactivity constraint equations corresponding to the introduced ...
Definition: EquilibriumSpecs.hpp:200
MatrixXd Kn
The coefficient matrix of the linear reactivity constraint equations corresponding to the species amo...
Definition: EquilibriumSpecs.hpp:197
Strings ids
The unique identifiers for each reactivity constraint.
Definition: EquilibriumSpecs.hpp:194