ocelot package¶
Subpackages¶
- ocelot.adaptors package
- Submodules
- ocelot.adaptors.astra2ocelot module
- ocelot.adaptors.astra_lattice_converter module
- ocelot.adaptors.csrtrack2ocelot module
- ocelot.adaptors.elegant2ocelot module
- ocelot.adaptors.elegant_lattice_converter module
- ocelot.adaptors.genesis module
- ocelot.adaptors.genesis4 module
- ocelot.adaptors.longlist2ocelot module
- ocelot.adaptors.mad8 module
- ocelot.adaptors.madx module
- ocelot.adaptors.madx_old module
- ocelot.adaptors.srwutil module
- ocelot.adaptors.wake_t module
- Module contents
- astraBeam2particleArray
- emittance_analysis
- exact_xp_2_xxstg_de
- exact_xp_2_xxstg_dp
- exact_xp_2_xxstg_mad
- exact_xxstg_2_xp_de
- exact_xxstg_2_xp_dp
- exact_xxstg_2_xp_mad
- particleArray2astraBeam
- AstraLatticeConverter
- csrtrackBeam2particleArray
- particleArray2csrtrackBeam
- read_file
- read_lattice_elegant
- read_twi_file
- ElegantLatticeConverter
- GenStatOutput
- GenesisElectronDist
- GenesisInput
- GenesisOutput
- GenesisParticlesDump
- GenesisRad
- adapt_rad_file
- assemble
- astra2edist
- astra2edist_ext
- beam_file_str
- create_exp_dir
- create_rad_file
- cut_beam
- cut_edist
- cut_edist_std
- cut_lattice
- disperse_edist
- dpa2edist
- edist2beam
- edist2parray
- find_transform
- generate_input
- generate_lattice
- getAverageUndulatorParameter
- get_beam_peak
- get_beam_s
- get_genesis_launcher
- get_genesis_new_launcher
- get_power_exit
- get_power_z
- get_spectrum
- max_dpa_dens
- next_run_id
- parray2edist
- rad_file_str
- read_astra_dist
- read_beam_file
- read_dfl_file
- read_dfl_file_out
- read_dpa_file
- read_dpa_file_out
- read_edist_file
- read_edist_file_out
- read_out_file
- read_out_file_stat
- read_out_file_stat_u
- read_rad_file
- rematch_edist
- repeat_edist
- run_genesis
- set_beam_energy
- set_edist_energy
- test_beam_transform
- transform_beam_file
- transform_beam_twiss
- write_beam_file
- write_dfl_file
- write_dpa_file
- write_edist_file
- zero_wake_at_ipk
- Genesis4Input
- Genesis4Output
- Genesis4ParticlesDump
- Namespace
- dpa42edist
- get_genesis4_launcher
- read_dfl4
- read_dpa4
- read_dpa42parray
- read_edist_hdf5
- read_gout4
- run_genesis4
- write_dfl4
- write_edist_hdf5
- write_gen4_lat
- find_comments
- find_functions
- find_line
- find_multiline
- find_objects
- find_subroutine
- lattice_str_from_mad8
- mad8saveline2lines
- mad8saveline2ocelot
- save_lattice_str
- translate
- xfel_line_transform
- TFS
- TrackingInfo
- beta
- binomial
- chisquare
- choice
- convert_madx_seq
- dirichlet
- expand_element
- exponential
- f
- gamma
- geometric
- get_par
- get_state
- get_tunes
- gumbel
- hypergeometric
- laplace
- logistic
- lognormal
- logseries
- madx_input
- multinomial
- multivariate_normal
- negative_binomial
- noncentral_chisquare
- noncentral_f
- normal
- parameter_str
- pareto
- permutation
- poisson
- power
- rand
- randint
- randn
- random
- random_integers
- random_sample
- rayleigh
- rename_par
- rename_type
- seed
- set_state
- shuffle
- standard_cauchy
- standard_exponential
- standard_gamma
- standard_normal
- standard_t
- triangular
- uniform
- vonmises
- wald
- weibull
- zipf
- MadObj
- RFcavity
- c2py
- collect_sequence
- find_objects
- lattice_str_from_madx
- line_transform
- madx2ocelot
- madx_seq2ocelot_seq
- parse_obj
- replace_objects
- save_lattice_str
- subs_objects
- translate
- parray_to_wake_t_beam
- wake_t_beam_to_parray
- astraBeam2particleArray
- particleArray2astraBeam
- read_lattice_elegant
- read_twi_file
- ocelot.common package
- Submodules
- ocelot.common.conf module
- ocelot.common.globals module
- ocelot.common.math_op module
- ocelot.common.ocelog module
- ocelot.common.py_func module
- ocelot.common.xio module
- Module contents
- alpha
- bin_array
- bin_scale
- complete_gamma
- conj_sym
- convolve
- corr_c_nb
- corr_c_np
- corr_c_py
- corr_f_nb
- corr_f_np
- corr_f_py
- correlation2d
- correlation2d_center
- deconvolve
- find_nearest
- find_nearest_idx
- find_saturation
- fit_gauss_1d
- fit_gauss_2d
- fwhm
- fwhm3
- gauss_fit
- gs_search
- index_of
- invert_cdf
- mut_coh_func
- mut_coh_func_py
- n_moment
- peaks
- rolling_mean
- rolling_window
- stats
- std_moment
- OcelogFormatter
- ocelog_indentate
- background
- bcolors
- copy_this_script
- deep_sim_dir
- directory_from_path
- filename_from_path
- list_attr
- loc_class
- ocelot.cpbd package
- Submodules
- ocelot.cpbd.beam module
- ocelot.cpbd.beam_params module
- ocelot.cpbd.chromaticity module
- ocelot.cpbd.coord_transform module
- ocelot.cpbd.csr module
- ocelot.cpbd.elements module
- ocelot.cpbd.errors module
- ocelot.cpbd.field_map module
- ocelot.cpbd.high_order module
- ocelot.cpbd.io module
- ocelot.cpbd.magnetic_lattice module
- ocelot.cpbd.match module
- ocelot.cpbd.moga module
- ocelot.cpbd.optics module
- ocelot.cpbd.orbit_correction module
- ocelot.cpbd.physics_proc module
- ocelot.cpbd.r_matrix module
- ocelot.cpbd.response_matrix module
- ocelot.cpbd.reswake module
- ocelot.cpbd.sc module
- ocelot.cpbd.touschek module
- ocelot.cpbd.track module
- ocelot.cpbd.wake3D module
- Module contents
- Beam
- BeamArray
- Particle
- ParticleArray
- SliceParameters
- Trajectory
- Twiss
- beam_matching
- convmode
- convmode_py
- ellipse_from_twiss
- gauss_from_twiss
- generate_beam
- generate_parray
- get_current
- get_envelope
- global_slice_analysis
- global_slice_analysis_extended
- interp1
- m_from_twiss
- moments
- parray2beam
- recalculate_ref_particle
- s2cur_auxil
- s2cur_auxil_py
- s_to_cur
- simple_filter
- slice_analysis
- slice_analysis_py
- slice_analysis_transverse
- sortrows
- waterbag_from_twiss
- EbeamParams
- I2_ID
- I3_ID
- I4_ID
- I5_ID
- radiation_integrals
- DZ
- calculate_sex_strength
- chromaticity
- compensate_chromaticity
- edge_chromaticity
- edge_chromaticity_old
- natural_chromaticity
- sextupole_chromaticity
- sextupole_id
- xp_2_xxstg_mad
- xxstg_2_xp_mad
- CSR
- K0_fin_anf
- Smoothing
- SubBinning
- csr_convolution
- nextpow2
- sample_0
- sample_1
- Aperture
- Bend
- Cavity
- CouplerKick
- Drift
- Edge
- Element
- Hcor
- Marker
- Matrix
- Monitor
- Multipole
- Octupole
- Pulse
- Quadrupole
- RBend
- SBend
- Sequence
- Sextupole
- Solenoid
- TDCavity
- TWCavity
- Undulator
- UnknownElement
- Vcor
- XYQuadrupole
- survey
- Errors
- create_copy
- errors_seed
- normal
- tgauss
- tgauss_old
- FieldMap
- length_array
- read_flat_file
- read_tabular_file
- H23
- arcline
- fringe_ent
- fringe_ext
- moments
- moments_py
- rk_field
- rk_field_scipy
- rk_track_in_field
- scipy_track_in_field
- sym_map
- t_nnn
- t_nnn_mad
- t_nnn_transport
- track_und_weave
- track_und_weave_openmp
- verlet
- verlet1O
- beam2input
- cell2input
- create_var_name
- element_def_string
- elements2input
- find_drifts
- find_obj_and_create_name
- find_objects
- get_elements
- lat2input
- load_particle_array
- load_particle_array_from_npz
- matrix_def_string
- pprinting
- print_elements
- rem_drifts
- save_particle_array
- save_particle_array2npz
- sort_elements
- twiss2input
- write_lattice
- write_power_supply_id
- CouplerKickUtil
- EdgeUtil
- EndElements
- MagneticLattice
- exclude_zero_length_element
- flatten
- lattice_format_converter
- merge_drifts
- merger
- closed_orbit
- match
- match_beam
- match_matrix
- match_tunes
- weights_default
- CavityTM
- CorrectorTM
- CouplerKickTM
- KickTM
- MethodTM
- MultipoleTM
- Navigator
- ProcessTable
- PulseTM
- RungeKuttaTM
- RungeKuttaTrTM
- SecondOrderMult
- SecondTM
- TWCavityTM
- TransferMap
- UndulatorTestTM
- fodo_parameters
- get_map
- lattice_transfer_map
- merge_maps
- periodic_twiss
- sym_matrix
- trace_obj
- trace_z
- transfer_map_rotation
- transfer_maps_mult
- transfer_maps_mult_py
- transform_vec_ent
- transform_vec_ext
- twiss
- twiss_fast
- unsym_matrix
- LInfinityNorm
- MICADO
- NewOrbit
- Orbit
- OrbitSVD
- change_corrector
- change_quad_position
- elem_response_matrix
- measure_response_matrix
- normal
- quad_response_matrix
- restore_corrector
- BeamAnalysis
- BeamTransform
- Chicane
- EmptyProc
- LaserHeater
- LaserModulator
- PhaseSpaceAperture
- PhysProc
- RectAperture
- SaveBeam
- SmoothBeam
- SpontanRadEffects
- create_r_matrix
- rot_mtx
- uni_matrix
- LinacDisperseSimRM
- LinacDisperseTmatrixRM
- LinacOpticalRM
- LinacRmatrixRM
- LinacSimRM
- MeasureResponseMatrix
- ResponseMatrix
- ResponseMatrixJSON
- RingRM
- LossShape
- ResistiveZaZb
- imp_resistiveAC_SI
- impedance2wake
- pipe_wake
- wake2impedance
- xfel_pipe_wake
- LSC
- SpaceCharge
- smooth_z
- B1
- B2
- F
- t_touschek
- Track_info
- aperture_limit
- arg_peaks
- contour_da
- create_track_list
- da_mpi
- ellipse_track_list
- find_highest
- find_nearest
- fma
- freq_analysis
- harmonic_position
- lattice_track
- merge_drifts
- nearest_particle
- normal
- phase_space_transform
- spectrum
- stable_particles
- track
- track_nturns
- track_nturns_mpi
- tracking_step
- update_effective_beta
- Der
- Int1
- Int1h
- Wake
- WakeKick
- WakeTable
- WakeTableDechirperOffAxis
- project_on_grid
- project_on_grid_py
- s2current
- triang_filter
- ocelot.gui package
- Subpackages
- Submodules
- ocelot.gui.accelerator module
- ocelot.gui.beam_plot module
- ocelot.gui.db_example1 module
- ocelot.gui.designer module
- ocelot.gui.dfl_plot module
- ocelot.gui.genesis4_plot module
- ocelot.gui.genesis_plot module
- ocelot.gui.misc module
- ocelot.gui.moga_plt module
- ocelot.gui.optics module
- ocelot.gui.plot_gen_out module
- ocelot.gui.qrc_icons module
- ocelot.gui.settings_plot module
- ocelot.gui.sr_plot module
- Module contents
- Save3DBeamDensity
- beam_jointplot
- compare_beams
- compare_beams_reduced
- compare_betas
- elem_cord
- plot_API
- plot_betas
- plot_disp
- plot_elems
- plot_lattice
- plot_opt_func
- plot_opt_func_reduced
- plot_resonance_diag
- plot_xy
- resonance
- show_da
- show_density
- show_e_beam
- show_e_beam_reduced
- show_mu
- show_phase_space
- plot_beam
- plot_estimator_energy_evo
- plot_estimator_power_evo
- plot_estimator_power_z
- plot_estimator_spectrogram
- plot_estimator_spectrum
- plot_1d_hprofile
- plot_dfl
- plot_dfl_all
- plot_dfl_waistscan
- plot_hprofile
- plot_stokes_3d
- plot_stokes_angles
- plot_stokes_sbfg_circ
- plot_stokes_sbfg_lin
- plot_stokes_values
- plot_trf
- plot_wigner
- plot_gen4_out_all
- plot_gen4_out_e
- plot_gen4_out_evo
- plot_gen4_out_ph
- plot_gen4_out_z
- subfig_evo_el_bunching
- subfig_evo_el_energy
- subfig_evo_el_pos
- subfig_evo_el_size
- subfig_evo_rad_pow
- subfig_evo_rad_pow_en
- subfig_evo_rad_pow_sz
- subfig_evo_rad_spec
- subfig_evo_rad_spec_sz
- subfig_evo_und
- subfig_evo_und_quad
- subfig_rad_size
- subfig_z_energy_espread
- subfig_z_energy_espread_bunching
- subfig_z_phase
- subfig_z_power_curr
- subfig_z_spec
- Display
- plot_dpa_bucket
- plot_dpa_bucket_out
- plot_edist
- plot_gen_corr
- plot_gen_out_all
- plot_gen_out_all_paral
- plot_gen_out_e
- plot_gen_out_evo
- plot_gen_out_ph
- plot_gen_out_scanned_z
- plot_gen_out_slip
- plot_gen_out_z
- plot_gen_out_z_old
- plot_gen_stat
- read_plot_dump_proj
- show_output
- show_plots
- subfig_evo_el_bunching
- subfig_evo_el_energy
- subfig_evo_el_pos
- subfig_evo_el_size
- subfig_evo_rad_pow
- subfig_evo_rad_pow_en
- subfig_evo_rad_pow_sz
- subfig_evo_rad_spec
- subfig_evo_rad_spec_sz
- subfig_evo_und
- subfig_evo_und_quad
- subfig_rad_size
- subfig_z_energy_espread
- subfig_z_energy_espread_bunching
- subfig_z_phase
- subfig_z_power_curr
- subfig_z_spec
- ParetoPlot
- init_plots
- plot_geometry
- plot_rays
- if_plottable
- save_figure
- save_show
- D1
- D3
- plot3D_data
- show_flux
- plot_lattice
- plot_opt_func
- show_da
- show_density
- show_e_beam
- show_flux
- show_mu
- ocelot.lib package
- ocelot.optics package
- Subpackages
- Submodules
- ocelot.optics.bragg module
- ocelot.optics.elements module
- ocelot.optics.parse_xop module
- ocelot.optics.ray module
- ocelot.optics.utils module
- ocelot.optics.wave module
- Module contents
- CrystalCell
- CrystalLattice
- CrystalStructureFactors
- D0_Dh
- Element
- F_hkl
- MP
- StructureFactorFactory
- calc_angle
- eta
- f_scat
- find_bragg
- get_crystal_filter
- load_stucture_factors
- plot_bragg_reflections
- plot_scattering_factors
- save_stucture_factors
- transmissivity_reflectivity
- unfold_angles
- xij
- Aperture
- Crystal
- Detector
- EllipticMirror
- Filter_freq
- Geometry
- Grating
- Lense
- Material
- Mirror
- OptDrift
- OptElement
- ParabolicMirror
- debug
- info
- warn
- Ray
- find_intersections
- refl_matrix
- trace
- Signal
- Signal3D
- plot_filters
- plot_signal
- plot_signal_spec
- plot_spec_filt
- read_signal
- HeightProfile
- RadiationField
- Spectrogram
- StokesParameters
- TransferFunction
- WaistScanResults
- WignerDistribution
- average_stokes_l
- bin_stokes
- calc_ph_sp_dens
- calc_phase_delay
- calc_phase_delay_poly
- calc_stokes
- calc_stokes_dfl
- calc_stokes_out
- calc_wigner
- dfl_ap
- dfl_ap_circ
- dfl_ap_rect
- dfl_chirp_freq
- dfl_cut_z
- dfl_disperse
- dfl_fft_xy
- dfl_fft_z
- dfl_interp
- dfl_pad_z
- dfl_prop
- dfl_reflect_surface
- dfl_shift_z
- dfl_trf
- dfl_waistscan
- dfldomain_check
- generate_1d_profile
- generate_dfl
- generate_gaussian_dfl
- imitate_1d_sase
- imitate_1d_sase_like
- imitate_sase_dfl
- save_trf
- screen2dfl
- sum_stokes_tr
- trf_mult
- trf_mult_mix
- wigner_dfl
- wigner_out
- wigner_pad
- wigner_smear
- wigner_stat
- ocelot.rad package
- Submodules
- ocelot.rad.bmrad module
- ocelot.rad.fel module
- ocelot.rad.fel_estimator module
- ocelot.rad.optics_elements module
- ocelot.rad.optics_line module
- ocelot.rad.propagation module
- ocelot.rad.radiation_py module
- ocelot.rad.screen module
- ocelot.rad.spline_py module
- ocelot.rad.transfer_function module
- ocelot.rad.undulator_params module
- Module contents
- beta
- binomial
- bm_e
- bm_e0
- bm_e_a
- chisquare
- choice
- dirichlet
- exponential
- f
- gamma
- geometric
- get_state
- gumbel
- hypergeometric
- laplace
- logistic
- lognormal
- logseries
- multinomial
- multivariate_normal
- negative_binomial
- noncentral_chisquare
- noncentral_f
- normal
- pareto
- permutation
- poisson
- power
- rand
- randint
- randn
- random
- random_integers
- random_sample
- rayleigh
- seed
- set_state
- shuffle
- standard_cauchy
- standard_exponential
- standard_gamma
- standard_normal
- standard_t
- triangular
- uniform
- vonmises
- wald
- weibull
- zipf
- FelParameters
- FelParametersArray
- beam2fel
- calculateFelParameters
- printFelParameters
- beamlat2fel
- parraylat2fel
- Aperture
- ApertureEllips
- ApertureRect
- FreeSpace
- HeightErrorProfile
- Mirror
- OpticsElement
- OpticsMarker
- ThinLens
- OpticsLine
- flatten
- combine_elements
- estimate_masks
- propagate
- BeamTraject
- Motion
- bspline
- calculate_radiation
- coherent_radiation
- energy_loss_und
- field_map2field_func
- gintegrator
- gintegrator_over_traj
- gintegrator_over_traj_py
- integ_beta2
- normal
- quantum_diffusion
- radiation_py
- sigma_gamma_quat
- track4rad_beam
- traj2motion
- und_field
- und_field_py
- wrap_gintegrator
- x2xgaus
- Py2C
- Screen
- sum_screens
- cinterp
- cspline_coef
- derivat
- moment
- DriftMask
- LensMask
- Mask
- RectMask
- get_transfer_function
- Ephoton2K
- Ephoton2field
- ID_radiation
- K2Ephoton
- K2Lambda
- K2field
- UndulatorParameters
- eV2lambda
- field2Ephoton
- field2K
- lambda2Ebeam
- lambda2eV
- print_rad_props
- Ephoton2K
- Ephoton2field
- K2Ephoton
- K2Lambda
- K2field
- Screen
- calculate_radiation
- coherent_radiation
- eV2lambda
- field2Ephoton
- field2K
- lambda2Ebeam
- lambda2eV
- print_rad_props
- print_rad_props
- sigma_gamma_quat
- ocelot.utils package
- Submodules
- ocelot.utils.acc_utils module
- ocelot.utils.add_wake module
- ocelot.utils.create_db module
- ocelot.utils.db module
- ocelot.utils.launcher module
- ocelot.utils.mpi_utils module
- ocelot.utils.section_track module
- ocelot.utils.sim_gui module
- ocelot.utils.sim_info module
- ocelot.utils.sim_plot module
- ocelot.utils.wake_pws module
- ocelot.utils.xfel_utils module
- Module contents
- RTU_56
- beam2rf
- beam2rf_xfel_linac
- bunching
- calculate_mismatch
- chicane_RTU
- rf2beam
- rf2beam_xfel_linac
- slice_bunching
- ActionParameters
- ActionResult
- PerfDB
- Tuning
- create_db
- test_add_action_parameters
- test_new_action
- test_new_tunings
- Launcher
- LocalLauncher
- MpiLauncher
- NewLauncher
- PollableMpiLauncher
- SshMpiLauncher
- createId
- chunks
- slicing_p_array
- SectionLattice
- SectionTrack
- normal
- RunInfo
- SimInfo
- wake_kick
- wake_tables
- FelSimulator
- checkout_run
- create_exfel_lattice
- create_fel_beamline
- create_fel_lattice
- create_fel_lattice_tmp
- detune_E
- detune_k
- dfl_hxrss_filt
- dfl_st_cpl
- get_data_dir
- prepare_el_optics
- rematch
- rematch_beam_lat
- save_xhrss_dump_proj
- tap_exp
- tap_pol
- tap_pol_old
- taper
- update_beam
- chicane_RTU
Module contents¶
general ocelot description
-
class
ocelot.
Aperture
(xmax=inf, ymax=inf, dx=0, dy=0, type='rect', eid=None)¶ Bases:
ocelot.cpbd.elements.Element
xmax - half size in horizontal plane in [m], ymax - half size in vertical plane in [m], type - “rect” or “elliptical”.
-
class
ocelot.
Beam
(x=0, xp=0, y=0, yp=0)¶ Bases:
object
-
property
dg
¶
-
property
emit_xn
¶
-
property
emit_yn
¶
-
property
g
¶
-
len
()¶
-
property
p
¶
-
properties
= ['g', 'dg', 'emit_xn', 'emit_yn', 'p', 'pz', 'px', 'py']¶
-
property
px
¶
-
property
py
¶
-
property
pz
¶
-
sizes
()¶
-
to_array
(nslice=100, window_len=None)¶
-
property
-
class
ocelot.
BeamTransform
(tws=None, x_opt=None, y_opt=None)¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
Beam matching
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
property
twiss
¶
-
-
class
ocelot.
Bend
(l=0.0, angle=0.0, k1=0.0, k2=0.0, e1=0.0, e2=0.0, tilt=0.0, gap=0.0, h_pole1=0.0, h_pole2=0.0, fint=0.0, fintx=None, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
bending magnet l - length of magnet in [m], angle - angle of bend in [rad], k1 - strength of quadrupole lens in [1/m^2], k2 - strength of sextupole lens in [1/m^3], tilt - tilt of lens in [rad], e1 - the angle of inclination of the entrance face [rad], e2 - the angle of inclination of the exit face [rad]. fint - fringe field integral fintx - allows (fintx > 0) to set fint at the element exit different from its entry value. gap - the magnet gap [m], NOTE in MAD and ELEGANT: HGAP = gap/2 h_pole1 - the curvature (1/r) of the entrance face h_pole1 - the curvature (1/r) of the exit face
-
class
ocelot.
CSR
¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
coherent synchrotron radiation Attributes:
self.step = 1 [in Navigator.unit_step] - step of the CSR kick applying for beam (ParticleArray) self.sigma_min = 1.e-4 - minimal sigma if gauss filtering applied self.traj_step = 0.0002 [m] - trajectory step or, other words, integration step for calculation of the CSR-wake self.apply_step = 0.0005 [m] - step of the calculation CSR kick, to calculate average CSR kick
-
CSR_K1
(i, traj, NdW, gamma=None)¶ - Parameters
i – index of the trajectories points for the convolution kernel is calculated;
traj – trajectory. traj[0,:] - longitudinal coordinate, traj[1,:], traj[2,:], traj[3,:] - rectangular coordinates, traj[4,:], traj[5,:], traj[6,:] - tangential unit vectors
NdW – list [N, dW], NdW[0] is number of mesh points, NdW[1] = dW > 0 is increment. Mesh = Mesh = (-N:0) * dW
gamma –
- Returns
-
K0_fin_inf
(i, traj, w_range, gamma)¶ Radiative interaction is coming from the infinite straight line that is assumed before the specified CSR region and it is calculated analytically
- Parameters
i –
traj –
w_range –
gamma –
- Returns
-
K0_inf_anf
(i, traj, wmin)¶ - Parameters
i – index of the trajectories points for the convolution kernel is calculated;
traj – trajectory. traj[0,:] - longitudinal coordinate, traj[1,:], traj[2,:], traj[3,:] - rectangular coordinates, traj[4,:], traj[5,:], traj[6,:] - tangential unit vectors
wmin – the first coordinate of the mash
- Returns
-
K0_inf_inf
(i, traj, w_range)¶ Radiative interaction is coming from the infinite straight line that is assumed before the specified CSR region and it is calculated analytically
- Parameters
i –
traj –
w_range –
- Returns
-
apply
(p_array, delta_s)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
finalize
(*args, **kwargs)¶ the method is called at the end of tracking
- Returns
-
plot_wake
(p_array, lam_K1, itr_ra, s1, st)¶ Method to plot CSR wakes on each step and save pictures in the working folder. Might be time-consuming.
- Parameters
p_array –
lam_K1 –
itr_ra –
s1 –
st –
- Returns
-
prepare
(lat)¶ calculation of trajectory in rectangular coordinates calculation of the z_csr_start :param lat: Magnetic Lattice :return: self.csr_traj: trajectory. traj[0,:] - longitudinal coordinate,
traj[1,:], traj[2,:], traj[3,:] - rectangular coordinates, traj[4,:], traj[5,:], traj[6,:] - tangential unit vectors
-
-
class
ocelot.
Cavity
(l=0.0, v=0.0, phi=0.0, freq=0.0, vx_up=0, vy_up=0, vxx_up=0, vxy_up=0, vx_down=0, vy_down=0, vxx_down=0, vxy_down=0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
Standing wave RF cavity v - voltage [GV] freq - frequency [Hz] phi - phase in [deg] vx_{up/down}, vy_{up/down} - zero order kick of a {up/down}stream coupler vxx_{up/down}, vxy_{up/down} - first order kick a {up/down}stream coupler
-
class
ocelot.
CavityTM
(v=0, freq=0.0, phi=0.0)¶ Bases:
ocelot.cpbd.optics.TransferMap
-
map4cav
(X, E, V, freq, phi, z=0)¶
-
-
class
ocelot.
Drift
(l=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
drift - free space l - length of drift in [m]
-
class
ocelot.
EbeamParams
(lattice, tws0, coupling=0.01, nsuperperiod=1)¶ Bases:
object
-
integrals_id
()¶
-
-
class
ocelot.
Edge
(l=0.0, angle=0.0, k1=0.0, edge=0.0, tilt=0.0, dtilt=0.0, dx=0.0, dy=0.0, h_pole=0.0, gap=0.0, fint=0.0, pos=1, eid=None)¶ Bases:
ocelot.cpbd.elements.Bend
-
class
ocelot.
Element
(eid=None)¶ Bases:
object
Element is a basic beamline building element Accelerator optics elements are subclasses of Element Arbitrary set of additional parameters can be attached if necessary
-
class
ocelot.
EmptyProc
(step=1)¶
-
class
ocelot.
Hcor
(l=0.0, angle=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.RBend
horizontal corrector, l - length of magnet in [m], angle - angle of bend in [rad],
-
class
ocelot.
KickTM
(angle=0.0, k1=0.0, k2=0.0, k3=0.0, nkick=1)¶ Bases:
ocelot.cpbd.optics.TransferMap
-
kick
(X, l, angle, k1, k2, k3, energy, nkick=1)¶ does not work for dipole
-
kick_apply
(X, l, angle, k1, k2, k3, energy, nkick, dx, dy, tilt)¶
-
-
class
ocelot.
LSC
(step=1)¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
Longitudinal Space Charge smooth_param - 0.1 smoothing parameter, resolution = np.std(p_array.tau())*smooth_param
-
apply
(p_array, dz)¶ wakes in V/pC
- Parameters
p_array –
dz –
- Returns
-
imp_lsc
(gamma, sigma, w, dz)¶ gamma - energy sigma - transverse RMS size of the beam w - omega = 2*pi*f
-
imp_step_lsc
(gamma, rb, w, dz)¶ longitudinal space-charge impedance in case of a stepped profile bunch
gamma - energy rb - transverse radius of the beam w - omega = 2*pi*f
-
impedance2wake
(f, y)¶ Fourier transform with exp(-iwt) f - Hz y - Om s - Meter w - V/C
-
wake2impedance
(s, w)¶ Fourier transform with exp(iwt) s - Meter w - V/C f - Hz y - Om
-
wake_lsc
(s, bunch, gamma, sigma, dz)¶
-
-
class
ocelot.
LaserHeater
(step=1)¶
-
class
ocelot.
LaserModulator
(step=1)¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
lambda_ph
(energy)¶ Wavelength of the laser pulse
- Parameters
energy – in [GeV] - beam energy
- Returns
wavelength in [m]
-
r56
(energy)¶ Method calculate R56 of the undulator
- Parameters
energy – in [GeV] - beam energy
- Returns
R56 in [m]
-
-
class
ocelot.
MagneticLattice
(sequence, start=None, stop=None, method=<ocelot.cpbd.optics.MethodTM object>)¶ Bases:
object
sequence - list of the elements, start - first element of lattice. If None, then lattice starts from first element of sequence, stop - last element of lattice. If None, then lattice stops by last element of sequence, method = MethodTM() - method of the tracking.
-
find_indices
(element)¶
-
get_sequence_part
(start, stop)¶
-
update_endings
(lat_index, element, body_elements, element_util)¶
-
update_transfer_maps
()¶
-
-
class
ocelot.
Marker
(eid=None)¶ Bases:
ocelot.cpbd.elements.Element
-
class
ocelot.
Matrix
(l=0.0, delta_e=0, eid=None, **kwargs)¶ Bases:
ocelot.cpbd.elements.Element
Matrix element
l = 0 - m, length of the matrix element r = np.zeros((6, 6)) - R - elements, first order t = np.zeros((6, 6, 6)) - T - elements, second order delta_e = 0 - GeV, energy gain along the matrix element
-
class
ocelot.
MethodTM
(params=None)¶ Bases:
object
The class creates a transfer map for elements that depend on user-defined parameters (“parameters”). By default, the parameters = {“global”: TransferMap}, which means that all elements will have linear transfer maps. You can also specify different transfer maps for any type of element.
# use linear matrices for all elements except Sextupole which will have nonlinear kick map (KickTM) method = MethodTM() method.global_method = TransferMap method.params[Sextupole] = KickTM
# All elements are assigned matrices of the second order. # For elements for which there are no matrices of the second order are assigned default matrices, e.g. linear matrices. method2 = MethodTM() method2.global_method = SecondTM
-
create_tm
(element)¶
-
set_tm
(element, method)¶
-
-
class
ocelot.
Monitor
(l=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
-
class
ocelot.
Multipole
(kn=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
kn - list of strengths
Bases:
object
Navigator defines step (dz) of tracking and which physical process will be applied during each step. lattice - MagneticLattice Attributes:
unit_step = 1 [m] - unit step for all physics processes
- Methods:
- add_physics_proc(physics_proc, elem1, elem2)
physics_proc - physics process, can be CSR, SpaceCharge or Wake, elem1 and elem2 - first and last elements between which the physics process will be applied.
activate apertures if thea exist in the lattice from
- Parameters
start – element, activate apertures starting form element ‘start’ element
stop – element, activate apertures up to ‘stop’ element
- Returns
Method adds Physics Process.
- Parameters
physics_proc – PhysicsProc, e.g. SpaceCharge, CSR, Wake …
elem1 – the element in the lattice where to start applying the physical process.
elem2 – the element in the lattice where to stop applying the physical process, can be the same as starting element.
- Returns
method return list of all physics processes which were added
- Returns
list, list of PhysProc(s)
in case physics processes are applied and do not more needed they are removed from table
- Parameters
processes – list of processes are about to apply
- Returns
None
method to reset Navigator position. :return:
-
class
ocelot.
Octupole
(l=0.0, k3=0.0, tilt=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
octupole k3 - strength of octupole lens in [1/m^4], l - length of lens in [m].
-
class
ocelot.
Particle
(x=0.0, y=0.0, px=0.0, py=0.0, s=0.0, p=0.0, tau=0.0, E=0.0, q=0.0)¶ Bases:
object
particle to be used for tracking
-
class
ocelot.
ParticleArray
(n=0)¶ Bases:
object
array of particles of fixed size; for optimized performance (x, x’ = px/p0),(y, y’ = py/p0),(ds = c*tau, p = dE/(p0*c)) p0 - momentum
-
class
LostParticleRecorder
(n)¶ Bases:
object
Stores information about particles that are getting lost.
- Attributes:
lost_particles: List of indices of deleted particle. Notes: The indices of the initial ParticleArray are used. lp_to_pos_hist: Histogram of number of lost particles to position s. [(pos, num of lost particles), …]
-
add
(inds, position)¶
-
array2ex_list
(p_list)¶
-
array2list
()¶
-
delete_particles
(inds, record=True)¶ Deletes particles from the particle array via index. :param inds: Indices that will be removed from the particle array. :param record: If record is true the deleted particles will be saved in self.lost_particle_recorder. :return:
-
list2array
(p_list)¶
-
property
n
¶
-
p
()¶
-
px
()¶
-
py
()¶
-
rescale2energy
(energy)¶ Method to rescale beam coordinates with new energy
- Parameters
energy – new energy
- Returns
-
rm_particle
(index)¶ Method removes a “bad” particle with particular “index”. :param index: :return:
-
rm_tails
(xlim, ylim, px_lim, py_lim)¶ Method removes particles outside range [-xlim, +xlim], [-px_lim, +px_lim] …
-
size
()¶
-
property
t
¶
-
tau
()¶
-
thin_out
(nth=10, n0=0)¶ Method to thin out the particle array in n-th times. Means every n-th particle will be saved in new Particle array
- Parameters
nth – 10, every n-th particle will be taken to new Particle array
n0 – start from n0 particle
- Returns
New ParticleArray
-
x
()¶
-
y
()¶
-
class
-
class
ocelot.
PhaseSpaceAperture
(step=1)¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
Method to cut beam in longitudinal (by default), horizontal or/and vertical direction
- Parameters
longitudinal – True, cutting in longitudinal direction
vertical – False, cutting in vertical direction
horizontal – False, cutting in horizontal direction
taumin – -5 longitudinal plane in [rms] from center of mass
taumax – 5 longitudinal plane in [rms] from center of mass
xmin – -5 horizontal plane in [rms] from center of mass
xmax – 5 horizontal plane in [rms] from center of mass
ymin – -5 vertical plane in [rms] from center of mass
ymax – 5 vertical plane in [rms] from center of mass
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
class
ocelot.
PhysProc
(step=1)¶ Bases:
object
Parent class for all Physics processes
- Method prepare(self, lat)
the method is called at the moment of Physics Process addition to Navigator class.
- Method apply(self, p_array, dz)
the method is called on every step.
- Attribute step
number of steps in [Navigator.unit_step] self.step*Navigator.unit_step = [m]
- Attribute indx0
number of start element in lattice.sequence - assigned in navigator.add_physics_proc()
- Attribute indx1
number of stop element in lattice.sequence - assigned in navigator.add_physics_proc()
- Attribute s_start
position of start element in lattice - assigned in navigator.add_physics_proc()
- Attribute s_stop
position of stop element in lattice.sequence - assigned in navigator.add_physics_proc()
- Attribute z0
current position of navigator - assigned in track.track() before p.apply()
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
finalize
(*args, **kwargs)¶ the method is called at the end of tracking
- Returns
-
prepare
(lat)¶ method is called at the moment of Physics Process addition to Navigator class.
- Parameters
lat –
- Returns
-
class
ocelot.
Quadrupole
(l=0.0, k1=0, k2=0.0, tilt=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
quadrupole l - length of lens in [m], k1 - strength of quadrupole lens in [1/m^2], k2 - strength of sextupole lens in [1/m^3], tilt - tilt of lens in [rad].
-
class
ocelot.
RBend
(l=0.0, angle=0.0, k1=0.0, k2=0.0, e1=None, e2=None, tilt=0.0, gap=0, h_pole1=0.0, h_pole2=0.0, fint=0.0, fintx=None, eid=None)¶ Bases:
ocelot.cpbd.elements.Bend
rectangular bending magnet, l - length of magnet in [m], angle - angle of bend in [rad], k1 - strength of quadrupole lens in [1/m^2], k2 - strength of sextupole lens in [1/m^3], tilt - tilt of lens in [rad], e1 - the angle of inclination of the entrance face [rad], e2 - the angle of inclination of the exit face [rad]. fint - fringe field integral fintx - allows (fintx > 0) to set fint at the element exit different from its entry value. gap - the magnet gap [m], NOTE in MAD and ELEGANT: HGAP = gap/2 h_pole1 - the curvature (1/r) of the entrance face h_pole1 - the curvature (1/r) of the exit face
-
class
ocelot.
SBend
(l=0.0, angle=0.0, k1=0.0, k2=0.0, e1=0.0, e2=0.0, tilt=0.0, gap=0, h_pole1=0.0, h_pole2=0.0, fint=0.0, fintx=None, eid=None)¶ Bases:
ocelot.cpbd.elements.Bend
sector bending magnet, l - length of magnet in [m], angle - angle of bend in [rad], k1 - strength of quadrupole lens in [1/m^2], k2 - strength of sextupole lens in [1/m^3], tilt - tilt of lens in [rad], e1 - the angle of inclination of the entrance face [rad], e2 - the angle of inclination of the exit face [rad]. fint - fringe field integral fintx - allows (fintx > 0) to set fint at the element exit different from its entry value. gap - the magnet gap [m], NOTE in MAD and ELEGANT: HGAP = gap/2 h_pole1 - the curvature (1/r) of the entrance face h_pole1 - the curvature (1/r) of the exit face
-
class
ocelot.
SecondTM
(r_z_no_tilt, t_mat_z_e)¶ Bases:
ocelot.cpbd.optics.TransferMap
-
t_apply
(R, T, X, dx, dy, tilt, U5666=0.0)¶
-
-
class
ocelot.
Sequence
(l=0, refer=0)¶ Bases:
object
-
class
ocelot.
Sextupole
(l=0.0, k2=0.0, tilt=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
sextupole l - length of lens in [m], k2 - strength of sextupole lens in [1/m^3].
-
class
ocelot.
SmoothBeam
¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
Physics Process for the beam smoothing. Can be applied when number of particles is not enough.
- Attribute mslice
number of particles in the slice
# lat is the MagneticLattice navi = Navigator(lat)
smooth = SmoothBeam() smooth.mslice = 10000
navi.add_physics_process(smooth, start=elem, stop=elem) # elem is the lattice element where you want to apply smoothing
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
class
ocelot.
Solenoid
(l=0.0, k=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
l - length in m, k - strength B0/(2B*rho)
-
class
ocelot.
SpaceCharge
(step=1)¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
Space Charge physics process
- Attributes:
self.step = 1 [in Navigator.unit_step] - step of the Space Charge kick applying self.nmesh_xyz = [63, 63, 63] - 3D mesh
- Description:
The space charge forces are calculated by solving the Poisson equation in the bunch frame.
Then the Lorentz transformed electromagnetic field is applied as a kick in the laboratory frame. For the solution of the Poisson equation we use an integral representation of the electrostatic potential by convolution of the free-space Green’s function with the charge distribution. The convolution equation is solved with the help of the Fast Fourier Transform (FFT). The same algorithm for solution of the 3D Poisson equation is used, for example, in ASTRA
-
apply
(p_array, zstep)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
el_field
(X, Q, gamma, nxyz)¶
-
potential
(q, steps)¶
-
prepare
(lat)¶ method is called at the moment of Physics Process addition to Navigator class.
- Parameters
lat –
- Returns
-
sym_kernel
(ijk2, hxyz)¶
-
class
ocelot.
SpontanRadEffects
(K=0.0, lperiod=0.0, type='planar')¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
Effects of the spontaneous radiation: energy loss and quantum diffusion
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
energy_loss_und
(energy, dz)¶
-
sigma_gamma_quant
(energy, dz)¶ rate of energy diffusion
- Parameters
energy – electron beam energy
Kx – undulator parameter
lperiod – undulator period
dz – length of the
- Returns
sigma_gamma/gamma
-
-
class
ocelot.
TDCavity
(l=0.0, freq=0.0, phi=0.0, v=0.0, tilt=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
Transverse deflecting cavity - by default kick in horizontal plane
l - length [m] v - voltage [GV/m] freq - frequency [Hz] phi - phase in [deg] tilt - tilt of cavity in [rad]
-
class
ocelot.
TransferMap
¶ Bases:
object
TransferMap is a basic linear transfer map for all elements.
-
apply
(prcl_series)¶ - Parameters
prcl_series – can be list of Particles [Particle_1, Particle_2, … ] or ParticleArray
- Returns
None
-
map_x_twiss
(tws0)¶
-
mul_p_array
(rparticles, energy=0.0)¶
-
-
class
ocelot.
Twiss
(beam=None)¶ Bases:
object
class - container for twiss parameters
-
class
ocelot.
Undulator
(lperiod=0.0, nperiods=0, Kx=0.0, Ky=0.0, field_file=None, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
lperiod - undulator period in [m];
nperiod - number of periods;
Kx - undulator paramenter for vertical field;
Ky - undulator parameter for horizantal field;
field_file - absolute path to magnetic field data;
mag_field - None by default, the magnetic field map function - (Bx, By, Bz) = f(x, y, z) eid - id of undulator.
-
validate
()¶
-
-
class
ocelot.
UndulatorTestTM
(lperiod, Kx, ax=0, ndiv=10)¶ Bases:
ocelot.cpbd.optics.TransferMap
-
map4undulator
(u, z, lperiod, Kx, ax, energy, ndiv)¶
-
-
class
ocelot.
UnknownElement
(l=0, kick=0, xsize=0, ysize=0, volt=0, lag=0, harmon=0, refer=0, vkick=0, hkick=0, eid=None)¶ Bases:
ocelot.cpbd.elements.Element
l - length of lens in [m]
-
class
ocelot.
Vcor
(l=0.0, angle=0.0, eid=None)¶ Bases:
ocelot.cpbd.elements.RBend
horizontal corrector, l - length of magnet in [m], angle - angle of bend in [rad],
-
class
ocelot.
Wake
(step=1)¶ Bases:
ocelot.cpbd.physics_proc.PhysProc
The wake field impact on the beam is included as series of kicks. In order to take into account the impact of the wake field on the beam the longitudinal wake function of point charge through the second order Taylor expansion is used. In general case it uses 13 one-dimensional functions to represent the longitudinal component of the wake function for arbitrary sets of the source and the wittness particles near to the reference axis.
- w_sampling = 500 - defines the number of the equidistant sampling points for the one-dimensional
wake coefficients in the Taylor expansion of the 3D wake function.
filter_order = 20 - smoothing filter order wake_table = None - wake table [WakeTable()] factor = 1. - scaling coefficient TH - list from WakeTable, (T, H): T- table of wakes coefs, H - matrix of the coefs place in T
-
add_total_wake
(X, Y, Z, q, TH, Ns, NF)¶
-
add_wake
(I, T)¶ [x, W] = AddWake(I, T) :param I: wake table in V/C, W in V (R, L, Cinv, nm, W0, N0, W1, N1) :param T: wake table in V/C, W in V :return:
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
convolution
(xu, u, xw, w)¶
-
get_long_wake
(current_profile)¶ method to extract a longitudinal wake from the Table for specific current profile
- Parameters
current_profile – 2D array with shape (n, 2) where first column is position and second is a beam current
- Returns
wake
-
prepare
(lat)¶ method is called at the moment of Physics Process addition to Navigator class.
- Parameters
lat –
- Returns
-
wake_convolution
(xb, bunch, xw, wake)¶
-
class
ocelot.
WakeKick
(factor=1)¶ Bases:
ocelot.cpbd.wake3D.Wake
-
apply
(p_array, dz)¶ the method is called on every step.
- Parameters
p_array –
dz –
- Returns
-
-
class
ocelot.
WakeTable
(wake_file=None)¶ Bases:
object
WakeTable(wake_file) - load and prepare wake table wake_file - path to the wake table
-
load_table
(wake_file)¶
-
process_wake_table
(wake_table)¶ - Parameters
wake_file – file name
- Returns
(T, H): T- table of wakes coefs, H - matrix of the coefs place in T
-
read_file
(wake_file)¶
-
-
class
ocelot.
WakeTableDechirperOffAxis
(b=0.0005, a=0.01, width=0.02, t=0.00025, p=0.0005, length=1, sigma=3e-05, orient='horz')¶ Bases:
ocelot.cpbd.wake3D.WakeTable
WakeTableDechirperOffAxis() - creates two wake tables for horizontal and vertical corrugated plates. Based on https://doi.org/10.1016/j.nima.2016.09.001 and SLAC-PUB-16881
- Parameters
b – distance from the plate in [m]
a – half gap between plates in [m]
width – width of the corrugated structure in [m]
t – longitudinal gap in [m]
p – period of corrugation in [m]
length – length of the corrugated structure in [m]
sigma – characteristic (rms) longitudinal beam size in [m]
orient – “horz” or “vert” plate orientation
- Returns
hor_wake_table, vert_wake_table
-
calculate_wake_tables
(b, a, width, t, p, length, sigma)¶ Function creates two wake tables for horizontal and vertical corrugated plates
- Parameters
b – distance from the plate in [m]
a – half gap between plates in [m]
width – width of the corrugated structure in [m]
t – longitudinal gap in [m]
p – period of corrugation in [m]
length – length of the corrugated structure in [m]
sigma – characteristic longitudinal beam size in [m]]
filename – save to files if filename is not None
- Returns
hor_wake_table, vert_wake_table
-
ocelot.
compensate_chromaticity
(lattice, ksi_x_comp=0, ksi_y_comp=0, nsuperperiod=1)¶ old chromaticity compensation with 2 sextupole families
-
ocelot.
contour_da
(track_list, nturns, lvl=0.9)¶ the function defines contour of DA. If particle “lived” > lvl*nturns then we set up nturns if particle “lived” < lvl*nturns then we set up 0
-
ocelot.
create_track_list
(x_array, y_array, p_array, energy=0.0)¶ the function create list of Pxy
-
ocelot.
ellipse_from_twiss
(emit, beta, alpha)¶
-
ocelot.
fodo_parameters
(betaXmean=36.0, L=10.0, verbose=False)¶
-
ocelot.
freq_analysis
(track_list, lat, nturns, harm=True, diap=0.1, nearest=False, nsuperperiods=1)¶
-
ocelot.
gauss_from_twiss
(emit, beta, alpha)¶
-
ocelot.
generate_parray
(sigma_x=0.0001, sigma_px=2e-05, sigma_y=None, sigma_py=None, sigma_tau=0.001, sigma_p=0.0001, chirp=0.01, charge=5e-09, nparticles=200000, energy=0.13, tau_trunc=None, tws=None)¶ Method to generate ParticleArray with gaussian distribution.
- Note: in ParticleArray, {x, px} and {y, py} are canonical coordinates. {tau, p} is not, to make it canonical
the sign of “tau” should be flipped.
- Parameters
sigma_x – std(x), x is horizontal cartesian coordinate.
sigma_px – std(px), ‘px’ is conjugate momentum canonical momentum px/p0.
sigma_y – std(y), y is vertical cartesian coordinate.
sigma_py – std(py), ‘py’ is canonical momentum py/p0.
sigma_tau – std(tau), “tau” = c*t
sigma_p – std(p), ‘p’ is canonical momentum E/(c*p0)
chirp – energy chirp [unitless], linear correlation - p_i += chirp * tau_i/sigma_tau
charge – beam charge in [C], 5e-9 by default
nparticles – namber of particles, 200k by default
energy – beam energy in [GeV], 0.13 [GeV]
tau_trunc – None, if not [float] - truncated gauss distribution in “tau” direction.
tws – None, if Twiss obj - the beam is matched to twiss params.
- Returns
ParticleArray
-
ocelot.
get_current
(p_array, num_bins=200, **kwargs)¶ Function calculates beam current from particleArray.
- Parameters
p_array – particleArray
charge –
None, OBSOLETE, charge of the one macro-particle.
If None, charge of the first macro-particle is used
num_bins – number of bins
:return s, I - (np.array, np.array) - beam positions [m] and currents in [A]
-
ocelot.
get_envelope
(p_array, tws_i=<ocelot.cpbd.beam.Twiss object>, bounds=None)¶ Function to calculate twiss parameters form the ParticleArray
- Parameters
p_array – ParticleArray
tws_i – optional, design Twiss,
bounds – optional, [left_bound, right_bound] - bounds in units of std(p_array.tau())
- Returns
Twiss()
-
ocelot.
get_map
(lattice, dz, navi)¶
-
ocelot.
global_slice_analysis
(parray, nparts_in_slice=5000, smooth_param=0.01, filter_base=2, filter_iter=2)¶ Function to calculate slice parameters
- Parameters
parray – ParticleArray
nparts_in_slice – 5000, nparticles in the slice
smooth_param – 0.01, smoothing parameters to calculate the beam current: smooth_param = m_std * np.std(p_array.tau())
filter_base – 2, filter parameter in the func: simple_filter
filter_iter – 2, filter parameter in the func: simple_filter
- Returns
SliceParameters,
-
ocelot.
lattice_transfer_map
(lattice, energy)¶ Function calculates transfer maps, the first and second orders (R, T), for the whole lattice. Second order matrices are attached to lattice object: lattice.T_sym - symmetric second order matrix lattice.T - second order matrix lattice.R - linear R matrix
- Parameters
lattice – MagneticLattice
energy – the initial electron beam energy [GeV]
- Returns
R - matrix
-
ocelot.
load_particle_array
(filename, print_params=False)¶ Universal function to load beam file, *.ast (ASTRA), *.fmt1 (CSRTrack) or *.npz format
Note that downloading ParticleArray from the astra file (.ast) and saving it back does not give the same distribution. The difference arises because the array of particles does not have a reference particle, and in this case the first particle is used as a reference.
- Parameters
filename – path to file, filename.ast or filename.npz
- Returns
ParticleArray
-
ocelot.
match
(lat, constr, vars, tw, verbose=True, max_iter=1000, method='simplex', weights=<function weights_default>, vary_bend_angle=False, min_i5=False)¶ Function to match twiss parameters
- Parameters
lat – MagneticLattice
constr –
dictionary, constrains. Example: ‘periodic’:True - means the “match” function tries to find periodic solution at the ends of lattice:
constr = {elem1:{‘beta_x’:15, ‘beta_y’:2}, ‘periodic’:True}
- ”hard” constrains on the end of elements (elem1, elem2):
constr = {elem1:{‘alpha_x’:5, ‘beta_y’:5}, elem2:{‘Dx’:0 ‘Dyp’:0, ‘alpha_x’:5, ‘beta_y’:5}}
- or mixture of “soft” and hard constrains:
constr = {elem1:{‘alpha_x’:[“>”, 5], ‘beta_y’:5}, elem2:{‘Dx’:0 ‘Dyp’:0, ‘alpha_x’:5, ‘beta_y’:[“>”, 5]}}
- in case one needs global control on beta function, the constrains can be written following way.
constr = {elem1:{‘alpha_x’:5, ‘beta_y’:5}, ‘global’: {‘beta_x’: [‘>’, 10]}}
vars – list of elements e.g. vars = [QF, QD] or it can be initial twiss parameters: vars = [[tws0, ‘beta_x’], [tws0, ‘beta_y’], [tws0, ‘alpha_x’], [tws0, ‘alpha_y’]]
tw – initial Twiss
verbose – allow print output of minimization procedure
max_iter –
method – string, available ‘simplex’, ‘cg’, ‘bfgs’
weights –
function returns weights, for example def weights_default(val):
if val == ‘periodic’: return 10000001.0 if val == ‘total_len’: return 10000001.0 if val in [‘Dx’, ‘Dy’, ‘Dxp’, ‘Dyp’]: return 10000002.0 if val in [‘alpha_x’, ‘alpha_y’]: return 100007.0 if val in [‘mux’, ‘muy’]: return 10000006.0 if val in [‘beta_x’, ‘beta_y’]: return 100007.0 return 0.0001
vary_bend_angle – False, allow to vary “angle” of the dipoles instead of the focusing strength “k1”
min_i5 – minimization of the radiation integral I5. Can be useful for storage rings.
- Returns
result
-
ocelot.
match_tunes
(lat, tw0, quads, nu_x, nu_y, ncells=1, print_proc=0)¶
-
ocelot.
merger
(lat, remaining_types=[], remaining_elems=[], init_energy=0.0)¶ Function to compress the lattice excluding elements by type or by individual elements
- Parameters
lat – MagneticLattice
remaining_types – list, the type of the elements which needed to be untouched others will be “compress” to Matrix element e.g. [Monitor, Quadrupole, Bend, Hcor]
remaining_elems – list of elements (ids (str) or object)
init_energy – initial energy
- Returns
New MagneticLattice
-
ocelot.
nearest_particle
(track_list, xi, yi)¶
-
ocelot.
save_particle_array
(filename, p_array)¶ Universal function to save beam file, *.ast (ASTRA), *.fmt1 (CSRTrack) or *.npz format
Note that downloading ParticleArray from the astra file (.ast) and saving it back does not give the same distribution. The difference arises because the array of particles does not have a reference particle, and in this case the first particle is used as a reference.
- Parameters
filename – path to file, filename.ast or filename.npz
- Returns
ParticleArray
-
ocelot.
spectrum
(data1D)¶ input: 1D sample data output: frequency and fourier transform
-
ocelot.
stable_particles
(track_list, nturns)¶
-
ocelot.
track
(lattice, p_array, navi, print_progress=True, calc_tws=True, bounds=None)¶ tracking through the lattice
- Parameters
lattice – Magnetic Lattice
p_array – ParticleArray
navi – Navigator
print_progress – True, print tracking progress
calc_tws – True, during the tracking twiss parameters are calculated from the beam distribution
bounds – None, optional, [left_bound, right_bound] - bounds in units of std(p_array.tau())
- Returns
twiss_list, ParticleArray. In case calc_tws=False, twiss_list is list of empty Twiss classes.
-
ocelot.
track_nturns
(lat, nturns, track_list, nsuperperiods=1, save_track=True, print_progress=True)¶
-
ocelot.
track_nturns_mpi
(mpi_comm, lat, nturns, track_list, errors=None, nsuperperiods=1, save_track=True)¶
-
ocelot.
tracking_step
(lat, particle_list, dz, navi)¶ tracking for a fixed step dz :param lat: Magnetic Lattice :param particle_list: ParticleArray or Particle list :param dz: step in [m] :param navi: Navigator :return: None
-
ocelot.
twiss
(lattice, tws0=None, nPoints=None)¶ twiss parameters calculation
- Parameters
lattice – lattice, MagneticLattice() object
tws0 – initial twiss parameters, Twiss() object. If None, try to find periodic solution.
nPoints – number of points per cell. If None, then twiss parameters are calculated at the end of each element.
- Returns
list of Twiss() objects
-
ocelot.
write_lattice
(lattice, tws0=None, file_name='lattice.py', remove_rep_drifts=True, power_supply=False)¶ saves lattice as python imput file lattice - MagneticLattice file_name - name of the file remove_rep_drifts - if True, remove the drifts with the same lengths from the lattice drifts definition