Cantera  4.0.0a2
Loading...
Searching...
No Matches
SteadyStateSystem Class Referenceabstract

Base class for representing a system of differential-algebraic equations and solving for its steady-state response. More...

#include <SteadyStateSystem.h>

Inheritance diagram for SteadyStateSystem:
[legend]

Detailed Description

Base class for representing a system of differential-algebraic equations and solving for its steady-state response.

Since
New in Cantera 3.2.

Definition at line 40 of file SteadyStateSystem.h.

Public Member Functions

 SteadyStateSystem (const SteadyStateSystem &)=delete
 
SteadyStateSystemoperator= (const SteadyStateSystem &)=delete
 
virtual void eval (span< const double > x, span< double > r, double rdt=-1.0, int count=1)=0
 Evaluate the residual function.
 
virtual void evalJacobian (span< const double > x0)=0
 Evaluates the Jacobian at x0 using finite differences.
 
virtual double weightedNorm (span< const double > step) const =0
 Compute the weighted norm of step.
 
void setInitialGuess (span< const double > x)
 Set the initial guess. Should be called before solve().
 
void solve (int loglevel=0)
 Solve the steady-state problem, taking internal timesteps as necessary until the Newton solver can converge for the steady problem.
 
void getState (span< double > x) const
 Get the converged steady-state solution after calling solve().
 
double ssnorm (span< const double > x, span< double > r)
 Steady-state max norm (infinity norm) of the residual evaluated using solution x.
 
double tsnorm (span< const double > x, span< double > r)
 Transient max norm (infinity norm) of the residual evaluated using solution x and the current timestep (rdt).
 
size_t size () const
 Total solution vector length;.
 
virtual void resize ()
 Call to set the size of internal data structures after first defining the system or if the problem size changes, for example after grid refinement.
 
size_t bandwidth () const
 Jacobian bandwidth.
 
virtual string componentName (size_t i) const
 Get the name of the i-th component of the state vector.
 
virtual pair< string, string > componentTableHeader () const
 Get header lines describing the column names included in a component label.
 
virtual string componentTableLabel (size_t i) const
 Get elements of the component name, aligned with the column headings given by componentTableHeader().
 
virtual double upperBound (size_t i) const =0
 Get the upper bound for global component i in the state vector.
 
virtual double lowerBound (size_t i) const =0
 Get the lower bound for global component i in the state vector.
 
MultiNewtonnewton ()
 Return a reference to the Newton iterator.
 
void setLinearSolver (shared_ptr< SystemJacobian > solver)
 Set the linear solver used to hold the Jacobian matrix and solve linear systems as part of each Newton iteration.
 
shared_ptr< SystemJacobianlinearSolver () const
 Get the the linear solver being used to hold the Jacobian matrix and solve linear systems as part of each Newton iteration.
 
double rdt () const
 Reciprocal of the time step.
 
bool transient () const
 True if transient mode.
 
bool steady () const
 True if steady mode.
 
virtual void initTimeInteg (double dt, span< const double > x)
 Prepare for time stepping beginning with solution x and timestep dt.
 
virtual void setSteadyMode ()
 Prepare to solve the steady-state problem.
 
vector< int > & transientMask ()
 Access the vector indicating which equations contain a transient term.
 
double timeStep (int nsteps, double dt, span< double > x, span< double > r, int loglevel)
 Take time steps using Backward Euler.
 
virtual void resetBadValues (span< double > x)
 Reset values such as negative species concentrations.
 
void setJacAge (int ss_age, int ts_age=-1)
 Set the maximum number of steps that can be taken using the same Jacobian before it must be re-evaluated.
 
void setInterrupt (Func1 *interrupt)
 Set a function that will be called every time eval is called.
 
void setTimeStepCallback (Func1 *callback)
 Set a function that will be called after each successful timestep.
 
void setJacobianPerturbation (double relative, double absolute, double threshold)
 Configure perturbations used to evaluate finite difference Jacobian.
 
virtual void writeDebugInfo (const string &header_suffix, const string &message, int loglevel, int attempt_counter)
 Write solver debugging based on the specified log level.
 
virtual void clearDebugFile ()
 Delete debug output file that may be created by writeDebugInfo() when solving with high loglevel.
 
Solver statistics

Per-grid solver statistics, collected after each successful solve on a grid.

Times are wall-clock seconds.

const AnyMapsolverStats ()
 Return solver statistics as a map of per-grid arrays.
 
virtual void saveStats ()
 Commit statistics for the current grid into m_stats and reset the staging counters.
 
virtual void clearStats ()
 Clear all saved solver statistics and reset the staging counters.
 
void recordFactorization (double wallTime)
 Record wall-clock time [s] spent factorizing the Jacobian.
 
void recordLinearSolve (double wallTime)
 Record wall-clock time [s] spent in a linear solve.
 
void factorizeJacobian ()
 Update the transient term of the Jacobian (forming and factorizing \( M = I - \gamma J \)) and record the elapsed wall-clock time as a factorization in the solver statistics.
 
Options
void setTimeStep (double stepsize, span< const int > tsteps)
 Set the number of time steps to try when the steady Newton solver is unsuccessful.
 
void setMinTimeStep (double tmin)
 Set the minimum time step allowed during time stepping.
 
void setMaxTimeStep (double tmax)
 Set the maximum time step allowed during time stepping.
 
void setTimeStepFactor (double tfactor)
 Sets a factor by which the time step is reduced if the time stepping fails.
 
void setTimeStepGrowthFactor (double tfactor)
 Set the growth factor used after successful timesteps when the Jacobian is re-used.
 
double timeStepGrowthFactor () const
 Get the successful-step time step growth factor.
 
void setTimeStepGrowthStrategy (const string &strategy)
 Set the strategy used to grow the timestep after a successful step that reuses the current Jacobian.
 
string timeStepGrowthStrategy () const
 Get the configured timestep growth strategy.
 
void setMaxTimeStepCount (int nmax)
 Set the maximum number of timeteps allowed before successful steady-state solve.
 
int maxTimeStepCount () const
 Get the maximum number of timeteps allowed before successful steady-state solve.
 

Protected Types

enum class  TimeStepGrowthStrategy {
  fixed , steadyNorm , transientResidual , residualRatio ,
  newtonIterations
}
 

Protected Member Functions

virtual size_t gridSize () const
 Value reported as grid_points in solver statistics.
 
void evalSSJacobian (span< const double > x)
 Evaluate the steady-state Jacobian, accessible via linearSolver()
 
double calculateTimeStepGrowthFactor (span< const double > x_before, span< const double > x_after)
 Determine the timestep growth factor after a successful step.
 

Static Protected Member Functions

static TimeStepGrowthStrategy parseTimeStepGrowthStrategy (const string &strategy)
 
static string timeStepGrowthStrategyName (TimeStepGrowthStrategy strategy)
 

Protected Attributes

vector< int > m_steps = { 10 }
 Array of number of steps to take after each unsuccessful steady-state solve before re-attempting the steady-state solution.
 
double m_tstep = 1.0e-5
 Initial timestep.
 
double m_tmin = 1e-16
 Minimum timestep size.
 
double m_tmax = 1e+08
 Maximum timestep size.
 
double m_tfactor = 0.5
 Factor time step is multiplied by if time stepping fails ( < 1 )
 
double m_tstep_growth = 1.5
 Growth factor for successful steps that reuse the Jacobian.
 
TimeStepGrowthStrategy m_tstep_growth_strategy = TimeStepGrowthStrategy::fixed
 Selected strategy for successful-step growth.
 
shared_ptr< vector< double > > m_state
 Solution vector.
 
vector< double > m_xnew
 Work array used to hold the residual or the new solution.
 
vector< double > m_xlast_ts
 State vector after the last successful set of time steps.
 
unique_ptr< MultiNewtonm_newt
 Newton iterator.
 
double m_rdt = 0.0
 Reciprocal of time step.
 
shared_ptr< SystemJacobianm_jac
 Jacobian evaluator.
 
bool m_jac_ok = false
 If true, Jacobian is current.
 
size_t m_bw = 0
 Jacobian bandwidth.
 
size_t m_size = 0
 Solution vector size
 
vector< double > m_work1
 Work arrays used during Jacobian evaluation.
 
vector< double > m_work2
 
vector< int > m_mask
 Transient mask.
 
int m_ss_jac_age = 20
 Maximum age of the Jacobian in steady-state mode.
 
int m_ts_jac_age = 20
 Maximum age of the Jacobian in time-stepping mode.
 
int m_attempt_counter = 0
 Counter used to manage the number of states stored in the debug log file generated by writeDebugInfo()
 
int m_max_history = 10
 Constant that determines the maximum number of states stored in the debug log file generated by writeDebugInfo()
 
Func1m_interrupt = nullptr
 Function called at the start of every call to eval.
 
Func1m_time_step_callback = nullptr
 User-supplied function called after each successful timestep.
 
int m_nsteps = 0
 Number of time steps taken in the current call to solve()
 
int m_nsteps_max = 500
 Maximum number of timesteps allowed per call to solve()
 
double m_jacobianThreshold = 0.0
 Threshold for ignoring small elements in Jacobian.
 
double m_jacobianRelPerturb = 1e-5
 Relative perturbation of each component in finite difference Jacobian.
 
double m_jacobianAbsPerturb = 1e-10
 Absolute perturbation of each component in finite difference Jacobian.
 
Solver-statistics storage

m_stats holds committed per-grid statistics (arrays indexed by grid); the remaining members are staging accumulators for the current grid, committed by saveStats().

AnyMap m_stats
 Committed per-grid statistics.
 
int m_nevals = 0
 Standalone residual evaluations (not Jacobian fill)
 
double m_evaltime = 0.0
 Wall time [s] in standalone residual evals.
 
int m_factorizations = 0
 Jacobian factorizations on the current grid.
 
double m_factorTime = 0.0
 Wall time [s] factorizing the Jacobian.
 
int m_linearSolves = 0
 Linear solves on the current grid.
 
double m_solveTime = 0.0
 Wall time [s] in linear solves.
 
double m_gridTime = 0.0
 Total wall time [s] solving on the current grid.
 

Member Enumeration Documentation

◆ TimeStepGrowthStrategy

enum class TimeStepGrowthStrategy
strongprotected

Definition at line 376 of file SteadyStateSystem.h.

Constructor & Destructor Documentation

◆ SteadyStateSystem()

Definition at line 17 of file SteadyStateSystem.cpp.

◆ ~SteadyStateSystem()

~SteadyStateSystem ( )
virtual

Definition at line 24 of file SteadyStateSystem.cpp.

Member Function Documentation

◆ eval()

virtual void eval ( span< const double >  x,
span< double >  r,
double  rdt = -1.0,
int  count = 1 
)
pure virtual

Evaluate the residual function.

Parameters
[in]xState vector
[out]rOn return, contains the residual vector
rdtReciprocal of the time step. if omitted, then the internally stored value (accessible using the rdt() method) is used.
countSet to zero to omit this call from the statistics

Implemented in OneDim, Sim1D, and SteadyReactorSolver.

◆ evalJacobian()

virtual void evalJacobian ( span< const double >  x0)
pure virtual

Evaluates the Jacobian at x0 using finite differences.

The Jacobian is computed by perturbing each component of x0, evaluating the residual function, and then estimating the partial derivatives numerically using finite differences to determine the corresponding column of the Jacobian.

Parameters
x0State vector at which to evaluate the Jacobian

Implemented in OneDim, and SteadyReactorSolver.

◆ weightedNorm()

virtual double weightedNorm ( span< const double >  step) const
pure virtual

Compute the weighted norm of step.

The purpose is to measure the "size" of the step vector \( \Delta x \) in a way that takes into account the relative importance or scale of different solution components. Each component of the step vector is normalized by a weight that depends on both the current magnitude of the solution vector and specified tolerances. This makes the norm dimensionless and scaled appropriately, avoiding issues where some components dominate due to differences in their scales. See OneDim::weightedNorm() for a representative implementation.

Implemented in OneDim, and SteadyReactorSolver.

◆ setInitialGuess()

void setInitialGuess ( span< const double >  x)

Set the initial guess. Should be called before solve().

Definition at line 89 of file SteadyStateSystem.cpp.

◆ solve()

void solve ( int  loglevel = 0)

Solve the steady-state problem, taking internal timesteps as necessary until the Newton solver can converge for the steady problem.

Parameters
loglevelControls amount of diagnostic output.

Definition at line 101 of file SteadyStateSystem.cpp.

◆ getState()

void getState ( span< double >  x) const

Get the converged steady-state solution after calling solve().

Definition at line 96 of file SteadyStateSystem.cpp.

◆ ssnorm()

double ssnorm ( span< const double >  x,
span< double >  r 
)

Steady-state max norm (infinity norm) of the residual evaluated using solution x.

On return, array r contains the steady-state residual values.

Definition at line 361 of file SteadyStateSystem.cpp.

◆ tsnorm()

double tsnorm ( span< const double >  x,
span< double >  r 
)

Transient max norm (infinity norm) of the residual evaluated using solution x and the current timestep (rdt).

On return, array r contains the transient residual values.

Definition at line 371 of file SteadyStateSystem.cpp.

◆ size()

size_t size ( ) const
inline

Total solution vector length;.

Definition at line 99 of file SteadyStateSystem.h.

◆ resize()

void resize ( )
virtual

Call to set the size of internal data structures after first defining the system or if the problem size changes, for example after grid refinement.

The m_size variable should be updated before calling this method

Reimplemented in OneDim, and Sim1D.

Definition at line 387 of file SteadyStateSystem.cpp.

◆ bandwidth()

size_t bandwidth ( ) const
inline

Jacobian bandwidth.

Definition at line 110 of file SteadyStateSystem.h.

◆ componentName()

virtual string componentName ( size_t  i) const
inlinevirtual

Get the name of the i-th component of the state vector.

Reimplemented in OneDim, and SteadyReactorSolver.

Definition at line 115 of file SteadyStateSystem.h.

◆ componentTableHeader()

virtual pair< string, string > componentTableHeader ( ) const
inlinevirtual

Get header lines describing the column names included in a component label.

Headings should be aligned with items formatted in the output of componentTableLabel(). Two lines are allowed. If only one is needed, the first line should be blank.

Reimplemented in OneDim.

Definition at line 121 of file SteadyStateSystem.h.

◆ componentTableLabel()

virtual string componentTableLabel ( size_t  i) const
inlinevirtual

Get elements of the component name, aligned with the column headings given by componentTableHeader().

Reimplemented in OneDim.

Definition at line 127 of file SteadyStateSystem.h.

◆ upperBound()

virtual double upperBound ( size_t  i) const
pure virtual

Get the upper bound for global component i in the state vector.

Implemented in OneDim, and SteadyReactorSolver.

◆ lowerBound()

virtual double lowerBound ( size_t  i) const
pure virtual

Get the lower bound for global component i in the state vector.

Implemented in OneDim, and SteadyReactorSolver.

◆ newton()

MultiNewton & newton ( )

Return a reference to the Newton iterator.

Definition at line 454 of file SteadyStateSystem.cpp.

◆ setLinearSolver()

void setLinearSolver ( shared_ptr< SystemJacobian solver)

Set the linear solver used to hold the Jacobian matrix and solve linear systems as part of each Newton iteration.

Definition at line 403 of file SteadyStateSystem.cpp.

◆ linearSolver()

shared_ptr< SystemJacobian > linearSolver ( ) const
inline

Get the the linear solver being used to hold the Jacobian matrix and solve linear systems as part of each Newton iteration.

Definition at line 144 of file SteadyStateSystem.h.

◆ solverStats()

const AnyMap & solverStats ( )
inline

Return solver statistics as a map of per-grid arrays.

Keys: grid_points, steps, residual_evals, residual_time, jacobian_evals, jacobian_time, factorizations, factor_time, linear_solves, solve_time, total_time.

This method is non-const because it calls saveStats() to flush statistics for the current (possibly not-yet-committed) grid before returning.

An entry whose total_time is 0 corresponds to a grid where the solve attempt failed (threw) before completing; its other timing fields will also be partial.

Definition at line 163 of file SteadyStateSystem.h.

◆ saveStats()

void saveStats ( )
virtual

Commit statistics for the current grid into m_stats and reset the staging counters.

A no-op unless at least one Jacobian evaluation and one residual evaluation have occurred since the last commit.

Definition at line 36 of file SteadyStateSystem.cpp.

◆ clearStats()

void clearStats ( )
virtual

Clear all saved solver statistics and reset the staging counters.

Definition at line 66 of file SteadyStateSystem.cpp.

◆ recordFactorization()

void recordFactorization ( double  wallTime)
inline

Record wall-clock time [s] spent factorizing the Jacobian.

Called by the Newton solver.

Definition at line 178 of file SteadyStateSystem.h.

◆ recordLinearSolve()

void recordLinearSolve ( double  wallTime)
inline

Record wall-clock time [s] spent in a linear solve.

Called by the Newton solver.

Definition at line 185 of file SteadyStateSystem.h.

◆ factorizeJacobian()

void factorizeJacobian ( )

Update the transient term of the Jacobian (forming and factorizing \( M = I - \gamma J \)) and record the elapsed wall-clock time as a factorization in the solver statistics.

Used at every factorization site so that factor_time accounts for steady and time-stepping factorizations alike.

Definition at line 28 of file SteadyStateSystem.cpp.

◆ rdt()

double rdt ( ) const
inline

Reciprocal of the time step.

Definition at line 199 of file SteadyStateSystem.h.

◆ transient()

bool transient ( ) const
inline

True if transient mode.

Definition at line 204 of file SteadyStateSystem.h.

◆ steady()

bool steady ( ) const
inline

True if steady mode.

Definition at line 209 of file SteadyStateSystem.h.

◆ initTimeInteg()

void initTimeInteg ( double  dt,
span< const double >  x 
)
virtual

Prepare for time stepping beginning with solution x and timestep dt.

Reimplemented in OneDim, and SteadyReactorSolver.

Definition at line 421 of file SteadyStateSystem.cpp.

◆ setSteadyMode()

void setSteadyMode ( )
virtual

Prepare to solve the steady-state problem.

After invoking this method, subsequent calls to solve() will solve the steady-state problem. Sets the reciprocal of the time step to zero, and, if it was previously non-zero, signals that a new Jacobian will be needed.

Reimplemented in OneDim.

Definition at line 432 of file SteadyStateSystem.cpp.

◆ transientMask()

vector< int > & transientMask ( )
inline

Access the vector indicating which equations contain a transient term.

Elements are 1 for equations with a transient terms and 0 otherwise.

Definition at line 224 of file SteadyStateSystem.h.

◆ timeStep()

double timeStep ( int  nsteps,
double  dt,
span< double >  x,
span< double >  r,
int  loglevel 
)

Take time steps using Backward Euler.

Parameters
nstepsnumber of steps
dtinitial step size
xcurrent solution vector
rsolution vector after time stepping
loglevelcontrols amount of printed diagnostics
Returns
size of last timestep taken

Definition at line 268 of file SteadyStateSystem.cpp.

◆ resetBadValues()

virtual void resetBadValues ( span< double >  x)
inlinevirtual

Reset values such as negative species concentrations.

Reimplemented in OneDim, and SteadyReactorSolver.

Definition at line 240 of file SteadyStateSystem.h.

◆ setTimeStep()

void setTimeStep ( double  stepsize,
span< const int >  tsteps 
)

Set the number of time steps to try when the steady Newton solver is unsuccessful.

Parameters
stepsizeInitial time step size [s]
tstepsA sequence of time step counts to take after subsequent failures of the steady-state solver. The last value in tsteps will be used again after further unsuccessful solution attempts.

Definition at line 381 of file SteadyStateSystem.cpp.

◆ setMinTimeStep()

void setMinTimeStep ( double  tmin)
inline

Set the minimum time step allowed during time stepping.

Definition at line 254 of file SteadyStateSystem.h.

◆ setMaxTimeStep()

void setMaxTimeStep ( double  tmax)
inline

Set the maximum time step allowed during time stepping.

Definition at line 259 of file SteadyStateSystem.h.

◆ setTimeStepFactor()

void setTimeStepFactor ( double  tfactor)
inline

Sets a factor by which the time step is reduced if the time stepping fails.

The default value is 0.5.

Parameters
tfactorfactor time step is multiplied by if time stepping fails

Definition at line 267 of file SteadyStateSystem.h.

◆ setTimeStepGrowthFactor()

void setTimeStepGrowthFactor ( double  tfactor)
inline

Set the growth factor used after successful timesteps when the Jacobian is re-used.

This factor is used directly by the fixed-growth strategy, and as the accepted growth factor or upper bound for the other named strategies.

The default value is 1.5, matching historical behavior.

Parameters
tfactorFinite growth factor applied to successful timesteps; must be >= 1.0.

Definition at line 280 of file SteadyStateSystem.h.

◆ timeStepGrowthFactor()

double timeStepGrowthFactor ( ) const
inline

Get the successful-step time step growth factor.

Definition at line 290 of file SteadyStateSystem.h.

◆ setTimeStepGrowthStrategy()

void setTimeStepGrowthStrategy ( const string &  strategy)

Set the strategy used to grow the timestep after a successful step that reuses the current Jacobian.

Available options are:

The default strategy is fixed-growth, which matches historical behavior.

Definition at line 215 of file SteadyStateSystem.cpp.

◆ timeStepGrowthStrategy()

string timeStepGrowthStrategy ( ) const

Get the configured timestep growth strategy.

Definition at line 220 of file SteadyStateSystem.cpp.

◆ setMaxTimeStepCount()

void setMaxTimeStepCount ( int  nmax)
inline

Set the maximum number of timeteps allowed before successful steady-state solve.

Definition at line 315 of file SteadyStateSystem.h.

◆ maxTimeStepCount()

int maxTimeStepCount ( ) const
inline

Get the maximum number of timeteps allowed before successful steady-state solve.

Definition at line 320 of file SteadyStateSystem.h.

◆ setJacAge()

void setJacAge ( int  ss_age,
int  ts_age = -1 
)

Set the maximum number of steps that can be taken using the same Jacobian before it must be re-evaluated.

Parameters
ss_ageAge limit during steady-state mode
ts_ageAge limit during time stepping mode. If not specified, the steady-state age is also used during time stepping.

Definition at line 444 of file SteadyStateSystem.cpp.

◆ setInterrupt()

void setInterrupt ( Func1 interrupt)
inline

Set a function that will be called every time eval is called.

Can be used to provide keyboard interrupt support in the high-level language interfaces.

Definition at line 335 of file SteadyStateSystem.h.

◆ setTimeStepCallback()

void setTimeStepCallback ( Func1 callback)
inline

Set a function that will be called after each successful timestep.

The function will be called with the size of the timestep as the argument. Intended to be used for observing solver progress for debugging purposes.

Definition at line 343 of file SteadyStateSystem.h.

◆ setJacobianPerturbation()

void setJacobianPerturbation ( double  relative,
double  absolute,
double  threshold 
)
inline

Configure perturbations used to evaluate finite difference Jacobian.

Parameters
relativeRelative perturbation (multiplied by the absolute value of each component). Default 1.0e-5.
absoluteAbsolute perturbation (independent of component value). Default 1.0e-10.
thresholdThreshold below which to exclude elements from the Jacobian Default 0.0.

Definition at line 354 of file SteadyStateSystem.h.

◆ writeDebugInfo()

virtual void writeDebugInfo ( const string &  header_suffix,
const string &  message,
int  loglevel,
int  attempt_counter 
)
inlinevirtual

Write solver debugging based on the specified log level.

See also
Sim1D::writeDebugInfo for a specific implementation of this capability.

Reimplemented in Sim1D, and SteadyReactorSolver.

Definition at line 363 of file SteadyStateSystem.h.

◆ clearDebugFile()

virtual void clearDebugFile ( )
inlinevirtual

Delete debug output file that may be created by writeDebugInfo() when solving with high loglevel.

Reimplemented in Sim1D.

Definition at line 368 of file SteadyStateSystem.h.

◆ gridSize()

virtual size_t gridSize ( ) const
inlineprotectedvirtual

Value reported as grid_points in solver statistics.

Overridden by subclasses with a meaningful grid-point count; defaults to the total number of unknowns.

Reimplemented in OneDim.

Definition at line 374 of file SteadyStateSystem.h.

◆ evalSSJacobian()

void evalSSJacobian ( span< const double >  x)
protected

Evaluate the steady-state Jacobian, accessible via linearSolver()

Parameters
[in]xCurrent state vector, length size()

Definition at line 412 of file SteadyStateSystem.cpp.

◆ parseTimeStepGrowthStrategy()

SteadyStateSystem::TimeStepGrowthStrategy parseTimeStepGrowthStrategy ( const string &  strategy)
staticprotected

Definition at line 178 of file SteadyStateSystem.cpp.

◆ timeStepGrowthStrategyName()

string timeStepGrowthStrategyName ( TimeStepGrowthStrategy  strategy)
staticprotected

Definition at line 197 of file SteadyStateSystem.cpp.

◆ calculateTimeStepGrowthFactor()

double calculateTimeStepGrowthFactor ( span< const double >  x_before,
span< const double >  x_after 
)
protected

Determine the timestep growth factor after a successful step.

Called only when a successful step reuses the current Jacobian.

Definition at line 225 of file SteadyStateSystem.cpp.

Member Data Documentation

◆ m_steps

vector<int> m_steps = { 10 }
protected

Array of number of steps to take after each unsuccessful steady-state solve before re-attempting the steady-state solution.

For subsequent time stepping calls, the final value is reused. See setTimeStep().

Definition at line 400 of file SteadyStateSystem.h.

◆ m_tstep

double m_tstep = 1.0e-5
protected

Initial timestep.

Definition at line 402 of file SteadyStateSystem.h.

◆ m_tmin

double m_tmin = 1e-16
protected

Minimum timestep size.

Definition at line 403 of file SteadyStateSystem.h.

◆ m_tmax

double m_tmax = 1e+08
protected

Maximum timestep size.

Definition at line 404 of file SteadyStateSystem.h.

◆ m_tfactor

double m_tfactor = 0.5
protected

Factor time step is multiplied by if time stepping fails ( < 1 )

Definition at line 407 of file SteadyStateSystem.h.

◆ m_tstep_growth

double m_tstep_growth = 1.5
protected

Growth factor for successful steps that reuse the Jacobian.

Used directly for fixed-growth, and as the base / cap value for the other named growth strategies.

Definition at line 413 of file SteadyStateSystem.h.

◆ m_tstep_growth_strategy

TimeStepGrowthStrategy m_tstep_growth_strategy = TimeStepGrowthStrategy::fixed
protected

Selected strategy for successful-step growth.

Definition at line 416 of file SteadyStateSystem.h.

◆ m_state

shared_ptr<vector<double> > m_state
protected

Solution vector.

Definition at line 418 of file SteadyStateSystem.h.

◆ m_xnew

vector<double> m_xnew
protected

Work array used to hold the residual or the new solution.

Definition at line 421 of file SteadyStateSystem.h.

◆ m_xlast_ts

vector<double> m_xlast_ts
protected

State vector after the last successful set of time steps.

Definition at line 424 of file SteadyStateSystem.h.

◆ m_newt

unique_ptr<MultiNewton> m_newt
protected

Newton iterator.

Definition at line 426 of file SteadyStateSystem.h.

◆ m_rdt

double m_rdt = 0.0
protected

Reciprocal of time step.

Definition at line 427 of file SteadyStateSystem.h.

◆ m_jac

shared_ptr<SystemJacobian> m_jac
protected

Jacobian evaluator.

Definition at line 429 of file SteadyStateSystem.h.

◆ m_jac_ok

bool m_jac_ok = false
protected

If true, Jacobian is current.

Definition at line 430 of file SteadyStateSystem.h.

◆ m_bw

size_t m_bw = 0
protected

Jacobian bandwidth.

Definition at line 432 of file SteadyStateSystem.h.

◆ m_size

size_t m_size = 0
protected

Solution vector size

Definition at line 433 of file SteadyStateSystem.h.

◆ m_work1

vector<double> m_work1
protected

Work arrays used during Jacobian evaluation.

Definition at line 436 of file SteadyStateSystem.h.

◆ m_work2

vector<double> m_work2
protected

Definition at line 436 of file SteadyStateSystem.h.

◆ m_mask

vector<int> m_mask
protected

Transient mask.

See transientMask()

Definition at line 438 of file SteadyStateSystem.h.

◆ m_ss_jac_age

int m_ss_jac_age = 20
protected

Maximum age of the Jacobian in steady-state mode.

Definition at line 439 of file SteadyStateSystem.h.

◆ m_ts_jac_age

int m_ts_jac_age = 20
protected

Maximum age of the Jacobian in time-stepping mode.

Definition at line 440 of file SteadyStateSystem.h.

◆ m_attempt_counter

int m_attempt_counter = 0
protected

Counter used to manage the number of states stored in the debug log file generated by writeDebugInfo()

Definition at line 444 of file SteadyStateSystem.h.

◆ m_max_history

int m_max_history = 10
protected

Constant that determines the maximum number of states stored in the debug log file generated by writeDebugInfo()

Definition at line 448 of file SteadyStateSystem.h.

◆ m_interrupt

Func1* m_interrupt = nullptr
protected

Function called at the start of every call to eval.

Definition at line 451 of file SteadyStateSystem.h.

◆ m_time_step_callback

Func1* m_time_step_callback = nullptr
protected

User-supplied function called after each successful timestep.

Definition at line 454 of file SteadyStateSystem.h.

◆ m_nsteps

int m_nsteps = 0
protected

Number of time steps taken in the current call to solve()

Definition at line 456 of file SteadyStateSystem.h.

◆ m_nsteps_max

int m_nsteps_max = 500
protected

Maximum number of timesteps allowed per call to solve()

Definition at line 457 of file SteadyStateSystem.h.

◆ m_stats

AnyMap m_stats
protected

Committed per-grid statistics.

Each key holds an array indexed by grid. Schema is established in clearStats().

Definition at line 467 of file SteadyStateSystem.h.

◆ m_nevals

int m_nevals = 0
protected

Standalone residual evaluations (not Jacobian fill)

Definition at line 469 of file SteadyStateSystem.h.

◆ m_evaltime

double m_evaltime = 0.0
protected

Wall time [s] in standalone residual evals.

Definition at line 470 of file SteadyStateSystem.h.

◆ m_factorizations

int m_factorizations = 0
protected

Jacobian factorizations on the current grid.

Definition at line 471 of file SteadyStateSystem.h.

◆ m_factorTime

double m_factorTime = 0.0
protected

Wall time [s] factorizing the Jacobian.

Definition at line 472 of file SteadyStateSystem.h.

◆ m_linearSolves

int m_linearSolves = 0
protected

Linear solves on the current grid.

Definition at line 473 of file SteadyStateSystem.h.

◆ m_solveTime

double m_solveTime = 0.0
protected

Wall time [s] in linear solves.

Definition at line 474 of file SteadyStateSystem.h.

◆ m_gridTime

double m_gridTime = 0.0
protected

Total wall time [s] solving on the current grid.

Definition at line 475 of file SteadyStateSystem.h.

◆ m_jacobianThreshold

double m_jacobianThreshold = 0.0
protected

Threshold for ignoring small elements in Jacobian.

Definition at line 479 of file SteadyStateSystem.h.

◆ m_jacobianRelPerturb

double m_jacobianRelPerturb = 1e-5
protected

Relative perturbation of each component in finite difference Jacobian.

Definition at line 481 of file SteadyStateSystem.h.

◆ m_jacobianAbsPerturb

double m_jacobianAbsPerturb = 1e-10
protected

Absolute perturbation of each component in finite difference Jacobian.

Definition at line 483 of file SteadyStateSystem.h.


The documentation for this class was generated from the following files: