Line data Source code
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 :
10 : #include "LinearFluidProperties.h"
11 :
12 : registerMooseObject("ThermalHydraulicsApp", LinearFluidProperties);
13 :
14 : InputParameters
15 2 : LinearFluidProperties::validParams()
16 : {
17 2 : InputParameters params = SinglePhaseFluidProperties::validParams();
18 4 : params.addRequiredParam<Real>("p_0", "Reference pressure");
19 4 : params.addRequiredParam<Real>("rho_0", "Reference density");
20 4 : params.addRequiredParam<Real>("a2", "dp/d(rho)");
21 4 : params.addRequiredParam<Real>("beta", "Coefficient of thermal expansion");
22 4 : params.addRequiredParam<Real>("cv", "Specific heat");
23 4 : params.addRequiredParam<Real>("e_0", "Reference internal energy");
24 4 : params.addRequiredParam<Real>("T_0", "Reference internal energy");
25 4 : params.addRequiredParam<Real>("mu", "Dynamic viscosity, Pa.s");
26 4 : params.addRequiredParam<Real>("k", "Thermal conductivity, W/(m-K)");
27 4 : params.addDeprecatedParam<Real>(
28 : "Pr",
29 : "Prandtl Number, [-]",
30 : "This parameter is no longer required. It is computed from the other parameters.");
31 2 : params.addClassDescription(
32 : "Fluid properties for a fluid with density linearly dependent on temperature and pressure");
33 2 : return params;
34 0 : }
35 :
36 1 : LinearFluidProperties::LinearFluidProperties(const InputParameters & parameters)
37 : : SinglePhaseFluidProperties(parameters),
38 1 : _rho_0(getParam<Real>("rho_0")),
39 2 : _p_0(getParam<Real>("p_0")),
40 2 : _a2(getParam<Real>("a2")),
41 2 : _beta(getParam<Real>("beta")),
42 2 : _cv(getParam<Real>("cv")),
43 2 : _e_0(getParam<Real>("e_0")),
44 2 : _T_0(getParam<Real>("T_0")),
45 2 : _mu(getParam<Real>("mu")),
46 3 : _k(getParam<Real>("k"))
47 : {
48 2 : if (isParamValid("Pr"))
49 2 : _Pr = getParam<Real>("Pr");
50 : else
51 0 : _Pr = _cv / _k * _mu;
52 :
53 : // Sanity checks
54 1 : if (!MooseUtils::absoluteFuzzyEqual(_Pr, _cv / _k * _mu))
55 0 : paramError("Pr", "Prandtl number should be equal to cv * mu / k");
56 1 : }
57 :
58 : Real
59 13 : LinearFluidProperties::p_from_v_e(Real v, Real e) const
60 : {
61 13 : return _p_0 + _rho_0 * _a2 * ((1 / v / _rho_0 - 1.) + (_beta / _cv) * (e - _e_0));
62 : }
63 :
64 : void
65 1 : LinearFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
66 : {
67 1 : p = p_from_v_e(v, e);
68 1 : dp_dv = -_a2 / v / v;
69 1 : dp_de = _rho_0 * _a2 * _beta / _cv;
70 1 : }
71 :
72 : Real
73 7 : LinearFluidProperties::T_from_v_e(Real /*v*/, Real e) const
74 : {
75 : // e - e0 = cv * (T - T0)
76 7 : return _T_0 + (1. / _cv) * (e - _e_0);
77 : }
78 :
79 : void
80 1 : LinearFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
81 : {
82 1 : T = T_from_v_e(v, e);
83 1 : dT_dv = 0;
84 1 : dT_de = 1 / _cv;
85 1 : }
86 :
87 : Real
88 6 : LinearFluidProperties::c_from_v_e(Real, Real) const
89 : {
90 6 : return std::sqrt(_a2);
91 : }
92 :
93 : void
94 1 : LinearFluidProperties::c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const
95 : {
96 1 : c = c_from_v_e(v, e);
97 1 : dc_dv = 0;
98 1 : dc_de = 0;
99 1 : }
100 :
101 : Real
102 7 : LinearFluidProperties::cp_from_v_e(Real, Real) const
103 : {
104 7 : return _cv;
105 : }
106 :
107 : void
108 1 : LinearFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
109 : {
110 1 : cp = cp_from_v_e(v, e);
111 1 : dcp_de = 0;
112 1 : dcp_dv = 0;
113 1 : }
114 :
115 : Real
116 7 : LinearFluidProperties::cv_from_v_e(Real, Real) const
117 : {
118 7 : return _cv;
119 : }
120 :
121 : void
122 1 : LinearFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
123 : {
124 1 : cv = cv_from_v_e(v, e);
125 1 : dcv_de = 0;
126 1 : dcv_dv = 0;
127 1 : }
128 :
129 : Real
130 1 : LinearFluidProperties::mu_from_v_e(Real, Real) const
131 : {
132 1 : return _mu;
133 : }
134 :
135 : Real
136 1 : LinearFluidProperties::k_from_v_e(Real, Real) const
137 : {
138 1 : return _k;
139 : }
140 :
141 : Real
142 1 : LinearFluidProperties::s_from_v_e(Real, Real) const
143 : {
144 1 : mooseError(name(), ": s_from_v_e() not implemented.");
145 : }
146 :
147 : void
148 1 : LinearFluidProperties::s_from_v_e(Real, Real, Real &, Real &, Real &) const
149 : {
150 1 : mooseError(name(), ": s_from_v_e() not implemented.");
151 : }
152 :
153 : Real
154 1 : LinearFluidProperties::s_from_p_T(Real, Real) const
155 : {
156 1 : mooseError(name(), ": s_from_p_T() not implemented.");
157 : }
158 :
159 : void
160 1 : LinearFluidProperties::s_from_p_T(Real, Real, Real &, Real &, Real &) const
161 : {
162 1 : mooseError(name(), ": s_from_p_T() not implemented.");
163 : }
164 :
165 : Real
166 1 : LinearFluidProperties::s_from_h_p(Real, Real) const
167 : {
168 1 : mooseError(name(), ": s(h,p) is not implemented");
169 : }
170 :
171 : void
172 1 : LinearFluidProperties::s_from_h_p(Real, Real, Real &, Real &, Real &) const
173 : {
174 1 : mooseError(name(), ": s(h,p) is not implemented");
175 : }
176 :
177 : Real
178 1 : LinearFluidProperties::rho_from_p_s(Real, Real) const
179 : {
180 1 : mooseError(name(), ": rho_from_p_s() not implemented.");
181 : }
182 :
183 : void
184 1 : LinearFluidProperties::rho_from_p_s(Real, Real, Real &, Real &, Real &) const
185 : {
186 1 : mooseError(name(), ": rho_from_p_s() not implemented.");
187 : }
188 :
189 : Real
190 6 : LinearFluidProperties::e_from_v_h(Real v, Real h) const
191 : {
192 6 : return (h - v * p_from_v_e(v, 0)) / (1 + v * _beta / _cv * _rho_0 * _a2);
193 : }
194 :
195 : void
196 1 : LinearFluidProperties::e_from_v_h(Real v, Real h, Real & e, Real & de_dv, Real & de_dh) const
197 : {
198 1 : const auto num = (h - v * (_p_0 + _a2 * ((1 / v - _rho_0) - _rho_0 * _beta / _cv * _e_0)));
199 1 : const auto denum = (1 + v * _beta / _cv * _rho_0 * _a2);
200 1 : e = num / denum;
201 1 : de_dh = 1 / denum;
202 1 : de_dv = ((-_p_0 - _a2 * _rho_0 * (-1 - _beta / _cv * _e_0)) * denum -
203 1 : num * _beta / _cv * _rho_0 * _a2) /
204 1 : denum / denum;
205 1 : }
206 :
207 : Real
208 1 : LinearFluidProperties::beta_from_p_T(Real, Real) const
209 : {
210 1 : return _beta;
211 : }
212 :
213 : void
214 0 : LinearFluidProperties::beta_from_p_T(
215 : Real p, Real T, Real & beta, Real & dbeta_dp, Real & dbeta_dT) const
216 : {
217 0 : beta = beta_from_p_T(p, T);
218 0 : dbeta_dp = 0;
219 0 : dbeta_dT = 0;
220 0 : }
221 :
222 : Real
223 19 : LinearFluidProperties::rho_from_p_T(Real p, Real T) const
224 : {
225 19 : Real e = _e_0 + _cv * (T - _T_0);
226 19 : return (p - _p_0) / _a2 - _rho_0 * (_beta / _cv) * (e - _e_0) + _rho_0;
227 : }
228 :
229 : void
230 3 : LinearFluidProperties::rho_from_p_T(
231 : Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const
232 : {
233 3 : Real e = _e_0 + _cv * (T - _T_0);
234 3 : rho = (p - _p_0) / _a2 - _rho_0 * (_beta / _cv) * (e - _e_0) + _rho_0;
235 3 : drho_dp = 1 / _a2;
236 3 : drho_dT = -_rho_0 * _beta;
237 3 : }
238 :
239 : Real
240 6 : LinearFluidProperties::e_from_p_T(Real p, Real T) const
241 : {
242 6 : const auto rho = rho_from_p_T(p, T);
243 6 : return e_from_p_rho(p, rho);
244 : }
245 :
246 : void
247 1 : LinearFluidProperties::e_from_p_T(Real p, Real T, Real & e, Real & de_dp, Real & de_dT) const
248 : {
249 : Real rho, drho_dp, drho_dT;
250 1 : rho_from_p_T(p, T, rho, drho_dp, drho_dT);
251 : Real de_drho, de_dp_rho;
252 1 : e_from_p_rho(p, rho, e, de_dp_rho, de_drho);
253 1 : de_dp = de_drho * drho_dp + de_dp_rho;
254 1 : de_dT = de_drho * drho_dT;
255 1 : }
256 :
257 : Real
258 22 : LinearFluidProperties::e_from_p_rho(Real p, Real rho) const
259 : {
260 22 : return (_cv / _beta) * (((p - _p_0) / (_rho_0 * _a2)) - (rho / _rho_0) + 1) + _e_0;
261 : }
262 :
263 : void
264 2 : LinearFluidProperties::e_from_p_rho(Real p, Real rho, Real & e, Real & de_dp, Real & de_drho) const
265 : {
266 2 : e = e_from_p_rho(p, rho);
267 2 : de_dp = _cv / _beta / _rho_0 / _a2;
268 2 : de_drho = -_cv / _beta / _rho_0;
269 2 : }
270 :
271 : Real
272 7 : LinearFluidProperties::h_from_p_T(Real p, Real T) const
273 : {
274 7 : Real rho = rho_from_p_T(p, T);
275 7 : Real e = e_from_p_rho(p, rho);
276 7 : return e + p / rho;
277 : }
278 :
279 : void
280 1 : LinearFluidProperties::h_from_p_T(Real p, Real T, Real & h, Real & dh_dp, Real & dh_dT) const
281 : {
282 1 : h = h_from_p_T(p, T);
283 :
284 : Real rho, drho_dp, drho_dT;
285 1 : rho_from_p_T(p, T, rho, drho_dp, drho_dT);
286 :
287 1 : dh_dp = 1.0 / rho - p / rho / rho * drho_dp;
288 1 : dh_dT = _cv - p / rho / rho * drho_dT;
289 1 : }
290 :
291 : Real
292 1 : LinearFluidProperties::p_from_h_s(Real, Real) const
293 : {
294 1 : mooseError(name(), ": p_from_h_s() not implemented");
295 : }
296 :
297 : void
298 1 : LinearFluidProperties::p_from_h_s(Real, Real, Real &, Real &, Real &) const
299 : {
300 1 : mooseError(name(), ": p_from_h_s() not implemented");
301 : }
302 :
303 : Real
304 1 : LinearFluidProperties::g_from_v_e(Real, Real) const
305 : {
306 1 : mooseError(name(), ": g_from_v_e(v, e) not implemented");
307 : }
308 :
309 : Real
310 1 : LinearFluidProperties::molarMass() const
311 : {
312 1 : mooseError(name(), ": molarMass() not implemented");
313 : }
314 :
315 : Real
316 1 : LinearFluidProperties::Pr(Real, Real) const
317 : {
318 1 : return _Pr;
319 : }
|