scipy_gmres.py

OpenMDAO LinearSolver that uses Scipy’s GMRES to solve for derivatives.

class openmdao.solvers.scipy_gmres.ScipyGMRES[source]

Bases: openmdao.solvers.solver_base.MultLinearSolver

Scipy’s GMRES Solver. This is a serial solver, so it should never be used in an MPI setting. A preconditioner can be specified by placing another linear solver into self.preconditioner.

Options:

options[‘atol’] : float(1e-12)

Absolute convergence tolerance.

options[‘err_on_maxiter’] : bool(False)

If True, raise an AnalysisError if not converged at maxiter.

options[‘iprint’] : int(0)

Set to 0 to print only failures, set to 1 to print iteration totals to stdout, set to 2 to print the residual each iteration to stdout, or -1 to suppress all printing.

options[‘maxiter’] : int(1000)

Maximum number of iterations.

options[‘mode’] : str(‘auto’)

Derivative calculation mode, set to ‘fwd’ for forward mode, ‘rev’ for reverse mode, or ‘auto’ to let OpenMDAO determine the best mode.

options[‘restart’] : int(20)

Number of iterations between restarts. Larger values increase iteration cost, but may be necessary for convergence

monitor(res)[source]

GMRES Callback: Prints the current residual norm.

Args:

res : ndarray

Current residual.

print_all_convergence(level=2)[source]

Turns on iprint for this solver and all subsolvers. Override if your solver has subsolvers.

Args:

level : int(2)

iprint level. Set to 2 to print residuals each iteration; set to 1 to print just the iteration totals.

setup(sub)[source]

Initialize sub solvers.

Args:

sub: `System`

System that owns this solver.

solve(rhs_mat, system, mode)[source]

Solves the linear system for the problem in self.system. The full solution vector is returned.

Args:

rhs_mat : dict of ndarray

Dictionary containing one ndarry per top level quantity of interest. Each array contains the right-hand side for the linear solve.

system : System

Parent System object.

mode : string

Derivative mode, can be ‘fwd’ or ‘rev’.

Returns:

dict of ndarray : Solution vectors