diff --git a/dumux/boxmodels/2p2c/2p2cfluidstate.hh b/dumux/boxmodels/2p2c/2p2cfluidstate.hh index b6df121236cdc65c44b5c9a989af7ac5ce1be5a6..524033133d825d10abfafac4351a2135ef947094 100644 --- a/dumux/boxmodels/2p2c/2p2cfluidstate.hh +++ b/dumux/boxmodels/2p2c/2p2cfluidstate.hh @@ -292,6 +292,22 @@ public: Scalar viscosity(int phaseIdx) const { return viscosity_[phaseIdx]; } + /*! + * \brief Returns the specific internal energy of a phase \f$\mathrm{[J/kg]}\f$. + * + * \param phaseIdx The phase index + */ + Scalar internalEnergy(int phaseIdx) const + { return internalEnergy_[phaseIdx]; } + + /*! + * \brief Returns the specific enthalpy of a phase \f$\mathrm{[J/kg]}\f$. + * + * \param phaseIdx The phase index + */ + Scalar enthalpy(int phaseIdx) const + { return internalEnergy_[phaseIdx] + pressure_[phaseIdx]/density_[phaseIdx]; } + /*! * \brief Returns mean molar mass of a phase \f$\mathrm{[kg/mol]}\f$. * diff --git a/dumux/boxmodels/2p2c/2p2cvolumevariables.hh b/dumux/boxmodels/2p2c/2p2cvolumevariables.hh index 93c526b4f8233d5d7b0a7fb298c9565ee8cfd72c..01beda45f64de865abdcc995badb2eaef097ecf6 100644 --- a/dumux/boxmodels/2p2c/2p2cvolumevariables.hh +++ b/dumux/boxmodels/2p2c/2p2cvolumevariables.hh @@ -104,11 +104,11 @@ public: scvIdx, isOldSol); - asImp().updateTemperature_(priVars, - element, - elemGeom, - scvIdx, - problem); + asImp_().updateTemperature_(priVars, + element, + elemGeom, + scvIdx, + problem); // capillary pressure parameters const MaterialLawParams &materialParams = @@ -147,7 +147,10 @@ public: elemGeom, scvIdx); Valgrind::CheckDefined(porosity_); - } + + // energy related quantities + asImp_().updateEnergy_(paramCache, priVars, problem, element, elemGeom, scvIdx, isOldSol); + } /*! * \brief Returns the phase state for the control-volume. @@ -252,16 +255,30 @@ protected: fluidState_.setTemperature(problem.boxTemperature(element, elemGeom, scvIdx)); } + /*! + * \brief Called by update() to compute the energy related quantities + */ + template <class ParameterCache> + void updateEnergy_(ParameterCache ¶mCache, + const PrimaryVariables &sol, + const Problem &problem, + const Element &element, + const FVElementGeometry &elemGeom, + int vertIdx, + bool isOldSol) + { + } + Scalar porosity_; //!< Effective porosity within the control volume Scalar relativePermeability_[numPhases]; //!< Relative permeability within the control volume Scalar diffCoeff_[numPhases]; //!< Binary diffusion coefficients for the phases FluidState fluidState_; private: - Implementation &asImp() + Implementation &asImp_() { return *static_cast<Implementation*>(this); } - const Implementation &asImp() const + const Implementation &asImp_() const { return *static_cast<const Implementation*>(this); } diff --git a/dumux/boxmodels/2p2cni/2p2cnivolumevariables.hh b/dumux/boxmodels/2p2cni/2p2cnivolumevariables.hh index 88af0cde99c624a0ba6fb9ad5fdb6b7e65fdefa5..f7ab0f41d454fb71fa68107afe24379e3b103dcb 100644 --- a/dumux/boxmodels/2p2cni/2p2cnivolumevariables.hh +++ b/dumux/boxmodels/2p2cni/2p2cnivolumevariables.hh @@ -70,48 +70,6 @@ class TwoPTwoCNIVolumeVariables : public TwoPTwoCVolumeVariables<TypeTag> //! \endcond public: - /*! - * \brief Update all quantities for a given control volume. - * - * \param sol The solution primary variables - * \param problem The problem - * \param element The element - * \param elemGeom Evaluate function with solution of current or previous time step - * \param vertIdx The local index of the SCV (sub-control volume) - * \param isOldSol Evaluate function with solution of current or previous time step - */ - void update(const PrimaryVariables &sol, - const Problem &problem, - const Element &element, - const FVElementGeometry &elemGeom, - int vertIdx, - bool isOldSol) - { - // vertex update data for the mass balance - ParentType::update(sol, - problem, - element, - elemGeom, - vertIdx, - isOldSol); - - // the internal energies and the enthalpies - for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - enthalpy_[phaseIdx] = - FluidSystem::phaseEnthalpy(phaseIdx, - this->fluidState().temperature(), - this->fluidState().phasePressure(phaseIdx), - this->fluidState()); - internalEnergy_[phaseIdx] = - FluidSystem::phaseInternalEnergy(phaseIdx, - this->fluidState().temperature(), - this->fluidState().phasePressure(phaseIdx), - this->fluidState()); - } - Valgrind::CheckDefined(internalEnergy_); - Valgrind::CheckDefined(enthalpy_); - }; - /*! * \brief Returns the total internal energy of a phase in the * sub-control volume. @@ -119,7 +77,7 @@ public: * \param phaseIdx The phase index */ Scalar internalEnergy(int phaseIdx) const - { return internalEnergy_[phaseIdx]; }; + { return this->fluidState_.internalEnergy(phaseIdx); }; /*! * \brief Returns the total enthalpy of a phase in the sub-control @@ -128,7 +86,7 @@ public: * \param phaseIdx The phase index */ Scalar enthalpy(int phaseIdx) const - { return enthalpy_[phaseIdx]; }; + { return this->fluidState_.enthalpy(phaseIdx); }; /*! * \brief Returns the total heat capacity \f$\mathrm{[J/(K*m^3]}\f$ of the rock matrix in @@ -141,6 +99,8 @@ protected: // this method gets called by the parent class. since this method // is protected, we are friends with our parent.. friend class TwoPTwoCVolumeVariables<TypeTag>; + + // set the fluid state's temperature void updateTemperature_(const PrimaryVariables &sol, const Element &element, const FVElementGeometry &elemGeom, @@ -148,17 +108,40 @@ protected: const Problem &problem) { // retrieve temperature from solution vector - this->temperature_ = sol[temperatureIdx]; + this->fluidState_.setTemperature(sol[temperatureIdx]); + } - heatCapacity_ = - problem.spatialParameters().heatCapacity(element, elemGeom, scvIdx); + /*! + * \brief Update all quantities for a given control volume. + * + * \param sol The solution primary variables + * \param problem The problem + * \param element The element + * \param elemGeom Evaluate function with solution of current or previous time step + * \param scvIdx The local index of the SCV (sub-control volume) + * \param isOldSol Evaluate function with solution of current or previous time step + */ + template <class ParameterCache> + void updateEnergy_(ParameterCache ¶mCache, + const PrimaryVariables &sol, + const Problem &problem, + const Element &element, + const FVElementGeometry &elemGeom, + int scvIdx, + bool isOldSol) + { + // copmute and set the internal energies of the fluid phases + for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { + Scalar u = FluidSystem::internalEnergy(this->fluidState_, paramCache, phaseIdx); - Valgrind::CheckDefined(this->temperature_); + this->fluidState_.setInternalEnergy(phaseIdx, u); + } + + // copmute and set the heat capacity of the solid phase + heatCapacity_ = problem.spatialParameters().heatCapacity(element, elemGeom, scvIdx); Valgrind::CheckDefined(heatCapacity_); - } + }; - Scalar internalEnergy_[numPhases]; - Scalar enthalpy_[numPhases]; Scalar heatCapacity_; }; diff --git a/test/boxmodels/2p2cni/waterairproblem.hh b/test/boxmodels/2p2cni/waterairproblem.hh index 2b733da3f8cb137e57835883299ebf59ae667c71..64f7b7f03190b92d6dd0bcfad33350a12ed97ac0 100644 --- a/test/boxmodels/2p2cni/waterairproblem.hh +++ b/test/boxmodels/2p2cni/waterairproblem.hh @@ -31,7 +31,7 @@ #include <dune/grid/io/file/dgfparser/dgfs.hh> #include <dune/grid/io/file/dgfparser/dgfyasp.hh> -#include <dumux/material/fluidsystems/h2o_n2_system.hh> +#include <dumux/material/MpNcfluidsystems/h2on2fluidsystem.hh> #include <dumux/boxmodels/2p2cni/2p2cnimodel.hh> @@ -61,7 +61,7 @@ SET_PROP(WaterAirProblem, Problem) }; // Set the wetting phase -SET_TYPE_PROP(WaterAirProblem, FluidSystem, Dumux::H2O_N2_System<TypeTag>); +SET_TYPE_PROP(WaterAirProblem, FluidSystem, Dumux::H2ON2FluidSystem<typename GET_PROP_TYPE(TypeTag, PTAG(Scalar))>); // Enable gravity SET_BOOL_PROP(WaterAirProblem, EnableGravity, true);