solver.py

Define the base Solver, NonlinearSolver, and LinearSolver classes.

class openmdao.solvers.solver.BlockLinearSolver(**kwargs)[source]

Bases: openmdao.solvers.solver.LinearSolver

A base class for LinearBlockGS and LinearBlockJac.

SOLVER = 'base_solver'
__init__(**kwargs)

Initialize all attributes.

Parameters:
**kwargs : dict

options dictionary.

add_recorder(recorder)

Add a recorder to the solver’s RecordingManager.

Parameters:
recorder : <CaseRecorder>

A recorder instance to be added to RecManager.

cleanup()

Clean up resources prior to exit.

record_iteration(**kwargs)

Record an iteration of the current Solver.

Parameters:
**kwargs : dict

Keyword arguments (used for abs and rel error).

solve(vec_names, mode, rel_systems=None)

Run the solver.

Parameters:
vec_names : [str, …]

list of names of the right-hand-side vectors.

mode : str

‘fwd’ or ‘rev’.

rel_systems : set of str

Set of names of relevant systems based on the current linear solve.

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

initial error.

float

error at the first iteration.

class openmdao.solvers.solver.LinearSolver(**kwargs)[source]

Bases: openmdao.solvers.solver.Solver

Base class for linear solvers.

SOLVER = 'base_solver'
__init__(**kwargs)[source]

Initialize all attributes.

Parameters:
**kwargs : dict

options dictionary.

add_recorder(recorder)[source]

Add a recorder to the solver’s RecordingManager.

Parameters:
recorder : <CaseRecorder>

A recorder instance to be added to RecManager.

cleanup()

Clean up resources prior to exit.

record_iteration(**kwargs)

Record an iteration of the current Solver.

Parameters:
**kwargs : dict

Keyword arguments (used for abs and rel error).

solve(vec_names, mode, rel_systems=None)[source]

Run the solver.

Parameters:
vec_names : [str, …]

list of names of the right-hand-side vectors.

mode : str

‘fwd’ or ‘rev’.

rel_systems : set of str

Set of names of relevant systems based on the current linear solve.

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

initial error.

float

error at the first iteration.

class openmdao.solvers.solver.NonlinearSolver(**kwargs)[source]

Bases: openmdao.solvers.solver.Solver

Base class for nonlinear solvers.

SOLVER = 'base_solver'
__init__(**kwargs)[source]

Initialize all attributes.

Parameters:
**kwargs : dict

options dictionary.

add_recorder(recorder)

Add a recorder to the solver’s RecordingManager.

Parameters:
recorder : <CaseRecorder>

A recorder instance to be added to RecManager.

cleanup()

Clean up resources prior to exit.

record_iteration(**kwargs)

Record an iteration of the current Solver.

Parameters:
**kwargs : dict

Keyword arguments (used for abs and rel error).

solve()[source]

Run the solver.

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

absolute error.

float

relative error.

class openmdao.solvers.solver.Solver(**kwargs)[source]

Bases: object

Base solver class.

This class is subclassed by NonlinearSolver and LinearSolver, which are in turn subclassed by actual solver implementations.

Attributes

cite (str) Listing of relevant citations that should be referenced when publishing work that uses this class.
options (<OptionsDictionary>) Options dictionary.
recording_options (<OptionsDictionary>) Recording options dictionary.
supports (<OptionsDictionary>) Options dictionary describing what features are supported by this solver.
SOLVER = 'base_solver'
__init__(**kwargs)[source]

Initialize all attributes.

Parameters:
**kwargs : dict of keyword arguments

Keyword arguments that will be mapped into the Solver options.

add_recorder(recorder)[source]

Add a recorder to the solver’s RecordingManager.

Parameters:
recorder : <CaseRecorder>

A recorder instance to be added to RecManager.

cleanup()[source]

Clean up resources prior to exit.

record_iteration(**kwargs)[source]

Record an iteration of the current Solver.

Parameters:
**kwargs : dict

Keyword arguments (used for abs and rel error).

solve()[source]

Run the solver.

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

absolute error.

float

relative error.

class openmdao.solvers.solver.SolverInfo[source]

Bases: object

Communal object for storing some formatting for solver iprint.

Attributes

prefix (str) Prefix to prepend during this iprint.
stack (List) List of strings; strings are popped and appended as needed.
__init__()[source]

Initialize.

append_precon()[source]

Add a new level for any preconditioner to a linear solver.

append_solver()[source]

Add a new level for the main solver in a group.

append_subsolver()[source]

Add a new level for any sub-solver for your solver.

clear()[source]

Clear out the iprint stack, in case something is left over from a handled exception.

pop()[source]

Remove one level of solver depth in the printing.

restore_cache(cache)[source]

Restore previously saved iprint stack names.

Parameters:
cache : tuple(str, list)

cache of current stack

save_cache()[source]

Save prefix and stack so that they can be restored later in event of an exception recovery.

Returns:
tuple(str, list)

cache of current stack