version 3.10-dev
electrochemistryni.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_ELECTROCHEMISTRY_NI_HH
13#define DUMUX_ELECTROCHEMISTRY_NI_HH
14
17
18namespace Dumux {
19
28template <class Scalar, class Indices, class FluidSystem, class GridGeometry, ElectroChemistryModel electroChemistryModel>
29class ElectroChemistryNI : public ElectroChemistry<Scalar, Indices, FluidSystem, GridGeometry, electroChemistryModel>
30{
33
34 enum {
35 //equation indices
36 contiH2OEqIdx = Indices::conti0EqIdx + FluidSystem::H2OIdx,
37 contiO2EqIdx = Indices::conti0EqIdx + FluidSystem::O2Idx,
38 energyEqIdx = Indices::energyEqIdx, //energy equation
39 };
40
41 using GridView = typename GridGeometry::GridView;
42 static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethods::box;
43 using GlobalPosition = typename Dune::FieldVector<typename GridView::ctype, GridView::dimensionworld>;
44 using CellVector = typename Dune::FieldVector<typename GridView::ctype, GridView::dimension>;
45
46public:
56 template<class SourceValues>
57 static void reactionSource(SourceValues &values, Scalar currentDensity,
58 const std::string& paramGroup = "")
59 {
60 //correction to account for actually relevant reaction area
61 //current density has to be divided by the half length of the box
62 //\todo Do we have multiply with the electrochemically active surface area (ECSA) here instead?
63 static Scalar gridYMax = getParamFromGroup<GlobalPosition>(paramGroup, "Grid.UpperRight")[1];
64 static Scalar nCellsY = getParamFromGroup<GlobalPosition>(paramGroup, "Grid.Cells")[1];
65
66 // Warning: This assumes the reaction layer is always just one cell (cell-centered) or half a box (box) thick
67 const auto lengthBox = gridYMax/nCellsY;
68 if (isBox)
69 currentDensity *= 2.0/lengthBox;
70 else
71 currentDensity *= 1.0/lengthBox;
72
73 static Scalar transportNumberH2O = getParam<Scalar>("ElectroChemistry.TransportNumberH20");
74 static Scalar thermoneutralVoltage = getParam<Scalar>("ElectroChemistry.ThermoneutralVoltage");
75 static Scalar cellVoltage = getParam<Scalar>("ElectroChemistry.CellVoltage");
76
77 //calculation of flux terms with faraday equation
78 values[contiH2OEqIdx] = currentDensity/(2*Constant::F); //reaction term in reaction layer
79 values[contiH2OEqIdx] += currentDensity/Constant::F*transportNumberH2O; //osmotic term in membrane
80 values[contiO2EqIdx] = -currentDensity/(4*Constant::F); //O2-equation
81 values[energyEqIdx] = (thermoneutralVoltage - cellVoltage)*currentDensity; //energy equation
82 }
83};
84
85} // end namespace Dumux
86
87#endif
A central place for various physical constants occurring in some equations.
Definition: constants.hh:27
static constexpr Scalar F
Faraday constant .
Definition: constants.hh:54
This class calculates source terms and current densities for fuel cells with the electrochemical mode...
Definition: electrochemistry.hh:41
Class calculating source terms and current densities for fuel cells with the electrochemical models s...
Definition: electrochemistryni.hh:30
static void reactionSource(SourceValues &values, Scalar currentDensity, const std::string &paramGroup="")
Calculates reaction sources with an electrochemical model approach.
Definition: electrochemistryni.hh:57
A central place for various physical constants occurring in some equations.
Electrochemical model for a fuel cell application.
constexpr Box box
Definition: method.hh:147
Definition: adapt.hh:17