atomsmltr.simulation.simulator package#
simulator#
Here we implement the Simulation class, that allows to run simulations
on a configuration defined via the Configuration class.
Examples
Run a simulation with one initial condition vector
# ... init a config object with the `Configuration` class
# - import a simulation class
from atomsmltr.simulation import ScipyIVP_3D
# - init and setup
sim = ScipyIVP_3D(method="Radau")
sim.config = config
# - parameters
u0 = (0, 0, -0.15, 0, 0, 200)
t = np.linspace(0, 0.05, 1000)
# - integrate
res = sim.integrate(u0, t)
Run a batch of simulations
# ... init a config object with the `Configuration` class
# - import a simulation class
from atomsmltr.simulation import ScipyIVP_3D
# - init and setup
sim = ScipyIVP_3D(method="Radau")
sim.config = config
# - parameters
# initial conditions
vz_list = np.linspace(10, 300, 40)
u0_list = [(0, 0, -0.15, 0, 0, v) for v in vz_list]
sim.u0_list = u0_list
# time
t = np.linspace(0, 0.05, 1000)
# - run a batch in parallel
res_list = sim.run(t, npools=5, verbose=True)
- class atomsmltr.simulation.simulator.Euler(config: Configuration = None)[source]#
Bases:
CustomSimulationBaseA 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.simulator.EulerSt(config: Configuration = None, enable_fluct: bool = True)[source]#
Bases:
CustomSimulationBaseA 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.simulator.RK4(config: Configuration = None)[source]#
Bases:
CustomSimulationBaseA homemade simulator based on fourth order Runge-Kutta method
- Parameters:
config (Configuration, optional) – the configuration to consider for the simulation
References
- class atomsmltr.simulation.simulator.RK4St(config: Configuration = None)[source]#
Bases:
CustomSimulationBaseA 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
- class atomsmltr.simulation.simulator.ScipyIVP_3D(config: Configuration = None, method: str = 'Radau', **solve_ivp_args)[source]#
Bases:
SimulationA simulation class based on Scipy’s
solve_ivpsolver- Parameters:
config (Configuration, optional) – the configuration to consider for the simulation
method (str, optional) – method used for the
solve_ivpsolver, 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
- 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.simulator.Simulation(config: Configuration = None)[source]#
Bases:
ABCThe generic Simulation object
- Parameters:
config (Configuration, optional) – the configuration to consider, by default None
Note
this is an abstract class, actual implementations are defined elsewhere and inherit from this class
- property config#
the configuration for this simulation
- Type:
- abstractmethod get_force(u: ndarray) ndarray[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)
- integrate(u0: ndarray, t: ndarray)[source]#
Integrates the system with initial conditions
u0- Parameters:
u0 (array, shape (6,)) – the initial conditions (x, y, z, vx, vy, vz)
t (array, shape (n,)) – the timesteps to integrate
- Returns:
the result of the simulation
- Return type:
res
- run(t: ndarray, u0_list: list = None, npools: int = 0, verbose: bool = False) list[source]#
Runs a batch of simulations from a list of initial conditions
- Parameters:
t (array, shape (n,)) – time steps for the simulation
u0_list (list, optional) – list of initial conditions, by default None
npools (int, optional) – number of pools for parallel computing. If set to zero, no paralalelisation, by default 0
verbose (bool, optional) – if set to True, a progress bar is displayed, by default False
- Returns:
res_list – a list of results
- Return type:
list
Examples
# ... init a config object with the `Configuration` class # - import a simulation class from atomsmltr.simulation import ScipyIVP_3D # - init and setup sim = ScipyIVP_3D(method="Radau") sim.config = config # - parameters # initial conditions vz_list = np.linspace(10, 300, 40) u0_list = [(0, 0, -0.15, 0, 0, v) for v in vz_list] sim.u0_list = u0_list # time t = np.linspace(0, 0.05, 1000) # - run a batch in parallel res_list = sim.run(t, npools=5, verbose=True)
- property u0_list#
a list of initial conditions for batch running
- Type:
list
- class atomsmltr.simulation.simulator.VelocityVerlet(config: Configuration = None)[source]#
Bases:
CustomSimulationBaseA homemade simulator based on velocity verlet method
- Parameters:
config (Configuration, optional) – the configuration to consider for the simulation
References
TODO: put here
Submodules#
- Home-made deterministic integrators
CustomSimulationBaseEulerRK4VelocityVerletstop_position_event()stop_speed_event()- Scipy-based integrators
ScipyIVP_3Dget_force_vec_scipy()stop_position_event_scipy()stop_speed_event_scipy()- simulators objects
SimResSimulationget_force_vec()- Home-made stochastic integrators
EulerStRK4Strandom_unit_vector()