# broyden.py

# 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:

`openmdao.solvers.solver.NonlinearSolver`

Broyden solver.

- Parameters

**kwargsdictOptions dictionary.

- Attributes

delta_fxmndarrayMost recent change in residual vector.

delta_xmndarrayMost recent change in state vector.

fxmndarrayMost recent residual.

GmndarrayMost recent Jacobian matrix.

linear_solverLinearSolverLinear solver to use for calculating inverse Jacobian.

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

sizeintTotal length of the states being solved.

xmndarrayMost recent state.

_idxdictCache of vector indices for each state name.

_computed_jacobiansintNumber of computed jacobians.

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

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

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

`SOLVER`

= '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

vecndarrayArray 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_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`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

**kwargsdictKeyword arguments (used for abs and rel error).

`set_linear_vector`

(dx)[source]Copy values from step into the linear vector for backtracking.

- Parameters

dxndarrayFull step in the states for this iteration.

`set_states`

(new_val)[source]Set new values for states specified in options.

- Parameters

new_valndarrayNew values for states.

`solve`

()Run the solver.