MoleCool.tools.diststraj#

This Module contains different type of functions and classes, e.g. to calculate simple linear trajectories through multiple apertures and to evaluate trajectories as solutions of the Monte Carlo simulations.

Functions

get_dist(system[, key, unperturbed, radial, ...])

Extract the results of the Monte Carlo (MC) simulation and calculate the distribution after a certain time of flight distance.

get_hist_vals(system[, yz, w, radial, ...])

Get histogram values from Monte Carlo simulation distributions.

load_init_distr(system, fname[, samplesize, ...])

loading initial velocity and position distribution into system instance.

plot_hist(system[, key, yz, y_off, ax, ...])

Plotting histograms from get_hist_vals.

transversal_width2Temp([w_sigma, v_Fw, ...])

Calculate the velocity and corresponding temperature of a particle that is flying for a certain total distance and finally reaches a specific transversal position starting from zero position.

Classes

TrajectoryApertures([name, diameter0, ...])

Set up an instance for calculating linear propagation trajectories through multiple round apertures.

MoleCool.tools.diststraj.transversal_width2Temp(w_sigma=0.0012, v_Fw=170, total_dist=0.58, mass=157, printing=True)[source]#

Calculate the velocity and corresponding temperature of a particle that is flying for a certain total distance and finally reaches a specific transversal position starting from zero position. The temperature corresponds to a transversal Gaussian distribution with standard deviation given by the transversal position w_sigma.

Parameters:
  • w_sigma (float or np.ndarray, optional) – transversal position in m. The default is 1.2e-3.

  • v_Fw (float, optional) – Forward velocity in m/s. The default is 170.

  • total_dist (float, optional) – Total flying distance in m. The default is 58e-2.

  • mass (float, optional) – atomic mass units of the particle. The default is 157.

  • printing (bool, optional) – for enabling printing additional information. The default is True.

Returns:

  • T (float or np.ndarray) – temperature in K.

  • v_tr (float or np.ndarray) – Transversal velocity in m/s.

MoleCool.tools.diststraj.load_init_distr(system, fname, samplesize=None, x_init=0.0, plotting=False)[source]#

loading initial velocity and position distribution into system instance.

Parameters:
  • system (System) – The System into which the distributions should be stored.

  • fname (str) – file name of the distribution pkl file.

  • samplesize (int, optional) – number of samples to be used from the distribution. The default is None for taking all samples.

  • x_init (int, optional) – Distance from x=0 where initial free propagation starts to let the initial distribution evolve in the transverse axes. Or, initial free propagation until entering interaction zone. At x=0 The MC trajectory simulation starts. The default is 0..

  • plotting (bool, optional) – Whether plotting is enabled. The default is False.

class MoleCool.tools.diststraj.TrajectoryApertures(name='TrajApers', diameter0=0.003, diameters=[0.005, 0.0033, 10, 10], x_aper=[0.028, 0.123, 0.17, 0.55], labels=['aper1', 'aper2', 'PD1', 'PD2'])[source]#

Bases: object

Set up an instance for calculating linear propagation trajectories through multiple round apertures. To initiate, specify the apertures’ labels and geometrics.

The whole simulation is based on the following default axes definitions:

  • x-axis: longitudinal direction (molecular beam axis)

  • y-axis: transversal horizontal direction along probe lasers

  • z-axis: transversal vertical direction

Parameters:
  • name (str, optional) – with this you can name the instance which is used in other functions for saving figures or hdf5 files if no other filename is specified. Default is ‘TrajApers’.

  • diameter0 (float, optional) – Diameter of buffer gas cell output in m. The default is 3e-3.

  • diameters (list, optional) – Diameters of the apertures in m. The default is [5e-3, 3.3e-3, 10, 10].

  • x_aper (list, optional) – Positions of the apertures along the x-axis. The default is [28e-3, 123e-3, 170e-3, 580e-3].

  • labels (list, optional) – Labels of the apertures. The default is [‘aper1’, ‘aper2’, ‘PD1’, ‘PD2’].

calc_propagation_apers(samplesize=5000000, mu=[200, 0, 0], sigma=[32.0, 12.0, 12.0], v_tr_max=0.0)[source]#

Calculate the distributions at every aperture using simple linear trajectories of the particles that are removed when hitting on the apertures.

Parameters:
  • samplesize (int, optional) – how many particles or samples trajectories to be calculated. The default is 5000000.

  • mu (list, optional) – mean values of all 3 axes in m/s for initializing a 3D Gaussian velocity distribution at the start. The default is [200, 0, 0].

  • sigma (list, optional) – Same as mu but standard deviations. The default is [32., 12., 12.].

  • v_tr_max (float, optional) – maximum initial transversal velocity at the edge of the buffer gas cell output. The transversal velocity distributions’ mean is shifted linearly from 0 to v_tr_max at the edges. The default is +0.

initial_rdist_from_other(ind=-1, save_hdf5=False, fname='')[source]#

Saving initial distribution of only the molecules that made it through all the apertures until reaching the aperture with index ind.

Parameters:
  • ind (int, optional) – Index of the aperture from which the initial distribution is to be calculated. The default is -1.

  • save_hdf5 (bool, optional) – Whether to save the initial distribution as hdf5. The default is False.

  • fname (str, optional) – filename. The default is ‘’.

Returns:

rdist0_new – Calculated new initial distribution from final distribution.

Return type:

np.ndarray

get_hist_data(i, w, r_v='r', bins=30)[source]#

Calculate histogram data for the distribution at a certain aperture. All important evaluated arrays are saved in the dictionary hist_data.

Parameters:
  • i (int) – index of the aperture.

  • w (float) – Should imitate the imaging laser beam width as a width of the slice which is cut out of the 2D plane. So, it is the standard deviation in m of the Gaussian integrating over z-axis.

  • r_v (str, optional) – position of velocity histogram (‘r’ or ‘v’). The default is ‘r’.

  • bins (int, optional) – Number of bins. The default is 30.

Returns:

Dictionary with x and y axes of histogram data (x_data, y_data), fit data (x_data_fit and y_data_fit) and fit values (popt). This dictionary is also stored and can afterwards be accessed in the attribute hist_data in the following way: hist_data[r_v][i].

Return type:

dict

plot_pos_vel_distr(w=0.001, show_which=None, bins=(30, 30), save_fig=False, fname='')[source]#

Plot 1D and 2D position and velocity distributions as histograms.

Parameters:
  • w (float, optional) – width see get_hist_data(). The default is 1e-3.

  • show_which (list of int, optional) – indices (of apertures below) for which the velocity distrs should be plotted. The default is None.

  • bins (tuple, optional) – Numbers of bins for position and velocity histograms, respectively.

  • save_hdf5 (bool, optional) – Whether to save the initial distribution as hdf5. The default is False.

  • fname (str, optional) – filename. The default is ‘’.

get_fname(fname, middle='', end='')[source]#

Add some strings for making filenames

plot_trajectories(N=200, ind=-1, yunit=0.001, ylim=[-15, 15], save_fig=False, fname='')[source]#

Plotting trajectories of a certain distribution at a certain aperture.

Parameters:
  • N (int, optional) – number of trajectories to be plotted. The default is 200.

  • ind (int, optional) – Index of the aperture from which the initial distribution is to be calculated. The default is -1.

  • yunit (float, optional) – unit of y-axis. The default is 1e-3.

  • ylim (list, optional) – limits of y axis. The default is [-15,15].

  • save_hdf5 (bool, optional) – Whether to save the initial distribution as hdf5. The default is False.

  • fname (str, optional) – filename. The default is ‘’.

MoleCool.tools.diststraj.get_dist(system, key='r', unperturbed=False, radial=False, x_fly=0, xyz='z')[source]#

Extract the results of the Monte Carlo (MC) simulation and calculate the distribution after a certain time of flight distance.

Parameters:
  • system (System) – System instance from which the distributions are to be loaded.

  • key (str, optional) – Type of distribution. Can be ‘r’ for position, ‘v’ for velocity and ‘photons’ for scattered photon number. The default is ‘r’.

  • unperturbed (bool, optional) – Whether to neglect the MC results and only use the unperturbed initial distribution. The default is False.

  • radial (bool, optional) – Whether to calculate a radial distribution using the y and z axes. The default is False.

  • x_fly (float, optional) – Time of flight distance to propagate the distribution from MC further. The default is 0.

  • xyz (str, optional) – axis of the disibution to be returned. The default is ‘z’.

Returns:

Position or velocity distribution along a certain axis or scattered photon number distribution.

Return type:

np.ndarray

MoleCool.tools.diststraj.get_hist_vals(system, yz='z', w=0, radial=False, bins_per_unit=None, xrange=None, **kwargs)[source]#

Get histogram values from Monte Carlo simulation distributions.

Parameters:
  • system (System) – System instance from which the distributions are to be loaded..

  • yz (str, optional) – Axis for which the histogram should be calculated. The default is ‘z’.

  • w (float or dict, optional) – Parameter(s) for weighting along the other transversal axis. Should imitate the imaging laser beam width as a width of the slice which is cut out of the 2D plane. So, when a float number is provided, it is the standard deviation in m of the Gaussian integrating over z-axis. If otherwise a dictionary is provided, it can contain all parameters corresponding to the gaussian function (tools.gaussian()). The default is 0.

  • radial (bool, optional) – Whether to use a radial distribution. The default is False.

  • bins_per_unit (float, optional) – Number of bins per unit (e.g. m or m/s). The default is None.

  • xrange (tuple, optional) – xrange for evaluation the bins of the histogram. The default is None.

  • **kwargs (kwargs) – further keyword arguments for get_dist() function.

Returns:

  • hist_y (np.ndarray) – heights of the histogram’s bins.

  • hist_x (np.ndarray) – center positions of the histogram’s bins.

MoleCool.tools.diststraj.plot_hist(system, key='r', yz='z', y_off=0, ax=None, color=None, scale_x=1, **kwargs)[source]#

Plotting histograms from get_hist_vals.

Parameters: