Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
EquilibriumSensitivity.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // Reaktoro includes
21 #include <Reaktoro/Common/Matrix.hpp>
22 #include <Reaktoro/Core/ChemicalSystem.hpp>
23 #include <Reaktoro/Equilibrium/EquilibriumSpecs.hpp>
24 
25 namespace Reaktoro {
26 
37 {
38 public:
41 
43  explicit EquilibriumSensitivity(EquilibriumSpecs const& specs);
44 
46  auto initialize(EquilibriumSpecs const& specs) -> void;
47 
48  //======================================================================
49  // DERIVATIVES OF SPECIES AMOUNTS WITH RESPECT TO INPUT PARAMETERS
50  //======================================================================
51 
54  auto dndw(String const& wid) const -> VectorXdConstRef;
55 
57  auto dndw() const -> MatrixXdConstRef;
58 
60  auto dndw(MatrixXdConstRef data) -> void;
61 
62  //======================================================================
63  // DERIVATIVES OF p-CONTROL VARIABLES WITH RESPECT TO INPUT PARAMETERS
64  //======================================================================
65 
68  auto dpdw(String const& wid) const -> VectorXdConstRef;
69 
71  auto dpdw() const -> MatrixXdConstRef;
72 
74  auto dpdw(MatrixXdConstRef data) -> void;
75 
76  //======================================================================
77  // DERIVATIVES OF q-CONTROL VARIABLES WITH RESPECT TO INPUT PARAMETERS
78  //======================================================================
79 
82  auto dqdw(String const& wid) const -> VectorXdConstRef;
83 
85  auto dqdw() const -> MatrixXdConstRef;
86 
88  auto dqdw(MatrixXdConstRef data) -> void;
89 
90  //======================================================================
91  // DERIVATIVES OF SPECIES AMOUNTS WITH RESPECT TO COMPONENT AMOUNTS
92  //======================================================================
93 
95  auto dndc() const -> MatrixXdConstRef;
96 
98  auto dndc(MatrixXdConstRef data) -> void;
99 
100  //======================================================================
101  // DERIVATIVES OF p-CONTROL VARIABLES WITH RESPECT TO COMPONENT AMOUNTS
102  //======================================================================
103 
105  auto dpdc() const -> MatrixXdConstRef;
106 
108  auto dpdc(MatrixXdConstRef data) -> void;
109 
110  //======================================================================
111  // DERIVATIVES OF q-CONTROL VARIABLES WITH RESPECT TO COMPONENT AMOUNTS
112  //======================================================================
113 
115  auto dqdc() const -> MatrixXdConstRef;
116 
118  auto dqdc(MatrixXdConstRef data) -> void;
119 
120  //======================================================================
121  // TOTAL DERIVATIVES OF CHEMICAL PROPERTIES
122  //======================================================================
123 
125  auto dudw() const -> MatrixXdConstRef;
126 
128  auto dudc() const -> MatrixXdConstRef;
129 
131  auto dudw(MatrixXdConstRef data) -> void;
132 
134  auto dudc(MatrixXdConstRef data) -> void;
135 
136 private:
138  ChemicalSystem msystem;
139 
141  Strings minputs;
142 
144  MatrixXd mdndw;
145 
147  MatrixXd mdpdw;
148 
150  MatrixXd mdqdw;
151 
153  MatrixXd mdndc;
154 
156  MatrixXd mdpdc;
157 
159  MatrixXd mdqdc;
160 
162  MatrixXd mdudw;
163 
165  MatrixXd mdudc;
166 };
167 
168 } // namespace Reaktoro
The class used to represent a chemical system and its attributes and properties.
Definition: ChemicalSystem.hpp:70
The sensitivity derivatives of a chemical equilibrium state.
Definition: EquilibriumSensitivity.hpp:37
auto initialize(EquilibriumSpecs const &specs) -> void
Initialize this EquilibriumSensitivity object with given equilibrium problem specifications.
auto dqdc() const -> MatrixXdConstRef
Return the derivatives of the control variables q with respect to component amounts c.
EquilibriumSensitivity()
Construct a default EquilibriumSensitivity object.
auto dpdw() const -> MatrixXdConstRef
Return the derivatives of the p control variables with respect to the input variables w.
auto dndw(String const &wid) const -> VectorXdConstRef
Return the derivatives of the species amounts n with respect to an input variable in w.
auto dpdc() const -> MatrixXdConstRef
Return the derivatives of the control variables p with respect to component amounts c.
auto dndw() const -> MatrixXdConstRef
Return the derivatives of the species amounts n with respect to the input variables w.
auto dudw() const -> MatrixXdConstRef
Return the total derivatives of the chemical properties u with respect to input variables w.
auto dqdw() const -> MatrixXdConstRef
Return the derivatives of the q control variables with respect to the input variables w.
auto dudc() const -> MatrixXdConstRef
Return the total derivatives of the chemical properties u with respect to component amounts c.
auto dndc() const -> MatrixXdConstRef
Return the derivatives of the species amounts n with respect to component amounts c.
EquilibriumSensitivity(EquilibriumSpecs const &specs)
Construct an EquilibriumSensitivity object with given equilibrium problem specifications.
The class used to define conditions to be satisfied at chemical equilibrium.
Definition: EquilibriumSpecs.hpp:281
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
Eigen::MatrixXd MatrixXd
Convenient alias to Eigen type.
Definition: Matrix.hpp:137
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
std::vector< std::string > Strings
Convenient alias for std::vector<String>.
Definition: Types.hpp:55
Eigen::Ref< const VectorXd > VectorXdConstRef
Convenient alias to Eigen type.
Definition: Matrix.hpp:76
Eigen::Ref< const MatrixXd > MatrixXdConstRef
Convenient alias to Eigen type.
Definition: Matrix.hpp:139