Skip to content
Snippets Groups Projects
Commit 0187cc2b authored by Johannes Hommel's avatar Johannes Hommel Committed by Kilian Weishaupt
Browse files

[2pncmin] deprecated the +- duplicate special 2pncmin constraintsolvers

(cherry picked from commit 86941f78)
parent cf3f4568
No related branches found
No related tags found
2 merge requests!617[WIP] Next,!363Cleanup/2pnc 2pncmin models next
...@@ -39,108 +39,113 @@ namespace Dumux { ...@@ -39,108 +39,113 @@ namespace Dumux {
* fugacities in a phase. * fugacities in a phase.
*/ */
template <class Scalar, class FluidSystem> template <class Scalar, class FluidSystem>
class CompositionFromFugacities2pncmin class DUNE_DEPRECATED_MSG("CompositionFromFugacities2pncmin is deprecated. Use CompositionFromFugacities2pnc instead.")
{ CompositionFromFugacities2pncmin
enum { : public CompositionFromFugacities2pnc<Scalar, FluidSystem>
numComponents = FluidSystem::numComponents, { };
numMajorComponents = FluidSystem::numPhases // template <class Scalar, class FluidSystem>
}; // class CompositionFromFugacities2pncmin
// {
typedef typename FluidSystem::ParameterCache ParameterCache; // enum {
// numComponents = FluidSystem::numComponents,
// numMajorComponents = FluidSystem::numPhases
public: // };
typedef Dune::FieldVector<Scalar, numComponents> ComponentVector; //
// typedef typename FluidSystem::ParameterCache ParameterCache;
/*! //
* \brief Guess an initial value for the composition of the phase. //
* \param fluidState Thermodynamic state of the fluids // public:
* \param paramCache Container for cache parameters // typedef Dune::FieldVector<Scalar, numComponents> ComponentVector;
* \param phaseIdx The phase index //
* \param phasePresence The presence index of the reference phase // /*!
* \param fugVec fugacity vector of the component // * \brief Guess an initial value for the composition of the phase.
*/ // * \param fluidState Thermodynamic state of the fluids
template <class FluidState> // * \param paramCache Container for cache parameters
static void guessInitial(FluidState &fluidState, // * \param phaseIdx The phase index
ParameterCache &paramCache, // * \param phasePresence The presence index of the reference phase
int phaseIdx, // * \param fugVec fugacity vector of the component
int phasePresence, // */
const ComponentVector &fugVec) // template <class FluidState>
{ // static void guessInitial(FluidState &fluidState,
if (FluidSystem::isIdealMixture(phaseIdx)) // ParameterCache &paramCache,
return; // int phaseIdx,
// int phasePresence,
// Pure component fugacities // const ComponentVector &fugVec)
for (int i = 0; i < numComponents; ++ i) // {
{ // if (FluidSystem::isIdealMixture(phaseIdx))
fluidState.setMoleFraction(phaseIdx,i, 1.0/numComponents); // return;
} //
} // // Pure component fugacities
// for (int i = 0; i < numComponents; ++ i)
/*! // {
* \brief Calculates the chemical equilibrium from the component // fluidState.setMoleFraction(phaseIdx,i, 1.0/numComponents);
* fugacities in a phase. This constraint solver is developed for drying scenarios where // }
* salt component is restricted to liquid phase and still for the sake for equilibrium // }
* calculation some residual salt must be considered in the gas phase. In such cases for //
* existence of gas phase only, in the theoretical liquid phase, we set the mole fraction // /*!
* of salt to 1e-10. // * \brief Calculates the chemical equilibrium from the component
* \param fluidState Thermodynamic state of the fluids // * fugacities in a phase. This constraint solver is developed for drying scenarios where
* \param paramCache Container for cache parameters // * salt component is restricted to liquid phase and still for the sake for equilibrium
* \param phaseIdx The phase index // * calculation some residual salt must be considered in the gas phase. In such cases for
* \param targetFug target fugacity // * existence of gas phase only, in the theoretical liquid phase, we set the mole fraction
* \param phasePresence Presence of the phase // * of salt to 1e-10.
* // * \param fluidState Thermodynamic state of the fluids
* The phase's fugacities must already be set. // * \param paramCache Container for cache parameters
*/ // * \param phaseIdx The phase index
template <class FluidState> // * \param targetFug target fugacity
static void solve(FluidState &fluidState, // * \param phasePresence Presence of the phase
ParameterCache &paramCache, // *
int phaseIdx, // * The phase's fugacities must already be set.
int phasePresence, // */
const ComponentVector &targetFug) // template <class FluidState>
{ // static void solve(FluidState &fluidState,
// use a much more efficient method in case the phase is an // ParameterCache &paramCache,
// ideal mixture // int phaseIdx,
if (FluidSystem::isIdealMixture(phaseIdx)) // int phasePresence,
{ // const ComponentVector &targetFug)
solveIdealMix_(fluidState, paramCache, phaseIdx, phasePresence, targetFug); // {
return; // // use a much more efficient method in case the phase is an
} // // ideal mixture
else // if (FluidSystem::isIdealMixture(phaseIdx))
DUNE_THROW(NumericalProblem, "This constraint solver is not tested for non-ideal mixtures: Please refer computefromfugacities.hh for details" ); // {
} // solveIdealMix_(fluidState, paramCache, phaseIdx, phasePresence, targetFug);
// return;
protected: // }
// update the phase composition in case the phase is an ideal // else
// mixture, i.e. the component's fugacity coefficients are // DUNE_THROW(NumericalProblem, "This constraint solver is not tested for non-ideal mixtures: Please refer computefromfugacities.hh for details" );
// independent of the phase's composition. // }
template <class FluidState> //
static void solveIdealMix_(FluidState &fluidState, // protected:
ParameterCache &paramCache, // // update the phase composition in case the phase is an ideal
int phaseIdx, // // mixture, i.e. the component's fugacity coefficients are
int phasePresence, // // independent of the phase's composition.
const ComponentVector &fugacities) // template <class FluidState>
{ // static void solveIdealMix_(FluidState &fluidState,
for (int i = 0; i < numComponents; ++ i) // ParameterCache &paramCache,
{ // int phaseIdx,
Scalar phi = FluidSystem::fugacityCoefficient(fluidState, // int phasePresence,
paramCache, // const ComponentVector &fugacities)
phaseIdx, // {
i); // for (int i = 0; i < numComponents; ++ i)
Scalar gamma = phi * fluidState.pressure(phaseIdx); // {
fluidState.setFugacityCoefficient(phaseIdx, i, phi); // Scalar phi = FluidSystem::fugacityCoefficient(fluidState,
fluidState.setMoleFraction(phaseIdx, i, fugacities[i]/gamma); // paramCache,
// Special situation for drying PM and n-phase only situation.set the mole fraction of salt to 1e-10. // phaseIdx,
if (phaseIdx == 0 && i >= numMajorComponents && phasePresence == 2 /*nPhaseOnly*/) // i);
fluidState.setMoleFraction(phaseIdx, i, 1.0e-10); // Scalar gamma = phi * fluidState.pressure(phaseIdx);
} // fluidState.setFugacityCoefficient(phaseIdx, i, phi);
// fluidState.setMoleFraction(phaseIdx, i, fugacities[i]/gamma);
paramCache.updatePhase(fluidState, phaseIdx); // // Special situation for drying PM and n-phase only situation.set the mole fraction of salt to 1e-10.
// if (phaseIdx == 0 && i >= numMajorComponents && phasePresence == 2 /*nPhaseOnly*/)
Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx); // fluidState.setMoleFraction(phaseIdx, i, 1.0e-10);
fluidState.setDensity(phaseIdx, rho); // }
return; //
} // paramCache.updatePhase(fluidState, phaseIdx);
//
// Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
// fluidState.setDensity(phaseIdx, rho);
// return;
// }
}; };
template <class Scalar, class FluidSystem> template <class Scalar, class FluidSystem>
......
...@@ -29,8 +29,10 @@ ...@@ -29,8 +29,10 @@
#ifndef DUMUX_COMPUTE_FROM_REFERENCE_PHASE_2PNCMIN_HH #ifndef DUMUX_COMPUTE_FROM_REFERENCE_PHASE_2PNCMIN_HH
#define DUMUX_COMPUTE_FROM_REFERENCE_PHASE_2PNCMIN_HH #define DUMUX_COMPUTE_FROM_REFERENCE_PHASE_2PNCMIN_HH
#include <dumux/material/constraintsolvers/compositionfromfugacities2pncmin.hh> #include <dumux/material/constraintsolvers/compositionfromfugacities.hh>
#include "computefromreferencephase.hh"
#include <dune/common/deprecated.hh>
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
...@@ -66,112 +68,117 @@ namespace Dumux { ...@@ -66,112 +68,117 @@ namespace Dumux {
* - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases * - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases
*/ */
template <class Scalar, class FluidSystem> template <class Scalar, class FluidSystem>
class ComputeFromReferencePhase2pNCMin class DUNE_DEPRECATED_MSG("ComputeFromReferencePhase2pNCMin is deprecated. Use ComputeFromReferencePhase instead.")
{ ComputeFromReferencePhase2pNCMin
enum { numPhases = FluidSystem::numPhases }; : public ComputeFromReferencePhase<Scalar, FluidSystem>
enum { numComponents = FluidSystem::numComponents }; { };
typedef Dumux::compositionFromFugacities2pncmin<Scalar, FluidSystem> compositionFromFugacities2pncmin; // template <class Scalar, class FluidSystem>
typedef Dune::FieldVector<Scalar, numComponents> ComponentVector; // class ComputeFromReferencePhase2pNCMin
// {
public: // enum { numPhases = FluidSystem::numPhases };
/*! // enum { numComponents = FluidSystem::numComponents };
* \brief Computes all quantities of a generic fluid state if a // typedef Dumux::compositionFromFugacities2pncmin<Scalar, FluidSystem> compositionFromFugacities2pncmin;
* reference phase has been specified. // typedef Dune::FieldVector<Scalar, numComponents> ComponentVector;
* //
* This makes it is possible to specify just one phase and let the // public:
* remaining ones be calculated by the constraint solver. This // /*!
* constraint solver assumes thermodynamic equilibrium. It assumes the // * \brief Computes all quantities of a generic fluid state if a
* following quantities to be set: // * reference phase has been specified.
* // *
* - composition (mole+mass fractions) of the *reference* phase // * This makes it is possible to specify just one phase and let the
* - temperature of the *all* phases // * remaining ones be calculated by the constraint solver. This
* - saturations of *all* phases // * constraint solver assumes thermodynamic equilibrium. It assumes the
* - pressures of *all* phases // * following quantities to be set:
* // *
* after calling the solve() method the following quantities are // * - composition (mole+mass fractions) of the *reference* phase
* calculated in addition: // * - temperature of the *all* phases
* // * - saturations of *all* phases
* - temperature of *all* phases // * - pressures of *all* phases
* - density, molar density, molar volume of *all* phases // *
* - composition in mole and mass fractions and molaries of *all* phases // * after calling the solve() method the following quantities are
* - mean molar masses of *all* phases // * calculated in addition:
* - fugacity coefficients of *all* components in *all* phases // *
* - if the setViscosity parameter is true, also dynamic viscosities of *all* phases // * - temperature of *all* phases
* - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases // * - density, molar density, molar volume of *all* phases
* // * - composition in mole and mass fractions and molaries of *all* phases
* \param fluidState Thermodynamic state of the fluids // * - mean molar masses of *all* phases
* \param paramCache Container for cache parameters // * - fugacity coefficients of *all* components in *all* phases
* \param refPhaseIdx The phase index of the reference phase // * - if the setViscosity parameter is true, also dynamic viscosities of *all* phases
* \param phasePresence The presence index of the reference phase // * - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases
* \param setViscosity Specify whether the dynamic viscosity of // *
* each phase should also be set. // * \param fluidState Thermodynamic state of the fluids
* \param setEnthalpy Specify whether the specific // * \param paramCache Container for cache parameters
* enthalpy/internal energy of each phase // * \param refPhaseIdx The phase index of the reference phase
* should also be set. // * \param phasePresence The presence index of the reference phase
*/ // * \param setViscosity Specify whether the dynamic viscosity of
template <class FluidState, class ParameterCache> // * each phase should also be set.
static void solve(FluidState &fluidState, // * \param setEnthalpy Specify whether the specific
ParameterCache &paramCache, // * enthalpy/internal energy of each phase
int refPhaseIdx, // * should also be set.
int phasePresence, // */
bool setViscosity, // template <class FluidState, class ParameterCache>
bool setEnthalpy) // static void solve(FluidState &fluidState,
{ // ParameterCache &paramCache,
ComponentVector fugVec; // int refPhaseIdx,
// int phasePresence,
// compute the density and enthalpy of the // bool setViscosity,
// reference phase // bool setEnthalpy)
paramCache.updatePhase(fluidState, refPhaseIdx); // {
fluidState.setDensity(refPhaseIdx, // ComponentVector fugVec;
FluidSystem::density(fluidState, //
paramCache, // // compute the density and enthalpy of the
refPhaseIdx)); // // reference phase
// paramCache.updatePhase(fluidState, refPhaseIdx);
if (setEnthalpy) // fluidState.setDensity(refPhaseIdx,
fluidState.setEnthalpy(refPhaseIdx, // FluidSystem::density(fluidState,
FluidSystem::enthalpy(fluidState, // paramCache,
paramCache, // refPhaseIdx));
refPhaseIdx)); //
// if (setEnthalpy)
if (setViscosity) // fluidState.setEnthalpy(refPhaseIdx,
fluidState.setViscosity(refPhaseIdx, // FluidSystem::enthalpy(fluidState,
FluidSystem::viscosity(fluidState, // paramCache,
paramCache, // refPhaseIdx));
refPhaseIdx)); //
// if (setViscosity)
// compute the fugacities of all components in the reference phase // fluidState.setViscosity(refPhaseIdx,
for (int compIdx = 0; compIdx < numComponents; ++compIdx) { // FluidSystem::viscosity(fluidState,
fluidState.setFugacityCoefficient(refPhaseIdx, // paramCache,
compIdx, // refPhaseIdx));
FluidSystem::fugacityCoefficient(fluidState, //
paramCache, // // compute the fugacities of all components in the reference phase
refPhaseIdx, // for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
compIdx)); // fluidState.setFugacityCoefficient(refPhaseIdx,
fugVec[compIdx] = fluidState.fugacity(refPhaseIdx, compIdx); // compIdx,
} // FluidSystem::fugacityCoefficient(fluidState,
// paramCache,
// compute all quantities for the non-reference phases // refPhaseIdx,
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { // compIdx));
if (phaseIdx == refPhaseIdx) // fugVec[compIdx] = fluidState.fugacity(refPhaseIdx, compIdx);
continue; // reference phase is already calculated // }
//
compositionFromFugacities2pncmin::guessInitial(fluidState, paramCache, phaseIdx, phasePresence,fugVec); // // compute all quantities for the non-reference phases
compositionFromFugacities2pncmin::solve(fluidState, paramCache, phaseIdx, phasePresence, fugVec); // for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
// if (phaseIdx == refPhaseIdx)
if (setViscosity) // continue; // reference phase is already calculated
fluidState.setViscosity(phaseIdx, //
FluidSystem::viscosity(fluidState, // compositionFromFugacities2pncmin::guessInitial(fluidState, paramCache, phaseIdx, phasePresence,fugVec);
paramCache, // compositionFromFugacities2pncmin::solve(fluidState, paramCache, phaseIdx, phasePresence, fugVec);
phaseIdx)); //
// if (setViscosity)
if (setEnthalpy) // fluidState.setViscosity(phaseIdx,
fluidState.setEnthalpy(phaseIdx, // FluidSystem::viscosity(fluidState,
FluidSystem::enthalpy(fluidState, // paramCache,
paramCache, // phaseIdx));
phaseIdx)); //
} // if (setEnthalpy)
} // fluidState.setEnthalpy(phaseIdx,
}; // FluidSystem::enthalpy(fluidState,
// paramCache,
// phaseIdx));
// }
// }
// };
} // end namespace Dumux } // end namespace Dumux
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <dumux/common/math.hh> #include <dumux/common/math.hh>
#include <dumux/implicit/model.hh> #include <dumux/implicit/model.hh>
#include <dumux/material/fluidstates/compositional.hh> #include <dumux/material/fluidstates/compositional.hh>
#include <dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh> #include <dumux/material/constraintsolvers/computefromreferencephase.hh>
#include <dumux/material/constraintsolvers/miscible2pnccomposition.hh> #include <dumux/material/constraintsolvers/miscible2pnccomposition.hh>
#include <dumux/porousmediumflow/2pnc/implicit/volumevariables.hh> #include <dumux/porousmediumflow/2pnc/implicit/volumevariables.hh>
...@@ -103,7 +103,7 @@ class TwoPNCMinVolumeVariables : public TwoPNCVolumeVariables<TypeTag> ...@@ -103,7 +103,7 @@ class TwoPNCMinVolumeVariables : public TwoPNCVolumeVariables<TypeTag>
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
using CoordScalar = typename Grid::ctype; using CoordScalar = typename Grid::ctype;
using Miscible2pNCComposition = Dumux::Miscible2pNCComposition<Scalar, FluidSystem>; using Miscible2pNCComposition = Dumux::Miscible2pNCComposition<Scalar, FluidSystem>;
using ComputeFromReferencePhase2pNCMin = Dumux::ComputeFromReferencePhase2pNCMin<Scalar, FluidSystem>; using ComputeFromReferencePhase = Dumux::ComputeFromReferencePhase<Scalar, FluidSystem>;
enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) }; enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) };
enum { dofCodim = isBox ? dim : 0 }; enum { dofCodim = isBox ? dim : 0 };
...@@ -301,11 +301,11 @@ public: ...@@ -301,11 +301,11 @@ public:
// calculate the composition of the remaining phases (as // calculate the composition of the remaining phases (as
// well as the densities of all phases). this is the job // well as the densities of all phases). this is the job
// of the "ComputeFromReferencePhase2pNc" constraint solver // of the "ComputeFromReferencePhase" constraint solver
ComputeFromReferencePhase2pNCMin::solve(fluidState, ComputeFromReferencePhase::solve(fluidState,
paramCache, paramCache,
nPhaseIdx, nPhaseIdx,
nPhaseOnly, // nPhaseOnly,
/*setViscosity=*/true, /*setViscosity=*/true,
/*setEnthalpy=*/false); /*setEnthalpy=*/false);
...@@ -338,11 +338,11 @@ public: ...@@ -338,11 +338,11 @@ public:
// calculate the composition of the remaining phases (as // calculate the composition of the remaining phases (as
// well as the densities of all phases). this is the job // well as the densities of all phases). this is the job
// of the "ComputeFromReferencePhase2pNc" constraint solver // of the "ComputeFromReferencePhase" constraint solver
ComputeFromReferencePhase2pNCMin::solve(fluidState, ComputeFromReferencePhase::solve(fluidState,
paramCache, paramCache,
wPhaseIdx, wPhaseIdx,
wPhaseOnly, // wPhaseOnly,
/*setViscosity=*/true, /*setViscosity=*/true,
/*setEnthalpy=*/false); /*setEnthalpy=*/false);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment