Skip to content
Snippets Groups Projects
Commit ffa45a97 authored by Thomas Fetzer's avatar Thomas Fetzer
Browse files

[material] Introduce check if phase is gas, remove unused function in...

[material] Introduce check if phase is gas, remove unused function in immiscible fluidstate, and cosmetic changes
parent 717c37cc
No related branches found
No related tags found
2 merge requests!31Feature/colebrookwhiteboundarylayer,!11[material,decoupled] add partial and vapor pressure functions
......@@ -122,32 +122,23 @@ public:
* For an ideal gas, this means \f$ R*T*c \f$.
* Unit: \f$\mathrm{[Pa] = [N/m^2]}\f$
*
* \param componentIdx the index of the component
* \param compIdx the index of the component
*/
Scalar partialPressure(int componentIdx) const
Scalar partialPressure(int compIdx) const
{
//! \bug non-wetting phase is not necessarily a gas phase
if(componentIdx==nCompIdx)
return pressure(nPhaseIdx)*moleFraction(nPhaseIdx, nCompIdx);
if(componentIdx == wCompIdx)
return pressure(nPhaseIdx)*moleFraction(nPhaseIdx, wCompIdx);
else
DUNE_THROW(Dune::NotImplemented, "component not found in fluidState!");
return 0.;
return partialPressure(nPhaseIdx, compIdx);
}
/*!
* \brief Return the partial pressure of a component in a phase.
*
* \param phaseIdx the index of the phase
* \param componentIdx the index of the component
* \param compIdx the index of the component
*/
Scalar partialPressure(int phaseIdx, int componentIdx) const
Scalar partialPressure(int phaseIdx, int compIdx) const
{
if(phaseIdx==nPhaseIdx)
return partialPressure(componentIdx);
else
DUNE_THROW(Dune::NotImplemented, "Not implemented for non-gaseous phases!");
assert(FluidSystem::isGas(phaseIdx));
return pressure(phaseIdx)*moleFraction(phaseIdx, compIdx);
}
/*!
......
......@@ -162,7 +162,10 @@ public:
* \brief The partial pressure of a component in a phase \f$\mathrm{[Pa]}\f$
*/
Scalar partialPressure(int phaseIdx, int compIdx) const
{ return moleFraction(phaseIdx, compIdx) * pressure(phaseIdx); }
{
assert(FluidSystem::isGas(phaseIdx));
return moleFraction(phaseIdx, compIdx) * pressure(phaseIdx);
}
/*!
* \brief The specific enthalpy of a fluid phase \f$\mathrm{[J/kg]}\f$
......@@ -311,7 +314,7 @@ public:
Valgrind::SetDefined(massFraction_[phaseIdx][compIdx]);
if (numComponents != 2)
DUNE_THROW(Dune::NotImplemented, "This currently only works for 2 components and for setting the mass fractions of the transported component.");
DUNE_THROW(Dune::NotImplemented, "This currently only works for 2 components.");
else
{
// calculate average molar mass of the gas phase
......@@ -343,19 +346,20 @@ public:
* to the current composition of the phase
*/
template <class FluidState>
void setRelativeHumidity(FluidState &fs, int phaseIdx, int compIdx, Scalar value)
void setRelativeHumidity(FluidState &fluidState, int phaseIdx, int compIdx, Scalar value)
{
Valgrind::CheckDefined(value);
if (numComponents != 2)
DUNE_THROW(Dune::NotImplemented, "This currently only works for 2 components and for setting the mass fractions of the transported component.");
else
{
Scalar moleFraction = value * FluidSystem::vaporPressure(fs, compIdx)
/ fs.pressure(phaseIdx);
fs.setMoleFraction(phaseIdx, compIdx, moleFraction);
fs.setMoleFraction(phaseIdx, 1-compIdx, 1-moleFraction);
}
// asserts for the assumption under which setting the relative humidity is possible
assert(phaseIdx == FluidSystem::nPhaseIdx);
assert(compIdx == FluidSystem::wCompIdx);
assert(numComponents == 2);
assert(FluidSystem::isGas(phaseIdx));
Scalar moleFraction = value * FluidSystem::vaporPressure(fluidState, FluidSystem::wCompIdx)
/ fluidState.pressure(phaseIdx);
fluidState.setMoleFraction(phaseIdx, FluidSystem::wCompIdx, moleFraction);
fluidState.setMoleFraction(phaseIdx, FluidSystem::nCompIdx, 1.0-moleFraction);
}
/*!
......
......@@ -159,21 +159,6 @@ public:
Scalar pressure(int phaseIdx) const
{ return pressure_[phaseIdx]; }
/*!
* \brief The partial pressure of a component in a phase \f$\mathrm{[Pa]}\f$
*
* To avoid numerical issues with code that assumes miscibility,
* we return a partial pressure of 0 for components which do not mix with
* the specified phase. Actually it is undefined.
*/
Scalar partialPressure(int phaseIdx, int compIdx) const
{
if (phaseIdx == compIdx)
return pressure(phaseIdx);
else
return 0;
}
/*!
* \brief The specific enthalpy of a fluid phase \f$\mathrm{[J/kg]}\f$
*/
......
......@@ -84,32 +84,23 @@ public:
* For an ideal gas, this means \f$ R*T*c \f$.
* Unit: \f$\mathrm{[Pa] = [N/m^2]}\f$
*
* \param componentIdx the index of the component
* \param compIdx the index of the component
*/
Scalar partialPressure(int componentIdx) const
Scalar partialPressure(int compIdx) const
{
//! \bug non-wetting phase is not necessarily a gas phase
if(componentIdx==nCompIdx)
return pressure(nPhaseIdx)*moleFraction(nPhaseIdx, nCompIdx);
if(componentIdx == wCompIdx)
return pressure(nPhaseIdx)*moleFraction(nPhaseIdx, wCompIdx);
else
DUNE_THROW(Dune::NotImplemented, "component not found in fluidState!");
return 0.;
return partialPressure(nPhaseIdx, compIdx);
}
/*!
* \brief Return the partial pressure of a component in a phase.
*
* \param phaseIdx the index of the phase
* \param componentIdx the index of the component
* \param compIdx the index of the component
*/
Scalar partialPressure(int phaseIdx, int componentIdx) const
Scalar partialPressure(int phaseIdx, int compIdx) const
{
if(phaseIdx==nPhaseIdx)
return partialPressure(componentIdx);
else
DUNE_THROW(Dune::NotImplemented, "Not implemented for non-gaseous phases!");
assert(FluidSystem::isGas(phaseIdx));
return pressure(phaseIdx)*moleFraction(phaseIdx, compIdx);
}
/*! \brief Returns the pressure of a fluid phase \f$\mathrm{[Pa]}\f$.
......
......@@ -130,6 +130,17 @@ public:
return phaseIdx != nPhaseIdx;
}
/*!
* \brief Return whether a phase is gaseous
*
* \param phaseIdx The index of the fluid phase to consider
*/
static bool isGas(int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
return phaseIdx == nPhaseIdx;
}
/*!
* \brief Returns true if and only if a fluid phase is assumed to
* be an ideal mixture.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment