3.1. wavesim.domain
- class ABCMeta(name, bases, namespace, /, **kwargs)[source]
Bases:
typeMetaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
- register(subclass)[source]
Register a virtual subclass of an ABC.
Returns the subclass, to allow usage as a class decorator.
- class Domain(pixel_size, shape, device)[source]
Bases:
objectBase class for all simulation domains
This base class defines the interface for operations that are common for all simulation types, and for MultiDomain. todo: the design using slots minimizes memory use, but it is a suboptimal design because it mixes mutable and immutable state. This design should be revisited so that the Domain is immutable, and the code that runs the algorithms performs the memory management.
- abstractmethod add_source(slot, weight)[source]
- abstractmethod clear(slot)[source]
Clears the data in the specified slot
- coordinates(dim, type='linear')[source]
Returns the real-space coordinates along the specified dimension, starting at 0
- coordinates_f(dim)[source]
Returns the Fourier-space coordinates along the specified dimension
- abstractmethod create_empty_vdot()[source]
Create an empty tensor for the Vdot tensor
- abstractmethod get(slot, copy=False)[source]
Returns the data in the specified slot.
- Parameters:
slot (
int) – slot from which to return the datacopy – if True, returns a copy of the data. Otherwise, may return the original data possible.
Note that this data may be overwritten by the next call to domain.
- abstractmethod inner_product(slot_a, slot_b)[source]
Computes the inner product of two data vectors
Note
The vectors may be represented as multidimensional arrays, but these arrays must be contiguous for this operation to work. Although it would be possible to use flatten(), this would create a copy when the array is not contiguous, causing a hidden performance hit.
- abstractmethod inverse_propagator(slot_in, slot_out)[source]
Applies the operator (L+1) x .
This operation is not needed for the Wavesim algorithm, but is provided for testing purposes, and can be used to evaluate the residue of the solution.
- abstractmethod medium(slot_in, slot_out, mnum)[source]
Applies the operator 1-Vscat.
- abstractmethod mix(weight_a, slot_a, weight_b, slot_b, slot_out)[source]
Mixes two data arrays and stores the result in the specified slot
- abstractmethod propagator(slot_in, slot_out)[source]
Applies the operator (L+1)^-1 x.
- abstractmethod set(slot, data)[source]
Copy the date into the specified slot
- abstractmethod set_source(source)[source]
Sets the source term for this domain.
- abstractmethod(funcobj)[source]
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms. abstractmethod() may be used to declare abstract methods for properties and descriptors.
Usage:
- class C(metaclass=ABCMeta):
@abstractmethod def my_abstract_method(self, arg1, arg2, argN):
…