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>
40 #include <opm/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>
56 namespace Properties {
61 SET_TYPE_PROP(DiffusionBaseProblem, Grid, Dune::YaspGrid</*dim=*/1>);
70 SET_PROP(DiffusionBaseProblem, FluidSystem)
76 typedef Opm::FluidSystems::H2ON2<Scalar> type;
80 SET_PROP(DiffusionBaseProblem, MaterialLaw)
84 typedef typename
GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
86 static_assert(FluidSystem::numPhases == 2,
87 "A fluid system with two phases is required "
90 typedef Opm::TwoPhaseMaterialTraits<Scalar,
91 FluidSystem::liquidPhaseIdx,
92 FluidSystem::gasPhaseIdx>
96 typedef Opm::LinearMaterial<Traits> type;
133 template <
class TypeTag>
136 typedef typename GET_PROP_TYPE(TypeTag, BaseProblem) ParentType;
140 typedef typename
GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
141 typedef typename
GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
147 numPhases = FluidSystem::numPhases,
150 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
151 gasPhaseIdx = FluidSystem::gasPhaseIdx,
154 H2OIdx = FluidSystem::H2OIdx,
155 N2Idx = FluidSystem::N2Idx,
158 dim = GridView::dimension,
159 dimWorld = GridView::dimensionworld
163 typedef typename
GET_PROP_TYPE(TypeTag, RateVector) RateVector;
164 typedef typename
GET_PROP_TYPE(TypeTag, BoundaryRateVector) BoundaryRateVector;
166 typedef typename
GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
167 typedef typename
GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
169 typedef typename GridView::ctype CoordScalar;
170 typedef Dune::FieldVector<CoordScalar, dimWorld> GlobalPosition;
172 typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
179 : ParentType(simulator)
187 ParentType::finishInit();
191 temperature_ = 273.15 + 20.0;
193 materialParams_.finalize();
195 K_ = this->toDimMatrix_(1e-12);
197 setupInitialFluidStates_();
209 {
return std::string(
"diffusion_") + Model::name(); }
217 this->model().checkConservativeness();
221 this->model().globalStorage(storage);
224 if (this->gridView().comm().rank() == 0) {
225 std::cout <<
"Storage: " << storage << std::endl << std::flush;
240 template <
class Context>
242 unsigned spaceIdx OPM_UNUSED,
243 unsigned timeIdx OPM_UNUSED)
const
249 template <
class Context>
251 unsigned spaceIdx OPM_UNUSED,
252 unsigned timeIdx OPM_UNUSED)
const
258 template <
class Context>
259 const MaterialLawParams&
261 unsigned spaceIdx OPM_UNUSED,
262 unsigned timeIdx OPM_UNUSED)
const
263 {
return materialParams_; }
268 template <
class Context>
270 unsigned spaceIdx OPM_UNUSED,
271 unsigned timeIdx OPM_UNUSED)
const
272 {
return temperature_; }
286 template <
class Context>
288 const Context& context OPM_UNUSED,
289 unsigned spaceIdx OPM_UNUSED,
290 unsigned timeIdx OPM_UNUSED)
const
291 { values.setNoFlow(); }
303 template <
class Context>
305 const Context& context,
307 unsigned timeIdx)
const
309 const auto& pos = context.pos(spaceIdx, timeIdx);
310 if (onLeftSide_(pos))
311 values.assignNaive(leftInitialFluidState_);
313 values.assignNaive(rightInitialFluidState_);
322 template <
class Context>
324 const Context& context OPM_UNUSED,
325 unsigned spaceIdx OPM_UNUSED,
326 unsigned timeIdx OPM_UNUSED)
const
327 { rate = Scalar(0.0); }
332 bool onLeftSide_(
const GlobalPosition& pos)
const
333 {
return pos[0] < (this->boundingBoxMin()[0] + this->boundingBoxMax()[0]) / 2; }
335 void setupInitialFluidStates_()
338 leftInitialFluidState_.setTemperature(temperature_);
341 leftInitialFluidState_.setSaturation(liquidPhaseIdx, Sl);
342 leftInitialFluidState_.setSaturation(gasPhaseIdx, 1 - Sl);
345 leftInitialFluidState_.setPressure(liquidPhaseIdx, p);
346 leftInitialFluidState_.setPressure(gasPhaseIdx, p);
349 leftInitialFluidState_.setMoleFraction(gasPhaseIdx, H2OIdx, xH2O);
350 leftInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O);
352 typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
353 typename FluidSystem::template ParameterCache<Scalar> paramCache;
354 CFRP::solve(leftInitialFluidState_, paramCache, gasPhaseIdx,
358 rightInitialFluidState_.assign(leftInitialFluidState_);
360 rightInitialFluidState_.setMoleFraction(gasPhaseIdx, H2OIdx, xH2O);
361 rightInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O);
362 CFRP::solve(rightInitialFluidState_, paramCache, gasPhaseIdx,
367 MaterialLawParams materialParams_;
369 Opm::CompositionalFluidState<Scalar, FluidSystem> leftInitialFluidState_;
370 Opm::CompositionalFluidState<Scalar, FluidSystem> rightInitialFluidState_;
#define SET_BOOL_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant boolean value.
Definition: propertysystem.hh:361
const MaterialLawParams & materialLawParams(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:260
void source(RateVector &rate, const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: diffusionproblem.hh:323
void finishInit()
Called by the Ewoms::Simulator in order to initialize the problem.
Definition: diffusionproblem.hh:185
void endTimeStep()
Called by the simulator after each time integration.
Definition: diffusionproblem.hh:214
std::string name() const
The problem name.
Definition: diffusionproblem.hh:208
1D problem which is driven by molecular diffusion.
Definition: diffusionproblem.hh:52
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
#define SET_INT_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant integer value.
Definition: propertysystem.hh:345
Declares the properties required for the NCP compositional multi-phase model.
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the initial value for a control volume.
Definition: diffusionproblem.hh:304
Scalar temperature(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:269
Provides a grid manager which a regular grid made of quadrilaterals.
#define SET_PROP(EffTypeTagName, PropTagName)
Set a property for a specific type tag.
Definition: propertysystem.hh:297
Scalar porosity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:250
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
const DimMatrix & intrinsicPermeability(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: diffusionproblem.hh:241
Provides a grid manager which a regular grid made of quadrilaterals.
Definition: cubegridmanager.hh:65
void boundary(BoundaryRateVector &values, const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Evaluate the boundary conditions for a boundary segment.
Definition: diffusionproblem.hh:287
#define SET_SCALAR_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant scalar value.
Definition: propertysystem.hh:394