26 #ifndef EWOMS_NCP_PRIMARY_VARIABLES_HH
27 #define EWOMS_NCP_PRIMARY_VARIABLES_HH
34 #include <opm/material/constraintsolvers/NcpFlash.hpp>
35 #include <opm/material/fluidstates/CompositionalFluidState.hpp>
37 #include <dune/common/fvector.hh>
50 template <
class TypeTag>
55 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
56 typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
57 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
58 typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
59 typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
61 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
62 enum { pressure0Idx = Indices::pressure0Idx };
63 enum { saturation0Idx = Indices::saturation0Idx };
64 enum { fugacity0Idx = Indices::fugacity0Idx };
68 typedef Dune::FieldVector<Scalar, numComponents> ComponentVector;
73 typedef Opm::NcpFlash<Scalar, FluidSystem> NcpFlash;
74 typedef Opm::MathToolbox<Evaluation> Toolbox;
96 template <
class Flu
idState>
98 const MaterialLawParams &matParams,
99 bool isInEquilibrium =
false)
103 for (
int phaseIdx = 1; phaseIdx < numPhases; ++phaseIdx) {
104 assert(fluidState.temperature(0) == fluidState.temperature(phaseIdx));
110 if (isInEquilibrium) {
117 typename FluidSystem::ParameterCache paramCache;
118 Opm::CompositionalFluidState<Scalar, FluidSystem> fsFlash;
121 ComponentVector globalMolarities(0.0);
122 for (
int compIdx = 0; compIdx < numComponents; ++compIdx) {
123 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
124 globalMolarities[compIdx] +=
125 fluidState.saturation(phaseIdx) * fluidState.molarity(phaseIdx, compIdx);
131 fsFlash.assign(fluidState);
135 NcpFlash::template solve<MaterialLaw>(fsFlash, paramCache, matParams, globalMolarities);
144 template <
class Flu
idState>
149 EnergyModule::setPriVarTemperatures(*
this, fluidState);
152 for (
int compIdx = 0; compIdx < numComponents; ++compIdx) {
153 (*this)[fugacity0Idx + compIdx] = fluidState.fugacity(0, compIdx);
157 (*this)[pressure0Idx] = fluidState.pressure(0);
160 for (
int phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx)
161 (*
this)[saturation0Idx + phaseIdx] = fluidState.saturation(phaseIdx);
Represents the primary variables used by the a model.
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: ncpprimaryvariables.hh:145
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:41
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:54
Definition: baseauxiliarymodule.hh:35
NcpPrimaryVariables(Scalar value)
Constructor with assignment from scalar.
Definition: ncpprimaryvariables.hh:83
NcpPrimaryVariables()
Definition: ncpprimaryvariables.hh:77
NcpPrimaryVariables(const NcpPrimaryVariables &value)
Default constructor.
Definition: ncpprimaryvariables.hh:90
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:97
Declares the properties required for the NCP compositional multi-phase model.
Represents the primary variables used by the compositional multi-phase NCP model. ...
Definition: ncpprimaryvariables.hh:51
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...