www.mooseframework.org
SinglePhaseFluidProperties.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
10 #pragma once
11 
12 #include "FluidProperties.h"
13 
15 
16 template <>
18 
24 #define propfuncAD(want, prop1, prop2) \
25  virtual DualReal want##_from_##prop1##_##prop2(const DualReal & p1, const DualReal & p2) const \
26  { \
27  Real x = 0; \
28  Real raw1 = p1.value(); \
29  Real raw2 = p2.value(); \
30  Real dxd1 = 0; \
31  Real dxd2 = 0; \
32  want##_from_##prop1##_##prop2(raw1, raw2, x, dxd1, dxd2); \
33  \
34  DualReal result = x; \
35  result.derivatives() = p1.derivatives() * dxd1 + p2.derivatives() * dxd2; \
36  return result; \
37  } \
38  \
39  virtual void want##_from_##prop1##_##prop2(const DualReal & prop1, \
40  const DualReal & prop2, \
41  DualReal & val, \
42  DualReal & d##want##d1, \
43  DualReal & d##want##d2) const \
44  { \
45  fluidPropError(name(), ": ", __PRETTY_FUNCTION__, " derivative derivatives not implemented."); \
46  Real dummy, tmp1, tmp2; \
47  val = want##_from_##prop1##_##prop2(prop1, prop2); \
48  want##_from_##prop1##_##prop2(prop1.value(), prop2.value(), dummy, tmp1, tmp2); \
49  d##want##d1 = tmp1; \
50  d##want##d2 = tmp2; \
51  }
52 
57 #define propfunc(want, prop1, prop2) \
58  virtual Real want##_from_##prop1##_##prop2(Real, Real) const \
59  { \
60  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented."); \
61  } \
62  \
63  virtual void want##_from_##prop1##_##prop2( \
64  Real prop1, Real prop2, Real & val, Real & d##want##d1, Real & d##want##d2) const \
65  { \
66  fluidPropError(name(), ": ", __PRETTY_FUNCTION__, " derivatives not implemented."); \
67  d##want##d1 = 0; \
68  d##want##d2 = 0; \
69  val = want##_from_##prop1##_##prop2(prop1, prop2); \
70  } \
71  \
72  propfuncAD(want, prop1, prop2)
73 
79 #define propfuncWithDefault(want, prop1, prop2) \
80  virtual Real want##_from_##prop1##_##prop2(Real, Real) const; \
81  virtual void want##_from_##prop1##_##prop2( \
82  Real prop1, Real prop2, Real & val, Real & d##want##d1, Real & d##want##d2) const; \
83  \
84  propfuncAD(want, prop1, prop2)
85 
90 {
91 public:
92  SinglePhaseFluidProperties(const InputParameters & parameters);
94 
95 #pragma GCC diagnostic push
96 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
97  // clang-format off
98 
153  propfunc(p, v, e)
155  propfunc(T, v, e)
156  propfunc(c, v, e)
157  propfunc(cp, v, e)
158  propfunc(cv, v, e)
159  propfunc(mu, v, e)
160  propfunc(k, v, e)
161  propfunc(s, v, e)
162  propfunc(s, h, p)
164  propfunc(rho, p, s)
165  propfunc(e, v, h)
166  propfunc(s, p, T)
167  propfunc(pp_sat, p, T)
168  propfunc(mu, rho, T)
170  propfunc(c, p, T)
171  propfunc(cp, p, T)
172  propfunc(cv, p, T)
173  propfunc(mu, p, T)
174  propfunc(k, p, T)
176  propfunc(e, p, rho)
177  propfunc(e, T, v)
178  propfunc(p, T, v)
180  propfunc(s, T, v)
181  propfunc(cv, T, v)
182  propfunc(h, p, T)
183  propfunc(p, h, s)
184  propfunc(g, v, e)
186  propfuncWithDefault(beta, p, T)
188  propfuncWithDefault(e, p, T)
192 
193  // clang-format on
194 
195 #undef propfunc
196 #undef propfuncWithDefault
197 #undef propfuncAD
198 
203  virtual std::string fluidName() const;
204 
209  virtual Real molarMass() const;
210 
215  virtual Real criticalPressure() const;
216 
221  virtual Real criticalTemperature() const;
222 
227  virtual Real criticalDensity() const;
228 
233  virtual Real criticalInternalEnergy() const;
234 
239  virtual Real triplePointPressure() const;
240 
245  virtual Real triplePointTemperature() const;
246 
253  virtual Real e_spndl_from_v(Real v) const;
254 
261  virtual void v_e_spndl_from_T(Real T, Real & v, Real & e) const;
262 
272  virtual Real vaporPressure(Real T) const;
273  virtual void vaporPressure(Real T, Real & psat, Real & dpsat_dT) const;
274  DualReal vaporPressure(const DualReal & T) const;
275 
285  virtual Real vaporTemperature(Real p) const;
286  virtual void vaporTemperature(Real p, Real & Tsat, Real & dTsat_dp) const;
287  DualReal vaporTemperature(const DualReal & p) const;
288 
293  virtual std::vector<Real> henryCoefficients() const;
294 
303  virtual void rho_mu_from_p_T(Real p, Real T, Real & rho, Real & mu) const;
304  virtual void rho_mu_from_p_T(Real p,
305  Real T,
306  Real & rho,
307  Real & drho_dp,
308  Real & drho_dT,
309  Real & mu,
310  Real & dmu_dp,
311  Real & dmu_dT) const;
312  virtual void
313  rho_mu_from_p_T(const DualReal & p, const DualReal & T, DualReal & rho, DualReal & mu) const;
314 
315  virtual void rho_e_from_p_T(Real p,
316  Real T,
317  Real & rho,
318  Real & drho_dp,
319  Real & drho_dT,
320  Real & e,
321  Real & de_dp,
322  Real & de_dT) const;
323 
324 private:
325  template <typename... Args>
326  void fluidPropError(Args... args) const
327  {
329  mooseDoOnce(mooseWarning(std::forward<Args>(args)...));
330  else
331  mooseError(std::forward<Args>(args)...);
332  }
333 };
334 
335 #pragma GCC diagnostic pop
SinglePhaseFluidProperties::rho_mu_from_p_T
virtual void rho_mu_from_p_T(Real p, Real T, Real &rho, Real &mu) const
Combined methods.
Definition: SinglePhaseFluidProperties.C:256
SinglePhaseFluidProperties::v_e_spndl_from_T
virtual void v_e_spndl_from_T(Real T, Real &v, Real &e) const
Specific internal energy from temperature and specific volume.
Definition: SinglePhaseFluidProperties.C:292
SinglePhaseFluidProperties::henryCoefficients
virtual std::vector< Real > henryCoefficients() const
Henry's law coefficients for dissolution in water.
Definition: SinglePhaseFluidProperties.C:183
SinglePhaseFluidProperties
Common class for single phase fluid properties.
Definition: SinglePhaseFluidProperties.h:89
SinglePhaseFluidProperties::criticalInternalEnergy
virtual Real criticalInternalEnergy() const
Critical specific internal energy.
Definition: SinglePhaseFluidProperties.C:126
SinglePhaseFluidProperties::v
v
Definition: SinglePhaseFluidProperties.h:155
SinglePhaseFluidProperties::rho_e_from_p_T
virtual void rho_e_from_p_T(Real p, Real T, Real &rho, Real &drho_dp, Real &drho_dT, Real &e, Real &de_dp, Real &de_dT) const
Definition: SinglePhaseFluidProperties.C:242
SinglePhaseFluidProperties::SinglePhaseFluidProperties
SinglePhaseFluidProperties(const InputParameters &parameters)
Definition: SinglePhaseFluidProperties.C:22
SinglePhaseFluidProperties::triplePointPressure
virtual Real triplePointPressure() const
Triple point pressure.
Definition: SinglePhaseFluidProperties.C:132
SinglePhaseFluidProperties::criticalPressure
virtual Real criticalPressure() const
Critical pressure.
Definition: SinglePhaseFluidProperties.C:108
FluidProperties.h
SinglePhaseFluidProperties::~SinglePhaseFluidProperties
virtual ~SinglePhaseFluidProperties()
Definition: SinglePhaseFluidProperties.C:27
SinglePhaseFluidProperties::triplePointTemperature
virtual Real triplePointTemperature() const
Triple point temperature.
Definition: SinglePhaseFluidProperties.C:138
SinglePhaseFluidProperties::propfuncWithDefault
e e e e p h T T T T T v v v s h T e propfuncWithDefault(gamma, p, T)
Definition: SinglePhaseFluidProperties.h:190
SinglePhaseFluidProperties::T
e e e e p h T T T T T T
Definition: SinglePhaseFluidProperties.h:177
SinglePhaseFluidProperties::criticalTemperature
virtual Real criticalTemperature() const
Critical temperature.
Definition: SinglePhaseFluidProperties.C:114
SinglePhaseFluidProperties::rho
e e e e p h T rho
Definition: SinglePhaseFluidProperties.h:169
SinglePhaseFluidProperties::vaporPressure
virtual Real vaporPressure(Real T) const
Vapor pressure.
Definition: SinglePhaseFluidProperties.C:177
SinglePhaseFluidProperties::vaporTemperature
virtual Real vaporTemperature(Real p) const
Vapor temperature.
Definition: SinglePhaseFluidProperties.C:212
SinglePhaseFluidProperties::e_spndl_from_v
virtual Real e_spndl_from_v(Real v) const
Specific internal energy from temperature and specific volume.
Definition: SinglePhaseFluidProperties.C:286
SinglePhaseFluidProperties::criticalDensity
virtual Real criticalDensity() const
Critical density.
Definition: SinglePhaseFluidProperties.C:120
SinglePhaseFluidProperties::molarMass
virtual virtual std Real molarMass() const
Fluid name.
Definition: SinglePhaseFluidProperties.C:96
SinglePhaseFluidProperties::fluidPropError
void fluidPropError(Args... args) const
Definition: SinglePhaseFluidProperties.h:326
FluidProperties::_allow_imperfect_jacobians
const bool _allow_imperfect_jacobians
Flag to set unimplemented Jacobian entries to zero.
Definition: FluidProperties.h:48
FluidProperties
Definition: FluidProperties.h:28
SinglePhaseFluidProperties::p
e e e e p h p
Definition: SinglePhaseFluidProperties.h:167
validParams< SinglePhaseFluidProperties >
InputParameters validParams< SinglePhaseFluidProperties >()
Definition: SinglePhaseFluidProperties.C:14
SinglePhaseFluidProperties::propfunc
propfunc(p, v, e) propfunc(T
Compute a fluid property given for the state defined by two given properties.
SinglePhaseFluidProperties::h
e e e e h
Definition: SinglePhaseFluidProperties.h:163