www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
GeneralVaporMixtureFluidProperties Class Reference

Class for fluid properties of an arbitrary vapor mixture. More...

#include <GeneralVaporMixtureFluidProperties.h>

Inheritance diagram for GeneralVaporMixtureFluidProperties:
[legend]

Public Member Functions

 GeneralVaporMixtureFluidProperties (const InputParameters &parameters)
 
virtual ~GeneralVaporMixtureFluidProperties ()
 
virtual unsigned int getNumberOfSecondaryVapors () const override
 Returns the number of secondary vapors. More...
 
virtual Real p_from_v_e (Real v, Real e, const std::vector< Real > &x) const override
 Pressure from specific volume and specific internal energy. More...
 
virtual void p_from_v_e (Real v, Real e, const std::vector< Real > &x, Real &p, Real &dp_dv, Real &dp_de, std::vector< Real > &dp_dx) const override
 Pressure and its derivatives from specific volume and specific internal energy. More...
 
virtual Real T_from_v_e (Real v, Real e, const std::vector< Real > &x) const override
 Temperature from specific volume and specific internal energy. More...
 
virtual void T_from_v_e (Real v, Real e, const std::vector< Real > &x, Real &T, Real &dT_dv, Real &dT_de, std::vector< Real > &dT_dx) const override
 Temperature and its derivatives from specific volume and specific internal energy. More...
 
virtual Real rho_from_p_T (Real p, Real T, const std::vector< Real > &x) const override
 Density from pressure and temperature. More...
 
virtual void rho_from_p_T (Real p, Real T, const std::vector< Real > &x, Real &rho, Real &drho_dp, Real &drho_dT, std::vector< Real > &drho_dx) const override
 Density and its derivatives from pressure and temperature. More...
 
virtual Real e_from_p_T (Real p, Real T, const std::vector< Real > &x) const override
 Specific internal energy from pressure and temperature. More...
 
virtual void e_from_p_T (Real p, Real T, const std::vector< Real > &x, Real &e, Real &de_dp, Real &de_dT, std::vector< Real > &de_dx) const override
 Specific internal energy and its derivatives from pressure and temperature. More...
 
virtual Real c_from_p_T (Real p, Real T, const std::vector< Real > &x) const override
 Sound speed from pressure and temperature. More...
 
virtual void c_from_p_T (Real p, Real T, const std::vector< Real > &x, Real &c, Real &dc_dp, Real &dc_dT, std::vector< Real > &dc_dx) const override
 Sound speed and its derivatives from pressure and temperature. More...
 
virtual Real cp_from_p_T (Real p, Real T, const std::vector< Real > &x) const override
 Isobaric (constant-pressure) specific heat from pressure and temperature. More...
 
virtual Real cv_from_p_T (Real p, Real T, const std::vector< Real > &x) const override
 Isochoric (constant-volume) specific heat from pressure and temperature. More...
 
virtual Real mu_from_p_T (Real p, Real T, const std::vector< Real > &x) const override
 Dynamic viscosity from pressure and temperature. More...
 
virtual Real k_from_p_T (Real p, Real T, const std::vector< Real > &x) const override
 Thermal conductivity from pressure and temperature. More...
 
virtual Real v_from_p_T (Real p, Real T, const std::vector< Real > &x) const
 Specific volume from pressure and temperature. More...
 
virtual void v_from_p_T (Real p, Real T, const std::vector< Real > &x, Real &v, Real &dv_dp, Real &dv_dT, std::vector< Real > &dv_dx) const
 Specific volume and its derivatives from pressure and temperature. More...
 
void p_T_from_v_e (Real v, Real e, const std::vector< Real > &x, Real &p, Real &T) const
 Pressure and temperature from specific volume and specific internal energy. More...
 
void p_T_from_v_e (Real v, Real e, const std::vector< Real > &x, Real &p, Real &dp_dv, Real &dp_de, std::vector< Real > &dp_dx, Real &T, Real &dT_dv, Real &dT_de, std::vector< Real > &dT_dx) const
 Pressure and temperature from specific volume and specific internal energy. More...
 
Real primaryMassFraction (const std::vector< Real > &x) const
 Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors. More...
 
virtual void execute () final
 
virtual void initialize () final
 
virtual void finalize () final
 
virtual void threadJoin (const UserObject &) final
 
virtual void subdomainSetup () final
 

Protected Attributes

const SinglePhaseFluidProperties_fp_primary
 Primary vapor fluid properties. More...
 
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
 Secondary vapor fluid properties. More...
 
const std::vector< UserObjectName > _fp_secondary_names
 Names of secondary vapor fluid properties. More...
 
const unsigned int _n_secondary_vapors
 Number of secondary vapors. More...
 
const Real _p_initial_guess
 Initial guess for pressure. More...
 
const Real _T_initial_guess
 Initial guess for temperature. More...
 
const Real _newton_damping
 Damping factor for Newton updates. More...
 
const Real _newton_rel_tol
 Relative tolerance for Newton iteration. More...
 
const unsigned int _newton_max_its
 Maximum iterations for Newton iteration. More...
 
const bool _update_guesses
 Option to update guesses after each converged solve. More...
 
Real _p_guess
 Current guess for pressure (in case guess is chosen to be changed) More...
 
Real _T_guess
 Current guess for temperature (in case guess is chosen to be changed) More...
 

Detailed Description

Class for fluid properties of an arbitrary vapor mixture.

This model assumes that the gases occupy separate volumes, but share the same pressure \(p\) and temperature \(T\). Specific volume and specific internal energy have the following mixture relations, where \(i\) denotes the index of the gas in the mixture, and the lack of a subscript denotes the mixture quantity:

\[ v = \sum\limits_i^N x_i v_i(p, T) , \]

\[ e = \sum\limits_i^N x_i e_i(p, T) . \]

Here \(v_i(p, T)\) and \(e_i(p, T)\) denote the equation-of-state calls from the respective gas from \(p\) and \(T\). Therefore, if \(v\) and \(e\) are known, then to get \(p\) and \(T\), a size-2 nonlinear system needs to be solved.

Definition at line 40 of file GeneralVaporMixtureFluidProperties.h.

Constructor & Destructor Documentation

◆ GeneralVaporMixtureFluidProperties()

GeneralVaporMixtureFluidProperties::GeneralVaporMixtureFluidProperties ( const InputParameters &  parameters)

Definition at line 46 of file GeneralVaporMixtureFluidProperties.C.

48  : VaporMixtureFluidProperties(parameters),
49  _fp_secondary_names(getParam<std::vector<UserObjectName>>("fp_secondary")),
51  _p_initial_guess(getParam<Real>("p_initial_guess")),
52  _T_initial_guess(getParam<Real>("T_initial_guess")),
53  _newton_damping(getParam<Real>("newton_damping")),
54  _newton_rel_tol(getParam<Real>("newton_rel_tol")),
55  _newton_max_its(getParam<unsigned int>("newton_max_its")),
56  _update_guesses(getParam<bool>("update_guesses"))
57 {
58  _fp_primary = &getUserObject<SinglePhaseFluidProperties>("fp_primary");
59 
61  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
62  _fp_secondary[i] = &getUserObjectByName<SinglePhaseFluidProperties>(_fp_secondary_names[i]);
63 
66 }
const Real _p_initial_guess
Initial guess for pressure.
VaporMixtureFluidProperties(const InputParameters &parameters)
const unsigned int _newton_max_its
Maximum iterations for Newton iteration.
const std::vector< UserObjectName > _fp_secondary_names
Names of secondary vapor fluid properties.
const Real _newton_damping
Damping factor for Newton updates.
const Real _T_initial_guess
Initial guess for temperature.
Real _T_guess
Current guess for temperature (in case guess is chosen to be changed)
const unsigned int _n_secondary_vapors
Number of secondary vapors.
const Real _newton_rel_tol
Relative tolerance for Newton iteration.
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
Real _p_guess
Current guess for pressure (in case guess is chosen to be changed)
const bool _update_guesses
Option to update guesses after each converged solve.

◆ ~GeneralVaporMixtureFluidProperties()

GeneralVaporMixtureFluidProperties::~GeneralVaporMixtureFluidProperties ( )
virtual

Definition at line 68 of file GeneralVaporMixtureFluidProperties.C.

68 {}

Member Function Documentation

◆ c_from_p_T() [1/2]

Real GeneralVaporMixtureFluidProperties::c_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
overridevirtual

Sound speed from pressure and temperature.

Returns
Sound speed
Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 229 of file GeneralVaporMixtureFluidProperties.C.

230 {
231  const Real x_primary = primaryMassFraction(x);
232 
233  Real vp, dvp_dp_T, dvp_dT_p;
234  _fp_primary->v_from_p_T(p, T, vp, dvp_dp_T, dvp_dT_p);
235  Real v = x_primary * vp;
236  Real dv_dp_T = x_primary * dvp_dp_T;
237  Real dv_dT_p = x_primary * dvp_dT_p;
238 
239  Real sp, dsp_dp_T, dsp_dT_p;
240  _fp_primary->s_from_p_T(p, T, sp, dsp_dp_T, dsp_dT_p);
241  Real ds_dp_T = x_primary * dsp_dp_T;
242  Real ds_dT_p = x_primary * dsp_dT_p;
243 
244  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
245  {
246  Real vi, dvi_dp_T, dvi_dT_p;
247  _fp_secondary[i]->v_from_p_T(p, T, vi, dvi_dp_T, dvi_dT_p);
248  v += x[i] * vi;
249  dv_dp_T += x[i] * dvi_dp_T;
250  dv_dT_p += x[i] * dvi_dT_p;
251 
252  Real si, dsi_dp_T, dsi_dT_p;
253  _fp_secondary[i]->s_from_p_T(p, T, si, dsi_dp_T, dsi_dT_p);
254  ds_dp_T += x[i] * dsi_dp_T;
255  ds_dT_p += x[i] * dsi_dT_p;
256  }
257 
258  Real dv_dp_s = dv_dp_T - dv_dT_p * ds_dp_T / ds_dT_p;
259 
260  if (dv_dp_s >= 0)
261  mooseWarning(name(), ":c_from_p_T(), dv_dp_s = ", dv_dp_s, ". Should be negative.");
262  return v * std::sqrt(-1. / dv_dp_s);
263 }
const unsigned int _n_secondary_vapors
Number of secondary vapors.
const std::string name
Definition: Setup.h:22
virtual Real s_from_p_T(Real p, Real T) const
Specific entropy from pressure and temperature.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
virtual Real v_from_p_T(Real p, Real T) const
Specific volume from pressure and temperature.

◆ c_from_p_T() [2/2]

void GeneralVaporMixtureFluidProperties::c_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x,
Real &  c,
Real &  dc_dp,
Real &  dc_dT,
std::vector< Real > &  dc_dx 
) const
overridevirtual

Sound speed and its derivatives from pressure and temperature.

Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values
[out]csound speed
[out]dc_dpderivative of sound speed w.r.t. pressure
[out]dc_dTderivative of sound speed w.r.t. temperature
[out]dc_dxderivative of sound speed w.r.t. vapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 266 of file GeneralVaporMixtureFluidProperties.C.

273 {
274  mooseError("Not Implemented.");
275 }

◆ cp_from_p_T()

Real GeneralVaporMixtureFluidProperties::cp_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
overridevirtual

Isobaric (constant-pressure) specific heat from pressure and temperature.

Returns
Isobaric (constant-pressure) specific heat
Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 278 of file GeneralVaporMixtureFluidProperties.C.

279 {
280  const Real x_primary = primaryMassFraction(x);
281  Real vp = _fp_primary->v_from_p_T(p, T);
282  Real ep = _fp_primary->e_from_p_T(p, T);
283  Real cp = x_primary * _fp_primary->cp_from_v_e(vp, ep);
284 
285  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
286  {
287  Real vi = _fp_secondary[i]->v_from_p_T(p, T);
288  Real ei = _fp_secondary[i]->e_from_p_T(p, T);
289  cp += x[i] * _fp_secondary[i]->cp_from_v_e(vi, ei);
290  }
291 
292  return cp;
293 }
virtual Real e_from_p_T(Real p, Real T) const
Internal energy from pressure and temperature.
const unsigned int _n_secondary_vapors
Number of secondary vapors.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
virtual Real cp_from_v_e(Real v, Real e) const
Isobaric (constant-pressure) specific heat from specific volume and specific internal energy...
virtual Real v_from_p_T(Real p, Real T) const
Specific volume from pressure and temperature.

◆ cv_from_p_T()

Real GeneralVaporMixtureFluidProperties::cv_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
overridevirtual

Isochoric (constant-volume) specific heat from pressure and temperature.

Returns
Isochoric (constant-volume) specific heat
Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 296 of file GeneralVaporMixtureFluidProperties.C.

297 {
298  const Real x_primary = primaryMassFraction(x);
299  Real vp = _fp_primary->v_from_p_T(p, T);
300  Real ep = _fp_primary->e_from_p_T(p, T);
301  Real cv = x_primary * _fp_primary->cv_from_v_e(vp, ep);
302 
303  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
304  {
305  Real vi = _fp_secondary[i]->v_from_p_T(p, T);
306  Real ei = _fp_secondary[i]->e_from_p_T(p, T);
307  cv += x[i] * _fp_secondary[i]->cv_from_v_e(vi, ei);
308  }
309 
310  return cv;
311 }
virtual Real e_from_p_T(Real p, Real T) const
Internal energy from pressure and temperature.
const unsigned int _n_secondary_vapors
Number of secondary vapors.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
virtual Real cv_from_v_e(Real v, Real e) const
Isochoric (constant-volume) specific heat from specific volume and specific internal energy...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
virtual Real v_from_p_T(Real p, Real T) const
Specific volume from pressure and temperature.

◆ e_from_p_T() [1/2]

Real GeneralVaporMixtureFluidProperties::e_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
overridevirtual

Specific internal energy from pressure and temperature.

Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 189 of file GeneralVaporMixtureFluidProperties.C.

Referenced by p_T_from_v_e().

190 {
191  const Real x_primary = primaryMassFraction(x);
192 
193  Real e = x_primary * _fp_primary->e_from_p_T(p, T);
194  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
195  e += x[i] * _fp_secondary[i]->e_from_p_T(p, T);
196 
197  return e;
198 }
virtual Real e_from_p_T(Real p, Real T) const
Internal energy from pressure and temperature.
const unsigned int _n_secondary_vapors
Number of secondary vapors.
virtual Real e_from_p_T(Real p, Real T, const std::vector< Real > &x) const override
Specific internal energy from pressure and temperature.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.

◆ e_from_p_T() [2/2]

void GeneralVaporMixtureFluidProperties::e_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x,
Real &  e,
Real &  de_dp,
Real &  de_dT,
std::vector< Real > &  de_dx 
) const
overridevirtual

Specific internal energy and its derivatives from pressure and temperature.

Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values
[in]xvapor mass fraction values
[out]especific internal energy
[out]de_dpderivative of specific internal energy w.r.t. pressure
[out]de_dTderivative of specific internal energy w.r.t. temperature
[out]de_dxderivative of specific internal energy w.r.t. vapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 201 of file GeneralVaporMixtureFluidProperties.C.

208 {
209  const Real x_primary = primaryMassFraction(x);
210 
211  Real ep, dep_dp, dep_dT;
212  _fp_primary->e_from_p_T(p, T, ep, dep_dp, dep_dT);
213  e = x_primary * ep;
214  de_dp = x_primary * dep_dp;
215  de_dT = x_primary * dep_dT;
216  de_dx.resize(_n_secondary_vapors);
217  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
218  {
219  Real ei, dei_dp, dei_dT;
220  _fp_secondary[i]->e_from_p_T(p, T, ei, dei_dp, dei_dT);
221  e += x[i] * ei;
222  de_dp += x[i] * dei_dp;
223  de_dT += x[i] * dei_dT;
224  de_dx[i] = ei - ep;
225  }
226 }
virtual Real e_from_p_T(Real p, Real T) const
Internal energy from pressure and temperature.
const unsigned int _n_secondary_vapors
Number of secondary vapors.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.

◆ execute()

virtual void FluidProperties::execute ( )
inlinefinalvirtualinherited

Definition at line 27 of file FluidProperties.h.

27 {}

◆ finalize()

virtual void FluidProperties::finalize ( )
inlinefinalvirtualinherited

Definition at line 29 of file FluidProperties.h.

29 {}

◆ getNumberOfSecondaryVapors()

virtual unsigned int GeneralVaporMixtureFluidProperties::getNumberOfSecondaryVapors ( ) const
inlineoverridevirtual

Returns the number of secondary vapors.

Implements VaporMixtureFluidProperties.

Definition at line 46 of file GeneralVaporMixtureFluidProperties.h.

46 { return _n_secondary_vapors; }
const unsigned int _n_secondary_vapors
Number of secondary vapors.

◆ initialize()

virtual void FluidProperties::initialize ( )
inlinefinalvirtualinherited

Definition at line 28 of file FluidProperties.h.

28 {}

◆ k_from_p_T()

Real GeneralVaporMixtureFluidProperties::k_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
overridevirtual

Thermal conductivity from pressure and temperature.

Returns
Dynamic viscosity
Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 340 of file GeneralVaporMixtureFluidProperties.C.

341 {
342  const Real x_primary = primaryMassFraction(x);
343  Real M_primary = _fp_primary->molarMass();
344 
345  Real sum = x_primary / M_primary;
346  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
347  sum += x[i] / _fp_secondary[i]->molarMass();
348  Real M_star = 1. / sum;
349 
350  Real vp = _fp_primary->v_from_p_T(p, T);
351  Real ep = _fp_primary->e_from_p_T(p, T);
352  Real k = x_primary * M_star / M_primary * _fp_primary->k_from_v_e(vp, ep);
353 
354  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
355  {
356  Real vi = _fp_secondary[i]->v_from_p_T(p, T);
357  Real ei = _fp_secondary[i]->e_from_p_T(p, T);
358  Real Mi = _fp_secondary[i]->molarMass();
359  k += x[i] * M_star / Mi * _fp_secondary[i]->k_from_v_e(vi, ei);
360  }
361 
362  return k;
363 }
virtual Real molarMass() const
Molar mass [kg/mol].
virtual Real e_from_p_T(Real p, Real T) const
Internal energy from pressure and temperature.
const unsigned int _n_secondary_vapors
Number of secondary vapors.
virtual Real k_from_v_e(Real v, Real e) const
Thermal conductivity from specific volume and specific internal energy.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
virtual Real v_from_p_T(Real p, Real T) const
Specific volume from pressure and temperature.

◆ mu_from_p_T()

Real GeneralVaporMixtureFluidProperties::mu_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
overridevirtual

Dynamic viscosity from pressure and temperature.

Returns
Dynamic viscosity
Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 314 of file GeneralVaporMixtureFluidProperties.C.

315 {
316  const Real x_primary = primaryMassFraction(x);
317  Real M_primary = _fp_primary->molarMass();
318 
319  Real sum = x_primary / M_primary;
320  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
321  sum += x[i] / _fp_secondary[i]->molarMass();
322  Real M_star = 1. / sum;
323 
324  Real vp = _fp_primary->v_from_p_T(p, T);
325  Real ep = _fp_primary->e_from_p_T(p, T);
326  Real mu = x_primary * M_star / M_primary * _fp_primary->mu_from_v_e(vp, ep);
327 
328  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
329  {
330  Real vi = _fp_secondary[i]->v_from_p_T(p, T);
331  Real ei = _fp_secondary[i]->e_from_p_T(p, T);
332  Real Mi = _fp_secondary[i]->molarMass();
333  mu += x[i] * M_star / Mi * _fp_secondary[i]->mu_from_v_e(vi, ei);
334  }
335 
336  return mu;
337 }
virtual Real mu_from_v_e(Real v, Real e) const
Dynamic viscosity from specific volume and specific internal energy.
virtual Real molarMass() const
Molar mass [kg/mol].
virtual Real e_from_p_T(Real p, Real T) const
Internal energy from pressure and temperature.
const unsigned int _n_secondary_vapors
Number of secondary vapors.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
virtual Real v_from_p_T(Real p, Real T) const
Specific volume from pressure and temperature.

◆ p_from_v_e() [1/2]

Real GeneralVaporMixtureFluidProperties::p_from_v_e ( Real  v,
Real  e,
const std::vector< Real > &  x 
) const
overridevirtual

Pressure from specific volume and specific internal energy.

Parameters
[in]vspecific volume
[in]especific internal energy
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 71 of file GeneralVaporMixtureFluidProperties.C.

72 {
73  Real p, dp_dv, dp_de, T, dT_dv, dT_de;
74  std::vector<Real> dp_dx(_n_secondary_vapors);
75  std::vector<Real> dT_dx(_n_secondary_vapors);
76  p_T_from_v_e(v, e, x, p, dp_dv, dp_de, dp_dx, T, dT_dv, dT_de, dT_dx);
77 
78  return p;
79 }
void p_T_from_v_e(Real v, Real e, const std::vector< Real > &x, Real &p, Real &T) const
Pressure and temperature from specific volume and specific internal energy.
const unsigned int _n_secondary_vapors
Number of secondary vapors.

◆ p_from_v_e() [2/2]

void GeneralVaporMixtureFluidProperties::p_from_v_e ( Real  v,
Real  e,
const std::vector< Real > &  x,
Real &  p,
Real &  dp_dv,
Real &  dp_de,
std::vector< Real > &  dp_dx 
) const
overridevirtual

Pressure and its derivatives from specific volume and specific internal energy.

Parameters
[in]vspecific volume
[in]especific internal energy
[in]xvapor mass fraction values
[out]ppressure
[out]dp_dvderivative of pressure w.r.t. specific volume
[out]dp_dederivative of pressure w.r.t. specific internal energy
[out]dp_dxderivative of pressure w.r.t. vapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 82 of file GeneralVaporMixtureFluidProperties.C.

89 {
90  Real T, dT_dv, dT_de;
91  std::vector<Real> dT_dx(_n_secondary_vapors);
92  p_T_from_v_e(v, e, x, p, dp_dv, dp_de, dp_dx, T, dT_dv, dT_de, dT_dx);
93 }
void p_T_from_v_e(Real v, Real e, const std::vector< Real > &x, Real &p, Real &T) const
Pressure and temperature from specific volume and specific internal energy.
const unsigned int _n_secondary_vapors
Number of secondary vapors.

◆ p_T_from_v_e() [1/2]

void GeneralVaporMixtureFluidProperties::p_T_from_v_e ( Real  v,
Real  e,
const std::vector< Real > &  x,
Real &  p,
Real &  T 
) const

Pressure and temperature from specific volume and specific internal energy.

Parameters
[in]vspecific volume
[in]especific internal energy
[in]xvapor mass fraction values
[out]ppressure
[out]Ttemperature

Definition at line 366 of file GeneralVaporMixtureFluidProperties.C.

Referenced by p_from_v_e(), p_T_from_v_e(), and T_from_v_e().

368 {
369  // The residuals are the following:
370  // residual[0] = v(p,T,x) - v
371  // residual[1] = e(p,T,x) - e
372  std::vector<Real> residual(2);
373 
374  // The Jacobian columns are the following:
375  // 0: pressure
376  // 1: temperature
377  std::vector<std::vector<Real>> jacobian(2);
378  jacobian[0].resize(2);
379  jacobian[1].resize(2);
380 
381  std::vector<Real> dv_dx(_n_secondary_vapors);
382  std::vector<Real> de_dx(_n_secondary_vapors);
383 
384  p = _p_guess;
385  T = _T_guess;
386  bool converged = false;
387  std::stringstream err_ss;
388  err_ss << name() << ": The nonlinear solve for p and T did not converge:\n";
389  err_ss << " v = " << v << ", e = " << e;
390  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
391  err_ss << ", x[" << i << "] = " << x[i];
392  err_ss << "\n";
393  for (unsigned int l = 0; l < _newton_max_its; ++l)
394  {
395  // specific volume residual and Jacobians from primary vapor and mixture
396  Real v_it, dv_it_dp, dv_it_dT;
397  std::vector<Real> dv_it_dx;
398  v_from_p_T(p, T, x, v_it, dv_it_dp, dv_it_dT, dv_it_dx);
399  residual[0] = v_it - v;
400  jacobian[0][0] = dv_it_dp;
401  jacobian[0][1] = dv_it_dT;
402 
403  // specific internal energy residual and Jacobians from primary vapor and mixture
404  Real e_it, de_it_dp, de_it_dT;
405  std::vector<Real> de_it_dx;
406  e_from_p_T(p, T, x, e_it, de_it_dp, de_it_dT, de_it_dx);
407  residual[1] = e_it - e;
408  jacobian[1][0] = de_it_dp;
409  jacobian[1][1] = de_it_dT;
410 
411  // compute scaled errors
412  const Real scaled_residual_v = residual[0] / std::abs(v);
413  const Real scaled_residual_e = residual[1] / std::abs(e);
414 
415  // check for convergence
416  const Real l2_error =
417  std::sqrt(std::pow(scaled_residual_v, 2) + std::pow(scaled_residual_e, 2));
418  err_ss << " Iteration " << l << ": p = " << p << ", T = " << T << ": l2 error = " << l2_error
419  << "\n";
420  if (l2_error < _newton_rel_tol)
421  {
422  converged = true;
423  break;
424  }
425 
426  // take Newton step: dx = -J^{-1} r
427  const Real elim = jacobian[1][0] / jacobian[0][0];
428  const Real T_step =
429  (residual[1] - elim * residual[0]) / (jacobian[1][1] - elim * jacobian[0][1]);
430  const Real p_step = (residual[0] - jacobian[0][1] * T_step) / jacobian[0][0];
431  p -= p_step * _newton_damping;
432  T -= T_step * _newton_damping;
433  }
434 
435  if (converged)
436  {
437  if (_update_guesses)
438  {
439  _p_guess = p;
440  _T_guess = T;
441  }
442  }
443  else
444  {
445  err_ss << "\nTry setting the parameters 'p_initial_guess' and 'T_initial_guess'.";
446  mooseWarning(err_ss.str());
447  p = std::nan("");
448  T = std::nan("");
449  }
450 }
const unsigned int _newton_max_its
Maximum iterations for Newton iteration.
const Real _newton_damping
Damping factor for Newton updates.
Real _T_guess
Current guess for temperature (in case guess is chosen to be changed)
const unsigned int _n_secondary_vapors
Number of secondary vapors.
const Real _newton_rel_tol
Relative tolerance for Newton iteration.
const std::string name
Definition: Setup.h:22
virtual Real e_from_p_T(Real p, Real T, const std::vector< Real > &x) const override
Specific internal energy from pressure and temperature.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
virtual Real v_from_p_T(Real p, Real T, const std::vector< Real > &x) const
Specific volume from pressure and temperature.
Real _p_guess
Current guess for pressure (in case guess is chosen to be changed)
const bool _update_guesses
Option to update guesses after each converged solve.

◆ p_T_from_v_e() [2/2]

void GeneralVaporMixtureFluidProperties::p_T_from_v_e ( Real  v,
Real  e,
const std::vector< Real > &  x,
Real &  p,
Real &  dp_dv,
Real &  dp_de,
std::vector< Real > &  dp_dx,
Real &  T,
Real &  dT_dv,
Real &  dT_de,
std::vector< Real > &  dT_dx 
) const

Pressure and temperature from specific volume and specific internal energy.

Parameters
[in]vspecific volume
[in]especific internal energy
[in]xvapor mass fraction values
[out]ppressure
[out]dp_dvderivative of pressure w.r.t. specific volume
[out]dp_dederivative of pressure w.r.t. specific internal energy
[out]dp_dxderivative of pressure w.r.t. vapor mass fraction values
[out]Ttemperature
[out]dT_dvderivative of temperature w.r.t. specific volume
[out]dT_dederivative of temperature w.r.t. specific internal energy
[out]dT_dxderivative of temperature w.r.t. vapor mass fraction values

Definition at line 453 of file GeneralVaporMixtureFluidProperties.C.

464 {
465  p_T_from_v_e(v, e, x, p, T);
466 
467  // specific volume residual and Jacobians from primary vapor and mixture
468  Real v_unused, dv_dp, dv_dT;
469  std::vector<Real> dv_dx;
470  v_from_p_T(p, T, x, v_unused, dv_dp, dv_dT, dv_dx);
471 
472  // specific internal energy residual and Jacobians from primary vapor and mixture
473  Real e_unused, de_dp, de_dT;
474  std::vector<Real> de_dx;
475  e_from_p_T(p, T, x, e_unused, de_dp, de_dT, de_dx);
476 
477  // Compute derivatives using the following rules:
478  // * Reciprocity: da/db|_c = (db/da|_c)^{-1}
479  // * Chain rule: da/db|_c = da/dc|_b * dc/db|_a
480  // * Triple product rule: da/db|_c * db/dc|_a * dc/da|_b = -1
481  dp_dv = de_dT / (dv_dp * de_dT - dv_dT * de_dp);
482  dp_de = dv_dT / (de_dp * dv_dT - de_dT * dv_dp);
483  dT_dv = de_dp / (dv_dT * de_dp - dv_dp * de_dT);
484  dT_de = dv_dp / (de_dT * dv_dp - de_dp * dv_dT);
485 
486  // Derivatives with respect to mass fractions are more complicated, so a
487  // finite difference approximation is used (this is expensive of course).
488  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
489  {
490  Real p_perturbed, T_perturbed;
491  std::vector<Real> x_perturbed(x);
492  x_perturbed[i] += 1e-6;
493  p_T_from_v_e(v, e, x_perturbed, p_perturbed, T_perturbed);
494 
495  dp_dx[i] = (p_perturbed - p) / 1e-6;
496  dT_dx[i] = (T_perturbed - T) / 1e-6;
497  }
498 }
void p_T_from_v_e(Real v, Real e, const std::vector< Real > &x, Real &p, Real &T) const
Pressure and temperature from specific volume and specific internal energy.
const unsigned int _n_secondary_vapors
Number of secondary vapors.
virtual Real e_from_p_T(Real p, Real T, const std::vector< Real > &x) const override
Specific internal energy from pressure and temperature.
virtual Real v_from_p_T(Real p, Real T, const std::vector< Real > &x) const
Specific volume from pressure and temperature.

◆ primaryMassFraction()

Real VaporMixtureFluidProperties::primaryMassFraction ( const std::vector< Real > &  x) const
inherited

◆ rho_from_p_T() [1/2]

Real GeneralVaporMixtureFluidProperties::rho_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
overridevirtual

Density from pressure and temperature.

Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 121 of file GeneralVaporMixtureFluidProperties.C.

122 {
123  return 1.0 / v_from_p_T(p, T, x);
124 }
virtual Real v_from_p_T(Real p, Real T, const std::vector< Real > &x) const
Specific volume from pressure and temperature.

◆ rho_from_p_T() [2/2]

void GeneralVaporMixtureFluidProperties::rho_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x,
Real &  rho,
Real &  drho_dp,
Real &  drho_dT,
std::vector< Real > &  drho_dx 
) const
overridevirtual

Density and its derivatives from pressure and temperature.

Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values
[in]xvapor mass fraction values
[out]rhodensity
[out]drho_dpderivative of density w.r.t. pressure
[out]drho_dTderivative of density w.r.t. temperature
[out]drho_dxderivative of density w.r.t. vapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 127 of file GeneralVaporMixtureFluidProperties.C.

134 {
135  Real v, dv_dp, dv_dT;
136  std::vector<Real> dv_dx;
137  v_from_p_T(p, T, x, v, dv_dp, dv_dT, dv_dx);
138 
139  rho = 1.0 / v;
140  const Real drho_dv = -1.0 / (v * v);
141  drho_dp = drho_dv * dv_dp;
142  drho_dT = drho_dv * dv_dT;
143  drho_dx.resize(_n_secondary_vapors);
144  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
145  drho_dx[i] = drho_dv * dv_dx[i];
146 }
const unsigned int _n_secondary_vapors
Number of secondary vapors.
virtual Real v_from_p_T(Real p, Real T, const std::vector< Real > &x) const
Specific volume from pressure and temperature.

◆ subdomainSetup()

virtual void FluidProperties::subdomainSetup ( )
inlinefinalvirtualinherited

Definition at line 32 of file FluidProperties.h.

32 {}

◆ T_from_v_e() [1/2]

Real GeneralVaporMixtureFluidProperties::T_from_v_e ( Real  v,
Real  e,
const std::vector< Real > &  x 
) const
overridevirtual

Temperature from specific volume and specific internal energy.

Parameters
[in]vspecific volume
[in]especific internal energy
[in]xvapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 96 of file GeneralVaporMixtureFluidProperties.C.

97 {
98  Real p, dp_dv, dp_de, T, dT_dv, dT_de;
99  std::vector<Real> dp_dx(_n_secondary_vapors);
100  std::vector<Real> dT_dx(_n_secondary_vapors);
101  p_T_from_v_e(v, e, x, p, dp_dv, dp_de, dp_dx, T, dT_dv, dT_de, dT_dx);
102 
103  return T;
104 }
void p_T_from_v_e(Real v, Real e, const std::vector< Real > &x, Real &p, Real &T) const
Pressure and temperature from specific volume and specific internal energy.
const unsigned int _n_secondary_vapors
Number of secondary vapors.

◆ T_from_v_e() [2/2]

void GeneralVaporMixtureFluidProperties::T_from_v_e ( Real  v,
Real  e,
const std::vector< Real > &  x,
Real &  T,
Real &  dT_dv,
Real &  dT_de,
std::vector< Real > &  dT_dx 
) const
overridevirtual

Temperature and its derivatives from specific volume and specific internal energy.

Parameters
[in]vspecific volume
[in]especific internal energy
[in]xvapor mass fraction values
[out]Ttemperature
[out]dT_dvderivative of temperature w.r.t. specific volume
[out]dT_dederivative of temperature w.r.t. specific internal energy
[out]dT_dxderivative of temperature w.r.t. vapor mass fraction values

Implements VaporMixtureFluidProperties.

Definition at line 107 of file GeneralVaporMixtureFluidProperties.C.

114 {
115  Real p, dp_dv, dp_de;
116  std::vector<Real> dp_dx(_n_secondary_vapors);
117  p_T_from_v_e(v, e, x, p, dp_dv, dp_de, dp_dx, T, dT_dv, dT_de, dT_dx);
118 }
void p_T_from_v_e(Real v, Real e, const std::vector< Real > &x, Real &p, Real &T) const
Pressure and temperature from specific volume and specific internal energy.
const unsigned int _n_secondary_vapors
Number of secondary vapors.

◆ threadJoin()

virtual void FluidProperties::threadJoin ( const UserObject &  )
inlinefinalvirtualinherited

Definition at line 31 of file FluidProperties.h.

31 {}

◆ v_from_p_T() [1/2]

Real GeneralVaporMixtureFluidProperties::v_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x 
) const
virtual

Specific volume from pressure and temperature.

Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values

Definition at line 149 of file GeneralVaporMixtureFluidProperties.C.

Referenced by p_T_from_v_e(), and rho_from_p_T().

150 {
151  const Real x_primary = primaryMassFraction(x);
152 
153  Real v = x_primary * _fp_primary->v_from_p_T(p, T);
154  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
155  v += x[i] * _fp_secondary[i]->v_from_p_T(p, T);
156 
157  return v;
158 }
const unsigned int _n_secondary_vapors
Number of secondary vapors.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
virtual Real v_from_p_T(Real p, Real T, const std::vector< Real > &x) const
Specific volume from pressure and temperature.
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
virtual Real v_from_p_T(Real p, Real T) const
Specific volume from pressure and temperature.

◆ v_from_p_T() [2/2]

void GeneralVaporMixtureFluidProperties::v_from_p_T ( Real  p,
Real  T,
const std::vector< Real > &  x,
Real &  v,
Real &  dv_dp,
Real &  dv_dT,
std::vector< Real > &  dv_dx 
) const
virtual

Specific volume and its derivatives from pressure and temperature.

Parameters
[in]ppressure
[in]Ttemperature
[in]xvapor mass fraction values
[in]xvapor mass fraction values
[out]vspecific volume
[out]dv_dpderivative of specific volume w.r.t. pressure
[out]dv_dTderivative of specific volume w.r.t. temperature
[out]dv_dxderivative of specific volume w.r.t. vapor mass fraction values

Definition at line 161 of file GeneralVaporMixtureFluidProperties.C.

168 {
169  const Real x_primary = primaryMassFraction(x);
170 
171  Real vp, dvp_dp, dvp_dT;
172  _fp_primary->v_from_p_T(p, T, vp, dvp_dp, dvp_dT);
173  v = x_primary * vp;
174  dv_dp = x_primary * dvp_dp;
175  dv_dT = x_primary * dvp_dT;
176  dv_dx.resize(_n_secondary_vapors);
177  for (unsigned int i = 0; i < _n_secondary_vapors; ++i)
178  {
179  Real vi, dvi_dp, dvi_dT;
180  _fp_secondary[i]->v_from_p_T(p, T, vi, dvi_dp, dvi_dT);
181  v += x[i] * vi;
182  dv_dp += x[i] * dvi_dp;
183  dv_dT += x[i] * dvi_dT;
184  dv_dx[i] = vi - vp;
185  }
186 }
const unsigned int _n_secondary_vapors
Number of secondary vapors.
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
std::vector< const SinglePhaseFluidProperties * > _fp_secondary
Secondary vapor fluid properties.
const SinglePhaseFluidProperties * _fp_primary
Primary vapor fluid properties.
virtual Real v_from_p_T(Real p, Real T) const
Specific volume from pressure and temperature.

Member Data Documentation

◆ _fp_primary

const SinglePhaseFluidProperties* GeneralVaporMixtureFluidProperties::_fp_primary
protected

◆ _fp_secondary

std::vector<const SinglePhaseFluidProperties *> GeneralVaporMixtureFluidProperties::_fp_secondary
protected

◆ _fp_secondary_names

const std::vector<UserObjectName> GeneralVaporMixtureFluidProperties::_fp_secondary_names
protected

Names of secondary vapor fluid properties.

Definition at line 165 of file GeneralVaporMixtureFluidProperties.h.

Referenced by GeneralVaporMixtureFluidProperties().

◆ _n_secondary_vapors

const unsigned int GeneralVaporMixtureFluidProperties::_n_secondary_vapors
protected

◆ _newton_damping

const Real GeneralVaporMixtureFluidProperties::_newton_damping
protected

Damping factor for Newton updates.

Definition at line 175 of file GeneralVaporMixtureFluidProperties.h.

Referenced by p_T_from_v_e().

◆ _newton_max_its

const unsigned int GeneralVaporMixtureFluidProperties::_newton_max_its
protected

Maximum iterations for Newton iteration.

Definition at line 179 of file GeneralVaporMixtureFluidProperties.h.

Referenced by p_T_from_v_e().

◆ _newton_rel_tol

const Real GeneralVaporMixtureFluidProperties::_newton_rel_tol
protected

Relative tolerance for Newton iteration.

Definition at line 177 of file GeneralVaporMixtureFluidProperties.h.

Referenced by p_T_from_v_e().

◆ _p_guess

Real GeneralVaporMixtureFluidProperties::_p_guess
mutableprotected

Current guess for pressure (in case guess is chosen to be changed)

Definition at line 184 of file GeneralVaporMixtureFluidProperties.h.

Referenced by GeneralVaporMixtureFluidProperties(), and p_T_from_v_e().

◆ _p_initial_guess

const Real GeneralVaporMixtureFluidProperties::_p_initial_guess
protected

Initial guess for pressure.

Definition at line 171 of file GeneralVaporMixtureFluidProperties.h.

Referenced by GeneralVaporMixtureFluidProperties().

◆ _T_guess

Real GeneralVaporMixtureFluidProperties::_T_guess
mutableprotected

Current guess for temperature (in case guess is chosen to be changed)

Definition at line 186 of file GeneralVaporMixtureFluidProperties.h.

Referenced by GeneralVaporMixtureFluidProperties(), and p_T_from_v_e().

◆ _T_initial_guess

const Real GeneralVaporMixtureFluidProperties::_T_initial_guess
protected

Initial guess for temperature.

Definition at line 173 of file GeneralVaporMixtureFluidProperties.h.

Referenced by GeneralVaporMixtureFluidProperties().

◆ _update_guesses

const bool GeneralVaporMixtureFluidProperties::_update_guesses
protected

Option to update guesses after each converged solve.

Definition at line 181 of file GeneralVaporMixtureFluidProperties.h.

Referenced by p_T_from_v_e().


The documentation for this class was generated from the following files: