Reaktoro  v2.1.1
A unified framework for modeling chemically reactive systems
EquilibriumSetup Class Reference

Used to construct the optimization problem for a chemical equilibrium calculation. More...

#include <EquilibriumSetup.hpp>

Public Member Functions

 EquilibriumSetup (EquilibriumSpecs const &specs)
 Construct an EquilibriumSetup object with given specifications.
 
 EquilibriumSetup (EquilibriumSetup const &other)
 Construct a copy of an EquilibriumSetup object.
 
 ~EquilibriumSetup ()
 Destroy this EquilibriumSetup object.
 
auto operator= (EquilibriumSetup other) -> EquilibriumSetup &
 Assign a copy of an EquilibriumSetup object to this.
 
auto setOptions (EquilibriumOptions const &options) -> void
 Set the options for the solution of the equilibrium problem.
 
auto dims () const -> EquilibriumDims const &
 Return the dimensions of the variables in the equilibrium problem.
 
auto options () const -> EquilibriumOptions const &
 Return the options for the solution of the equilibrium problem.
 
auto Aex () const -> MatrixXdConstRef
 Return the coefficient matrix Aex in the optimization problem.
 
auto Aen () const -> MatrixXdConstRef
 Return the block Aen corresponding to variables n in the coefficient matrix Aex = [Aen Aeq] of the optimization problem.
 
auto Aeq () const -> MatrixXdConstRef
 Return the block Aeq corresponding to variables n in the coefficient matrix Aex = [Aen Aeq] of the optimization problem.
 
auto Aep () const -> MatrixXdConstRef
 Return the coefficient matrix Aep in the optimization problem.
 
auto assembleLowerBoundsVector (EquilibriumRestrictions const &restrictions, ChemicalState const &state0) const -> VectorXd
 Assemble the lower bound vector xlower in the optimization problem where x = (n, q). More...
 
auto assembleUpperBoundsVector (EquilibriumRestrictions const &restrictions, ChemicalState const &state0) const -> VectorXd
 Assemble the upper bound vector xupper in the optimization problem where x = (n, q). More...
 
auto update (VectorXrConstRef x, VectorXrConstRef p, VectorXrConstRef w) -> void
 Update the chemical potentials and residuals of the equilibrium constraints. More...
 
auto updateGradX (VectorXlConstRef ibasicvars) -> void
 Update the derivatives of the chemical potentials and residuals of the equilibrium constraints with respect to x. More...
 
auto updateGradP () -> void
 Update the derivatives of the chemical potentials and residuals of the equilibrium constraints with respect to p.
 
auto updateGradW () -> void
 Update the derivatives of the chemical potentials and residuals of the equilibrium constraints with respect to w.
 
auto getGibbsEnergy () -> real
 Get the updated Gibbs energy value.
 
auto getGibbsGradX () -> VectorXdConstRef
 Get the updated gradient vector of the Gibbs energy with respect to x.
 
auto getGibbsHessianX () -> MatrixXdConstRef
 Get the updated Hessian matrix of the Gibbs energy with respect to x.
 
auto getGibbsHessianP () -> MatrixXdConstRef
 Get the updated Hessian matrix of the Gibbs energy with respect to p.
 
auto getGibbsHessianC () -> MatrixXdConstRef
 Get the updated Hessian matrix of the Gibbs energy with respect to c.
 
auto getConstraintResiduals () -> MatrixXdConstRef
 Get the updated residuals of the equilibrium constraints.
 
auto getConstraintResidualsGradX () -> MatrixXdConstRef
 Get the updated Jacobian of the equilibrium constraints with respect to x.
 
auto getConstraintResidualsGradP () -> MatrixXdConstRef
 Get the updated Jacobian of the equilibrium constraints with respect to p.
 
auto getConstraintResidualsGradC () -> MatrixXdConstRef
 Get the updated Jacobian of the equilibrium constraints with respect to c.
 
auto usingPartiallyExactDerivatives () -> bool
 Return true if partially exact derivatives are adopted for the Hessian matrix Hxx.
 
auto usingDiagonalApproxDerivatives () -> bool
 Return true if a diagonal structure is adopted for the Hessian matrix Hxx.
 
auto assembleChemicalPropsJacobianBegin () -> void
 Enable recording of derivatives of the chemical properties with respect to *(n, p, w)* to construct its full Jacobian matrix. More...
 
auto assembleChemicalPropsJacobianEnd () -> void
 Disable recording of derivatives of the chemical properties with respect to *(n, p, w)* to indicate the end of the full Jacobian matrix construction.
 
auto equilibriumProps () const -> EquilibriumProps const &
 Return the current chemical properties of the system as an EquilibriumProps object.
 
auto chemicalProps () const -> ChemicalProps const &
 Return the current chemical properties of the system as a ChemicalProps object.
 

Detailed Description

Used to construct the optimization problem for a chemical equilibrium calculation.

Member Function Documentation

◆ assembleLowerBoundsVector()

auto assembleLowerBoundsVector ( EquilibriumRestrictions const &  restrictions,
ChemicalState const &  state0 
) const -> VectorXd

Assemble the lower bound vector xlower in the optimization problem where x = (n, q).

Parameters
restrictionsThe lower and upper bounds information of the species.
state0The initial chemical state of the system.

◆ assembleUpperBoundsVector()

auto assembleUpperBoundsVector ( EquilibriumRestrictions const &  restrictions,
ChemicalState const &  state0 
) const -> VectorXd

Assemble the upper bound vector xupper in the optimization problem where x = (n, q).

Parameters
restrictionsThe lower and upper bounds information of the species.
state0The initial chemical state of the system.

◆ update()

auto update ( VectorXrConstRef  x,
VectorXrConstRef  p,
VectorXrConstRef  w 
) -> void

Update the chemical potentials and residuals of the equilibrium constraints.

Parameters
xThe amounts of the species and implicit titrants, \(x = (n, q)\).
pThe values of the p control variables (e.g., temperature, pressure, and/or amounts of explicit titrants).
wThe input variables w in the chemical equilibrium problem.

◆ updateGradX()

auto updateGradX ( VectorXlConstRef  ibasicvars) -> void

Update the derivatives of the chemical potentials and residuals of the equilibrium constraints with respect to x.

Parameters
ibasicvarsThe indices of the current basic variables in x.

◆ assembleChemicalPropsJacobianBegin()

auto assembleChemicalPropsJacobianBegin ( ) -> void

Enable recording of derivatives of the chemical properties with respect to *(n, p, w)* to construct its full Jacobian matrix.

Consider a series of forward automatic differentiation passes to compute the partial derivatives of the chemical properties with respect to the variables *(n, p, w)*. Use this method before these operations so that these derivatives are recorded in this EquilibriumProps object. At the end of all forward passes, the full Jacobian of the chemical properties will have been constructed.

Note
Call assembleChemicalPropsJacobianEnd after these forward passes have ended to eliminates the minor overhead of recording derivatives.

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