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:
NonlinearSolverBroyden 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.
Methods
add_recorder(recorder)Add a recorder to the solver's RecordingManager.
can_solve_cycle()Return True if this solver can solve groups with cycles.
check_config(logger)Perform optional error checks.
cleanup()Clean up resources prior to exit.
compute_norm(vec)Compute norm of the vector.
get_outputs_dir(*subdirs[, mkdir])Get the path under which all output files of this solver are to be placed.
get_reports_dir()Get the path to the directory where the report files should go.
get_vector(vec)Return a vector containing the values of vec at the states specified in options.
record_iteration(**kwargs)Record an iteration of the current Solver.
report_failure(msg)Report a failure that has occurred.
set_linear_vector(dx)Copy values from step into the linear vector for backtracking.
set_states(new_val)Set new values for states specified in options.
solve()Run the solver.
use_relevance()Return True if relevance should be active.
- SOLVER = 'NL: BROYDEN'
- __init__(**kwargs)[source]
Initialize all attributes.
- 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_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.
- 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.