MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
materialstate.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef MAIA_MATERIALSTATE_H
8#define MAIA_MATERIALSTATE_H
9#include <functional>
10#include "globals.h"
11#include "solver.h"
12
13
14template <MInt nDim>
16 private:
17 friend class LPT<nDim>;
18
20
22
26
30
33
36
37 std::array<MFloat, 4> m_particleDensity = {-1.0, 0.0, 0.0, 0.0};
38 std::array<MFloat, 4> m_cp = {0.0, 0.0, 0.0, 0.0};
39 std::array<MFloat, 4> m_my = {0.0, 0.0, 0.0, 0.0};
40 std::array<MFloat, 4> m_thCond = {0.0, 0.0, 0.0, 0.0};
41 std::array<MFloat, 4> m_diffC = {0.0, 0.0, 0.0, 0.0};
42 std::array<MFloat, 4> m_lH_ev = {0.0, 0.0, 0.0, 0.0};
43 std::array<MFloat, 4> m_surfaceTension = {1.0, 0.0, 0.0, 0.0};
44 std::array<MFloat, 4> m_liquidMy = {0.0, 0.0, 0.0, 0.0};
45 std::array<MFloat, 4> m_liquidThCond = {0.0, 0.0, 0.0, 0.0};
46
47 std::array<MFloat, 4> m_fluidThCond = {3.227E-3, 8.3894E-5, -1.9858E-8, 0.0};
48 std::array<MFloat, 4> m_Pr = {0.815, -0.0004958, 0.0000004514, 0.0};
49
52
53 std::function<MFloat(const MFloat T)> m_viscosityFunction;
54 MFloat m_nu = -1.0;
55
56 public:
57 MaterialState(const MInt solverId_) : solverId(solverId_) { readProperties(); }
58
63
64 // check given temperature against given temperature range and return valid value
65 inline MFloat checkWithTemperatureRange(const MFloat temperature_) {
66 if(temperature_ < m_temperatureLower) {
67 return m_temperatureLower;
68 }
69 if(temperature_ > m_temperatureUpper) {
70 return m_temperatureUpper;
71 }
72 return temperature_;
73 }
74
75 // thermal conductivity of disperse phase in continous phase
76 inline MFloat thermalConductivity(const MFloat temperature_) {
77 MFloat temperature = checkWithTemperatureRange(temperature_);
78 return m_thCond[0] + m_thCond[1] * temperature + m_thCond[2] * POW2(temperature) + m_thCond[3] * POW3(temperature);
79 }
80
81 // thermal conductivity of liquid phase in continous phase
82 inline MFloat liquidThermalConductivity(const MFloat temperature_) {
83 MFloat temperature = checkWithTemperatureRange(temperature_);
84 return m_liquidThCond[0] + m_liquidThCond[1] * temperature + m_liquidThCond[2] * POW2(temperature)
85 + m_liquidThCond[3] * POW3(temperature);
86 }
87
88 // diffusion Coefficient
89 inline MFloat diffusionCoefficient(const MFloat temperature_) {
90 MFloat temperature = checkWithTemperatureRange(temperature_);
91 return m_diffC[0] + m_diffC[1] * temperature + m_diffC[2] * POW2(temperature) + m_diffC[3] * POW3(temperature);
92 }
93
94 // latent heat of evaporation of the disperse phase
95 inline MFloat latentHeatEvap(const MFloat temperature_) {
96 MFloat temperature = checkWithTemperatureRange(temperature_);
97 return m_lH_ev[0] + m_lH_ev[1] * temperature + m_lH_ev[2] * POW2(temperature) + m_lH_ev[3] * POW3(temperature);
98 }
99
100 // dynamic viscosity as a function of temperature based on coefficients for dynamic viscosity
101 inline MFloat dynamicViscosity(const MFloat temperature_) {
102 MFloat temperature = checkWithTemperatureRange(temperature_);
103 return m_my[0] + m_my[1] * temperature + m_my[2] * POW2(temperature) + m_my[3] * POW3(temperature);
104 }
105
106 // dynamic viscosity of liquid phase as a function of temperature based on coefficients for dynamic viscosity of
107 // liquid phase
108 inline MFloat liquidDynamicViscosity(const MFloat temperature_) {
109 MFloat temperature = checkWithTemperatureRange(temperature_);
110 return m_liquidMy[0] + m_liquidMy[1] * temperature + m_liquidMy[2] * POW2(temperature)
111 + m_liquidMy[3] * POW3(temperature);
112 }
113
114 // thermal conductivity of the continous-phase
115 inline MFloat airThermalConductivity(const MFloat temperature_) {
116 MFloat temperature = checkWithTemperatureRange(temperature_);
117 return m_fluidThCond[0] + m_fluidThCond[1] * temperature + m_fluidThCond[2] * POW2(temperature)
118 + m_fluidThCond[3] * POW3(temperature);
119 }
120
121 // Pr-number of the continous-phase
122 inline MFloat airPrandtl(const MFloat temperature_) {
123 MFloat temperature = checkWithTemperatureRange(temperature_);
124 return m_Pr[0] + m_Pr[1] * temperature + m_Pr[2] * POW2(temperature) + m_Pr[3] * POW3(temperature);
125 }
126
127 // dynamic viscosity of the continous phase
128 inline MFloat dynViscosityFun(const MFloat temperature_) {
129 MFloat temperature = checkWithTemperatureRange(temperature_);
130 return m_viscosityFunction(temperature);
131 }
132
133 // NOTE: either particle surface tension (dimensional case)
134 // or 1 as always equal to the constant reference value (non-dimensional case)
135 // Surface Tension as a function of temperature based on coefficients for Surface Tension
136 inline MFloat spraySurfaceTension(const MFloat temperature_ = 1) {
137 MFloat temperature = checkWithTemperatureRange(temperature_);
138 return m_surfaceTension[0] + m_surfaceTension[1] * temperature + m_surfaceTension[2] * POW2(temperature)
139 + m_surfaceTension[3] * POW3(temperature);
140 }
141
142 // NOTE: either particle temperture (dimensional case)
143 // or temperature ratio (non-dimensional case)
144 inline MFloat T() { return m_particleTemperature; }
145
146 // NOTE: either particle density (dimensional case)
147 // or density ratio and identically with densityRatio (non-dimensional case)
148 // particle density as a function of temperature based on coefficients for particle density
149 inline MFloat density(const MFloat temperature_ = 1) {
150 MFloat temperature = checkWithTemperatureRange(temperature_);
151 return m_particleDensity[0] + m_particleDensity[1] * temperature + m_particleDensity[2] * POW2(temperature)
152 + m_particleDensity[3] * POW3(temperature);
153 }
154
155 inline MFloat densityRatio() { return m_densityRatio; }
156
158
159 // NOTE: either particle cp (dimensional case) particle/air ratio (non-dimensional case)
160 // particle cp as a function of temperature based on coefficients for particle cp
161 inline MFloat cp(const MFloat temperature_ = 1) {
162 MFloat temperature = checkWithTemperatureRange(temperature_);
163 return m_cp[0] + m_cp[1] * temperature + m_cp[2] * POW2(temperature) + m_cp[3] * POW3(temperature);
164 }
165
166 // NOTE: either particle surface tension (dimensional case)
167 // or 1 as always equal to the constant reference value (non-dimensional case)
168 inline MFloat airCp() { return m_airCp; }
169
170 // identically function for non-dimensional and dimensional
171 // as purely property based!
172 inline MFloat boilingPoint() { return m_boilingPoint; }
173
174 // identically function for non-dimensional and dimensional
175 // as purely property based!
177
178 // NOTE: either particle specific gas constant (dimensional case)
179 // or 1/gamma * molarWeight-Ration (non-dimensional case)
180 inline MFloat gasConstant() { return m_gasConstant; }
181
182 // identically function for non-dimensional and dimensional
183 // as purely property based!
185
186 // NOTE: either unity (dimensional case)
187 // or gamma -1 (non-dimensional case)
189
190
191 void readProperties() {
192 MBool heatCoupling = false;
193 heatCoupling = Context::getSolverProperty<MBool>("particleHeatCoupling", solverId, AT_, &heatCoupling);
194
195 MBool evaporation = false;
196 evaporation = Context::getSolverProperty<MBool>("particleEvaporation", solverId, AT_, &evaporation);
197
198 MBool nonDimensional = false;
199 nonDimensional = Context::getSolverProperty<MBool>("nonDimensionaliseLPT", solverId, AT_, &nonDimensional);
200
201 const std::array<MString, 4> suffix = {"_a", "_b", "_c", "_d"};
202
203 //----------------------------------------- particle related ------------------------------------
204
212 // NOTE: can be dimensional or non-dimensionalized by the reference density
213 if(Context::propertyExists("particleDensity")) {
215 Context::getSolverProperty<MFloat>("particleDensity", solverId, AT_, &m_particleDensity[0]);
216 } else {
218 Context::getSolverProperty<MFloat>("particleDensity_a", solverId, AT_, &m_particleDensity[0]);
219 }
220
228 // NOTE: can be dimensional or non-dimensionalized by the reference Temperature
229 // default temperature is set to 20C(293.15K)
231 Context::getSolverProperty<MFloat>("particleTemperature", solverId, AT_, &m_particleTemperature);
232
240 // NOTE: can be dimensional or non-dimensionalized by the reference Temperature
241 m_temperatureLower = Context::getSolverProperty<MFloat>("temperatureLowerBnd", solverId, AT_, &m_temperatureLower);
242 m_temperatureUpper = Context::getSolverProperty<MFloat>("temperatureUpperBnd", solverId, AT_, &m_temperatureUpper);
243
244
252 static constexpr MFloat defaultAirCP = 1005;
253 // NOTE: can be dimensional or non-dimensionalized by the fluid cp in the reference state
254 if(Context::propertyExists("particleCP")) {
255 m_cp[0] = Context::getSolverProperty<MFloat>("particleCP", solverId, AT_, &defaultAirCP);
256 } else {
257 m_cp[0] = Context::getSolverProperty<MFloat>("particleCP_a", solverId, AT_, &defaultAirCP);
258 }
259
267 // NOTE: always equal to unity in the non-dimensional case!
268 if(Context::propertyExists("sprayLiquidSurfaceTension")) {
270 Context::getSolverProperty<MFloat>("sprayLiquidSurfaceTension", solverId, AT_, &m_surfaceTension[0]);
271 } else {
272 m_surfaceTension[0] = Context::getSolverProperty<MFloat>("liquidSurfTens_a", solverId, AT_, &m_surfaceTension[0]);
273 }
274
275 if(heatCoupling || evaporation) {
283 if(nonDimensional) {
284 // reference pressure
285 m_bpRefPressure = -1;
286 } else {
287 // 1 bar
288 m_bpRefPressure = 100000;
289 }
290 m_bpRefPressure = Context::getSolverProperty<MFloat>("particleBPRefPressure", solverId, AT_, &m_bpRefPressure);
291
299 static constexpr MFloat defaultAirTB = 58;
300 m_boilingPoint = Context::getSolverProperty<MFloat>("particleBoilingPoint", solverId, AT_, &defaultAirTB);
301
309 for(MInt i = 0; i < 4; ++i) {
311 Context::getSolverProperty<MFloat>("particleDensity" + suffix[i], solverId, AT_, &m_particleDensity[i]);
312 }
313
321 for(MInt i = 0; i < 4; ++i) {
322 m_cp[i] = Context::getSolverProperty<MFloat>("particleCP" + suffix[i], solverId, AT_, &m_cp[i]);
323 }
324
332 if(!Context::propertyExists("particleMy_a")) {
333 mTerm(1, AT_, "Property particleMy_a not found, but is required for the Simulation!");
334 }
335 for(MInt i = 0; i < 4; ++i) {
336 m_my[i] = Context::getSolverProperty<MFloat>("particleMy" + suffix[i], solverId, AT_, &m_my[i]);
337 }
338
346 if(!Context::propertyExists("particleThCond_a")) {
347 mTerm(1, AT_, "Property particleThCond_a not found, but is required for the Simulation!");
348 }
349 for(MInt i = 0; i < 4; ++i) {
350 m_thCond[i] = Context::getSolverProperty<MFloat>("particleThCond" + suffix[i], solverId, AT_, &m_thCond[i]);
351 }
352
360 if(!Context::propertyExists("particleDiffC_a")) {
361 mTerm(1, AT_, "Property particleDiffC_a not found, but is required for the Simulation!");
362 }
363 for(MInt i = 0; i < 4; ++i) {
364 m_diffC[i] = Context::getSolverProperty<MFloat>("particleDiffC" + suffix[i], solverId, AT_, &m_diffC[i]);
365 }
366
374 if(!Context::propertyExists("particleLH_ev_a")) {
375 mTerm(1, AT_, "Property particleLH_ev_a not found, but is required for the Simulation!");
376 }
377 for(MInt i = 0; i < 4; ++i) {
378 m_lH_ev[i] = Context::getSolverProperty<MFloat>("particleLH_ev" + suffix[i], solverId, AT_, &m_lH_ev[i]);
379 }
380
388 for(MInt i = 0; i < 4; ++i) {
390 Context::getSolverProperty<MFloat>("liquidSurfTens" + suffix[i], solverId, AT_, &m_surfaceTension[i]);
391 }
392
401 // Not yet stricly required -> to be changed !!!
402 // if(!Context::propertyExists("liquidMy_a")) {
403 // mTerm(1, AT_, "Property liquidMy_a not found, but is required for the Simulation!");
404 // }
405 for(MInt i = 0; i < 4; ++i) {
406 m_liquidMy[i] = Context::getSolverProperty<MFloat>("liquidMy" + suffix[i], solverId, AT_, &m_liquidMy[i]);
407 }
408
417 // Not yet stricly required -> to be changed !!!
418 // if(!Context::propertyExists("liquidThCond_a")) {
419 // mTerm(1, AT_, "Property liquidThCond_a not found, but is required for the Simulation!");
420 // }
421 for(MInt i = 0; i < 4; ++i) {
422 m_liquidThCond[i] =
423 Context::getSolverProperty<MFloat>("liquidThCond" + suffix[i], solverId, AT_, &m_liquidThCond[i]);
424 }
425
434 for(MInt i = 0; i < 4; ++i) {
435 m_fluidThCond[i] =
436 Context::getSolverProperty<MFloat>("fluidThCond" + suffix[i], solverId, AT_, &m_fluidThCond[i]);
437 }
438
447 for(MInt i = 0; i < 4; ++i) {
448 m_Pr[i] = Context::getSolverProperty<MFloat>("fluidPr" + suffix[i], solverId, AT_, &m_Pr[i]);
449 }
450 }
451
452
453 // --------------------------------- continues/ambient related --------------------------------
454
462 m_molarWeightRatio = Context::getSolverProperty<MFloat>("molarWeightRatio", solverId, AT_, &m_molarWeightRatio);
463
464 m_ambientDensity = Context::getSolverProperty<MFloat>("initialDensity", solverId, AT_, &m_ambientDensity);
465
474 MString viscosityLaw = "SUTHERLAND";
475 viscosityLaw = Context::getSolverProperty<MString>("viscosityLaw", solverId, AT_, &viscosityLaw);
476
489 MFloat referenceTemperature = 273.15;
490 referenceTemperature =
491 Context::getSolverProperty<MFloat>("referenceTemperature", solverId, AT_, &referenceTemperature);
492
504 m_sutherlandConstant = 110.4;
506 Context::getSolverProperty<MFloat>("sutherlandConstant", solverId, AT_, &m_sutherlandConstant);
507
508 m_sutherlandConstant /= referenceTemperature;
510
511 if(string2enum(viscosityLaw) == CONSTANT) {
519 m_nu = Context::getSolverProperty<MFloat>("ambientViscosity", solverId, AT_);
520 }
521
522 if(!nonDimensional) {
530 m_molarMass = 0.02896;
531 m_molarMass = Context::getSolverProperty<MFloat>("particleMolarWeight", solverId, AT_, &m_molarMass);
532 m_gasConstant = 8.3144598 / m_molarMass;
533
534 m_temperatureFactor = 293.15;
536 Context::getSolverProperty<MFloat>("ambientTemperature", solverId, AT_, &m_temperatureFactor);
537
539 0.00001716 * pow(m_temperatureFactor / 273.15, 1.5) * (273.15 + 110.4) / (m_temperatureFactor + 110.4);
540 m_viscosityFactor = Context::getSolverProperty<MFloat>("ambientDynViscosity", solverId, AT_, &m_viscosityFactor);
541
542 if(Context::propertyExists("particleDensityRatio", solverId)) {
543 m_densityRatio = Context::getSolverProperty<MFloat>("particleDensityRatio", solverId, AT_, &m_densityRatio);
544
545 } else if(Context::propertyExists("particleDensity", solverId)
546 && Context::propertyExists("ambientDensity", solverId)) {
547 MFloat disperse = 1;
548 disperse = Context::getSolverProperty<MFloat>("particleDensity", solverId, AT_, &disperse);
549 MFloat continous = 1;
550 continous = Context::getSolverProperty<MFloat>("ambientDensity", solverId, AT_, &continous);
551
552 m_densityRatio = disperse / continous;
553
554 } else {
555 m_densityRatio = 1;
556 }
557
558 if(density(T()) < 0.0) {
559 MFloat continous = -1;
560 continous = Context::getSolverProperty<MFloat>("ambientDensity", solverId, AT_, &continous);
561 if(continous > 0.0) {
562 m_particleDensity[0] = m_densityRatio * continous;
563 m_particleDensity[1] = 0.0;
564 m_particleDensity[2] = 0.0;
565 m_particleDensity[3] = 0.0;
566 } else {
567 // particleDensity should be densityRatio * rho_ref;
568 mTerm(1, AT_, "Particle-density not set!");
569 }
570 }
571
579 // NOTE: always equal to unity in the non-dimensional case!
580 m_airCp = Context::getSolverProperty<MFloat>("ambientCPG", solverId, AT_, &m_airCp);
581
582 m_gammaMinusOne = 1;
583
584 switch(string2enum(viscosityLaw)) {
585 case SUTHERLAND:
586 m_viscosityFunction = [&](const MFloat temperature) {
587 return m_viscosityFactor * SUTHERLANDLAW(temperature / m_temperatureFactor);
588 };
589 break;
590 case CONSTANT:
591 m_viscosityFunction = [&](const MFloat) { return m_nu; };
592 break;
593 default:
594 mTerm(1, AT_, "Invalid viscosity law");
595 break;
596 }
597 } else {
598 m_gamma = 1.4;
601
602 if(Context::propertyExists("ambientDensity", solverId)) {
603 mTerm(1, AT_, "Set particle density instead!");
604 }
605
607 if(m_densityRatio < 0.0) {
608 mTerm(1, AT_, "Set particle density!");
609 }
610
611 switch(string2enum(viscosityLaw)) {
612 case SUTHERLAND:
613 m_viscosityFunction = [&](const MFloat temperature) { return SUTHERLANDLAW(temperature); };
614 break;
615 case CONSTANT:
616 m_viscosityFunction = [&](const MFloat) { return m_nu; };
617 break;
618 default:
619 mTerm(1, AT_, "Invalid viscosity law");
620 break;
621 }
622 }
623 }
624};
625
626template class MaterialState<3>;
627
628#endif // MAIA_MATERIALSTATE_H
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
Definition: context.cpp:494
Definition: lpt.h:82
std::array< MFloat, 4 > m_liquidThCond
Definition: materialstate.h:45
MFloat m_sutherlandConstant
Definition: materialstate.h:61
std::array< MFloat, 4 > m_Pr
Definition: materialstate.h:48
MFloat checkWithTemperatureRange(const MFloat temperature_)
Definition: materialstate.h:65
const MInt solverId
Definition: materialstate.h:19
MFloat m_temperatureLower
Definition: materialstate.h:28
MFloat m_sutherlandPlusOne
Definition: materialstate.h:62
MFloat airPrandtl(const MFloat temperature_)
std::array< MFloat, 4 > m_thCond
Definition: materialstate.h:40
MFloat bpRefPressure()
MFloat dynamicViscosity(const MFloat temperature_)
std::array< MFloat, 4 > m_cp
Definition: materialstate.h:38
MFloat density(const MFloat temperature_=1)
std::array< MFloat, 4 > m_particleDensity
Definition: materialstate.h:37
MFloat diffusionCoefficient(const MFloat temperature_)
Definition: materialstate.h:89
MFloat gammaMinusOne()
MFloat boilingPoint()
MFloat m_particleTemperature
Definition: materialstate.h:27
MFloat dynViscosityFun(const MFloat temperature_)
MFloat airThermalConductivity(const MFloat temperature_)
MFloat m_boilingPoint
Definition: materialstate.h:34
std::array< MFloat, 4 > m_diffC
Definition: materialstate.h:41
std::array< MFloat, 4 > m_my
Definition: materialstate.h:39
MFloat m_densityRatio
Definition: materialstate.h:50
MFloat liquidDynamicViscosity(const MFloat temperature_)
MFloat liquidThermalConductivity(const MFloat temperature_)
Definition: materialstate.h:82
MaterialState(const MInt solverId_)
Definition: materialstate.h:57
MFloat airCp()
MFloat latentHeatEvap(const MFloat temperature_)
Definition: materialstate.h:95
MFloat thermalConductivity(const MFloat temperature_)
Definition: materialstate.h:76
MFloat m_molarWeightRatio
Definition: materialstate.h:32
MFloat m_ambientDensity
Definition: materialstate.h:51
MFloat m_molarMass
Definition: materialstate.h:31
MFloat m_bpRefPressure
Definition: materialstate.h:35
MFloat m_gasConstant
Definition: materialstate.h:25
std::array< MFloat, 4 > m_surfaceTension
Definition: materialstate.h:43
MFloat m_temperatureUpper
Definition: materialstate.h:29
std::array< MFloat, 4 > m_lH_ev
Definition: materialstate.h:42
MFloat densityRatio()
MFloat m_gammaMinusOne
Definition: materialstate.h:24
std::array< MFloat, 4 > m_fluidThCond
Definition: materialstate.h:47
std::function< MFloat(const MFloat T)> m_viscosityFunction
Definition: materialstate.h:53
MFloat cp(const MFloat temperature_=1)
std::array< MFloat, 4 > m_liquidMy
Definition: materialstate.h:44
MFloat m_temperatureFactor
Definition: materialstate.h:60
MFloat spraySurfaceTension(const MFloat temperature_=1)
MFloat gasConstant()
MFloat m_viscosityFactor
Definition: materialstate.h:59
MFloat ambientDensityRatio()
MFloat molWeightRatio()
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
Definition: enums.cpp:20
@ SUTHERLAND
Definition: enums.h:430
@ CONSTANT
Definition: enums.h:430
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
constexpr Real POW3(const Real x)
Definition: functions.h:123
constexpr Real POW2(const Real x)
Definition: functions.h:119
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58