A generic compositional multi-phase model using primary-variable switching. More...

#include <pvsmodel.hh>

Inheritance diagram for Ewoms::PvsModel< TypeTag >:
Inheritance graph

Public Member Functions

 PvsModel (Simulator &simulator)
 
std::string primaryVarName (int pvIdx) const
 Given an primary variable index, return a human readable name. More...
 
std::string eqName (int eqIdx) const
 Given an equation index, return a human readable name. More...
 
void updateFailed ()
 Called by the update() method if it was unsuccessful. This is primary a hook which the actual model can overload. More...
 
void updateBegin ()
 Called by the update() method before it tries to apply the newton method. This is primary a hook which the actual model can overload. More...
 
Scalar primaryVarWeight (int globalDofIdx, int pvIdx) const
 Returns the relative weight of a primary variable for calculating relative errors. More...
 
Scalar eqWeight (int globalDofIdx, int eqIdx) const
 Returns the relative weight of an equation. More...
 
void advanceTimeLevel ()
 Called by the problem if a time integration was successful, post processing of the solution is done and the result has been written to disk. More...
 
bool switched () const
 Return true if the primary variables were switched for at least one vertex after the last timestep. More...
 
template<class DofEntity >
void serializeEntity (std::ostream &outstream, const DofEntity &dofEntity)
 Write the current solution for a degree of freedom to a restart file. More...
 
template<class DofEntity >
void deserializeEntity (std::istream &instream, const DofEntity &dofEntity)
 Reads the current solution variables for a degree of freedom from a restart file. More...
 
void switchPrimaryVars_ ()
 
template<class FluidState >
void printSwitchedPhases_ (const ElementContext &elemCtx, int dofIdx, const FluidState &fs, int oldPhasePresence, const PrimaryVariables &newPv) const
 
void registerOutputModules_ ()
 
void finishInit ()
 Apply the initial conditions to the model. More...
 
bool phaseIsConsidered (int phaseIdx) const
 Returns true iff a fluid phase is used by the model. More...
 
void globalPhaseStorage (EqVector &storage, int phaseIdx)
 Compute the total storage inside one phase of all conservation quantities. More...
 

Static Public Member Functions

static void registerParameters ()
 Register all run-time parameters for the PVS compositional model. More...
 
static std::string name ()
 

Public Attributes

Scalar referencePressure_
 
int numSwitched_
 
int verbosity_
 

Detailed Description

template<class TypeTag>
class Ewoms::PvsModel< TypeTag >

A generic compositional multi-phase model using primary-variable switching.

This model assumes a flow of $M \geq 1$ fluid phases $\alpha$, each of which is assumed to be a mixture $N \geq M$ chemical species $\kappa$.

By default, the standard multi-phase Darcy approach is used to determine the velocity, i.e.

\[ \mathbf{v}_\alpha = - \frac{k_{r\alpha}}{\mu_\alpha} \mathbf{K} \left(\mathbf{grad}\, p_\alpha - \varrho_{\alpha} \mathbf{g} \right) \;, \]

although the actual approach which is used can be specified via the FluxModule property. For example, the velocity model can by changed to the Forchheimer approach by

The core of the model is the conservation mass of each component by means of the equation

\[ \sum_\alpha \frac{\partial\;\phi c_\alpha^\kappa S_\alpha }{\partial t} - \sum_\alpha \mathrm{div} \left\{ c_\alpha^\kappa \mathbf{v}_\alpha \right\} - q^\kappa = 0 \;. \]

To close the system mathematically, $M$ model equations are also required. This model uses the primary variable switching assumptions, which are given by:

\[ 0 \stackrel{!}{=} f_\alpha = \left\{ \begin{array}{cl} S_\alpha & \quad \text{if phase }\alpha\text{ is not present} \ \ 1 - \sum_\kappa x_\alpha^\kappa & \quad \text{else} \end{array} \right. \]

To make this approach applicable, a pseudo primary variable phase presence has to be introduced. Its purpose is to specify for each phase whether it is present or not. It is a pseudo primary variable because it is not directly considered when linearizing the system in the Newton method, but after each Newton iteration, it gets updated like the "real" primary variables. The following rules are used for this update procedure:

  • If phase $\alpha$ is present according to the pseudo primary variable, but $S_\alpha < 0$ after the Newton update, consider the phase $\alpha$ disappeared for the next iteration and use the set of primary variables which correspond to the new phase presence.
  • If phase $\alpha$ is not present according to the pseudo primary variable, but the sum of the component mole fractions in the phase is larger than 1, i.e. $\sum_\kappa x_\alpha^\kappa > 1$, consider the phase $\alpha$ present in the the next iteration and update the set of primary variables to make it consistent with the new phase presence.
  • In all other cases don't modify the phase presence for phase $\alpha$.

The model always requires $N$ primary variables, but their interpretation is dependent on the phase presence:

  • The first primary variable is always interpreted as the pressure of the phase with the lowest index $PV_0 = p_0$.

  • Then, $M - 1$ "switching primary variables" follow, which are interpreted depending in the presence of the first $M-1$ phases: If phase $\alpha$ is present, its saturation $S_\alpha = PV_i$ is used as primary variable; if it is not present, the mole fraction $PV_i = x_{\alpha^\star}^\alpha$ of the component with index $\alpha$ in the phase with the lowest index that is present $\alpha^\star$ is used instead.

  • Finally, the mole fractions of the $N-M$ components with the largest index in the phase with the lowest index that is present $x_{\alpha^\star}^\kappa$ are used as primary variables.

Constructor & Destructor Documentation

template<class TypeTag >
Ewoms::PvsModel< TypeTag >::PvsModel ( Simulator simulator)
inline

Member Function Documentation

template<class TypeTag >
void Ewoms::PvsModel< TypeTag >::advanceTimeLevel ( )
inline

Called by the problem if a time integration was successful, post processing of the solution is done and the result has been written to disk.

This should prepare the model for the next time integration.

References Ewoms::PvsModel< TypeTag >::numSwitched_.

template<class TypeTag >
template<class DofEntity >
void Ewoms::PvsModel< TypeTag >::deserializeEntity ( std::istream &  instream,
const DofEntity &  dofEntity 
)
inline

Reads the current solution variables for a degree of freedom from a restart file.

Parameters
instreamThe stream from which the vertex data should be deserialized from
dofThe Dune entity which's data should be deserialized
template<class TypeTag >
std::string Ewoms::PvsModel< TypeTag >::eqName ( int  eqIdx) const
inline

Given an equation index, return a human readable name.

Parameters
eqIdxThe index of the conservation equation of interest.
template<class TypeTag >
Scalar Ewoms::PvsModel< TypeTag >::eqWeight ( int  globalDofIdx,
int  eqIdx 
) const
inline

Returns the relative weight of an equation.

Parameters
globalVertexIdxThe global index of the vertex
eqIdxThe index of the equation
template<class TypeTag >
void Ewoms::MultiPhaseBaseModel< TypeTag >::finishInit ( )
inlineinherited

Apply the initial conditions to the model.

References EWOMS_GET_PARAM.

Referenced by Ewoms::BlackOilModel< TypeTag >::finishInit(), and Ewoms::NcpModel< TypeTag >::finishInit().

template<class TypeTag >
void Ewoms::MultiPhaseBaseModel< TypeTag >::globalPhaseStorage ( EqVector &  storage,
int  phaseIdx 
)
inlineinherited

Compute the total storage inside one phase of all conservation quantities.

Parameters
storageStores the total amount of each conserved quantity inside the domain.
phaseIdxThe index of the fluid phase of interest.

References Ewoms::ThreadedEntityIterator< GridView, codim >::beginParallel(), Ewoms::ThreadedEntityIterator< GridView, codim >::increment(), Ewoms::ThreadedEntityIterator< GridView, codim >::isFinished(), Ewoms::ThreadManager< TypeTag >::threadId(), and OmpMutex::unlock().

template<class TypeTag >
static std::string Ewoms::PvsModel< TypeTag >::name ( )
inlinestatic

template<class TypeTag >
bool Ewoms::MultiPhaseBaseModel< TypeTag >::phaseIsConsidered ( int  phaseIdx) const
inlineinherited

Returns true iff a fluid phase is used by the model.

Parameters
phaseIdxThe index of the fluid phase in question
template<class TypeTag >
std::string Ewoms::PvsModel< TypeTag >::primaryVarName ( int  pvIdx) const
inline

Given an primary variable index, return a human readable name.

Parameters
pvIdxThe index of the primary variable of interest.
template<class TypeTag >
Scalar Ewoms::PvsModel< TypeTag >::primaryVarWeight ( int  globalDofIdx,
int  pvIdx 
) const
inline

Returns the relative weight of a primary variable for calculating relative errors.

Parameters
globalDofIdxThe global index of the degree of freedom
pvIdxThe index of the primary variable

References GET_PROP_VALUE, and Ewoms::PvsModel< TypeTag >::referencePressure_.

template<class TypeTag >
template<class FluidState >
void Ewoms::PvsModel< TypeTag >::printSwitchedPhases_ ( const ElementContext &  elemCtx,
int  dofIdx,
const FluidState &  fs,
int  oldPhasePresence,
const PrimaryVariables &  newPv 
) const
inline
template<class TypeTag >
void Ewoms::PvsModel< TypeTag >::registerOutputModules_ ( )
inline
template<class TypeTag >
template<class DofEntity >
void Ewoms::PvsModel< TypeTag >::serializeEntity ( std::ostream &  outstream,
const DofEntity &  dofEntity 
)
inline

Write the current solution for a degree of freedom to a restart file.

Parameters
outstreamThe stream into which the vertex data should be serialized to
dofThe Dune entity which's data should be serialized
template<class TypeTag >
bool Ewoms::PvsModel< TypeTag >::switched ( ) const
inline

Return true if the primary variables were switched for at least one vertex after the last timestep.

References Ewoms::PvsModel< TypeTag >::numSwitched_.

template<class TypeTag >
void Ewoms::PvsModel< TypeTag >::updateBegin ( )
inline

Called by the update() method before it tries to apply the newton method. This is primary a hook which the actual model can overload.

References Ewoms::PvsModel< TypeTag >::referencePressure_.

template<class TypeTag >
void Ewoms::PvsModel< TypeTag >::updateFailed ( )
inline

Called by the update() method if it was unsuccessful. This is primary a hook which the actual model can overload.

References Ewoms::PvsModel< TypeTag >::numSwitched_.

Member Data Documentation

template<class TypeTag >
Scalar Ewoms::PvsModel< TypeTag >::referencePressure_
mutable
template<class TypeTag >
int Ewoms::PvsModel< TypeTag >::verbosity_

The documentation for this class was generated from the following file: