# jacobian.py

# jacobian.py¶

Define the base Jacobian class.

classopenmdao.jacobians.jacobian.Jacobian(system)[source]Bases:

`object`

Base Jacobian class.

This class provides a dictionary interface for sub-Jacobians and performs matrix-vector products when apply_linear is called.

- Parameters

systemSystemParent system to this jacobian.

- Attributes

_system<System>Pointer to the system that is currently operating on this Jacobian.

_subjacs_infodictDictionary of the sub-Jacobian metadata keyed by absolute names.

_under_complex_stepboolWhen True, this Jacobian is under complex step, using a complex jacobian.

_abs_keysdefaultdictA cache dict for key to absolute key.

_randgenGenerator or NoneIf not None, use the generator to generate random numbers during computation of sparsity for for simultaneous derivative coloring.

_col_var_offsetdictMaps column name to offset into the result array.

_col_varnameslistList of column var names.

_col2name_indndarrayArray that maps jac col index to index of column name.

- __contains__(
key)[source]Return whether there is a subjac for the given promoted or relative name pair.

- Parameters

key(str, str)Promoted or relative name pair of sub-Jacobian.

- Returns

- bool
return whether sub-Jacobian has been defined.

- __getitem__(
key)[source]Get sub-Jacobian.

- Parameters

key(str, str)Promoted or relative name pair of sub-Jacobian.

- Returns

- ndarray or spmatrix or list[3]
sub-Jacobian as an array, sparse mtx, or AIJ/IJ list or tuple.

- __init__(
system)[source]Initialize all attributes.

- __iter__()[source]
Yield next name pair of sub-Jacobian.

- Yields

- str

- __setitem__(
key,subjac)[source]Set sub-Jacobian.

- Parameters

key(str, str)Promoted or relative name pair of sub-Jacobian.

subjacint or float or ndarray or sparse matrixsub-Jacobian as a scalar, vector, array, or AIJ list or tuple.

- items()[source]
Yield name pair and value of sub-Jacobian.

- Yields

- str

- keys()[source]
Yield next name pair of sub-Jacobian.

- Yields

- str

propertymsginfoReturn info to prepend to messages.

- Returns

- str
Info to prepend to messages.

- set_col(
system,icol,column)[source]Set a column of the jacobian.

The column is assumed to be the same size as a column of the jacobian.

This also assumes that the column does not attempt to set any nonzero values that are outside of specified sparsity patterns for any of the subjacs.

- Parameters

systemSystemThe system that owns this jacobian.

icolintColumn index.

columnndarrayColumn value.

- set_complex_step_mode(
active)[source]Turn on or off complex stepping mode.

When turned on, the value in each subjac is cast as complex, and when turned off, they are returned to real values.

- Parameters

activeboolComplex mode flag; set to True prior to commencing complex step.

- set_dense_jac(
system,jac)[source]Assign a dense jacobian to this jacobian.

This assumes that any column does not attempt to set any nonzero values that are outside of specified sparsity patterns for any of the subjacs.

- Parameters

systemSystemThe system that owns this jacobian.

jacndarrayDense jacobian.