BaseTrajectoryModule#
- class BaseTrajectoryModule(name=None)[source]#
Base implementation for Trajectory modules compatible with the Bloch simulation module as well as containing a guaranteed method for position pre-calculation on call.
All derived classes must implement the abstract method “increment_particles” which must be compatible with a tf.function decoration. The __call__ function must also be implemented but is not meant to be called inside a tf.function
Methods:
__call__
(initial_positions, timing, **kwargs)Evaluates the positions for particles at given initial positions for all times specified in the timing argument.
increment_particles
(particle_positions, dt, ...)Evaluates the new position of particles at given locations r for a temporal step width dt.
- abstract __call__(initial_positions, timing, **kwargs)[source]#
Evaluates the positions for particles at given initial positions for all times specified in the timing argument. For implementations using the increment_particles function in a loop the maximal time-delta must be specified.
- Parameters:
initial_positions (
Tensor
) – (N, 3)timing (
Tensor
) – (T, )kwargs – Can vary in concrete implementation
- Return type:
(
Tensor
,dict
)- Returns:
r_new [tf.Tensor, (T, N, 3)]
additional_fields [dict] containing the lookup values for each step
- abstract increment_particles(particle_positions, dt, **kwargs)[source]#
Evaluates the new position of particles at given locations r for a temporal step width dt. If the concrete implementation involves a look up (e.g. velocity fields) the values at the old location is also returned as dictionary.
Note
concrete implementations must be compatible with tf.function decoration
- Parameters:
particle_positions (
Tensor
) – (N, 3) Current particle positions.dt (
Tensor
) – (,) Temporal step width in milliseconds to evaluate the next positionskwargs – Can vary in concrete implementation
- Return type:
(
Tensor
,dict
)- Returns:
r_new [tf.Tensor, (N, 3)], additional_fields [dict] containing the lookup values