30#ifndef DUMUX_COMBUSTION_PROBLEM_ONE_COMPONENT_HH
31#define DUMUX_COMBUSTION_PROBLEM_ONE_COMPONENT_HH
33#include <dune/grid/onedgrid.hh>
54template<
class TypeTag>
55class CombustionProblemOneComponent;
58template<
int numP,
int numC, MpNcPressureFormulation formulation,
bool useM>
72template<
class TypeTag>
73struct Grid<TypeTag, TTag::CombustionOneComponent> {
using type = Dune::OneDGrid; };
76template<
class TypeTag>
77struct Problem<TypeTag, TTag::CombustionOneComponent>
81template<
class TypeTag>
89template<
class TypeTag>
94template<
class TypeTag>
102template<
class TypeTag>
103struct Scalar<TypeTag, TTag::CombustionOneComponent> {
using type = double ; };
107template<
class TypeTag>
114 FluidSystem::numComponents,
115 getPropValue<TypeTag, Properties::PressureFormulation>(),
116 getPropValue<TypeTag, Properties::UseMoles>() >;
119template<
class TypeTag>
131template<
class TypeTag>
132struct NumEnergyEqFluid<TypeTag, TTag::CombustionOneComponent> {
static constexpr int value = 1; };
133template<
class TypeTag>
134struct NumEnergyEqSolid<TypeTag, TTag::CombustionOneComponent> {
static constexpr int value = 1; };
137template<
class TypeTag>
141template<
class TypeTag>
147 static constexpr int numInertComponents = 2;
151template<
class TypeTag>
161template<
class TypeTag>
170template<
class TypeTag>
181 using ElementVolumeVariables =
typename GridVariables::GridVolumeVariables::LocalView;
182 using ElementFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache::LocalView;
185 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
186 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
188 using Element =
typename GridView::template Codim<0>::Entity;
189 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
192 using ParameterCache =
typename FluidSystem::ParameterCache;
197 enum {dimWorld = GridView::dimensionworld};
198 enum {numPhases = ModelTraits::numFluidPhases()};
199 enum {numComponents = ModelTraits::numFluidComponents()};
200 enum {s0Idx = Indices::s0Idx};
201 enum {p0Idx = Indices::p0Idx};
202 enum {conti00EqIdx = Indices::conti0EqIdx};
203 enum {energyEq0Idx = Indices::energyEqIdx};
204 enum {numEnergyEqFluid = ModelTraits::numEnergyEqFluid()};
205 enum {numEnergyEqSolid = ModelTraits::numEnergyEqSolid()};
206 enum {energyEqSolidIdx = energyEq0Idx + numEnergyEqFluid + numEnergyEqSolid - 1};
207 enum {wPhaseIdx = FluidSystem::wPhaseIdx};
208 enum {nPhaseIdx = FluidSystem::nPhaseIdx};
209 enum {wCompIdx = FluidSystem::H2OIdx};
210 enum {nCompIdx = FluidSystem::N2Idx};
213 static constexpr auto pressureFormulation = ModelTraits::pressureFormulation();
221 outputName_ = getParam<std::string>(
"Problem.Name");
222 nRestart_ = getParam<Scalar>(
"Constants.nRestart");
223 TInitial_ = getParam<Scalar>(
"InitialConditions.TInitial");
224 TRight_ = getParam<Scalar>(
"InitialConditions.TRight");
225 pnInitial_ = getParam<Scalar>(
"InitialConditions.pnInitial");
226 TBoundary_ = getParam<Scalar>(
"BoundaryConditions.TBoundary");
227 SwBoundary_ = getParam<Scalar>(
"BoundaryConditions.SwBoundary");
228 SwOneComponentSys_= getParam<Scalar>(
"BoundaryConditions.SwOneComponentSys");
229 massFluxInjectedPhase_ = getParam<Scalar>(
"BoundaryConditions.massFluxInjectedPhase");
230 heatFluxFromRight_ = getParam<Scalar>(
"BoundaryConditions.heatFluxFromRight");
231 coldTime_ =getParam<Scalar>(
"BoundaryConditions.coldTime");
242 {
return *gridVariables_; }
263 {
return outputName_;}
278 NumEqVector
source(
const Element &element,
279 const FVElementGeometry& fvGeometry,
280 const ElementVolumeVariables& elemVolVars,
281 const SubControlVolume &scv)
const
283 NumEqVector values(0.0);
285 const auto& globalPos = scv.dofPosition();
287 const Scalar volume = scv.volume();
288 const Scalar numScv = fvGeometry.numScv();
290 if (time_ > coldTime_ )
292 if (onRightBoundaryPorousMedium_(globalPos))
295 values[energyEqSolidIdx] = heatFluxFromRight_ / volume / numScv;
309 BoundaryTypes bcTypes;
311 bcTypes.setAllNeumann();
313 if(onRightBoundary_(globalPos) ) {
314 bcTypes.setAllDirichlet();
328 return initial_(globalPos);
344 const FVElementGeometry& fvGeometry,
345 const ElementVolumeVariables& elemVolVars,
346 const ElementFluxVariablesCache& elemFluxVarsCache,
347 const SubControlVolumeFace& scvf)
const
349 NumEqVector values(0.0);
351 const auto& globalPos = fvGeometry.scv(scvf.insideScvIdx()).dofPosition();
352 const auto& scvIdx = scvf.insideScvIdx();
353 const Scalar massFluxInjectedPhase = massFluxInjectedPhase_;
355 FluidState fluidState;
357 const Scalar pn = elemVolVars[scvIdx].pressure(nPhaseIdx);
358 const Scalar pw = elemVolVars[scvIdx].pressure(wPhaseIdx);
360 fluidState.setPressure(nPhaseIdx, pn);
361 fluidState.setPressure(wPhaseIdx, pw);
363 fluidState.setTemperature(TBoundary_);
364 ParameterCache dummyCache;
365 fluidState.setMoleFraction(wPhaseIdx, nCompIdx, 0.0);
366 fluidState.setMoleFraction(wPhaseIdx, wCompIdx, 1.0);
371 fluidState.setDensity(wPhaseIdx,
density);
377 for(
int phaseIdx=0; phaseIdx<numPhases; phaseIdx++) {
378 const Scalar h = FluidSystem::enthalpy(fluidState,
381 fluidState.setEnthalpy(phaseIdx, h);
384 const Scalar molarFlux = massFluxInjectedPhase / fluidState.averageMolarMass(wPhaseIdx);
386 if (onLeftBoundary_(globalPos))
388 values[conti00EqIdx + wCompIdx] = - molarFlux * fluidState.moleFraction(wPhaseIdx, wCompIdx);
389 values[conti00EqIdx + nCompIdx] = - molarFlux * fluidState.moleFraction(wPhaseIdx, nCompIdx);
390 values[energyEq0Idx] = - massFluxInjectedPhase * fluidState.enthalpy(wPhaseIdx);
405 return initial_(globalPos);
410 PrimaryVariables initial_(
const GlobalPosition &globalPos)
const
412 PrimaryVariables priVars(0.0);
413 const Scalar curPos = globalPos[0];
414 const Scalar slope = (SwBoundary_-SwOneComponentSys_) / (this->
spatialParams().lengthPM());
416 const Scalar thisSaturation = SwOneComponentSys_ + curPos * slope;
418 S[wPhaseIdx] = SwBoundary_;
419 if (inPM_(globalPos) ) {
420 S[wPhaseIdx] = thisSaturation;
423 S[nPhaseIdx] = 1. - S[wPhaseIdx];
428 for (
int i = 0; i < numPhases - 1; ++i) {
429 priVars[s0Idx + i] = S[i];
432 FluidState fluidState;
434 Scalar thisTemperature = TInitial_;
435 if(onRightBoundary_(globalPos))
436 thisTemperature = TRight_;
438 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
439 fluidState.setSaturation(phaseIdx, S[phaseIdx]);
441 fluidState.setTemperature(thisTemperature );
447 priVars[energyEq0Idx] = thisTemperature;
448 priVars[energyEqSolidIdx] = thisTemperature;
449 std::vector<Scalar> capPress(numPhases);
452 const auto &materialParams =
454 using MaterialLaw =
typename ParentType::SpatialParams::MaterialLaw;
455 using MPAdapter = MPAdapter<MaterialLaw, numPhases>;
457 const int wettingPhaseIdx = this->
spatialParams().template wettingPhaseAtPos<FluidSystem>(globalPos);
458 MPAdapter::capillaryPressures(capPress, materialParams, fluidState, wettingPhaseIdx);
463 p[wPhaseIdx] = pnInitial_ - abs(capPress[wPhaseIdx]);
464 p[nPhaseIdx] = p[wPhaseIdx] + abs(capPress[wPhaseIdx]);
466 for (
int phaseIdx=0; phaseIdx<numPhases; phaseIdx++)
467 fluidState.setPressure(phaseIdx, p[phaseIdx]);
472 if(pressureFormulation == mostWettingFirst) {
475 priVars[p0Idx] = p[wPhaseIdx];
477 else if(pressureFormulation == leastWettingFirst) {
480 priVars[p0Idx] = p[nPhaseIdx];
483 DUNE_THROW(Dune::InvalidStateException,
"CombustionProblemOneComponent does not support the chosen pressure formulation.");
485 fluidState.setMoleFraction(wPhaseIdx, wCompIdx, 1.0);
486 fluidState.setMoleFraction(wPhaseIdx, nCompIdx, 0.0);
488 fluidState.setMoleFraction(nPhaseIdx, wCompIdx, 1.0);
489 fluidState.setMoleFraction(nPhaseIdx, nCompIdx, 0.0);
494 refPhaseIdx = nPhaseIdx;
496 if(inPM_(globalPos)) {
497 refPhaseIdx = wPhaseIdx;
501 using ComputeFromReferencePhase = ComputeFromReferencePhase<Scalar, FluidSystem>;
502 ParameterCache paramCache;
510 for (
int compIdx = 0; compIdx < numComponents; ++compIdx) {
511 priVars[conti00EqIdx + compIdx] = fluidState.fugacity(refPhaseIdx,compIdx);
519 bool onLeftBoundary_(
const GlobalPosition & globalPos)
const
520 {
return globalPos[0] < this->
gridGeometry().bBoxMin()[0] + eps_;}
525 bool onRightBoundary_(
const GlobalPosition & globalPos)
const
526 {
return globalPos[0] > this->
gridGeometry().bBoxMax()[0] - eps_;}
532 bool onRightBoundaryPorousMedium_(
const GlobalPosition & globalPos)
const
535 return (abs(globalPos[0] - (this->
spatialParams().lengthPM())) < eps_ );
541 bool inPM_(
const GlobalPosition & globalPos)
const
545 static constexpr Scalar eps_ = 1e-6;
548 std::string outputName_;
555 Dune::ParameterTree inputParameters_;
556 Scalar x_[numPhases][numComponents];
560 Scalar SwOneComponentSys_;
562 Scalar massFluxInjectedPhase_;
563 Scalar heatFluxFromRight_;
568 std::shared_ptr<GridVariables> gridVariables_;
Defines a type tag and some properties for models using the box scheme.
Computes all quantities of a generic fluid state if a reference phase has been specified.
Relation for the saturation-dependent effective thermal conductivity.
Setting constant fluid properties via the input file.
A solid phase consisting of multiple inert solid components.
Represents all relevant thermodynamic quantities of a compositional solid system.
Enumeration of the formulations accepted by the MpNc model.
This file contains the parts of the local residual to calculate the heat conservation in the thermal ...
A two-phase fluid system with water as sole component.
MpNcPressureFormulation
Enumerates the formulations which the MpNc model accepts.
Definition: pressureformulation.hh:36
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
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:83
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
Property to specify the type of scalar values.
Definition: common/properties.hh:53
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
The local residual of the energy equation.
Definition: common/properties.hh:206
The type of the spatial parameters object.
Definition: common/properties.hh:221
The type of the fluid system to use.
Definition: common/properties.hh:223
The type of the fluid state to use.
Definition: common/properties.hh:225
The type of the solid system to use.
Definition: common/properties.hh:227
The type of the solid state to use.
Definition: common/properties.hh:229
Definition: common/properties.hh:312
the formulation of the pressure e.g most wetting first
Definition: common/properties.hh:318
Definition: common/properties.hh:330
Definition: common/properties.hh:332
Definition: common/properties.hh:334
A component which returns run time specified values for all fluid properties.
Definition: constant.hh:58
static void solve(FluidState &fluidState, ParameterCache ¶mCache, int refPhaseIdx)
Computes all quantities of a generic fluid state if a reference phase has been specified.
Definition: computefromreferencephase.hh:112
Represents all relevant thermodynamic quantities of a multi-phase, multi-component fluid system assum...
Definition: compositional.hh:47
Represents all relevant thermodynamic quantities of a compositional solid system.
Definition: compositionalsolidstate.hh:37
A solid phase consisting of multiple inert solid components.
Definition: compositionalsolidphase.hh:42
Specifies a number properties of the m-phase n-component model.
Definition: porousmediumflow/mpnc/model.hh:137
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: dumux/porousmediumflow/problem.hh:146
A two-phase fluid system with water as sole component.
Definition: combustionfluidsystem.hh:52
This file contains the parts of the local residual to calculate the heat conservation in the thermal ...
Definition: combustionlocalresidual.hh:44
Problem where water is injected from the left hand side into a porous media filled domain,...
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:172
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:403
const std::string name() const
The problem name.
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:262
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the source term for all balance equations within a given sub-control volume.
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:278
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:326
const GridVariables & gridVariables() const
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:241
CombustionProblemOneComponent(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:218
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:307
Scalar temperature() const
Returns the temperature for an isothermal problem.
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:249
void setTime(Scalar time)
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:235
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:343
void setGridVariables(std::shared_ptr< GridVariables > gridVariables)
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:238
Custom model traits to deactivate diffusion for this test.
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:60
static constexpr bool enableMolecularDiffusion()
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:61
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:67
std::tuple< MPNCNonequil > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:67
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:68
std::tuple< CombustionOneComponent, BoxModel > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:68
Dune::OneDGrid type
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:73
GetPropType< TypeTag, GridGeometry > GridGeometry
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:84
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:85
double type
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:103
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/mpnc/implicit/thermalnonequilibrium/problem.hh:144
Definition of the spatial parameters for the one component combustion problem.
Definition: porousmediumflow/mpnc/implicit/thermalnonequilibrium/spatialparams.hh:49
A fully implicit model for MpNc flow using vertex centered finite volumes.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.