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

from openmdao.api import Problem, DirectSolver
from openmdao.test_suite.components.sellar import SellarDerivatives

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

model.linear_solver = DirectSolver()

NL: NLBGS Converged in 7 iterations
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])

DirectSolver Options

Option Default Acceptable Values Acceptable Types Description
assemble_jac False N/A [‘bool’] Activates use of assembled jacobian by this solver.
err_on_singular True N/A N/A Raise an error if LU decomposition is singular.
iprint 1 N/A [‘int’] whether to print output

Note: Options can be passed as keyword arguments at initialization.