Problem type

class stride.physics.problem_type.ProblemTypeBase(**kwargs)[source]

Bases: ABC, Gridded, Operator

Problem types encode the physics of the forward and inverse problems that we want to solve using Stride. In most cases, these physics will correspond to state and adjoint PDEs describing problems of interest.

A problem type could have multiple implementations, depending on how the physics are solved or the techniques that are used to solve them.

For example, the iso_acoustic problem corresponds to the second-order isotropic acoustic wave equation, which currently has one implementation using the Devito library. This implementation is contained within the iso_acoustic/devito folder.

ProblemTypeBase provides a convenient template for other problem types to use, but is not needed. Only inheriting from Operator is needed to generate new physics.

When inheriting from ProblemTypeBase, classes will have to define a certain interface.

To solve the state or forward problem:

  • before_forward

  • run_forward

  • after_forward

and to solve the adjoint problem:

  • before_adjoint

  • run_adjoint

  • after_adjoint

If the problem type has to provide the gradient for a certain optimisation variable, the class will also have to define a set of methods per variable:

  • prepare_grad_[variable_name] will be called before the adjoint run to prepare the calculation of the gradient.

  • init_grad_[variable_name] will be called after prepare to initialise any necessary buffers.

  • get_grad_[variable_name] will be called after the adjoint run to retrieve in the calculated gradients.

in order for the gradients to be calculated.

async adjoint(*args, **kwargs)[source]

Run the adjoint problem.

async after_adjoint(*args, **kwargs)[source]

Clean up after the adjoint run and retrieve the gradients (if needed).

Returns:

Gradients wrt to the problem inputs.

Return type:

gradient or tuple of gradients

async after_forward(*args, **kwargs)[source]

Clean up after the state run and retrieve the outputs.

Returns:

Time traces produced by the state run.

Return type:

Traces

async before_adjoint(*args, **kwargs)[source]

Prepare the problem type to run the adjoint problem.

async before_forward(*args, **kwargs)[source]

Prepare the problem type to run the state or forward problem.

property comms
async forward(*args, **kwargs)[source]

Run the state or forward problem.

async get_grad(*wrt, **kwargs)[source]

Retrieve the gradients calculated wrt to the inputs.

Parameters:
  • wrt – Tuple of variables with respect to which the inversion is running.

  • kwargs – Extra parameters to be used by the method.

Returns:

Tuple with all the requested gradients

Return type:

tuple

property head
async init_grad(*wrt, **kwargs)[source]

Initialise buffers in the problem type to calculate the gradients wrt the inputs.

Parameters:
  • wrt – Tuple of variables with respect to which the inversion is running.

  • kwargs – Extra parameters to be used by the method.

classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
classmethod parameter(*args, uid=None, **kwargs)
async prepare_grad(*wrt, **kwargs)[source]

Prepare the problem type to calculate the gradients wrt the inputs.

Parameters:
  • wrt – Tuple of variables with respect to which the inversion is running.

  • kwargs – Extra parameters to be used by the method.

Returns:

List of update rules (if any) for the gradients of the problem type with respect to the inputs

Return type:

list

classmethod remote(*args, **kwargs)
async run_adjoint(*args, **kwargs)[source]

Run the adjoint problem.

async run_forward(*args, **kwargs)[source]

Run the state or forward problem.

property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property worker
property zmq_context