dictionary_jacobian.py#
Define the DictionaryJacobian class.
- class openmdao.jacobians.dictionary_jacobian.DictionaryJacobian(system)[source]
Bases:
Jacobian
A Jacobian that stores nonzero subjacobians in a dictionary.
- Parameters:
- systemSystem
Parent system to this jacobian.
- Attributes:
- _has_childrenbool
True if the system has children, False otherwise.
- __contains__(key)
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)
Get sub-Jacobian.
- Parameters:
- key(str, str)
Promoted or relative name pair of sub-Jacobian.
- Returns:
- ndarray or sparse matrix
sub-Jacobian as an array or sparse matrix.
- __init__(system)[source]
Initialize all attributes.
- __iter__()
Yield next name pair of sub-Jacobian.
- Yields:
- str
- __setitem__(key, subjac)
Set sub-Jacobian.
- Parameters:
- key(str, str)
Promoted or relative name pair of sub-Jacobian.
- subjacfloat or ndarray or sparse matrix
sub-Jacobian as a scalar, array, or sparse matrix.
- create_subjac(abs_key, meta, dtype)
Create a subjacobian.
- Parameters:
- abs_keytuple
The absolute key for the subjacobian.
- metadict
Metadata for the subjacobian.
- dtypedtype
The dtype of the subjacobian.
- Returns:
- Subjac
The created subjacobian,.
- get_metadata(key)
Get metadata for the given key.
- Parameters:
- key(str, str)
Promoted or relative name pair of sub-Jacobian.
- Returns:
- dict
Metadata dict for the given key.
- items()
Yield name pair and value of sub-Jacobian.
- Yields:
- str
- keys()
Yield next name pair of sub-Jacobian.
- Yields:
- str
- set_col(system, icol, column)
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:
- systemSystem
The system that owns this jacobian.
- icolint
Column index.
- columnndarray
Column value.
- set_csc_jac(system, jac)
Assign a CSC jacobian to this jacobian.
- Parameters:
- systemSystem
The system that owns this jacobian.
- jaccsc_matrix
CSC jacobian.
- set_dense_jac(system, jac)
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:
- systemSystem
The system that owns this jacobian.
- jacndarray
Dense jacobian.
- todense()
Return a dense version of the full jacobian.
This includes the combined dr/do and dr/di matrices.
- Returns:
- ndarray
Dense version of the full jacobian.
- class openmdao.jacobians.dictionary_jacobian.ExplicitDictionaryJacobian(system)[source]
Bases:
Jacobian
A DictionaryJacobian that is a collection of sub-Jacobians.
It is intended to be used with ExplicitComponents only because dr/do is assumed to be -I.
- Parameters:
- systemSystem
System that is updating this jacobian. Must be an ExplicitComponent.
- __contains__(key)
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)
Get sub-Jacobian.
- Parameters:
- key(str, str)
Promoted or relative name pair of sub-Jacobian.
- Returns:
- ndarray or sparse matrix
sub-Jacobian as an array or sparse matrix.
- __init__(system)[source]
Initialize all attributes.
- __iter__()
Yield next name pair of sub-Jacobian.
- Yields:
- str
- __setitem__(key, subjac)
Set sub-Jacobian.
- Parameters:
- key(str, str)
Promoted or relative name pair of sub-Jacobian.
- subjacfloat or ndarray or sparse matrix
sub-Jacobian as a scalar, array, or sparse matrix.
- create_subjac(abs_key, meta, dtype)
Create a subjacobian.
- Parameters:
- abs_keytuple
The absolute key for the subjacobian.
- metadict
Metadata for the subjacobian.
- dtypedtype
The dtype of the subjacobian.
- Returns:
- Subjac
The created subjacobian,.
- get_metadata(key)
Get metadata for the given key.
- Parameters:
- key(str, str)
Promoted or relative name pair of sub-Jacobian.
- Returns:
- dict
Metadata dict for the given key.
- items()
Yield name pair and value of sub-Jacobian.
- Yields:
- str
- keys()
Yield next name pair of sub-Jacobian.
- Yields:
- str
- set_col(system, icol, column)
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:
- systemSystem
The system that owns this jacobian.
- icolint
Column index.
- columnndarray
Column value.
- set_csc_jac(system, jac)
Assign a CSC jacobian to this jacobian.
- Parameters:
- systemSystem
The system that owns this jacobian.
- jaccsc_matrix
CSC jacobian.
- set_dense_jac(system, jac)
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:
- systemSystem
The system that owns this jacobian.
- jacndarray
Dense jacobian.
- todense()[source]
Return a dense version of the jacobian.
- Returns:
- ndarray
Dense version of the jacobian.