Useful formulas¶
Statistics¶
- twissed.weighted_avg(a: float | ndarray, weights: float | ndarray) float | ndarray [source]¶
Calculate the weighted average of array a.
\[\langle {\bf a} \rangle = \frac{\sum_i w_i a_i}{\sum_i w_i} \, ,\]- Parameters:
arr (Union[float, np.ndarray]) – 1D numpy array
weights (Union[float, np.ndarray]) – 1D numpy array
- Returns:
weighted average.
- Return type:
Union[float, np.ndarray]
- twissed.weighted_std(arr: float | ndarray, weights: float | ndarray, verbose=True) float | ndarray [source]¶
Calculate the weighted standard deviation.
- Parameters:
arr (Union[float, np.ndarray]) – 1D numpy array
weights (Union[float, np.ndarray]) – 1D numpy array
- Returns:
weighted standard deviation.
- Return type:
Union[float, np.ndarray]
- twissed.weighted_med(arr: float | ndarray, weights: float | ndarray, verbose=True) float | ndarray [source]¶
Compute the weighted median
- Parameters:
a (Union[float, np.ndarray]) – 1D numpy array
weights (Union[float, np.ndarray]) – 1D numpy array
- Returns:
weighted median
- Return type:
Union[float, np.ndarray]
Physics¶
- twissed.laser_strength(I0: float, lambda0: float, normalised: bool = False) float [source]¶
Laser strength parameter \(a_0\).
\[a_0 = \sqrt{\frac{e^2}{2 \pi^2 \epsilon_0 m_e^2 c^5} \lambda_0 I_0}\]or if
normalised == True
:\[a_0 = 0.855 \lambda_0 [\mu \mathrm{m}] \sqrt{I_0 [10^{18} \mathrm{W/cm}^2]}\]- Parameters:
I0 (float) – Maximum intensity
lambda0 (float) – Wavelength
normalised (bool) – Normalised equation. Default to False.
- Returns:
Laser strength parameter
- Return type:
float
- twissed.critical_density(lambda0: float) float [source]¶
Laser critical density \(n_{\mathrm{c}}\).
\[n_{\mathrm{c}} = \frac{m_e \epsilon_0 \omega_0^2}{e^2}\]- Parameters:
lambda0 (float) – Wavelength
- Returns:
Laser critical density
- Return type:
float
- twissed.Rayleigh_length(w0: float, lambda0: float) float [source]¶
Return the Rayleigh length \(z_{\rm R}\).
\[z_{\rm R} = \frac{\pi w_0^2}{\lambda_0}\]- Parameters:
w0 (float) – Maximum waist
lambda0 (float) – Wavelength
- Returns:
Rayleigh length
- Return type:
float
- twissed.accelerating_electric_field(ne: float) float [source]¶
Return the maximum accelerating electric field (a.k.a the wavebreaking field or space charge field) \(E_{\rm max}\).
\[E_{\rm max} = \frac{m_e c \omega_{\rm pe}}{e}\]- Parameters:
ne (float) – Plasma density in m-3
- Returns:
Maximum accelerating electric field in V/m
- Return type:
float
- twissed.waist0_theory(z: float | ndarray, w0: float, lambda0: float, zfoc: float = 0) float | ndarray [source]¶
Return the theoretical waist over \(z\).
\[w(z) = w_0 \sqrt{1 + \left( \frac{z - z_{\rm foc}}{z_{\rm R}} \right)^2}\]- Parameters:
z (Union[float, np.ndarray]) – Positions in z
w0 (float) – Maximum waist
zfoc (float) – Z focal position. Default to 0.
lambda0 (float) – Laser wavelength
- Returns:
Theoretical waist
- Return type:
Union[float, np.ndarray]
Helpful¶
- twissed.convert_laser_duration_FWHM(t: float, convert: str = 'fbpic_to_FWHM') float [source]¶
Convert laser FWHM duration.
- Parameters:
t (float) – time to convert.
convert (str, optional) – Type of conversion. Chose between “fbpic_to_FWHM”, “FWHM_to_fbpic”, “smilei_to_FWHM” or “FWHM_to_smilei”. Defaults to “fbpic_to_FWHM”.
- Returns:
Converted time
- Return type:
float