Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
rheological_model.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2021-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_rheological_model_h
5#define lethe_rheological_model_h
6
7#include <core/parameters.h>
9
10using namespace dealii;
11
12/**
13 * @brief Abstract class that allows to calculate the
14 * non-Newtonian viscosity on each quadrature point and the shear rate
15 * magnitude.
16 */
18{
19public:
20 /**
21 * @brief Default constructor
22 */
23 RheologicalModel() = default;
24
25 /**
26 * @brief Instantiates and returns a pointer to a RheologicalModel object by
27 * casting it to the proper child class
28 *
29 * @param material_properties Parsed physical properties that will provide
30 * either the model rheological model being used or say it is a
31 * Newtonian flow
32 */
33 static std::shared_ptr<RheologicalModel>
34 model_cast(const Parameters::Material &material_properties);
35
36 /**
37 * @brief Returns the value of the n parameters of the model, if the model
38 * has one.
39 */
40 virtual double
41 get_n() const
42 {
43 return 1.0;
44 }
45
46 /**
47 * @brief Sets a new value to the n parameter, if the models has one.
48 */
49 virtual void
50 set_n(const double &)
51 {}
52
53 /**
54 * @brief Returns the value of the kinematic viscosity, if the model has one.
55 */
56 virtual double
58 {
59 return 1.0;
60 }
61
62 /**
63 * @brief Returns the kinematic viscosity scale. This is used to get the
64 * kinematic viscosity scale in the problem when it's not constant. This is
65 * useful for weak boundary conditions.
66 */
67 virtual double
69 {
70 return 1.0;
71 }
72
73 /**
74 * @brief Sets a new kinematic viscosity value, if the models has one.
75 * @param p_kinematic_viscosity The kinematic viscosity value
76 */
77 virtual void
78 set_kinematic_viscosity([[maybe_unused]] const double &p_kinematic_viscosity)
79 {}
80
81 /**
82 * @brief Sets a new dynamic viscosity value, if the models has a constant
83 * dynamic viscosity value.
84 * @param p_density_ref The density of the fluid at the reference state
85 */
86 virtual void
87 set_dynamic_viscosity([[maybe_unused]] const double &p_density_ref)
88 {}
89
90 /**
91 * @brief Calculates the dynamic viscosity, if a kinematic viscosity
92 * and a reference density value is specified.
93 * @param p_density_ref The density of the fluid at the reference state
94 * @param field_values Value of the various fields on which the property may
95 * depend.
96 */
97 virtual double
98 get_dynamic_viscosity(const double &p_density_ref,
99 const std::map<field, double> &field_values) const = 0;
100
101 /**
102 * @brief Calculates the vector values of the dynamic viscosity.
103 * @param p_density_ref The density of the fluid at the reference state
104 * @param field_vectors Values of the field on which the dynamic viscosity may
105 * depend on.
106 * @param property_vector todo
107 */
108 virtual void
110 const double &p_density_ref,
111 const std::map<field, std::vector<double>> &field_vectors,
112 std::vector<double> &property_vector) = 0;
113
114 /**
115 * @brief Calculates the kinematic viscosity used in PSPG and SUPG stabilization terms.
116 * @param[in] field_values Value of the various fields on which the property
117 * may depend.
118 */
119 virtual double
121 const std::map<field, double> &field_values)
122 {
123 return value(field_values);
124 }
125
126 /**
127 * @brief Calculates the vector values of the kinematic viscosity used in PSPG and SUPG stabilization terms.
128 * @param[in] field_vectors Value of the fields on which the property may
129 * depend on.
130 * @param[out] property_vector Vector of computed viscosities.
131 */
132 virtual void
134 const std::map<field, std::vector<double>> &field_vectors,
135 std::vector<double> &property_vector)
136 {
137 vector_value(field_vectors, property_vector);
138 }
139
140 /**
141 * @brief Calculates the dynamic viscosity used in PSPG and SUPG stabilization terms.
142 * @param[in] p_density_ref The density of the fluid at the reference state
143 * @param[in] field_values Value of the various fields on which the property
144 * may depend.
145 */
146 virtual double
148 const double &p_density_ref,
149 const std::map<field, double> &field_values)
150 {
151 return get_dynamic_viscosity(p_density_ref, field_values);
152 }
153
154 /**
155 * @brief Calculates the vector values of the dynamic viscosity used in PSPG and SUPG stabilization terms.
156 * @param[in] p_density_ref The density of the fluid at the reference state
157 * @param[in] field_vectors Value of the fields on which the property may
158 * depend on.
159 * @param[out] property_vector Vector of computed viscosities.
160 */
161 virtual void
163 const double &p_density_ref,
164 const std::map<field, std::vector<double>> &field_vectors,
165 std::vector<double> &property_vector)
166 {
167 get_dynamic_viscosity_vector(p_density_ref, field_vectors, property_vector);
168 }
169
170 /**
171 * @brief is_non_newtonian_rheological_model Returns a boolean indicating if
172 * the model is a non-Newtonian rheological model.
173 * @return Boolean value of if the model corresponds to a non-Newtonian
174 * rheological model.
175 */
176 bool
181
182 /**
183 * @brief Returns a boolean indicating if
184 * the model is a phase change rheological model.
185 * @return Boolean value of if the model corresponds to a phase change
186 * rheological model.
187 */
188 bool
193
194protected:
195 /// Boolean to indicate if the rheological model is a non-Newtonian model.
197
198 /// Boolean to indicate if the rheological model is a phase change model.
200};
201
203{
204public:
205 /**
206 * @brief Parameter constructor
207 *
208 * @param p_kinematic_viscosity The constant newtonian viscosity
209 */
210 explicit Newtonian(const double &p_kinematic_viscosity)
211 : kinematic_viscosity(p_kinematic_viscosity)
213 {}
214
215 /**
216 * @brief Returns the kinematic viscosity.
217 *
218 * @param[in] field_values Values of the field on which the viscosity may
219 * depend on. For the constant kinematic viscosity, the kinematic viscosity
220 * does not depend on anything.
221 */
222 double
223 value([[maybe_unused]] const std::map<field, double> &field_values) override;
224
225 /**
226 * @brief vector_value Calculates the vector values of the kinematic
227 * viscosity.
228 * @param field_vectors Values of the field on which the kinematic viscosity
229 * may depend on. These are not used for the constant kinematic viscosity.
230 * @param property_vector Vector of the value of the kinematic viscosity.
231 */
232 void
234 [[maybe_unused]] const std::map<field, std::vector<double>> &field_vectors,
235 std::vector<double> &property_vector) override
236 {
237 std::ranges::fill(property_vector, kinematic_viscosity);
238 }
239
240 /**
241 * @brief jacobian Calculates the jacobian (the partial derivative) of the
242 * kinematic viscosity
243 * with respect to a field
244 * @param field_values Value of the various fields on which the property may
245 * depend. The constant kinematic viscosity does not depend on anything
246 * @param id Indicator of the field with respect to which the jacobian
247 * should be calculated
248 * @return value of the partial derivative of the kinematic viscosity with
249 * respect to the field.
250 */
251
252 double
253 jacobian([[maybe_unused]] const std::map<field, double> &field_values,
254 [[maybe_unused]] field id) override
255 {
256 return 0;
257 };
258
259 /**
260 * @brief vector_jacobian Calculate the derivative of the with respect to a
261 * field
262 * @param[in] field_vectors Vector for the values of the fields used to
263 * evaluate the property
264 * @param[in] id Identifier of the field with respect to which a derivative
265 * should be calculated
266 * @param[out] jacobian_vector Vector of the value of the derivative of the
267 * kinematic viscosity with respect to the field id
268 */
269
270 void
272 [[maybe_unused]] const std::map<field, std::vector<double>> &field_vectors,
273 [[maybe_unused]] const field id,
274 std::vector<double> &jacobian_vector) override
275 {
276 std::ranges::fill(jacobian_vector, 0);
277 }
278
279 double
280 get_kinematic_viscosity() const override
281 {
282 return kinematic_viscosity;
283 }
284
285 double
287 {
288 return kinematic_viscosity;
289 }
290
291 void
292 set_kinematic_viscosity(const double &p_kinematic_viscosity) override
293 {
294 kinematic_viscosity = p_kinematic_viscosity;
295 }
296
297 void
298 set_dynamic_viscosity(const double &p_density_ref) override
299 {
300 dynamic_viscosity = kinematic_viscosity * p_density_ref;
301 }
302
303 /**
304 * @brief Calculates the dynamic viscosity, if a kinematic viscosity
305 * and a reference density value is specified.
306 * @param p_density_ref The density of the fluid at the reference state
307 * @param field_values Value of the various fields on which the property may
308 * depend. The constant dynamic viscosity does not depend on anything.
309 *
310 * These parameters are not needed if the model has a constant kinematic
311 * viscosity, since it implies a constant dynamic viscosity also. The value of
312 * the dynamic viscosity needs to be set with
313 * "set_dynamic_viscosity(density_ref)" before calling this function.
314 */
315 double
317 [[maybe_unused]] const double &p_density_ref,
318 [[maybe_unused]] const std::map<field, double> &field_values) const override
319 {
320 return dynamic_viscosity;
321 }
322
323 /**
324 * @brief Calculates the vector values of the dynamic viscosity.
325 * @param p_density_ref The density of the fluid at the reference state. This
326 * value is not needed if the model has a constant kinematic viscosity, since
327 * it implies a constant dynamic viscosity also. The value of the dynamic
328 * viscosity needs to be set with "set_dynamic_viscosity(density_ref)"
329 * before calling this function.
330 * @param field_vectors Values of the field on which the dynamic viscosity may
331 * depend on. These are not used for the constant kinematic viscosity.
332 * @param property_vector Vector of the value of the dynamic viscosity.
333 */
334 void
336 [[maybe_unused]] const double &p_density_ref,
337 [[maybe_unused]] const std::map<field, std::vector<double>> &field_vectors,
338 std::vector<double> &property_vector) override
339 {
340 std::ranges::fill(property_vector, dynamic_viscosity);
341 }
342
343private:
346};
347
349{
350public:
351 /**
352 * @brief Parameter constructor
353 *
354 * @param K Todo
355 * @param n Todo
356 * @param shear_rate_min Todo
357 */
358 PowerLaw(const double K, const double n, const double shear_rate_min)
359 : K(K)
360 , n(n)
362 {
365 }
366
367 /**
368 * @brief Returns the non-Newtonian kinematic viscosity.
369 *
370 * @param field_values The values of the field on which the kinematic
371 * viscosity may depend on. For this model, it only depends on the magnitude
372 * of the shear rate tensor
373 *
374 * Source : Morrison, F. A. (2001). No Memory: Generalized Newtonian Fluids.
375 * Understanding Rheology. Raymond F. Boyer Library Collection, Oxford
376 * University Press.
377 */
378 double
379 value(const std::map<field, double> &field_values) override;
380
381 /**
382 * @brief vector_value Calculates the vector values of the kinematic
383 * viscosity.
384 * @param field_vectors Values of the field on which the kinematic viscosity
385 * may depend on. The power-law kinematic viscosity depends on the shear rate.
386 * @param property_vector Vector of the properties.
387 */
388 void
390 [[maybe_unused]] const std::map<field, std::vector<double>> &field_vectors,
391 std::vector<double> &property_vector) override;
392
393 /**
394 * @brief jacobian Calculates the jacobian (the partial derivative) of the
395 * kinematic viscosity with respect to a field
396 * @param field_values Value of the various fields on which the property may
397 * depend. The constant kinematic viscosity does not depend on anything.
398 * @param id Indicator of the field with respect to which the jacobian
399 * should be calculated
400 * @return value of the partial derivative of the kinematic viscosity with
401 * respect to the field.
402 */
403
404 double
405 jacobian(const std::map<field, double> &field_values,
406 [[maybe_unused]] field id) override;
407
408 /**
409 * @brief vector_jacobian Calculate the derivative of the with respect to a
410 * field
411 * @param field_vectors Vector for the values of the fields used to evaluate
412 * the property
413 * @param id Identifier of the field with respect to which a derivative
414 * should be calculated
415 * @param jacobian_vector Vector of the value of the derivative of the kinematic
416 * viscosity with respect to the field id
417 */
418
419 void
421 [[maybe_unused]] const std::map<field, std::vector<double>> &field_vectors,
422 [[maybe_unused]] const field id,
423 std::vector<double> &jacobian_vector) override;
424
425 double
426 get_n() const override
427 {
428 return n;
429 }
430
431 void
432 set_n(const double &p_n) override
433 {
434 n = p_n;
435 }
436
437 double
438 get_kinematic_viscosity() const override
439 {
440 return K;
441 }
442
443 double
445 {
446 return 1.0 > shear_rate_min ? K * std::pow(1.0, n - 1) :
447 K * std::pow(shear_rate_min, n - 1);
448 }
449
450 void
451 set_kinematic_viscosity(const double &p_kinematic_viscosity) override
452 {
453 K = p_kinematic_viscosity;
454 }
455
456 /**
457 * @brief Calculates the dynamic viscosity, if a kinematic viscosity
458 * and a reference density value is specified.
459 * @param p_density_ref The density of the fluid at the reference state
460 * @param field_values Value of the various fields on which the property may
461 * depend. The power law dynamic viscosity depends on the shear rate
462 * magnitude.
463 */
464 double
466 const double &p_density_ref,
467 const std::map<field, double> &field_values) const override
468 {
469 Assert(field_values.contains(field::shear_rate),
470 PhysicialPropertyModelFieldUndefined("PowerLaw", "shear_rate"));
471 const double shear_rate_magnitude = field_values.at(field::shear_rate);
472 return calculate_kinematic_viscosity(shear_rate_magnitude) * p_density_ref;
473 }
474
475 /**
476 * @brief Calculates the vector values of the dynamic viscosity.
477 * @param p_density_ref The density of the fluid at the reference state
478 * @param field_vectors Values of the field on which the dynamic viscosity may
479 * depend on.
480 * @param property_vector
481 */
482 void
484 const double &p_density_ref,
485 const std::map<field, std::vector<double>> &field_vectors,
486 std::vector<double> &property_vector) override
487 {
488 Assert(field_vectors.contains(field::shear_rate),
489 PhysicialPropertyModelFieldUndefined("PowerLaw", "shear_rate"));
490 const std::vector<double> &shear_rate_magnitude =
491 field_vectors.at(field::shear_rate);
492
493 for (unsigned int i = 0; i < property_vector.size(); ++i)
494 property_vector[i] =
495 calculate_kinematic_viscosity(shear_rate_magnitude[i]) * p_density_ref;
496 }
497
498private:
499 inline double
500 calculate_kinematic_viscosity(const double shear_rate_magnitude) const
501 {
502 return shear_rate_magnitude > shear_rate_min ?
503 K * std::pow(shear_rate_magnitude, n - 1) :
504 K * std::pow(shear_rate_min, n - 1);
505 }
506
507 inline double
508 calculate_derivative(const double shear_rate_magnitude) const
509 {
510 return shear_rate_magnitude > shear_rate_min ?
511 (n - 1) * K * std::pow(shear_rate_magnitude, n - 2) :
512 0;
513 }
514
515 double K;
516 double n;
517 const double shear_rate_min;
518};
519
521{
522public:
523 /**
524 * @brief Parameter constructor
525 *
526 * @param p_kinematic_viscosity_0
527 * @param p_kinematic_viscosity_inf
528 * @param p_lambda
529 * @param p_a
530 * @param p_n
531 */
532 Carreau(const double p_kinematic_viscosity_0,
533 const double p_kinematic_viscosity_inf,
534 const double p_lambda,
535 const double p_a,
536 const double p_n)
537 : kinematic_viscosity_0(p_kinematic_viscosity_0)
538 , kinematic_viscosity_inf(p_kinematic_viscosity_inf)
539 , lambda(p_lambda)
540 , a(p_a)
541 , n(p_n)
542 {
545 }
546
547 /**
548 * @brief Returns the non-Newtonian viscosity.
549 *
550 * @param field_values The values of the field on which the viscosity may
551 * depend on. For this model, it only depends on the magnitude of the shear
552 * rate tensor.
553 *
554 * Source : Morrison, F. A. (2001). No Memory: Generalized Newtonian Fluids.
555 * Understanding Rheology. Raymond F. Boyer Library Collection, Oxford
556 * University Press.
557 */
558 double
559 value(const std::map<field, double> &field_values) override;
560
561 /**
562 * @brief vector_value Calculates the vector values of the viscosity.
563 * @param field_vectors Values of the field on which the viscosity may depend
564 * on. The power-law viscosity depends on the shear rate.
565 * @param property_vector
566 */
567 void
568 vector_value(const std::map<field, std::vector<double>> &field_vectors,
569 std::vector<double> &property_vector) override;
570
571 /**
572 * @brief jacobian Calculates the jacobian (the partial derivative) of the
573 * viscosity with respect to a field
574 * @param field_values Value of the various fields on which the property may
575 * depend. The constant viscosity does not depend on anything
576 * @param id Indicator of the field with respect to which the jacobian
577 * should be calculated
578 * @return value of the partial derivative of the viscosity with respect to
579 * the field.
580 */
581 double
582 jacobian(const std::map<field, double> &field_values, field id) override;
583
584 /**
585 * @brief vector_jacobian Calculate the derivative of the with respect to a
586 * field
587 * @param field_vectors Vector for the values of the fields used to evaluate
588 * the property
589 * @param id Identifier of the field with respect to which a derivative should
590 * be calculated
591 * @param jacobian_vector Vector of the value of the derivative of the viscosity with
592 * respect to the field id
593 */
594
595 void
596 vector_jacobian(const std::map<field, std::vector<double>> &field_vectors,
597 const field id,
598 std::vector<double> &jacobian_vector) override;
599
600 double
601 get_n() const override
602 {
603 return n;
604 }
605
606 void
607 set_n(const double &p_n) override
608 {
609 n = p_n;
610 }
611
612 double
613 get_kinematic_viscosity() const override
614 {
616 }
617
618 double
620 {
623 std::pow(1.0 + std::pow(1.0 * lambda, a), (n - 1) / a);
624 }
625
626 void
627 set_kinematic_viscosity(const double &p_kinematic_viscosity) override
628 {
629 kinematic_viscosity_0 = p_kinematic_viscosity;
630 }
631
632 double
634 const double &p_density_ref,
635 const std::map<field, double> &field_values) const override
636 {
637 Assert(field_values.contains(field::shear_rate),
638 PhysicialPropertyModelFieldUndefined("Carreau", "shear_rate"));
639 const double shear_rate_magnitude = field_values.at(field::shear_rate);
640 return calculate_kinematic_viscosity(shear_rate_magnitude) * p_density_ref;
641 }
642
643 /**
644 * @brief Calculates the vector values of the dynamic viscosity.
645 * @param p_density_ref The density of the fluid at the reference state
646 * @param field_vectors Values of the field on which the dynamic viscosity may
647 * depend on.
648 * @param property_vector
649 */
650 void
652 const double &p_density_ref,
653 const std::map<field, std::vector<double>> &field_vectors,
654 std::vector<double> &property_vector) override
655 {
656 Assert(field_vectors.contains(field::shear_rate),
657 PhysicialPropertyModelFieldUndefined("Carreau", "shear_rate"));
658 const std::vector<double> &shear_rate_magnitude =
659 field_vectors.at(field::shear_rate);
660
661 for (unsigned int i = 0; i < property_vector.size(); ++i)
662 property_vector[i] =
663 calculate_kinematic_viscosity(shear_rate_magnitude[i]) * p_density_ref;
664 }
665
666private:
667 inline double
668 calculate_kinematic_viscosity(const double shear_rate_magnitude) const
669 {
672 std::pow(1.0 + std::pow(shear_rate_magnitude * lambda, a),
673 (n - 1) / a);
674 }
675
678 double lambda;
679 double a;
680 double n;
681};
682
683/**
684 * @brief Calculates the magnitude of the shear rate tensor given as input
685 *
686 * @param shear_rate A shear rate tensor
687 */
688template <int dim>
689inline double
691{
692 double shear_rate_magnitude = 0;
693 for (int i = 0; i < dim; ++i)
694 {
695 for (int j = 0; j < dim; ++j)
696 {
697 shear_rate_magnitude += (shear_rate[i][j] * shear_rate[j][i]);
698 }
699 }
700 shear_rate_magnitude = sqrt(0.5 * shear_rate_magnitude);
701 return shear_rate_magnitude;
702}
703
704
706{
707public:
708 /**
709 * @brief Parameter constructor
710 *
711 * @param p_phase_change_parameters The parameters needed by the phase change
712 * rheology
713 */
714 PhaseChangeRheology(const Parameters::PhaseChange &p_phase_change_parameters)
715 : param(p_phase_change_parameters)
716 {
719 }
720
721 /**
722 * @brief Returns the kinematic viscosity.
723 *
724 * @param field_values Values of the field on which the kinematic viscosity
725 * may depend on.
726 * For the constant kinematic viscosity, the kinematic viscosity does not
727 * depend on anything.
728 */
729 double
730 value(const std::map<field, double> &field_values) override;
731
732 /**
733 * @brief vector_value Calculates the vector values of the kinematic
734 * viscosity.
735 * @param field_vectors Values of the field on which the kinematic viscosity
736 * may depend on. These are not used for the constant kinematic viscosity.
737 * @param property_vector
738 */
739 void
740 vector_value(const std::map<field, std::vector<double>> &field_vectors,
741 std::vector<double> &property_vector) override;
742
743 /**
744 * @brief jacobian Calculates the jacobian (the partial derivative) of the
745 * kinematic viscosity with respect to a field
746 * @param field_values Value of the various fields on which the property may
747 * depend. The constant kinematic viscosity does not depend on anything.
748 * @param id Indicator of the field with respect to which the jacobian
749 * should be calculated
750 * @return value of the partial derivative of the kinematic viscosity with
751 * respect to the field.
752 */
753
754 double
755 jacobian(const std::map<field, double> &field_values, field id) override;
756
757 /**
758 * @brief vector_jacobian Calculate the derivative of the with respect to a
759 * field
760 * @param field_vectors Vector for the values of the fields used to evaluate
761 * the property
762 * @param id Identifier of the field with respect to which a derivative should
763 * be calculated
764 * @param jacobian_vector Vector of the value of the derivative of the kinematic
765 * viscosity with respect to the field id
766 */
767
768 void
769 vector_jacobian(const std::map<field, std::vector<double>> &field_vectors,
770 const field id,
771 std::vector<double> &jacobian_vector) override;
772
773 /**
774 * @brief Returns the kinematic viscosity scale.
775 */
776 double
778 {
779 return param.kinematic_viscosity_l;
780 }
781
782 double
784 const double &p_density_ref,
785 const std::map<field, double> &field_values) const override
786 {
787 Assert(field_values.contains(field::temperature),
788 PhysicialPropertyModelFieldUndefined("PhaseChangeRheology",
789 "temperature"));
790 const double temperature = field_values.at(field::temperature);
791 return kinematic_viscosity(temperature) * p_density_ref;
792 }
793
794 /**
795 * @brief Calculates the vector values of the dynamic viscosity.
796 * @param p_density_ref The density of the fluid at the reference state
797 * @param field_vectors Values of the field on which the dynamic viscosity may
798 * depend on.
799 * @param property_vector
800 */
801 void
803 const double &p_density_ref,
804 const std::map<field, std::vector<double>> &field_vectors,
805 std::vector<double> &property_vector) override
806 {
807 Assert(field_vectors.contains(field::temperature),
808 PhysicialPropertyModelFieldUndefined("PhaseChangeRheology",
809 "temperature"));
810 const std::vector<double> &temperature =
811 field_vectors.at(field::temperature);
812
813 for (unsigned int i = 0; i < property_vector.size(); ++i)
814 property_vector[i] = kinematic_viscosity(temperature[i]) * p_density_ref;
815 }
816
817 /**
818 * @brief Calculates the kinematic viscosity used in PSPG and SUPG stabilization terms.
819 * @param[in] field_values Value of the various fields on which the property
820 * may depend.
821 */
822 double
824 const std::map<field, double> &field_values) override;
825
826 /**
827 * @brief Calculates the vector values of the kinematic viscosity used in PSPG and SUPG stabilization terms.
828 * @param[in] field_vectors Value of the fields on which the property may
829 * depend on.
830 * @param[out] property_vector Vector of computed viscosities.
831 */
832 void
834 const std::map<field, std::vector<double>> &field_vectors,
835 std::vector<double> &property_vector) override;
836
837 /**
838 * @brief Calculates the dynamic viscosity used in PSPG and SUPG stabilization terms.
839 * @param[in] p_density_ref The density of the fluid at the reference state
840 * @param[in] field_values Value of the various fields on which the property
841 * may depend.
842 */
843 virtual double
845 const double &p_density_ref,
846 [[maybe_unused]] const std::map<field, double> &field_values) override;
847
848 /**
849 * @brief Calculates the vector values of the dynamic viscosity used in PSPG and SUPG stabilization terms.
850 * @param[in] p_density_ref The density of the fluid at the reference state
851 * @param[in] field_vectors Value of the fields on which the property may
852 * depend on.
853 * @param[out] property_vector Vector of computed viscosities.
854 */
855 virtual void
857 const double &p_density_ref,
858 [[maybe_unused]] const std::map<field, std::vector<double>> &field_vectors,
859 std::vector<double> &property_vector) override;
860
861private:
862 /**
863 * @brief kinematic_viscosity Calculates the kinematic viscosity from the
864 * temperature using the liquid fraction
865 *
866 * @param T value of the temperature
867 * @return value of the kinematic viscosity
868 *
869 */
870 inline double
871 kinematic_viscosity(const double T) const
872 {
873 const double l_frac =
874 std::min(std::max((T - param.T_solidus) /
875 (param.T_liquidus - param.T_solidus),
876 0.),
877 1.);
878
879 return param.kinematic_viscosity_l * l_frac +
880 param.kinematic_viscosity_s * (1. - l_frac);
881 }
882
884};
885
886#endif
Carreau(const double p_kinematic_viscosity_0, const double p_kinematic_viscosity_inf, const double p_lambda, const double p_a, const double p_n)
Parameter constructor.
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
double kinematic_viscosity_0
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the viscosity.
double get_kinematic_viscosity() const override
Returns the value of the kinematic viscosity, if the model has one.
void set_kinematic_viscosity(const double &p_kinematic_viscosity) override
Sets a new kinematic viscosity value, if the models has one.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
void set_n(const double &p_n) override
Sets a new value to the n parameter, if the models has one.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
double get_n() const override
Returns the value of the n parameters of the model, if the model has one.
double kinematic_viscosity_inf
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the viscosity with respect to a field
double value(const std::map< field, double > &field_values) override
Returns the non-Newtonian viscosity.
double calculate_kinematic_viscosity(const double shear_rate_magnitude) const
double get_kinematic_viscosity() const override
Returns the value of the kinematic viscosity, if the model has one.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
Newtonian(const double &p_kinematic_viscosity)
Parameter constructor.
void set_dynamic_viscosity(const double &p_density_ref) override
Sets a new dynamic viscosity value, if the models has a constant dynamic viscosity value.
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the kinematic viscosity.
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
void set_kinematic_viscosity(const double &p_kinematic_viscosity) override
Sets a new kinematic viscosity value, if the models has one.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
double dynamic_viscosity
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the kinematic viscosity with respect to ...
double value(const std::map< field, double > &field_values) override
Returns the kinematic viscosity.
double kinematic_viscosity
Material - Class that defines the physical property of a material. Generally a material will be a flu...
Definition parameters.h:594
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the kinematic viscosity with respect to ...
PhaseChangeRheology(const Parameters::PhaseChange &p_phase_change_parameters)
Parameter constructor.
virtual void get_dynamic_viscosity_for_stabilization_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity used in PSPG and SUPG stabilization terms.
Parameters::PhaseChange param
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the kinematic viscosity.
double kinematic_viscosity(const double T) const
kinematic_viscosity Calculates the kinematic viscosity from the temperature using the liquid fraction
double get_kinematic_viscosity_for_stabilization(const std::map< field, double > &field_values) override
Calculates the kinematic viscosity used in PSPG and SUPG stabilization terms.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale.
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
void get_kinematic_viscosity_for_stabilization_vector(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the kinematic viscosity used in PSPG and SUPG stabilization terms.
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
virtual double get_dynamic_viscosity_for_stabilization(const double &p_density_ref, const std::map< field, double > &field_values) override
Calculates the dynamic viscosity used in PSPG and SUPG stabilization terms.
double value(const std::map< field, double > &field_values) override
Returns the kinematic viscosity.
virtual double value(const std::map< field, double > &fields_value)=0
value Calculates the value of a physical property.
PhysicalPropertyModel()
Default constructor. Set the model_depends_on to false for all variables.
virtual void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)=0
vector_value Calculates the values of a physical property for multiple points
std::map< field, bool > model_depends_on
double calculate_kinematic_viscosity(const double shear_rate_magnitude) const
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the kinematic viscosity.
void set_kinematic_viscosity(const double &p_kinematic_viscosity) override
Sets a new kinematic viscosity value, if the models has one.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
PowerLaw(const double K, const double n, const double shear_rate_min)
Parameter constructor.
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the kinematic viscosity with respect to ...
double calculate_derivative(const double shear_rate_magnitude) const
double get_n() const override
Returns the value of the n parameters of the model, if the model has one.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
double get_kinematic_viscosity() const override
Returns the value of the kinematic viscosity, if the model has one.
void set_n(const double &p_n) override
Sets a new value to the n parameter, if the models has one.
double value(const std::map< field, double > &field_values) override
Returns the non-Newtonian kinematic viscosity.
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
const double shear_rate_min
virtual double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const =0
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
virtual void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)=0
Calculates the vector values of the dynamic viscosity.
virtual double get_dynamic_viscosity_for_stabilization(const double &p_density_ref, const std::map< field, double > &field_values)
Calculates the dynamic viscosity used in PSPG and SUPG stabilization terms.
bool is_phase_change_rheological_model() const
Returns a boolean indicating if the model is a phase change rheological model.
bool phase_change_rheological_model
Boolean to indicate if the rheological model is a phase change model.
bool non_newtonian_rheological_model
Boolean to indicate if the rheological model is a non-Newtonian model.
virtual double get_n() const
Returns the value of the n parameters of the model, if the model has one.
virtual double get_kinematic_viscosity_for_stabilization(const std::map< field, double > &field_values)
Calculates the kinematic viscosity used in PSPG and SUPG stabilization terms.
virtual void get_dynamic_viscosity_for_stabilization_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)
Calculates the vector values of the dynamic viscosity used in PSPG and SUPG stabilization terms.
bool is_non_newtonian_rheological_model() const
is_non_newtonian_rheological_model Returns a boolean indicating if the model is a non-Newtonian rheol...
static std::shared_ptr< RheologicalModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a RheologicalModel object by casting it to the proper child cla...
virtual void get_kinematic_viscosity_for_stabilization_vector(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)
Calculates the vector values of the kinematic viscosity used in PSPG and SUPG stabilization terms.
virtual void set_dynamic_viscosity(const double &p_density_ref)
Sets a new dynamic viscosity value, if the models has a constant dynamic viscosity value.
virtual void set_n(const double &)
Sets a new value to the n parameter, if the models has one.
virtual double get_kinematic_viscosity_scale() const
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
virtual double get_kinematic_viscosity() const
Returns the value of the kinematic viscosity, if the model has one.
virtual void set_kinematic_viscosity(const double &p_kinematic_viscosity)
Sets a new kinematic viscosity value, if the models has one.
RheologicalModel()=default
Default constructor.
@ temperature
Temperature scalar field from heat transfer.
double calculate_shear_rate_magnitude(const Tensor< 2, dim > shear_rate)
Calculates the magnitude of the shear rate tensor given as input.
Phase change model for melting/freezing liquids The model assumes that the phase change occurs betwee...
Definition parameters.h:264