https://mooseframework.inl.gov
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
22  params.addClassDescription(
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");
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 
69 std::string
71 {
72  return _fluid_name;
73 }
74 
75 Real
77 {
78  return _tp.rho_kgm3(temperature, pressure * Pa_to_kPa);
79 }
80 
81 void
83  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
84 {
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 
91 Real
93 {
94  return _tp.cp_kg(temperature, pressure * Pa_to_kPa); // J/kg/K
95 }
96 
97 void
99  Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
100 {
102  dcp_dp = 0;
103  dcp_dT = (cp_from_p_T(pressure, temperature + 1.0) - cp) / 1.0;
104 }
105 
106 Real
108 {
109  return _tp.h_t_kg(temperature);
110 }
111 
112 void
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 
122 Real
124 {
126 }
127 
128 void
130  Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
131 {
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 
139 Real
140 SalineMoltenSaltFluidProperties::T_from_p_h(Real /*pressure*/, Real enthalpy) const
141 {
142  return _tp.t_h_kg(enthalpy);
143 }
144 
145 Real
147 {
148  return _tp.mu(temperature, pressure * Pa_to_kPa) * mN_to_N; // Ns/m^2
149 }
150 
151 void
153  Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
154 {
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 
162 Real
164 {
165  return _tp.k(temperature, pressure * Pa_to_kPa); // W/m/K
166 }
167 
168 void
170  Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
171 {
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
std::string join(Iterator begin, Iterator end, const std::string &delimiter)
virtual Real cp_from_p_T(Real pressure, Real temperature) const override
Isobaric specific heat capacity from pressure and temperature.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
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.
static InputParameters validParams()
virtual Real h_from_p_T(Real p, Real T) const override
Specific enthalpy from pressure and temperature.
SalineMoltenSaltFluidProperties(const InputParameters &parameters)
virtual Real k_from_p_T(Real pressure, Real temperature) const override
Thermal conductivity from pressure and temperature.
virtual Real T_from_p_h(Real p, Real h) const override
Temperature from pressure and specific enthalpy.
const Real _fd_size
The relative finite differencing step size.
static const std::string temperature
Definition: NS.h:59
virtual Real rho_from_p_T(Real pressure, Real temperature) const override
Density from pressure and temperature.
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
static const std::string cp
Definition: NS.h:121
registerMooseObject("FluidPropertiesApp", SalineMoltenSaltFluidProperties)
saline::Thermophysical_Properties _tp
Saline interface to fluid properties.
static const std::string mu
Definition: NS.h:123
std::string _fluid_name
Name of the fluid.
Common class for single phase fluid properties.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56
virtual Real e_from_p_T(Real p, Real T) const override
Specific energy from pressure and temperature.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static const std::string k
Definition: NS.h:130
virtual std::string fluidName() const override
Fluid name.