本文整理汇总了C++中FluidState类的典型用法代码示例。如果您正苦于以下问题:C++ FluidState类的具体用法?C++ FluidState怎么用?C++ FluidState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FluidState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dRelativePermeabilities_dSaturation
static void dRelativePermeabilities_dSaturation(ContainerT &values,
const Params ¶ms,
const FluidState &state,
int satPhaseIdx)
{
for (int krPhaseIdx = 0; krPhaseIdx < numPhases; ++krPhaseIdx)
values[krPhaseIdx] = 0.0;
// -> linear relation between 0 and 1, else constant
if (state.saturation(satPhaseIdx) >= 0 &&
state.saturation(satPhaseIdx) <= 1)
{
values[satPhaseIdx] = 1.0;
}
}
示例2: guessInitial
void guessInitial(FluidState& fluidState, unsigned phaseIdx)
{
if (phaseIdx == FluidSystem::gasPhaseIdx) {
fluidState.setMoleFraction(phaseIdx, FluidSystem::H2OIdx, 0.0);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C1Idx, 0.74785);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C3Idx, 0.0121364);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C6Idx, 0.00606028);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C10Idx, 0.00268136);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C15Idx, 0.000204256);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C20Idx, 8.78291e-06);
}
else if (phaseIdx == FluidSystem::oilPhaseIdx) {
fluidState.setMoleFraction(phaseIdx, FluidSystem::H2OIdx, 0.0);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C1Idx, 0.50);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C3Idx, 0.03);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C6Idx, 0.07);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C10Idx, 0.20);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C15Idx, 0.15);
fluidState.setMoleFraction(phaseIdx, FluidSystem::C20Idx, 0.05);
}
else {
assert(phaseIdx == FluidSystem::waterPhaseIdx);
}
}
示例3: solveIdealMix_
static void solveIdealMix_(FluidState &fluidState,
ParameterCache ¶mCache,
unsigned phaseIdx,
const ComponentVector &fugacities)
{
for (unsigned i = 0; i < numComponents; ++ i) {
const Evaluation& phi = FluidSystem::fugacityCoefficient(fluidState,
paramCache,
phaseIdx,
i);
const Evaluation& gamma = phi * fluidState.pressure(phaseIdx);
Valgrind::CheckDefined(phi);
Valgrind::CheckDefined(gamma);
Valgrind::CheckDefined(fugacities[i]);
fluidState.setFugacityCoefficient(phaseIdx, i, phi);
fluidState.setMoleFraction(phaseIdx, i, fugacities[i]/gamma);
};
paramCache.updatePhase(fluidState, phaseIdx);
const Evaluation& rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
fluidState.setDensity(phaseIdx, rho);
return;
}
示例4: guessInitial
static void guessInitial(FluidState &fluidState,
ParameterCache ¶mCache,
int phaseIdx,
const ComponentVector &fugVec)
{
if (FluidSystem::isIdealMixture(phaseIdx))
return;
// Pure component fugacities
for (int i = 0; i < numComponents; ++ i) {
//std::cout << f << " -> " << mutParams.fugacity(phaseIdx, i)/f << "\n";
fluidState.setMoleFraction(phaseIdx,
i,
1.0/numComponents);
}
}
示例5: krw
static Evaluation krw(const Params ¶ms, const FluidState &fluidState)
{
typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
typedef MathToolbox<Evaluation> Toolbox;
const Evaluation& Sw =
FsToolbox::template toLhs<Evaluation>(fluidState.saturation(wettingPhaseIdx));
// transformation to effective saturation
const Evaluation& Se = (Sw - params.Swr()) / (1-params.Swr());
// regularization
if(Se > 1.0) return 1.;
if(Se < 0.0) return 0.;
const Evaluation& r = 1. - Toolbox::pow(1 - Toolbox::pow(Se, 1/params.vgM()), params.vgM());
return Toolbox::sqrt(Se)*r*r;
}
示例6: krn
static Evaluation krn(const Params ¶ms, const FluidState &fs)
{
typedef Opm::SaturationOverlayFluidState<FluidState> OverlayFluidState;
static_assert(FluidState::numPhases == numPhases,
"The fluid state and the material law must exhibit the same "
"number of phases!");
OverlayFluidState overlayFs(fs);
for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
return EffLaw::template krn<OverlayFluidState, Evaluation>(params, overlayFs);
}
示例7: krg
static typename std::enable_if< (Traits::numPhases > 2), Evaluation>::type
krg(const Params& params, const FluidState& fs)
{
typedef Opm::SaturationOverlayFluidState<FluidState> OverlayFluidState;
static_assert(FluidState::numPhases == numPhases,
"The fluid state and the material law must exhibit the same "
"number of phases!");
OverlayFluidState overlayFs(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
overlayFs.setSaturation(phaseIdx,
effectiveSaturation(params,
fs.saturation(phaseIdx),
phaseIdx));
}
return EffLaw::template krg<OverlayFluidState, Evaluation>(params, overlayFs);
}
示例8: pcnw
static Evaluation pcnw(const Params ¶ms, const FluidState &fluidState)
{
typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
typedef MathToolbox<Evaluation> Toolbox;
const Evaluation& Sw =
FsToolbox::template toLhs<Evaluation>(fluidState.saturation(wettingPhaseIdx));
Evaluation Se = (Sw-params.Swr())/(1.-params.Snr());
Scalar PC_VG_REG = 0.01;
// regularization
if (Se<0.0)
Se=0.0;
if (Se>1.0)
Se=1.0;
if (Se>PC_VG_REG && Se<1-PC_VG_REG) {
Evaluation x = Toolbox::pow(Se,-1/params.vgM()) - 1.0;
x = Toolbox::pow(x, 1 - params.vgM());
return x/params.vgAlpha();
}
// value and derivative at regularization point
Scalar Se_regu;
if (Se<=PC_VG_REG)
Se_regu = PC_VG_REG;
else
Se_regu = 1.0 - PC_VG_REG;
const Evaluation& x = std::pow(Se_regu,-1/params.vgM())-1;
const Evaluation& pc = Toolbox::pow(x, 1/params.vgN())/params.vgAlpha();
const Evaluation& pc_prime =
Toolbox::pow(x,1/params.vgN()-1)
* std::pow(Se_regu, -1.0/params.vgM() - 1)
/ (-params.vgM())
/ params.vgAlpha()
/ (1-params.Snr()-params.Swr())
/ params.vgN();
// evaluate tangential
return ((Se-Se_regu)*pc_prime + pc)/params.betaNW();
}
示例9: density
static Scalar density(const FluidState &fluidState,
const ParameterCache ¶mCache,
int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
Scalar temperature = fluidState.temperature(phaseIdx);
Scalar pressure = fluidState.pressure(phaseIdx);
if (phaseIdx == lPhaseIdx) {
// use normalized composition for to calculate the density
// (the relations don't seem to take non-normalized
// compositions too well...)
Scalar xlBrine = std::min(1.0, std::max(0.0, fluidState.moleFraction(lPhaseIdx, BrineIdx)));
Scalar xlCO2 = std::min(1.0, std::max(0.0, fluidState.moleFraction(lPhaseIdx, CO2Idx)));
Scalar sumx = xlBrine + xlCO2;
xlBrine /= sumx;
xlCO2 /= sumx;
Scalar result = liquidDensity_(temperature,
pressure,
xlBrine,
xlCO2);
Valgrind::CheckDefined(result);
return result;
}
assert(phaseIdx == gPhaseIdx);
// use normalized composition for to calculate the density
// (the relations don't seem to take non-normalized
// compositions too well...)
Scalar xgBrine = std::min(1.0, std::max(0.0, fluidState.moleFraction(gPhaseIdx, BrineIdx)));
Scalar xgCO2 = std::min(1.0, std::max(0.0, fluidState.moleFraction(gPhaseIdx, CO2Idx)));
Scalar sumx = xgBrine + xgCO2;
xgBrine /= sumx;
xgCO2 /= sumx;
Scalar result = gasDensity_(temperature,
pressure,
xgBrine,
xgCO2);
Valgrind::CheckDefined(result);
return result;
}
示例10: heatConductivity
static Scalar heatConductivity(const Params ¶ms,
const FluidState &fluidState)
{
Valgrind::CheckDefined(params.vacuumLambda());
Scalar lambda = 0;
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
Valgrind::CheckDefined(params.fullySaturatedLambda(phaseIdx));
if (FluidSystem::isLiquid(phaseIdx)) {
lambda +=
regularizedSqrt_(std::max(0.0, std::min(1.0, fluidState.saturation(phaseIdx))))
* (params.fullySaturatedLambda(phaseIdx) - params.vacuumLambda());
}
else { // gas phase
lambda += params.fullySaturatedLambda(phaseIdx) - params.vacuumLambda();
}
};
lambda += params.vacuumLambda();
assert(lambda >= 0);
return lambda;
}
示例11: thermalConductivity
static Evaluation thermalConductivity(const Params& params,
const FluidState& fluidState)
{
Valgrind::CheckDefined(params.vacuumLambda());
Evaluation lambda = 0;
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
Valgrind::CheckDefined(params.fullySaturatedLambda(phaseIdx));
if (FluidSystem::isLiquid(phaseIdx)) {
const auto& sat = Opm::decay<Evaluation>(fluidState.saturation(phaseIdx));
lambda +=
regularizedSqrt_(Opm::max(0.0, Opm::min(1.0, sat)))
* (params.fullySaturatedLambda(phaseIdx) - params.vacuumLambda());
}
else { // gas phase
lambda += params.fullySaturatedLambda(phaseIdx) - params.vacuumLambda();
}
};
lambda += params.vacuumLambda();
assert(lambda >= 0);
return lambda;
}
示例12: viscosity
static LhsEval viscosity(const FluidState &fluidState,
const ParameterCache &/*paramCache*/,
unsigned phaseIdx)
{
typedef Opm::MathToolbox<LhsEval> LhsToolbox;
typedef Opm::MathToolbox<typename FluidState::Scalar> FsToolbox;
assert(0 <= phaseIdx && phaseIdx < numPhases);
const auto& T = FsToolbox::template toLhs<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = FsToolbox::template toLhs<LhsEval>(fluidState.pressure(phaseIdx));
if (phaseIdx == liquidPhaseIdx)
{
// assume pure water for the liquid phase
// TODO: viscosity of mixture
// couldn't find a way to solve the mixture problem
return H2O::liquidViscosity(T, p);
}
else if (phaseIdx == gasPhaseIdx)
{
if(!useComplexRelations){
return Air::gasViscosity(T, p);
}
else //using a complicated version of this fluid system
{
/* Wilke method. See:
*
* See: R. Reid, et al.: The Properties of Gases and Liquids,
* 4th edition, McGraw-Hill, 1987, 407-410 or
* 5th edition, McGraw-Hill, 2000, p. 9.21/22
*
*/
LhsEval muResult = 0;
const LhsEval mu[numComponents] = {
H2O::gasViscosity(T, H2O::vaporPressure(T)),
Air::gasViscosity(T, p)
};
// molar masses
const Scalar M[numComponents] = {
H2O::molarMass(),
Air::molarMass()
};
for (unsigned i = 0; i < numComponents; ++i) {
LhsEval divisor = 0;
for (unsigned j = 0; j < numComponents; ++j) {
LhsEval phiIJ =
1 +
LhsToolbox::sqrt(mu[i]/mu[j]) * // 1 + (mu[i]/mu[j]^1/2
std::pow(M[j]/M[i], 1./4.0); // (M[i]/M[j])^1/4
phiIJ *= phiIJ;
phiIJ /= std::sqrt(8*(1 + M[i]/M[j]));
divisor += FsToolbox::template toLhs<LhsEval>(fluidState.moleFraction(phaseIdx, j))*phiIJ;
}
const auto& xAlphaI = FsToolbox::template toLhs<LhsEval>(fluidState.moleFraction(phaseIdx, i));
muResult += xAlphaI*mu[i]/divisor;
}
return muResult;
}
}
OPM_THROW(std::logic_error, "Invalid phase index " << phaseIdx);
}
示例13: viscosity
static Scalar viscosity(const FluidState &fluidState,
const ParameterCache ¶mCache,
int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
Scalar T = fluidState.temperature(phaseIdx);
Scalar p = fluidState.pressure(phaseIdx);
if (phaseIdx == lPhaseIdx)
{
// assume pure water for the liquid phase
// TODO: viscosity of mixture
// couldn't find a way to solve the mixture problem
return H2O::liquidViscosity(T, p);
}
else if (phaseIdx == gPhaseIdx)
{
if(!useComplexRelations){
return Air::gasViscosity(T, p);
}
else //using a complicated version of this fluid system
{
/* Wilke method. See:
*
* See: R. Reid, et al.: The Properties of Gases and Liquids,
* 4th edition, McGraw-Hill, 1987, 407-410 or
* 5th edition, McGraw-Hill, 2000, p. 9.21/22
*
*/
Scalar muResult = 0;
const Scalar mu[numComponents] = {
H2O::gasViscosity(T,
H2O::vaporPressure(T)),
Air::gasViscosity(T, p)
};
// molar masses
const Scalar M[numComponents] = {
H2O::molarMass(),
Air::molarMass()
};
for (int i = 0; i < numComponents; ++i)
{
Scalar divisor = 0;
for (int j = 0; j < numComponents; ++j)
{
Scalar phiIJ = 1 + std::sqrt(mu[i]/mu[j]) * // 1 + (mu[i]/mu[j]^1/2
std::pow(M[j]/M[i], 1./4.0); // (M[i]/M[j])^1/4
phiIJ *= phiIJ;
phiIJ /= std::sqrt(8*(1 + M[i]/M[j]));
divisor += fluidState.moleFraction(phaseIdx, j)*phiIJ;
}
muResult += fluidState.moleFraction(phaseIdx, i)*mu[i] / divisor;
}
return muResult;
}
}
OPM_THROW(std::logic_error, "Invalid phase index " << phaseIdx);
}
示例14: density
static Scalar density(const FluidState &fluidState,
const ParameterCache ¶mCache,
int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
Scalar T = fluidState.temperature(phaseIdx);
Scalar p;
if (isCompressible(phaseIdx))
p = fluidState.pressure(phaseIdx);
else {
// random value which will hopefully cause things to blow
// up if it is used in a calculation!
p = - 1e100;
Valgrind::SetUndefined(p);
}
Scalar sumMoleFrac = 0;
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
sumMoleFrac += fluidState.moleFraction(phaseIdx, compIdx);
if (phaseIdx == lPhaseIdx)
{
if (!useComplexRelations)
// assume pure water
return H2O::liquidDensity(T, p);
else
{
// See: Ochs 2008 (2.6)
Scalar rholH2O = H2O::liquidDensity(T, p);
Scalar clH2O = rholH2O/H2O::molarMass();
return
clH2O
* (H2O::molarMass()*fluidState.moleFraction(lPhaseIdx, H2OIdx)
+
Air::molarMass()*fluidState.moleFraction(lPhaseIdx, AirIdx))
/ sumMoleFrac;
}
}
else if (phaseIdx == gPhaseIdx)
{
if (!useComplexRelations)
// for the gas phase assume an ideal gas
return
IdealGas::molarDensity(T, p)
* fluidState.averageMolarMass(gPhaseIdx)
/ std::max(1e-5, sumMoleFrac);
Scalar partialPressureH2O =
fluidState.moleFraction(gPhaseIdx, H2OIdx) *
fluidState.pressure(gPhaseIdx);
Scalar partialPressureAir =
fluidState.moleFraction(gPhaseIdx, AirIdx) *
fluidState.pressure(gPhaseIdx);
return
H2O::gasDensity(T, partialPressureH2O) +
Air::gasDensity(T, partialPressureAir);
}
OPM_THROW(std::logic_error, "Invalid phase index " << phaseIdx);
}
示例15: krn
static Evaluation krn(const Params& params, const FluidState& fs)
{
const Evaluation& Sw =
1.0 - Opm::decay<Evaluation>(fs.saturation(Traits::nonWettingPhaseIdx));
return twoPhaseSatKrn(params, Sw);
}