modifiers for environment objects#
This module contains several modifiers (decorators) for environment objects, that can be used to perform spatial translations or rotation on those objects.
Warning
(!) This module is still at an experimental stage (!)
Do not use it yet, as it might yield unexpected results
Examples
Rotate a laser beam
import numpy as np
from atomsmltr.environment import GaussianLaserBeam
from atomsmltr.environment.modifiers import rotate
laser = GaussianLaserBeam(direction=(1,0,0))
rotate(laser, (0,0,1), np.pi/4)
Shift a magnetic field quadrupole
from atomsmltr.environment import MagneticQuadrupoleX
from atomsmltr.environment.modifiers import shift
mag_field = MagneticQuadrupoleX(origin=(0,0,0), slope=1)
shift(mag_field, (-1,0,1))
- atomsmltr.environment.modifiers.rotate(obj: EnvObject, u: ndarray, theta: float)[source]#
Modifier for environment objects, performing a rotation
- atomsmltr.environment.modifiers.rotate_position_vector(position: ndarray, u: ndarray, theta: float) ndarray[source]#
Rotates a position vector
- Parameters:
position (array of shape (3,) or (n1, n2, ..., 3)) – cartesian coordinates in the lab frame
u (array, shape (3,)) – the axis around which to perform the rotation it does not need to be normalized, the function will take care of it
theta (float) – the angle for the rotation
- Returns:
rotated_position – rotated position vector
- Return type:
array of shape (3,) or (n1, n2, …, 3)
Notes
position is an array_like object, with shape (3,) or (n1, n2, .., 3). In all cases, the last dimension contains cordinates (x, y, z), in meter and in the lab frame
- atomsmltr.environment.modifiers.rotate_position_vector_alt(position: ndarray, u: ndarray, theta: float) ndarray[source]#
Rotates a position vector
Alternative version to
rotate_position_vector, not using the numpy tensordot method, and therefore less performant. Included as a more transparent comparison, to make sure that tensordot is doing what we want.- Parameters:
position (array of shape (3,) or (n1, n2, ..., 3)) – cartesian coordinates in the lab frame
u (array, shape (3,)) – the axis around which to perform the rotation it does not need to be normalized, the function will take care of it
theta (float) – the angle for the rotation
- Returns:
rotated_position – rotated position vector
- Return type:
array of shape (3,) or (n1, n2, …, 3)
Notes
position is an array_like object, with shape (3,) or (n1, n2, .., 3). In all cases, the last dimension contains cordinates (x, y, z), in meter and in the lab frame
- atomsmltr.environment.modifiers.rotation_matrix(u: ndarray, theta: float) ndarray[source]#
Generates 3D rotation matrix
- Parameters:
u (array, shape (3,)) – the axis around which to perform the rotation it does not need to be normalized, the function will take care of it
theta (float) – the angle for the rotation
- Returns:
rotmat – the rotation matrix
- Return type:
array, shape (3,)
References
https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle