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.

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 of AdjointRHS objects.

Parameters:
eqEquation

The adjoint right-hand-sides are associated with the operation defined by this Equation.

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 of AdjointEquationRHS objects.

Parameters:
blockSequence[Equation, …]

The adjoint right-hand-sides are associated with the operations defined by these Equation objects.

pop()

Remove and return the last AdjointEquationRHS. Decreases the length of this AdjointBlockRHS 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 from int to AdjointBlockRHS 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 empty AdjointBlockRHS objects are removed automatically.

pop()

Remove and return the last AdjointEquationRHS in the last AdjointBlockRHS in this AdjointModelRHS. Then remove any trailing empty AdjointBlockRHS 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.