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.LinearSolver

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[‘iprint’] : int(0)

Set to 0 to disable printing, set to 1 to print the residual to stdout each iteration, set to 2 to print subiteration residuals as well.

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.

mult(arg)[source]

GMRES Callback: applies Jacobian matrix. Mode is determined by the system.

Args:

arg : ndarray

Incoming vector

Returns:

ndarray : Matrix vector product of arg with jacobian

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