Skip to content
Permalink
Browse files

Merge pull request #13524 from MatthiasKunick/feature_13523

Add IdealRealGasMixtureFluidProperties::c_from_v_e
  • Loading branch information...
andrsd committed Jun 6, 2019
2 parents 9dcfcb2 + dd0f598 commit ca64a6318790f19ac07127b5fd7b17345c5df387
@@ -59,6 +59,14 @@ class GeneralVaporMixtureFluidProperties : public VaporMixtureFluidProperties
Real & dT_dv,
Real & dT_de,
std::vector<Real> & dT_dx) const override;
virtual Real c_from_v_e(Real v, Real e, const std::vector<Real> & x) const override;
virtual void c_from_v_e(Real v,
Real e,
const std::vector<Real> & x,
Real & c,
Real & dc_dv,
Real & dc_de,
std::vector<Real> & dc_dx) const override;
virtual Real rho_from_p_T(Real p, Real T, const std::vector<Real> & x) const override;
virtual void rho_from_p_T(Real p,
Real T,
@@ -184,4 +192,3 @@ class GeneralVaporMixtureFluidProperties : public VaporMixtureFluidProperties
/// Current guess for temperature (in case guess is chosen to be changed)
mutable Real _T_guess;
};

@@ -93,6 +93,35 @@ class IdealRealGasMixtureFluidProperties : public VaporMixtureFluidProperties, p
Real & dT_de,
std::vector<Real> & dT_dx) const override;

/**
* Speed of sound from specific volume and specific internal energy
*
* @param[in] v specific volume
* @param[in] e specific internal energy
* @param[in] x vapor mass fraction values
* @return speed of sound
*/
virtual Real c_from_v_e(Real v, Real e, const std::vector<Real> & x) const override;

/**
* Speed of sound and its derivatives from specific volume and specific internal energy
*
* @param[in] v specific volume
* @param[in] e specific internal energy
* @param[in] x vapor mass fraction values
* @param[out] c Speed of sound
* @param[out] dc_dv derivative of temperature w.r.t. specific volume
* @param[out] dc_de derivative of temperature w.r.t. specific internal energy
* @param[out] dc_dx derivative of temperature w.r.t. vapor mass fraction values
*/
virtual void c_from_v_e(Real v,
Real e,
const std::vector<Real> & x,
Real & c,
Real & dc_dv,
Real & dc_de,
std::vector<Real> & dc_dx) const override;

/**
* Density from pressure and temperature
*
@@ -464,4 +493,3 @@ class IdealRealGasMixtureFluidProperties : public VaporMixtureFluidProperties, p
/// maximum temperature of all components
const Real _T_mix_max;
};

@@ -91,6 +91,35 @@ class VaporMixtureFluidProperties : public FluidProperties
Real & dT_de,
std::vector<Real> & dT_dx) const = 0;

/**
* Speed of sound from specific volume and specific internal energy
*
* @param[in] v specific volume
* @param[in] e specific internal energy
* @param[in] x vapor mass fraction values
* @return speed of sound
*/
virtual Real c_from_v_e(Real v, Real e, const std::vector<Real> & x) const = 0;

/**
* Speed of sound and its derivatives from specific volume and specific internal energy
*
* @param[in] v specific volume
* @param[in] e specific internal energy
* @param[in] x vapor mass fraction values
* @param[out] c Speed of sound
* @param[out] dc_dv derivative of temperature w.r.t. specific volume
* @param[out] dc_de derivative of temperature w.r.t. specific internal energy
* @param[out] dc_dx derivative of temperature w.r.t. vapor mass fraction values
*/
virtual void c_from_v_e(Real v,
Real e,
const std::vector<Real> & x,
Real & c,
Real & dc_dv,
Real & dc_de,
std::vector<Real> & dc_dx) const = 0;

/**
* Density from pressure and temperature
*
@@ -231,4 +260,3 @@ class VaporMixtureFluidProperties : public FluidProperties
*/
Real primaryMassFraction(const std::vector<Real> & x) const;
};

@@ -123,6 +123,26 @@ GeneralVaporMixtureFluidProperties::rho_from_p_T(Real p, Real T, const std::vect
return 1.0 / v_from_p_T(p, T, x);
}

Real
GeneralVaporMixtureFluidProperties::c_from_v_e(Real /*v*/,
Real /*e*/,
const std::vector<Real> & /*x*/) const
{
mooseError(name(), ": ", __PRETTY_FUNCTION__, " is not implemented.");
}

void
GeneralVaporMixtureFluidProperties::c_from_v_e(Real /*v*/,
Real /*e*/,
const std::vector<Real> & /*x*/,
Real & /*c*/,
Real & /*dc_dv*/,
Real & /*dc_de*/,
std::vector<Real> & /*dc_dx*/) const
{
mooseError(name(), ": ", __PRETTY_FUNCTION__, " is not implemented.");
}

void
GeneralVaporMixtureFluidProperties::rho_from_p_T(Real p,
Real T,
@@ -97,6 +97,47 @@ IdealRealGasMixtureFluidProperties::T_from_v_e(Real v,
p_T_from_v_e(v, e, x, p, dp_dv, dp_de, dp_dx, T, dT_dv, dT_de, dT_dx);
}

Real
IdealRealGasMixtureFluidProperties::c_from_v_e(Real v, Real e, const std::vector<Real> & x) const
{
Real p, T;
p_T_from_v_e(v, e, x, p, T);
return c_from_T_v(T, v, x);
}

void
IdealRealGasMixtureFluidProperties::c_from_v_e(Real v,
Real e,
const std::vector<Real> & x,
Real & c,
Real & dc_dv,
Real & dc_de,
std::vector<Real> & dc_dx) const
{
Real p, T;
p_T_from_v_e(v, e, x, p, T);

// sound of speed and derivatives
Real dc_dT_v, dc_dv_T;
std::vector<Real> dc_dx_Tv;
c_from_T_v(T, v, x, c, dc_dT_v, dc_dv_T, dc_dx_Tv);

// internal energy and derivatives
Real e_unused, de_dT_v, de_dv_T;
std::vector<Real> de_dx_Tv;
e_from_T_v(T, v, x, e_unused, de_dT_v, de_dv_T, de_dx_Tv);

// Compute derivatives using the following rules:
dc_dv = dc_dv_T - dc_dT_v * de_dv_T / de_dT_v;
dc_de = dc_dT_v / de_dT_v;

// Derivatives with respect to mass fractions:
for (unsigned int i = 0; i < _n_secondary_vapors; i++)
{
dc_dx[i] = dc_dx_Tv[i] - dc_dT_v * de_dx_Tv[i] / de_dT_v;
}
}

Real
IdealRealGasMixtureFluidProperties::rho_from_p_T(Real p, Real T, const std::vector<Real> & x) const
{
@@ -252,9 +293,10 @@ IdealRealGasMixtureFluidProperties::c_from_p_T(Real p,
c = c_from_p_T(p, T, x);
// For derived properties, we would need higher order derivatives;
// therefore, numerical derivatives are used here
p_perturbed = p * 1.e-6;
Real dp = p * 1.e-6;
p_perturbed = p + dp;
c_perturbed = c_from_p_T(p_perturbed, T, x);
dc_dp = (c_perturbed - c) / (p_perturbed - p);
dc_dp = (c_perturbed - c) / (dp);

Real dT = 1.e-6;
T_perturbed = T + dT;
@@ -651,9 +693,10 @@ IdealRealGasMixtureFluidProperties::c_from_T_v(Real T,
c_perturbed = c_from_T_v(T_perturbed, v, x);
dc_dT = (c_perturbed - c) / (dT);

v_perturbed = v * 1.e-6;
Real dv = v * 1.e-6;
v_perturbed = v + dv;
c_perturbed = c_from_T_v(T, v_perturbed, x);
dc_dv = (c_perturbed - c) / (v_perturbed - v);
dc_dv = (c_perturbed - c) / (dv);

dc_dx.resize(_n_secondary_vapors);
for (unsigned int i = 0; i < _n_secondary_vapors; i++)

0 comments on commit ca64a63

Please sign in to comment.
You can’t perform that action at this time.