diff --git a/dumux/flux/porenetwork/fourierslaw.hh b/dumux/flux/porenetwork/fourierslaw.hh index 6db79c10cc4b2405b5f1880f1364ed5ae54ed418..2f091f6a20db667fce4a24f20ba5c3b608aed6cd 100644 --- a/dumux/flux/porenetwork/fourierslaw.hh +++ b/dumux/flux/porenetwork/fourierslaw.hh @@ -26,13 +26,22 @@ #define DUMUX_FLUX_PNM_FOURIERS_LAW_HH #include <dumux/common/math.hh> +#include <dumux/flux/referencesystemformulation.hh> +#include <type_traits> namespace Dumux::PoreNetwork { +namespace Detail { + +struct NoDiffusionType {}; + +} // end namespace Detail + /*! * \ingroup PoreNetworkModels * \brief Specialization of Fourier's Law for the pore-network model. */ +template<class MolecularDiffusionType = Detail::NoDiffusionType> struct PNMFouriersLaw { @@ -68,7 +77,41 @@ struct PNMFouriersLaw const Scalar gradT = deltaT/fluxVarsCache.throatLength(); heatflux += thermalConductivity*gradT*area; + + if constexpr (!std::is_same_v<MolecularDiffusionType, Detail::NoDiffusionType>) + heatflux += componentEnthalpyFlux_(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache, phaseIdx); + } + + return heatflux; + } + +private: + template<class Problem, class Element, class FVElementGeometry, + class ElementVolumeVariables, class ElementFluxVariablesCache> + static auto componentEnthalpyFlux_(const Problem& problem, + const Element& element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& elemVolVars, + const typename FVElementGeometry::SubControlVolumeFace& scvf, + const ElementFluxVariablesCache& elemFluxVarsCache, + const int phaseIdx) + { + using Scalar = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables::value_type; + Scalar heatflux = 0.0; + using FluidSystem = typename ElementVolumeVariables::VolumeVariables::FluidSystem; + const auto diffusiveFlux = MolecularDiffusionType::flux(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, elemFluxVarsCache); + for (int compIdx = 0; compIdx < ElementVolumeVariables::VolumeVariables::numFluidComponents(); ++compIdx) + { + const bool insideIsUpstream = diffusiveFlux[compIdx] > 0.0; + const auto& upstreamVolVars = insideIsUpstream ? elemVolVars[scvf.insideScvIdx()] : elemVolVars[scvf.outsideScvIdx()]; + const Scalar componentEnthalpy = FluidSystem::componentEnthalpy(upstreamVolVars.fluidState(), phaseIdx, compIdx); + + if (MolecularDiffusionType::referenceSystemFormulation() == ReferenceSystemFormulation::massAveraged) + heatflux += diffusiveFlux[compIdx] * componentEnthalpy; + else + heatflux += diffusiveFlux[compIdx] * FluidSystem::molarMass(compIdx) * componentEnthalpy; } + return heatflux; } }; diff --git a/dumux/porenetwork/1pnc/model.hh b/dumux/porenetwork/1pnc/model.hh index 807f6e20b61a958a5a3f10d298c7f202595051c2..7619f8c2dc1322d65332042a1cbf595d98841659 100644 --- a/dumux/porenetwork/1pnc/model.hh +++ b/dumux/porenetwork/1pnc/model.hh @@ -242,5 +242,12 @@ struct ThermalConductivityModel<TypeTag, TTag::PNMOnePNCNI> using type = ThermalConductivityAverage<GetPropType<TypeTag, Properties::Scalar>>; }; //!< Use the average for effective conductivities +// template<class TypeTag> +// struct HeatConductionType<TypeTag, TTag::PNMOnePNCNI> +// { +// TODO uncomment this as soon as there is a generalized approach for component enthalpies in all fluid systems +// using type = Dumux::PoreNetwork::PNMFouriersLaw<GetPropType<TypeTag, MolecularDiffusionType>>; +// }; //!< Use Fourier's law and also consider enthalpy transport by molecular diffusion + } // end namespace Dumux::Properties #endif diff --git a/dumux/porenetwork/properties.hh b/dumux/porenetwork/properties.hh index 628182f78bb93359ae9ecf54b2919fde000102a3..dec06d8a0a3f017e099cf77919a7cbaa78d946cb 100644 --- a/dumux/porenetwork/properties.hh +++ b/dumux/porenetwork/properties.hh @@ -68,7 +68,7 @@ public: }; template<class TypeTag> -struct HeatConductionType<TypeTag, TTag::PoreNetworkModel> { using type = Dumux::PoreNetwork::PNMFouriersLaw; }; +struct HeatConductionType<TypeTag, TTag::PoreNetworkModel> { using type = Dumux::PoreNetwork::PNMFouriersLaw<>; }; //! The labels template<class TypeTag>