syned.storage_ring.magnetic_structures package

Submodules

syned.storage_ring.magnetic_structures.bending_magnet module

Base class for a Bending Magnet

class syned.storage_ring.magnetic_structures.bending_magnet.BendingMagnet(radius=1.0, magnetic_field=1.0, length=1.0)[source]

Bases: MagneticStructure

Constructor.

Parameters:
  • radius (float, optional) – Physical Radius/curvature of the magnet in m.

  • magnetic_field (float, optional) – Magnetic field strength in T.

  • length (float, optional) – physical length of the bending magnet (along the arc) in m.

classmethod calculate_critical_energy(magnetic_radius, electron_energy_in_GeV)[source]

Calculates the photon critical energy from magnetic radius and electron energy.

Parameters:
  • magnetic_radius (float) – Magnetic radius in m.

  • electron_energy_in_GeV (float) – The electron beam energy in GeV.

Returns:

The photon critical energy in eV.

Return type:

float

References

See, for example, https://people.eecs.berkeley.edu/~attwood/srms/2007/Lec09.pdf

classmethod calculate_critical_energy_from_magnetic_field(magnetic_field, electron_energy_in_GeV)[source]

Calculates the photon critical energy from magnetic field and electron energy.

Parameters:
  • magnetic_field (float) – Magnetic field in T.

  • electron_energy_in_GeV (float) – The electron beam energy in GeV.

Returns:

The critical energy in eV.

Return type:

float

References

See, for example, https://people.eecs.berkeley.edu/~attwood/srms/2007/Lec09.pdf

classmethod calculate_magnetic_field(magnetic_radius, electron_energy_in_GeV)[source]

Calculates magnetic field from magnetic radius and electron energy.

Parameters:
  • magnetic_radius (float) – Magnetic radius in m.

  • electron_energy_in_GeV (float) – The electron beam energy in GeV.

Returns:

The magnetic field in T.

Return type:

float

References

See, for example, https://people.eecs.berkeley.edu/~attwood/srms/2007/Lec09.pdf

classmethod calculate_magnetic_radius(magnetic_field, electron_energy_in_GeV)[source]

Calculates magnetic radius from magnetic field and electron energy.

Parameters:
  • magnetic_field (float) – Magnetic field in T.

  • electron_energy_in_GeV (float) – The electron beam energy in GeV.

Returns:

The magnetic radius in m.

Return type:

float

References

See, for example, https://people.eecs.berkeley.edu/~attwood/srms/2007/Lec09.pdf

get_critical_energy(electron_energy_in_GeV, method=1)[source]

Returns the photon critical energy in eV.

Parameters:
  • electron_energy_in_GeV (float, optional) – The electron beam energy in GeV.

  • method (int, optional) – 0= uses magnetic radius, 1=uses magnetic field

Return type:

float

get_magnetic_field(electron_energy_in_GeV)[source]

returns magnetic field in T (from the magnetic radius and electron energy).

Parameters:

electron_energy_in_GeV (float, optional) – The electron beam energy in GeV.

Return type:

float

get_magnetic_radius(electron_energy_in_GeV)[source]

Calculates magnetic radius (from the magnetic field and electron energy).

Parameters:

electron_energy_in_GeV (float, optional) – The electron beam energy in GeV.

Return type:

float

horizontal_divergence()[source]

returns the horizontal divergence in rad.

Return type:

float

classmethod initialize_from_magnetic_field_divergence_and_electron_energy(magnetic_field=1.0, divergence=0.001, electron_energy_in_GeV=1.0, **params)[source]

Returns an bending magnet from the magnetic field and electron energy.

Parameters:
  • magnetic_field (float, optional) – Magnetic field strength in T.

  • divergence (float, optional) – The beam divergence also corresponding to the BM angle in rad.

  • electron_energy_in_GeV (float, optional) – The electron beam energy in GeV.

  • params – Other parameters accepted by BendingMagnet.

Return type:

instance of BendingMagnet

classmethod initialize_from_magnetic_radius_divergence_and_electron_energy(magnetic_radius=10.0, divergence=0.001, electron_energy_in_GeV=1.0, **params)[source]

Returns an bending magnet from the magnetic radius and electron energy.

Parameters:
  • magnetic_radius (float, optional) – Magnetic radius in m.

  • divergence (float, optional) – The beam divergence also corresponding to the BM angle in rad.

  • electron_energy_in_GeV (float, optional) – The electron beam energy in GeV.

  • params – Other parameters accepted by BendingMagnet.

Return type:

instance of BendingMagnet

length()[source]

returns the BM length in m.

Return type:

float

magnetic_field()[source]

Returns the bagnetic field in T.

Return type:

float

radius()[source]

Returns the BM radius in m.

Return type:

float

syned.storage_ring.magnetic_structures.insertion_device module

Base class for all insertion devices: wiggler, undulator

class syned.storage_ring.magnetic_structures.insertion_device.InsertionDevice(K_vertical=0.0, K_horizontal=0.0, period_length=0.0, number_of_periods=1.0)[source]

Bases: MagneticStructure

Base clase for the Insertion Device (ID) (common class for wigglers and undulators).

Parameters:
  • K_vertical (float, optional) – The deflection K parameter corresponding to magnetic field in the vertical direction.

  • K_horizontal (float, optional) – The deflection K parameter corresponding to magnetic field in the horizontal direction.

  • period_length (float, optional) – The ID period in m.

  • number_of_periods (float, optional) – The number of periods. It may be a float, considering that number_of_periods = ID_length / period_length.

K()[source]

Returns K vertical.

Return type:

float

K_horizontal()[source]

Returns K horizontal.

Return type:

float

K_vertical()[source]

Returns K vertical.

Return type:

float

length()[source]

Returns the ID length in m.

Return type:

float

magnetic_field_horizontal()[source]

Returns the peak magnetic field in T in the horizontal direction.

Return type:

float

magnetic_field_vertical()[source]

Returns the peak magnetic field in T in the vertical direction.

Return type:

float

number_of_periods()[source]

Returns the number of periods.

Return type:

float

period_length()[source]

Returns the ID period in m.

Return type:

float

set_K_horizontal_from_magnetic_field(B_horizontal)[source]

Set the horizontal K value given the corresponding peak magnetic field.

Parameters:

B_vertical (float) – Peak magnetic field in T.

set_K_vertical_from_magnetic_field(B_vertical)[source]

Set the vertical K value given the corresponding peak magnetic field.

Parameters:

B_vertical (float) – Peak magnetic field in T.

syned.storage_ring.magnetic_structures.undulator module

Implement an undulator with vertical and horizontal magnetic fields.

class syned.storage_ring.magnetic_structures.undulator.Undulator(K_vertical=0.0, K_horizontal=0.0, period_length=0.0, number_of_periods=1.0)[source]

Bases: InsertionDevice

Constructor.

Parameters:
  • K_vertical (float, optional) – The deflection K parameter corresponding to magnetic field in the vertical direction.

  • K_horizontal (float, optional) – The deflection K parameter corresponding to magnetic field in the horizontal direction.

  • period_length (float, optional) – The ID period in m.

  • number_of_periods (float, optional) – The number of periods. It may be a float, considering that number_of_periods = ID_length / period_length.

approximated_coherent_fraction(syned_electron_beam, harmonic=1)[source]

Gets the approximated coherent fraction at resonance.

It is calculated as the product of the horizontal and vertical coherent fractions.

Parameters:
  • syned_electron_beam (instance of ElectronBeam) – The electron bean used to get the electron beam sizes and electron energy.

  • harmonic (int) – The harmonic number (1,2,3…).

Return type:

float

approximated_coherent_fraction_horizontal(syned_electron_beam, harmonic=1)[source]

Gets the approximated coherent fraction at resonance in the horizontal direction.

It is calculated as the ratio of the phase space of the coherent emission (zero emittance) over the actual emission (finite emittance).

Parameters:
  • syned_electron_beam (instance of ElectronBeam) – The electron bean used to get the electron beam sizes and electron energy.

  • harmonic (int) – The harmonic number (1,2,3…).

Return type:

float

approximated_coherent_fraction_vertical(syned_electron_beam, harmonic=1)[source]

Gets the approximated coherent fraction at resonance in the vertical direction.

It is calculated as the ratio of the phase space of the coherent emission (zero emittance) over the actual emission (finite emittance).

Parameters:
  • syned_electron_beam (instance of ElectronBeam) – The electron bean used to get the electron beam sizes and electron energy.

  • harmonic (int) – The harmonic number (1,2,3…).

Return type:

float

gaussian_central_cone_aperture(gamma, n=1.0)[source]

Returns the approximated angular width (sigma) in rad of the central cone.

Parameters:
  • gamma (float) – The gamma or Lorentz factor of the electron beam.

  • n (float, optional) – The harmonic number (1,2,3…) to be considered.

Return type:

float

References

Eq. 15 in https://xdb.lbl.gov/Section2/Sec_2-1.html

get_K_from_photon_energy(photon_energy, gamma, harmonic=1)[source]

Calculate K for a given resonance energy.

Parameters:
  • photon_energy (float) – The photon energy in eV.

  • gamma (float) – The electron gamma (Lorentz factor).

  • harmonic (int) – The harmonic number.

Return type:

float

get_photon_sizes_and_divergences(syned_electron_beam, harmonic=1)[source]

Return the photon beam sizes and divergences.

They are calculates as a convolution of the radiation sigmas (get_sigmas_radiation()) and the electron beam sizes.

Parameters:
  • syned_electron_beam (instance of ElectronBeam) – The electron bean used to get the electron beam sizes and electron energy.

  • harmonic (int) – The harmonic number (1,2,3…).

Returns:

(Sx [m], Sz [m], Sxp [rad], Szp [rad])

Return type:

tuple

get_resonance_ring(gamma, harmonic=1.0, ring_order=1)[source]

Return the angular position of the rings at resonance.

Parameters:
  • gamma (float) – The gamma or Lorentz factor of the electron beam.

  • harmonic (float, optional) – The harmonic number (1,2,3…) to be considered.

  • ring_order (int, optional) – The ring order (1,2,3…)

Returns:

The angular position in rad.

Return type:

float

get_sigmas_radiation(gamma, harmonic=1.0)[source]

Returns the approximated radiation sigmas (size and divergence).

Parameters:
  • gamma (float) – The gamma or Lorentz factor of the electron beam.

  • harmonic (float, optional) – The harmonic number (1,2,3…) to be considered.

Returns:

(sigma_in_real_space [m], sigma_in_divergence_space [rad])

Return type:

tuple

References

See formulas 25 & 30 in Elleaume (Onuki & Elleaume) for the calculated sizes of the photon undulator beam. Onuki & Elleaume “Undulators, Wigglers and Their Applications” (2002) CRC Press.

classmethod initialize_as_vertical_undulator(K=0.0, period_length=0.0, periods_number=1.0, **params)[source]

Create an undulator with vertical magnetic field.

Parameters:
  • K (float, optional) – The deflection K parameter corresponding to magnetic field in the vertical direction.

  • period_length (float, optional) – The ID period in m.

  • periods_number (float, optional) – The number of periods. It may be a float, considering that number_of_periods = ID_length / period_length.

  • params (other parameters accepted by Undulator.) –

Return type:

instance of Undulator

resonance_energy(gamma, theta_x=0.0, theta_z=0.0, harmonic=1.0)[source]

Returns the resonant energy in eV.

Parameters:
  • gamma (float) – The gamma or Lorentz factor of the electron beam.

  • theta_x (float, optional) – The angle along the horizontal direction in rad.

  • theta_z (float, optional) – The angle along the vertical direction in rad.

  • harmonic (float, optional) – The harmonic number (1,2,3…) to be considered.

Return type:

float

resonance_frequency(gamma, theta_x=0.0, theta_z=0.0, harmonic=1.0)[source]

Returns the resonant frequency in Hz.

Parameters:
  • gamma (float) – The gamma or Lorentz factor of the electron beam.

  • theta_x (float, optional) – The angle along the horizontal direction in rad.

  • theta_z (float, optional) – The angle along the vertical direction in rad.

  • harmonic (float, optional) – The harmonic number (1,2,3…) to be considered.

Return type:

float

resonance_wavelength(gamma, theta_x=0.0, theta_z=0.0, harmonic=1.0)[source]

Returns the resonant wavelength in m.

Parameters:
  • gamma (float) – The gamma or Lorentz factor of the electron beam.

  • theta_x (float, optional) – The angle along the horizontal direction in rad.

  • theta_z (float, optional) – The angle along the vertical direction in rad.

  • harmonic (float, optional) – The harmonic number (1,2,3…) to be considered.

Return type:

float

undulator_full_emitted_power(gamma, ring_current)[source]

Returns the total emitted power by an undulator.

Parameters:
  • gamma (float) – The gamma or Lorentz factor of the electron beam.

  • ring_current (float) – The current of the electron beam in A.

Returns:

The power in W.

Return type:

float

References

Eq. 18 in https://xdb.lbl.gov/Section2/Sec_2-1.html

syned.storage_ring.magnetic_structures.wiggler module

class syned.storage_ring.magnetic_structures.wiggler.Wiggler(K_vertical=0.0, K_horizontal=0.0, period_length=0.0, number_of_periods=1)[source]

Bases: InsertionDevice

Constructor.

Parameters:
  • K_vertical (float, optional) – The deflection K parameter corresponding to magnetic field in the vertical direction.

  • K_horizontal (float, optional) – The deflection K parameter corresponding to magnetic field in the horizontal direction.

  • period_length (float, optional) – The ID period in m.

  • number_of_periods (float, optional) – The number of periods. It may be a float, considering that number_of_periods = ID_length / period_length.

Module contents