ChemicalScalar.hpp
38 using ChemicalScalarRef = ChemicalScalarBase<double&, Eigen::Ref<RowVector, 0, Eigen::InnerStride<Eigen::Dynamic>>>; // Relax inner stride (dynamic, instead of default) so that a matrix row can be represented using Ref
41 using ChemicalScalarConstRef = ChemicalScalarBase<const double&, Eigen::Ref<const RowVector, 0, Eigen::InnerStride<Eigen::Dynamic>>>;
233 inline auto amount(double value, Index nspecies, Index ispecies) -> ChemicalScalarBase<double, decltype(tr(unit(nspecies, ispecies)))>
245 auto operator-(const ChemicalScalarBase<V,N>& l) -> ChemicalScalarBase<double, decltype(-l.ddn)>
251 auto operator+(const ChemicalScalarBase<VL,NL>& l, const ChemicalScalarBase<VR,NR>& r) -> ChemicalScalarBase<double, decltype(l.ddn + r.ddn)>
257 auto operator+(const ChemicalScalarBase<VL,NL>& l, const ThermoScalarBase<VR>& r) -> ChemicalScalarBase<double, decltype(l.ddn)>
263 auto operator+(const ThermoScalarBase<VL>& l, const ChemicalScalarBase<VR,NR>& r) -> decltype(r + l)
269 auto operator+(const ChemicalScalarBase<V,N>& l, double r) -> ChemicalScalarBase<double, decltype(l.ddn)>
281 auto operator-(const ChemicalScalarBase<VL,NL>& l, const ChemicalScalarBase<VR,NR>& r) -> ChemicalScalarBase<double, decltype(l.ddn - r.ddn)>
287 auto operator-(const ChemicalScalarBase<VL,NL>& l, const ThermoScalarBase<VR>& r) -> ChemicalScalarBase<double, decltype(l.ddn)>
293 auto operator-(const ThermoScalarBase<VL>& l, const ChemicalScalarBase<VR,NR>& r) -> ChemicalScalarBase<double, decltype(-r.ddn)>
299 auto operator-(const ChemicalScalarBase<V,N>& l, double r) -> ChemicalScalarBase<double, decltype(l.ddn)>
305 auto operator-(double l, const ChemicalScalarBase<V,N>& r) -> ChemicalScalarBase<double, decltype(-r.ddn)>
311 auto operator*(double l, const ChemicalScalarBase<V,N>& r) -> ChemicalScalarBase<double, decltype(l * r.ddn)>
323 auto operator*(const ThermoScalarBase<VL>& l, const ChemicalScalarBase<VR,NR>& r) -> ChemicalScalarBase<double, decltype(l.val * r.ddn)>
325 return {l.val * r.val, l.val * r.ddT + l.ddT * r.val, l.val * r.ddP + l.ddP * r.val, l.val * r.ddn};
329 auto operator*(const ChemicalScalarBase<VL,NL>& l, const ThermoScalarBase<VR>& r) -> decltype(r * l)
335 auto operator*(const ChemicalScalarBase<VL,NL>& l, const ChemicalScalarBase<VR,NR>& r) -> ChemicalScalarBase<double, decltype(l.val * r.ddn + l.ddn * r.val)>
337 return {l.val * r.val, l.val * r.ddT + l.ddT * r.val, l.val * r.ddP + l.ddP * r.val, l.val * r.ddn + l.ddn * r.val};
341 auto operator/(double l, const ChemicalScalarBase<V,N>& r) -> ChemicalScalarBase<double, decltype(double() * r.ddn)>
355 auto operator/(const ThermoScalarBase<VL>& l, const ChemicalScalarBase<VR,NR>& r) -> ChemicalScalarBase<double, decltype(-(l.val * r.ddn) * double())>
358 return {l.val/r.val, (l.ddT * r.val - l.val * r.ddT) * tmp, (l.ddP * r.val - l.val * r.ddP) * tmp, -(l.val * r.ddn) * tmp};
362 auto operator/(const ChemicalScalarBase<VL,NL>& l, const ThermoScalarBase<VR>& r) -> ChemicalScalarBase<double, decltype(l.ddn/r.val)>
365 return {l.val/r.val, (l.ddT * r.val - l.val * r.ddT) * tmp, (l.ddP * r.val - l.val * r.ddP) * tmp, l.ddn/r.val};
369 auto operator/(const ChemicalScalarBase<VL,NL>& l, const ChemicalScalarBase<VR,NR>& r) -> ChemicalScalarBase<double, decltype((l.ddn * r.val - l.val * r.ddn) * double())>
372 return {l.val/r.val, (l.ddT * r.val - l.val * r.ddT) * tmp, (l.ddP * r.val - l.val * r.ddP) * tmp, (l.ddn * r.val - l.val * r.ddn) * tmp};
490 auto abs(const ChemicalScalarBase<V,N>& l) -> ChemicalScalarBase<double, decltype(double() * l.ddn)>
498 auto sqrt(const ChemicalScalarBase<V,N>& l) -> ChemicalScalarBase<double, decltype(double() * l.ddn)>
506 auto pow(const ChemicalScalarBase<V,N>& l, double power) -> ChemicalScalarBase<double, decltype(double() * l.ddn)>
514 auto exp(const ChemicalScalarBase<V,N>& l) -> ChemicalScalarBase<double, decltype(double() * l.ddn)>
ChemicalScalarBase(ChemicalScalarBase< VR, NR > &other)
Construct a ChemicalScalarBase instance from another.
Definition: ChemicalScalar.hpp:88
auto operator-=(const ChemicalScalarBase< VR, NR > &other) -> ChemicalScalarBase &
Assign-subtraction of a ChemicalScalarBase instance to this.
Definition: ChemicalScalar.hpp:168
auto operator+=(const ChemicalScalarBase< VR, NR > &other) -> ChemicalScalarBase &
Assign-addition of a ChemicalScalarBase instance to this.
Definition: ChemicalScalar.hpp:140
ChemicalScalarBase()
Construct a default ChemicalScalarBase instance.
Definition: ChemicalScalar.hpp:64
A template base class to represent a chemical scalar and its partial derivatives.
Definition: ChemicalScalar.hpp:49
V val
The value of the chemical scalar.
Definition: ChemicalScalar.hpp:52
auto amount(double value, Index nspecies, Index ispecies) -> ChemicalScalarBase< double, decltype(tr(unit(nspecies, ispecies)))>
Return a ChemicalScalar representation of a mole amount of a species.
Definition: ChemicalScalar.hpp:233
auto operator+=(double other) -> ChemicalScalarBase &
Assign-addition of a scalar to this.
Definition: ChemicalScalar.hpp:160
Eigen::RowVectorXd RowVector
< Alias to Eigen type Map<const VectorXd>.
Definition: Matrix.hpp:35
ChemicalScalarBase(Index nspecies, double val)
Construct a ChemicalScalarBase instance with given number of species and a constant value.
Definition: ChemicalScalar.hpp:75
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
ChemicalScalarBase(const ChemicalScalarBase< VR, NR > &other)
Construct a ChemicalScalarBase instance from another.
Definition: ChemicalScalar.hpp:93
N ddn
The partial mole derivatives of the chemical scalar.
Definition: ChemicalScalar.hpp:61
auto operator+=(const ThermoScalarBase< VR > &other) -> ChemicalScalarBase &
Assign-addition of a ThermoScalarBase instance to this.
Definition: ChemicalScalar.hpp:151
ChemicalScalarBase(const V &val, const V &ddT, const V &ddP, const N &ddn)
Construct a ChemicalScalarBase instance with given values and derivatives.
Definition: ChemicalScalar.hpp:83
auto operator*=(double other) -> ChemicalScalarBase &
Assign-multiplication of a scalar to this.
Definition: ChemicalScalar.hpp:206
auto operator/=(double other) -> ChemicalScalarBase &
Assign-division of a scalar to this.
Definition: ChemicalScalar.hpp:216
V ddT
The partial temperature derivative of the chemical scalar.
Definition: ChemicalScalar.hpp:55
auto operator=(const ChemicalScalarBase< VR, NR > &other) -> ChemicalScalarBase &
Assign another ChemicalScalarBase instance to this.
Definition: ChemicalScalar.hpp:108
auto operator=(const ThermoScalarBase< VR > &other) -> ChemicalScalarBase &
Assign a ThermoScalarBase instance to this.
Definition: ChemicalScalar.hpp:119
ChemicalScalarBase< double, RowVector > ChemicalScalar
A type that represents a chemical property and its derivatives.
Definition: ChemicalScalar.hpp:35
auto operator*=(const ChemicalScalarBase< VR, NR > &other) -> ChemicalScalarBase &
Assign-multiplication of a ChemicalScalarBase instance to this.
Definition: ChemicalScalar.hpp:196
A template base class to represent a thermodynamic scalar and its partial derivatives.
Definition: ThermoScalar.hpp:45
auto tr(Eigen::MatrixBase< Derived > &mat) -> decltype(mat.transpose())
Return the transpose of the matrix.
Definition: Matrix.hxx:167
auto operator=(ChemicalScalarBase< V, N > &other) -> ChemicalScalarBase &
Assign another ChemicalScalarBase instance to this.
Definition: ChemicalScalar.hpp:97
ChemicalScalarBase(Index nspecies)
Construct a ChemicalScalarBase instance with given number of species.
Definition: ChemicalScalar.hpp:69
auto operator-=(double other) -> ChemicalScalarBase &
Assign-subtraction of a scalar to this.
Definition: ChemicalScalar.hpp:188
V ddP
The partial pressure derivative of the chemical scalar.
Definition: ChemicalScalar.hpp:58
auto unit(Index rows, Index i) -> decltype(Vector::Unit(rows, i))
Return an expression of a unit vector.
Definition: Matrix.hxx:47
auto operator=(double other) -> ChemicalScalarBase &
Assign a scalar to this.
Definition: ChemicalScalar.hpp:129
auto operator-=(const ThermoScalarBase< VR > &other) -> ChemicalScalarBase &
Assign-subtraction of a ThermoScalarBase instance to this.
Definition: ChemicalScalar.hpp:179