add integrator parameters to the InterfaceKinetics::advanceCoverages & ImplicitSurfChem constructor to allow users to modfiy
This commit is contained in:
parent
654e582bc0
commit
d2cb02f254
4 changed files with 46 additions and 8 deletions
|
|
@ -61,8 +61,16 @@ public:
|
|||
* @param k Vector of pointers to InterfaceKinetics objects Each object
|
||||
* consists of a surface or an edge containing internal degrees of
|
||||
* freedom representing the concentration of surface adsorbates.
|
||||
* @param rtol The relative tolerance for the integrator
|
||||
* @param atol The absolute tolerance for the integrator
|
||||
* @param maxStepSize The maximum step-size the integrator is allowed to take
|
||||
* @param maxSteps the maximum number of time-steps the integrator can take
|
||||
* @param maxErrTestFails the maximum permissible number of error test failures
|
||||
*/
|
||||
ImplicitSurfChem(std::vector<InterfaceKinetics*> k);
|
||||
ImplicitSurfChem(std::vector<InterfaceKinetics*> k,
|
||||
doublereal rtol=1.e-7, doublereal atol=1.e-14,
|
||||
doublereal maxStepSize=0, size_t maxSteps=0,
|
||||
size_t maxErrTestFails=0);
|
||||
|
||||
virtual ~ImplicitSurfChem() {};
|
||||
|
||||
|
|
@ -230,6 +238,8 @@ protected:
|
|||
std::unique_ptr<Integrator> m_integ;
|
||||
doublereal m_atol, m_rtol; // tolerances
|
||||
doublereal m_maxstep; //!< max step size
|
||||
size_t m_nmax; //!< maximum number of steps allowed
|
||||
size_t m_maxErrTestFails; //!< maximum number of error test failures allowed
|
||||
vector_fp m_work;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -240,8 +240,16 @@ public:
|
|||
* \f]
|
||||
*
|
||||
* @param tstep Time value to advance the surface coverages
|
||||
* @param rtol The relative tolerance for the integrator
|
||||
* @param atol The absolute tolerance for the integrator
|
||||
* @param maxStepSize The maximum step-size the integrator is allowed to take
|
||||
* @param maxSteps the maximum number of time-steps the integrator can take
|
||||
* before reaching tstep
|
||||
* @param maxErrTestFails the maximum permissible number of error test failures
|
||||
*/
|
||||
void advanceCoverages(doublereal tstep);
|
||||
void advanceCoverages(doublereal tstep, doublereal rtol=1.e-7,
|
||||
doublereal atol=1.e-14, doublereal maxStepSize=0,
|
||||
size_t maxSteps=0, size_t maxErrTestFails=0);
|
||||
|
||||
//! Solve for the pseudo steady-state of the surface problem
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -17,13 +17,18 @@ using namespace std;
|
|||
namespace Cantera
|
||||
{
|
||||
|
||||
ImplicitSurfChem::ImplicitSurfChem(vector<InterfaceKinetics*> k) :
|
||||
ImplicitSurfChem::ImplicitSurfChem(
|
||||
vector<InterfaceKinetics*> k, doublereal rtol, doublereal atol,
|
||||
doublereal maxStepSize, size_t maxSteps,
|
||||
size_t maxErrTestFails) :
|
||||
m_nv(0),
|
||||
m_numTotalBulkSpecies(0),
|
||||
m_numTotalSpecies(0),
|
||||
m_atol(1.e-14),
|
||||
m_rtol(1.e-7),
|
||||
m_maxstep(0.0),
|
||||
m_atol(atol),
|
||||
m_rtol(rtol),
|
||||
m_maxstep(maxStepSize),
|
||||
m_nmax(maxSteps),
|
||||
m_maxErrTestFails(maxErrTestFails),
|
||||
m_mediumSpeciesStart(-1),
|
||||
m_bulkSpeciesStart(-1),
|
||||
m_surfSpeciesStart(-1),
|
||||
|
|
@ -107,6 +112,18 @@ void ImplicitSurfChem::getState(doublereal* c)
|
|||
void ImplicitSurfChem::initialize(doublereal t0)
|
||||
{
|
||||
m_integ->setTolerances(m_rtol, m_atol);
|
||||
if (m_maxstep > 0)
|
||||
{
|
||||
m_integ->setMaxStepSize(m_maxstep);
|
||||
}
|
||||
if (m_nmax > 0)
|
||||
{
|
||||
m_integ->setMaxSteps(m_nmax);
|
||||
}
|
||||
if (m_maxErrTestFails > 0)
|
||||
{
|
||||
m_integ->setMaxErrTestFails(m_maxErrTestFails);
|
||||
}
|
||||
m_integ->initialize(t0, *this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -767,11 +767,14 @@ doublereal InterfaceKinetics::electrochem_beta(size_t irxn) const
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
void InterfaceKinetics::advanceCoverages(doublereal tstep)
|
||||
void InterfaceKinetics::advanceCoverages(doublereal tstep, doublereal rtol,
|
||||
doublereal atol, doublereal maxStepSize,
|
||||
size_t maxSteps, size_t maxErrTestFails)
|
||||
{
|
||||
if (m_integrator == 0) {
|
||||
vector<InterfaceKinetics*> k{this};
|
||||
m_integrator = new ImplicitSurfChem(k);
|
||||
m_integrator = new ImplicitSurfChem(k, rtol, atol, maxStepSize, maxSteps,
|
||||
maxErrTestFails);
|
||||
m_integrator->initialize();
|
||||
}
|
||||
m_integrator->integrate(0.0, tstep);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue