shadow4.sources.bending_magnet package
Submodules
shadow4.sources.bending_magnet.s4_bending_magnet module
Bending magnet magnetic structure.
- class shadow4.sources.bending_magnet.s4_bending_magnet.S4BendingMagnet(radius=1.0, magnetic_field=1.0, length=1.0, emin=10000.0, emax=11000.0, ng_e=11, flag_emittance=0)[source]
Bases:
BendingMagnetDefines a shadow4 bending magnet magnetic structure.
Note that the radius and magnetic_field are somewhat redundant but they must be correctly set here. One can be calculated from the other if the electron energy is known (it is not known here). Shadow will use the magnetic_radius to sample the trajectory. The radius is positive in a typical ring (clockwise, e-). The sign of magnetic field indicates the direction of the arc: B>0 means x<0, and B<0 means x>0.
- Parameters:
radius (float, optional) – Physical Radius/curvature of the magnet in m.
magnetic_field (float, optional) – Magnetic field strength (signed) in T.
length (float, optional) – physical length of the bending magnet (along the arc) in m.
emin (float, optional) – minimum photon energy in eV.
emax (float, optional) – maximum photon energy in eV.
ng_e (int, optional) – Number of points in energy.
flag_emittance (int, optional) – Flag: 0=Zero emmitance (filament beam), 1=Use emittance.
- get_energy_box()[source]
Returns the limits of photon energy distribution for the source and the number of points.
- Returns:
(emin, emax, npoints)
- Return type:
tuple
- get_info()[source]
Returns the specific information for the wiggler magnetic structure.
- Return type:
str
- classmethod initialize_from_magnetic_field_divergence_and_electron_energy(magnetic_field=1.0, divergence=0.001, electron_energy_in_GeV=1.0, emin=10000.0, emax=11000.0, ng_e=11, flag_emittance=0)[source]
Constructor from magnetic field divergence and electron energy.
- Parameters:
magnetic_field (float, optional) – Magnetic field strength in T.
divergence (float, optional) – The accepted divergence in rad.
electron_energy_in_GeV (float, optional) – The electron beam energy in GeV.
emin (float, optional) – minimum photon energy in eV.
emax (float, optional) – maximum photon energy in eV.
ng_e (int, optional) – Number of points in energy.
flag_emittance (int, optional) – Flag: 0=Zero emmitance (filament beam), 1=Use emittance.
- Return type:
instance of S4BendingMagnet
- classmethod initialize_from_magnetic_radius_divergence_and_electron_energy(magnetic_radius=10.0, divergence=0.001, electron_energy_in_GeV=1.0, emin=10000.0, emax=11000.0, ng_e=11, flag_emittance=0)[source]
Constructor from magnetic radius, divergence and electron energy.
- Parameters:
magnetic_radius (float, optional) – The magnetic radius in m.
divergence (float, optional) – The accepted divergence in rad.
electron_energy_in_GeV (float, optional) – The electron beam energy in GeV.
emin (float, optional) – minimum photon energy in eV.
emax (float, optional) – maximum photon energy in eV.
ng_e (int, optional) – Number of points in energy.
flag_emittance (int, optional) – Flag: 0=Zero emmitance (filament beam), 1=Use emittance.
- Return type:
instance of S4BendingMagnet
- is_monochromatic()[source]
Returns a flag indicating if the source is monochromatic (True) or polychromatic (False).
- Return type:
boolean
- set_energy_box(emin, emax, npoints=None)[source]
Sets a box for photon energy distribution for the source.
- Parameters:
emin (float) – minimum photon energy in eV.
emax (float) – maximum photon energy in eV.
npoints (int, optional) – Number of points in energy.
shadow4.sources.bending_magnet.s4_bending_magnet_light_source module
Bending magnet light source.
- class shadow4.sources.bending_magnet.s4_bending_magnet_light_source.S4BendingMagnetLightSource(name='Undefined', electron_beam=None, magnetic_structure=None, nrays=5000, seed=12345)[source]
Bases:
S4LightSourceDefines a bending magnet light source and implements the mechanism of sampling rays.
- Parameters:
name (str, optional) – The name of the light source.
electron_beam (instance of ElectronBeam) – The electron beam parameters.
magnetic_structure (instance of S4BendingMagnet) – The shadow4 bending magnet magnetic structure.
nrays (int, optional) – The number of rays.
seed (int, optional) – The Monte Carlo seed.
- calculate_spectrum(photon_energy_array=None, shift_half_interval=0, output_file='')[source]
Calculates the spectrum.
- Parameters:
photon_energy_array (None, numpy array, optional) – The array with the photon energy values (in eV) for calculating the spectrum. If None, it uses the emin, emax and ng_e from the magnetic structure.
shift_half_interval (int, optional) – For photon_energy_array=None, set this to 1 to shift the energy points a half-energy-interval (must be uniform) to mimic histogramming arrays.
output_file (str, optional) – Name of the file to write the spectrom (use “” for not writing file).
- Returns:
(e, f, w) numpy arrays with photon energy (e), photon flux (f) and spectral power (w).
- Return type:
tuple
- get_beam(F_COHER=0, psi_interval_in_units_one_over_gamma=None, psi_interval_number_of_points=1001, sample_emission_cone_in_horizontal=1)[source]
Creates the beam as emitted by the bending magnet.
- Parameters:
F_COHER (int, optional) – A flag for coherent (1) or incoherent (0) rays.
psi_interval_in_units_one_over_gamma (int, optional) – The sampling interval for the vertical divergence in units if 1/gamma. If None, it is calculated automatically.
psi_interval_number_of_points (int, optional) – The number of points for the vertical divergency scan.
- Return type:
instance od S4beam
- get_info()[source]
Returns the specific information for the bending magnet light source.
- Return type:
str
- get_pdf()[source]
Returns the probability distribution function used to sample radiation angles and photon energy.
- Returns:
(tot_intensity, s_intensity, p_intensity, angle_array_mrad, photon_energy_array) - tot_intensity, s_intensity, p_intensity : if monochromatic source: 1D arrays (vs) angle
if polychromatic source: @D arrays (vs) angle, energy
angle_array_mrad: 1D array
photon_energy_array: 1D array if polychronatic source else None.
- Return type:
tuple