flashcompositionstep.hh File Reference
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
Include dependency graph for flashcompositionstep.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Opm
 
namespace  Opm::detail
 

Functions

template<class Scalar , std::size_t numComponents>
void Opm::detail::keepCompositionFloor (std::array< Scalar, numComponents > &z, const Scalar compositionFloor)
 
template<class Scalar , std::size_t numComponents>
Scalar Opm::detail::largestAmountChange (const Scalar share, const std::array< Scalar, numComponents > &z, const Scalar otherShare, const std::array< Scalar, numComponents > &otherZ)
 Largest change of the hydrocarbon share h or of an amount h z between two states. More...
 
template<class Scalar , std::size_t numComponents>
void Opm::detail::shortenStep (std::array< Scalar, numComponents > &z, Scalar &sw, const std::array< Scalar, numComponents > &newZ, const Scalar newShare, const Scalar compositionFloor, const Scalar hydrocarbonFloor, const Scalar maxAmountChange)
 
template<class Scalar , std::size_t numComponents>
void Opm::applyFlashCompositionStep (std::array< Scalar, numComponents > &z, Scalar &sw, const std::array< Scalar, numComponents > &dz, const Scalar dSw, const Scalar compositionFloor, const Scalar hydrocarbonFloor, const Scalar maxAmountChange)
 Applies a Newton step to the overall composition and the water saturation. More...
 

Detailed Description

Applies a Newton step to the overall composition and the water saturation.

The step is taken and limited in h and the component amounts h z, where h = max(1 - Sw, hydrocarbonFloor) is the regularized hydrocarbon share of the pore space. Component-storage derivatives scale with h, so Newton steps in the mole fractions can become large in cells containing almost only water. Where h ends at its floor, the hydrocarbon has vanished and z is kept, since the equations no longer determine it.

The returned fractions sum to one and are at or above compositionFloor, and Sw stays within [0, 1]. Changes in h and each h z are limited to maxAmountChange. If restoring an input state to these bounds requires a larger change, restoring the bounds takes priority.

Parameters
zOverall mole fractions, summing to one, updated in place; zeros are allowed.
swWater saturation, updated in place; zero without water.
dzNewton step of the mole fractions, summing to zero.
dSwNewton step of the water saturation; zero without water.
compositionFloorLower bound of every mole fraction.
hydrocarbonFloorLower bound of h.
maxAmountChangeLargest change of h and of every amount.
Precondition
Inputs are finite, 0 <= numComponents * compositionFloor < 1, 0 < hydrocarbonFloor <= 1, and maxAmountChange > 0.