28#ifndef EWOMS_POWER_INJECTION_PROBLEM_HH
29#define EWOMS_POWER_INJECTION_PROBLEM_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>
41#include <dune/grid/yaspgrid.hh>
42#include <dune/common/version.hh>
43#include <dune/common/fvector.hh>
44#include <dune/common/fmatrix.hh>
50template <
class TypeTag>
51class DiffusionProblem;
63template<
class TypeTag>
64struct Grid<TypeTag, TTag::DiffusionBaseProblem> {
using type = Dune::YaspGrid<1>; };
67template<
class TypeTag>
71template<
class TypeTag>
75template<
class TypeTag>
82 using type = Opm::H2ON2FluidSystem<Scalar>;
86template<
class TypeTag>
93 static_assert(FluidSystem::numPhases == 2,
94 "A fluid system with two phases is required "
97 using Traits = Opm::TwoPhaseMaterialTraits<Scalar,
98 FluidSystem::liquidPhaseIdx,
99 FluidSystem::gasPhaseIdx>;
102 using type = Opm::LinearMaterial<Traits>;
106template<
class TypeTag>
107struct EnableDiffusion<TypeTag, TTag::DiffusionBaseProblem> {
static constexpr bool value =
true; };
122template <
class TypeTag>
136 numPhases = FluidSystem::numPhases,
139 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
140 gasPhaseIdx = FluidSystem::gasPhaseIdx,
143 H2OIdx = FluidSystem::H2OIdx,
144 N2Idx = FluidSystem::N2Idx,
147 dim = GridView::dimension,
148 dimWorld = GridView::dimensionworld
158 using CoordScalar =
typename GridView::ctype;
159 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
161 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
168 : ParentType(simulator)
176 ParentType::finishInit();
180 temperature_ = 273.15 + 20.0;
182 materialParams_.finalize();
184 K_ = this->toDimMatrix_(1e-12);
186 setupInitialFluidStates_();
194 ParentType::registerParameters();
196 Parameters::SetDefault<Parameters::CellsX>(250);
198 if constexpr (dim > 1) {
199 Parameters::SetDefault<Parameters::CellsY>(1);
201 if constexpr (dim == 3) {
202 Parameters::SetDefault<Parameters::CellsZ>(1);
205 Parameters::SetDefault<Parameters::EndTime<Scalar>>(1e6);
206 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(1000);
218 {
return std::string(
"diffusion_") + Model::name(); }
226 this->model().checkConservativeness();
230 this->model().globalStorage(storage);
233 if (this->gridView().comm().rank() == 0) {
234 std::cout <<
"Storage: " << storage << std::endl << std::flush;
249 template <
class Context>
258 template <
class Context>
267 template <
class Context>
268 const MaterialLawParams&
272 {
return materialParams_; }
277 template <
class Context>
281 {
return temperature_; }
295 template <
class Context>
300 { values.setNoFlow(); }
312 template <
class Context>
314 const Context& context,
316 unsigned timeIdx)
const
318 const auto& pos = context.pos(spaceIdx, timeIdx);
319 if (onLeftSide_(pos))
320 values.assignNaive(leftInitialFluidState_);
322 values.assignNaive(rightInitialFluidState_);
331 template <
class Context>
336 { rate = Scalar(0.0); }
341 bool onLeftSide_(
const GlobalPosition& pos)
const
342 {
return pos[0] < (this->boundingBoxMin()[0] + this->boundingBoxMax()[0]) / 2; }
344 void setupInitialFluidStates_()
347 leftInitialFluidState_.setTemperature(temperature_);
350 leftInitialFluidState_.setSaturation(liquidPhaseIdx, Sl);
351 leftInitialFluidState_.setSaturation(gasPhaseIdx, 1 - Sl);
354 leftInitialFluidState_.setPressure(liquidPhaseIdx, p);
355 leftInitialFluidState_.setPressure(gasPhaseIdx, p);
358 leftInitialFluidState_.setMoleFraction(gasPhaseIdx, H2OIdx, xH2O);
359 leftInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O);
361 using CFRP = Opm::ComputeFromReferencePhase<Scalar, FluidSystem>;
362 typename FluidSystem::template ParameterCache<Scalar> paramCache;
363 CFRP::solve(leftInitialFluidState_, paramCache, gasPhaseIdx,
367 rightInitialFluidState_.assign(leftInitialFluidState_);
369 rightInitialFluidState_.setMoleFraction(gasPhaseIdx, H2OIdx, xH2O);
370 rightInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O);
371 CFRP::solve(rightInitialFluidState_, paramCache, gasPhaseIdx,
376 MaterialLawParams materialParams_;
378 Opm::CompositionalFluidState<Scalar, FluidSystem> leftInitialFluidState_;
379 Opm::CompositionalFluidState<Scalar, FluidSystem> rightInitialFluidState_;
Provides a simulator vanguad which creates a regular grid made of quadrilaterals.
Definition: cubegridvanguard.hh:53
1D problem which is driven by molecular diffusion.
Definition: diffusionproblem.hh:124
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: diffusionproblem.hh:278
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the initial value for a control volume.
Definition: diffusionproblem.hh:313
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: diffusionproblem.hh:174
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: diffusionproblem.hh:259
void boundary(BoundaryRateVector &values, const Context &, unsigned, unsigned) const
Evaluate the boundary conditions for a boundary segment.
Definition: diffusionproblem.hh:296
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: diffusionproblem.hh:332
DiffusionProblem(Simulator &simulator)
Definition: diffusionproblem.hh:167
void endTimeStep()
Called by the simulator after each time integration.
Definition: diffusionproblem.hh:223
std::string name() const
The problem name.
Definition: diffusionproblem.hh:217
const MaterialLawParams & materialLawParams(const Context &, unsigned, unsigned) const
Definition: diffusionproblem.hh:269
static void registerParameters()
Definition: diffusionproblem.hh:192
const DimMatrix & intrinsicPermeability(const Context &, unsigned, unsigned) const
Definition: diffusionproblem.hh:250
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
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:235
Declares the properties required for the NCP compositional multi-phase model.
Enable diffusive fluxes?
Definition: multiphasebaseproperties.hh:79
Opm::H2ON2FluidSystem< Scalar > type
Definition: diffusionproblem.hh:82
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:69
Dune::YaspGrid< 1 > type
Definition: diffusionproblem.hh:64
The type of the DUNE grid.
Definition: basicproperties.hh:100
Opm::LinearMaterial< Traits > type
Definition: diffusionproblem.hh:102
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:51
The type of the problem.
Definition: fvbaseproperties.hh:81
Definition: diffusionproblem.hh:58
Property which provides a Vanguard (manages grids)
Definition: basicproperties.hh:96