Commit 58581947 authored by Gabi Seitz's avatar Gabi Seitz Committed by Dennis Gläser

[1pncmintest] rename test, add new reference and calculate source in separate file

parent 8aee86f7
# isothermal tests
add_input_file_links()
# add_executable(test_box1pncmin test_box1pncmin.cc)
# add_executable(test_cc1pncmin test_cc1pncmin.cc)
add_dumux_test(test_box1pncmin test_box1pncmin test_box1pncmin.cc
${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
--script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/box1pncmin-00042.vtu
${CMAKE_CURRENT_BINARY_DIR}/box1pncmin-00042.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_box1pncmin"
--zeroThreshold {"temperature":5e-6})
dune_add_test(NAME test_1pncminni_box
SOURCES test_1pncminni_fv.cc
COMPILE_DEFINITIONS TYPETAG=ThermoChemBoxProblem
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_1pncmin-00064_batch.vtu
${CMAKE_CURRENT_BINARY_DIR}/1pncmintest_batch_box-00065.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_1pncminni_box test_1pncminni_fv.input -Problem.Name 1pncmintest_batch_box"
--zeroThreshold {"precipVolFrac_CaOH2":5e-6})
add_dumux_test(test_cc1pncmin test_cc1pncmin test_cc1pncmin.cc
${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
--script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/cc1pncmin-00042.vtu
${CMAKE_CURRENT_BINARY_DIR}/cc1pncmin-00042.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_cc1pncmin"
--zeroThreshold {"temperature":5e-6})
#
# #install sources
#install sources
install(FILES
thermochempatialparams.hh
thermochemproblem.hh
test_box1pncmin.cc
test_cc1pncmin.cc
thermochemspatialparams.hh
thermochemreaction.hh
test_1pncminni_fv.cc
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/implicit/1pncmin)
# Parameter file for test case 1pncmin.
# Everything behind a '#' is a comment.
# Type "./test_1pncmin --help" for more information.
[TimeManager]
DtInitial = 1 # [s] initial time step size
MaxTimeStepSize = 50 # [s] maximum time step size
TEnd= 5000 # [s] duration of the simulation
FreqOutput = 10 # frequency of VTK output
WriteRestartFile = 1 # Boolean. Should restart files be written? (1) Yes (0) No
[Grid]
UpperRight = 0.08 0.01 #20 10 # # [m] upper right corner coordinates
Cells = 40 2 # 21 6 # [-] number of cells in x,y-direction
[FluidSystem]
NTemperature = 10 # [-] number of tabularization entries
NPressure = 100 # [-] number of tabularization entries
PressureLow = 1E5 # [Pa]low end for tabularization of fluid properties
PressureHigh = 1E6 # [Pa]high end for tabularization of fluid properties
TemperatureLow = 373.15 # [Pa]low end for tabularization of fluid properties
TemperatureHigh = 873.15 # [Pa]high end for tabularization of fluid properties
[Problem]
Name = thermochem
IsCharge = 1 # Bool: 1: charge; 0: discharge
[Charge]
PressureInitial = 1E5 # [Pa] Initial reservoir pressure
TemperatureInitial = 773.15 # [K] reservoir temperature
VaporInitial = 0.01 # [-] initial mole fraction of water
CaOInitial = 0.0 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
CaO2H2Initial = 0.3960 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
PressureIn = 1.02e5 # [Pa] Inlet pressure; charge
PressureOut = 1e5 # [Pa] outlet pressure
TemperatureIn = 773.15 # [K] inlet temperature: // Shao 500 °C
TemperatureOut = 673.15 # [K] outlet temperature: // Shao noflow
InFlow = 5 # [mol/s] Inflow of HTF // Shao 0.309 g/s (Area (0.015)^2pi m^2) --> here 1.55 mol/s
VaporIn = 0.01 # [] molefraction // Shao 0.01 [g/g]
[Discharge]
PressureInitial = 1E5 # [Pa] Initial reservoir pressure
TemperatureInitial = 573.15 # [K] reservoir temperature
VaporInitial = 0.35 # [-] initial mole fraction of water
CaOInitial = 0.2 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
CaO2H2Initial = 0.0
PressureIn = 1.05e5 # [Pa] Inlet pressure; charge
PressureOut = 1e5 # [Pa] outlet pressure
TemperatureIn = 573.15 # [K] inlet temperature: charge: 873 K ; discharge: 473K
TemperatureOut = 573.15 # [K] outlet temperature: charge: 573; discharge: outflow
InFlow = 5 # 0.277[mol/s] Inflow of HTF
VaporIn = 0.36 # [] molefraction
[Vtk]
AddVelocity = 0 # Add extra information
VtuWritingFreq = 1 # 1: write a vtu file at every timestep, 2: write a vtu file every second timestep ...
[LinearSolver]
ResidualReduction = 1e-6
[Newton]
MaxRelativeShift = 1e-6
2WriteConvergence = 1
[Output]
#Frequency of restart file, flux and VTK output
FreqRestart = 1000 # how often restart files are written out
FreqOutput = 50 # frequency of VTK output
FreqMassOutput = 2 # frequency of mass and evaporation rate output (Darcy)
FreqFluxOutput = 1000 # frequency of detailed flux output
FreqVaporFluxOutput = 2 # frequency of summarized flux output
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief Test for the 1pncminni model
*/
#include <config.h>
#include <iostream>
#include <dune/common/parallel/mpihelper.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
#include <dumux/common/dumuxmessage.hh>
#include <dumux/nonlinear/newtonmethod.hh>
#include <dumux/nonlinear/newtoncontroller.hh>
#include <dumux/linear/seqsolverbackend.hh>
#include <dumux/assembly/fvassembler.hh>
#include <dumux/io/vtkoutputmodule.hh>
#include "thermochemproblem.hh"
/*!
* \brief Provides an interface for customizing error messages associated with
* reading in parameters.
*
* \param progName The name of the program, that was tried to be started.
* \param errorMsg The error message that was issued by the start function.
* Comprises the thing that went wrong and a general help message.
*/
void usage(const char *progName, const std::string &errorMsg)
{
if (errorMsg.size() > 0) {
std::string errorMessageOut = "\nUsage: ";
errorMessageOut += progName;
errorMessageOut += " [options]\n";
errorMessageOut += errorMsg;
errorMessageOut += "\n\nThe list of mandatory options for this program is:\n"
"\t-ParameterFile Parameter file (Input file) \n";
std::cout << errorMessageOut
<< "\n";
}
}
int main(int argc, char** argv) try
{
using namespace Dumux;
// define the type tag for this problem
using TypeTag = TTAG(TYPETAG);
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// initialize MPI, finalize is done automatically on exit
const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv);
// print dumux start message
if (mpiHelper.rank() == 0)
DumuxMessage::print(/*firstCall=*/true);
// parse command line arguments and input file
Parameters::init(argc, argv, usage);
//////////////////////////////////////////////////////////////////////
// try to create a grid (from the given grid file or the input file)
/////////////////////////////////////////////////////////////////////
using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator);
GridCreator::makeGrid();
GridCreator::loadBalance();
////////////////////////////////////////////////////////////
// run instationary non-linear problem on this grid
////////////////////////////////////////////////////////////
// we compute on the leaf grid view
const auto& leafGridView = GridCreator::grid().leafGridView();
// create the finite volume grid geometry
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView);
fvGridGeometry->update();
// the problem (initial and boundary conditions)
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
auto problem = std::make_shared<Problem>(fvGridGeometry);
// the solution vector
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
SolutionVector x(fvGridGeometry->numDofs());
problem->applyInitialSolution(x);
auto xOld = x;
// the grid variables
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry);
gridVariables->init(x, xOld);
// get some time loop parameters
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
auto dt = getParam<Scalar>("TimeLoop.DtInitial");
auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions");
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
// intialize the vtk output module
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputFields::init(vtkWriter);
// Add model specific output fields
vtkWriter.addField(problem->getPerm(), "permeability");
vtkWriter.addField(problem->getPoro(), "porosity");
vtkWriter.addField(problem->getRRate(), "reactionRate");
// update the output fields before writing initial solution
problem->updateVtkOutput(x);
vtkWriter.write(0.0);
// instantiate time loop
auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd);
timeLoop->setMaxTimeStepSize(maxDt);
// the assembler with time loop for instationary problem
using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
// the linear solver
using LinearSolver = ILU0BiCGSTABBackend<TypeTag>;
auto linearSolver = std::make_shared<LinearSolver>();
// the non-linear solver
using NewtonController = Dumux::NewtonController<TypeTag>;
auto newtonController = std::make_shared<NewtonController>(leafGridView.comm(), timeLoop);
NewtonMethod<NewtonController, Assembler, LinearSolver> nonLinearSolver(newtonController, assembler, linearSolver);
// time loop
timeLoop->start(); do
{
// set time for problem for implicit Euler scheme
// problem->setTime( timeLoop->time() + timeLoop->timeStepSize() );
problem->setTimeStepSize( timeLoop->timeStepSize() );
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// try solving the non-linear system
for (int i = 0; i < maxDivisions; ++i)
{
// linearize & solve
auto converged = nonLinearSolver.solve(x);
if (converged)
break;
if (!converged && i == maxDivisions-1)
DUNE_THROW(Dune::MathError,
"Newton solver didn't converge after "
<< maxDivisions
<< " time-step divisions. dt="
<< timeLoop->timeStepSize()
<< ".\nThe solutions of the current and the previous time steps "
<< "have been saved to restart files.");
}
// make the new solution the old solution
xOld = x;
gridVariables->advanceTimeStep();
// advance to the time loop to the next step
timeLoop->advanceTimeStep();
// update the output fields before write
problem->updateVtkOutput(x);
// write vtk output
vtkWriter.write(timeLoop->time());
// report statistics of this time step
timeLoop->reportTimeStep();
// set new dt as suggested by newton controller
timeLoop->setTimeStepSize(newtonController->suggestTimeStepSize(timeLoop->timeStepSize()));
} while (!timeLoop->finished());
// finalize, print dumux message to say goodbye
timeLoop->finalize(leafGridView.comm());
if (mpiHelper.rank() == 0)
DumuxMessage::print(/*firstCall=*/false);
return 0;
}
catch (Dumux::ParameterException &e)
{
std::cerr << std::endl << e << " ---> Abort!" << std::endl;
return 1;
}
catch (Dune::DGFException & e)
{
std::cerr << "DGF exception thrown (" << e <<
"). Most likely, the DGF file name is wrong "
"or the DGF file is corrupted, "
"e.g. missing hash at end of file or wrong number (dimensions) of entries."
<< " ---> Abort!" << std::endl;
return 2;
}
catch (Dune::Exception &e)
{
std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl;
return 3;
}
catch (...)
{
std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl;
return 4;
}
......@@ -2,16 +2,16 @@
# Everything behind a '#' is a comment.
# Type "./test_1pncmin --help" for more information.
[TimeManager]
DtInitial = 1 # [s] initial time step size
MaxTimeStepSize = 50 # [s] maximum time step size
TEnd= 5000 # [s] duration of the simulation
[TimeLoop]
DtInitial = 0.5 # [s] initial time step size
MaxTimeStepSize =1 # [s] maximum time step size
TEnd= 150 # [s] duration of the simulation
FreqOutput = 10 # frequency of VTK output
WriteRestartFile = 1 # Boolean. Should restart files be written? (1) Yes (0) No
[Grid]
UpperRight = 0.08 0.01 #20 10 # # [m] upper right corner coordinates
Cells = 40 2 # 21 6 # [-] number of cells in x,y-direction
UpperRight = 0.02 0.01 #20 10 # # [m] upper right corner coordinates
Cells = 2 1 # 21 6 # [-] number of cells in x,y-direction
[FluidSystem]
NTemperature = 10 # [-] number of tabularization entries
......@@ -22,37 +22,18 @@ TemperatureLow = 373.15 # [Pa]low end for tabularization of fluid pr
TemperatureHigh = 873.15 # [Pa]high end for tabularization of fluid properties
[Problem]
Name = cc1pncmin
IsCharge = 1 # Bool: 1: charge; 0: discharge
[Charge]
PressureInitial = 1E5 # [Pa] Initial reservoir pressure
TemperatureInitial = 773.15 # [K] reservoir temperature
VaporInitial = 0.01 # [-] initial mole fraction of water
CaOInitial = 0.0 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
CaO2H2Initial = 0.3960 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
PressureIn = 1.02e5 # [Pa] Inlet pressure; charge
PressureOut = 1e5 # [Pa] outlet pressure
TemperatureIn = 773.15 # [K] inlet temperature: // Shao 500 °C
TemperatureOut = 673.15 # [K] outlet temperature: // Shao noflow
InFlow = 5 # [mol/s] Inflow of HTF // Shao 0.309 g/s (Area (0.015)^2pi m^2) --> here 1.55 mol/s
VaporIn = 0.01 # [] molefraction // Shao 0.01 [g/g]
[Discharge]
PressureInitial = 1E5 # [Pa] Initial reservoir pressure
Name = 1pncmin_test
PressureInitial = 2E5 # [Pa] Initial reservoir pressure
TemperatureInitial = 573.15 # [K] reservoir temperature
VaporInitial = 0.35 # [-] initial mole fraction of water
VaporInitial = 0.464 # [-] initial mole fraction of water
CaOInitial = 0.2 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
CaO2H2Initial = 0.0
PressureIn = 1.05e5 # [Pa] Inlet pressure; charge
PressureOut = 1e5 # [Pa] outlet pressure
TemperatureIn = 573.15 # [K] inlet temperature: charge: 873 K ; discharge: 473K
TemperatureOut = 573.15 # [K] outlet temperature: charge: 573; discharge: outflow
InFlow = 5 # 0.277[mol/s] Inflow of HTF
VaporIn = 0.36 # [] molefraction
BoundaryPressure= 2e5 # [Pa] outlet pressure
BoundaryTemperature = 573.15 # [K] inlet temperature: charge: 873 K ; discharge: 473K
BoundaryMoleFraction = 0.464 # [] molefraction
[Vtk]
AddVelocity = 0 # Add extra information
#AddVelocity = 0 # Add extra information
VtuWritingFreq = 1 # 1: write a vtu file at every timestep, 2: write a vtu file every second timestep ...
[LinearSolver]
......@@ -60,12 +41,4 @@ ResidualReduction = 1e-6
[Newton]
MaxRelativeShift = 1e-6
2WriteConvergence = 1
[Output]
#Frequency of restart file, flux and VTK output
FreqRestart = 1000 # how often restart files are written out
FreqOutput = 50 # frequency of VTK output
FreqMassOutput = 2 # frequency of mass and evaporation rate output (Darcy)
FreqFluxOutput = 1000 # frequency of detailed flux output
FreqVaporFluxOutput = 2 # frequency of summarized flux output
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief Test for the 2pnc box model used for water management in PEM fuel cells.
*/
#include <config.h>
#include "thermochemproblem.hh"
#include <dumux/common/start.hh>
/*!
* \brief Provides an interface for customizing error messages associated with
* reading in parameters.
*
* \param progName The name of the program, that was tried to be started.
* \param errorMsg The error message that was issued by the start function.
* Comprises the thing that went wrong and a general help message.
*/
void usage(const char *progName, const std::string &errorMsg)
{
if (errorMsg.size() > 0) {
std::string errorMessageOut = "\nUsage: ";
errorMessageOut += progName;
errorMessageOut += " [options]\n";
errorMessageOut += errorMsg;
errorMessageOut += "\n\nThe list of mandatory options for this program is:\n"
"\t-ParameterFile Parameter file (Input file) \n";
std::cout << errorMessageOut
<< "\n";
}
}
int main(int argc, char** argv)
{
using ProblemTypeTag = TTAG(ThermoChemBoxProblem);
return Dumux::start<ProblemTypeTag>(argc, argv, usage);
}
# Parameter file for test case 1pncmin.
# Everything behind a '#' is a comment.
# Type "./test_1pncmin --help" for more information.
[TimeManager]
DtInitial = 1 # [s] initial time step size
MaxTimeStepSize = 50 # [s] maximum time step size
TEnd= 5000 # [s] duration of the simulation
FreqOutput = 10 # frequency of VTK output
WriteRestartFile = 1 # Boolean. Should restart files be written? (1) Yes (0) No
[Grid]
UpperRight = 0.08 0.01 #20 10 # # [m] upper right corner coordinates
Cells = 40 2 # 21 6 # [-] number of cells in x,y-direction
[FluidSystem]
NTemperature = 10 # [-] number of tabularization entries
NPressure = 100 # [-] number of tabularization entries
PressureLow = 1E5 # [Pa]low end for tabularization of fluid properties
PressureHigh = 1E6 # [Pa]high end for tabularization of fluid properties
TemperatureLow = 373.15 # [Pa]low end for tabularization of fluid properties
TemperatureHigh = 873.15 # [Pa]high end for tabularization of fluid properties
[Problem]
Name = box1pncmin
IsCharge = 1 # Bool: 1: charge; 0: discharge
[Charge]
PressureInitial = 1E5 # [Pa] Initial reservoir pressure
TemperatureInitial = 773.15 # [K] reservoir temperature
VaporInitial = 0.01 # [-] initial mole fraction of water
CaOInitial = 0.0 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
CaO2H2Initial = 0.3960 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
PressureIn = 1.02e5 # [Pa] Inlet pressure; charge
PressureOut = 1e5 # [Pa] outlet pressure
TemperatureIn = 773.15 # [K] inlet temperature: // Shao 500 °C
TemperatureOut = 673.15 # [K] outlet temperature: // Shao noflow
InFlow = 5 # [mol/s] Inflow of HTF // Shao 0.309 g/s (Area (0.015)^2pi m^2) --> here 1.55 mol/s
VaporIn = 0.01 # [] molefraction // Shao 0.01 [g/g]
[Discharge]
PressureInitial = 1E5 # [Pa] Initial reservoir pressure
TemperatureInitial = 573.15 # [K] reservoir temperature
VaporInitial = 0.35 # [-] initial mole fraction of water
CaOInitial = 0.2 # [-] molefraction in the solid phase; 0 dehydration/charge, 1 hydration/discharge
CaO2H2Initial = 0.0
PressureIn = 1.05e5 # [Pa] Inlet pressure; charge
PressureOut = 1e5 # [Pa] outlet pressure
TemperatureIn = 573.15 # [K] inlet temperature: charge: 873 K ; discharge: 473K
TemperatureOut = 573.15 # [K] outlet temperature: charge: 573; discharge: outflow
InFlow = 5 # 0.277[mol/s] Inflow of HTF
VaporIn = 0.36 # [] molefraction
[Vtk]
AddVelocity = 0 # Add extra information
VtuWritingFreq = 1 # 1: write a vtu file at every timestep, 2: write a vtu file every second timestep ...
[LinearSolver]
ResidualReduction = 1e-6
[Newton]
MaxRelativeShift = 1e-6
2WriteConvergence = 1
[Output]
#Frequency of restart file, flux and VTK output
FreqRestart = 1000 # how often restart files are written out
FreqOutput = 50 # frequency of VTK output
FreqMassOutput = 2 # frequency of mass and evaporation rate output (Darcy)
FreqFluxOutput = 1000 # frequency of detailed flux output
FreqVaporFluxOutput = 2 # frequency of summarized flux output
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief Test for the 2pnc box model used for water management in PEM fuel cells.
*/
#include <config.h>
#include "thermochemproblem.hh"
#include <dumux/common/start.hh>
/*!
* \brief Provides an interface for customizing error messages associated with
* reading in parameters.
*
* \param progName The name of the program, that was tried to be started.
* \param errorMsg The error message that was issued by the start function.
* Comprises the thing that went wrong and a general help message.
*/
void usage(const char *progName, const std::string &errorMsg)
{
if (errorMsg.size() > 0) {
std::string errorMessageOut = "\nUsage: ";
errorMessageOut += progName;
errorMessageOut += " [options]\n";
errorMessageOut += errorMsg;
errorMessageOut += "\n\nThe list of mandatory options for this program is:\n"
"\t-ParameterFile Parameter file (Input file) \n";
std::cout << errorMessageOut
<< "\n";
}
}
int main(int argc, char** argv)
{
using ProblemTypeTag = TTAG(ThermoChemCCProblem);
return Dumux::start<ProblemTypeTag>(argc, argv, usage);
}
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup OnePNCMinTests
* \brief Class for the evaluation of the reaction rate of Calciumoxide to Halciumhydroxide
*
* It contains simple and advanced reaction kinetics according to Nagel et al. (2014).
*/
#ifndef DUMUX_THERMOCHEM_REACTION_HH
#define DUMUX_THERMOCHEM_REACTION_HH
#include <dumux/common/properties.hh>
namespace Dumux
{
/*!
* \ingroup OnePNCMinTests
* \brief Class for the evaluation of the reaction rate of Calciumoxide to Halciumhydroxide
*
* It contains simple and advanced reaction kinetics according to Nagel et al. (2014).
*/
template<class TypeTag>
class ThermoChemReaction
{
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
static const int numSolidPhases = GET_PROP_VALUE(TypeTag, NumSPhases);
enum{
// Indices of the primary variables
pressureIdx = Indices::pressureIdx, //gas-phase pressure
firstMoleFracIdx = Indices::firstMoleFracIdx, // mole fraction water
// Phase Indices
phaseIdx = FluidSystem::gPhaseIdx,
cPhaseIdx = FluidSystem::cPhaseIdx,
hPhaseIdx = FluidSystem::hPhaseIdx
};
public:
/*!
* \brief evaluates the reaction kinetics (see Nagel et al. 2014)
*/
Scalar thermoChemReaction(const VolumeVariables &volVars) const
{
// calculate the equilibrium temperature Teq
Scalar T= volVars.temperature();
Scalar Teq = 0;
Scalar moleFractionVapor = 1e-3;
if(volVars.moleFraction(phaseIdx, firstMoleFracIdx) > 1e-3)
moleFractionVapor = volVars.moleFraction(phaseIdx, firstMoleFracIdx);
if(volVars.moleFraction(phaseIdx, firstMoleFracIdx) >= 1.0) moleFractionVapor = 1;
Scalar pV = volVars.pressure(phaseIdx) *moleFractionVapor;
Scalar vaporPressure = pV*1.0e-5;
Scalar pFactor = log(vaporPressure);
Teq = -12845;
Teq /= (pFactor - 16.508); //the equilibrium temperature
Scalar realSolidDensityAverage = (volVars.<