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.linear_solver = om.DirectSolver()


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

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

DirectSolver Constructor#

The call signature for the DirectSolver constructor is:


Initialize all attributes.