Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
CarreauYasuda_def.hpp
1#ifndef CARREAUYASUDA_DEF_hpp
2#define CARREAUYASUDA_DEF_hpp
3
4#include "CarreauYasuda_decl.hpp"
5
6namespace FEDD
7{
8
9 template <class SC, class LO, class GO, class NO>
10 CarreauYasuda<SC, LO, GO, NO>::CarreauYasuda(ParameterListPtr_Type params) : DifferentiableFuncClass<SC, LO, GO, NO>(params)
11 {
12 this->params_ = params;
13 // Reading through parameterlist
14 shearThinningModel_ = this->params_->sublist("Material").get("ShearThinningModel", "");
15 characteristicTime = this->params_->sublist("Material").get("CharacteristicTime_Lambda", 0.); // corresponds to \lambda in the formulas in the literature
16 fluid_index_n = this->params_->sublist("Material").get("FluidIndex_n", 1.); // corresponds to n in the formulas being the power-law index
17 nu_0 = this->params_->sublist("Material").get("ZeroShearRateViscosity_eta0", 0.); // is the zero shear-rate viscosity
18 nu_infty = this->params_->sublist("Material").get("InftyShearRateViscosity_etaInfty", 0.); // is the infnite shear-rate viscosity
19 inflectionPoint = this->params_->sublist("Material").get("InflectionPoint_a", 1.); // corresponds to a in the formulas in the literature
20 shear_rate_limitZero = this->params_->sublist("Material").get("Numerical_ZeroValue_ShearRate", 1e-8);
21
22 viscosity_ = 0.; // Initialize Viscsoity value to zero
23 }
24
25 template <class SC, class LO, class GO, class NO>
26 void CarreauYasuda<SC, LO, GO, NO>::evaluateMapping(ParameterListPtr_Type params, double shearRate, double &viscosity)
27 {
28
29 viscosity = this->nu_infty + (this->nu_0 - this->nu_infty) * (std::pow(1.0 + std::pow(this->characteristicTime * shearRate, this->inflectionPoint), (this->fluid_index_n - 1.0) / this->inflectionPoint));
30 this->viscosity_ = viscosity;
31 }
32
33 /*
34 The function is composed of d(eta)/d(GammaDot) * d(GammaDot)/d(Tau) through chain rule
35 while d(GammaDot) * d(GammaDot)/d(Tau)= - 2/GammaDot
36 So a problematic case is if this->inflectionPoint-2.0 < 0 than the shear rate is in the denominator and because it can
37 be zero we may get nan/inf values. Therefore we have to check these cases and catch them
38 */
39 template <class SC, class LO, class GO, class NO>
40 void CarreauYasuda<SC, LO, GO, NO>::evaluateDerivative(ParameterListPtr_Type params, double shearRate, double &res)
41 {
42
43 if (std::abs(this->inflectionPoint - 2.0) < std::numeric_limits<double>::epsilon()) // for a=2.0 we get gammaDot^{-0} which is 1
44 {
45 // So for a Carreau-like Fluid we should jump here because a=2.0
46 res = (-2.0) * (this->nu_0 - this->nu_infty) * (this->fluid_index_n - 1.0) * std::pow(this->characteristicTime, this->inflectionPoint) * std::pow(1.0 + std::pow(this->characteristicTime * shearRate, this->inflectionPoint), ((this->fluid_index_n - 1.0 - this->inflectionPoint) / this->inflectionPoint));
47 }
48 else // in the other case we have to check that gammaDot is not zero because otherwise we get 1/0
49 {
50 if (std::abs(shearRate) <= shear_rate_limitZero) // How to choose epsilon?
51 {
52 shearRate = shear_rate_limitZero;
53 }
54 res = (-2.0) * (this->nu_0 - this->nu_infty) * (this->fluid_index_n - 1.0) * std::pow(this->characteristicTime, this->inflectionPoint) * std::pow(shearRate, this->inflectionPoint - 2.0) * std::pow(1.0 + std::pow(this->characteristicTime * shearRate, this->inflectionPoint), ((this->fluid_index_n - 1.0 - this->inflectionPoint) / this->inflectionPoint));
55 }
56 }
57
58 template <class SC, class LO, class GO, class NO>
59 void CarreauYasuda<SC, LO, GO, NO>::setParams(ParameterListPtr_Type params)
60 {
61 this->params_ = params;
62 // Reading through parameterlist
63 shearThinningModel_ = this->params_->sublist("Material").get("ShearThinningModel", "");
64 characteristicTime = this->params_->sublist("Material").get("CharacteristicTime_Lambda", 0.); // corresponds to \lambda in the formulas in the literature
65 fluid_index_n = this->params_->sublist("Material").get("FluidIndex_n", 1.); // corresponds to n in the formulas being the power-law index
66 nu_0 = this->params_->sublist("Material").get("ZeroShearRateViscosity_eta0", 0.); // is the zero shear-rate viscosity
67 nu_infty = this->params_->sublist("Material").get("InftyShearRateViscosity_etaInfty", 0.); // is the infnite shear-rate viscosity
68 inflectionPoint = this->params_->sublist("Material").get("InflectionPoint_a", 1.);
69 shear_rate_limitZero = this->params_->sublist("Material").get("Numerical_ZeroValue_ShearRate", 1e-8);
70 }
71
72 template <class SC, class LO, class GO, class NO>
74 {
75 std::cout << "************************************************************ " << std::endl;
76 std::cout << "-- Chosen material model ..." << this->shearThinningModel_ << " --- " << std::endl;
77 std::cout << "-- Specified material parameters:" << std::endl;
78 std::cout << "-- eta_0:" << this->nu_0 << std::endl;
79 std::cout << "-- eta_Infty:" << this->nu_infty << std::endl;
80 std::cout << "-- Fluid index n:" << this->fluid_index_n << std::endl;
81 std::cout << "-- Inflection point a:" << this->inflectionPoint << std::endl;
82 std::cout << "-- Characteristic time lambda:" << this->characteristicTime << std::endl;
83 std::cout << "************************************************************ " << std::endl;
84 }
85
86}
87#endif
CarreauYasuda(ParameterListPtr_Type parameters)
Constructor for CarreauYasuda.
Definition CarreauYasuda_def.hpp:10
void evaluateMapping(ParameterListPtr_Type params, double shearRate, double &viscosity) override
Update the viscosity according to a chosen shear thinning generalized newtonian constitutive equation...
Definition CarreauYasuda_def.hpp:26
void setParams(ParameterListPtr_Type params) override
Each constitutive model includes different material parameters which will be specified in parametersP...
Definition CarreauYasuda_def.hpp:59
void evaluateDerivative(ParameterListPtr_Type params, double shearRate, double &res) override
For Newton method and NOX we need additional term in Jacobian considering directional derivative of o...
Definition CarreauYasuda_def.hpp:40
void echoInformationMapping() override
Print parameter values used in model at runtime.
Definition CarreauYasuda_def.hpp:73
DifferentiableFuncClass(ParameterListPtr_Type parameters)
Definition DifferentiableFuncClass_def.hpp:10
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5