28 #ifndef EWOMS_NCP_PRIMARY_VARIABLES_HH 29 #define EWOMS_NCP_PRIMARY_VARIABLES_HH 36 #include <opm/material/constraintsolvers/NcpFlash.hpp> 37 #include <opm/material/fluidstates/CompositionalFluidState.hpp> 38 #include <opm/material/densead/Math.hpp> 40 #include <dune/common/fvector.hh> 53 template <
class TypeTag>
58 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
59 typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
60 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
61 typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
62 typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
64 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
65 enum { pressure0Idx = Indices::pressure0Idx };
66 enum { saturation0Idx = Indices::saturation0Idx };
67 enum { fugacity0Idx = Indices::fugacity0Idx };
71 typedef Dune::FieldVector<Scalar, numComponents> ComponentVector;
76 typedef Opm::NcpFlash<Scalar, FluidSystem> NcpFlash;
77 typedef Opm::MathToolbox<Evaluation> Toolbox;
99 template <
class Flu
idState>
101 const MaterialLawParams& matParams,
102 bool isInEquilibrium =
false)
104 typedef Opm::MathToolbox<typename FluidState::Scalar> FsToolbox;
108 for (
unsigned phaseIdx = 1; phaseIdx < numPhases; ++phaseIdx) {
109 assert(fluidState.temperature(0) == fluidState.temperature(phaseIdx));
115 if (isInEquilibrium) {
122 typename FluidSystem::template ParameterCache<Scalar> paramCache;
123 Opm::CompositionalFluidState<Scalar, FluidSystem> fsFlash;
127 fsFlash.assign(fluidState);
130 paramCache.updateAll(fsFlash);
131 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
132 Scalar rho = FluidSystem::density(fsFlash, paramCache, phaseIdx);
133 fsFlash.setDensity(phaseIdx, rho);
137 ComponentVector globalMolarities(0.0);
138 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
139 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
140 globalMolarities[compIdx] +=
141 FsToolbox::value(fsFlash.saturation(phaseIdx))
142 * FsToolbox::value(fsFlash.molarity(phaseIdx, compIdx));
147 NcpFlash::template solve<MaterialLaw>(fsFlash, matParams, paramCache, globalMolarities);
156 template <
class Flu
idState>
157 void assignNaive(
const FluidState& fluidState,
unsigned refPhaseIdx = 0)
159 typedef Opm::MathToolbox<typename FluidState::Scalar> FsToolbox;
163 EnergyModule::setPriVarTemperatures(*
this, fluidState);
166 typename FluidSystem::template ParameterCache<Scalar> paramCache;
167 paramCache.updatePhase(fluidState, refPhaseIdx);
168 Scalar pRef = FsToolbox::value(fluidState.pressure(refPhaseIdx));
169 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
173 FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fluidState,
177 (*this)[fugacity0Idx + compIdx] =
178 fugCoeff*fluidState.moleFraction(refPhaseIdx, compIdx)*pRef;
182 (*this)[pressure0Idx] = FsToolbox::value(fluidState.pressure(0));
185 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx)
186 (*
this)[saturation0Idx + phaseIdx] = FsToolbox::value(fluidState.saturation(phaseIdx));
void assignNaive(const FluidState &fluidState, unsigned refPhaseIdx=0)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: ncpprimaryvariables.hh:157
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &matParams, bool isInEquilibrium=false)
Set the primary variables from an arbitrary fluid state in a mass conservative way.
Definition: ncpprimaryvariables.hh:100
Definition: baseauxiliarymodule.hh:37
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:59
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...
NcpPrimaryVariables(Scalar value)
Constructor with assignment from scalar.
Definition: ncpprimaryvariables.hh:86
Represents the primary variables used by the compositional multi-phase NCP model. ...
Definition: ncpprimaryvariables.hh:54
Declares the properties required for the NCP compositional multi-phase model.
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:48
Represents the primary variables used by the a model.