EquilibriumSpecs.hpp
44 using ChemicalPotentialFn = Fn<real(ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w)>;
85 using Func1 = Fn<real(ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w)>;
103 EquationConstraintFn(Func2 const& f) : _fn([=](ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w) -> real { return f(props, w); }) {}
106 EquationConstraintFn(Func3 const& f) : _fn([=](ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w) -> real { return f(props); }) {}
112 auto operator()(ChemicalProps const& props, VectorXrConstRef const& p, VectorXrConstRef const& w) const -> real { return _fn(props, p, w); }
144 struct [[deprecated("ConstraintEquation has been renamed to EquationConstraint. Please make this change in your code.")]] ConstraintEquation : EquationConstraint
154 using Func = Fn<VectorXr(ChemicalProps const& props, VectorXrConstRef const& w, VectorXrConstRef const& p)>;
286 //=================================================================================================
290 //=================================================================================================
310 //=================================================================================================
314 //=================================================================================================
407 //=================================================================================================
411 //=================================================================================================
425 //=================================================================================================
429 //=================================================================================================
551 //=================================================================================================
555 //=================================================================================================
593 //=================================================================================================
597 //=================================================================================================
602 //=================================================================================================
606 //=================================================================================================
641 //=================================================================================================
645 //=================================================================================================
674 //=================================================================================================
678 //=================================================================================================
701 //=================================================================================================
705 //=================================================================================================
767 //=================================================================================================
769 // METHODS THAT ASSEMBLE CONSTRAINTS AND MATRICES FOR CURRENT STATE OF EQUILIBRIUM SPECIFICATIONS
771 //=================================================================================================
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:281
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 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 gibbsEnergy() -> void
Specify that the Gibbs energy of the system is given at chemical equilibrium.
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 a chemical species and its attributes.
Definition: Species.hpp:35
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
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:145
Used to define a p control variable in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:65
ChemicalFormula substance
The chemical formula of the substance associated to this p control variable (optional).
Definition: EquilibriumSpecs.hpp:75
String name
The unique name for this p control variable (required).
Definition: EquilibriumSpecs.hpp:72
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:69
Used to define a q control variable in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:39
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:44
ChemicalFormula substance
The chemical formula of the substance associated to this q control variable (required).
Definition: EquilibriumSpecs.hpp:50
String id
The unique identifier for the chemical potential constraint associated to this q control variable (re...
Definition: EquilibriumSpecs.hpp:53
ChemicalPotentialFn fn
The chemical potential function associated to this q control variable (required).
Definition: EquilibriumSpecs.hpp:56
String name
The unique name for this q control variable (required).
Definition: EquilibriumSpecs.hpp:47
Used to define the function that evaluates the residual of an equation constraint in a chemical equil...
Definition: EquilibriumSpecs.hpp:80
Fn< real(ChemicalProps const &props)> Func3
An alternative signature of functions that evaluate the residual of an equation constraint.
Definition: EquilibriumSpecs.hpp:94
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:115
EquationConstraintFn(Func3 const &f)
Construct an EquationConstraintFn object with given equilibrium constraint function with signature Fu...
Definition: EquilibriumSpecs.hpp:106
auto operator=(Func3 const &f)
Assign an equilibrium constraint function with signature EquationConstraintFn::Func3 to this Equation...
Definition: EquilibriumSpecs.hpp:121
EquationConstraintFn(Func1 const &f)
Construct an EquationConstraintFn object with given equilibrium constraint function with signature Fu...
Definition: EquilibriumSpecs.hpp:100
EquationConstraintFn(Func2 const &f)
Construct an EquationConstraintFn object with given equilibrium constraint function with signature Fu...
Definition: EquilibriumSpecs.hpp:103
Func1 _fn
The function that evaluates the residual of the equation constraint.
Definition: EquilibriumSpecs.hpp:130
auto operator=(Func2 const &f)
Assign an equilibrium constraint function with signature EquationConstraintFn::Func2 to this Equation...
Definition: EquilibriumSpecs.hpp:118
auto initialized() const
Return true if this EquationConstraintFn object has been initialized with an equilibrium constraint f...
Definition: EquilibriumSpecs.hpp:124
auto operator()(ChemicalProps const &props, VectorXrConstRef const &p, VectorXrConstRef const &w) const -> real
Evaluate the residual of the equation constraint.
Definition: EquilibriumSpecs.hpp:112
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:85
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:90
Used to define equation constraints in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:135
String id
The unique identifier for this equation constraint.
Definition: EquilibriumSpecs.hpp:137
EquationConstraintFn fn
The function defining the equation to be satisfied at chemical equilibrium.
Definition: EquilibriumSpecs.hpp:140
Used to define a system of equation constraints in a chemical equilibrium problem.
Definition: EquilibriumSpecs.hpp:149
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:154
Strings ids
The unique identifier for each equation constraint.
Definition: EquilibriumSpecs.hpp:157
Func fn
The function defining the system of equations to be satisfied at chemical equilibrium.
Definition: EquilibriumSpecs.hpp:160
Used to define reactivity restrictions among species in the chemical equilibrium calculation.
Definition: EquilibriumSpecs.hpp:167
VectorXd Kn
The linear equation coefficients in the constraint corresponding to the species amounts variables n.
Definition: EquilibriumSpecs.hpp:172
String id
The unique identifier for this reactivity constraint.
Definition: EquilibriumSpecs.hpp:169
VectorXd Kp
The linear equation coefficients in the constraint corresponding to the introduced control variables ...
Definition: EquilibriumSpecs.hpp:175
Used to define a system of reactivity restrictions among species in the chemical equilibrium calculat...
Definition: EquilibriumSpecs.hpp:182
MatrixXd Kp
The coefficient matrix of the linear reactivity constraint equations corresponding to the introduced ...
Definition: EquilibriumSpecs.hpp:190
MatrixXd Kn
The coefficient matrix of the linear reactivity constraint equations corresponding to the species amo...
Definition: EquilibriumSpecs.hpp:187
Strings ids
The unique identifiers for each reactivity constraint.
Definition: EquilibriumSpecs.hpp:184