configuration#
Here we implement the Configuration class, that allows to define
consistent configurations that are later fed to the Simulation objects.
Quick description#
A configuration consists of:
a atom (
Atom)a collection of laser beams (
LaserBeam)a collection of magnetic Fields (
MagneticField)a collection of forces (
Force)a collection of zones (
Zone)
The coupling between atoms and lasers is stored in a atomlight dictionnary, that
is setup with the add_atomlight_coupling() method.
- class atomsmltr.simulation.configurator.Configuration(object_list: EnvObject | list = None, atom: Atom = None)[source]#
Bases:
objectDefines a configuration for the simulation
- Parameters:
Examples
# - imports from atomsmltr.environment import GaussianLaserBeam, MagneticOffset, Limits from atomsmltr.atoms import Ytterbium from atomsmltr.simulation import Configuration # - setup environment objects laser = GaussianLaserBeam(tag="laser") mag_offset = MagneticOffset(offset=(0,1,0), tag="offset") xlim = Limits(min=0, max=10, axis=0, target="position") # - setup atom yb = Ytterbium() # - init configuration config = Configuration(object_list=[laser, mag_offset, xlim], atom=yb) # - print info config.print_info()
- add_atomlight_coupling(laser: str | LaserBeam, transition: str, detuning: float, verbose: bool = False, override: bool = False)[source]#
Adds a atom-light coupling element in the configuration
- Parameters:
laser (str | LaserBeam) – either a laser tag or a laser object. This object/tag has to be in the configuration laser list
transition (str) – the tag of the transition. Should be part of the collection’s atom transition list
detuning (float) – detuning of the laser w.r.t to transition (rad/s), see notes for the definition
verbose (bool, optional) – if True, will print messages when adding the couplint, by default False
override (bool, optional) – if set to True, if a coupling between the laser and the transition already exists, then it will be overriden. Otherwise it will raise an error, by default False
Notes
The detuning δ is defined as:
δ = ωL - ω0
Where ωL is the laser pulsation and ω0 the atomic transition pulsation (hence, in rad/s) Stated otherwise, detuning units is in units of 2π x Hz
- add_objects(obj: EnvObject | list, verbose=False)[source]#
Add environment objects to the configuration.
- Parameters:
obj (EnvObject | list) – a environment object or a list of objects
verbose (bool, optional) – if set to True messages are displayed. Defaults to False.
Notes
The function takes a single environment object (laser, magnetic field…) or a collection of objects in the form of a tuple or a list.
Objects of different subtypes can be added at the same time: the method will add them to the correct collection based on their classes
Note
The addition operator
+also allows to add objects. Hence,conf.add_objects([obj1, obj2, ...])is equivalent toconf += obj1, obj2 , ...Examples
... init a proper config first and env objects # add objects config.add_objects(laser1) config.add_objects([mag_field, zone1, zone2, laser2]) # also works with += operator* config += laser3, laser4
- gen_object_infostring_object(collection: str, tag: str) InfoString[source]#
Generate infostring object for an object from ‘collection’ with ‘tag’
Collection must be in [‘laser’, ‘magnetic field’, ‘zone’]
- Parameters:
collection (str) – the collection from which the object should be taken
tag (str) – the tag of the object
- Returns:
infostring – an infostring object
- Return type:
Infostring
See also
- getB(position: ndarray) ndarray[source]#
Returns the total magnetic field at a given position in the lab frame
- Parameters:
position (array, shape (3,) or (n1, n2, .., 3)) – array of cartesian coordinates in the lab frame
- Returns:
B – magnetic field at the position. shape matches the one of
position- Return type:
array, 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
Example
... init a proper config first import numpy as np # generate a grid of 100 x 100 points in the (x, y) plane grid = np.mgrid[-10:10:100j, -10:-10:100j, 0:0:1j] grid = np.squeeze(grid) # get coordinates arrays (for plotting for instance) X, Y, Z = grid # generate the requested (..., 3) shaped position array position = grid.T # compute magnetic field B = config.getB(position) # get magnetic field components Bx, By, Bz = B.T # show shapes (to illustrate what we did) print(f"{grid.shape=}") print(f"{position.shape=}") print(f"{B.shape=}") print(f"{X.shape=}") print(f"{Bx.shape=}")
This returns
grid.shape=(3, 100, 100) position.shape=(100, 100, 3) B.shape=(100, 100, 3) X.shape=(100, 100) Bx.shape=(100, 100)
- getBnorm(position)[source]#
Returns the magnetic field amplitude (norm) at a given lab position
- Parameters:
position (array, shape (3,) or (n1, n2, .., 3)) – array of cartesian coordinates in the lab frame
- Returns:
B_norm – magnetic field norm the position. shape matches the one of
position- Return type:
array, shape (1,) or (n1, n2, .., 1)
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
- get_all_forces() list[source]#
Returns a list of all forces
- Returns:
a list of all forces in the configuration
- Return type:
force_list (list)
- get_all_zones()[source]#
Returns zones sorted in according to their target
- Returns:
stop_position (list) – list of position stop zones (target=position)
stop_speed (list) – list of speed stop zones (target=speed)
- get_atomlight_couples() list[source]#
Returns a list of (transition, laser, detuning) tuples
- Returns:
a list of tuples with (transition, laser, detuning)
- Return type:
list
- get_force_copy(tag: str)[source]#
Returns a copy of the force indentified by ‘tag’
- Parameters:
tag (str) – the tag of the force
- get_laser_copy(tag: str)[source]#
Returns a copy of the laser indentified by ‘tag’
- Parameters:
tag (str) – the tag of the laser
- get_magnetic_field_copy(tag: str)[source]#
Returns a copy of the magnetic field indentified by ‘tag’
- Parameters:
tag (str) – the tag of the magnetic field
- get_object_copy(collection: str, tag: str) EnvObject[source]#
Returns a copy of an object from ‘collection’ with ‘tag’
Collection must be in [‘laser’, ‘magnetic field’, ‘zone’, ‘force’ ]
- Parameters:
collection (str) – the collection from which the object should be taken
tag (str) – the tag of the object
- get_stop_zones()[source]#
Returns two list of the zones whose
actionare set tostop- Returns:
stop_position (list) – list of position stop zones (target=position)
stop_speed (list) – list of speed stop zones (target=speed)
- get_zone_copy(tag: str)[source]#
Returns a copy of the zone indentified by ‘tag’
- Parameters:
tag (str) – the tag of the zone
- in_zone(pos_speed_vector: ndarray, action: str = 'stop') ndarray[source]#
Evaluates whether ‘pos_speed_vector’ is in the zones corresponding to a given action
- Parameters:
vector (array of shape (6,) or (n1, n2, ..., 6)) – cartesian coordinates of the vectors in the lab frame
action (str, optionnal) – the action of the zones to consider by default “stop”
- Returns:
in_zone – whether the vector is ‘in the zone’
- Return type:
array of shape (1,) or (n1, n2, …, 1)
Notes
vectorshould be an array of shape (6,) or (n1, n2, .., 6), where last axis contains the coordinates (position & speed) to evaluate.In all cases, the last dimension contains cordinates (x, y, z, vx, vy, vz),
- property objects: dict#
the collection of objects
- Type:
dict
- print_force_info(tag: str)[source]#
Print info of the force indentified by ‘tag’
- Parameters:
tag (str) – the tag of the force
- print_laser_info(tag: str)[source]#
Print info of the laser indentified by ‘tag’
- Parameters:
tag (str) – the tag of the laser
- print_magnetic_field_info(tag: str)[source]#
Print info of the magnetic field indentified by ‘tag’
- Parameters:
tag (str) – the tag of the magnetic field
- print_object_info(collection: str, tag: str)[source]#
Print info for an object from ‘collection’ with ‘tag’
Collection must be in [‘laser’, ‘magnetic field’, ‘zone’ ]
- Parameters:
collection (str) – the collection from which the object should be taken
tag (str) – the tag of the object
- print_zone_info(tag: str)[source]#
Print info of the zone indentified by ‘tag’
- Parameters:
tag (str) – the tag of the zone
- rm_atomlight_coupling(laser: str | LaserBeam, transition: str)[source]#
Removes an atom-light coupling
- Parameters:
laser (str | LaserBeam) – laser coupled : tag (str) or directly the object
transition (str) – transition tag
- rm_magnetic_field(tag)[source]#
Removes magnetic field by tag
- Parameters:
tag (str) – magnetic field tag
- rm_object(collection: str, tag: str)[source]#
Remove object from ‘collection’ with ‘tag’
Collection must be in [‘laser’, ‘magnetic field’, ‘zone’, ‘force’]
- Parameters:
collection (str) – the collection from which the object should be removed
tag (str) – the tag of the object
- update_objects(obj: EnvObject | list, verbose=False, error_on_fail=False)[source]#
Update an object or a list of objects
- Parameters:
obj (EnvObject | list) – a environment object or a list of objects
verbose (bool, optional) – if set to True messages are displayed. Defaults to False.
error_on_fail (bool, optional) – if set to True, raises an error if it fails. Otherwise, just raises a warning and continues. Defaults to False.
Notes
The function takes a single environment object (laser, magnetic field…) or a collection of objects in the form of a tuple or a list.
For each object given as an input, if there is an object with:
same type (laser, magnetic field) and
same tag
then this object is replaced by the new one.