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 object");
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  using std::max;
300  return HeatTransferUtils::prandtl(cp(r, t), mu(r, t), max(k(r, t), small_number));
301  });
302 
303  addFunctorProperty<Real>(
305  [&mu, &cp, &k, &dmu_dp, &dcp_dp, &dk_dp](const auto & r, const auto & t) -> Real
306  {
308  MetaPhysicL::raw_value(cp(r, t)),
309  MetaPhysicL::raw_value(k(r, t)),
310  dmu_dp(r, t),
311  dcp_dp(r, t),
312  dk_dp(r, t));
313  });
314 
315  addFunctorProperty<Real>(
317  [&mu, &cp, &k, &dmu_dT, &dcp_dT, &dk_dT](const auto & r, const auto & t) -> Real
318  {
320  MetaPhysicL::raw_value(cp(r, t)),
321  MetaPhysicL::raw_value(k(r, t)),
322  dmu_dT(r, t),
323  dcp_dT(r, t),
324  dk_dT(r, t));
325  });
326 
327  //
328  // (pore / particle) Reynolds number based on superficial velocity and
329  // characteristic length. Only call Reynolds() one time to compute all three so that
330  // we don't redundantly check that viscosity is not too close to zero.
331  //
332 
333  const auto & Re = addFunctorProperty<GenericReal<is_ad>>(
334  NS::Reynolds,
335  [this, &mu](const auto & r, const auto & t) -> GenericReal<is_ad>
336  {
337  static constexpr Real small_number = 1e-8;
338  using std::max;
339  return max(
341  _rho(r, t), _eps(r, t) * _speed(r, t), _d(r, t), max(mu(r, t), small_number)),
342  small_number);
343  });
344 
345  addFunctorProperty<Real>(
347  [this, &Re, &mu, &drho_dp, &dmu_dp](const auto & r, const auto & t) -> Real
348  {
351  MetaPhysicL::raw_value(mu(r, t)),
352  drho_dp(r, t),
353  dmu_dp(r, t));
354  });
355 
356  addFunctorProperty<Real>(
358  [this, &Re, &mu, &drho_dT, &dmu_dT](const auto & r, const auto & t) -> Real
359  {
362  MetaPhysicL::raw_value(mu(r, t)),
363  drho_dT(r, t),
364  dmu_dT(r, t));
365  });
366 
367  // (hydraulic) Reynolds number
368  addFunctorProperty<GenericReal<is_ad>>(
370  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
371  {
372  static constexpr Real small_number = 1e-8;
373  using std::max;
374  return Re(r, t) / max(1 - _eps(r, t), small_number);
375  });
376 
377  // (interstitial) Reynolds number
378  addFunctorProperty<GenericReal<is_ad>>(
380  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
381  { return Re(r, t) / _eps(r, t); });
382  }
383  else
384  {
385 
386  const auto & rho =
390  [this](const auto & r, const auto & t) -> GenericReal<is_ad>
391  {
393  // TODO: we should be integrating this term
394  const auto rho_approx = _fluid.rho_from_p_T(total_pressure, _T_fluid(r, t));
395  total_pressure +=
396  rho_approx * _gravity_vec * (r.getPoint() - _reference_pressure_point);
397  return _fluid.rho_from_p_T(total_pressure, _T_fluid(r, t));
398  })
400 
401  addFunctorProperty<GenericReal<is_ad>>(
402  NS::cv,
403  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
404  {
405  const auto total_pressure =
407  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
408  return _fluid.cv_from_p_T(total_pressure, _T_fluid(r, t));
409  });
410 
411  const auto & cp = addFunctorProperty<GenericReal<is_ad>>(
413  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
414  {
415  const auto total_pressure =
417  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
418  return _fluid.cp_from_p_T(total_pressure, _T_fluid(r, t));
419  });
420 
421  const auto & mu = addFunctorProperty<GenericReal<is_ad>>(
423  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
424  {
425  const auto total_pressure =
427  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
428  return _mu_rampdown(r, t) * _fluid.mu_from_p_T(total_pressure, _T_fluid(r, t));
429  });
430 
431  const auto & k = addFunctorProperty<GenericReal<is_ad>>(
433  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
434  {
435  const auto total_pressure =
437  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
438  return _fluid.k_from_p_T(total_pressure, _T_fluid(r, t));
439  });
440 
441  //
442  // Time derivatives of fluid properties
443  //
445  {
446  addFunctorProperty<GenericReal<is_ad>>(
448  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
449  {
450  const auto total_pressure =
452  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
453  Real rho, drho_dp, drho_dT;
456  rho,
457  drho_dp,
458  drho_dT);
459  return drho_dp * _pressure.dot(r, t) + drho_dT * _T_fluid.dot(r, t);
460  });
461  }
462  else
463  {
464  addFunctorProperty<GenericReal<is_ad>>(
466  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
467  {
468  const auto total_pressure =
470  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
471  GenericReal<is_ad> rho, drho_dp, drho_dT;
472  _fluid.rho_from_p_T(total_pressure, _T_fluid(r, t), rho, drho_dp, drho_dT);
473  return drho_dp * _pressure.dot(r, t) + drho_dT * _T_fluid.dot(r, t);
474  });
475  }
476 
477  addFunctorProperty<GenericReal<is_ad>>(
479  [this, &rho](const auto & r, const auto & t) -> GenericReal<is_ad>
480  {
481  const auto total_pressure =
483  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
484  Real dcp_dp, dcp_dT, dummy;
485  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
486  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
487  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
488 
489  return dcp_dp * _pressure.dot(r, t) + dcp_dT * _T_fluid.dot(r, t);
490  });
491 
492  //
493  // Temperature and pressure derivatives, to help with computing time derivatives
494  //
495 
496  const auto & drho_dp = addFunctorProperty<Real>(
498  [this, &rho](const auto & r, const auto & t) -> Real
499  {
500  const auto total_pressure =
502  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
503  Real drho_dp, drho_dT, dummy;
504  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
505  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
506 
507  _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, drho_dp, drho_dT);
508  return drho_dp;
509  });
510 
511  const auto & drho_dT = addFunctorProperty<Real>(
513  [this, &rho](const auto & r, const auto & t) -> Real
514  {
515  const auto total_pressure =
517  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
518  Real drho_dp, drho_dT, dummy;
519  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
520  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
521 
522  _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, drho_dp, drho_dT);
523  return drho_dT;
524  });
525 
526  const auto & dcp_dp = addFunctorProperty<Real>(
528  [this, &rho](const auto & r, const auto & t) -> Real
529  {
530  const auto total_pressure =
532  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
533  Real dcp_dp, dcp_dT, dummy;
534  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
535  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
536 
537  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
538  return dcp_dp;
539  });
540 
541  const auto & dcp_dT = addFunctorProperty<Real>(
543  [this, &rho](const auto & r, const auto & t) -> Real
544  {
545  const auto total_pressure =
547  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
548  Real dcp_dp, dcp_dT, dummy;
549  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
550  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
551 
552  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, dcp_dp, dcp_dT);
553  return dcp_dT;
554  });
555 
556  const auto & dmu_dp = addFunctorProperty<Real>(
558  [this, &rho](const auto & r, const auto & t) -> Real
559  {
560  const auto total_pressure =
562  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
563  Real dmu_dp, dmu_dT, dummy;
564  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
565  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
566 
567  _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, dmu_dp, dmu_dT);
568  return _mu_rampdown(r, t) * dmu_dp;
569  });
570 
571  const auto & dmu_dT = addFunctorProperty<Real>(
573  [this, &rho](const auto & r, const auto & t) -> Real
574  {
575  const auto total_pressure =
577  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
578  Real dmu_dp, dmu_dT, dummy;
579  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
580  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
581 
582  _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, dmu_dp, dmu_dT);
583  return _mu_rampdown(r, t) * dmu_dT;
584  });
585 
586  const auto & dk_dp = addFunctorProperty<Real>(
588  [this, &rho](const auto & r, const auto & t) -> Real
589  {
590  const auto total_pressure =
592  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
593  Real dk_dp, dk_dT, dummy;
594  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
595  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
596 
597  _fluid.k_from_p_T(raw_pressure, raw_T_fluid, dummy, dk_dp, dk_dT);
598  return dk_dp;
599  });
600 
601  const auto & dk_dT = addFunctorProperty<Real>(
603  [this, &rho](const auto & r, const auto & t) -> Real
604  {
605  const auto total_pressure =
607  rho(r, t) * _gravity_vec * (r.getPoint() - _reference_pressure_point);
608  Real dk_dp, dk_dT, dummy;
609  auto raw_pressure = MetaPhysicL::raw_value(total_pressure);
610  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid(r, t));
611 
612  _fluid.k_from_p_T(raw_pressure, raw_T_fluid, dummy, dk_dp, dk_dT);
613  return dk_dT;
614  });
615 
616  //
617  // Fluid adimensional quantities, used in numerous correlations
618  //
619 
620  addFunctorProperty<GenericReal<is_ad>>(
621  NS::Prandtl,
622  [&cp, &mu, &k](const auto & r, const auto & t) -> GenericReal<is_ad>
623  {
624  static constexpr Real small_number = 1e-8;
625  using std::max;
626 
627  return HeatTransferUtils::prandtl(cp(r, t), mu(r, t), max(k(r, t), small_number));
628  });
629 
630  addFunctorProperty<Real>(
632  [&mu, &cp, &k, &dmu_dp, &dcp_dp, &dk_dp](const auto & r, const auto & t) -> Real
633  {
635  MetaPhysicL::raw_value(cp(r, t)),
636  MetaPhysicL::raw_value(k(r, t)),
637  dmu_dp(r, t),
638  dcp_dp(r, t),
639  dk_dp(r, t));
640  });
641 
642  addFunctorProperty<Real>(
644  [&mu, &cp, &k, &dmu_dT, &dcp_dT, &dk_dT](const auto & r, const auto & t) -> Real
645  {
647  MetaPhysicL::raw_value(cp(r, t)),
648  MetaPhysicL::raw_value(k(r, t)),
649  dmu_dT(r, t),
650  dcp_dT(r, t),
651  dk_dT(r, t));
652  });
653 
654  //
655  // (pore / particle) Reynolds number based on superficial velocity and
656  // characteristic length. Only call Reynolds() one time to compute all three so that
657  // we don't redundantly check that viscosity is not too close to zero.
658  //
659 
660  const auto & Re = addFunctorProperty<GenericReal<is_ad>>(
661  NS::Reynolds,
662  [this, &mu](const auto & r, const auto & t) -> GenericReal<is_ad>
663  {
664  static constexpr Real small_number = 1e-8;
665  using std::max;
666 
667  return max(
669  _rho(r, t), _eps(r, t) * _speed(r, t), _d(r, t), max(mu(r, t), small_number)),
670  small_number);
671  });
672 
673  addFunctorProperty<Real>(
675  [this, &Re, &mu, &drho_dp, &dmu_dp](const auto & r, const auto & t) -> Real
676  {
679  MetaPhysicL::raw_value(mu(r, t)),
680  drho_dp(r, t),
681  dmu_dp(r, t));
682  });
683 
684  addFunctorProperty<Real>(
686  [this, &Re, &mu, &drho_dT, &dmu_dT](const auto & r, const auto & t) -> Real
687  {
690  MetaPhysicL::raw_value(mu(r, t)),
691  drho_dT(r, t),
692  dmu_dT(r, t));
693  });
694 
695  // (hydraulic) Reynolds number
696  addFunctorProperty<GenericReal<is_ad>>(
698  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
699  {
700  static constexpr Real small_number = 1e-8;
701  using std::max;
702  return Re(r, t) / max(1 - _eps(r, t), small_number);
703  });
704 
705  // (interstitial) Reynolds number
706  addFunctorProperty<GenericReal<is_ad>>(
708  [this, &Re](const auto & r, const auto & t) -> GenericReal<is_ad>
709  { return Re(r, t) / _eps(r, t); });
710  }
711 }
712 
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.
void paramError(const std::string &param, Args... args) const
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.
auto max(const L &left, const R &right)
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 $...
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
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
bool isParamValid(const std::string &name) const
const MooseFunctorName & _dynamic_viscosity_name
Name to use for the dynamic viscosity functor.
bool isParamSetByUser(const std::string &name) const
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.