25#ifndef DUMUX_FUELCELL_PROBLEM_HH
26#define DUMUX_FUELCELL_PROBLEM_HH
28#include <dune/grid/yaspgrid.hh>
49template <
class TypeTag>
56struct FuelCell {
using InheritsFrom = std::tuple<TwoPNCNI>; };
57struct FuelCellNIBox {
using InheritsFrom = std::tuple<FuelCell, BoxModel>; };
66template<
class TypeTag>
67struct Grid<TypeTag, TTag::FuelCell> {
using type = Dune::YaspGrid<2>; };
70template<
class TypeTag>
74template<
class TypeTag>
83template<
class TypeTag>
88template<
class TypeTag>
105template <
class TypeTag>
118 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
120 using Element =
typename GridView::template Codim<0>::Entity;
130 static constexpr int dim = GridView::dimension;
131 static constexpr int dimWorld = GridView::dimensionworld;
133 using GlobalPosition =
typename SubControlVolume::GlobalPosition;
135 enum { dofCodim = isBox ? dim : 0 };
140 nTemperature_ = getParam<int>(
"Problem.NTemperature");
141 nPressure_ = getParam<int>(
"Problem.NPressure");
142 pressureLow_ = getParam<Scalar>(
"Problem.PressureLow");
143 pressureHigh_ = getParam<Scalar>(
"Problem.PressureHigh");
144 temperatureLow_ = getParam<Scalar>(
"Problem.TemperatureLow");
145 temperatureHigh_ = getParam<Scalar>(
"Problem.TemperatureHigh");
146 temperature_ = getParam<Scalar>(
"Problem.InitialTemperature");
148 name_ = getParam<std::string>(
"Problem.Name");
150 pO2Inlet_ = getParam<Scalar>(
"ElectroChemistry.pO2Inlet");
152 FluidSystem::init(temperatureLow_,
169 const std::string&
name()
const
178 {
return temperature_; }
181 NumEqVector
source(
const Element &element,
182 const FVElementGeometry& fvGeometry,
183 const ElementVolumeVariables& elemVolVars,
184 const SubControlVolume &scv)
const
186 NumEqVector values(0.0);
187 const auto& globalPos = scv.dofPosition();
190 if(inReactionLayer_(globalPos))
192 const auto& volVars = elemVolVars[scv];
214 BoundaryTypes bcTypes;
215 bcTypes.setAllNeumann();
217 if (onUpperBoundary_(globalPos)){
218 bcTypes.setAllDirichlet();
230 auto priVars = initial_(globalPos);
232 if(onUpperBoundary_(globalPos))
235 priVars[Indices::pressureIdx] = pn;
236 priVars[Indices::switchIdx] = 0.3;
237 priVars[Indices::switchIdx+1] = pO2Inlet_/4.315e9;
239 priVars[Indices::temperatureIdx] = 293.15;
257 {
return initial_(globalPos); }
265 template<
class VTKWriter>
269 currentDensity_.resize(gridView.size(dofCodim));
270 reactionSourceH2O_.resize(gridView.size(dofCodim));
271 reactionSourceO2_.resize(gridView.size(dofCodim));
272 Kxx_.resize(gridView.size(dofCodim));
273 Kyy_.resize(gridView.size(dofCodim));
275 vtk.addField(currentDensity_,
"currentDensity [A/cm^2]");
276 vtk.addField(reactionSourceH2O_,
"reactionSourceH2O [mol/(sm^2)]");
277 vtk.addField(reactionSourceO2_,
"reactionSourceO2 [mol/(sm^2)]");
278 vtk.addField(Kxx_,
"Kxx");
279 vtk.addField(Kyy_,
"Kyy");
284 for (
const auto& element : elements(this->
gridGeometry().gridView()))
289 fvGeometry.bindElement(element);
291 for (
auto&& scv : scvs(fvGeometry))
293 VolumeVariables volVars;
294 volVars.update(elemSol, *
this, element, scv);
295 const auto& globalPos = scv.dofPosition();
296 const auto dofIdxGlobal = scv.dofIndex();
298 if(inReactionLayer_(globalPos))
305 reactionSourceH2O_[dofIdxGlobal] =
source[Indices::conti0EqIdx + FluidSystem::H2OIdx];
306 reactionSourceO2_[dofIdxGlobal] =
source[Indices::conti0EqIdx + FluidSystem::O2Idx];
309 currentDensity_[dofIdxGlobal] = i/10000;
313 reactionSourceH2O_[dofIdxGlobal] = 0.0;
314 reactionSourceO2_[dofIdxGlobal] = 0.0;
315 currentDensity_[dofIdxGlobal] = 0.0;
317 Kxx_[dofIdxGlobal] = volVars.permeability()[0][0];
318 Kyy_[dofIdxGlobal] = volVars.permeability()[1][1];
325 PrimaryVariables initial_(
const GlobalPosition &globalPos)
const
327 PrimaryVariables priVars(0.0);
328 priVars.setState(Indices::bothPhases);
331 priVars[Indices::pressureIdx] = pn;
332 priVars[Indices::switchIdx] = 0.3;
333 priVars[Indices::switchIdx+1] = pO2Inlet_/4.315e9;
335 priVars[Indices::temperatureIdx] = 293.15;
341 bool onUpperBoundary_(
const GlobalPosition &globalPos)
const
342 {
return globalPos[1] > this->
gridGeometry().bBoxMax()[1] - eps_; }
344 bool inReactionLayer_(
const GlobalPosition& globalPos)
const
348 static constexpr Scalar eps_ = 1e-6;
352 Scalar pressureLow_, pressureHigh_;
353 Scalar temperatureLow_, temperatureHigh_;
355 std::vector<double> currentDensity_;
356 std::vector<double> reactionSourceH2O_;
357 std::vector<double> reactionSourceO2_;
358 std::vector<double> Kxx_;
359 std::vector<double> Kyy_;
A two-phase (water and air) fluid system with water, nitrogen and oxygen as components.
Electrochemical model for a fuel cell application.
Electrochemical model for a fuel cell application.
Element solution classes and factory functions.
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.
@ p1s0
first phase saturation and second phase pressure as primary variables
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
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
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 formulation of the model.
Definition: common/properties.hh:237
This class calculates source terms and current densities for fuel cells with the electrochemical mode...
Definition: electrochemistry.hh:53
static void reactionSource(SourceValues &values, Scalar currentDensity, const std::string ¶mGroup="")
Calculates reaction sources with an electrochemical model approach.
Definition: electrochemistry.hh:92
static Scalar calculateCurrentDensity(const VolumeVariables &volVars)
Newton solver for calculation of the current density.
Definition: electrochemistry.hh:122
Class calculating source terms and current densities for fuel cells with the electrochemical models s...
Definition: electrochemistryni.hh:42
A two-phase (water and air) fluid system with water, nitrogen and oxygen as components.
Definition: h2on2o2.hh:78
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
Definition of a problem for water management in PEM fuel cells.
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:107
void updateVtkFields(const SolutionVector &curSol)
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:282
Scalar temperature() const
Returns the temperature within the domain.
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:177
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/2pnc/implicit/fuelcell/problem.hh:212
void addVtkFields(VTKWriter &vtk)
Adds additional VTK output data to the VTKWriter.
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:266
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:181
FuelCellProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:137
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:169
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:228
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial values for a control volume.
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:256
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:59
std::tuple< TwoPNC > InheritsFrom
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:59
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:60
std::tuple< FuelCell, BoxModel > InheritsFrom
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:60
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:61
std::tuple< FuelCell, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:61
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:67
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:77
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/2pnc/implicit/fuelcell/problem.hh:78
Definition of the spatial parameters for the FuelCell problem which uses the isothermal 2p2c box mode...
Definition: porousmediumflow/2pnc/implicit/fuelcell/spatialparams.hh:46
Adaption of the fully implicit scheme to the two-phase n-component fully implicit model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.