jacobian.py

Define the base Jacobian class.

class openmdao.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.

__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:
boolean

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.

Parameters:
system : System

Parent system to this jacobian.

__setitem__(key, subjac)[source]

Set sub-Jacobian.

Parameters:
key : (str, str)

Promoted or relative name pair of sub-Jacobian.

subjac : int or float or ndarray or sparse matrix

sub-Jacobian as a scalar, vector, array, or AIJ list or tuple.

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:
active : bool

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

openmdao.jacobians.jacobian.rand(d0, d1, ..., dn)

Random values in a given shape.

Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).

Parameters:
d0, d1, …, dn : int, optional

The dimensions of the returned array, should all be positive. If no argument is given a single Python float is returned.

Returns:
out : ndarray, shape (d0, d1, ..., dn)

Random values.

See also

random

Notes

This is a convenience function. If you want an interface that takes a shape-tuple as the first argument, refer to np.random.random_sample .

Examples

>>> np.random.rand(3,2)
array([[ 0.14022471,  0.96360618],  #random
       [ 0.37601032,  0.25528411],  #random
       [ 0.49313049,  0.94909878]]) #random