Class NewtonSolver

Inheritance Relationships

Derived Types

Class Documentation

class amici::NewtonSolver

The NewtonSolver class sets up the linear solver for the Newton method.

Subclassed by amici::NewtonSolverDense, amici::NewtonSolverIterative, amici::NewtonSolverSparse

Public Functions

NewtonSolver(realtype *t, AmiVector *x, Model *model)

Initializes all members with the provided objects.

Parameters
  • t – pointer to time variable

  • x – pointer to state variables

  • model – pointer to the model object

void getStep(int ntry, int nnewt, AmiVector &delta)

Computes the solution of one Newton iteration.

Parameters
  • ntry – integer newton_try integer start number of Newton solver (1 or 2)

  • nnewt – integer number of current Newton step

  • delta – containing the RHS of the linear system, will be overwritten by solution to the linear system

void computeNewtonSensis(AmiVectorArray &sx)

Computes steady state sensitivities.

Parameters

sx – pointer to state variable sensitivities

inline const std::vector<int> &getNumLinSteps() const

Accessor for numlinsteps.

Returns

numlinsteps

virtual void prepareLinearSystem(int ntry, int nnewt) = 0

Writes the Jacobian for the Newton iteration and passes it to the linear solver.

Parameters
  • ntry – integer newton_try integer start number of Newton solver (1 or 2)

  • nnewt – integer number of current Newton step

virtual void prepareLinearSystemB(int ntry, int nnewt) = 0

Writes the Jacobian (JB) for the Newton iteration and passes it to the linear solver

Parameters
  • ntry – integer newton_try integer start number of Newton solver (1 or 2)

  • nnewt – integer number of current Newton step

virtual void solveLinearSystem(AmiVector &rhs) = 0

Solves the linear system for the Newton step.

Parameters

rhs – containing the RHS of the linear system, will be overwritten by solution to the linear system

virtual ~NewtonSolver() = default

Public Members

int max_lin_steps_ = {0}

maximum number of allowed linear steps per Newton step for steady state computation

int max_steps = {0}

maximum number of allowed Newton steps for steady state computation

realtype atol_ = {1e-16}

absolute tolerance

realtype rtol_ = {1e-8}

relative tolerance

NewtonDampingFactorMode damping_factor_mode_ = {NewtonDampingFactorMode::on}

damping factor flag

realtype damping_factor_lower_bound = {1e-8}

damping factor lower bound

Public Static Functions

static std::unique_ptr<NewtonSolver> getSolver(realtype *t, AmiVector *x, Solver &simulationSolver, Model *model)

Factory method to create a NewtonSolver based on linsolType.

Parameters
  • t – pointer to time variable

  • x – pointer to state variables

  • simulationSolver – solver with settings

  • model – pointer to the model object

Returns

solver NewtonSolver according to the specified linsolType

Protected Attributes

realtype *t_

time variable

Model *model_

pointer to the model object

AmiVector xdot_

right hand side AmiVector

AmiVector *x_

current state

AmiVector dx_

current state time derivative (DAE)

std::vector<int> num_lin_steps_

history of number of linear steps

AmiVector xB_

current adjoint state

AmiVector dxB_

current adjoint state time derivative (DAE)