https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SalineMoltenSaltFluidProperties.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
13
16{
18 const std::string description = "Molten salt fluid properties using Saline";
19#ifdef SALINE_ENABLED
20 params.addClassDescription(description);
21#else
23 "To use this object, you need to have the `Saline` library installed. Refer to the "
24 "documentation for guidance on how to enable it. (Original description: " +
25 description + ")");
26#endif
27 params.addRequiredParam<std::vector<std::string>>("comp_name",
28 "The name of the components in the salt");
29 params.addRequiredParam<std::vector<Real>>("comp_val",
30 "The mole fraction of each salt component");
31 params.addRequiredParam<std::string>(
32 "prop_def_file",
33 "Definition of a fluid property file, which must be a file path to the "
34 "comma-separated data matching the Saline format.");
35 return params;
36}
37
39 : SinglePhaseFluidProperties(parameters), _fd_size(1e-6)
40{
41#ifdef SALINE_ENABLED
42 const auto & propDef = getParam<std::string>("prop_def_file");
43 _d.load(propDef);
44 bool success = _tp.initialize(&_d);
45 if (!success)
46 mooseError("The initialization of the Saline interface has failed");
47 const auto & name = getParam<std::vector<std::string>>("comp_name");
48 const auto & comp = getParam<std::vector<Real>>("comp_val");
49
50 // Verify mole fractions
51 Real mole_sum = 0.0;
52 for (const auto val : comp)
53 mole_sum += val;
54 if (!MooseUtils::absoluteFuzzyEqual(mole_sum, 1.))
55 mooseError("Mole fractions of defined salt compound do not sum to 1.0.");
56
57 success = _tp.setComposition(name, comp);
58 if (!success)
59 mooseError("The composition set has failed");
60 _fluid_name = MooseUtils::join(name, "-");
61#else
62 mooseError("Saline was not made available during the build and cannot be used. Make sure you "
63 "have the 'modules/fluid_properties/contrib/saline' submodule checked out.");
64#endif
65}
66
67#ifdef SALINE_ENABLED
68
69std::string
74
75Real
76SalineMoltenSaltFluidProperties::rho_from_p_T(Real pressure, Real temperature) const
77{
78 return _tp.rho_kgm3(temperature, pressure * Pa_to_kPa);
79}
80
81void
83 Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
84{
85 rho = rho_from_p_T(pressure, temperature);
86 // Estimate derivatives for now because they are not provided by Saline
87 drho_dp = 0.;
88 drho_dT = (rho_from_p_T(pressure, temperature + 1.0) - rho) / 1.0;
89}
90
91Real
92SalineMoltenSaltFluidProperties::cp_from_p_T(Real pressure, Real temperature) const
93{
94 return _tp.cp_kg(temperature, pressure * Pa_to_kPa); // J/kg/K
95}
96
97void
99 Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
100{
101 cp = cp_from_p_T(pressure, temperature);
102 dcp_dp = 0;
103 dcp_dT = (cp_from_p_T(pressure, temperature + 1.0) - cp) / 1.0;
104}
105
106Real
107SalineMoltenSaltFluidProperties::h_from_p_T(Real /*pressure*/, Real temperature) const
108{
109 return _tp.h_t_kg(temperature);
110}
111
112void
114 Real /*pressure*/, Real temperature, Real & enthalpy, Real & dh_dp, Real & dh_dT) const
115{
116 enthalpy = h_from_p_T(0.0, temperature);
117 dh_dp = 0.0;
118 // finite difference approximation
119 dh_dT = (h_from_p_T(0.0, temperature * (1 + _fd_size)) - enthalpy) / (temperature * _fd_size);
120}
121
122Real
123SalineMoltenSaltFluidProperties::e_from_p_T(Real pressure, Real temperature) const
124{
125 return _tp.h_t_kg(temperature) - pressure / rho_from_p_T(pressure, temperature);
126}
127
128void
130 Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
131{
132 const Real rho = rho_from_p_T(pressure, temperature);
133 e = _tp.h_t_kg(temperature) - pressure / rho;
134 de_dp = -1 / rho;
135 // finite difference approximation
136 de_dT = (e_from_p_T(pressure, temperature * (1 + _fd_size)) - e) / (temperature * _fd_size);
137}
138
139Real
140SalineMoltenSaltFluidProperties::T_from_p_h(Real /*pressure*/, Real enthalpy) const
141{
142 return _tp.t_h_kg(enthalpy);
143}
144
145Real
146SalineMoltenSaltFluidProperties::mu_from_p_T(Real pressure, Real temperature) const
147{
148 return _tp.mu(temperature, pressure * Pa_to_kPa) * mN_to_N; // Ns/m^2
149}
150
151void
153 Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
154{
155 mu = _tp.mu(temperature, pressure * Pa_to_kPa) * mN_to_N;
156 Real mu_p1 = _tp.mu(temperature, pressure * (1 + _fd_size) * Pa_to_kPa) * mN_to_N; // Ns/m^2
157 Real mu_T1 = _tp.mu(temperature * (1 + _fd_size), pressure * Pa_to_kPa) * mN_to_N; // Ns/m^2
158 dmu_dp = (mu_p1 - mu) / (_fd_size * pressure * Pa_to_kPa);
159 dmu_dT = (mu_T1 - mu) / (_fd_size * temperature);
160}
161
162Real
163SalineMoltenSaltFluidProperties::k_from_p_T(Real pressure, Real temperature) const
164{
165 return _tp.k(temperature, pressure * Pa_to_kPa); // W/m/K
166}
167
168void
170 Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
171{
172 k = _tp.k(temperature, pressure * Pa_to_kPa);
173 Real k_p1 = _tp.k(temperature, pressure * (1 + _fd_size) * Pa_to_kPa);
174 Real k_T1 = _tp.k(temperature * (1 + _fd_size), pressure * Pa_to_kPa);
175 dk_dp = (k_p1 - k) / (_fd_size * pressure * Pa_to_kPa);
176 dk_dT = (k_T1 - k) / (_fd_size * temperature);
177}
178
179#endif
const double mu
const double rho
registerMooseObject("FluidPropertiesApp", SalineMoltenSaltFluidProperties)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & name() const
void mooseError(Args &&... args) const
SalineMoltenSaltFluidProperties(const InputParameters &parameters)
virtual Real T_from_p_h(Real p, Real h) const override
Temperature from pressure and specific enthalpy.
virtual Real h_from_p_T(Real p, Real T) const override
Specific enthalpy from pressure and temperature.
virtual std::string fluidName() const override
Fluid name.
virtual Real e_from_p_T(Real p, Real T) const override
Specific energy from pressure and temperature.
saline::Thermophysical_Properties _tp
Saline interface to fluid properties.
virtual Real rho_from_p_T(Real pressure, Real temperature) const override
Density from pressure and temperature.
const Real _fd_size
The relative finite differencing step size.
saline::Default_Data_Store _d
Saline DataStore object.
virtual Real mu_from_p_T(Real pressure, Real temperature) const override
Dynamic viscosity from pressure and temperature.
virtual Real k_from_p_T(Real pressure, Real temperature) const override
Thermal conductivity from pressure and temperature.
virtual Real cp_from_p_T(Real pressure, Real temperature) const override
Isobaric specific heat capacity from pressure and temperature.
Common class for single phase fluid properties.
static InputParameters validParams()