atomsmltr.simulation package#

The atomsmltr.simulation subpackage provides classes to manage configurations and simulations

class atomsmltr.simulation.Configuration(object_list: EnvObject | list = None, atom: Atom = None)[source]#

Bases: object

Defines a configuration for the simulation

Parameters:
  • object_list (EnvObject | list, optional) – list of environment objects (lasers, magnetic fields, zones, forces) to include in the configuration, by default None

  • atom (Atom, optional) – atom for the simulation, by default None

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 to conf += 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
property atom: Atom#

the configuration atom

Type:

“Atom

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

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 action are set to stop

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

vector should 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),

list_forces()[source]#

Returns the list of forces’ tags in the current config

list_lasers() list[source]#

Returns the list of laser’s tags in the current config

list_magnetic_fields()[source]#

Returns the list of magnetic fields’ tags in the current config

list_zones()[source]#

Returns the list of zones’ tags in the current config

property objects: dict#

the collection of objects

Type:

dict

print_atomlight_info()[source]#

Prints atom-light coupling information

print_force_info(tag: str)[source]#

Print info of the force indentified by ‘tag’

Parameters:

tag (str) – the tag of the force

print_info()[source]#

Prints informations on the configuration

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_all_forces()[source]#

Remove all forces

rm_all_lasers()[source]#

Remove all lasers

rm_all_magnetic_fields()[source]#

Remove all magnetic fields

rm_all_objects()[source]#

Remove all objects

rm_all_zones()[source]#

Remove all zones

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_force(tag)[source]#

Removes force by tag

Parameters:

tag (str) – force tag

rm_laser(tag: str)[source]#

Removes laser by tag

Parameters:

tag (str) – laser 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

rm_zone(tag)[source]#

Removes zone by tag

Parameters:

tag (str) – zone tag

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:

  1. same type (laser, magnetic field) and

  2. same tag

then this object is replaced by the new one.

class atomsmltr.simulation.Euler(config: Configuration = None)[source]#

Bases: CustomSimulationBase

A homemade simulator based on Euler’s method

Parameters:

config (Configuration, optional) – the configuration to consider for the simulation

References

TODO: put here

class atomsmltr.simulation.EulerSt(config: Configuration = None, enable_fluct: bool = True)[source]#

Bases: CustomSimulationBase

A homemade simulator based on simple Euler integration method, taking into account spontaneous emission.

Parameters:
  • config (Configuration, optional) – the configuration to consider for the simulation

  • enable_fluct (Boolean, optional (default=True)) – if set to True, fluctations are enabled. Otherwise, the simulator boils down to a deterministic Euler simulator

References

TODO: put here

class atomsmltr.simulation.RK4(config: Configuration = None)[source]#

Bases: CustomSimulationBase

A homemade simulator based on fourth order Runge-Kutta method

Parameters:

config (Configuration, optional) – the configuration to consider for the simulation

References

https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

class atomsmltr.simulation.RK4St(config: Configuration = None)[source]#

Bases: CustomSimulationBase

A homemade simulator based on fourth order Runge-Kutta method, taking into account spontaneous emission.

Parameters:

config (Configuration, optional) – the configuration to consider for the simulation

References

https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

class atomsmltr.simulation.ScipyIVP_3D(config: Configuration = None, method: str = 'Radau', **solve_ivp_args)[source]#

Bases: Simulation

A simulation class based on Scipy’s solve_ivp solver

Parameters:
  • config (Configuration, optional) – the configuration to consider for the simulation

  • method (str, optional) – method used for the solve_ivp solver, by default “Radau”

  • **solve_ivp_args – all other arguments are directly passed to solve_ivp

References

https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html

dudt(t, u)[source]#

should return the derivative of the position/speed vector u

get_force(u)[source]#

returns the force felt at a position/speed vector u

Parameters:

u (array, shape (6,) or (n1, n2, .., 6)) – array of cartesian coordinates (position and speed) in the lab frame

Returns:

force – the force at the coordinates given by pos_speed_vector

Return type:

array, shape (3,) or (n1, n2, .., 3)

class atomsmltr.simulation.VelocityVerlet(config: Configuration = None)[source]#

Bases: CustomSimulationBase

A homemade simulator based on velocity verlet method

Parameters:

config (Configuration, optional) – the configuration to consider for the simulation

References

TODO: put here

Subpackages#

Submodules#