Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
tracer_reaction_model.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2025-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_tracer_reaction_prefactor_model_h
5#define lethe_tracer_reaction_prefactor_model_h
6
8
9#include <algorithm>
10#include <cmath>
11
12/**
13 * @brief Computes the effective concentration above the threshold and with a
14 * smooth transition
15 *
16 * This function prevents NaN in the reaction rate computations when the
17 * reaction order is lower than 1 by introducing a small threshold value, to be
18 * set above 0.
19 *
20 * @param[in] C Concentration value
21 * @param[in] threshold Threshold value above which effective concentration will
22 * be
23 */
24inline double
25calculate_effective_concentration(const double C, const double threshold)
26{
27 return std::sqrt(C * C + threshold * threshold);
28}
29
30/**
31 * @brief Computes the derivative of effective concentration in regards to the
32 * input concentration
33 *
34 * @param[in] C Concentration value
35 * @param[in] threshold Threshold value above which effective concentration will
36 * be
37 */
38inline double
39calculate_d_effective_concentration_dC(const double C, const double threshold)
40{
41 const double Ce = calculate_effective_concentration(C, threshold);
42 return (Ce > 0.0) ? (C / Ce) : 0.0;
43}
44
45/**
46 * @brief Abstract class to calculate the tracer reaction prefactor.
47 *
48 * This model computes the prefactor
49 * \f$ k = \alpha \, C^{(n-1)} \f$
50 * such that the full reaction term is assembled as
51 * \f$ r = -k \, C \f$.
52 *
53 * Here, \f$ \alpha \f$ represents the reaction constant.
54 * This parent class could have children classes that are not based on the power
55 * law.
56 */
58{
59public:
60 /**
61 * @brief Instantiates and returns a pointer to a TracerReactionPrefactorModel object by casting it to
62 * the proper child class.
63 *
64 * @param material_properties Parameters for a material.
65 */
66 static std::shared_ptr<TracerReactionPrefactorModel>
67 model_cast(const Parameters::Material &material_properties);
68};
69
70/**
71 * @brief Dummy tracer reaction prefactor model.
72 *
73 * This class is a dummy implementation and always returns zero.
74 */
76{
77public:
78 /**
79 * @brief Default constructor.
80 */
82
83 /**
84 * @brief Returns a dummy value.
85 */
86 double
87 value(const std::map<field, double> & /*fields_value*/) override
88 {
89 return 0.;
90 }
91
92 /**
93 * @brief Dummy vector value computation.
94 */
95 void
96 vector_value(const std::map<field, std::vector<double>> & /*field_vectors*/,
97 std::vector<double> & /*property_vector*/) override
98 {}
99
100 /**
101 * @brief Returns a dummy jacobian value.
102 */
103 double
104 jacobian(const std::map<field, double> & /*field_values*/,
105 field /*id*/) override
106 {
107 return 0;
108 }
109
110 /**
111 * @brief Dummy vector jacobian computation.
112 */
113 void
115 const std::map<field, std::vector<double>> & /*field_vectors*/,
116 const field /*id*/,
117 std::vector<double> & /*jacobian_vector*/) override
118 {}
119};
120
121/**
122 * @brief Constant tracer reaction prefactor.
123 *
124 * This model computes the prefactor as
125 * \f[ k = \alpha C_\text{eff}^{n-1}, \f]
126 * with a smooth floor \f[C_\text{eff} = \sqrt{C^2 + \epsilon^2} \f]
127 * where \f$ \alpha \f$ (the reaction constant) and the reaction order \f$ n \f$
128 * are provided.
129 */
131{
132public:
133 /**
134 * @brief Constructor.
135 *
136 * @param[in] p_tracer_reaction_constant The base reaction constant \f$ \alpha
137 * \f$.
138 * @param[in] p_tracer_reaction_order The reaction order \f$ n \f$.
139 * @param[in] p_tracer_reaction_threshold The threshold value used to smoothly
140 * floor the concentration.
141 */
142 ConstantTracerReactionPrefactor(const double p_tracer_reaction_constant,
143 const double p_tracer_reaction_order,
144 const double p_tracer_reaction_threshold)
145 : tracer_reaction_constant(p_tracer_reaction_constant)
146 , tracer_reaction_order(p_tracer_reaction_order)
147 , tracer_reaction_threshold(p_tracer_reaction_threshold)
148 {
150 }
151
152 /**
153 * @brief Compute the tracer reaction prefactor.
154 *
155 * @param[in] fields_value Map of field values.
156 * @return The computed prefactor value.
157 */
158 double
159 value(const std::map<field, double> &fields_value) override
160 {
161 Assert(fields_value.find(field::tracer_concentration) != fields_value.end(),
162 PhysicialPropertyModelFieldUndefined(
163 "ConstantTracerReactionPrefactor", "tracer_concentration"));
164
165 const double Ceff = calculate_effective_concentration(
168 std::pow(Ceff, tracer_reaction_order - 1.);
169 }
170
171 /**
172 * @brief Compute the vector of tracer reaction prefactor values.
173 *
174 * @param[in] field_vectors Map of field vectors.
175 * @param property_vector Vector to be filled with computed prefactor values.
176 */
177 void
178 vector_value(const std::map<field, std::vector<double>> &field_vectors,
179 std::vector<double> &property_vector) override
180 {
181 Assert(
182 field_vectors.find(field::tracer_concentration) != field_vectors.end(),
183 PhysicialPropertyModelFieldUndefined("ConstantTracerReactionPrefactor",
184 "tracer_concentration"));
185 const auto &concentration_vector =
186 field_vectors.at(field::tracer_concentration);
187 for (size_t i = 0; i < property_vector.size(); ++i)
188 {
189 const double Ceff =
190 calculate_effective_concentration(concentration_vector[i],
192 property_vector[i] =
193 tracer_reaction_constant * std::pow(Ceff, tracer_reaction_order - 1.);
194 }
195 }
196
197 /**
198 * @brief Compute the jacobian (partial derivative) of the prefactor with respect to a field.
199 *
200 * @param[in] field_values Map of field values.
201 * @param[in] id The field identifier with respect to which the derivative is
202 * computed.
203 * @return The computed derivative value.
204 */
205 double
206 jacobian(const std::map<field, double> &field_values, field id) override
207 {
208 Assert(field_values.find(field::tracer_concentration) != field_values.end(),
209 PhysicialPropertyModelFieldUndefined(
210 "ConstantTracerReactionPrefactor", "tracer_concentration"));
212 {
213 const double C = field_values.at(field::tracer_concentration);
214 const double Ceff =
216 const double dCe =
218
220 std::pow(Ceff, tracer_reaction_order - 2.) * dCe;
221 }
222 return 0.0;
223 }
224
225 /**
226 * @brief Compute the vector jacobian (partial derivatives) of the prefactor with respect to a field.
227 *
228 * @param[in] field_vectors Map of field vectors.
229 * @param[in] id The field identifier with respect to which the derivative is
230 * computed.
231 * @param[out] jacobian_vector Vector to be filled with computed derivative
232 * values.
233 */
234 void
235 vector_jacobian(const std::map<field, std::vector<double>> &field_vectors,
236 const field id,
237 std::vector<double> &jacobian_vector) override
238 {
239 Assert(
240 field_vectors.find(field::tracer_concentration) != field_vectors.end(),
241 PhysicialPropertyModelFieldUndefined("ConstantTracerReactionPrefactor",
242 "tracer_concentration"));
244 {
245 std::ranges::fill(jacobian_vector, 0.0);
246 return;
247 }
248 const auto &concentration_vector =
249 field_vectors.at(field::tracer_concentration);
250 for (size_t i = 0; i < jacobian_vector.size(); ++i)
251 {
252 const double Ceff =
253 calculate_effective_concentration(concentration_vector[i],
255 const double dCe =
256 calculate_d_effective_concentration_dC(concentration_vector[i],
258 jacobian_vector[i] = tracer_reaction_constant *
259 (tracer_reaction_order - 1.) *
260 std::pow(Ceff, tracer_reaction_order - 2.) * dCe;
261 }
262 };
263
264private:
268};
269
270/**
271 * @brief Tanh level-set-dependent tracer reaction prefactor.
272 *
273 * This model computes a prefactor that depends on the level-set function,
274 * smoothly transitioning between a reaction constant \‍(\alpha\‍) inside and
275 * outside the solid.
276 */
278{
279public:
280 /**
281 * @brief Constructor.
282 *
283 * @param[in] p_tracer_reaction_constant_outside Reaction constant \‍(\alpha\‍)
284 * outside the solid.
285 * @param[in] p_tracer_reaction_constant_inside Reaction constant \‍(\alpha\‍)
286 * inside the solid.
287 * @param[in] p_thickness Thickness for the tanh smoothing function.
288 * @param[in] p_tracer_reaction_order The reaction order.
289 * @param[in] p_tracer_reaction_threshold The threshold value used to smoothly
290 * floor the concentration.
291 */
293 const double p_tracer_reaction_constant_outside,
294 const double p_tracer_reaction_constant_inside,
295 const double p_thickness,
296 const double p_tracer_reaction_order,
297 const double p_tracer_reaction_threshold)
298 : tracer_reaction_constant_outside(p_tracer_reaction_constant_outside)
299 , tracer_reaction_constant_inside(p_tracer_reaction_constant_inside)
300 , thickness(p_thickness)
303 , tracer_reaction_order(p_tracer_reaction_order)
304 , tracer_reaction_threshold(p_tracer_reaction_threshold)
305 {
306 this->model_depends_on[field::levelset] = true;
308 }
309
310 /**
311 * @brief Compute the tracer reaction prefactor.
312 *
313 * @param[in] field_values Map of field values.
314 * @return The computed prefactor value.
315 */
316 double
317 value(const std::map<field, double> &field_values) override
318 {
319 Assert(field_values.find(field::levelset) != field_values.end(),
320 PhysicialPropertyModelFieldUndefined(
321 "TanhLevelsetTracerReactionPrefactor", "levelset"));
322 Assert(field_values.find(field::tracer_concentration) != field_values.end(),
323 PhysicialPropertyModelFieldUndefined(
324 "TanhLevelsetTracerReactionPrefactor", "tracer_concentration"));
325 const double levelset = field_values.at(field::levelset);
326 const double Ceff = calculate_effective_concentration(
328 const double k =
330 delta_reaction_constant * (0.5 + 0.5 * std::tanh(levelset / thickness));
331 return k * std::pow(Ceff, tracer_reaction_order - 1.);
332 }
333
334 /**
335 * @brief Compute a vector of tracer reaction prefactor values.
336 *
337 * @param[in] field_vectors Map of field vectors.
338 * @param[out] property_vector Vector to be filled with computed prefactor
339 * values.
340 */
341 void
342 vector_value(const std::map<field, std::vector<double>> &field_vectors,
343 std::vector<double> &property_vector) override
344 {
345 Assert(field_vectors.find(field::levelset) != field_vectors.end(),
346 PhysicialPropertyModelFieldUndefined(
347 "TanhLevelsetTracerReactionPrefactor", "levelset"));
348 Assert(field_vectors.find(field::tracer_concentration) !=
349 field_vectors.end(),
350 PhysicialPropertyModelFieldUndefined(
351 "TanhLevelsetTracerReactionPrefactor", "tracer_concentration"));
352
353 const std::vector<double> &levelset_vec = field_vectors.at(field::levelset);
354 const std::vector<double> &concentration_vector =
355 field_vectors.at(field::tracer_concentration);
356
357 const unsigned int n_values = levelset_vec.size();
358 Assert(n_values == concentration_vector.size(),
359 SizeOfFields(n_values, concentration_vector.size()));
360 for (unsigned int i = 0; i < n_values; ++i)
361 {
362 const double k = tracer_reaction_constant_inside +
364 (0.5 + 0.5 * std::tanh(levelset_vec[i] / thickness));
365 const double Ceff =
366 calculate_effective_concentration(concentration_vector[i],
368 property_vector[i] = k * std::pow(Ceff, tracer_reaction_order - 1.);
369 }
370 }
371
372 /**
373 * @brief Compute the jacobian (partial derivative) of the prefactor with respect to a specified field.
374 *
375 * @param[in] field_values Map of field values.
376 * @param[in] id The field identifier with respect to which the derivative is
377 * computed.
378 * @return The computed derivative value.
379 */
380 double
381 jacobian(const std::map<field, double> &field_values, field id) override
382 {
383 Assert(field_values.find(field::levelset) != field_values.end(),
384 PhysicialPropertyModelFieldUndefined(
385 "TanhLevelsetTracerReactionPrefactor", "levelset"));
386 Assert(field_values.find(field::tracer_concentration) != field_values.end(),
387 PhysicialPropertyModelFieldUndefined(
388 "TanhLevelsetTracerReactionPrefactor", "tracer_concentration"));
389 const double levelset = field_values.at(field::levelset);
390 const double concentration_val =
391 field_values.at(field::tracer_concentration);
392 const double Ceff =
393 calculate_effective_concentration(concentration_val,
395 if (id == field::levelset)
396 {
397 // dk/dlambda for tanh profile: Δk * 0.5 * (1 - tanh^2(lambda/sigma)) *
398 // (1/sigma)
399 const double tanh = std::tanh(levelset / thickness);
400 const double dkdlambda =
401 delta_reaction_constant * 0.5 * (1.0 - tanh * tanh) / thickness;
402 return dkdlambda * std::pow(Ceff, tracer_reaction_order - 1.);
403 }
404 else if (id == field::tracer_concentration)
405 {
406 const double k = tracer_reaction_constant_inside +
408 (0.5 + 0.5 * std::tanh(levelset / thickness));
409 const double dCe =
412 return k * (tracer_reaction_order - 1.) *
413 std::pow(Ceff, tracer_reaction_order - 2.) * dCe;
414 }
415 else
416 return 0.0;
417 }
418
419 /**
420 * @brief Compute the vector jacobian (partial derivatives) of the prefactor with respect to a field.
421 *
422 * @param[in] field_vectors Map of field vectors.
423 * @param[in] id The field identifier with respect to which the derivative is
424 * computed.
425 * @param[out] jacobian_vector Vector to be filled with computed derivative
426 * values.
427 */
428 void
429 vector_jacobian(const std::map<field, std::vector<double>> &field_vectors,
430 const field id,
431 std::vector<double> &jacobian_vector) override
432 {
433 Assert(field_vectors.find(field::levelset) != field_vectors.end(),
434 PhysicialPropertyModelFieldUndefined(
435 "TanhLevelsetTracerReactionPrefactor", "levelset"));
436 Assert(field_vectors.find(field::tracer_concentration) !=
437 field_vectors.end(),
438 PhysicialPropertyModelFieldUndefined(
439 "TanhLevelsetTracerReactionPrefactor", "tracer_concentration"));
440 const std::vector<double> &levelset_vec = field_vectors.at(field::levelset);
441 const std::vector<double> &concentration_vec =
442 field_vectors.at(field::tracer_concentration);
443 const unsigned int n_values = levelset_vec.size();
444 if (id == field::levelset)
445 {
446 for (unsigned int i = 0; i < n_values; ++i)
447 {
448 const double tanh = std::tanh(levelset_vec[i] / thickness);
449 const double dkdlambda =
450 delta_reaction_constant * 0.5 * (1.0 - tanh * tanh) / thickness;
451 const double Ceff =
452 calculate_effective_concentration(concentration_vec[i],
454 jacobian_vector[i] =
455 dkdlambda * std::pow(Ceff, tracer_reaction_order - 1.);
456 }
457 }
458 else if (id == field::tracer_concentration)
459 {
460 for (unsigned int i = 0; i < n_values; ++i)
461 {
462 const double k =
465 (0.5 + 0.5 * std::tanh(levelset_vec[i] / thickness));
466 const double Ceff =
467 calculate_effective_concentration(concentration_vec[i],
469 const double dCe =
470 calculate_d_effective_concentration_dC(concentration_vec[i],
472 jacobian_vector[i] = k * (tracer_reaction_order - 1.) *
473 std::pow(Ceff, tracer_reaction_order - 2.) *
474 dCe;
475 }
476 }
477 else
478 {
479 std::ranges::fill(jacobian_vector, 0.0);
480 }
481 }
482
483private:
486 const double thickness;
490};
491
492/**
493 * @brief Reaction prefactor that depends on the Gaussian of the level set
494 */
497{
498public:
499 /**
500 * @brief Constructor of the Gaussian level set-dependent reaction prefactor model.
501 *
502 * @param[in] p_tracer_reaction_constant_interface Reaction constant at the
503 * fluid-solid interface the solid
504 * @param[in] p_tracer_reaction_constant_bulk Reaction constant in the bulk of
505 * the phases
506 * @param[in] p_thickness Thickness of the Gaussian function used to smooth
507 * the property jump
508 * @param[in] p_tracer_reaction_order The reaction order.
509 * @param[in] p_tracer_reaction_threshold The threshold value used to smoothly
510 * floor the concentration.
511 */
513 const double p_tracer_reaction_constant_interface,
514 const double p_tracer_reaction_constant_bulk,
515 const double p_thickness,
516 const double p_tracer_reaction_order,
517 const double p_tracer_reaction_threshold)
518 : tracer_reaction_constant_interface(p_tracer_reaction_constant_interface)
519 , tracer_reaction_constant_bulk(p_tracer_reaction_constant_bulk)
522 , squared_thickness(p_thickness * p_thickness)
523 , tracer_reaction_order(p_tracer_reaction_order)
524 , tracer_reaction_threshold(p_tracer_reaction_threshold)
525 {
526 this->model_depends_on[field::levelset] = true;
528 }
529
530 /**
531 * @brief Compute the reaction constant.
532 *
533 * @param[in] field_values Values of the various fields on which the property
534 * may depend. In this case, the reaction constant depends on the level set.
535 * The map stores a single value per field.
536 *
537 * @return Value of the reaction constant computed with the @p field_values.
538 */
539 double
540 value(const std::map<field, double> &field_values) override
541 {
542 Assert(field_values.find(field::levelset) != field_values.end(),
543 PhysicialPropertyModelFieldUndefined(
544 "GaussianLevelsetTracerReactionPrefactor", "levelset"));
545 Assert(field_values.find(field::tracer_concentration) != field_values.end(),
546 PhysicialPropertyModelFieldUndefined(
547 "GaussianLevelsetTracerReactionPrefactor",
548 "tracer_concentration"));
549 const double levelset_val = field_values.at(field::levelset);
550 const double Ceff = calculate_effective_concentration(
552
553 const double k =
556 std::exp(-levelset_val * levelset_val / squared_thickness);
557 return k * std::pow(Ceff, tracer_reaction_order - 1.);
558 }
559
560 /**
561 * @brief Compute a vector of reaction constant.
562 *
563 * @param[in] field_vectors Vectors of the fields on which the reaction
564 * constant may depend. In this case, the reaction constant depends on the
565 * level set. The map stores a vector of values per field.
566 *
567 * @param[out] property_vector Vectors of computed reaction constants.
568 */
569 void
570 vector_value(const std::map<field, std::vector<double>> &field_vectors,
571 std::vector<double> &property_vector) override
572 {
573 Assert(field_vectors.find(field::levelset) != field_vectors.end(),
574 PhysicialPropertyModelFieldUndefined(
575 "GaussianLevelsetTracerReactionPrefactor", "levelset"));
576 Assert(field_vectors.find(field::tracer_concentration) !=
577 field_vectors.end(),
578 PhysicialPropertyModelFieldUndefined(
579 "GaussianLevelsetTracerReactionPrefactor",
580 "tracer_concentration"));
581
582 const std::vector<double> &levelset_vec = field_vectors.at(field::levelset);
583 const std::vector<double> &concentration_vec =
584 field_vectors.at(field::tracer_concentration);
585 const unsigned int n_values = levelset_vec.size();
586 Assert(n_values == concentration_vec.size(),
587 SizeOfFields(n_values, concentration_vec.size()));
588 for (unsigned int i = 0; i < n_values; ++i)
589 {
590 const double k =
593 std::exp(-levelset_vec[i] * levelset_vec[i] / squared_thickness);
594 const double Ceff =
595 calculate_effective_concentration(concentration_vec[i],
597 property_vector[i] = k * std::pow(Ceff, tracer_reaction_order - 1.);
598 }
599 }
600
601 /**
602 * @brief Compute the jacobian (the partial derivative) of the reaction constant
603 * with respect to a specified field.
604 *
605 * @param[in] field_values Values of the various fields on which the specific
606 * heat may depend. The map stores a single value per field.
607 *
608 * @param[in] id Indicator of the field with respect to which the jacobian
609 * should be computed.
610 *
611 * @return Value of the derivative of the reaction constant with respect to the
612 * specified field.
613 */
614 double
615 jacobian(const std::map<field, double> &field_values, field id) override
616 {
617 Assert(field_values.find(field::levelset) != field_values.end(),
618 PhysicialPropertyModelFieldUndefined(
619 "GaussianLevelsetTracerReactionPrefactor", "levelset"));
620 Assert(field_values.find(field::tracer_concentration) != field_values.end(),
621 PhysicialPropertyModelFieldUndefined(
622 "GaussianLevelsetTracerReactionPrefactor",
623 "tracer_concentration"));
624
625 const double levelset_val = field_values.at(field::levelset);
626 const double concentration_val =
627 field_values.at(field::tracer_concentration);
628 const double Ceff =
629 calculate_effective_concentration(concentration_val,
631 if (id == field::levelset)
632 {
633 // dk/dlambda = Δk * exp(-lambda^2/sigma^2) * (-2*lambda/sigma^2)
634 const double exponential =
635 std::exp(-levelset_val * levelset_val / squared_thickness);
636 const double dkdlambda = delta_reaction_constant * exponential *
637 (-2.0 * levelset_val / squared_thickness);
638 return dkdlambda * std::pow(Ceff, tracer_reaction_order - 1.);
639 }
640 else if (id == field::tracer_concentration)
641 {
642 const double k =
645 std::exp(-levelset_val * levelset_val / squared_thickness);
646 const double dCe =
649 return k * (tracer_reaction_order - 1.) *
650 std::pow(Ceff, tracer_reaction_order - 2.) * dCe;
651 }
652 else
653 return 0.0;
654 }
655
656 /**
657 * @brief Compute the derivative of the reaction constant with respect to a field.
658 *
659 * @param[in] field_vectors Vector of values of the fields used to evaluate
660 * the reaction constant. The map stores a vector of values per field.
661 *
662 * @param[in] id Identifier of the field with respect to which a derivative
663 * should be computed.
664 *
665 * @param[out] jacobian Vector of computed derivative values of the
666 * reaction constant with respect to the field of the specified @p id.
667 */
668 void
669 vector_jacobian(const std::map<field, std::vector<double>> &field_vectors,
670 const field id,
671 std::vector<double> &jacobian_vector) override
672 {
673 Assert(field_vectors.find(field::levelset) != field_vectors.end(),
674 PhysicialPropertyModelFieldUndefined(
675 "GaussianLevelsetTracerReactionPrefactor", "levelset"));
676 Assert(field_vectors.find(field::tracer_concentration) !=
677 field_vectors.end(),
678 PhysicialPropertyModelFieldUndefined(
679 "GaussianLevelsetTracerReactionPrefactor",
680 "tracer_concentration"));
681 const std::vector<double> &levelset_vec = field_vectors.at(field::levelset);
682 const std::vector<double> &concentration_vec =
683 field_vectors.at(field::tracer_concentration);
684 const unsigned int n_values = levelset_vec.size();
685 if (id == field::levelset)
686 {
687 for (unsigned int i = 0; i < n_values; ++i)
688 {
689 const double exponential =
690 std::exp(-levelset_vec[i] * levelset_vec[i] / squared_thickness);
691 const double dkdlambda =
692 delta_reaction_constant * exponential *
693 (-2.0 * levelset_vec[i] / squared_thickness);
694 const double Ceff =
695 calculate_effective_concentration(concentration_vec[i],
697 jacobian_vector[i] =
698 dkdlambda * std::pow(Ceff, tracer_reaction_order - 1.);
699 }
700 }
701 else if (id == field::tracer_concentration)
702 {
703 for (unsigned int i = 0; i < n_values; ++i)
704 {
705 const double k = tracer_reaction_constant_bulk +
707 std::exp(-levelset_vec[i] * levelset_vec[i] /
709 const double Ceff =
710 calculate_effective_concentration(concentration_vec[i],
712 const double dCe =
713 calculate_d_effective_concentration_dC(concentration_vec[i],
715 jacobian_vector[i] = k * (tracer_reaction_order - 1.) *
716 std::pow(Ceff, tracer_reaction_order - 2.) *
717 dCe;
718 }
719 }
720 else
721 std::ranges::fill(jacobian_vector, 0.0);
722 }
723
724private:
728 const double squared_thickness;
731};
732
733#endif
ConstantTracerReactionPrefactor(const double p_tracer_reaction_constant, const double p_tracer_reaction_order, const double p_tracer_reaction_threshold)
Constructor.
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Compute the vector of tracer reaction prefactor values.
double jacobian(const std::map< field, double > &field_values, field id) override
Compute the jacobian (partial derivative) of the prefactor with respect to a field.
double value(const std::map< field, double > &fields_value) override
Compute the tracer reaction prefactor.
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
Compute the vector jacobian (partial derivatives) of the prefactor with respect to a field.
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Compute a vector of reaction constant.
GaussianLevelsetTracerReactionPrefactor(const double p_tracer_reaction_constant_interface, const double p_tracer_reaction_constant_bulk, const double p_thickness, const double p_tracer_reaction_order, const double p_tracer_reaction_threshold)
Constructor of the Gaussian level set-dependent reaction prefactor model.
double jacobian(const std::map< field, double > &field_values, field id) override
Compute the jacobian (the partial derivative) of the reaction constant with respect to a specified fi...
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
Compute the derivative of the reaction constant with respect to a field.
double value(const std::map< field, double > &field_values) override
Compute the reaction constant.
void vector_jacobian(const std::map< field, std::vector< double > > &, const field, std::vector< double > &) override
Dummy vector jacobian computation.
double jacobian(const std::map< field, double > &, field) override
Returns a dummy jacobian value.
NoneTracerReactionPrefactor()=default
Default constructor.
void vector_value(const std::map< field, std::vector< double > > &, std::vector< double > &) override
Dummy vector value computation.
double value(const std::map< field, double > &) override
Returns a dummy value.
Material - Class that defines the physical property of a material. Generally a material will be a flu...
Definition parameters.h:594
PhysicalPropertyModel()
Default constructor. Set the model_depends_on to false for all variables.
std::map< field, bool > model_depends_on
double value(const std::map< field, double > &field_values) override
Compute the tracer reaction prefactor.
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
Compute the vector jacobian (partial derivatives) of the prefactor with respect to a field.
double jacobian(const std::map< field, double > &field_values, field id) override
Compute the jacobian (partial derivative) of the prefactor with respect to a specified field.
TanhLevelsetTracerReactionPrefactor(const double p_tracer_reaction_constant_outside, const double p_tracer_reaction_constant_inside, const double p_thickness, const double p_tracer_reaction_order, const double p_tracer_reaction_threshold)
Constructor.
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Compute a vector of tracer reaction prefactor values.
Abstract class to calculate the tracer reaction prefactor.
static std::shared_ptr< TracerReactionPrefactorModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a TracerReactionPrefactorModel object by casting it to the prop...
double calculate_effective_concentration(const double C, const double threshold)
Computes the effective concentration above the threshold and with a smooth transition.
double calculate_d_effective_concentration_dC(const double C, const double threshold)
Computes the derivative of effective concentration in regards to the input concentration.