Commit 07a3c637 authored by Simon Scholz's avatar Simon Scholz Committed by Timo Koch
Browse files

[volVars] get molarDensity from fluidState

parent a2ffcf94
......@@ -141,6 +141,9 @@ public:
Scalar value = FluidSystem::density(fluidState, paramCache, fluidSystemPhaseIdx);
fluidState.setDensity(fluidSystemPhaseIdx, value);
value = FluidSystem::molarDensity(fluidState, paramCache, fluidSystemPhaseIdx);
fluidState.setMolarDensity(fluidSystemPhaseIdx, value);
value = FluidSystem::viscosity(fluidState, paramCache, fluidSystemPhaseIdx);
fluidState.setViscosity(fluidSystemPhaseIdx, value);
......
......@@ -96,6 +96,9 @@ public:
Scalar value = FluidSystem::density(fluidState, paramCache, fluidSystemPhaseIdx);
fluidState.setDensity(fluidSystemPhaseIdx, value);
value = FluidSystem::molarDensity(fluidState, paramCache, fluidSystemPhaseIdx);
fluidState.setMolarDensity(fluidSystemPhaseIdx, value);
value = FluidSystem::viscosity(fluidState, paramCache, fluidSystemPhaseIdx);
fluidState.setViscosity(fluidSystemPhaseIdx, value);
......
......@@ -122,6 +122,9 @@ public:
Scalar value = FluidSystem::density(fluidState, paramCache, /*phaseIdx=*/0);
fluidState.setDensity(/*phaseIdx=*/0, value);
value = FluidSystem::molarDensity(fluidState, paramCache, /*phaseIdx=*/0);
fluidState.setMolarDensity(/*phaseIdx=*/0, value);
value = FluidSystem::viscosity(fluidState, paramCache, /*phaseIdx=*/0);
fluidState.setViscosity(/*phaseIdx=*/0, value);
......
......@@ -169,9 +169,11 @@ public:
paramCache.updateAll(fluidState);
Scalar rho = FluidSystem::density(fluidState, paramCache, fluidSystemPhaseIdx);
Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, fluidSystemPhaseIdx);
Scalar mu = FluidSystem::viscosity(fluidState, paramCache, fluidSystemPhaseIdx);
fluidState.setDensity(fluidSystemPhaseIdx, rho);
fluidState.setMolarDensity(fluidSystemPhaseIdx, rhoMolar);
fluidState.setViscosity(fluidSystemPhaseIdx, mu);
// compute and set the enthalpy
......
......@@ -187,7 +187,9 @@ public:
// compute and set the density
Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx);
fluidState.setDensity(phaseIdx, rho);
fluidState.setMolarDensity(phaseIdx, rhoMolar);
// compute and set the enthalpy
Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
......@@ -252,6 +254,15 @@ public:
Scalar temperature() const
{ return fluidState_.temperature(/*phaseIdx=*/0); }
/*!
* \brief Returns the mass density of a given phase within the
* control volume in \f$[mol/m^3]\f$.
*
* \param phaseIdx The phase index
*/
Scalar molarDensity(const int phaseIdx) const
{ return fluidState_.molarDensity(phaseIdx); }
/*!
* \brief Returns the dynamic viscosity of the fluid within the
* control volume in \f$\mathrm{[Pa s]}\f$.
......
......@@ -204,11 +204,14 @@ public:
solidState.setTemperature(temperature);
// set the densities
const Scalar rhoW = FluidSystem::density(fluidState, wPhaseIdx);
const Scalar rhoG = FluidSystem::density(fluidState, nPhaseIdx);
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
{
Scalar rho = FluidSystem::density(fluidState, phaseIdx);
Scalar rhoMolar = FluidSystem::molarDensity(fluidState, phaseIdx);
fluidState.setDensity(wPhaseIdx, rhoW);
fluidState.setDensity(nPhaseIdx, rhoG);
fluidState.setDensity(phaseIdx, rho);
fluidState.setMolarDensity(phaseIdx, rhoMolar);
}
//get the viscosity and mobility
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
......@@ -266,7 +269,7 @@ public:
* \param phaseIdx The phase index
*/
Scalar molarDensity(const int phaseIdx) const
{ return fluidState_.density(phaseIdx) / fluidState_.averageMolarMass(phaseIdx); }
{ return fluidState_.molarDensity(phaseIdx); }
/*!
* \brief Returns the effective pressure of a given phase within
......
......@@ -385,6 +385,8 @@ public:
paramCache.updateComposition(fluidState, phaseIdx);
const Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
fluidState.setDensity(phaseIdx, rho);
Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx);
fluidState.setMolarDensity(phaseIdx, rhoMolar);
const Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
fluidState.setViscosity(phaseIdx,mu);
}
......@@ -461,7 +463,7 @@ public:
* \param phaseIdx The phase index
*/
Scalar molarDensity(const int phaseIdx) const
{ return fluidState_.density(phaseIdx) / fluidState_.averageMolarMass(phaseIdx); }
{ return fluidState_.molarDensity(phaseIdx); }
/*!
* \brief Returns the effective pressure of a given phase within
......
......@@ -329,10 +329,12 @@ public:
for (int phaseIdx = 0; phaseIdx < ModelTraits::numPhases(); ++phaseIdx)
{
Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx);
Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
fluidState.setDensity(phaseIdx, rho);
fluidState.setMolarDensity(phaseIdx, rhoMolar);
fluidState.setViscosity(phaseIdx, mu);
fluidState.setEnthalpy(phaseIdx, h);
}
......@@ -378,14 +380,18 @@ public:
{ return fluidState_.viscosity(phaseIdx); }
/*!
* \brief Returns the mass density of a given phase within the
* \brief Returns the molar density of a given phase within the
* control volume.
*
* \param phaseIdx The phase index
*/
Scalar molarDensity(int phaseIdx) const
{
return fluidState_.molarDensity(phaseIdx);
if (phaseIdx < ModelTraits::numPhases())
return fluidState_.molarDensity(phaseIdx);
else
DUNE_THROW(Dune::InvalidStateException, "Invalid phase index " << phaseIdx);
}
/*!
......
......@@ -178,7 +178,9 @@ public:
// compute and set the density
const Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
const Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx);
fluidState.setDensity(phaseIdx, rho);
fluidState.setMolarDensity(phaseIdx, rhoMolar);
// compute and set the enthalpy
const Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
......
......@@ -260,10 +260,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
}
else if (phasePresence == wPhaseOnly) {
......@@ -324,10 +330,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
}
else if (phasePresence == gnPhaseOnly) {
......@@ -439,10 +451,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
}
else if (phasePresence == wgPhaseOnly) {
......@@ -502,10 +520,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
}
else
......@@ -618,7 +642,7 @@ public:
* \param phaseIdx The phase index
*/
Scalar molarDensity(const int phaseIdx) const
{ return fluidState_.density(phaseIdx) / fluidState_.averageMolarMass(phaseIdx); }
{ return fluidState_.molarDensity(phaseIdx); }
/*!
* \brief Returns the effective pressure of a given phase within
......
......@@ -293,10 +293,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else if (phasePresence == wPhaseOnly) {
// only the water phase is present, water phase composition is
......@@ -330,10 +336,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else if (phasePresence == gnPhaseOnly) {
......@@ -358,10 +370,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else if (phasePresence == wnPhaseOnly) {
......@@ -390,10 +408,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else if (phasePresence == gPhaseOnly) {
// only the gas phase is present, gas phase composition is
......@@ -417,10 +441,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else if (phasePresence == wgPhaseOnly) {
// only water and gas phases are present
......@@ -448,10 +478,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else
assert(false); // unhandled phase state
......@@ -631,10 +667,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else if (phasePresence == wnPhaseOnly) {
// mole fractions of non-existing gas phase are used as switching criteria
......@@ -661,10 +703,16 @@ public:
Scalar rhoW = FluidSystem::density(fluidState_, wPhaseIdx);
Scalar rhoG = FluidSystem::density(fluidState_, gPhaseIdx);
Scalar rhoN = FluidSystem::density(fluidState_, nPhaseIdx);
Scalar rhoWMolar = FluidSystem::molarDensity(fluidState_, wPhaseIdx);
Scalar rhoGMolar = FluidSystem::molarDensity(fluidState_, gPhaseIdx);
Scalar rhoNMolar = FluidSystem::molarDensity(fluidState_, nPhaseIdx);
fluidState_.setDensity(wPhaseIdx, rhoW);
fluidState_.setDensity(gPhaseIdx, rhoG);
fluidState_.setDensity(nPhaseIdx, rhoN);
fluidState_.setMolarDensity(wPhaseIdx, rhoWMolar);
fluidState_.setMolarDensity(gPhaseIdx, rhoGMolar);
fluidState_.setMolarDensity(nPhaseIdx, rhoNMolar);
}
else DUNE_THROW(Dune::InvalidStateException, "phasePresence: " << phasePresence << " is invalid.");
}
......@@ -773,7 +821,7 @@ public:
* \param phaseIdx The phase index
*/
Scalar molarDensity(const int phaseIdx) const
{ return fluidState_.density(phaseIdx) / fluidState_.averageMolarMass(phaseIdx); }
{ return fluidState_.molarDensity(phaseIdx); }
/*!
* \brief Returns the effective pressure of a given phase within
......
......@@ -293,6 +293,8 @@ public:
paramCache.updateComposition(fluidState, phaseIdx);
const Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
fluidState.setDensity(phaseIdx, rho);
const Scalar rhoMolar = FluidSystem::molarDensity(fluidState, phaseIdx);
fluidState.setMolarDensity(phaseIdx, rhoMolar);
const Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
fluidState.setViscosity(phaseIdx,mu);
......
......@@ -748,6 +748,8 @@ public:
for(int phaseIdx=0; phaseIdx<numPhases(); ++phaseIdx){
const Scalar rho = FluidSystem::density(actualFluidState, paramCache, phaseIdx);
actualFluidState.setDensity(phaseIdx, rho);
const Scalar rhoMolar = FluidSystem::molarDensity(actualFluidState, paramCache, phaseIdx);
actualFluidState.setMolarDensity(phaseIdx, rhoMolar);
}
}
......
......@@ -205,9 +205,16 @@ public:
// density and viscosity
typename FluidSystem::ParameterCache paramCache;
paramCache.updateAll(fluidState);
fluidState.setDensity(FluidSystem::liquidPhaseIdx, FluidSystem::density(fluidState, paramCache, FluidSystem::liquidPhaseIdx));
fluidState.setDensity(FluidSystem::gasPhaseIdx, FluidSystem::density(fluidState, paramCache, FluidSystem::gasPhaseIdx));
fluidState.setViscosity(FluidSystem::liquidPhaseIdx, FluidSystem::viscosity(fluidState, paramCache, FluidSystem::liquidPhaseIdx));
fluidState.setDensity(FluidSystem::liquidPhaseIdx,
FluidSystem::density(fluidState, paramCache, FluidSystem::liquidPhaseIdx));
fluidState.setDensity(FluidSystem::gasPhaseIdx,
FluidSystem::density(fluidState, paramCache, FluidSystem::gasPhaseIdx));
fluidState.setMolarDensity(FluidSystem::liquidPhaseIdx,
FluidSystem::molarDensity(fluidState, paramCache, FluidSystem::liquidPhaseIdx));
fluidState.setMolarDensity(FluidSystem::gasPhaseIdx,
FluidSystem::molarDensity(fluidState, paramCache, FluidSystem::gasPhaseIdx));
fluidState.setViscosity(FluidSystem::liquidPhaseIdx,
FluidSystem::viscosity(fluidState, paramCache, FluidSystem::liquidPhaseIdx));
// compute and set the enthalpy
fluidState.setEnthalpy(FluidSystem::liquidPhaseIdx, EnergyVolVars::enthalpy(fluidState, paramCache, FluidSystem::liquidPhaseIdx));
......
......@@ -179,6 +179,7 @@ public:
typename FluidSystem::ParameterCache paramCache;
paramCache.updateAll(fluidState);
fluidState.setDensity(fluidSystemPhaseIdx, FluidSystem::density(fluidState, paramCache, fluidSystemPhaseIdx));
fluidState.setMolarDensity(fluidSystemPhaseIdx, FluidSystem::molarDensity(fluidState, paramCache, fluidSystemPhaseIdx));
fluidState.setViscosity(fluidSystemPhaseIdx, FluidSystem::viscosity(fluidState, paramCache, fluidSystemPhaseIdx));
// compute and set the enthalpy
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment