13#ifndef DUMUX_COMPOSITIONAL_FLASH_HH
14#define DUMUX_COMPOSITIONAL_FLASH_HH
16#include <dune/common/fvector.hh>
37template <
class Scalar,
class Flu
idSystem>
42 enum { numPhases = FluidSystem::numPhases,
43 numComponents = FluidSystem::numComponents
47 phase0Idx = FluidSystem::phase0Idx,
48 phase1Idx = FluidSystem::phase1Idx,
49 comp0Idx = FluidSystem::comp0Idx,
50 comp1Idx = FluidSystem::comp1Idx
78 template<
class Flu
idState>
87 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
88 assert(FluidSystem::isIdealMixture(phaseIdx));
95 fluidState.setPressure(phase0Idx, phasePressure[phase0Idx]);
96 fluidState.setPressure(phase1Idx, phasePressure[phase1Idx]);
99 const Scalar k10 = FluidSystem::fugacityCoefficient(fluidState, phase0Idx, comp0Idx) * fluidState.pressure(phase0Idx)
100 / (FluidSystem::fugacityCoefficient(fluidState, phase1Idx, comp0Idx) * fluidState.pressure(phase1Idx));
101 const Scalar k11 = FluidSystem::fugacityCoefficient(fluidState, phase0Idx, comp1Idx) * fluidState.pressure(phase0Idx)
102 / (FluidSystem::fugacityCoefficient(fluidState, phase1Idx, comp1Idx) * fluidState.pressure(phase1Idx));
105 fluidState.setMoleFraction(phase0Idx, comp0Idx, ((1. - k11) / (k10 - k11)));
106 fluidState.setMoleFraction(phase1Idx, comp0Idx, (fluidState.moleFraction(phase0Idx,comp0Idx) * k10));
107 fluidState.setMoleFraction(phase0Idx, comp1Idx, 1.0 - fluidState.moleFraction(phase0Idx,comp0Idx));
108 fluidState.setMoleFraction(phase1Idx, comp1Idx, 1.0 - fluidState.moleFraction(phase1Idx,comp0Idx));
111 const Scalar K10 = fluidState.massFraction(phase1Idx, comp0Idx) / fluidState.massFraction(phase0Idx, comp0Idx);
112 const Scalar K11 = (1. - fluidState.massFraction(phase1Idx, comp0Idx)) / (1. - fluidState.massFraction(phase0Idx, comp0Idx));
115 const Scalar Nu0 = 1. + ((Z0 * (K10 - 1.)) + ((1. - Z0) * (K11 - 1.))) / ((K11 - 1.) * (K10 - 1.));
118 std::array<Scalar, 2> phaseMassFraction;
121 if (Nu0 > 0. && Nu0 < 1.)
122 phaseMassFraction[phase0Idx] = Nu0;
125 phaseMassFraction[phase0Idx] = 0.0;
126 fluidState.setMassFraction(phase1Idx,comp0Idx, Z0);
130 phaseMassFraction[phase0Idx] = 1.0;
131 fluidState.setMassFraction(phase0Idx, comp0Idx, Z0);
135 phaseMassFraction[phase1Idx] = 1.0 - phaseMassFraction[phase0Idx];
146 Scalar sw = phaseMassFraction[phase0Idx] / fluidState.density(phase0Idx);
147 sw /= (phaseMassFraction[phase0Idx] / fluidState.density(phase0Idx)
148 + phaseMassFraction[phase1Idx] / fluidState.density(phase1Idx));
149 fluidState.setSaturation(phase0Idx, sw);
150 fluidState.setSaturation(phase1Idx, 1.0-sw);
168 phasePressure,
const int presentPhaseIdx,
const Scalar&
temperature)
172 fluidState.
setPressure(phase0Idx, phasePressure[phase0Idx]);
173 fluidState.
setPressure(phase1Idx, phasePressure[phase1Idx]);
179 fluidState.
setMoleFraction(presentPhaseIdx, comp0Idx, Z0 / FluidSystem::molarMass(comp0Idx)
180 / (Z0 / FluidSystem::molarMass(comp0Idx) + (1. - Z0) / FluidSystem::molarMass(comp1Idx)));
183 fluidState.
massFraction(presentPhaseIdx, comp0Idx) * FluidSystem::molarMass(comp0Idx)
184 + fluidState.
massFraction(presentPhaseIdx, comp1Idx) * FluidSystem::molarMass(comp1Idx));
206 template<
class Flu
idState>
215 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
216 assert(FluidSystem::isIdealMixture(phaseIdx));
223 fluidState.setPressure(phase0Idx, phasePressure[phase0Idx]);
224 fluidState.setPressure(phase1Idx, phasePressure[phase1Idx]);
227 const Scalar k10 = FluidSystem::fugacityCoefficient(fluidState, phase0Idx, comp0Idx) * fluidState.pressure(phase0Idx)
228 / (FluidSystem::fugacityCoefficient(fluidState, phase1Idx, comp0Idx) * fluidState.pressure(phase1Idx));
229 const Scalar k11 = FluidSystem::fugacityCoefficient(fluidState, phase0Idx, comp1Idx) * fluidState.pressure(phase0Idx)
230 / (FluidSystem::fugacityCoefficient(fluidState, phase1Idx, comp1Idx) * fluidState.pressure(phase1Idx));
233 fluidState.setMoleFraction(phase0Idx,comp0Idx, ((1. - k11) / (k10 - k11)));
234 fluidState.setMoleFraction(phase1Idx,comp0Idx, (fluidState.moleFraction(phase0Idx,comp0Idx) * k10));
235 fluidState.setMoleFraction(phase0Idx, comp1Idx, 1.0 - fluidState.moleFraction(phase0Idx,comp0Idx));
236 fluidState.setMoleFraction(phase1Idx, comp1Idx, 1.0 - fluidState.moleFraction(phase1Idx,comp0Idx));
248 fluidState.setSaturation(phase0Idx,
saturation);
249 fluidState.setSaturation(phase1Idx, 1.0-
saturation);
Flash calculation routines for compositional sequential models.
Definition: compositionalflash.hh:39
static void saturationFlash2p2c(FluidState &fluidState, const Scalar saturation, const PhaseVector &phasePressure, const Scalar temperature)
Definition: compositionalflash.hh:207
Dune::FieldVector< Scalar, numComponents > ComponentVector
Definition: compositionalflash.hh:54
static void concentrationFlash1p2c(FluidState1p2c &fluidState, const Scalar &Z0, const Dune::FieldVector< Scalar, numPhases > phasePressure, const int presentPhaseIdx, const Scalar &temperature)
The simplest possible update routine for 1p2c "flash" calculations.
Definition: compositionalflash.hh:167
Dune::FieldVector< Scalar, numPhases > PhaseVector
Definition: compositionalflash.hh:55
static void concentrationFlash2p2c(FluidState &fluidState, const Scalar Z0, const PhaseVector &phasePressure, const Scalar temperature)
Definition: compositionalflash.hh:79
Container for compositional variables in a 1p2c situation.
Definition: pseudo1p2c.hh:32
void setAverageMolarMass(int phaseIdx, Scalar value)
Set the average molar mass of a fluid phase [kg/mol].
Definition: pseudo1p2c.hh:264
void setMassFraction(int phaseIdx, int compIdx, Scalar value)
Sets the mass fraction of a component in a phase.
Definition: pseudo1p2c.hh:204
void setPresentPhaseIdx(int phaseIdx)
Sets the phase Index that is present in this fluidState.
Definition: pseudo1p2c.hh:245
void setPressure(int phaseIdx, Scalar value)
Sets the phase pressure .
Definition: pseudo1p2c.hh:270
void setDensity(int phaseIdx, Scalar value)
Sets the density of a phase .
Definition: pseudo1p2c.hh:223
void setViscosity(int phaseIdx, Scalar value)
Sets the viscosity of a phase .
Definition: pseudo1p2c.hh:191
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: pseudo1p2c.hh:235
void setTemperature(Scalar value)
Sets the temperature.
Definition: pseudo1p2c.hh:253
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of component in fluid phase in .
Definition: pseudo1p2c.hh:109
void setMoleFraction(int phaseIdx, int compIdx, Scalar value)
Sets the molar fraction of a component in a fluid phase.
Definition: pseudo1p2c.hh:214
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string saturation(int phaseIdx) noexcept
I/O name of saturation for multiphase systems.
Definition: name.hh:31
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:62
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:71
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Calculates phase state for a single phase but two-component state.