From 86941f78cd3141236d761eefda668addb801ebed Mon Sep 17 00:00:00 2001 From: hommel <johannes.hommel@iws.uni-stuttgart.de> Date: Tue, 31 Jan 2017 12:08:18 +0100 Subject: [PATCH] [2pncmin] deprecated the +- duplicate special 2pncmin constraintsolvers --- .../compositionfromfugacities2pncmin.hh | 209 +++++++++-------- .../computefromreferencephase2pncmin.hh | 221 +++++++++--------- .../2pncmin/implicit/volumevariables.hh | 16 +- 3 files changed, 229 insertions(+), 217 deletions(-) diff --git a/dumux/material/constraintsolvers/compositionfromfugacities2pncmin.hh b/dumux/material/constraintsolvers/compositionfromfugacities2pncmin.hh index dcb295fcdc..b78511d91d 100644 --- a/dumux/material/constraintsolvers/compositionfromfugacities2pncmin.hh +++ b/dumux/material/constraintsolvers/compositionfromfugacities2pncmin.hh @@ -39,108 +39,113 @@ namespace Dumux { * fugacities in a phase. */ template <class Scalar, class FluidSystem> -class CompositionFromFugacities2pncmin -{ - enum { - numComponents = FluidSystem::numComponents, - numMajorComponents = FluidSystem::numPhases - }; - - typedef typename FluidSystem::ParameterCache ParameterCache; - - -public: - typedef Dune::FieldVector<Scalar, numComponents> ComponentVector; - - /*! - * \brief Guess an initial value for the composition of the phase. - * \param fluidState Thermodynamic state of the fluids - * \param paramCache Container for cache parameters - * \param phaseIdx The phase index - * \param phasePresence The presence index of the reference phase - * \param fugVec fugacity vector of the component - */ - template <class FluidState> - static void guessInitial(FluidState &fluidState, - ParameterCache ¶mCache, - int phaseIdx, - int phasePresence, - const ComponentVector &fugVec) - { - if (FluidSystem::isIdealMixture(phaseIdx)) - return; - - // Pure component fugacities - for (int i = 0; i < numComponents; ++ i) - { - fluidState.setMoleFraction(phaseIdx,i, 1.0/numComponents); - } - } - - /*! - * \brief Calculates the chemical equilibrium from the component - * 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. - * \param fluidState Thermodynamic state of the fluids - * \param paramCache Container for cache parameters - * \param phaseIdx The phase index - * \param targetFug target fugacity - * \param phasePresence Presence of the phase - * - * The phase's fugacities must already be set. - */ - template <class FluidState> - static void solve(FluidState &fluidState, - ParameterCache ¶mCache, - int phaseIdx, - int phasePresence, - const ComponentVector &targetFug) - { - // use a much more efficient method in case the phase is an - // ideal mixture - if (FluidSystem::isIdealMixture(phaseIdx)) - { - solveIdealMix_(fluidState, paramCache, phaseIdx, phasePresence, targetFug); - return; - } - else - DUNE_THROW(NumericalProblem, "This constraint solver is not tested for non-ideal mixtures: Please refer computefromfugacities.hh for details" ); - } - -protected: - // update the phase composition in case the phase is an ideal - // mixture, i.e. the component's fugacity coefficients are - // independent of the phase's composition. - template <class FluidState> - static void solveIdealMix_(FluidState &fluidState, - ParameterCache ¶mCache, - int phaseIdx, - int phasePresence, - const ComponentVector &fugacities) - { - for (int i = 0; i < numComponents; ++ i) - { - Scalar phi = FluidSystem::fugacityCoefficient(fluidState, - paramCache, - phaseIdx, - i); - Scalar gamma = phi * fluidState.pressure(phaseIdx); - fluidState.setFugacityCoefficient(phaseIdx, i, phi); - fluidState.setMoleFraction(phaseIdx, i, fugacities[i]/gamma); - // 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*/) - fluidState.setMoleFraction(phaseIdx, i, 1.0e-10); - } - - paramCache.updatePhase(fluidState, phaseIdx); - - Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx); - fluidState.setDensity(phaseIdx, rho); - return; - } +class DUNE_DEPRECATED_MSG("CompositionFromFugacities2pncmin is deprecated. Use CompositionFromFugacities2pnc instead.") + CompositionFromFugacities2pncmin + : public CompositionFromFugacities2pnc<Scalar, FluidSystem> +{ }; +// template <class Scalar, class FluidSystem> +// class CompositionFromFugacities2pncmin +// { +// enum { +// numComponents = FluidSystem::numComponents, +// numMajorComponents = FluidSystem::numPhases +// }; +// +// typedef typename FluidSystem::ParameterCache ParameterCache; +// +// +// public: +// typedef Dune::FieldVector<Scalar, numComponents> ComponentVector; +// +// /*! +// * \brief Guess an initial value for the composition of the phase. +// * \param fluidState Thermodynamic state of the fluids +// * \param paramCache Container for cache parameters +// * \param phaseIdx The phase index +// * \param phasePresence The presence index of the reference phase +// * \param fugVec fugacity vector of the component +// */ +// template <class FluidState> +// static void guessInitial(FluidState &fluidState, +// ParameterCache ¶mCache, +// int phaseIdx, +// int phasePresence, +// const ComponentVector &fugVec) +// { +// if (FluidSystem::isIdealMixture(phaseIdx)) +// return; +// +// // Pure component fugacities +// for (int i = 0; i < numComponents; ++ i) +// { +// fluidState.setMoleFraction(phaseIdx,i, 1.0/numComponents); +// } +// } +// +// /*! +// * \brief Calculates the chemical equilibrium from the component +// * 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. +// * \param fluidState Thermodynamic state of the fluids +// * \param paramCache Container for cache parameters +// * \param phaseIdx The phase index +// * \param targetFug target fugacity +// * \param phasePresence Presence of the phase +// * +// * The phase's fugacities must already be set. +// */ +// template <class FluidState> +// static void solve(FluidState &fluidState, +// ParameterCache ¶mCache, +// int phaseIdx, +// int phasePresence, +// const ComponentVector &targetFug) +// { +// // use a much more efficient method in case the phase is an +// // ideal mixture +// if (FluidSystem::isIdealMixture(phaseIdx)) +// { +// solveIdealMix_(fluidState, paramCache, phaseIdx, phasePresence, targetFug); +// return; +// } +// else +// DUNE_THROW(NumericalProblem, "This constraint solver is not tested for non-ideal mixtures: Please refer computefromfugacities.hh for details" ); +// } +// +// protected: +// // update the phase composition in case the phase is an ideal +// // mixture, i.e. the component's fugacity coefficients are +// // independent of the phase's composition. +// template <class FluidState> +// static void solveIdealMix_(FluidState &fluidState, +// ParameterCache ¶mCache, +// int phaseIdx, +// int phasePresence, +// const ComponentVector &fugacities) +// { +// for (int i = 0; i < numComponents; ++ i) +// { +// Scalar phi = FluidSystem::fugacityCoefficient(fluidState, +// paramCache, +// phaseIdx, +// i); +// Scalar gamma = phi * fluidState.pressure(phaseIdx); +// fluidState.setFugacityCoefficient(phaseIdx, i, phi); +// fluidState.setMoleFraction(phaseIdx, i, fugacities[i]/gamma); +// // 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*/) +// fluidState.setMoleFraction(phaseIdx, i, 1.0e-10); +// } +// +// paramCache.updatePhase(fluidState, phaseIdx); +// +// Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx); +// fluidState.setDensity(phaseIdx, rho); +// return; +// } }; template <class Scalar, class FluidSystem> diff --git a/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh b/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh index 2164109dbd..60bbe64e4e 100644 --- a/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh +++ b/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh @@ -29,8 +29,10 @@ #ifndef 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/fmatrix.hh> @@ -66,112 +68,117 @@ namespace Dumux { * - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases */ template <class Scalar, class FluidSystem> -class ComputeFromReferencePhase2pNCMin -{ - enum { numPhases = FluidSystem::numPhases }; - enum { numComponents = FluidSystem::numComponents }; - typedef Dumux::compositionFromFugacities2pncmin<Scalar, FluidSystem> compositionFromFugacities2pncmin; - typedef Dune::FieldVector<Scalar, numComponents> ComponentVector; - -public: - /*! - * \brief Computes all quantities of a generic fluid state if a - * reference phase has been specified. - * - * This makes it is possible to specify just one phase and let the - * remaining ones be calculated by the constraint solver. This - * constraint solver assumes thermodynamic equilibrium. It assumes the - * following quantities to be set: - * - * - composition (mole+mass fractions) of the *reference* phase - * - temperature of the *all* phases - * - saturations of *all* phases - * - pressures of *all* phases - * - * after calling the solve() method the following quantities are - * calculated in addition: - * - * - temperature of *all* phases - * - density, molar density, molar volume of *all* phases - * - composition in mole and mass fractions and molaries of *all* phases - * - mean molar masses of *all* phases - * - fugacity coefficients of *all* components in *all* phases - * - if the setViscosity parameter is true, also dynamic viscosities of *all* phases - * - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases - * - * \param fluidState Thermodynamic state of the fluids - * \param paramCache Container for cache parameters - * \param refPhaseIdx The phase index of the reference phase - * \param phasePresence The presence index of the reference phase - * \param setViscosity Specify whether the dynamic viscosity of - * each phase should also be set. - * \param setEnthalpy Specify whether the specific - * enthalpy/internal energy of each phase - * should also be set. - */ - template <class FluidState, class ParameterCache> - static void solve(FluidState &fluidState, - ParameterCache ¶mCache, - int refPhaseIdx, - int phasePresence, - bool setViscosity, - bool setEnthalpy) - { - ComponentVector fugVec; - - // compute the density and enthalpy of the - // reference phase - paramCache.updatePhase(fluidState, refPhaseIdx); - fluidState.setDensity(refPhaseIdx, - FluidSystem::density(fluidState, - paramCache, - refPhaseIdx)); - - if (setEnthalpy) - fluidState.setEnthalpy(refPhaseIdx, - FluidSystem::enthalpy(fluidState, - paramCache, - refPhaseIdx)); - - if (setViscosity) - fluidState.setViscosity(refPhaseIdx, - FluidSystem::viscosity(fluidState, - paramCache, - refPhaseIdx)); - - // compute the fugacities of all components in the reference phase - for (int compIdx = 0; compIdx < numComponents; ++compIdx) { - fluidState.setFugacityCoefficient(refPhaseIdx, - compIdx, - FluidSystem::fugacityCoefficient(fluidState, - paramCache, - refPhaseIdx, - compIdx)); - fugVec[compIdx] = fluidState.fugacity(refPhaseIdx, compIdx); - } - - // compute all quantities for the non-reference phases - for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - if (phaseIdx == refPhaseIdx) - continue; // reference phase is already calculated - - compositionFromFugacities2pncmin::guessInitial(fluidState, paramCache, phaseIdx, phasePresence,fugVec); - compositionFromFugacities2pncmin::solve(fluidState, paramCache, phaseIdx, phasePresence, fugVec); - - if (setViscosity) - fluidState.setViscosity(phaseIdx, - FluidSystem::viscosity(fluidState, - paramCache, - phaseIdx)); - - if (setEnthalpy) - fluidState.setEnthalpy(phaseIdx, - FluidSystem::enthalpy(fluidState, - paramCache, - phaseIdx)); - } - } -}; +class DUNE_DEPRECATED_MSG("ComputeFromReferencePhase2pNCMin is deprecated. Use ComputeFromReferencePhase instead.") + ComputeFromReferencePhase2pNCMin + : public ComputeFromReferencePhase<Scalar, FluidSystem> +{ }; +// template <class Scalar, class FluidSystem> +// class ComputeFromReferencePhase2pNCMin +// { +// enum { numPhases = FluidSystem::numPhases }; +// enum { numComponents = FluidSystem::numComponents }; +// typedef Dumux::compositionFromFugacities2pncmin<Scalar, FluidSystem> compositionFromFugacities2pncmin; +// typedef Dune::FieldVector<Scalar, numComponents> ComponentVector; +// +// public: +// /*! +// * \brief Computes all quantities of a generic fluid state if a +// * reference phase has been specified. +// * +// * This makes it is possible to specify just one phase and let the +// * remaining ones be calculated by the constraint solver. This +// * constraint solver assumes thermodynamic equilibrium. It assumes the +// * following quantities to be set: +// * +// * - composition (mole+mass fractions) of the *reference* phase +// * - temperature of the *all* phases +// * - saturations of *all* phases +// * - pressures of *all* phases +// * +// * after calling the solve() method the following quantities are +// * calculated in addition: +// * +// * - temperature of *all* phases +// * - density, molar density, molar volume of *all* phases +// * - composition in mole and mass fractions and molaries of *all* phases +// * - mean molar masses of *all* phases +// * - fugacity coefficients of *all* components in *all* phases +// * - if the setViscosity parameter is true, also dynamic viscosities of *all* phases +// * - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases +// * +// * \param fluidState Thermodynamic state of the fluids +// * \param paramCache Container for cache parameters +// * \param refPhaseIdx The phase index of the reference phase +// * \param phasePresence The presence index of the reference phase +// * \param setViscosity Specify whether the dynamic viscosity of +// * each phase should also be set. +// * \param setEnthalpy Specify whether the specific +// * enthalpy/internal energy of each phase +// * should also be set. +// */ +// template <class FluidState, class ParameterCache> +// static void solve(FluidState &fluidState, +// ParameterCache ¶mCache, +// int refPhaseIdx, +// int phasePresence, +// bool setViscosity, +// bool setEnthalpy) +// { +// ComponentVector fugVec; +// +// // compute the density and enthalpy of the +// // reference phase +// paramCache.updatePhase(fluidState, refPhaseIdx); +// fluidState.setDensity(refPhaseIdx, +// FluidSystem::density(fluidState, +// paramCache, +// refPhaseIdx)); +// +// if (setEnthalpy) +// fluidState.setEnthalpy(refPhaseIdx, +// FluidSystem::enthalpy(fluidState, +// paramCache, +// refPhaseIdx)); +// +// if (setViscosity) +// fluidState.setViscosity(refPhaseIdx, +// FluidSystem::viscosity(fluidState, +// paramCache, +// refPhaseIdx)); +// +// // compute the fugacities of all components in the reference phase +// for (int compIdx = 0; compIdx < numComponents; ++compIdx) { +// fluidState.setFugacityCoefficient(refPhaseIdx, +// compIdx, +// FluidSystem::fugacityCoefficient(fluidState, +// paramCache, +// refPhaseIdx, +// compIdx)); +// fugVec[compIdx] = fluidState.fugacity(refPhaseIdx, compIdx); +// } +// +// // compute all quantities for the non-reference phases +// for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { +// if (phaseIdx == refPhaseIdx) +// continue; // reference phase is already calculated +// +// compositionFromFugacities2pncmin::guessInitial(fluidState, paramCache, phaseIdx, phasePresence,fugVec); +// compositionFromFugacities2pncmin::solve(fluidState, paramCache, phaseIdx, phasePresence, fugVec); +// +// if (setViscosity) +// fluidState.setViscosity(phaseIdx, +// FluidSystem::viscosity(fluidState, +// paramCache, +// phaseIdx)); +// +// if (setEnthalpy) +// fluidState.setEnthalpy(phaseIdx, +// FluidSystem::enthalpy(fluidState, +// paramCache, +// phaseIdx)); +// } +// } +// }; } // end namespace Dumux diff --git a/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh b/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh index c96f161e13..d1e8f39617 100644 --- a/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh +++ b/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh @@ -31,7 +31,7 @@ #include <dumux/common/math.hh> #include <dumux/implicit/model.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/porousmediumflow/2pnc/implicit/volumevariables.hh> @@ -103,7 +103,7 @@ class TwoPNCMinVolumeVariables : public TwoPNCVolumeVariables<TypeTag> typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition; typedef typename Grid::ctype CoordScalar; typedef Dumux::Miscible2pNCComposition<Scalar, FluidSystem> Miscible2pNCComposition; - typedef Dumux::ComputeFromReferencePhase2pNCMin<Scalar, FluidSystem> ComputeFromReferencePhase2pNCMin; + typedef Dumux::ComputeFromReferencePhase<Scalar, FluidSystem> ComputeFromReferencePhase; enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) }; enum { dofCodim = isBox ? dim : 0 }; @@ -330,11 +330,11 @@ public: // calculate the composition of the remaining phases (as // well as the densities of all phases). this is the job - // of the "ComputeFromReferencePhase2pNc" constraint solver - ComputeFromReferencePhase2pNCMin::solve(fluidState, + // of the "ComputeFromReferencePhase" constraint solver + ComputeFromReferencePhase::solve(fluidState, paramCache, nPhaseIdx, - nPhaseOnly, +// nPhaseOnly, /*setViscosity=*/true, /*setEnthalpy=*/false); @@ -368,11 +368,11 @@ public: // calculate the composition of the remaining phases (as // well as the densities of all phases). this is the job - // of the "ComputeFromReferencePhase2pNc" constraint solver - ComputeFromReferencePhase2pNCMin::solve(fluidState, + // of the "ComputeFromReferencePhase" constraint solver + ComputeFromReferencePhase::solve(fluidState, paramCache, wPhaseIdx, - wPhaseOnly, +// wPhaseOnly, /*setViscosity=*/true, /*setEnthalpy=*/false); } -- GitLab