26#ifndef DUMUX_1P3C_TEST_PROBLEM_HH
27#define DUMUX_1P3C_TEST_PROBLEM_HH
30#include <dune/grid/uggrid.hh>
32#include <dune/grid/yaspgrid.hh>
44#include "../1p2c/spatialparams.hh"
51template <
class TypeTag>
52class MaxwellStefanOnePThreeCTestProblem;
65template<
class TypeTag>
66struct Grid<TypeTag, TTag::MaxwellStefanOnePThreeCTest> {
using type = Dune::UGGrid<2>; };
68template<
class TypeTag>
69struct Grid<TypeTag, TTag::MaxwellStefanOnePThreeCTest> {
using type = Dune::YaspGrid<2>; };
73template<
class TypeTag>
80template<
class TypeTag>
82:
public FluidSystems::Base<GetPropType<TypeTag, Properties::Scalar>, H2N2CO2FluidSystem<TypeTag>>
101 {
return "MaxwellStefan_" + std::to_string(compIdx); }
112 case H2Idx:
return 0.002;
113 case N2Idx:
return 0.028;
116 DUNE_THROW(Dune::InvalidStateException,
"Invalid component index " << compIdx);;
130 template <
class Flu
idState>
136 if (compIIdx > compJIdx)
139 swap(compIIdx, compJIdx);
148 DUNE_THROW(Dune::InvalidStateException,
149 "Binary diffusion coefficient of components "
150 << compIIdx <<
" and " << compJIdx <<
" is undefined!\n");
161 template <
class Flu
idState>
165 Scalar T = fluidState.temperature(phaseIdx);
166 Scalar p = fluidState.pressure(phaseIdx);
177 template <
class Flu
idState>
194 template <
class Flu
idState>
197 Scalar T = fluidState.temperature(phaseIdx);
198 Scalar p = fluidState.pressure(phaseIdx);
204template<
class TypeTag>
209template<
class TypeTag>
218template<
class TypeTag>
219struct UseMoles<TypeTag, TTag::MaxwellStefanOnePThreeCTest> {
static constexpr bool value =
true; };
222template<
class TypeTag>
239template <
class TypeTag>
256 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
258 using Element =
typename GridGeometry::GridView::template Codim<0>::Entity;
259 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
265 name_ = getParam<std::string>(
"Problem.Name");
269 std::cout<<
"problem uses mole fractions" <<
'\n';
271 std::cout<<
"problem uses mass fractions" <<
'\n';
285 const std::string&
name()
const
295 {
return 273.15 + 20; }
302 Scalar x_co2_left = 0.0;
303 Scalar x_n2_left = 0.0;
304 Scalar x_co2_right = 0.0;
305 Scalar x_n2_right = 0.0;
306 Scalar x_h2_left = 0.0;
307 Scalar x_h2_right = 0.0;
312 for (
const auto& element : elements(this->
gridGeometry().gridView()))
315 fvGeometry.bindElement(element);
318 for (
auto&& scv : scvs(fvGeometry))
320 const auto& globalPos = scv.dofPosition();
321 VolumeVariables volVars;
322 volVars.update(elemSol, *
this, element, scv);
324 if (globalPos[0] < 0.5)
326 x_co2_left += volVars.moleFraction(0,2);
328 x_n2_left += volVars.moleFraction(0,1);
329 x_h2_left += volVars.moleFraction(0,0);
334 x_co2_right += volVars.moleFraction(0,2);
335 x_n2_right += volVars.moleFraction(0,1);
336 x_h2_right += volVars.moleFraction(0,0);
350 y_.push_back(x_n2_left);
351 y2_.push_back(x_n2_right);
352 y3_.push_back(x_co2_left);
353 y4_.push_back(x_co2_right);
354 y5_.push_back(x_h2_left);
355 y6_.push_back(x_h2_right);
357 gnuplot_.resetPlot();
358 gnuplot_.setXRange(0, std::min(time, 72000.0));
359 gnuplot_.setYRange(0.4, 0.6);
360 gnuplot_.setXlabel(
"time [s]");
361 gnuplot_.setYlabel(
"mole fraction mol/mol");
362 gnuplot_.addDataSetToPlot(x_, y_,
"N2_left.dat",
"w l t 'N_2 left'");
363 gnuplot_.addDataSetToPlot(x_, y2_,
"N2_right.dat",
"w l t 'N_2 right'");
364 gnuplot_.plot(
"mole_fraction_N2");
366 gnuplot2_.resetPlot();
367 gnuplot2_.setXRange(0, std::min(time, 72000.0));
368 gnuplot2_.setYRange(0.0, 0.6);
369 gnuplot2_.setXlabel(
"time [s]");
370 gnuplot2_.setYlabel(
"mole fraction mol/mol");
371 gnuplot2_.addDataSetToPlot(x_, y3_,
"CO2_left.dat",
"w l t 'CO_2 left'");
372 gnuplot2_.addDataSetToPlot(x_, y4_,
"CO2_right.dat",
"w l t 'CO_2 right");
373 gnuplot2_.plot(
"mole_fraction_CO2");
375 gnuplot3_.resetPlot();
376 gnuplot3_.setXRange(0, std::min(time, 72000.0));
377 gnuplot3_.setYRange(0.0, 0.6);
378 gnuplot3_.setXlabel(
"time [s]");
379 gnuplot3_.setYlabel(
"mole fraction mol/mol");
380 gnuplot3_.addDataSetToPlot(x_, y5_,
"H2_left.dat",
"w l t 'H_2 left'");
381 gnuplot3_.addDataSetToPlot(x_, y6_,
"H2_right.dat",
"w l t 'H_2 right'");
382 gnuplot3_.plot(
"mole_fraction_H2");
402 BoundaryTypes values;
403 values.setAllNeumann();
413 {
return NumEqVector(0.0); }
429 PrimaryVariables initialValues(0.0);
430 if (globalPos[0] < 0.5)
432 initialValues[Indices::pressureIdx] = 1e5;
433 initialValues[FluidSystem::N2Idx] = 0.50086;
434 initialValues[FluidSystem::CO2Idx] = 0.49914;
438 initialValues[Indices::pressureIdx] = 1e5;
439 initialValues[FluidSystem::N2Idx] = 0.49879;
440 initialValues[FluidSystem::CO2Idx] = 0.0;
442 return initialValues;
454 std::vector<Scalar> x_;
455 std::vector<Scalar> y_;
456 std::vector<Scalar> y2_;
457 std::vector<Scalar> y3_;
458 std::vector<Scalar> y4_;
459 std::vector<Scalar> y5_;
460 std::vector<Scalar> y6_;
Defines a type tag and some properties for models using the box scheme.
Properties for all models using cell-centered finite volume scheme with TPFA.
free functions for the evaluation of primary variable gradients inside elements.
free functions for the evaluation of primary variables inside elements.
This file contains the data which is required to calculate diffusive mass fluxes due to molecular dif...
Interface for passing data sets to a file and plotting them, if gnuplot is installed.
Relations valid for an ideal gas.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:115
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
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
The DUNE grid type.
Definition: common/properties.hh:57
UndefinedProperty type
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
The type for the calculation of the molecular diffusion fluxes.
Definition: common/properties.hh:212
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
Definition: maxwellstefanslaw.hh:37
Interface for passing data sets to a file and plotting them, if gnuplot is installed.
Definition: gnuplotinterface.hh:57
Fluid system base class.
Definition: fluidsystems/base.hh:45
static Scalar density(const FluidState &fluidState, int phaseIdx)
Calculate the density of a fluid phase.
Definition: fluidsystems/base.hh:134
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: fluidsystems/base.hh:326
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: fluidsystems/base.hh:160
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: fluidsystems/base.hh:236
Relations valid for an ideal gas.
Definition: idealgas.hh:37
static constexpr Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of the gas , depending on pressure and temperature.
Definition: idealgas.hh:70
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
Definition of the spatial parameters for the 1pnc test problems.
Definition: porousmediumflow/1pnc/implicit/1p2c/spatialparams.hh:41
Definition of a problem for a 1p3c problem: Component transport of N2, CO2 and H2.
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:241
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:412
MaxwellStefanOnePThreeCTestProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:262
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:427
const std::string & name() const
The problem name. This is used as a prefix for files generated by the simulation.
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:285
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/1pnc/implicit/1p3c/problem.hh:400
void plotComponentsOverTime(const SolutionVector &curSol, Scalar time)
Called after every time step.
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:298
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:294
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:58
std::tuple< OnePNC > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:58
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:59
std::tuple< MaxwellStefanOnePThreeCTest, BoxModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:59
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:60
std::tuple< MaxwellStefanOnePThreeCTest, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:60
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:69
A simple fluid system with three components for testing the multi-component diffusion with the Maxwel...
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:84
static constexpr int CO2Idx
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:97
static Scalar density(const FluidState &fluidState, const int phaseIdx)
Given a phase's composition, temperature, pressure, and the partial pressures of all components,...
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:162
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculates the dynamic viscosity of a fluid phase .
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:178
static constexpr int N2Idx
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:96
static constexpr int numComponents
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:93
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:195
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, returns the binary diffusion coefficient for ...
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:131
static std::string componentName(int compIdx)
Human readable component name (index compIdx) (for vtk output)
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:100
static constexpr int H2Idx
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:95
static constexpr int numPhases
The number of phases.
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:92
static std::string phaseName(int phaseIdx=0)
Human readable phase name (index phaseIdx) (for velocity vtk output)
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:104
static Scalar molarMass(unsigned int compIdx)
Molar mass in kg/mol of the component with index compIdx.
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:108
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:212
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1pnc/implicit/1p3c/problem.hh:213
Adaption of the fully implicit model to the one-phase n-component flow model.
Base class for all porous media problems.