28 #ifndef EWOMS_POWER_INJECTION_PROBLEM_HH
29 #define EWOMS_POWER_INJECTION_PROBLEM_HH
31 #include <opm/models/ncp/ncpproperties.hh>
33 #include <opm/models/io/cubegridvanguard.hh>
35 #include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
36 #include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
37 #include <opm/material/fluidsystems/H2ON2FluidSystem.hpp>
38 #include <opm/material/fluidstates/CompositionalFluidState.hpp>
39 #include <opm/material/constraintsolvers/ComputeFromReferencePhase.hpp>
40 #include <opm/material/common/Unused.hpp>
42 #include <dune/grid/yaspgrid.hh>
43 #include <dune/common/version.hh>
44 #include <dune/common/fvector.hh>
45 #include <dune/common/fmatrix.hh>
51 template <
class TypeTag>
52 class DiffusionProblem;
55 namespace Opm::Properties {
64 template<
class TypeTag>
65 struct Grid<TypeTag, TTag::DiffusionBaseProblem> {
using type = Dune::YaspGrid<1>; };
68 template<
class TypeTag>
69 struct Vanguard<TypeTag, TTag::DiffusionBaseProblem> {
using type = Opm::CubeGridVanguard<TypeTag>; };
72 template<
class TypeTag>
76 template<
class TypeTag>
77 struct FluidSystem<TypeTag, TTag::DiffusionBaseProblem>
80 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
83 using type = Opm::H2ON2FluidSystem<Scalar>;
87 template<
class TypeTag>
88 struct MaterialLaw<TypeTag, TTag::DiffusionBaseProblem>
91 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
92 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
94 static_assert(FluidSystem::numPhases == 2,
95 "A fluid system with two phases is required "
98 using Traits = Opm::TwoPhaseMaterialTraits<Scalar,
99 FluidSystem::liquidPhaseIdx,
100 FluidSystem::gasPhaseIdx>;
103 using type = Opm::LinearMaterial<Traits>;
107 template<
class TypeTag>
108 struct EnableDiffusion<TypeTag, TTag::DiffusionBaseProblem> {
static constexpr
bool value =
true; };
111 template<
class TypeTag>
112 struct EnableGravity<TypeTag, TTag::DiffusionBaseProblem> {
static constexpr
bool value =
false; };
115 template<
class TypeTag>
116 struct DomainSizeX<TypeTag, TTag::DiffusionBaseProblem>
118 using type = GetPropType<TypeTag, Scalar>;
119 static constexpr type value = 1.0;
121 template<
class TypeTag>
122 struct DomainSizeY<TypeTag, TTag::DiffusionBaseProblem>
124 using type = GetPropType<TypeTag, Scalar>;
125 static constexpr type value = 1.0;
127 template<
class TypeTag>
128 struct DomainSizeZ<TypeTag, TTag::DiffusionBaseProblem>
130 using type = GetPropType<TypeTag, Scalar>;
131 static constexpr type value = 1.0;
134 template<
class TypeTag>
135 struct CellsX<TypeTag, TTag::DiffusionBaseProblem> {
static constexpr
int value = 250; };
136 template<
class TypeTag>
137 struct CellsY<TypeTag, TTag::DiffusionBaseProblem> {
static constexpr
int value = 1; };
138 template<
class TypeTag>
139 struct CellsZ<TypeTag, TTag::DiffusionBaseProblem> {
static constexpr
int value = 1; };
142 template<
class TypeTag>
143 struct EndTime<TypeTag, TTag::DiffusionBaseProblem>
145 using type = GetPropType<TypeTag, Scalar>;
146 static constexpr type value = 1e6;
150 template<
class TypeTag>
151 struct InitialTimeStepSize<TypeTag, TTag::DiffusionBaseProblem>
153 using type = GetPropType<TypeTag, Scalar>;
154 static constexpr type value = 1000;
170 template <
class TypeTag>
173 using ParentType = GetPropType<TypeTag, Properties::BaseProblem>;
175 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
176 using GridView = GetPropType<TypeTag, Properties::GridView>;
177 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
178 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
179 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
180 using Model = GetPropType<TypeTag, Properties::Model>;
184 numPhases = FluidSystem::numPhases,
187 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
188 gasPhaseIdx = FluidSystem::gasPhaseIdx,
191 H2OIdx = FluidSystem::H2OIdx,
192 N2Idx = FluidSystem::N2Idx,
195 dim = GridView::dimension,
196 dimWorld = GridView::dimensionworld
199 using EqVector = GetPropType<TypeTag, Properties::EqVector>;
200 using RateVector = GetPropType<TypeTag, Properties::RateVector>;
201 using BoundaryRateVector = GetPropType<TypeTag, Properties::BoundaryRateVector>;
203 using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
204 using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
206 using CoordScalar =
typename GridView::ctype;
207 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
209 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
216 : ParentType(simulator)
224 ParentType::finishInit();
228 temperature_ = 273.15 + 20.0;
230 materialParams_.finalize();
232 K_ = this->toDimMatrix_(1e-12);
234 setupInitialFluidStates_();
246 {
return std::string(
"diffusion_") + Model::name(); }
254 this->model().checkConservativeness();
258 this->model().globalStorage(storage);
261 if (this->gridView().comm().rank() == 0) {
262 std::cout <<
"Storage: " << storage << std::endl << std::flush;
277 template <
class Context>
279 unsigned spaceIdx OPM_UNUSED,
280 unsigned timeIdx OPM_UNUSED)
const
286 template <
class Context>
288 unsigned spaceIdx OPM_UNUSED,
289 unsigned timeIdx OPM_UNUSED)
const
295 template <
class Context>
296 const MaterialLawParams&
298 unsigned spaceIdx OPM_UNUSED,
299 unsigned timeIdx OPM_UNUSED)
const
300 {
return materialParams_; }
305 template <
class Context>
307 unsigned spaceIdx OPM_UNUSED,
308 unsigned timeIdx OPM_UNUSED)
const
309 {
return temperature_; }
323 template <
class Context>
325 const Context& context OPM_UNUSED,
326 unsigned spaceIdx OPM_UNUSED,
327 unsigned timeIdx OPM_UNUSED)
const
328 { values.setNoFlow(); }
340 template <
class Context>
342 const Context& context,
344 unsigned timeIdx)
const
346 const auto& pos = context.pos(spaceIdx, timeIdx);
347 if (onLeftSide_(pos))
348 values.assignNaive(leftInitialFluidState_);
350 values.assignNaive(rightInitialFluidState_);
359 template <
class Context>
361 const Context& context OPM_UNUSED,
362 unsigned spaceIdx OPM_UNUSED,
363 unsigned timeIdx OPM_UNUSED)
const
364 { rate = Scalar(0.0); }
369 bool onLeftSide_(
const GlobalPosition& pos)
const
370 {
return pos[0] < (this->boundingBoxMin()[0] + this->boundingBoxMax()[0]) / 2; }
372 void setupInitialFluidStates_()
375 leftInitialFluidState_.setTemperature(temperature_);
378 leftInitialFluidState_.setSaturation(liquidPhaseIdx, Sl);
379 leftInitialFluidState_.setSaturation(gasPhaseIdx, 1 - Sl);
382 leftInitialFluidState_.setPressure(liquidPhaseIdx, p);
383 leftInitialFluidState_.setPressure(gasPhaseIdx, p);
386 leftInitialFluidState_.setMoleFraction(gasPhaseIdx, H2OIdx, xH2O);
387 leftInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O);
389 using CFRP = Opm::ComputeFromReferencePhase<Scalar, FluidSystem>;
390 typename FluidSystem::template ParameterCache<Scalar> paramCache;
391 CFRP::solve(leftInitialFluidState_, paramCache, gasPhaseIdx,
395 rightInitialFluidState_.assign(leftInitialFluidState_);
397 rightInitialFluidState_.setMoleFraction(gasPhaseIdx, H2OIdx, xH2O);
398 rightInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O);
399 CFRP::solve(rightInitialFluidState_, paramCache, gasPhaseIdx,
404 MaterialLawParams materialParams_;
406 Opm::CompositionalFluidState<Scalar, FluidSystem> leftInitialFluidState_;
407 Opm::CompositionalFluidState<Scalar, FluidSystem> rightInitialFluidState_;
1D problem which is driven by molecular diffusion.
Definition: diffusionproblem.hh:172
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: diffusionproblem.hh:341
void finishInit()
Definition: diffusionproblem.hh:222
const MaterialLawParams & materialLawParams(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:297
Scalar temperature(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:306
const DimMatrix & intrinsicPermeability(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:278
Scalar porosity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:287
DiffusionProblem(Simulator &simulator)
Definition: diffusionproblem.hh:215
void endTimeStep()
Definition: diffusionproblem.hh:251
void boundary(BoundaryRateVector &values, const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:324
std::string name() const
Definition: diffusionproblem.hh:245
void source(RateVector &rate, const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:360
Definition: diffusionproblem.hh:59