Solver Recording

Solver Recording Options

Option

Default

Acceptable Values

Acceptable Types

Description

excludes

[]

N/A

[‘list’]

Patterns for vars to exclude in recording. (processed post-includes) Paths are relative to solver’s Group. Uses fnmatch wildcards

includes

[‘*’]

N/A

[‘list’]

Patterns for variables to include in recording. Paths are relative to solver’s Group. Uses fnmatch wildcards

record_abs_error

True

[True, False]

[‘bool’]

Set to True to record absolute error at the solver level

record_inputs

True

[True, False]

[‘bool’]

Set to True to record inputs at the solver level

record_metadata

True

[True, False]

[‘bool’]

Deprecated. Recording of metadata will always be done

record_outputs

True

[True, False]

[‘bool’]

Set to True to record outputs at the solver level

record_rel_error

True

[True, False]

[‘bool’]

Set to True to record relative error at the solver level

record_solver_residuals

False

[True, False]

[‘bool’]

Set to True to record residuals at the solver level

Note

Note that the excludes option takes precedence over the includes option.

Note

The paths given in the includes and excludes options are relative to the Group that the solver is attached to.

Note

It is currently not possible to record linear solvers.

Solver Recording Example

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

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

recorder = om.SqliteRecorder("cases.sql")

solver = prob.model.nonlinear_solver
solver.add_recorder(recorder)
solver.recording_options['record_abs_error'] = True
solver.options['use_apply_nonlinear'] = True

prob.run_model()
NL: NLBGS Converged in 7 iterations
prob.cleanup()

cr = om.CaseReader("cases.sql")

solver_cases = cr.list_cases('root.nonlinear_solver')

print(len(solver_cases))
solver
    rank0:root._solve_nonlinear|0|NonlinearBlockGS|0
solver
    rank0:root._solve_nonlinear|0|NonlinearBlockGS|1
solver
    rank0:root._solve_nonlinear|0|NonlinearBlockGS|2
solver
    rank0:root._solve_nonlinear|0|NonlinearBlockGS|3
solver
    rank0:root._solve_nonlinear|0|NonlinearBlockGS|4
solver
    rank0:root._solve_nonlinear|0|NonlinearBlockGS|5
solver
    rank0:root._solve_nonlinear|0|NonlinearBlockGS|6
7
case = cr.get_case(solver_cases[0])

print(case.abs_err)
2.2545141061171243