Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
ActivityProps.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 // C++ includes
21 #include <any>
22 
23 // Reaktoro includes
24 #include <Reaktoro/Common/Types.hpp>
25 #include <Reaktoro/Common/Matrix.hpp>
26 #include <Reaktoro/Common/TypeOp.hpp>
27 #include <Reaktoro/Core/Model.hpp>
28 #include <Reaktoro/Core/StateOfMatter.hpp>
29 
30 namespace Reaktoro {
31 
57 template<template<typename> typename TypeOp>
59 {
61  TypeOp<real> Vx;
62 
64  TypeOp<real> VxT;
65 
67  TypeOp<real> VxP;
68 
70  TypeOp<ArrayXr> Vxi;
71 
73  TypeOp<real> Gx;
74 
76  TypeOp<real> Hx;
77 
79  TypeOp<real> Cpx;
80 
82  TypeOp<ArrayXr> ln_g;
83 
85  TypeOp<ArrayXr> ln_a;
86 
88  TypeOp<StateOfMatter> som;
89 
91  TypeOp<Map<String, Any>> extra;
92 
95  {
96  Vx = value;
97  VxT = value;
98  VxP = value;
99  Gx = value;
100  Hx = value;
101  Cpx = value;
102  ln_g = value;
103  ln_a = value;
104  return *this;
105  }
106 
108  template<template<typename> typename OtherTypeOp>
110  {
111  Vx = other.Vx;
112  VxT = other.VxT;
113  VxP = other.VxP;
114  Vxi = other.Vxi;
115  Gx = other.Gx;
116  Hx = other.Hx;
117  Cpx = other.Cpx;
118  ln_g = other.ln_g;
119  ln_a = other.ln_a;
120  som = other.som;
121  extra = other.extra;
122  return *this;
123  }
124 
126  template<template<typename> typename OtherTypeOp>
128  {
129  return { Vx, VxT, VxP, Vxi, Gx, Hx, Cpx, ln_g, ln_a, som, extra };
130  }
131 
133  template<template<typename> typename OtherTypeOp>
135  {
136  return { Vx, VxT, VxP, Vxi, Gx, Hx, Cpx, ln_g, ln_a, som, extra };
137  }
138 
142  static auto create(Index numspecies) -> ActivityPropsBase<TypeOp>
143  {
144  ActivityPropsBase<TypeOp> props = {};
145  props.Vx = 0.0;
146  props.VxT = 0.0;
147  props.VxP = 0.0;
148  props.Gx = 0.0;
149  props.Hx = 0.0;
150  props.Cpx = 0.0;
151  props.Vxi = ArrayXr::Zero(numspecies);
152  props.ln_g = ArrayXr::Zero(numspecies);
153  props.ln_a = ArrayXr::Zero(numspecies);
154  return props;
155  }
156 };
157 
160 
163 
166 
167 } // namespace Reaktoro
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
The base type for the primary activity and corrective thermodynamic properties of a phase.
Definition: ActivityProps.hpp:59
auto operator=(real value) -> ActivityPropsBase &
Assign a common value to all properties in this ActivityPropsBase object.
Definition: ActivityProps.hpp:94
TypeOp< ArrayXr > ln_a
The activities (natural log) of the species in the phase.
Definition: ActivityProps.hpp:85
TypeOp< real > Gx
The corrective molar Gibbs energy of the phase (in units of J/mol).
Definition: ActivityProps.hpp:73
TypeOp< real > VxT
The derivative of the corrective molar volume with respect to temperature at constant pressure and sp...
Definition: ActivityProps.hpp:64
TypeOp< ArrayXr > Vxi
The derivatives of the corrective molar volume with respect to species mole fractions at constant tem...
Definition: ActivityProps.hpp:70
TypeOp< real > Hx
The corrective molar enthalpy of the phase (in units of J/mol).
Definition: ActivityProps.hpp:76
TypeOp< real > Cpx
The corrective molar isobaric heat capacity of the phase (in units of J/(mol⋅K)).
Definition: ActivityProps.hpp:79
TypeOp< ArrayXr > ln_g
The activity coefficients (natural log) of the species in the phase.
Definition: ActivityProps.hpp:82
auto operator=(const ActivityPropsBase< OtherTypeOp > &other) -> ActivityPropsBase &
Convert this ActivityPropsBase object into another.
Definition: ActivityProps.hpp:109
static auto create(Index numspecies) -> ActivityPropsBase< TypeOp >
Create a ActivityPropsBase object with given number of species.
Definition: ActivityProps.hpp:142
TypeOp< Map< String, Any > > extra
The extra data produced by an activity model that may be reused by subsequent models within a chained...
Definition: ActivityProps.hpp:91
TypeOp< StateOfMatter > som
The state of matter of the phase.
Definition: ActivityProps.hpp:88
TypeOp< real > Vx
The corrective molar volume of the phase (in m³/mol).
Definition: ActivityProps.hpp:61
TypeOp< real > VxP
The derivative of the corrective molar volume with respect to pressure at constant temperature and sp...
Definition: ActivityProps.hpp:67