tlm_adjoint.adjoint
Module Contents
- class tlm_adjoint.adjoint.AdjointRHS(x)
Adjoint equation right-hand-side component.
The right-hand-side of an adjoint equation, for an adjoint variable associated with an operation computing a forward variable x.
- Parameters:
- xvariable
The forward variable.
- b(*, copy=False)
Access the adjoint right-hand-side.
- Parameters:
- copybool
Whether to return a copy of the right-hand-side.
- Returns:
- variable
The right-hand-side.
- sub(b)
Subtract a term from the adjoint right-hand-side.
- Parameters:
- bobject
The term to subtract.
See also
- class tlm_adjoint.adjoint.AdjointEquationRHS(eq)
Adjoint equation right-hand-side.
The right-hand-side of an adjoint equation, for adjoint variables associated with an operation computing multiple forward variables.
Sequence
ofAdjointRHS
objects.- Parameters:
- b(*, copy=False)
For the case where there is a single forward variable, return the associated adjoint right-hand-side.
- Parameters:
- copybool
Whether to return a copy of the right-hand-side.
- Returns:
- variable
The right-hand-side.
- B(*, copy=False)
Return adjoint right-hand-side components.
- Parameters:
- copybool
Whether to return copies of the right-hand-side components.
- Returns:
- tuple[variable, …]
The right-hand-side components.
- class tlm_adjoint.adjoint.AdjointBlockRHS(block)
Multiple adjoint equation right-hand-sides.
Sequence
ofAdjointEquationRHS
objects.- Parameters:
- pop()
Remove and return the last
AdjointEquationRHS
. Decreases the length of thisAdjointBlockRHS
by one.- Returns:
- int
The index of the removed
AdjointEquationRHS
.AdjointEquationRHS
The removed
AdjointEquationRHS
.
- is_empty()
Return whether this
AdjointBlockRHS
has length zero.- Returns:
- bool
Whether this
AdjointBlockRHS
has length zero.
- class tlm_adjoint.adjoint.AdjointModelRHS(blocks)
Multiple blocks of adjoint right-hand-sides.
Mapping
fromint
toAdjointBlockRHS
objects.- Parameters:
- blocksSequence[Sequence[
Equation
, …], …] or Mapping[int, Sequence[Equation
, …], …] The adjoint right-hand-sides are associated with the operations defined by these blocks of
Equation
objects. Any trailing emptyAdjointBlockRHS
objects are removed automatically.
- blocksSequence[Sequence[
- pop()
Remove and return the last
AdjointEquationRHS
in the lastAdjointBlockRHS
in thisAdjointModelRHS
. Then remove any trailing emptyAdjointBlockRHS
objects.- Returns:
- (n, i)tuple[int, int]
The removed right-hand-side is associated with
Equation
i in block n.AdjointEquationRHS
The removed
AdjointEquationRHS
.
- is_empty()
Return whether this
AdjointModelRHS
has length zero.- Returns:
- bool
Whether this
AdjointModelRHS
has length zero.