www.mooseframework.org
TabulatedFluidProperties.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #ifndef TABULATEDFLUIDPROPERTIES_H
9 #define TABULATEDFLUIDPROPERTIES_H
10 
12 #include "DelimitedFileReader.h"
13 
15 class BicubicSplineInterpolation;
17 
18 template <>
20 
88 {
89 public:
90  TabulatedFluidProperties(const InputParameters & parameters);
91  virtual ~TabulatedFluidProperties();
92 
93  virtual void initialSetup() override;
94 
95  virtual std::string fluidName() const override;
96 
97  virtual Real molarMass() const override;
98 
99  virtual Real rho(Real pressure, Real temperature) const override;
100 
101  virtual void rho_dpT(
102  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const override;
103 
104  virtual Real e(Real pressure, Real temperature) const override;
105 
106  virtual void
107  e_dpT(Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const override;
108 
109  virtual void rho_e_dpT(Real pressure,
110  Real temperature,
111  Real & rho,
112  Real & drho_dp,
113  Real & drho_dT,
114  Real & e,
115  Real & de_dp,
116  Real & de_dT) const override;
117 
118  virtual Real h(Real p, Real T) const override;
119 
120  virtual void
121  h_dpT(Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const override;
122 
123  virtual Real mu(Real pressure, Real temperature) const override;
124 
125  virtual void
126  mu_dpT(Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const override;
127 
128  virtual Real mu_from_rho_T(Real density, Real temperature) const override;
129 
130  virtual void mu_drhoT_from_rho_T(Real density,
131  Real temperature,
132  Real ddensity_dT,
133  Real & mu,
134  Real & dmu_drho,
135  Real & dmu_dT) const override;
136 
137  virtual Real cp(Real pressure, Real temperature) const override;
138 
139  virtual Real cv(Real pressure, Real temperature) const override;
140 
141  virtual Real c(Real pressure, Real temperature) const override;
142 
143  virtual Real k(Real pressure, Real temperature) const override;
144 
145  virtual void
146  k_dpT(Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const override;
147 
148  virtual Real k_from_rho_T(Real density, Real temperature) const override;
149 
150  virtual Real s(Real pressure, Real temperature) const override;
151 
152  virtual Real beta(Real pressure, Real temperature) const override;
153 
154  virtual Real henryConstant(Real temperature) const override;
155 
156  virtual void henryConstant_dT(Real temperature, Real & Kh, Real & dKh_dT) const override;
157 
158 protected:
163  void writeTabulatedData(std::string file_name);
164 
171  void checkInputVariables(Real pressure, Real temperature) const;
172 
177  virtual void generateTabulatedData();
178 
186  void reshapeData2D(unsigned int nrow,
187  unsigned int ncol,
188  const std::vector<Real> & vec,
189  std::vector<std::vector<Real>> & mat);
190 
192  FileName _file_name;
194  std::vector<Real> _pressure;
196  std::vector<Real> _temperature;
198  std::vector<std::vector<Real>> _density;
200  std::vector<std::vector<Real>> _internal_energy;
202  std::vector<std::vector<Real>> _enthalpy;
204  std::unique_ptr<BicubicSplineInterpolation> _density_ipol;
206  std::unique_ptr<BicubicSplineInterpolation> _internal_energy_ipol;
208  std::unique_ptr<BicubicSplineInterpolation> _enthalpy_ipol;
211  std::vector<Real> _de_dp_0, _de_dp_n, _de_dT_0, _de_dT_n;
212  std::vector<Real> _dh_dp_0, _dh_dp_n, _dh_dT_0, _dh_dT_n;
213 
223  unsigned int _num_T;
225  unsigned int _num_p;
227  const unsigned int _wrt_p = 1;
229  const unsigned int _wrt_T = 2;
230 
233 
235  const std::vector<std::string> _required_columns{
236  "pressure", "temperature", "density", "enthalpy", "internal_energy"};
238  MooseUtils::DelimitedFileReader _csv_reader;
239 };
240 
241 #endif /* TABULATEDFLUIDPROPERTIES_H */
virtual void initialSetup() override
std::unique_ptr< BicubicSplineInterpolation > _enthalpy_ipol
Interpoled enthalpy.
Class for fluid properties read from a file.
virtual Real k(Real pressure, Real temperature) const override
Thermal conductivity.
virtual Real c(Real pressure, Real temperature) const override
Speed of sound.
virtual Real henryConstant(Real temperature) const override
Henry&#39;s law constant for dissolution in water.
std::vector< std::vector< Real > > _internal_energy
Tabulated internal energy.
Real _temperature_max
Maximum temperature in tabulated data.
const std::vector< std::string > _required_columns
List of required column names to be read.
virtual Real rho(Real pressure, Real temperature) const override
Density.
std::unique_ptr< BicubicSplineInterpolation > _internal_energy_ipol
Interpoled internal energy.
const unsigned int _wrt_T
Index for derivatives wrt temperature.
virtual Real mu_from_rho_T(Real density, Real temperature) const override
const std::string density
Definition: NS.h:15
Real _pressure_max
Maximum pressure in tabulated data.
std::vector< std::vector< Real > > _density
Tabulated density.
virtual void mu_dpT(Real pressure, Real temperature, Real &mu, Real &dmu_dp, Real &dmu_dT) const override
MooseUtils::DelimitedFileReader _csv_reader
The MOOSE delimited file reader.
virtual void henryConstant_dT(Real temperature, Real &Kh, Real &dKh_dT) const override
Henry&#39;s law constant for dissolution in water and derivative wrt temperature.
const std::string temperature
Definition: NS.h:25
virtual Real beta(Real pressure, Real temperature) const override
Thermal expansion coefficient.
void checkInputVariables(Real pressure, Real temperature) const
Checks that the inputs are within the range of the tabulated data, and throws an error if they are no...
virtual std::string fluidName() const override
Fluid name.
virtual Real s(Real pressure, Real temperature) const override
Specific entropy.
Common class for single phase fluid properties using a pressure and temperature formulation.
const unsigned int _wrt_p
Index for derivatives wrt pressure.
Real _temperature_min
Minimum temperature in tabulated data.
std::unique_ptr< BicubicSplineInterpolation > _density_ipol
Interpoled density.
virtual void e_dpT(Real pressure, Real temperature, Real &e, Real &de_dp, Real &de_dT) const override
Internal energy and its derivatives wrt pressure and temperature.
virtual void h_dpT(Real pressure, Real temperature, Real &h, Real &dh_dp, Real &dh_dT) const override
Enthalpy and its derivatives wrt pressure and temperature.
const SinglePhaseFluidPropertiesPT & _fp
SinglePhaseFluidPropertiesPT UserObject.
std::vector< std::vector< Real > > _enthalpy
Tabulated enthalpy.
virtual void rho_e_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT, Real &e, Real &de_dp, Real &de_dT) const override
Density and internal energy and their derivatives wrt pressure and temperature.
TabulatedFluidProperties(const InputParameters &parameters)
virtual void rho_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT) const override
Density and its derivatives wrt pressure and temperature.
virtual Real mu(Real pressure, Real temperature) const override
std::vector< Real > _pressure
Pressure vector.
std::vector< Real > _temperature
Temperature vector.
virtual Real cv(Real pressure, Real temperature) const override
Isochoric specific heat.
virtual void k_dpT(Real pressure, Real temperature, Real &k, Real &dk_dp, Real &dk_dT) const override
Thermal conductivity and its derivatives wrt pressure and temperature.
unsigned int _num_T
Number of temperature points in the tabulated data.
Real _pressure_min
Minimum pressure in tabulated data.
unsigned int _num_p
Number of pressure points in the tabulated data.
InputParameters validParams< TabulatedFluidProperties >()
const std::string pressure
Definition: NS.h:24
virtual Real e(Real pressure, Real temperature) const override
Internal energy.
void reshapeData2D(unsigned int nrow, unsigned int ncol, const std::vector< Real > &vec, std::vector< std::vector< Real >> &mat)
Forms a 2D matrix from a single std::vector.
virtual void mu_drhoT_from_rho_T(Real density, Real temperature, Real ddensity_dT, Real &mu, Real &dmu_drho, Real &dmu_dT) const override
Dynamic viscosity and its derivatives wrt density and temperature.
virtual Real h(Real p, Real T) const override
Specific enthalpy.
std::vector< Real > _drho_dp_0
Derivatives along the boundary.
virtual Real cp(Real pressure, Real temperature) const override
Isobaric specific heat capacity.
virtual void generateTabulatedData()
Generates a table of fluid properties by looping over pressure and temperature and calculating proper...
void writeTabulatedData(std::string file_name)
Writes tabulated data to a file.
virtual Real k_from_rho_T(Real density, Real temperature) const override
Thermal conductivity as a function of density and temperature.
virtual Real molarMass() const override
Molar mass.
FileName _file_name
File name of tabulated data file.