DirectSolver#

DirectSolver is a linear solver that assembles the system Jacobian and solves the linear system with LU factorization and back substitution. It can handle any system topology. Since it assembles a global Jacobian for all of its subsystems, any linear solver that is assigned in any of its subsystems does not participate in this calculation (though they may be used in other ways such as in subsystem Newton solves.)

Here we calculate the total derivatives of the Sellar system objective with respect to the design variable ‘z’.

import openmdao.api as om
from openmdao.test_suite.components.sellar_feature import SellarDerivatives

prob = om.Problem()
model = prob.model = SellarDerivatives()

model.nonlinear_solver=om.NonlinearBlockGS()
model.linear_solver = om.DirectSolver()

prob.setup()
prob.run_model()

wrt = ['z']
of = ['obj']

J = prob.compute_totals(of=of, wrt=wrt, return_format='flat_dict')
print(J['obj', 'z'][0][0])
print(J['obj', 'z'][0][1])
NL: NLBGS Converged in 8 iterations
9.610010556989947
1.784485335631365

DirectSolver Options#

OptionDefaultAcceptable ValuesAcceptable TypesDescription
assemble_jacTrue[True, False]['bool']Activates use of assembled jacobian by this solver.
err_on_singularTrue[True, False]['bool']Raise an error if LU decomposition is singular.
iprint1N/A['int']whether to print output
rhs_checkingFalseN/A['bool', 'dict']If True, check RHS vs. cache and/or zero to avoid some solves.Can also be set to a dict of options for the LinearRHSChecker to allow finer control over it. Allowed options are: ('check_zero', 'rtol', 'atol', 'max_cache_entries', 'collect_stats', 'auto', 'verbose')

DirectSolver Constructor#

The call signature for the DirectSolver constructor is:

DirectSolver.__init__(**kwargs)[source]

Declare the solver options.