Skip to content

Utils

utils

Attributes

MFX_prefocus_energy_range module-attribute

MFX_prefocus_energy_range = {(0, 5000): (None, None), (5000, 10000): (2, 750), (10000, 12000): (1, 428), (12000, 22000): (0, 333)}

NA module-attribute

NA = avogadro_number

eRad module-attribute

eRad = electron_radius * 100

logger module-attribute

logger = getLogger(__name__)

m_be module-attribute

m_be = mass

p_be module-attribute

p_be = density

Functions

estimate_beam_fwhm

estimate_beam_fwhm(radius, energy, fwhm_unfocused=0.0003, distance=4.474)
Source code in tfs/utils.py
def estimate_beam_fwhm(radius, energy, fwhm_unfocused = 300E-6, distance = 4.474):
    focal_len = focal_length(radius,energy)
    lam = calc.be_lens_calcs.photon_to_wavelength(energy) * 1E-9
    w_unfocused = calc.be_lens_calcs.gaussian_fwhm_to_sigma(fwhm_unfocused)*2
    waist = lam / np.pi * focal_len / w_unfocused
    rayleigh_range = np.pi *waist ** 2 /lam
    size = waist *np.sqrt(1.0 +(distance - focal_len) ** 2.0 / rayleigh_range **2)
    size_fwhm = calc.be_lens_calcs.gaussian_sigma_to_fwhm(size) /2.0
    waist_rd = '{:0.3e}'.format(waist)
    rayleigh_rang_rd = '{:0.3e}'.format(rayleigh_range)
    logger.info(f'waist: {waist_rd}')
    logger.info(f'rayleigh_range: {rayleigh_rang_rd}')
    logger.info(f'size_fwhm: {round(size_fwhm*1e6, 2)} um\n')

    return size_fwhm

focal_length

focal_length(radius, energy, N=1)

Calculate focal length using the pcds version of the focal length calculator

Source code in tfs/utils.py
def focal_length(radius, energy,N=1):
    """
    Calculate focal length using the pcds version of the focal length calculator
    """
    if N!=1:
        logger.error('N does not equal 1!')
    focal_length = calc.be_lens_calcs.calc_focal_length_for_single_lens(energy*1E-3,radius*1E-6)

    return focal_length

focal_length_old

focal_length_old(radius, energy, N=1)

Calculate the focal length of a Beryllium lens Ref: HR Beguiristain et al. OPTICS LETTERS, Vol. 27, No. 9 (2002)

Probably want to use pcdscalc instead eventually

Source code in tfs/utils.py
def focal_length_old(radius, energy, N=1):
    """
    Calculate the focal length of a Beryllium lens
    Ref: HR Beguiristain et al. OPTICS LETTERS, Vol. 27, No. 9 (2002)

    Probably want to use pcdscalc instead eventually
    """
    # Get scattering factors
    f1, f2 = pt.Be.xray.scattering_factors(energy=energy/1000)

    # Calculate delta (refraction index)
    f = f1+f2*1j
    f = f*p_be*NA/m_be
    wavelength = (12389.4/energy)*1E-08  # [cm]
    delta = (eRad * wavelength**2 * f / (2*np.pi)).real
    # delta = be_calcs.get_delta(energy/1000, 'Be', p_be) # too slow

    # f = R / (2N*delta)
    return radius*1e-6/2/N/delta