www.mooseframework.org
SinglePhaseFluidProperties.C
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 
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<FluidProperties>();
17  params.addCustomTypeParam<std::string>(
18  "fp_type", "single-phase-fp", "FPType", "Type of the fluid property object");
19  return params;
20 }
21 
22 SinglePhaseFluidProperties::SinglePhaseFluidProperties(const InputParameters & parameters)
23  : FluidProperties(parameters)
24 {
25 }
26 
28 
29 Real
30 SinglePhaseFluidProperties::e_from_p_T(Real p, Real T) const
31 {
32  const Real rho = rho_from_p_T(p, T);
33  return e_from_p_rho(p, rho);
34 }
35 
36 void
37 SinglePhaseFluidProperties::e_from_p_T(Real p, Real T, Real & e, Real & de_dp, Real & de_dT) const
38 {
39  // From rho(p,T), compute: drho(p,T)/dp, drho(p,T)/dT
40  Real rho = 0., drho_dp = 0., drho_dT = 0.;
41  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
42 
43  // From e(p, rho), compute: de(p,rho)/dp, de(p,rho)/drho
44  Real depr_dp = 0., depr_drho = 0.;
45  e_from_p_rho(p, rho, e, depr_dp, depr_drho);
46 
47  // Using partial derivative rules, we have:
48  // de(p,T)/dp = de(p,rho)/dp * dp/dp + de(p,rho)/drho * drho(p,T)/dp, (dp/dp == 1)
49  // de(p,T)/dT = de(p,rho)/dp * dp/dT + de(p,rho)/drho * drho(p,T)/dT, (dp/dT == 0)
50  de_dp = depr_dp + depr_drho * drho_dp;
51  de_dT = depr_drho * drho_dT;
52 }
53 
54 Real
55 SinglePhaseFluidProperties::v_from_p_T(Real p, Real T) const
56 {
57  const Real rho = rho_from_p_T(p, T);
58  return 1.0 / rho;
59 }
60 
61 void
62 SinglePhaseFluidProperties::v_from_p_T(Real p, Real T, Real & v, Real & dv_dp, Real & dv_dT) const
63 {
64  Real rho, drho_dp, drho_dT;
65  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
66 
67  v = 1.0 / rho;
68  const Real dv_drho = -1.0 / (rho * rho);
69 
70  dv_dp = dv_drho * drho_dp;
71  dv_dT = dv_drho * drho_dT;
72 }
73 
74 void
75 SinglePhaseFluidProperties::beta_from_p_T(Real, Real, Real &, Real &, Real &) const
76 {
77  mooseError(name(), ": ", __PRETTY_FUNCTION__, " is not implemented.");
78 }
79 
80 Real
81 SinglePhaseFluidProperties::beta_from_p_T(Real p, Real T) const
82 {
83  // The volumetric thermal expansion coefficient is defined as
84  // 1/v dv/dT)_p
85  // It is the fractional change rate of volume with respect to temperature change
86  // at constant pressure. Here it is coded as
87  // - 1/rho drho/dT)_p
88  // using chain rule with v = v(rho)
89 
90  Real rho, drho_dp, drho_dT;
91  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
92  return -drho_dT / rho;
93 }
94 
95 Real
97 {
98  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
99 }
100 
101 std::string
102 SinglePhaseFluidProperties::fluidName() const
103 {
104  return std::string("");
105 }
106 
107 Real
109 {
110  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
111 }
112 
113 Real
115 {
116  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
117 }
118 
119 Real
121 {
122  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
123 }
124 
125 Real
127 {
128  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
129 }
130 
131 Real
133 {
134  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
135 }
136 
137 Real
139 {
140  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
141 }
142 
143 Real
144 SinglePhaseFluidProperties::gamma_from_v_e(Real v, Real e) const
145 {
146  return cp_from_v_e(v, e) / cv_from_v_e(v, e);
147 }
148 
149 void
150 SinglePhaseFluidProperties::gamma_from_v_e(
151  Real v, Real e, Real & gamma, Real & dgamma_dv, Real & dgamma_de) const
152 {
153  fluidPropError(name(), ": ", __PRETTY_FUNCTION__, " derivatives not implemented.");
154 
155  dgamma_dv = 0.0;
156  dgamma_de = 0.0;
157  gamma = gamma_from_v_e(v, e);
158 }
159 
160 Real
161 SinglePhaseFluidProperties::gamma_from_p_T(Real p, Real T) const
162 {
163  return cp_from_p_T(p, T) / cv_from_p_T(p, T);
164 }
165 
166 void
167 SinglePhaseFluidProperties::gamma_from_p_T(
168  Real p, Real T, Real & gamma, Real & dgamma_dp, Real & dgamma_dT) const
169 {
170  fluidPropError(name(), ": ", __PRETTY_FUNCTION__, " derivatives not implemented.");
171 
172  dgamma_dp = 0.0;
173  dgamma_dT = 0.0;
174  gamma = gamma_from_p_T(p, T);
175 }
176 
178 {
179  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
180 }
181 
182 std::vector<Real>
184 {
185  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
186 }
187 
188 void
189 SinglePhaseFluidProperties::vaporPressure(Real T, Real & p, Real & dp_dT) const
190 {
191  fluidPropError(name(), ": ", __PRETTY_FUNCTION__, " derivatives not implemented.");
192 
193  dp_dT = 0.0;
194  p = vaporPressure(T);
195 }
196 
197 DualReal
199 {
200  Real p = 0.0;
201  Real temperature = T.value();
202  Real dpdT = 0.0;
203 
204  vaporPressure(temperature, p, dpdT);
205 
206  DualReal result = p;
207  result.derivatives() = T.derivatives() * dpdT;
208 
209  return result;
210 }
211 
213 {
214  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
215 }
216 
217 void
218 SinglePhaseFluidProperties::vaporTemperature(Real p, Real & T, Real & dT_dp) const
219 {
220  fluidPropError(name(), ": ", __PRETTY_FUNCTION__, " derivatives not implemented.");
221 
222  dT_dp = 0.0;
223  T = vaporTemperature(p);
224 }
225 
226 DualReal
228 {
229  Real T = 0.0;
230  Real pressure = p.value();
231  Real dTdp = 0.0;
232 
233  vaporTemperature(pressure, T, dTdp);
234 
235  DualReal result = T;
236  result.derivatives() = p.derivatives() * dTdp;
237 
238  return result;
239 }
240 
241 void
243  Real T,
244  Real & rho,
245  Real & drho_dp,
246  Real & drho_dT,
247  Real & e,
248  Real & de_dp,
249  Real & de_dT) const
250 {
251  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
252  e_from_p_T(p, T, e, de_dp, de_dT);
253 }
254 
255 void
256 SinglePhaseFluidProperties::rho_mu_from_p_T(Real p, Real T, Real & rho, Real & mu) const
257 {
258  rho = rho_from_p_T(p, T);
259  mu = mu_from_p_T(p, T);
260 }
261 
262 void
264  Real T,
265  Real & rho,
266  Real & drho_dp,
267  Real & drho_dT,
268  Real & mu,
269  Real & dmu_dp,
270  Real & dmu_dT) const
271 {
272  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
273  mu_from_p_T(p, T, mu, dmu_dp, dmu_dT);
274 }
275 
276 void
278  const DualReal & T,
279  DualReal & rho,
280  DualReal & mu) const
281 {
282  rho = rho_from_p_T(p, T);
283  mu = mu_from_p_T(p, T);
284 }
285 
287 {
288  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
289 }
290 
291 void
293 {
294  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented.");
295 }
296 
297 Real
298 SinglePhaseFluidProperties::T_from_p_h(Real p, Real h) const
299 {
300  const Real s = s_from_h_p(h, p);
301  const Real rho = rho_from_p_s(p, s);
302  const Real v = 1. / rho;
303  const Real e = e_from_v_h(v, h);
304  return T_from_v_e(v, e);
305 }
306 
307 void
308 SinglePhaseFluidProperties::T_from_p_h(Real p, Real h, Real & T, Real & dT_dp, Real & dT_dh) const
309 {
310  Real s, ds_dh, ds_dp;
311  s_from_h_p(h, p, s, ds_dh, ds_dp);
312 
313  Real rho, drho_dp_partial, drho_ds;
314  rho_from_p_s(p, s, rho, drho_dp_partial, drho_ds);
315  const Real drho_dp = drho_dp_partial + drho_ds * ds_dp;
316  const Real drho_dh = drho_ds * ds_dh;
317 
318  const Real v = 1.0 / rho;
319  const Real dv_drho = -1.0 / (rho * rho);
320  const Real dv_dp = dv_drho * drho_dp;
321  const Real dv_dh = dv_drho * drho_dh;
322 
323  Real e, de_dv, de_dh_partial;
324  e_from_v_h(v, h, e, de_dv, de_dh_partial);
325  const Real de_dp = de_dv * dv_dp;
326  const Real de_dh = de_dh_partial + de_dv * dv_dh;
327 
328  Real dT_dv, dT_de;
329  T_from_v_e(v, e, T, dT_dv, dT_de);
330  dT_dp = dT_dv * dv_dp + dT_de * de_dp;
331  dT_dh = dT_dv * dv_dh + dT_de * de_dh;
332 }
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::criticalInternalEnergy
virtual Real criticalInternalEnergy() const
Critical specific internal energy.
Definition: SinglePhaseFluidProperties.C:126
SinglePhaseFluidProperties::v
v
Definition: SinglePhaseFluidProperties.h:155
SinglePhaseFluidProperties.h
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
SinglePhaseFluidProperties::~SinglePhaseFluidProperties
virtual ~SinglePhaseFluidProperties()
Definition: SinglePhaseFluidProperties.C:27
SinglePhaseFluidProperties::triplePointTemperature
virtual Real triplePointTemperature() const
Triple point temperature.
Definition: SinglePhaseFluidProperties.C:138
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
validParams< FluidProperties >
InputParameters validParams< FluidProperties >()
Definition: FluidProperties.C:16
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
name
const std::string name
Definition: Setup.h:21
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
validParams< SinglePhaseFluidProperties >
InputParameters validParams< SinglePhaseFluidProperties >()
Definition: SinglePhaseFluidProperties.C:14
NS::temperature
const std::string temperature
Definition: NS.h:26
FluidProperties
Definition: FluidProperties.h:28
SinglePhaseFluidProperties::p
e e e e p h p
Definition: SinglePhaseFluidProperties.h:167
NS::pressure
const std::string pressure
Definition: NS.h:25
SinglePhaseFluidProperties::h
e e e e h
Definition: SinglePhaseFluidProperties.h:163