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 import SellarDerivatives

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

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.610010556989945
1.784485335631364

DirectSolver Options

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

DirectSolver Constructor

The call signature for the DirectSolver constructor is:

DirectSolver.__init__(**kwargs)

Initialize all attributes.