OGS
ProcessLib::TES::TESFEMReactionAdaptorAdsorption Class Referencefinal

Detailed Description

Definition at line 51 of file TESReactionAdaptor.h.

#include <TESReactionAdaptor.h>

Inheritance diagram for ProcessLib::TES::TESFEMReactionAdaptorAdsorption:
[legend]
Collaboration diagram for ProcessLib::TES::TESFEMReactionAdaptorAdsorption:
[legend]

Public Member Functions

 TESFEMReactionAdaptorAdsorption (TESLocalAssemblerData const &data)
 
bool checkBounds (std::vector< double > const &local_x, std::vector< double > const &local_x_prev_ts) override
 
ReactionRate initReaction (const unsigned int_pt) override
 
void preZerothTryAssemble () override
 
double getReactionDampingFactor () const override
 
- Public Member Functions inherited from ProcessLib::TES::TESFEMReactionAdaptor
virtual ~TESFEMReactionAdaptor ()=default
 

Private Member Functions

ReactionRate initReaction_slowDownUndershootStrategy (const unsigned int_pt)
 
double estimateAdsorptionEquilibrium (const double p_V0, const double C0) const
 

Private Attributes

double _reaction_damping_factor = 1.0
 
std::vector< bool > _bounds_violation
 
TESLocalAssemblerData const & _d
 

Additional Inherited Members

- Static Public Member Functions inherited from ProcessLib::TES::TESFEMReactionAdaptor
static std::unique_ptr< TESFEMReactionAdaptornewInstance (TESLocalAssemblerData const &data)
 

Constructor & Destructor Documentation

◆ TESFEMReactionAdaptorAdsorption()

ProcessLib::TES::TESFEMReactionAdaptorAdsorption::TESFEMReactionAdaptorAdsorption ( TESLocalAssemblerData const & data)
explicit

Definition at line 51 of file TESReactionAdaptor.cpp.

55 : _bounds_violation(data.solid_density.size(), false), _d(data)
56{
57 assert(dynamic_cast<Adsorption::AdsorptionReaction const*>(
58 data.ap.react_sys.get()) != nullptr &&
59 "Reactive system has wrong type.");
60 assert(!_bounds_violation.empty());
61}

References _bounds_violation, ProcessLib::TES::TESLocalAssemblerData::ap, and ProcessLib::TES::AssemblyParams::react_sys.

Member Function Documentation

◆ checkBounds()

bool ProcessLib::TES::TESFEMReactionAdaptorAdsorption::checkBounds ( std::vector< double > const & local_x,
std::vector< double > const & local_x_prev_ts )
overridevirtual

Reimplemented from ProcessLib::TES::TESFEMReactionAdaptor.

Definition at line 194 of file TESReactionAdaptor.cpp.

197{
198 double alpha = 1.0;
199
200 const double min_xmV = 1e-6;
201 const std::size_t nnodes = local_x.size() / NODAL_DOF;
202 const std::size_t xmV_offset = COMPONENT_ID_MASS_FRACTION * nnodes;
203
204 for (std::size_t i = 0; i < nnodes; ++i)
205 {
206 auto const xnew = local_x[xmV_offset + i];
207 auto const xold = local_x_prev_ts[xmV_offset + i];
208
209 if (xnew < min_xmV)
210 {
211 const auto a = xold / (xold - xnew);
212 alpha = std::min(alpha, a);
213 _bounds_violation[i] = true;
214 }
215 else if (xnew > 1.0)
216 {
217 const auto a = xold / (xnew - xold);
218 alpha = std::min(alpha, a);
219 _bounds_violation[i] = true;
220 }
221 else
222 {
223 _bounds_violation[i] = false;
224 }
225 }
226
227 assert(alpha > 0.0);
228
229 if (alpha != 1.0)
230 {
231 if (alpha > 0.5)
232 {
233 alpha = 0.5;
234 }
235 if (alpha < 0.05)
236 {
237 alpha = 0.05;
238 }
239
241 {
242 _reaction_damping_factor *= sqrt(alpha);
243 }
244 else
245 {
247 }
248 }
249
250 return alpha == 1.0;
251}
const unsigned NODAL_DOF
const unsigned COMPONENT_ID_MASS_FRACTION

References _bounds_violation, _d, _reaction_damping_factor, ProcessLib::TES::TESLocalAssemblerData::ap, ProcessLib::TES::COMPONENT_ID_MASS_FRACTION, ProcessLib::TES::NODAL_DOF, and ProcessLib::TES::AssemblyParams::number_of_try_of_iteration.

◆ estimateAdsorptionEquilibrium()

double ProcessLib::TES::TESFEMReactionAdaptorAdsorption::estimateAdsorptionEquilibrium ( const double p_V0,
const double C0 ) const
private

returns estimated equilibrium vapour pressure based on a local (i.e. no diffusion/advection) balance of adsorbate loading and vapour partial pressure

Definition at line 162 of file TESReactionAdaptor.cpp.

164{
165 auto f = [this, p_V0, C0](double pV) -> double
166 {
167 // pV0 := _p_V
168 const double C_eq =
169 _d.ap.react_sys->getEquilibriumLoading(pV, _d.T, _d.ap.M_react);
170 return (pV - p_V0) * _d.ap.M_react /
172 _d.ap.poro +
173 (1.0 - _d.ap.poro) * (C_eq - C0) * _d.ap.rho_SR_dry;
174 };
175
176 // range where to search for roots of f
177 const double C_eq0 =
178 _d.ap.react_sys->getEquilibriumLoading(p_V0, _d.T, _d.ap.M_react);
179 const double limit =
180 (C_eq0 > C0)
181 ? 1e-8
182 : Adsorption::AdsorptionReaction::getEquilibriumVapourPressure(
183 _d.T);
184
185 // search for roots
186 auto rf = MathLib::Nonlinear::makeRegulaFalsi<MathLib::Nonlinear::Pegasus>(
187 f, p_V0, limit);
188 rf.step(3);
189
190 // set vapour pressure
191 return rf.getResult();
192}
std::unique_ptr< Adsorption::Reaction > react_sys

References _d, ProcessLib::TES::TESLocalAssemblerData::ap, Adsorption::AdsorptionReaction::getEquilibriumVapourPressure(), MaterialLib::PhysicalConstant::IdealGasConstant, ProcessLib::TES::AssemblyParams::M_react, ProcessLib::TES::AssemblyParams::poro, ProcessLib::TES::AssemblyParams::react_sys, ProcessLib::TES::AssemblyParams::rho_SR_dry, and ProcessLib::TES::TESLocalAssemblerData::T.

Referenced by initReaction_slowDownUndershootStrategy().

◆ getReactionDampingFactor()

double ProcessLib::TES::TESFEMReactionAdaptorAdsorption::getReactionDampingFactor ( ) const
inlineoverridevirtual

Reimplemented from ProcessLib::TES::TESFEMReactionAdaptor.

Definition at line 67 of file TESReactionAdaptor.h.

68 {
70 }

References _reaction_damping_factor.

◆ initReaction()

ReactionRate ProcessLib::TES::TESFEMReactionAdaptorAdsorption::initReaction ( const unsigned int_pt)
inlineoverridevirtual

Implements ProcessLib::TES::TESFEMReactionAdaptor.

Definition at line 59 of file TESReactionAdaptor.h.

60 {
62 }
ReactionRate initReaction_slowDownUndershootStrategy(const unsigned int_pt)

References initReaction_slowDownUndershootStrategy().

◆ initReaction_slowDownUndershootStrategy()

ReactionRate ProcessLib::TES::TESFEMReactionAdaptorAdsorption::initReaction_slowDownUndershootStrategy ( const unsigned int_pt)
private

Definition at line 64 of file TESReactionAdaptor.cpp.

66{
67 assert(_d.ap.number_of_try_of_iteration <= 20);
68
69 const double loading = Adsorption::AdsorptionReaction::getLoading(
71
72 double react_rate_R =
73 _d.ap.react_sys->getReactionRate(_d.p_V, _d.T, _d.ap.M_react, loading) *
75
76 // set reaction rate based on current damping factor
77 react_rate_R = (_reaction_damping_factor > 1e-3)
78 ? _reaction_damping_factor * react_rate_R
79 : 0.0;
80
81 if (_d.p_V <
83 _d.T) &&
84 react_rate_R > 0.0)
85 {
86 react_rate_R = 0.0;
87 }
88 else if (_d.p_V < 100.0 ||
90 getEquilibriumVapourPressure(_d.T))
91 {
92 // use equilibrium reaction for dry regime
93
94 // in the case of zeroth try in zeroth iteration: _p_V and loading are
95 // the values
96 // at the end of the previous timestep
97
98 const double pV_eq = estimateAdsorptionEquilibrium(_d.p_V, loading);
99 // TODO [CL]: it would be more correct to subtract pV from the previous
100 // timestep here
101 const double delta_pV = pV_eq - _d.p_V;
102 const double delta_rhoV =
103 delta_pV * _d.ap.M_react /
105 const double delta_rhoSR = delta_rhoV / (_d.ap.poro - 1.0);
106 double react_rate_R2 = delta_rhoSR / _d.ap.delta_t;
107
108 if (_bounds_violation[int_pt])
109 {
110 react_rate_R2 *= 0.5;
111 }
112
113 // 0th try: make sure reaction is not slower than allowed by local
114 // estimation
115 // nth try: make sure reaction is not made faster by local estimation
116 if ((_d.ap.number_of_try_of_iteration == 1 &&
117 std::abs(react_rate_R2) > std::abs(react_rate_R)) ||
119 std::abs(react_rate_R2) < std::abs(react_rate_R)))
120 {
121 react_rate_R = react_rate_R2;
122 }
123 }
124
125 // smooth out readjustment of reaction rate
127 {
129 {
130 // update reaction rate for for five iterations
131 const auto N = _d.ap.iteration_in_current_timestep - 4;
132
133 // take average s.t. does not oscillate so much
134 react_rate_R = 1.0 / (1.0 + N) *
135 (N * _d.reaction_rate[int_pt] + 1.0 * react_rate_R);
136 }
137 else
138 {
139 // afterwards no update anymore
140 react_rate_R = _d.reaction_rate[int_pt];
141 }
142 }
143
145 {
146 // assert that within tries reaction does not get faster
147 // (e.g. due to switch equilibrium reaction <--> kinetic reaction)
148
149 // factor of 0.9*N: in fact, even slow down reaction over tries
150 const double r = std::pow(0.9, _d.ap.number_of_try_of_iteration - 1) *
151 _d.reaction_rate[int_pt];
152 if (std::abs(react_rate_R) > std::abs(r))
153 {
154 react_rate_R = r;
155 }
156 }
157
158 return {react_rate_R,
159 _d.solid_density_prev_ts[int_pt] + react_rate_R * _d.ap.delta_t};
160}
static double getEquilibriumVapourPressure(const double T_Ads)
static double getLoading(const double rho_curr, const double rho_dry)
double estimateAdsorptionEquilibrium(const double p_V0, const double C0) const

References _bounds_violation, _d, _reaction_damping_factor, ProcessLib::TES::TESLocalAssemblerData::ap, ProcessLib::TES::AssemblyParams::delta_t, estimateAdsorptionEquilibrium(), Adsorption::AdsorptionReaction::getEquilibriumVapourPressure(), Adsorption::AdsorptionReaction::getLoading(), MaterialLib::PhysicalConstant::IdealGasConstant, ProcessLib::TES::AssemblyParams::iteration_in_current_timestep, ProcessLib::TES::AssemblyParams::M_react, ProcessLib::TES::AssemblyParams::number_of_try_of_iteration, ProcessLib::TES::TESLocalAssemblerData::p_V, ProcessLib::TES::AssemblyParams::poro, ProcessLib::TES::AssemblyParams::react_sys, ProcessLib::TES::TESLocalAssemblerData::reaction_rate, ProcessLib::TES::AssemblyParams::rho_SR_dry, ProcessLib::TES::TESLocalAssemblerData::solid_density_prev_ts, and ProcessLib::TES::TESLocalAssemblerData::T.

Referenced by initReaction().

◆ preZerothTryAssemble()

void ProcessLib::TES::TESFEMReactionAdaptorAdsorption::preZerothTryAssemble ( )
overridevirtual

Reimplemented from ProcessLib::TES::TESFEMReactionAdaptor.

Definition at line 253 of file TESReactionAdaptor.cpp.

254{
255 if (_reaction_damping_factor < 1e-3)
256 {
258 }
259
262}

References _reaction_damping_factor.

Member Data Documentation

◆ _bounds_violation

std::vector<bool> ProcessLib::TES::TESFEMReactionAdaptorAdsorption::_bounds_violation
private

◆ _d

TESLocalAssemblerData const& ProcessLib::TES::TESFEMReactionAdaptorAdsorption::_d
private

◆ _reaction_damping_factor

double ProcessLib::TES::TESFEMReactionAdaptorAdsorption::_reaction_damping_factor = 1.0
private

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