https://mooseframework.inl.gov
GeneralFunctorFluidProps.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "NS.h" // Variable Term Names
12 #include "HeatTransferUtils.h"
13 #include "NavierStokesMethods.h"
15 
18 
19 template <bool is_ad>
22 {
23  auto params = FunctorMaterial::validParams();
24  params.addRequiredParam<UserObjectName>(NS::fluid, "Fluid properties functor userobject");
25  params.addClassDescription("Creates functor fluid properties using a (P, T) formulation");
26 
27  params.addRequiredParam<MooseFunctorName>(NS::pressure, "Pressure");
28  params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "Fluid temperature");
29  params.addRequiredParam<MooseFunctorName>(NS::speed, "Velocity norm");
30  params.addParam<MooseFunctorName>(NS::density, "Density");
31  params.addParam<bool>(
32  "force_define_density",
33  false,
34  "Whether to force the definition of a density functor from the fluid properties");
35  params.addParam<bool>("neglect_derivatives_of_density_time_derivative",
36  true,
37  "Whether to neglect the derivatives with regards to nonlinear variables "
38  "of the density time derivatives");
39 
40  params.addParam<FunctionName>(
41  "mu_rampdown", 1, "A function describing a ramp down of viscosity over time");
42  params.addRequiredParam<MooseFunctorName>(NS::porosity, "porosity");
43  params.addRequiredParam<MooseFunctorName>(
44  "characteristic_length", "characteristic length for Reynolds number calculation");
45 
46  // Dynamic pressure
47  params.addParam<bool>("solving_for_dynamic_pressure",
48  false,
49  "Whether to solve for the dynamic pressure instead of the total pressure");
50  params.addParam<Point>("reference_pressure_point",
51  Point(0, 0, 0),
52  "Point at which the gravity term for the static pressure is zero");
53  params.addParam<Real>("reference_pressure", 1e5, "Total pressure at the reference point");
54  params.addParam<Point>("gravity", Point(0, 0, -9.81), "Gravity vector");
55 
56  params.addParamNamesToGroup(
57  "solving_for_dynamic_pressure reference_pressure_point reference_pressure",
58  "Dynamic pressure");
59 
60  // Property names
61  params.addParam<MooseFunctorName>(
62  "density_name", NS::density, "Name to give to the density functor");
63  params.addParam<MooseFunctorName>(
64  "dynamic_viscosity_name", NS::mu, "Name to give to the dynamic viscosity functor");
65  params.addParam<MooseFunctorName>(
66  "specific_heat_name", NS::cp, "Name to give to the specific heat (cp) functor");
67  params.addParam<MooseFunctorName>(
68  "thermal_conductivity_name", NS::k, "Name to give to the thermal conductivity functor");
69  params.addParamNamesToGroup(
70  "density_name dynamic_viscosity_name specific_heat_name thermal_conductivity_name",
71  "Functor property names");
72  return params;
73 }
74 
75 template <bool is_ad>
77  const InputParameters & parameters)
78  : FunctorMaterial(parameters),
79  _fluid(UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid)),
80  _eps(getFunctor<GenericReal<is_ad>>(NS::porosity)),
81  _d(getFunctor<Real>("characteristic_length")),
82 
83  _pressure_is_dynamic(getParam<bool>("solving_for_dynamic_pressure")),
84  _reference_pressure_point(getParam<Point>("reference_pressure_point")),
85  _reference_pressure_value(getParam<Real>("reference_pressure")),
86  _gravity_vec(getParam<Point>("gravity")),
87 
88  _pressure(getFunctor<GenericReal<is_ad>>(NS::pressure)),
89  _T_fluid(getFunctor<GenericReal<is_ad>>(NS::T_fluid)),
90  _speed(getFunctor<GenericReal<is_ad>>(NS::speed)),
91  _force_define_density(getParam<bool>("force_define_density")),
92  _rho(getFunctor<GenericReal<is_ad>>(NS::density)),
93  _mu_rampdown(getFunction("mu_rampdown")),
94  _neglect_derivatives_of_density_time_derivative(
95  getParam<bool>("neglect_derivatives_of_density_time_derivative")),
96 
97  _density_name(getParam<MooseFunctorName>("density_name")),
98  _dynamic_viscosity_name(getParam<MooseFunctorName>("dynamic_viscosity_name")),
99  _specific_heat_name(getParam<MooseFunctorName>("specific_heat_name")),
100  _thermal_conductivity_name(getParam<MooseFunctorName>("thermal_conductivity_name"))
101 {
102  // Check parameters
103  if (!_pressure_is_dynamic &&
104  (isParamSetByUser("reference_pressure_point") || isParamSetByUser("reference_pressure")))
105  paramError("solving_for_dynamic_pressure",
106  "'reference_pressure_point' and 'reference_pressure' should not be set unless "
107  "solving for the dynamic pressure");
108 
109  //
110  // Set material properties functors
111  //
112 
113  // If pressure is dynamic (else case), we must obtain the total pressure
114  // We duplicate all this code. An alternative would be to redefine the pressure functor.
115  // The issue with that is that you need the density functor to define the pressure,
116  // and the pressure functor to define the density.
117  // This could be solved by keeping a pointer to the pressure functor as an attribute and set
118  // the pressure functor after the density functor has been defined.
120  {
122  addFunctorProperty<GenericReal<is_ad>>(
124  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
125  { return _fluid.rho_from_p_T(_pressure(r, t), _T_fluid(r, t)); });
126 
127  addFunctorProperty<GenericReal<is_ad>>(
128  NS::cv,
129  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
130  { return _fluid.cv_from_p_T(_pressure(r, t), _T_fluid(r, t)); });
131 
132  const auto & cp = addFunctorProperty<GenericReal<is_ad>>(
134  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
135  { return _fluid.cp_from_p_T(_pressure(r, t), _T_fluid(r, t)); });
136 
137  const auto & mu = addFunctorProperty<GenericReal<is_ad>>(
139  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
140  { return _mu_rampdown(r, t) * _fluid.mu_from_p_T(_pressure(r, t), _T_fluid(r, t)); });
141 
142  const auto & k = addFunctorProperty<GenericReal<is_ad>>(
144  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
145  { return _fluid.k_from_p_T(_pressure(r, t), _T_fluid(r, t)); });
146 
147  //
148  // Time derivatives of fluid properties
149  //
151  {
152  addFunctorProperty<GenericReal<is_ad>>(
154  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
155  {
156  Real rho, drho_dp, drho_dT;
157  _fluid.rho_from_p_T(MetaPhysicL::raw_value(_pressure(r, t)),
159  rho,
160  drho_dp,
161  drho_dT);
162  return drho_dp * _pressure.dot(r, t) + drho_dT * _T_fluid.dot(r, t);
163  });
164  }
165  else
166  {
167  addFunctorProperty<GenericReal<is_ad>>(
169  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
170  {
171  GenericReal<is_ad> rho, drho_dp, drho_dT;
172  _fluid.rho_from_p_T(_pressure(r, t), _T_fluid(r, t), rho, drho_dp, drho_dT);
173  return drho_dp * _pressure.dot(r, t) + drho_dT * _T_fluid.dot(r, t);
174  });
175  }
176 
177  addFunctorProperty<GenericReal<is_ad>>(
179  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
180  {
181  Real dcp_dp, dcp_dT, dummy;
182  const auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
183  const auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
184  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
185 
186  return dcp_dp * _pressure.dot(r, t) + dcp_dT * _T_fluid.dot(r, t);
187  });
188 
189  //
190  // Temperature and pressure derivatives, to help with computing time derivatives
191  //
192 
193  const auto & drho_dp = addFunctorProperty<Real>(
195  [this](const auto & r, const auto & t) -> Real
196  {
197  Real drho_dp, drho_dT, dummy;
198  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
199  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
200 
201  _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, drho_dp, drho_dT);
202  return drho_dp;
203  });
204 
205  const auto & drho_dT = addFunctorProperty<Real>(
207  [this](const auto & r, const auto & t) -> Real
208  {
209  Real drho_dp, drho_dT, dummy;
210  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
211  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
212 
213  _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, drho_dp, drho_dT);
214  return drho_dT;
215  });
216 
217  const auto & dcp_dp = addFunctorProperty<Real>(
219  [this](const auto & r, const auto & t) -> Real
220  {
221  Real dcp_dp, dcp_dT, dummy;
222  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
223  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
224 
225  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
226  return dcp_dp;
227  });
228 
229  const auto & dcp_dT = addFunctorProperty<Real>(
231  [this](const auto & r, const auto & t) -> Real
232  {
233  Real dcp_dp, dcp_dT, dummy;
234  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
235  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
236 
237  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
238  return dcp_dT;
239  });
240 
241  const auto & dmu_dp = addFunctorProperty<Real>(
243  [this](const auto & r, const auto & t) -> Real
244  {
245  Real dmu_dp, dmu_dT, dummy;
246  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
247  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
248 
249  _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, dmu_dp, dmu_dT);
250  return _mu_rampdown(r, t) * dmu_dp;
251  });
252 
253  const auto & dmu_dT = addFunctorProperty<Real>(
255  [this](const auto & r, const auto & t) -> Real
256  {
257  Real dmu_dp, dmu_dT, dummy;
258  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
259  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
260 
261  _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, dmu_dp, dmu_dT);
262  return _mu_rampdown(r, t) * dmu_dT;
263  });
264 
265  const auto & dk_dp = addFunctorProperty<Real>(
267  [this](const auto & r, const auto & t) -> Real
268  {
269  Real dk_dp, dk_dT, dummy;
270  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
271  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
272 
273  _fluid.k_from_p_T(raw_pressure, raw_T_fluid, dummy, dk_dp, dk_dT);
274  return dk_dp;
275  });
276 
277  const auto & dk_dT = addFunctorProperty<Real>(
279  [this](const auto & r, const auto & t) -> Real
280  {
281  Real dk_dp, dk_dT, dummy;
282  auto raw_pressure = MetaPhysicL::raw_value(_pressure(r, t));
283  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
284 
285  _fluid.k_from_p_T(raw_pressure, raw_T_fluid, dummy, dk_dp, dk_dT);
286  return dk_dT;
287  });
288 
289  //
290  // Fluid adimensional quantities, used in numerous correlations
291  //
292 
293  addFunctorProperty<GenericReal<is_ad>>(
294  NS::Prandtl,
295  [&cp, &mu, &k](const auto & r, const auto & t) -> GenericReal<is_ad>
296  {
297  static constexpr Real small_number = 1e-8;
298 
299  return HeatTransferUtils::prandtl(cp(r, t), mu(r, t), std::max(k(r, t), small_number));
300  });
301 
302  addFunctorProperty<Real>(
304  [&mu, &cp, &k, &dmu_dp, &dcp_dp, &dk_dp](const auto & r, const auto & t) -> Real
305  {
307  MetaPhysicL::raw_value(cp(r, t)),
308  MetaPhysicL::raw_value(k(r, t)),
309  dmu_dp(r, t),
310  dcp_dp(r, t),
311  dk_dp(r, t));
312  });
313 
314  addFunctorProperty<Real>(
316  [&mu, &cp, &k, &dmu_dT, &dcp_dT, &dk_dT](const auto & r, const auto & t) -> Real
317  {
319  MetaPhysicL::raw_value(cp(r, t)),
320  MetaPhysicL::raw_value(k(r, t)),
321  dmu_dT(r, t),
322  dcp_dT(r, t),
323  dk_dT(r, t));
324  });
325 
326  //
327  // (pore / particle) Reynolds number based on superficial velocity and
328  // characteristic length. Only call Reynolds() one time to compute all three so that
329  // we don't redundantly check that viscosity is not too close to zero.
330  //
331 
332  const auto & Re = addFunctorProperty<GenericReal<is_ad>>(
333  NS::Reynolds,
334  [this, &mu](const auto & r, const auto & t) -> GenericReal<is_ad>
335  {
336  static constexpr Real small_number = 1e-8;
337  return std::max(HeatTransferUtils::reynolds(_rho(r, t),
338  _eps(r, t) * _speed(r, t),
339  _d(r, t),
340  std::max(mu(r, t), small_number)),
341  small_number);
342  });
343 
344  addFunctorProperty<Real>(
346  [this, &Re, &mu, &drho_dp, &dmu_dp](const auto & r, const auto & t) -> Real
347  {
350  MetaPhysicL::raw_value(mu(r, t)),
351  drho_dp(r, t),
352  dmu_dp(r, t));
353  });
354 
355  addFunctorProperty<Real>(
357  [this, &Re, &mu, &drho_dT, &dmu_dT](const auto & r, const auto & t) -> Real
358  {
361  MetaPhysicL::raw_value(mu(r, t)),
362  drho_dT(r, t),
363  dmu_dT(r, t));
364  });
365 
366  // (hydraulic) Reynolds number
367  addFunctorProperty<GenericReal<is_ad>>(
369  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
370  {
371  static constexpr Real small_number = 1e-8;
372  return Re(r, t) / std::max(1 - _eps(r, t), small_number);
373  });
374 
375  // (interstitial) Reynolds number
376  addFunctorProperty<GenericReal<is_ad>>(
378  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
379  { return Re(r, t) / _eps(r, t); });
380  }
381  else
382  {
383 
384  const auto & rho =
388  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
389  {
391  // TODO: we should be integrating this term
392  const auto rho_approx = _fluid.rho_from_p_T(total_pressure, _T_fluid(r, t));
393  total_pressure +=
394  rho_approx * _gravity_vec * (r.getPoint() - _reference_pressure_point);
395  return _fluid.rho_from_p_T(total_pressure, _T_fluid(r, t));
396  })
398 
399  addFunctorProperty<GenericReal<is_ad>>(
400  NS::cv,
401  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
402  {
403  const auto total_pressure =
405  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
406  return _fluid.cv_from_p_T(total_pressure, _T_fluid(r, t));
407  });
408 
409  const auto & cp = addFunctorProperty<GenericReal<is_ad>>(
411  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
412  {
413  const auto total_pressure =
415  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
416  return _fluid.cp_from_p_T(total_pressure, _T_fluid(r, t));
417  });
418 
419  const auto & mu = addFunctorProperty<GenericReal<is_ad>>(
421  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
422  {
423  const auto total_pressure =
425  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
426  return _mu_rampdown(r, t) * _fluid.mu_from_p_T(total_pressure, _T_fluid(r, t));
427  });
428 
429  const auto & k = addFunctorProperty<GenericReal<is_ad>>(
431  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
432  {
433  const auto total_pressure =
435  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
436  return _fluid.k_from_p_T(total_pressure, _T_fluid(r, t));
437  });
438 
439  //
440  // Time derivatives of fluid properties
441  //
443  {
444  addFunctorProperty<GenericReal<is_ad>>(
446  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
447  {
448  const auto total_pressure =
450  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
451  Real rho, drho_dp, drho_dT;
454  rho,
455  drho_dp,
456  drho_dT);
457  return drho_dp * _pressure.dot(r, t) + drho_dT * _T_fluid.dot(r, t);
458  });
459  }
460  else
461  {
462  addFunctorProperty<GenericReal<is_ad>>(
464  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
465  {
466  const auto total_pressure =
468  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
469  GenericReal<is_ad> rho, drho_dp, drho_dT;
470  _fluid.rho_from_p_T(total_pressure, _T_fluid(r, t), rho, drho_dp, drho_dT);
471  return drho_dp * _pressure.dot(r, t) + drho_dT * _T_fluid.dot(r, t);
472  });
473  }
474 
475  addFunctorProperty<GenericReal<is_ad>>(
477  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
478  {
479  const auto total_pressure =
481  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
482  Real dcp_dp, dcp_dT, dummy;
483  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
484  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
485  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
486 
487  return dcp_dp * _pressure.dot(r, t) + dcp_dT * _T_fluid.dot(r, t);
488  });
489 
490  //
491  // Temperature and pressure derivatives, to help with computing time derivatives
492  //
493 
494  const auto & drho_dp = addFunctorProperty<Real>(
496  [this, &rho](const auto & r, const auto & t) -> Real
497  {
498  const auto total_pressure =
500  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
501  Real drho_dp, drho_dT, dummy;
502  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
503  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
504 
505  _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, drho_dp, drho_dT);
506  return drho_dp;
507  });
508 
509  const auto & drho_dT = addFunctorProperty<Real>(
511  [this, &rho](const auto & r, const auto & t) -> Real
512  {
513  const auto total_pressure =
515  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
516  Real drho_dp, drho_dT, dummy;
517  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
518  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
519 
520  _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, drho_dp, drho_dT);
521  return drho_dT;
522  });
523 
524  const auto & dcp_dp = addFunctorProperty<Real>(
526  [this, &rho](const auto & r, const auto & t) -> Real
527  {
528  const auto total_pressure =
530  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
531  Real dcp_dp, dcp_dT, dummy;
532  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
533  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
534 
535  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
536  return dcp_dp;
537  });
538 
539  const auto & dcp_dT = addFunctorProperty<Real>(
541  [this, &rho](const auto & r, const auto & t) -> Real
542  {
543  const auto total_pressure =
545  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
546  Real dcp_dp, dcp_dT, dummy;
547  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
548  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
549 
550  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
551  return dcp_dT;
552  });
553 
554  const auto & dmu_dp = addFunctorProperty<Real>(
556  [this, &rho](const auto & r, const auto & t) -> Real
557  {
558  const auto total_pressure =
560  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
561  Real dmu_dp, dmu_dT, dummy;
562  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
563  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
564 
565  _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, dmu_dp, dmu_dT);
566  return _mu_rampdown(r, t) * dmu_dp;
567  });
568 
569  const auto & dmu_dT = addFunctorProperty<Real>(
571  [this, &rho](const auto & r, const auto & t) -> Real
572  {
573  const auto total_pressure =
575  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
576  Real dmu_dp, dmu_dT, dummy;
577  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
578  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
579 
580  _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, dmu_dp, dmu_dT);
581  return _mu_rampdown(r, t) * dmu_dT;
582  });
583 
584  const auto & dk_dp = addFunctorProperty<Real>(
586  [this, &rho](const auto & r, const auto & t) -> Real
587  {
588  const auto total_pressure =
590  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
591  Real dk_dp, dk_dT, dummy;
592  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
593  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
594 
595  _fluid.k_from_p_T(raw_pressure, raw_T_fluid, dummy, dk_dp, dk_dT);
596  return dk_dp;
597  });
598 
599  const auto & dk_dT = addFunctorProperty<Real>(
601  [this, &rho](const auto & r, const auto & t) -> Real
602  {
603  const auto total_pressure =
605  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
606  Real dk_dp, dk_dT, dummy;
607  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
608  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
609 
610  _fluid.k_from_p_T(raw_pressure, raw_T_fluid, dummy, dk_dp, dk_dT);
611  return dk_dT;
612  });
613 
614  //
615  // Fluid adimensional quantities, used in numerous correlations
616  //
617 
618  addFunctorProperty<GenericReal<is_ad>>(
619  NS::Prandtl,
620  [&cp, &mu, &k](const auto & r, const auto & t) -> GenericReal<is_ad>
621  {
622  static constexpr Real small_number = 1e-8;
623 
624  return HeatTransferUtils::prandtl(cp(r, t), mu(r, t), std::max(k(r, t), small_number));
625  });
626 
627  addFunctorProperty<Real>(
629  [&mu, &cp, &k, &dmu_dp, &dcp_dp, &dk_dp](const auto & r, const auto & t) -> Real
630  {
632  MetaPhysicL::raw_value(cp(r, t)),
633  MetaPhysicL::raw_value(k(r, t)),
634  dmu_dp(r, t),
635  dcp_dp(r, t),
636  dk_dp(r, t));
637  });
638 
639  addFunctorProperty<Real>(
641  [&mu, &cp, &k, &dmu_dT, &dcp_dT, &dk_dT](const auto & r, const auto & t) -> Real
642  {
644  MetaPhysicL::raw_value(cp(r, t)),
645  MetaPhysicL::raw_value(k(r, t)),
646  dmu_dT(r, t),
647  dcp_dT(r, t),
648  dk_dT(r, t));
649  });
650 
651  //
652  // (pore / particle) Reynolds number based on superficial velocity and
653  // characteristic length. Only call Reynolds() one time to compute all three so that
654  // we don't redundantly check that viscosity is not too close to zero.
655  //
656 
657  const auto & Re = addFunctorProperty<GenericReal<is_ad>>(
658  NS::Reynolds,
659  [this, &mu](const auto & r, const auto & t) -> GenericReal<is_ad>
660  {
661  static constexpr Real small_number = 1e-8;
662  return std::max(HeatTransferUtils::reynolds(_rho(r, t),
663  _eps(r, t) * _speed(r, t),
664  _d(r, t),
665  std::max(mu(r, t), small_number)),
666  small_number);
667  });
668 
669  addFunctorProperty<Real>(
671  [this, &Re, &mu, &drho_dp, &dmu_dp](const auto & r, const auto & t) -> Real
672  {
675  MetaPhysicL::raw_value(mu(r, t)),
676  drho_dp(r, t),
677  dmu_dp(r, t));
678  });
679 
680  addFunctorProperty<Real>(
682  [this, &Re, &mu, &drho_dT, &dmu_dT](const auto & r, const auto & t) -> Real
683  {
686  MetaPhysicL::raw_value(mu(r, t)),
687  drho_dT(r, t),
688  dmu_dT(r, t));
689  });
690 
691  // (hydraulic) Reynolds number
692  addFunctorProperty<GenericReal<is_ad>>(
694  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
695  {
696  static constexpr Real small_number = 1e-8;
697  return Re(r, t) / std::max(1 - _eps(r, t), small_number);
698  });
699 
700  // (interstitial) Reynolds number
701  addFunctorProperty<GenericReal<is_ad>>(
703  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
704  { return Re(r, t) / _eps(r, t); });
705  }
706 }
707 
Moose::GenericType< Real, is_ad > GenericReal
static const std::string cv
Definition: NS.h:122
const Real _reference_pressure_value
The value of pressure at that point.
static InputParameters validParams()
const Moose::Functor< GenericReal< is_ad > > & _rho
Density as a functor, which could be from the variable set or the property.
static const std::string speed
Definition: NS.h:143
static InputParameters validParams()
static const std::string Reynolds
Definition: NS.h:139
Real prandtlPropertyDerivative(const Real &mu, const Real &cp, const Real &k, const Real &dmu, const Real &dcp, const Real &dk)
Computes the derivative of the Prandtl number, $Pr{ C_p}{k}$, with respect to an arbitrary variale $$...
const bool _neglect_derivatives_of_density_time_derivative
Whether to neglect the contributions to the Jacobian of the density time derivative.
const Moose::Functor< Real > & _d
Characteristic length $d$ used in computing the Reynolds number $Re=/$.
static const std::string density
Definition: NS.h:33
auto raw_value(const Eigen::Map< T > &in)
static const std::string fluid
Definition: NS.h:87
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
const Moose::Functor< GenericReal< is_ad > > & _pressure
variables
static const std::string total_pressure
Definition: NS.h:58
const bool _force_define_density
A parameter to force definition of a functor material property for density.
const SinglePhaseFluidProperties & _fluid
Computes fluid properties in (P, T) formulation using functor material properties.
bool isParamValid(const std::string &name) const
static const std::string porosity
Definition: NS.h:104
static const std::string Prandtl
Definition: NS.h:137
static const std::string cp
Definition: NS.h:121
const MooseFunctorName & _specific_heat_name
Name to use for the specific heat functor.
static const std::string T_fluid
Definition: NS.h:106
const Point _reference_pressure_point
Where the static pressure rho*g*(z-z0) term is 0.
const bool _pressure_is_dynamic
Whether the input pressure is the dynamic pressure.
static const std::string mu
Definition: NS.h:123
GeneralFunctorFluidPropsTempl(const InputParameters &parameters)
static const std::string Reynolds_hydraulic
Definition: NS.h:140
Common class for single phase fluid properties.
Real reynoldsPropertyDerivative(const Real &Re, const Real &rho, const Real &mu, const Real &drho, const Real &dmu)
Computes the derivative of the Reynolds number, $Re { Vd}{}$, with respect to an arbitrary variable $...
void paramError(const std::string &param, Args... args) const
auto reynolds(const T1 &rho, const T2 &vel, const T3 &L, const T4 &mu)
Compute Reynolds number.
const MooseFunctorName & _thermal_conductivity_name
Name to use for the thermal conductivity functor.
auto prandtl(const T1 &cp, const T2 &mu, const T3 &k)
Compute Prandtl number.
const Function & _mu_rampdown
Function to ramp down the viscosity, useful for relaxation transient.
const Moose::Functor< GenericReal< is_ad > > & _speed
bool isParamSetByUser(const std::string &nm) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Moose::Functor< T > & getFunctor(const std::string &name)
const MooseFunctorName & _density_name
Name to use for density functor.
const Moose::FunctorBase< T > & addFunctorProperty(const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule={EXEC_ALWAYS})
registerMooseObject("NavierStokesApp", GeneralFunctorFluidProps)
static const std::string pressure
Definition: NS.h:56
const Moose::Functor< GenericReal< is_ad > > & _T_fluid
const MooseFunctorName & _dynamic_viscosity_name
Name to use for the dynamic viscosity functor.
static const std::string k
Definition: NS.h:130
static const std::string Reynolds_interstitial
Definition: NS.h:141
const Point _gravity_vec
The gravity vector.
std::string time_deriv(const std::string &var)
Definition: NS.h:97
const Moose::Functor< GenericReal< is_ad > > & _eps
Porosity.