broyden.py#

Define the BroydenSolver class.

Based on implementation in Scipy via OpenMDAO 0.8x with improvements based on NPSS solver.

class openmdao.solvers.nonlinear.broyden.BroydenSolver(**kwargs)[source]

Bases: NonlinearSolver

Broyden solver.

Parameters:
**kwargsdict

Options dictionary.

Attributes:
delta_fxmndarray

Most recent change in residual vector.

delta_xmndarray

Most recent change in state vector.

fxmndarray

Most recent residual.

Gmndarray

Most recent Jacobian matrix.

linear_solverLinearSolver

Linear solver to use for calculating inverse Jacobian.

_linesearchNonlinearSolver

Line search algorithm. Default is None for no line search.

sizeint

Total length of the states being solved.

xmndarray

Most recent state.

_idxdict

Cache of vector indices for each state name.

_computed_jacobiansint

Number of computed jacobians.

_converge_failuresint

Number of consecutive iterations that failed to converge to the tol definied in options.

_full_inversebool

When True, Broyden considers the whole vector rather than a list of states.

_recompute_jacobianbool

Flag that becomes True when Broyden detects it needs to recompute the inverse Jacobian.

SOLVER = 'NL: BROYDEN'
__init__(**kwargs)[source]

Initialize all attributes.

add_recorder(recorder)

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.

compute_norm(vec)[source]

Compute norm of the vector.

Under MPI, compute the norm on rank 0, and broadcast it to all other ranks.

Parameters:
vecndarray

Array of real or complex values. For MPI on rank 0, should be full dimension of the openmdao vector with duplicate indices removed.

Returns:
float

Norm of vec, computed on rank 0 and broadcast to all other ranks.

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_vector(vec)[source]

Return a vector containing the values of vec at the states specified in options.

This is the full incoming vec when no states are defined. When under MPI, the values are appopriately gathered without duplicates to rank 0.

Parameters:
vec<Vector>

Vector from which to extract state values.

Returns:
ndarray

Array containing values of vector at desired states.

property linesearch

Get the linesearch solver associated with this solver.

Returns:
NonlinearSolver or None

The linesearch associated with this solver, or None if it does not support one.

property msginfo

Return info to prepend to messages.

Returns:
str

Info to prepend to messages.

record_iteration(**kwargs)

Record an iteration of the current Solver.

Parameters:
**kwargsdict

Keyword arguments (used for abs and rel error).

report_failure(msg)

Report a failure that has occurred.

The msg may be printed or ignored depending on the iprint option, and may raise an AnalysisError depending on the err_on_non_converge option.

Parameters:
msgstr

Message indicating the failure.

set_linear_vector(dx)[source]

Copy values from step into the linear vector for backtracking.

Parameters:
dxndarray

Full step in the states for this iteration.

set_states(new_val)[source]

Set new values for states specified in options.

Parameters:
new_valndarray

New values for states.

solve()

Run the solver.

use_relevance()

Return True if relevance should be active.

Returns:
bool

True if relevance should be active.