tlm_adjoint.adjoint
Module Contents
- class tlm_adjoint.adjoint.AdjointRHS(x)
The right-hand-side of an adjoint equation, for an adjoint variable associated with an equation solving for a forward variable x.
- Parameters:
x – The forward variable.
- b(*, copy=False)
Return the right-hand-side, as a variable.
- Parameters:
copy – If True then a copy of the internal variable storing the right-hand-side value is returned. If False the internal variable itself is returned.
- Returns:
A variable storing the right-hand-side value.
- initialize()
Allocate an internal variable to store the right-hand-side. Typically need not be called manually.
- sub(b)
Subtract a term from the right-hand-side.
- Parameters:
b – The term to subtract.
subtract_adjoint_derivative_action()
is used to subtract the term.
- is_empty()
Return whether the right-hand-side is ‘empty’, meaning that the
AdjointRHS.initialize()
method has not been called.- Returns:
True if the
AdjointRHS.initialize()
method has not been called, and False otherwise.
- class tlm_adjoint.adjoint.AdjointEquationRHS(eq)
The right-hand-side of an adjoint equation, for adjoint variables associated with an equation solving for multiple forward variables X.
Multiple
AdjointRHS
objects. TheAdjointRHS
objects may be accessed by index, e.g.adj_eq_rhs = AdjointEquationRHS(eq) adj_rhs = adj_eq_rhs[m]
- Parameters:
eq – An
Equation
. eq.X() defines the forward variables.
- b(*, copy=False)
For the case where there is a single forward variable, return a variable associated with the right-hand-side.
- Parameters:
copy – If True then a copy of the internal variable storing the right-hand-side value is returned. If False the internal variable itself is returned.
- Returns:
A variable storing the right-hand-side value.
- B(*, copy=False)
Return variables associated with the right-hand-sides.
- Parameters:
copy – If True then copies of the internal variables storing the right-hand-side values are returned. If False the internal variables themselves are returned.
- Returns:
A
tuple
of variables storing the right-hand-side values.
- is_empty()
Return whether all of the
AdjointRHS
objects are ‘empty’, meaning that theAdjointRHS.initialize()
method has not been called for anyAdjointRHS
.- Returns:
True if the
AdjointRHS.initialize()
method has not been called for anyAdjointRHS
, and False otherwise.
- class tlm_adjoint.adjoint.AdjointBlockRHS(block)
The right-hand-side of multiple adjoint equations.
Multiple
AdjointEquationRHS
objects. TheAdjointEquationRHS
objects may be accessed by index, e.g.adj_block_rhs = AdjointBlockRHS(block) adj_eq_rhs = adj_block_rhs[k]
- Parameters:
block – A
Sequence
ofEquation
objects.
- pop()
Remove and return the last
AdjointEquationRHS
in theAdjointBlockRHS
.- Returns:
A
tuple
(n, B). B is the removedAdjointEquationRHS
, associated with block n.
- is_empty()
Return whether there are no
AdjointEquationRHS
objects in theAdjointBlockRHS
.- Returns:
True if there are no
AdjointEquationRHS
objects in theAdjointBlockRHS
, and False otherwise.
- class tlm_adjoint.adjoint.AdjointModelRHS(blocks)
The right-hand-side of multiple blocks of adjoint equations.
Multiple
AdjointBlockRHS
objects. TheAdjointBlockRHS
objects may be accessed by index, e.g.adj_model_rhs = AdjointModelRHS(block) adj_block_rhs = adj_block_rhs[p]
If the last block of adjoint equations contains no equations then it is automatically removed from the
AdjointModelRHS
.- Parameters:
blocks – A
Sequence
ofSequence
objects each containingEquation
objects, or aMapping
with items (index, block) where index is anint
and block aSequence
ofEquation
objects. In the latter case blocks are ordered by index.
- pop()
Remove and return the last
AdjointEquationRHS
in the lastAdjointBlockRHS
in theAdjointModelRHS
.- Returns:
A
tuple
((n, i), B). B is the removedAdjointEquationRHS
, associated with equation i in block n.
- is_empty()
Return whether there are no
AdjointBlockRHS
objects in theAdjointModelRHS
.- Returns:
True if there are no
AdjointBlockRHS
objects in theAdjointModelRHS
, and False otherwise.