3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
combustionlocalresidual.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2/*****************************************************************************
3 * See the file COPYING for full copying permissions. *
4 * *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 *****************************************************************************/
24#ifndef DUMUX_ENERGY_COMBUSTION_LOCAL_RESIDUAL_HH
25#define DUMUX_ENERGY_COMBUSTION_LOCAL_RESIDUAL_HH
26
27#include <cmath>
31
33
34namespace Dumux {
35
41template<class TypeTag>
43: public EnergyLocalResidualNonEquilibrium<TypeTag, 1/*numEnergyEqFluid*/>
44{
48 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
49 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
52 using Element = typename GridView::template Codim<0>::Entity;
53 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
54 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
55
57 using Indices = typename ModelTraits::Indices;
58
59 static constexpr auto numEnergyEqFluid = ModelTraits::numEnergyEqFluid();
60 static constexpr auto numEnergyEqSolid = ModelTraits::numEnergyEqSolid();
61 static constexpr auto energyEq0Idx = Indices::energyEq0Idx;
62
63public:
73 static void computeSourceEnergy(NumEqVector& source,
74 const Element& element,
75 const FVElementGeometry& fvGeometry,
76 const ElementVolumeVariables& elemVolVars,
77 const SubControlVolume &scv)
78 {
79 //specialization for 2 fluid phases
80 const auto& volVars = elemVolVars[scv];
81 const auto& fs = volVars.fluidState() ;
82 const Scalar characteristicLength = volVars.characteristicLength() ;
83
84 //interfacial area
85 // Shi & Wang, Transport in porous media (2011)
86 const Scalar as = volVars.fluidSolidInterfacialArea();
87
88 //temperature fluid is the same for both fluids
89 const Scalar TFluid = volVars.temperatureFluid(0);
90 const Scalar TSolid = volVars.temperatureSolid();
91
92 const Scalar satW = fs.saturation(0) ;
93 const Scalar satN = fs.saturation(1) ;
94
95 const Scalar eps = 1e-6 ;
96 Scalar solidToFluidEnergyExchange ;
97
98 Scalar fluidConductivity ;
99 if (satW < 1.0 - eps)
100 fluidConductivity = volVars.fluidThermalConductivity(1) ;
101 else if (satW >= 1.0 - eps)
102 fluidConductivity = volVars.fluidThermalConductivity(0) ;
103 else
104 DUNE_THROW(Dune::NotImplemented, "wrong range");
105
106 const Scalar factorEnergyTransfer = volVars.factorEnergyTransfer() ;
107
108 solidToFluidEnergyExchange = factorEnergyTransfer * (TSolid - TFluid) / characteristicLength * as * fluidConductivity ;
109 const Scalar epsRegul = 1e-3 ;
110
111 if (satW < (0 + eps) )
112 {
113 solidToFluidEnergyExchange *= volVars.nusseltNumber(1) ;
114 }
115 else if ( (satW >= 0 + eps) and (satW < 1.0-eps) )
116 {
117 solidToFluidEnergyExchange *= (volVars.nusseltNumber(1) * satN );
118 Scalar qBoil ;
119 if (satW<=epsRegul)
120 {// regularize
122 Spline sp(0.0, epsRegul, // x1, x2
123 QBoilFunc(volVars, 0.0), QBoilFunc(volVars, epsRegul), // y1, y2
124 0.0,dQBoil_dSw(volVars, epsRegul)); // m1, m2
125
126 qBoil = sp.eval(satW);
127 }
128
129 else if (satW>= (1.0-epsRegul) )
130 { // regularize
132 Spline sp(1.0-epsRegul, 1.0, // x1, x2
133 QBoilFunc(volVars, 1.0-epsRegul), 0.0, // y1, y2
134 dQBoil_dSw(volVars, 1.0-epsRegul), 0.0 ); // m1, m2
135
136 qBoil = sp.eval(satW) ;
137 }
138 else
139 {
140 qBoil = QBoilFunc(volVars, satW) ;
141 }
142
143 solidToFluidEnergyExchange += qBoil;
144 }
145 else if (satW >= 1.0-eps)
146 {
147 solidToFluidEnergyExchange *= volVars.nusseltNumber(0) ;
148 }
149 else
150 DUNE_THROW(Dune::NotImplemented, "wrong range");
151
152 using std::isfinite;
153 if (!isfinite(solidToFluidEnergyExchange))
154 DUNE_THROW(NumericalProblem, "Calculated non-finite source, " << "TFluid="<< TFluid << " TSolid="<< TSolid);
155
156 for(int energyEqIdx =0; energyEqIdx<numEnergyEqFluid+numEnergyEqSolid; ++energyEqIdx)
157 {
158 switch (energyEqIdx)
159 {
160 case 0 :
161 source[energyEq0Idx + energyEqIdx] += solidToFluidEnergyExchange;
162 break;
163 case 1 :
164 source[energyEq0Idx + energyEqIdx] -= solidToFluidEnergyExchange;
165 break;
166 default:
167 DUNE_THROW(Dune::NotImplemented,
168 "wrong index");
169 } // end switch
170 }// end energyEqIdx
171 }// end source
172
173
179 static Scalar QBoilFunc(const VolumeVariables & volVars,
180 const Scalar satW)
181 {
182 // using saturation as input (instead of from volVars)
183 // in order to make regularization (evaluation at different points) easyer
184 const auto& fs = volVars.fluidState();
185 const Scalar g( 9.81 );
186 const Scalar gamma(0.0589);
187 const Scalar TSolid = volVars.temperatureSolid();
188 using std::pow;
189 const Scalar as = volVars.fluidSolidInterfacialArea();
190 const Scalar mul = fs.viscosity(0);
191 const Scalar deltahv = fs.enthalpy(1) - fs.enthalpy(0);
192 const Scalar deltaRho = fs.density(0) - fs.density(1);
193 const Scalar firstBracket = pow(g * deltaRho / gamma, 0.5);
194 const Scalar cp = FluidSystem::heatCapacity(fs, 0);
195 // This use of Tsat is only justified if the fluid is always boiling (tsat equals boiling conditions)
196 // If a different state is to be simulated, please use the actual fluid temperature instead.
197 const Scalar Tsat = FluidSystem::vaporTemperature(fs, 1 ) ;
198 const Scalar deltaT = TSolid - Tsat;
199 const Scalar secondBracket = pow( (cp *deltaT / (0.006 * deltahv) ) , 3.0 );
200 const Scalar Prl = volVars.prandtlNumber(0);
201 const Scalar thirdBracket = pow( 1/Prl , (1.7/0.33));
202 const Scalar QBoil = satW * as * mul * deltahv * firstBracket * secondBracket * thirdBracket;
203 return QBoil;
204 }
205
211 static Scalar dQBoil_dSw(const VolumeVariables & volVars,
212 const Scalar satW)
213 {
214 // on the fly derive w.r.t. Sw.
215 // Only linearly depending on it (directly)
216 return (QBoilFunc(volVars, satW) / satW ) ;
217 }
218};
219} // end namespace Dumux
220
221#endif //
Some exceptions thrown in DuMux
Provides 3rd order polynomial splines.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
constexpr double eps
epsilon for checking direction of scvf normals
Definition: test_tpfafvgeometry_nonconforming.cc:44
Exception thrown if a fixable numerical problem occurs.
Definition: exceptions.hh:39
A 3rd order polynomial spline.
Definition: spline.hh:55
Scalar eval(Scalar x, bool extrapolate=false) const
Evaluate the spline at a given position.
Definition: splinecommon_.hh:142
This file contains the parts of the local residual to calculate the heat conservation in the thermal ...
Definition: porousmediumflow/nonequilibrium/thermal/localresidual.hh:43
This file contains the parts of the local residual to calculate the heat conservation in the thermal ...
Definition: combustionlocalresidual.hh:44
static Scalar QBoilFunc(const VolumeVariables &volVars, const Scalar satW)
Calculates the energy transfer during boiling, i.e. latent heat.
Definition: combustionlocalresidual.hh:179
static Scalar dQBoil_dSw(const VolumeVariables &volVars, const Scalar satW)
Calculates the derivative of the energy transfer function during boiling. Needed for regularization.
Definition: combustionlocalresidual.hh:211
static void computeSourceEnergy(NumEqVector &source, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv)
Calculates the source term of the equation.
Definition: combustionlocalresidual.hh:73
Declares all properties used in Dumux.
This file contains the parts of the local residual to calculate the heat conservation in the thermal ...