Bmad

Core Bmad particle accelerator simulation library.

Classes (Fortran Structures)

AcKickerFreqStruct

Fortran struct: ac_kicker_freq_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
f float
amp float
phi float

AcKickerStruct

Fortran struct: ac_kicker_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
amp_vs_time 1D array of AcKickerTimeStruct
frequency 1D array of AcKickerFreqStruct

AcKickerTimeStruct

Fortran struct: ac_kicker_time_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
amp float
time float
spline SplineStruct

AnormalModeStruct

Fortran struct: anormal_mode_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
emittance float Beam emittance (unnormalized). Includes vertical photon opening angle.
emittance_no_vert float Unnormalized beam emittance without the vertical photon opening angle taken into account.
synch_int 1D array of float (shape: 4:6) Synchrotron integrals
j_damp float damping partition number
alpha_damp float damping per turn
chrom float Chromaticity
tune float "Fractional" tune in radians

ApertureParamStruct

Fortran struct: aperture_param_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
min_angle float
max_angle float
n_angle int
n_turn int Number of turns a particle must survive.
x_init float Initial x coordinate to start with for theta_xy = 0.
y_init float Initial y coordinate to start with for theta_xy = pi/2.
rel_accuracy float Relative resolution of bracketed aperture.
abs_accuracy float Absolute resolution of bracketed aperture (meters).
start_ele str Element to start tracking at.

AperturePointStruct

Fortran struct: aperture_point_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x float (x,y) aperture point with respect to the reference orbit.
y float (x,y) aperture point with respect to the reference orbit.
plane int plane determining loss
ix_ele int ele index particle lost at
i_turn int turn particle lost at

ApertureScanStruct

Fortran struct: aperture_scan_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
point 1D array of AperturePointStruct Set of aperture points at different angles.
ref_orb CoordStruct Ref orbit around which the scan is made.
pz_start float Starting pz.

BeamInitStruct

Fortran struct: beam_init_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
position_file str File with particle positions.
distribution_type 1D array of str (shape: 3) distribution type (in x-px, y-py, and z-pz planes) "ELLIPSE", "KV", "GRID", "FILE", "RAN_GAUSS" or "" = "RAN_GAUSS"
spin 1D array of float (shape: 3) Spin (x, y, z)
ellipse 1D array of EllipseBeamInitStruct (shape: 3) Ellipse beam distribution
KV KvBeamInitStruct KV beam distribution
grid 1D array of GridBeamInitStruct (shape: 3) Grid beam distribution
center_jitter 1D array of float (shape: 6) Bunch center rms jitter
emit_jitter 1D array of float (shape: 2) a and b bunch emittance rms jitter normalized to emittance
sig_z_jitter float bunch length RMS jitter
sig_pz_jitter float RMS pz spread jitter
n_particle int Number of particles per bunch.
renorm_center bool Renormalize centroid?
renorm_sigma bool Renormalize sigma?
random_engine str Or 'quasi'. Random number engine to use.
random_gauss_converter str Or 'quick' or 'exact'. Uniform to gauss conversion method.
random_sigma_cutoff float Cut-off in sigmas.
a_norm_emit float a-mode normalized emittance (emit * beta * gamma)
b_norm_emit float b-mode normalized emittance (emit * beta * gamma)
a_emit float a-mode emittance
b_emit float b-mode emittance
dPz_dz float Correlation of Pz with long position.
center 1D array of float (shape: 6) Bench phase space center offset relative to reference.
t_offset float Time center offset
dt_bunch float Time between bunches.
sig_z float Z sigma in m.
sig_pz float pz sigma
bunch_charge float charge (Coul) in a bunch.
n_bunch int Number of bunches.
ix_turn int Turn index used to adjust particles time if needed.
species str "positron", etc. "" => use referece particle.
full_6D_coupling_calc bool Use V from 6x6 1-turn mat to match distribution? Else use 4x4 1-turn mat used.
use_particle_start bool Use lat%particle_start instead of beam_init%center, %t_offset, and %spin?
use_t_coords bool If true, the distributions will be taken as in t-coordinates
use_z_as_t bool Only used if use_t_coords = .true. If true, z describes the t distribution If false, z describes the s distribution
file_name str OLD!! DO NOT USE!!

BeamStruct

Fortran struct: beam_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
bunch 1D array of BunchStruct

BmadCommonStruct

Fortran struct: bmad_common_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
max_aperture_limit float Max Aperture.
d_orb 1D array of float (shape: 6) Orbit deltas for the mat6 via tracking calc.
default_ds_step float Default integration step for eles without an explicit step calc.
significant_length float meter
rel_tol_tracking float Closed orbit relative tolerance.
abs_tol_tracking float Closed orbit absolute tolerance.
rel_tol_adaptive_tracking float Runge-Kutta tracking relative tolerance.
abs_tol_adaptive_tracking float Runge-Kutta tracking absolute tolerance.
init_ds_adaptive_tracking float Initial step size
min_ds_adaptive_tracking float Min step size to take.
fatal_ds_adaptive_tracking float If actual step size is below this particle is lost.
autoscale_amp_abs_tol float Autoscale absolute amplitude tolerance (eV).
autoscale_amp_rel_tol float Autoscale relative amplitude tolerance
autoscale_phase_tol float Autoscale phase tolerance.
electric_dipole_moment float Particle's EDM. Call set_ptc to transfer value to PTC.
synch_rad_scale float Synch radiation kick scale. 1 => normal, 0 => no kicks.
sad_eps_scale float Used in sad_mult step length calc.
sad_amp_max float Used in sad_mult step length calc.
sad_n_div_max int Used in sad_mult step length calc.
taylor_order int Taylor order to use. 0 -> default = ptc_private%taylor_order_saved.
runge_kutta_order int Runge Kutta order.
default_integ_order int PTC integration order.
max_num_runge_kutta_step int Maximum number of RK steps before particle is considered lost.
rf_phase_below_transition_ref bool Autoscale uses below transition stable point for RFCavities?
sr_wakes_on bool Short range wakefields?
lr_wakes_on bool Long range wakefields
auto_bookkeeper bool Deprecated and no longer used.
high_energy_space_charge_on bool High energy space charge effect switch.
high_energy_space_charge_linear bool High energy space charge effect switch.
csr_and_space_charge_on bool Space charge switch.
spin_tracking_on bool spin tracking?
spin_sokolov_ternov_flipping_on bool Spin flipping during synchrotron radiation emission?
radiation_damping_on bool Radiation damping toggle.
radiation_zero_average bool Shift damping to be zero on the zero orbit to get rid of sawtooth?
radiation_fluctuations_on bool Radiation fluctuations toggle.
conserve_taylor_maps bool Enable bookkeeper to set ele%taylor_map_includes_offsets = F?
absolute_time_tracking bool Absolute or relative time tracking?
absolute_time_ref_shift bool Apply reference time shift when using absolute time tracking?
convert_to_kinetic_momentum bool Cancel kicks due to finite vector potential when doing symplectic tracking? Set to True to test symp_lie_bmad against runge_kutta.
normalize_twiss bool Normalize matrix when computing Twiss for off-energy ref?
aperture_limit_on bool Use apertures in tracking?
spin_n0_direction_user_set bool User sets direction of n0 for closed geometry branches?
debug bool Used for code debugging.

BmadNormalFormStruct

Fortran struct: bmad_normal_form_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ele_origin EleStruct Element at which the on-turn map was created.
M 1D array of TaylorStruct (shape: 6) One-turn taylor map: M = A o N o A_inv, N = exp(:h:)
A 1D array of TaylorStruct (shape: 6) Map from Floquet -> Lab coordinates
A_inv 1D array of TaylorStruct (shape: 6) Map from Lab -> Floquet coordinates
dhdj 1D array of TaylorStruct (shape: 6) Nonlinear tune function operating on Floquet coordinates
F 1D array of ComplexTaylorStruct (shape: 6) Vector field factorization in phasor basis:
L 1D array of ComplexTaylorStruct (shape: 6) L component
h 1D array of ResonanceHStruct

BookkeepingStateStruct

Fortran struct: bookkeeping_state_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
attributes int Element dependent attributes: super_ok\(, ok\) or stale$
control int Lord/slave bookkeeping status: super_ok\(, ok\) or stale$
floor_position int Global (floor) geometry: super_ok\(, ok\) or stale$
s_position int Longitudinal position & element length: super_ok\(, ok\) or stale$
ref_energy int Reference energy and ref time: super_ok\(, ok\) or stale$
mat6 int Linear transfer map status: super_ok\(, ok\) or stale$
rad_int int Radiation integrals cache status
ptc int Associated PTC fibre (or layout) status.
has_misalign bool Used to avoid unnecessary calls to offset_particle.

BpmPhaseCouplingStruct

Fortran struct: bpm_phase_coupling_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
K_22a float In-phase y/x for a-mode oscillations.
K_12a float Out-of-phase y/x for a-mode oscillations.
K_11b float In-phase x/y for b-mode oscillations.
K_12b float Out-of-phase x/y for b-mode oscillations.
Cbar22_a float Cbar22 as calculated from K_22a.
Cbar12_a float Cbar12 as calculated from K_12a.
Cbar11_b float Cbar11 as calculated from K_11b.
Cbar12_b float Cbar12 as calculated from K_12b.
phi_a float a-mode betatron phase.
phi_b float b-mode betatron phase.

BranchStruct

Fortran struct: branch_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str Name of line that defines the branch.
ix_branch int Index of this branch. 0 => Main branch
ix_from_branch int -1 => No creating fork element to this branch.
ix_from_ele int Index of creating fork element which forks to this branch.
ix_to_ele int Index of element in this branch that creating fork element forks to.
ix_fixer int Index of active fixer or beginning_ele element.
n_ele_track int
n_ele_max int
lat LatStruct
a ModeInfoStruct Note: Tunes are the fractional part.
b ModeInfoStruct Note: Tunes are the fractional part.
z ModeInfoStruct Note: Tunes are the fractional part.
ele 1D array of EleStruct
param LatParamStruct
particle_start CoordStruct
wall3d 1D array of Wall3dStruct

BunchParamsStruct

Fortran struct: bunch_params_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
centroid CoordStruct Lab frame
x TwissStruct Projected Twiss parameters
y TwissStruct Projected Twiss parameters
z TwissStruct Projected Twiss parameters
a TwissStruct Normal mode twiss parameters
b TwissStruct Normal mode twiss parameters
c TwissStruct Normal mode twiss parameters
sigma 2D array of float (shape: 6,6) beam size matrix
rel_max 1D array of float (shape: 7) Max orbit relative to centroid. 7 -> time.
rel_min 1D array of float (shape: 7) Min orbit relative to_centroid. 7 -> time.
s float Longitudinal position.
t float Time.
sigma_t float RMS of time spread.
charge_live float Charge of all non-lost particle
charge_tot float Charge of all particles.
n_particle_tot int Total number of particles
n_particle_live int Number of non-lost particles
n_particle_lost_in_ele int Number lost in element (not calculated by Bmad)
n_good_steps int Number of good steps (set when tracking with space charge)
n_bad_steps int Number of bad steps (set when tracking with space charge)
ix_ele int Lattice element where params evaluated at.
location int Location in element: upstream_end\(, inside\), or downstream_end$
twiss_valid bool Is the data here valid? Note: IF there is no energy variation (RF off) twiss_valid may be true but in this case the z-twiss will not be valid.

BunchStruct

Fortran struct: bunch_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
particle 1D array of CoordStruct
ix_z 1D array of int bunch%ix_z(1) is index of head particle, etc.
charge_tot float Total charge in a bunch (Coul).
charge_live float Charge of live particles (Coul).
z_center float Longitudinal center of bunch at creation time. Note: Generally, z_center of bunch #1 is 0 and z_center of the other bunches is negative.
t_center float Center of bunch at creation time relative to head bunch.
t0 float Used by track1_bunch_space_charge for tracking so particles have constant t.
drift_between_t_and_s bool Drift (ignore any fields) instead of tracking to speed up the calculation? This can only be done under certain circumstances.
ix_ele int Nominal element bunch is at. But, EG, dead particles can be someplace else.
ix_bunch int Bunch index. Head bunch = 1, etc.
ix_turn int Turn index for long term tracking. ix_turn = 0 before end of first turn, etc.
n_live int
n_good int Number of accepted steps when using adaptive step size control.
n_bad int Number of rejected steps when using adaptive step size control.

BunchTrackStruct

Fortran struct: bunch_track_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
pt 1D array of BunchParamsStruct Array indexed from 0
ds_save float Min distance between points.
n_pt int Track upper bound

CartesianMapStruct

Fortran struct: cartesian_map_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
field_scale float Factor to scale the fields by
r0 1D array of float (shape: 3) Field origin offset.
master_parameter int Master parameter in ele%value(:) array to use for scaling the field.
ele_anchor_pt int anchor_beginning\(, anchor_center\), or anchor_end$
field_type int or electric$
ptr CartesianMapTermStruct

CartesianMapTerm1Struct

Fortran struct: cartesian_map_term1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
coef float
kx float
ky float
kz float
x0 float
y0 float
phi_z float
family int family_x$, etc.
form int hyper_y$, etc.

CartesianMapTermStruct

Fortran struct: cartesian_map_term_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
file str Input file name. Used also as ID for instances.
n_link int For memory management of %term
term 1D array of CartesianMapTerm1Struct

ComplexTaylorStruct

Fortran struct: complex_taylor_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ref complex
term 1D array of ComplexTaylorTermStruct

ComplexTaylorTermStruct

Fortran struct: complex_taylor_term_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
coef complex
expn 1D array of int (shape: 6)

ControlRamp1Struct

Fortran struct: control_ramp1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
y_knot 1D array of float
stack 1D array of ExpressionAtomStruct Evaluation stack
attribute str Name of attribute controlled. Set to "FIELD_OVERLAPS" for field overlaps.
slave_name str Name of slave.
is_controller bool Is the slave a controller? If so bookkeeping is different.

ControlStruct

Fortran struct: control_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
value float Used by group, and overlay elements.
y_knot 1D array of float
stack 1D array of ExpressionAtomStruct Evaluation stack
slave LatEleLocStruct
lord LatEleLocStruct
slave_name str Name of slave.
attribute str Name of attribute controlled. Set to "FIELD_OVERLAPS" for field overlaps. Set to "INPUT" or "OUTPUT" for feedback slaves.
ix_attrib int Index of attribute controlled. See note above!

ControlVar1Struct

Fortran struct: control_var1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str
value float
old_value float

ControllerStruct

Fortran struct: controller_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
var 1D array of ControlVar1Struct
ramp 1D array of ControlRamp1Struct For ramper lord elements
ramper_lord 1D array of RamperLordStruct Ramper lord info for this slave
x_knot 1D array of float

CoordArrayStruct

Fortran struct: coord_array_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
orbit 1D array of CoordStruct

CoordStruct

Fortran struct: coord_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
vec 1D array of float (shape: 6) (x, px, y, py, z, pz). Generally phase space for charged particles. See Bmad manual.
s float Longitudinal position
t float Absolute time (not relative to reference). Note: Quad precision!
spin 1D array of float (shape: 3) Spin.
field 1D array of float (shape: 2) Photon E-field intensity (x,y).
phase 1D array of float (shape: 2) Photon E-field phase (x,y). For charged particles, phase(1) is RF phase.
charge float Macroparticle weight (which is different from particle species charge). For some space charge calcs the weight is in Coulombs.
dt_ref float Used in: * time tracking for computing z. * by coherent photons = path_length/c_light.
r float For general use. Not used by Bmad.
p0c float For non-photons: Reference momentum. For photons: Photon momentum (not reference).
E_potential float Potential energy.
beta float Velocity / c_light.
ix_ele int Index of the lattice element the particle is in. May be -1 if element is not associated with a lattice.
ix_branch int Index of the lattice branch the particle is in.
ix_turn int Turn index for multiturn tracking.
ix_user int For general use, not used by Bmad.
state int alive\(, lost\), lost_neg_x_aperture\(, lost_pz\), etc.
direction int +1 or -1. Sign of longitudinal direction of motion (ds/dt). This is independent of the element orientation.
time_dir int +1 or -1. Time direction. -1 => Traveling backwards in time.
species int positron\(, proton\), etc.
location int upstream_end\(, inside\), or downstream_end$

CylindricalMapStruct

Fortran struct: cylindrical_map_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
m int Azimuthal Mode: varies as cos(m*phi - theta0_azimuth)
harmonic int Harmonic of fundamental
phi0_fieldmap float Mode oscillates as: twopi * (f * t + phi0_fieldmap)
theta0_azimuth float Azimuthal ((x, y) plane) orientation of mode.
field_scale float Factor to scale the fields by
master_parameter int Master parameter in ele%value(:) array to use for scaling the field.
ele_anchor_pt int anchor_beginning\(, anchor_center\), or anchor_end$
dz float Distance between sampled field points.
r0 1D array of float (shape: 3) Field origin offset.
ptr CylindricalMapTermStruct

CylindricalMapTerm1Struct

Fortran struct: cylindrical_map_term1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
e_coef complex
b_coef complex

CylindricalMapTermStruct

Fortran struct: cylindrical_map_term_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
file str Input file name. Used also as ID for instances.
n_link int For memory management of this structure
term 1D array of CylindricalMapTerm1Struct

ElePointerStruct

Fortran struct: ele_pointer_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ele EleStruct
loc LatEleLocStruct
id int For general use. Not used by Bmad. In particular, used by Tao to designate universe ele is in.

EleStruct

Fortran struct: ele_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str name of element.
type str type name.
alias str Another name.
component_name str Used by overlays, multipass patch, etc.
descrip str Description string.
a TwissStruct Twiss parameters at end of element
b TwissStruct Twiss parameters at end of element
z TwissStruct Twiss parameters at end of element
x XyDispStruct Projected dispersions.
y XyDispStruct Projected dispersions.
ac_kick AcKickerStruct ac_kicker element parameters.
bookkeeping_state BookkeepingStateStruct Attribute bookkeeping
branch BranchStruct Pointer to branch containing element.
control ControllerStruct group & overlay variables.
rf RfEleStruct RF parameters.
lord EleStruct Pointer to a slice lord.
ptc_fibre Fibre PTC track corresponding to this ele. %floor is floor coord of lab coordinates at the downstream end. Notice that if ele%direction = -1, the lab coords have the z-axis antiparallel to the +s-direction.
floor FloorPositionStruct
high_energy_space_charge HighEnergySpaceChargeStruct
mode3 Mode3Struct 6D normal mode structure.
photon PhotonElementStruct
rad_map RadMapEleStruct Radiation kick parameters Note: The reference orbits for spin and orbit Taylor maps are not necessarily the same. For example, Sprint spin Taylor maps can be with respect to the zero orbit independent of the orbital map.
taylor 1D array of TaylorStruct (shape: 6) Phase space Taylor map.
spin_taylor_ref_orb_in 1D array of float (shape: 6)
spin_taylor 1D array of TaylorStruct (shape: 0:3) Quaternion Spin Taylor map.
wake WakeStruct Wakes
wall3d 1D array of Wall3dStruct Chamber or capillary wall E/M field structs.
cartesian_map 1D array of CartesianMapStruct Used to define E/M fields
cylindrical_map 1D array of CylindricalMapStruct Used to define E/M fields
gen_grad_map 1D array of GenGradMapStruct Used to define E/M fields.
grid_field 1D array of GridFieldStruct Used to define E/M fields. The difference between map_ref_orb and time_ref_orb is that map_ref_orb is the reference orbit for the 1st order spin/orbit map which, in general, is non-zero while time_ref_orb follows the reference particle which is generally the zero orbit (non-zero, for example, in the second slice of a sliced wiggler).
map_ref_orb_in CoordStruct Entrance end transfer map ref orbit
map_ref_orb_out CoordStruct Exit end transfer map ref orbit
time_ref_orb_in CoordStruct Reference orbit at entrance end for ref_time calc.
time_ref_orb_out CoordStruct Reference orbit at exit end for ref_time calc.
value 1D array of float (shape: num_ele_attrib$) attribute values.
old_value 1D array of float (shape: num_ele_attrib$) Used to see if %value(:) array has changed. Note: The reference orbit for spin/orbit matrices is %map_ref_orb_in/out
spin_q 2D array of float (shape: 0:3,0:6) 0th and 1st order Spin transport quaternion.
vec0 1D array of float (shape: 6) 0th order transport vector.
mat6 2D array of float (shape: 6,6) 1st order transport matrix.
c_mat 2D array of float (shape: 2,2) 2x2 C coupling matrix
dc_mat_dpz 2D array of float (shape: 2,2) d(c_mat)/dpz variation.
gamma_c float gamma associated with C matrix
s_start float longitudinal ref position at entrance_end
s float longitudinal ref position at the exit end.
ref_time float Time ref particle passes exit end.
a_pole 1D array of float knl for multipole elements.
b_pole 1D array of float tilt for multipole elements.
a_pole_elec 1D array of float Electrostatic multipoles. ksnl for multipole elements.
b_pole_elec 1D array of float Electrostatic multipoles.
custom 1D array of float Custom attributes.
r 3D array of float For general use. Not used by Bmad.
key int Element class (quadrupole, etc.).
sub_key int Records bend input type.
ix_ele int Index in branch ele(0:) array. Set to ix_slice_slave$ = -2 for slice_slave$ elements.
ix_branch int Index in lat%branch(:) array. Note: lat%ele => lat%branch(0).
lord_status int Type of lord element this is. overlay_lord$, etc.
n_slave int Number of slaves (except field overlap slaves) of this element.
n_slave_field int Number of field slaves of this element.
ix1_slave int Pointer index to this element's slaves.
slave_status int Type of slave element this is. multipass_slave\(, slice_slave\), etc.
n_lord int Number of lords (except field overlap and ramper lords).
n_lord_field int Number of field lords of this element.
n_lord_ramper int Number of ramper lords.
ic1_lord int Pointer index to this element's lords.
ix_pointer int For general use. Not used by Bmad.
ixx int Index for Bmad internal use.
iyy int Index for Bmad internal use.
izz int Index for Bmad internal use.
mat6_calc_method int taylor\(, symp_lie_ptc\), etc.
tracking_method int taylor\(, linear\), etc.
spin_tracking_method int symp_lie_ptc$, etc.
csr_method int or one_dim$ ("1_dim"), steady_state_3d$
space_charge_method int slice\(, slice_longitudinal\), slice_transverse\(, fft_3D\), cathode_fft_3d$
ptc_integration_type int drift_kick\(, matrix_kick\), or ripken_kick$
field_calc int no_field\(, fieldmap\), refer_to_lords\(, or custom\)
aperture_at int Aperture location: entrance_end$, ...
aperture_type int rectangular\(, elliptical\), auto_aperture$, ...
ref_species int Reference species
orientation int -1 -> Element is longitudinally reversed. +1 -> Normal.
symplectify bool Symplectify mat6 matrices.
mode_flip bool Have the normal modes traded places?
multipoles_on bool For turning multipoles on/off
scale_multipoles bool Are ab_multipoles within other elements (EG: quads, etc.) scaled by the strength of the element?
taylor_map_includes_offsets bool Taylor map calculated with element misalignments?
field_master bool Calculate strength from the field value?
is_on bool For turning element on/off.
logic bool For general use. Not used by Bmad (except during lattice parsing).
bmad_logic bool For Bmad internal use only.
select bool For Bmad internal use only.
offset_moves_aperture bool element offsets affects aperture? ! final :: ele_finalizer

EllipseBeamInitStruct

Fortran struct: ellipse_beam_init_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
part_per_ellipse int number of particles per ellipse
n_ellipse int number of ellipses (>= 1)
sigma_cutoff float sigma cutoff of the representation

EmFieldStruct

Fortran struct: em_field_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
E 1D array of float (shape: 3) electric field.
B 1D array of float (shape: 3) magnetic field.
dE 2D array of float (shape: 3,3) electric field gradient.
dB 2D array of float (shape: 3,3) magnetic field gradient.
phi float Electric scalar potential.
phi_B float Magnetic scalar potential.
A 1D array of float (shape: 3) Magnetic vector potential.

ExpressionAtomStruct

Fortran struct: expression_atom_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str
type int plus\(, minum\), sin\(, cos\), etc. To convert to string use: expression_op_name
value float

ExpressionTreeStruct

Fortran struct: expression_tree_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str
type int plus\(, minum\), sin\(, cos\), etc.
value float
node 1D array of ExpressionTreeStruct Child nodes. Note: Pointer used here since Ifort does not support allocatable.

FloorPositionStruct

Fortran struct: floor_position_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
r 1D array of float (shape: 3) (x, y, z) offset from origin
w 2D array of float (shape: 3,3) W matrix. Columns are unit vectors of the frame axes.
theta float angular orientation consistent with W matrix
phi float angular orientation consistent with W matrix
psi float angular orientation consistent with W matrix

GenGrad1Struct

Fortran struct: gen_grad1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
m int Azimuthal index
sincos int sin$ or cos$
n_deriv_max int Max GG derivative The derivative matrix is extended to include the interpolating spline polynomial.
deriv 2D array of float Range: (iz0:iz1, 0:2*n_deriv_max+1)

GenGradMapStruct

Fortran struct: gen_grad_map_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
file str Input file name. Used also as ID for instances.
gg 1D array of GenGrad1Struct
ele_anchor_pt int anchor_beginning\(, anchor_center\), or anchor_end$
field_type int or electric$
iz0 int gg%deriv(iz0:iz1, :) lower bound.
iz1 int gg%deriv(iz0:iz1, :) upper bound.
dz float Point spacing.
r0 1D array of float (shape: 3) field origin relative to ele_anchor_pt.
field_scale float Factor to scale the fields by
master_parameter int Master parameter in ele%value(:) array to use for scaling the field.
curved_ref_frame bool

GgTaylorStruct

Fortran struct: gg_taylor_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ref float
term 1D array of GgTaylorTermStruct

GgTaylorTermStruct

Fortran struct: gg_taylor_term_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
coef float
expn 1D array of int (shape: 2)

GridBeamInitStruct

Fortran struct: grid_beam_init_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
n_x int Number of columns.
n_px int Number of rows.
x_min float Lower x limit.
x_max float Upper x limit.
px_min float Lower px limit.
px_max float Upper px limit.

GridFieldPt1Struct

Fortran struct: grid_field_pt1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
E 1D array of complex (shape: 3)
B 1D array of complex (shape: 3)

GridFieldPtStruct

Fortran struct: grid_field_pt_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
file str Input file name. Used also as ID for instances.
n_link int For memory management of this structure
pt 3D array of GridFieldPt1Struct

GridFieldStruct

Fortran struct: grid_field_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
geometry int Type of grid: xyz\(, or rotationally_symmetric_rz\)
harmonic int Harmonic of fundamental for AC fields.
phi0_fieldmap float Mode oscillates as: twopi * (f * t + phi0_fieldmap)
field_scale float Factor to scale the fields by
field_type int or magnetic$ or electric$
master_parameter int Master parameter in ele%value(:) array to use for scaling the field.
ele_anchor_pt int anchor_beginning\(, anchor_center\), or anchor_end$
interpolation_order int Possibilities are 1 or 3.
dr 1D array of float (shape: 3) Grid spacing.
r0 1D array of float (shape: 3) Field origin relative to ele_anchor_pt.
curved_ref_frame bool
ptr GridFieldPtStruct
bi_coef 3D array of BicubicCmplxCoefStruct (shape: 4, 2, 3) Save computed coefs for faster tracking
tri_coef 3D array of TricubicCmplxCoefStruct (shape: 4, 2, 3) Save computed coefs for faster tracking

HighEnergySpaceChargeStruct

Fortran struct: high_energy_space_charge_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
closed_orb CoordStruct beam orbit
kick_const float
sig_x float
sig_y float
phi float Rotation angle to go from lab frame to rotated frame.
sin_phi float
cos_phi float
sig_z float

Interval1CoefStruct

Fortran struct: interval1_coef_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
c0 float
c1 float
n_exp float

KvBeamInitStruct

Fortran struct: kv_beam_init_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
part_per_phi 1D array of int (shape: 2) number of particles per angle variable.
n_I2 int number of I2
A float A = I1/e

LatEleLocStruct

Fortran struct: lat_ele_loc_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ix_ele int
ix_branch int

LatEleOrder1Struct

Fortran struct: lat_ele_order1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ix_branch int Branch index
ix_order int Order index. -1 -> Unique in lattice, 0 -> unique in branch.

LatEleOrderArrayStruct

Fortran struct: lat_ele_order_array_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ele 1D array of LatEleOrder1Struct

LatEleOrderStruct

Fortran struct: lat_ele_order_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
branch 1D array of LatEleOrderArrayStruct

LatParamStruct

Fortran struct: lat_param_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
n_part float Particles/bunch (for BeamBeam elements).
total_length float total_length of branch. Warning: branch may not start at s = 0.
unstable_factor float If positive: Growth rate/turn if unstable in closed branches or |orbit-aperture|/aperture if particle hits wall. Zero otherwise.
t1_with_RF 2D array of float (shape: 6,6) Full 1-turn matrix with RF on.
t1_no_RF 2D array of float (shape: 6,6) Full 1-turn matrix with RF off.
spin_tune float Closed orbit spin tune.
particle int Reference particle: positron\(, electron\), etc. Call lattice_bookkeeper if this is changed.
default_tracking_species int Default particle type to use in tracking.
geometry int open$ or closed$
ixx int Integer for general use
stable bool is closed lat stable?
live_branch bool Should tracking be done on the branch?
g1_integral float Approximate |g| (bending strength) integral of branch.
g2_integral float Approximate g^2 integral of branch.
g3_integral float Approximate g^2 integral of branch.
bookkeeping_state BookkeepingStateStruct Overall status for the branch.
beam_init BeamInitStruct For beam initialization.

LatStruct

Fortran struct: lat_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
use_name str Name of lat given by USE statement
lattice str Lattice
machine str Name of the machine the lattice is for ("LHC", etc).
input_file_name str Name of the lattice input file
title str General title
print_str 1D array of str Saved print statements.
constant 1D array of ExpressionAtomStruct Constants defined in the lattice
a ModeInfoStruct Tunes (fractional part), etc.
b ModeInfoStruct Tunes (fractional part), etc.
z ModeInfoStruct Tunes (fractional part), etc.
param LatParamStruct Parameters
lord_state BookkeepingStateStruct lord bookkeeping status.
ele_init EleStruct For use by any program
ele 1D array of EleStruct Array of elements [=> branch(0)].
branch 1D array of BranchStruct Branch(0:) array
control 1D array of ControlStruct Control list
particle_start CoordStruct Starting particle_coords.
beam_init BeamInitStruct Beam initialization.
pre_tracker PreTrackerStruct For OPAL/IMPACT-T
custom 1D array of float Custom attributes.
version int Version number
n_ele_track int Number of lat elements to track through.
n_ele_max int Index of last valid element in %ele(:) array
n_control_max int Last index used in control_array
n_ic_max int Last index used in ic_array
input_taylor_order int As set in the input file
ic 1D array of int Index to %control(:) from slaves.
photon_type int Or coherent$. For X-ray simulations.
creation_hash int Set by bmad_parser. creation_hash will vary if any of the lattice files are modified.
ramper_slave_bookkeeping int
parser_make_xfer_mats bool Is Bmad parser to make element transfer matrices?

LinacNormalModeStruct

Fortran struct: linac_normal_mode_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
i2_E4 float Integral: g^2 * gamma^4
i3_E7 float Integral: g^3 * gamma^7
i5a_E6 float Integral: (g^3 * H_a) * gamma^6
i5b_E6 float Integral: (g^3 * H_b) * gamma^6
sig_E1 float Energy spread after 1 pass (eV)
a_emittance_end float a mode emittance at end of linac
b_emittance_end float b mode emittance at end of linac

MadEnergyStruct

Fortran struct: mad_energy_struct (bmad/modules/mad_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
total float
beta float normalized velocity: v/c
gamma float relativistic factor: 1/sqrt(1-beta^2)
kinetic float kinetic energy
p0c float particle momentum
particle int particle species

MadMapStruct

Fortran struct: mad_map_struct (bmad/modules/mad_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
k 1D array of float (shape: 6) 0th order map.
r 2D array of float (shape: 6,6) 1st order map.
t 3D array of float (shape: 6,6,6) 2nd order map.

Mode3Struct

Fortran struct: mode3_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
v 2D array of float (shape: 6,6)
a TwissStruct
b TwissStruct
c TwissStruct
x TwissStruct
y TwissStruct

ModeInfoStruct

Fortran struct: mode_info_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
stable bool Is the mode stable?
tune float "fractional" tune in radians
emit float Emittance (unnormalized).
chrom float Chromaticity.
sigma float Beam size.
sigmap float Beam divergence.

NormalModesStruct

Fortran struct: normal_modes_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
synch_int 1D array of float (shape: 0:3) Synchrotron integrals I0, I1, I2, and I3
sigE_E float SigmaE/E
sig_z float Sigma_Z
e_loss float Energy loss / turn (eV)
rf_voltage float Total rfcavity voltage (eV)
pz_aperture float pz aperture limit. Used with Touschek calculations.
pz_average float Average over branch due to damping.
momentum_compaction float
dpz_damp float Change in pz without RF
a AnormalModeStruct
b AnormalModeStruct
z AnormalModeStruct
lin LinacNormalModeStruct

PhotonElementStruct

Fortran struct: photon_element_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
curvature SurfaceCurvatureStruct
target PhotonTargetStruct
material PhotonMaterialStruct
segmented SurfaceSegmentedStruct
h_misalign SurfaceHMisalignStruct
displacement SurfaceDisplacementStruct
pixel PixelDetecStruct
reflectivity_table_type int
reflectivity_table_sigma PhotonReflectTableStruct If polarization is ignored use sigma table.
reflectivity_table_pi PhotonReflectTableStruct
init_energy_prob 1D array of SplineStruct Initial energy probability density
integrated_init_energy_prob 1D array of float

PhotonMaterialStruct

Fortran struct: photon_material_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
f0_m1 complex For multilayer_mirror only.
f0_m2 complex For multilayer_mirror only.
f_0 complex
f_h complex Structure factor for H direction.
f_hbar complex Structure factor for -H direction.
f_hkl complex = sqrt(f_h * f_hbar)
h_norm 1D array of float (shape: 3) Normalized H vector for crystals.
l_ref 1D array of float (shape: 3) Crystal reference orbit displacement vector in element coords.

PhotonReflectSurfaceStruct

Fortran struct: photon_reflect_surface_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str
description str Descriptive name
reflectivity_file str
table 1D array of PhotonReflectTableStruct
surface_roughness_rms float sigma in Dugan's notation
roughness_correlation_len float T in Dugan's notation
ix_surface int

PhotonReflectTableStruct

Fortran struct: photon_reflect_table_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
angle 1D array of float Vector of angle values for %p_reflect
energy 1D array of float Vector of energy values for %p_reflect
int1 1D array of Interval1CoefStruct
p_reflect 2D array of float (angle, ev) probability. Log used for smooth surface reflection
max_energy float maximum energy for this table
p_reflect_scratch 1D array of float Scratch space
bragg_angle 1D array of float Bragg angle at energy values.

PhotonTargetStruct

Fortran struct: photon_target_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
type int or rectangular$
n_corner int
ele_loc LatEleLocStruct
corner 1D array of TargetPointStruct (shape: 8)
center TargetPointStruct

PixelDetecStruct

Fortran struct: pixel_detec_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
dr 1D array of float (shape: 2)
r0 1D array of float (shape: 2)
n_track_tot int How many photons were launched from source element.
n_hit_detec int How many photons hit the detector.
n_hit_pixel int How many photons hit the pixel grid of the detector.
pt 2D array of PixelPtStruct Grid of pixels

PixelPtStruct

Fortran struct: pixel_pt_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
n_photon int
E_x complex
E_y complex
intensity_x float
intensity_y float
intensity float
orbit 1D array of float (shape: 6) x, Vx/c, y, Vy/c, dummy, E - E_ref.
orbit_rms 1D array of float (shape: 6) RMS statistics.
init_orbit 1D array of float (shape: 6) Initial orbit at start of lattice statistics.
init_orbit_rms 1D array of float (shape: 6) Initial orbit at start of lattice RMS statistics.

PreTrackerStruct

Fortran struct: pre_tracker_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
who int Can be opal\(, or impactt\)
ix_ele_start int
ix_ele_end int
input_file str

PtcNormalFormStruct

Fortran struct: ptc_normal_form_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ele_origin EleStruct Element at which the on-turn map was created.
orb0 1D array of float (shape: 6) Closed orbit at element.
valid_map bool

RadInt1Struct

Fortran struct: rad_int1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
i0 float
i1 float
i2 float
i3 float
i4a float
i4b float
i4z float
i5a float
i5b float
i6b float
lin_i2_E4 float
lin_i3_E7 float
lin_i5a_E6 float
lin_i5b_E6 float
lin_norm_emit_a float Running sum
lin_norm_emit_b float Running sum
lin_sig_E float Running sum
n_steps float number of qromb steps needed

RadIntAllEleStruct

Fortran struct: rad_int_all_ele_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
branch 1D array of RadIntBranchStruct Array is indexed from 0

RadIntBranchStruct

Fortran struct: rad_int_branch_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ele 1D array of RadInt1Struct Array is indexed from 0

RadMapEleStruct

Fortran struct: rad_map_ele_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
rm0 RadMapStruct Upstream half and downstream half matrices for an element.
rm1 RadMapStruct Upstream half and downstream half matrices for an element.
stale bool

RadMapStruct

Fortran struct: rad_map_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ref_orb 1D array of float (shape: 6) Reference point around which damp_mat is calculated.
damp_dmat 2D array of float (shape: 6,6) damp_correction = xfer_mat_with_damping - xfer_mat_without_damping.
xfer_damp_vec 1D array of float (shape: 6) Transfer map with damping 0th order vector.
xfer_damp_mat 2D array of float (shape: 6,6) 1st order matrix: xfer_no_damp_mat + xfer_damp_correction.
stoc_mat 2D array of float (shape: 6,6) Stochastic variance or "kick" (Cholesky decomposed) matrix.

RamperLordStruct

Fortran struct: ramper_lord_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ix_ele int Lord index
ix_con int Index in lord%control%ramp(:) array
attrib_ptr float Pointer to attribute in this element.

ResonanceHStruct

Fortran struct: resonance_h_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
id str 6 digit ID. EG: '003100'
c_val complex Resonance value

RfEleStruct

Fortran struct: rf_ele_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
steps 1D array of RfStairStepStruct Energy stair step array indexed from zero.
ds_step float length of a stair step.

RfStairStepStruct

Fortran struct: rf_stair_step_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
E_tot0 float Reference energy in the drift region (before the kick point).
E_tot1 float Reference energy after the kick point.
p0c float Reference momentum in the drift region (before the kick point).
p1c float Reference momentum after the kick point.
scale float Scale for multipole kick at the kick point. Sum over all steps will be 1.
time float Reference particle time at the kick point with respect to beginning of element.
s0 float S-position at beginning of drift region relative to the beginning of the element.
s float S-position at the kick point relative to the beginning of the element.
ix_step int Step index in ele%rf%steps(:) array

SpaceChargeCommonStruct

Fortran struct: space_charge_common_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ds_track_step float CSR tracking step size
dt_track_step float Time Runge kutta initial step.
cathode_strength_cutoff float Cutoff for the cathode field calc.
rel_tol_tracking float Relative tolerance for tracking.
abs_tol_tracking float Absolute tolerance for tracking.
beam_chamber_height float Used in shielding calculation.
lsc_sigma_cutoff float Cutoff for the 1-dim longitudinal SC calc. If a bin sigma is < cutoff * sigma_ave then ignore.
particle_sigma_cutoff float 3D SC calc cutoff for particles with (x,y,z) position far from the center. Negative or zero means ignore.
mesh_growth_factor float Fractional padding when growing SC mesh (default: 10%). Set to 0 for tight-fit (no caching speedup).
mesh_shrink_factor float Fractional threshold for shrinking SC mesh (default: 10%). Mesh shrinks when bunch fills < (1-this) of the mesh range.
space_charge_mesh_size 1D array of int (shape: 3) Gird size for fft_3d space charge calc.
csr3d_mesh_size 1D array of int (shape: 3) Gird size for CSR.
n_bin int Number of bins used
particle_bin_span int Longitudinal particle length / dz_bin
n_shield_images int Chamber wall shielding. 0 = no shielding.
sc_min_in_bin int Minimum number of particles in a bin for sigmas to be valid.
lsc_kick_transverse_dependence bool
debug bool
diagnostic_output_file str If non-blank write a diagnostic (EG wake) file

SpinAxisStruct

Fortran struct: spin_axis_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
l 1D array of float (shape: 3) Transverse axis.
n0 1D array of float (shape: 3) Invariant spin axis on closed orbit.
m 1D array of float (shape: 3) Transverse axis.

SpinOrbitMap1Struct

Fortran struct: spin_orbit_map1_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
orb_mat 2D array of float (shape: 6,6) Orbital matrix
vec0 1D array of float (shape: 6) Orbital 0th order map: r_out = mat6 * r_in + vec0
spin_q 2D array of float (shape: 0:3,0:6) 0th and 1st order quaternion spin map

SpinPolarStruct

Fortran struct: spin_polar_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
polarization float
theta float Spherical coords: Angle from z-axis.
phi float Spherical coords: Angle in (x,y) plane.
xi float Spinor phase angle (See Bmad manual).

StrongBeamStruct

Fortran struct: strong_beam_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ix_slice int 0 -> at element center and not at slice.
x_center float Strong beam slice center.
y_center float Strong beam slice center.
x_sigma float Strong beam slice sigma.
y_sigma float Strong beam slice sigma.
dx float Particle - beam slice distance.
dy float Particle - beam slice distance.

SummationRdtStruct

Fortran struct: summation_rdt_struct (bmad/modules/srdt_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
h11001 complex
h00111 complex
h20001 complex
h00201 complex
h10002 complex
h21000 complex
h30000 complex
h10110 complex
h10020 complex
h10200 complex 2nd order in K2 moments
h31000 complex
h40000 complex
h20110 complex
h11200 complex
h20020 complex
h20200 complex
h00310 complex
h00400 complex
h22000 complex
h00220 complex
h11110 complex

SurfaceCurvatureStruct

Fortran struct: surface_curvature_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
xy 2D array of float (shape: 0:6,0:6)
spherical float
elliptical 1D array of float (shape: 3) Total curvature = elliptical + spherical
has_curvature bool Dependent var. Will be set by Bmad

SurfaceDisplacementPtStruct

Fortran struct: surface_displacement_pt_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x0 float Position at center
y0 float Position at center
z0 float
dz_dx float
dz_dy float
d2z_dxdy float

SurfaceDisplacementStruct

Fortran struct: surface_displacement_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
active bool
dr 1D array of float (shape: 2)
r0 1D array of float (shape: 2)
pt 2D array of SurfaceDisplacementPtStruct

SurfaceHMisalignPtStruct

Fortran struct: surface_h_misalign_pt_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x0 float Position at center
y0 float Position at center
rot_y float rot_t = x-rotation for Bragg and z-rotation for Laue.
rot_t float rot_t = x-rotation for Bragg and z-rotation for Laue.
rot_y_rms float rot_t = x-rotation for Bragg and z-rotation for Laue.
rot_t_rms float rot_t = x-rotation for Bragg and z-rotation for Laue.

SurfaceHMisalignStruct

Fortran struct: surface_h_misalign_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
active bool
dr 1D array of float (shape: 2)
r0 1D array of float (shape: 2)
pt 2D array of SurfaceHMisalignPtStruct

SurfaceSegmentedPtStruct

Fortran struct: surface_segmented_pt_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x0 float Position at center
y0 float Position at center
z0 float Position at center
dz_dx float Slope at center
dz_dy float Slope at center

SurfaceSegmentedStruct

Fortran struct: surface_segmented_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
active bool
dr 1D array of float (shape: 2)
r0 1D array of float (shape: 2)
pt 2D array of SurfaceSegmentedPtStruct

TargetPointStruct

Fortran struct: target_point_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
r 1D array of float (shape: 3) (x, y, z)

TaylorStruct

Fortran struct: taylor_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ref float
term 1D array of TaylorTermStruct

TaylorTermStruct

Fortran struct: taylor_term_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
coef float
expn 1D array of int (shape: 6)

TrackPointStruct

Fortran struct: track_point_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
s_lab float Longitudinal lab coord with respect to the upstream end.
s_body float Longitudinal body coord with respect to the entrance end.
orb CoordStruct Particle position in lab coords.
field EmFieldStruct E&M fields in lab coordinates.
strong_beam StrongBeamStruct Strong beam info for beambeam element.
vec0 1D array of float (shape: 6) 0th order part of xfer map from the beginning.
mat6 2D array of float (shape: 6,6) 1st order part of xfer map (transfer matrix).

TrackStruct

Fortran struct: track_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
pt 1D array of TrackPointStruct Array of track points indexed from 0.
ds_save float Min distance between points. Not positive => Save at all points.
n_pt int Track upper bound for %pt(0:) array. n_bad and n_ok are used by adaptive trackers to record the number of times the step length had to be shortened.
n_bad int Number of "bad" steps where the step length was shortened.
n_ok int Number of "good" steps where the step length was not shortened.

TwissStruct

Fortran struct: twiss_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
beta float
alpha float
gamma float
phi float
eta float
etap float
deta_ds float
sigma float
sigma_p float
emit float
norm_emit float
chrom float
dbeta_dpz float
dalpha_dpz float
deta_dpz float
detap_dpz float

WakeLrModeStruct

Fortran struct: wake_lr_mode_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
freq float Actual Frequency in Hz.
freq_in float Input frequency in Hz.
R_over_Q float Strength in V/C/m^(2*m_mode).
Q float Used for backwards compatability.
damp float Damping factor = omega / 2 * Q = pi * freq / Q
phi float Phase in radians/2pi.
angle float polarization angle (radians/2pi).
b_sin float non-skew sin-like component of the wake.
b_cos float non-skew cos-like component of the wake.
a_sin float skew sin-like component of the wake.
a_cos float skew cos-like component of the wake.
m int Mode order (1 = dipole, 2 = quad, etc.)
polarized bool Polaraized mode?

WakeLrStruct

Fortran struct: wake_lr_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
file str
mode 1D array of WakeLrModeStruct
t_ref float time reference value for computing the wake amplitude. This is used to prevent value overflow with long trains.
freq_spread float Random frequency spread of long range modes.
amp_scale float Wake amplitude scale factor.
time_scale float time scale factor.
self_wake_on bool Long range self-wake used in tracking?

WakeSrModeStruct

Fortran struct: wake_sr_mode_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
amp float Amplitude
damp float Dampling factor.
k float k factor
phi float Phase in radians/2pi
b_sin float non-skew (x) sin-like component of the wake
b_cos float non-skew (x) cos-like component of the wake
a_sin float skew (y) sin-like component of the wake
a_cos float skew (y) cos-like component of the wake
polarization int Transverse: none\(, x_axis\), y_axis$. Not used for longitudinal.
position_dependence int Transverse: leading\(, trailing\), none$ Longitudinal: x_leading\(, ..., y_trailing\), none$

WakeSrStruct

Fortran struct: wake_sr_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
file str
z_long WakeSrZLongStruct
long_wake 1D array of WakeSrModeStruct
trans_wake 1D array of WakeSrModeStruct
z_ref_long float z reference value for computing the wake amplitude.
z_ref_trans float This is used to prevent value overflow with long bunches.
z_max float Max allowable z value. 0-> ignore
amp_scale float Wake amplitude scale factor.
z_scale float z-distance scale factor.
scale_with_length bool Scale wake with element length?

WakeSrZLongStruct

Fortran struct: wake_sr_z_long_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
w 1D array of float Input single particle Wake. Indexed from 1.
fw 1D array of complex Fourier transform of w.
fbunch 1D array of complex Scratch space.
w_out 1D array of complex Scratch space.
dz float Distance between points. If zero there is no wake.
z0 float Wake extent is [-z0, z0].
smoothing_sigma float 0 => No smoothing.
position_dependence int Transverse: leading\(, trailing\), none$ Longitudinal: x_leading\(, ..., y_trailing\), none$
time_based bool Was input time based?

WakeStruct

Fortran struct: wake_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
sr WakeSrStruct Short-range wake
lr WakeLrStruct Long-range wake

Wall3DSectionStruct

Fortran struct: wall3d_section_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str Identifying name
material str Material.
v 1D array of Wall3dVertexStruct Array of vertices. Always stored relative.
surface PhotonReflectSurfaceStruct Surface reflectivity tables.
type int normal\(, clear\), opaque\(, wall_start\), wall_end$
n_vertex_input int Number of vertices specified by the user.
ix_ele int index of lattice element containing section
ix_branch int Index of branch lattice element is in.
vertices_state int absolute\(, or shifted_to_relative\). If set to absolute$ on input, will be changed to shifted_to_relative$ by section initalizer.
patch_in_region bool Patch element exists between this section and previous one?
thickness float Material thickness.
s float Longitudinal position
r0 1D array of float (shape: 2) Center of section Section-to-section spline interpolation of the center of the section
dx0_ds float Center of wall derivative
dy0_ds float Center of wall derivative
x0_coef 1D array of float (shape: 0:3) Spline coefs for x-center
y0_coef 1D array of float (shape: 0:3) Spline coefs for y-center Section-to_section spline interpolation of the wall.
dr_ds float derivative of wall radius
p1_coef 1D array of float (shape: 3) Spline coefs for p0 function
p2_coef 1D array of float (shape: 3) Spline coefs for p1 function

Wall3DStruct

Fortran struct: wall3d_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name str
type int or mask_plate$
ix_wall3d int Index in branch%wall3d(:) array.
n_link int For memory management of ele%wall3d
thickness float For diffraction_plate elements
clear_material str
opaque_material str
superimpose bool Can overlap another wall
ele_anchor_pt int anchor_beginning\(, anchor_center\), or anchor_end$
section 1D array of Wall3dSectionStruct Indexed from 1.

Wall3DVertexStruct

Fortran struct: wall3d_vertex_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x float Coordinates of the vertex.
y float Coordinates of the vertex.
radius_x float Radius of arc or ellipse x-axis half width. 0 => Straight line.
radius_y float Ellipse y-axis half height.
tilt float Tilt of ellipse
angle float Angle of (x, y) point.
x0 float Center of ellipse
y0 float Center of ellipse
type int No longer used.

XyDispStruct

Fortran struct: xy_disp_struct (bmad/modules/bmad_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
eta float
etap float
deta_ds float
sigma float
deta_dpz float
detap_dpz float

Procedures

ab_multipole_kick

Fortran source: bmad/modules/multipole_mod.f90

ab_multipole_kick(a: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex, ref_species: typing.SupportsInt | typing.SupportsIndex, ele_orientation: typing.SupportsInt | typing.SupportsIndex, coord: pybmad._pybmad.CoordStruct, pole_type: typing.SupportsInt | typing.SupportsIndex | None = None, scale: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.AbMultipoleKick

Subroutine ab_multipole_kick (a, b, n, ref_species, ele_orientation, coord, kx, ky, dk, pole_type, scale)

Subroutine to put in the kick due to an ab_multipole.

Parameters:
  • a (float) –

    Multipole skew component.

  • b (float) –

    Multipole normal component.

  • n (int) –

    Multipole order.

  • ref_species (int) –

    Reference species.

  • ele_orientation (int) –

    Element orientation +1 = normal, -1 = reversed, 0 = Ignore orientation and tracking species (used with pole_type = magnetic$).

  • coord (CoordStruct) –

    Particle position and direction of travel.

  • pole_type (int) –

    Type of multipole. magnetic$ (default) or electric$.

  • scale (float) –

    Factor to scale the kicks. Default is 1. For pole_type = electric$, set scale to the longitudinal length of the field region.

Returns:
  • kx( float ) –

    X kick.

  • ky( float ) –

    Y kick.

  • dk( 2D array of float (shape: 2,2), optional ) –

    Kick derivative: dkick(x,y)/d(x,y).

ab_multipole_kicks

Fortran source: bmad/modules/multipole_mod.f90

ab_multipole_kicks(an: pybmad._pybmad.RealArray1D, bn: pybmad._pybmad.RealArray1D, ix_pole_max: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, pole_type: typing.SupportsInt | typing.SupportsIndex | None = None, scale: typing.SupportsFloat | typing.SupportsIndex | None = None, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine ab_multipole_kicks (an, bn, ix_pole_max, ele, orbit, pole_type, scale, mat6, make_matrix)

Routine to put in the kick due to ab_multipole components in an element. The kick will be corrected for the orientation of the element and the particle direction of travel. Any difference between element p0c and orbit%p0c will be taken into account.

Also see the multipole_kicks routine.

Parameters:
  • an (1D array of float) –

    Skew multipole strengths.

  • bn (1D array of float) –

    Normal multipole strengths.

  • ix_pole_max (int) –

    Maximum pole index.

  • ele (EleStruct) –

    Lattice element containing the multipoles.

  • orbit (CoordStruct) –

    Particle position. This parameter is an input/output and is modified in-place. As an output, orbit: Kicked particle.

  • pole_type (int) –

    Type of multipole. magnetic$ (default) or electric$.

  • scale (float) –

    Factor to scale the kicks. Default is 1. For pole_type = electric$, set scale to the longitudinal length of the field region

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the multipole. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix including multipole.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

absolute_photon_position

Fortran source: bmad/photon/photon_init_mod.f90

absolute_photon_position(e_orb: pybmad._pybmad.CoordStruct, photon_orb: pybmad._pybmad.CoordStruct) -> None

Subroutine absolute_photon_position (e_orb, photon_orb)

Routine to calculate the photon phase space coordinates given: 1) The phase space coords of the emitting charged particle and 2) The photon phase space coords relative to the emitting particle. The photon (x, y, z) position is ignored (it is assumed the photon is emitted at the charged particle position) and only the photon's (vx, vy, vz) velocity matters.

Parameters:
  • e_orb (CoordStruct) –

    charged particle position.

  • photon_orb (CoordStruct) –

    Photon position relative to e_orb. This parameter is an input/output and is modified in-place. As an output, photon_orb: Absolute photon position.

absolute_time_tracking

Fortran source: bmad/modules/bmad_routine_interface.f90

absolute_time_tracking(ele: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine absolute_time_tracking

Parameters:
  • ele (EleStruct) –

    Element being tracked through.

Returns:
  • is_abs_time( bool ) –

    True if absolute time tracking is needed.

ac_kicker_amp

Fortran source: bmad/modules/bmad_routine_interface.f90

ac_kicker_amp(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, true_time: typing.SupportsFloat | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine ac_kicker_amp

Parameters:
  • ele (EleStruct) –

    ac_kicker element.

  • orbit (CoordStruct) –

    Contains the time to evaluate the amplitude at.

  • true_time (float) –

    The actual time. Normally this time is calculated using orbit.t or orbit.vec(5) but sometimes it is convenient to be able to override this. For example, time_runge_kutta uses this.

Returns:
  • ac_amp( float ) –

    Amplitude. Will be set to 1 if the element is not an ac_kicker.

action_to_xyz

Fortran source: bmad/modules/mode3_mod.f90

action_to_xyz(ring: pybmad._pybmad.LatStruct, ix: typing.SupportsInt | typing.SupportsIndex, J: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]) -> pybmad._pybmad.ActionToXyz

Subroutine action_to_xyz(ring, ix, J, X, err_flag)

Given the normal mode invariants and phases J of a particle, returns the canonical coordinates.

The J vector looks like: J = (sqrt(2Ja)cos(phia), -sqrt(2Ja)sin(phia), sqrt(2Jb)cos(phib), -sqrt(2Jb)sin(phib), sqrt(2Jc)cos(phic), -sqrt(2Jc)sin(phic))

X is obtained from: X = N . J Where N is from the Eigen decomposition of the 1-turn transfer matrix.

Parameters:
  • ring (LatStruct) –

    lattice

  • ix (int) –

    element index at which to calculate J

  • J (1D array of float (shape: 1:6)) –

    Vector containing normal mode invariants and phases

Returns:
  • X( 1D array of float (shape: 1:6) ) –

    canonical phase space coordinates of the particle

  • err_flag( bool ) –

    Set to true on error. Often means Eigen decomposition failed.

add_lattice_control_structs

Fortran source: bmad/modules/bmad_routine_interface.f90

add_lattice_control_structs(ele: pybmad._pybmad.EleStruct, n_add_slave: typing.SupportsInt | typing.SupportsIndex | None = None, n_add_lord: typing.SupportsInt | typing.SupportsIndex | None = None, n_add_slave_field: typing.SupportsInt | typing.SupportsIndex | None = None, n_add_lord_field: typing.SupportsInt | typing.SupportsIndex | None = None, add_at_end: bool | None = None) -> None

Wrapper for Fortran routine add_lattice_control_structs

Parameters:
  • ele (EleStruct) –

    Lord or slave element that needs extra control elements.

  • n_add_slave (int) –

    Number of field slaves to add to lord. Default is zero.

  • n_add_lord (int) –

    Number of field lords to add to slave. Default is zero.

  • n_add_slave_field (int) –

    Number of field slaves to add to lord. Default is zero.

  • n_add_lord_field (int) –

    Number of field lords to add to slave. Default is zero.

  • add_at_end (bool) –

    Used when n_add_slave or n_add_slave_field is non-zero. If True then new space is added at the end of the array. If False then new space is added at the front of the array. Default is True.

add_superimpose

Fortran source: bmad/modules/superimpose_mod.f90

add_superimpose(lat: pybmad._pybmad.LatStruct, super_ele_in: pybmad._pybmad.EleStruct, ix_branch: typing.SupportsInt | typing.SupportsIndex, save_null_drift: bool | None = None, create_jumbo_slave: bool | None = None, ix_insert: typing.SupportsInt | typing.SupportsIndex | None = None, mangle_slave_names: bool | None = None, wrap: bool | None = None) -> pybmad._pybmad.AddSuperimpose

Subroutine add_superimpose (lat, super_ele_in, ix_branch, err_flag, super_ele_out, save_null_drift, create_jumbo_slave, ix_insert, mangle_slave_names, wrap)

Routine to superimpose an element. If the element can be inserted into the lat without making a super_lord element then this will be done.

Note: This routine, since it handles only one superposition, is not sufficient for superposition in a multipass region. For historical reasons, the extra code needed is buried in the parser_add_superimpose code. If you need to do multipass superpositions please contact David Sagan and this situation will be rectified.

Note: Bookkeeping like recalculating reference energies and recalculating transfer matrices is not done by this routine.

Parameters:
  • lat (LatStruct) –

    Lat to modify. This parameter is an input/output and is modified in-place. As an output, lat: Modified lat.

  • super_ele_in (EleStruct) –

    Element to superimpose.

  • ix_branch (int) –

    Branch index to put element.

  • save_null_drift (bool) –

    Save a copy of a drift to be split as a null_ele? This is useful if further superpositions might use this drift as a reference element. After all superpositions are done, remove_eles_from_lat can be called to remove all null_eles. Default is False.

  • create_jumbo_slave (bool) –

    Default is False. If True then super_slaves that are created that have super_ele_in as their super_lord are em_field elements.

  • ix_insert (int) –

    If present and positive, and super_ele_in has zero length, use ix_insert as the index to insert super_ele_in at. ix_insert is useful when superposing next to another element that has zero or negative length (EG a patch) and you want to make sure that the superimposed element is on the correct side of the element.

  • mangle_slave_names (bool) –

    If True (default), adjust slave names appropriately. Name mangeling can take time so bmad_parser will do this all at once at the end.

  • wrap (bool) –

    If True (default), and if the superimposed element has an end that extends beyond the starting or ending edge of the lattice, wrap the element around the lattice so that the beginning portion of the element is at the lattice ending edge and the rest of the element is at the lattice start edge. If wrap = False, and the superimposed element has an end that extends beyound a lattice edge, extend the lattice to accommodate.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise

  • super_ele_out( (EleStruct, optional) ) –

    Pointer to the super element in the lattice.

add_this_multipass

Fortran source: bmad/parsing/bmad_parser_mod.f90

add_this_multipass(lat: pybmad._pybmad.LatStruct, m_slaves: pybmad._pybmad.LatEleLocStructArray1D, lord_in: pybmad._pybmad.EleStruct | None = None) -> None

Wrapper for Fortran routine add_this_multipass

Parameters:

add_this_name_to_list

Fortran source: bmad/output/write_lattice_file_mod.f90

add_this_name_to_list(ele: pybmad._pybmad.EleStruct, names: pybmad._pybmad.CharacterAlloc1D, an_indexx: pybmad._pybmad.IntAlloc1D, n_names: typing.SupportsInt | typing.SupportsIndex, ix_match: typing.SupportsInt | typing.SupportsIndex, has_been_added: bool, named_eles: pybmad._pybmad.ElePointerStructAlloc1D) -> None

Wrapper for Fortran routine add_this_name_to_list

Parameters:
  • ele (EleStruct) –
  • names (1D array of str) –
  • an_indexx (1D array of int) –
  • n_names (int) –
  • ix_match (int) –
  • has_been_added (bool) –
  • named_eles (1D array of ElePointerStruct) –

add_this_taylor_term

Fortran source: bmad/parsing/bmad_parser_mod.f90

add_this_taylor_term(ele: pybmad._pybmad.EleStruct, i_out: typing.SupportsInt | typing.SupportsIndex, coef: typing.SupportsFloat | typing.SupportsIndex, expn: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(6)"]) -> None

Subroutine add_this_taylor_term (ele, i_out, coef, expn)

Subroutine used by bmad_parser and bmad_parser2 to parse the input file. This subroutine is not intended for general use.

adjust_super_slave_names

Fortran source: bmad/modules/superimpose_mod.f90

adjust_super_slave_names(lat: pybmad._pybmad.LatStruct, ix1_lord: typing.SupportsInt | typing.SupportsIndex, ix2_lord: typing.SupportsInt | typing.SupportsIndex, first_time: bool | None = None) -> None

Subroutine adjust_super_slave_names (lat, ix1_lord, ix2_lord, first_time)

Routine to adjust the names of the slaves. This routine is used by add_superimpose and is not meant for general use.

allocate_branch_array

Fortran source: bmad/modules/bmad_routine_interface.f90

allocate_branch_array(lat: pybmad._pybmad.LatStruct, upper_bound: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine allocate_branch_array

Parameters:
  • lat (LatStruct) –
  • upper_bound (int) –

    Desired upper bound.

allocate_grid_field

Fortran source: bmad/modules/bmad_routine_interface.f90

allocate_grid_field(g_field: pybmad._pybmad.GridFieldStructArray1D, n_gf: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine allocate_grid_field

Parameters:
  • g_field (1D array of GridFieldStruct) –
  • n_gf (int) –

allocate_lat_ele_array

Fortran source: bmad/modules/bmad_routine_interface.f90

allocate_lat_ele_array(lat: pybmad._pybmad.LatStruct, upper_bound: typing.SupportsInt | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, do_ramper_slave_setup: bool | None = None) -> None

Wrapper for Fortran routine allocate_lat_ele_array

Parameters:
  • lat (LatStruct) –

    Lattice with element array.

  • upper_bound (int) –

    Optional desired upper bound. Default: 1.3*ubound(ele(:)) or 10 if ele is not allocated.

  • ix_branch (int) –

    Branch index. Default is 0.

  • do_ramper_slave_setup (bool) –

    Default False. If true, setup ramper slaves. Generally this needs to be done if reallocating with a fully formed lattice.

angle_between_polars

Fortran source: bmad/modules/bmad_routine_interface.f90

angle_between_polars(polar1: pybmad._pybmad.SpinPolarStruct, polar2: pybmad._pybmad.SpinPolarStruct) -> float

Wrapper for Fortran routine angle_between_polars

Parameters:
Returns:
  • angle( float ) –

    Angle between the polar vectors

angle_to_canonical_coords

Fortran source: bmad/modules/bmad_routine_interface.f90

angle_to_canonical_coords(orbit: pybmad._pybmad.CoordStruct, coord_type: str | None = None) -> None

Wrapper for Fortran routine angle_to_canonical_coords

Parameters:
  • orbit (CoordStruct) –

    Orbit in angular coordinates. This parameter is an input/output and is modified in-place. As an output, orbit: Orbit in canonical coordinates.

  • coord_type (str) –

    Angular coordinates type '' (default): (x, x' = dx/ds, y, y' = dy/ds, z, pz) 'ZGOUBI': (x, x' = dx/ds, y, y' = dy/ds, dt = -z / (beta * c), pz)

aperture_bookkeeper

Fortran source: bmad/modules/bookkeeper_mod.f90

aperture_bookkeeper(ele: pybmad._pybmad.EleStruct) -> None

Subroutine aperture_bookkeeper (ele)

Routine to calculate aperture limits when ele%attribute_type is set to auto_aperture$

Parameters:
  • ele (EleStruct) –

    Element with aperture. This parameter is an input/output and is modified in-place. As an output, ele: Element with apertures set.

apply_all_rampers

Fortran source: bmad/modules/bmad_routine_interface.f90

apply_all_rampers(lat: pybmad._pybmad.LatStruct) -> bool

Wrapper for Fortran routine apply_all_rampers

Parameters:
  • lat (LatStruct) –

    Lattice. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with rampers applied.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

apply_energy_kick

Fortran source: bmad/modules/bmad_routine_interface.f90

apply_energy_kick(dE: typing.SupportsFloat | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, ddE_dr: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine apply_energy_kick

Parameters:
  • dE (float) –

    Energy change

  • orbit (CoordStruct) –

    Beginning coordinates This parameter is an input/output and is modified in-place. As an output, orbit: coordinates with added dE energy kick.

  • ddE_dr (1D array of float (shape: 2)) –

    real(rp), Derivatives of dE [ddE_dx, ddE_dy].

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before fringe. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix including energy kick.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

apply_patch_to_ptc_fibre

Fortran source: bmad/ptc/ptc_interface_mod.f90

apply_patch_to_ptc_fibre(ele: pybmad._pybmad.EleStruct) -> None

Subroutine apply_patch_to_ptc_fibre (ele)

Routine to take the patch parameters from a Bmad patch element and transfer them to the associated PTC fibre.

Parameters:

apply_rampers_to_slave

Fortran source: bmad/modules/bmad_routine_interface.f90

apply_rampers_to_slave(slave: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine apply_rampers_to_slave

Parameters:
  • slave (EleStruct) –

    Element to apply ramper elements to.

Returns:
  • err_flag( bool ) –

    Set true if there is an error. False otherwise.

array_re_str

Fortran source: bmad/output/write_lattice_file_mod.f90

array_re_str(arr: pybmad._pybmad.RealArray1D, str_out: str, parens_in: str | None = None) -> None

Wrapper for Fortran routine array_re_str

Parameters:
  • arr (1D array of float) –
  • str_out (str) –
  • parens_in (str) –

astra_max_field_reference

Fortran source: bmad/interface/astra_interface_mod.f90

astra_max_field_reference(pt0: pybmad._pybmad.GridFieldPt1Struct, ele: pybmad._pybmad.EleStruct, field_value: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine astra_max_field_reference

Parameters:

at_this_ele_end

Fortran source: bmad/modules/bmad_routine_interface.f90

at_this_ele_end(now_at: typing.SupportsInt | typing.SupportsIndex, where_at: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine at_this_ele_end

Parameters:
  • now_at (int) –

    Which end is under consideration: entrance_end\(, exit_end\), surface\(, or in_between\).

  • where_at (int) –

    Which ends have the aperture or fringe field: entrance_end\(, exit_end\), continuous\(, both_ends\), no_aperture\(, surface\), wall_transition$.

Returns:
  • is_at_this_end( bool ) –

    True if at this end. False otherwise.

attribute_bookkeeper

Fortran source: bmad/modules/bmad_routine_interface.f90

attribute_bookkeeper(ele: pybmad._pybmad.EleStruct, force_bookkeeping: bool | None = None) -> None

Wrapper for Fortran routine attribute_bookkeeper

Parameters:
  • ele (EleStruct) –

    Element with attributes This parameter is an input/output and is modified in-place. As an output, ele: Element with self-consistant attributes.

  • force_bookkeeping (bool) –

    If present and True then force attribute bookkeeping to be done independent of the state of ele.bookkeeping_stat.attributes.

attribute_free

Fortran sources (overloaded):

attribute_free(args, *kwargs) Overloaded function.

  1. attribute_free(ix_ele: typing.SupportsInt | typing.SupportsIndex, attrib_name: str, lat: pybmad._pybmad.LatStruct, err_print_flag: bool | None = None, except_overlay: bool | None = None, dependent_attribs_free: bool | None = None) -> pybmad._pybmad.AttributeFree1

Function attribute_free

Overloaded function for: Function attribute_free1 (ix_ele, attrib_name, lat, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free) Function attribute_free2 (ele, attrib_name, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free) Function attribute_free3 (ix_ele, ix_branch, attrib_name, lat, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free)

Routine to check if an attribute is free to vary.

Attributes that cannot be changed directly include super_slave attributes (since these attributes are controlled by their super_lords) and attributes that are controlled by an overlay.

Also dependent variables such as the angle of a bend cannot be freely variable.

Parameters:
  • ix_ele (int) –

    Index of element in element array.

  • attrib_name (str) –

    Name of the attribute. Assumed upper case.

  • lat (LatStruct) –

    Lattice structure.

  • err_print_flag (bool) –

    If present and False then suppress printing of an error message if attribute is not free.

  • except_overlay (bool) –

    If present and True then an attribute that is controlled by an overlay will be treated as free. This is used by, for example, the create_overlay routine.

  • dependent_attribs_free (bool) –

    If present and True then mark as free attributes that are dependent. For example, if ele.field_master = F, b1_field is dependent upon k1. Default is False. Also fixer Twiss/dispersion/orbit attributes are considered "dependent".

Returns:
  • free( bool ) –

    Set True if attribtute not found or attriubte cannot be changed directly.

  • why_not_free( (int, optional) ) –

    Possibilities are: field_master_dependent$ -> Dependent due to setting of ele.field_master. dependent$ -> Not field_master_dependent$ but value is dependent upon the value of other attributes. does_not_exist$ -> Attribute name is unrecognized or does not exist for the type of element. overlay_slave$ -> Attribute is controlled by an overlay lord. super_slave$ -> Attribute is controlled by element's super_lord. multipass_slave$ -> Attribute is controlled by element's multipass_lord.

  • 2. attribute_free(ele: pybmad._pybmad.EleStruct, attrib_name: str, err_print_flag: bool | None = None, except_overlay: bool | None = None, dependent_attribs_free: bool | None = None) -> pybmad._pybmad.AttributeFree2
  • Function attribute_free
  • Overloaded function for:

    Function attribute_free1 (ix_ele, attrib_name, lat, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free) Function attribute_free2 (ele, attrib_name, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free) Function attribute_free3 (ix_ele, ix_branch, attrib_name, lat, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free)

  • Routine to check if an attribute is free to vary.
  • Attributes that cannot be changed directly include super_slave attributes (since
  • these attributes are controlled by their super_lords) and attributes that
  • are controlled by an overlay.
  • Also dependent variables such as the angle of a bend cannot be

    freely variable.

Parameters:
  • ele (EleStruct) –

    Element containing the attribute

  • attrib_name (str) –

    Name of the attribute. Assumed upper case.

  • err_print_flag (bool) –

    If present and False then suppress printing of an error message if attribute is not free.

  • except_overlay (bool) –

    If present and True then an attribute that is controlled by an overlay will be treated as free. This is used by, for example, the create_overlay routine.

  • dependent_attribs_free (bool) –

    If present and True then mark as free attributes that are dependent. For example, if ele.field_master = F, b1_field is dependent upon k1. Default is False. Also fixer Twiss/dispersion/orbit attributes are considered "dependent".

Returns:
  • free( bool ) –

    Set True if attribtute not found or attriubte cannot be changed directly.

  • why_not_free( (int, optional) ) –

    Possibilities are: field_master_dependent$ -> Dependent due to setting of ele.field_master. dependent$ -> Not field_master_dependent$ but value is dependent upon the value of other attributes. does_not_exist$ -> Attribute name is unrecognized or does not exist for the type of element. overlay_slave$ -> Attribute is controlled by an overlay lord. super_slave$ -> Attribute is controlled by element's super_lord. multipass_slave$ -> Attribute is controlled by element's multipass_lord.

  • 3. attribute_free(ix_ele: typing.SupportsInt | typing.SupportsIndex, ix_branch: typing.SupportsInt | typing.SupportsIndex, attrib_name: str, lat: pybmad._pybmad.LatStruct, err_print_flag: bool | None = None, except_overlay: bool | None = None, dependent_attribs_free: bool | None = None) -> pybmad._pybmad.AttributeFree3
  • Function attribute_free
  • Overloaded function for:

    Function attribute_free1 (ix_ele, attrib_name, lat, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free) Function attribute_free2 (ele, attrib_name, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free) Function attribute_free3 (ix_ele, ix_branch, attrib_name, lat, err_print_flag, except_overlay, dependent_attribs_free, why_not_free) result (free)

  • Routine to check if an attribute is free to vary.
  • Attributes that cannot be changed directly include super_slave attributes (since
  • these attributes are controlled by their super_lords) and attributes that
  • are controlled by an overlay.
  • Also dependent variables such as the angle of a bend cannot be

    freely variable.

Parameters:
  • ix_ele (int) –

    Index of element in element array.

  • ix_branch (int) –

    Branch index of element.

  • attrib_name (str) –

    Name of the attribute. Assumed upper case.

  • lat (LatStruct) –

    Lattice structure.

  • err_print_flag (bool) –

    If present and False then suppress printing of an error message if attribute is not free.

  • except_overlay (bool) –

    If present and True then an attribute that is controlled by an overlay will be treated as free. This is used by, for example, the create_overlay routine.

  • dependent_attribs_free (bool) –

    If present and True then mark as free attributes that are dependent. For example, if ele.field_master = F, b1_field is dependent upon k1. Default is False. Also fixer Twiss/dispersion/orbit attributes are considered "dependent".

Returns:
  • free( bool ) –

    Set True if attribtute not found or attriubte cannot be changed directly.

  • why_not_free( (int, optional) ) –

    Possibilities are: field_master_dependent$ -> Dependent due to setting of ele.field_master. dependent$ -> Not field_master_dependent$ but value is dependent upon the value of other attributes. does_not_exist$ -> Attribute name is unrecognized or does not exist for the type of element. overlay_slave$ -> Attribute is controlled by an overlay lord. super_slave$ -> Attribute is controlled by element's super_lord. multipass_slave$ -> Attribute is controlled by element's multipass_lord.

attribute_index

Fortran sources (overloaded):

attribute_index(args, *kwargs) Overloaded function.

  1. attribute_index(ele: pybmad._pybmad.EleStruct, name: str, can_abbreviate: bool | None = None, print_error: bool | None = None) -> pybmad._pybmad.AttributeIndex1

Function attribute_index (...) result (attrib_index)

Function to return the index of a attribute for a given BMAD element type and the name of the attribute. Abbreviations are by default permitted but must be at least 3 characters. Exception: overlay and group varialbe names may not be abbreviated.

This routine is an overloaded name for: attribute_index1 (ele, name, full_name, can_abbreviate, print_error) result (attrib_index) attribute_index2 (key, name, full_name, can_abbreviate, print_error) result (attrib_index)

Parameters:
  • ele (EleStruct) –

    attribute_index will restrict the name search to valid attributes of the given element.

  • name (str) –

    Attribute name. Must be uppercase.

  • can_abbreviate (bool) –

    Can abbreviate names? Default is True.

  • print_error (bool) –

    Default True. If false, do not print error message.

Returns:
  • attrib_index( int ) –

    Index of the attribute. If the attribute name is not appropriate then 0 will be returned. ix -> k1$

  • full_name( (str, optional) ) –

    Non-abbreviated name.

Notes

If ele%key or key = 0 -> Entire name table will be searched. See also: has_attribute attribute_info attribute_name

  1. attribute_index(key: typing.SupportsInt | typing.SupportsIndex, name: str, can_abbreviate: bool | None = None, print_error: bool | None = None) -> pybmad._pybmad.AttributeIndex2

Function attribute_index (...) result (attrib_index)

Function to return the index of a attribute for a given BMAD element type and the name of the attribute. Abbreviations are by default permitted but must be at least 3 characters. Exception: overlay and group varialbe names may not be abbreviated.

This routine is an overloaded name for: attribute_index1 (ele, name, full_name, can_abbreviate, print_error) result (attrib_index) attribute_index2 (key, name, full_name, can_abbreviate, print_error) result (attrib_index)

Parameters:
  • key (int) –

    Equivalent to ele.key.

  • name (str) –

    Attribute name. Must be uppercase.

  • can_abbreviate (bool) –

    Can abbreviate names? Default is True.

  • print_error (bool) –

    Default True. If false, do not print error message.

Returns:
  • attrib_index( int ) –

    Index of the attribute. If the attribute name is not appropriate then 0 will be returned. ix -> k1$

  • full_name( (str, optional) ) –

    Non-abbreviated name.

Notes

If ele%key or key = 0 -> Entire name table will be searched. See also: has_attribute attribute_info attribute_name

attribute_name

Fortran sources (overloaded):

attribute_name(args, *kwargs) Overloaded function.

  1. attribute_name(key: typing.SupportsInt | typing.SupportsIndex, ix_att: typing.SupportsInt | typing.SupportsIndex, show_private: bool | None = None) -> str

Function attribute_name (...) result (attrib_name)

Function to return the name of an attribute for a particular type of Bmad element.

This routine is an overloaded name for: attribute_name1 (ele, ix_att, show_private) result (attrib_name) attribute_name2 (key, ix_att, show_private) result (attrib_name)

Note: attribute_name (key, ix_att) is not able to handle overlay/group control variables. Use attributge_name (ele, ix_att) is this is needed.

Parameters:
  • key (int) –

    Key name of element type (e.g. sbend$, etc.)

  • ix_att (int) –

    Index of attribute (e.g. k1$)

  • show_private (bool) –

    If False (default) return null_name$ for private attributes.

Returns:
  • attrib_name( str ) –

    Name of attribute. First character is a "!" if there is a problem. Will always be upper case (even with private attributes). = "!BAD ELE KEY" .key is invalid = "!BAD INDEX" ix_att is invalid (out of range). = "!NULL" (null_name$) ix_att does not correspond to an attribute or is private. name -> "K1"

  • 2. attribute_name(ele: pybmad._pybmad.EleStruct, ix_att: typing.SupportsInt | typing.SupportsIndex, show_private: bool | None = None) -> str
  • Function attribute_name (...) result (attrib_name)
  • Function to return the name of an attribute for a particular type of
  • Bmad element.
  • This routine is an overloaded name for:

    attribute_name1 (ele, ix_att, show_private) result (attrib_name) attribute_name2 (key, ix_att, show_private) result (attrib_name)

  • Note( attribute_name (key, ix_att) is not able to handle overlay/group control variables. ) –
  • Use attributge_name (ele, ix_att) is this is needed.
Parameters:
  • ele (EleStruct) –
  • ix_att (int) –

    Index of attribute (e.g. k1$)

  • show_private (bool) –

    If False (default) return null_name$ for private attributes.

Returns:
  • attrib_name( str ) –

    Name of attribute. First character is a "!" if there is a problem. Will always be upper case (even with private attributes). = "!BAD ELE KEY" .key is invalid = "!BAD INDEX" ix_att is invalid (out of range). = "!NULL" (null_name$) ix_att does not correspond to an attribute or is private. name -> "K1"

attribute_type

Fortran source: bmad/modules/attribute_mod.f90

attribute_type(attrib_name: str, ele: pybmad._pybmad.EleStruct | None = None) -> int

Function attribute_type (attrib_name, ele) result (attrib_type)

Routine to return the logical type of an attribute.

A "switch" attribute is an attribute whose value corresponds to some string. For example, the "COUPLER_AT" attirbute with value 1 corresponds to "ENTRANCE_END", etc.

A "struct" attribute is an attribute that is the name for a "structure". For example, CARTESIAN_MAP is the name of the structure hoding a Cartesian map.

If attrib_name corresponds to a switch attribute, The routine switch_attrib_value_name can be used to print the name corresponding to the attribute's value.

Note: The "storage type" of an attribute is different from the "logical type" returned by this routine. For example, the logical type of attribute "n_slice" is integer. However, the value of "n_slice" is stored as a real number in the ele_struct [in ele%value(n_slice$)].

Parameters:
  • attrib_name (str) –

    Name of the attribute. Must be upper case.

  • ele (EleStruct) –

    Element associated with the attribute. Needed if attrib_name can correspond to an overlay or group variable.

Returns:
  • attrib_type( int ) –

    Attribute type: is_string\(, is_logical\), is_integer\(, is_real\), is_switch\(, is_struct\), is_species$ or invalid_name$ Note: An overlay or group variable will be marked invalid_name$ if ele is missing.

attribute_units

Fortran source: bmad/modules/attribute_mod.f90

attribute_units(attrib_name: str, unrecognized_units: str | None = None) -> str

Function attribute_units (attrib_name, unrecognized_units) result (attrib_units)

Routine to return the units associated with an attribute. Example: attrib_units('P0C') -> 'eV'

Parameters:
  • attrib_name (str) –

    Name of the attribute. Must be upper case.

  • unrecognized_units (str) –

    String to use if the attribute name is unrecognized. Note: Non-real attributes (EG: 'TRACKING_METHOD') are not recognized. Default is ""

Returns:
  • attrib_units( str ) –

    Units associated with the attribute.

autoscale_phase_and_amp

Fortran source: bmad/modules/bmad_routine_interface.f90

autoscale_phase_and_amp(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, scale_phase: bool | None = None, scale_amp: bool | None = None, call_bookkeeper: bool | None = None) -> bool

Wrapper for Fortran routine autoscale_phase_and_amp

Parameters:
  • ele (EleStruct) –

    RF element or e_gun. This parameter is an input/output and is modified in-place. As an output, ele: element with phase and amplitude adjusted.

  • param (LatParamStruct) –

    lattice parameters

  • scale_phase (bool) –

    Scale the phase? See above.

  • scale_amp (bool) –

    Scale the amplitude? See above.

  • call_bookkeeper (bool) –

    Call lattice_bookkeeper at end? Default is True.

Returns:
  • err_flag( bool ) –

    Logical, Set true if there is an error. False otherwise.

average_twiss

Fortran source: bmad/modules/bmad_routine_interface.f90

average_twiss(frac1: typing.SupportsFloat | typing.SupportsIndex, twiss1: pybmad._pybmad.TwissStruct, twiss2: pybmad._pybmad.TwissStruct) -> pybmad._pybmad.TwissStruct

Wrapper for Fortran routine average_twiss

Parameters:
  • frac1 (float) –

    Fraction of twiss1 to use in the average.

  • twiss1 (TwissStruct) –

    Twiss parameters to average.

  • twiss2 (TwissStruct) –
Returns:

bbi_kick

Fortran source: bmad/modules/bmad_routine_interface.f90

bbi_kick(x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, sigma: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], linear_kick: bool | None = None) -> pybmad._pybmad.BbiKick

Wrapper for Fortran routine bbi_kick

Parameters:
  • x (float) –

    X coordinate.

  • y (float) –

    Y coordinate.

  • sigma (1D array of float (shape: 2)) –

    Beam (x,y) sigmas.

  • linear_kick (bool) –

    Default False. If present and True, kick and dnk are computed using the extrapolated kick from the linear region.

Returns:
  • nk( 1D array of float (shape: 2) ) –

    Normalized, dimensionless kick component. In terms of the the actual kick: nk = [kick_x / (xi_x * sigma_x / beta_x), kick_y / (xi_y * sigma_y / beta_y) nk = -4 * pi * [x/sigma_x, y/sigma_y] in the linear region

  • dnk( 2D array of float (shape: 2,2) ) –

    derivatives of nk. EG: dnk(2,1) = nk(2)/dx

bbi_slice_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

bbi_slice_calc(ele: pybmad._pybmad.EleStruct, n_slice: typing.SupportsInt | typing.SupportsIndex, z_slice: pybmad._pybmad.RealArray1D) -> None

Wrapper for Fortran routine bbi_slice_calc

Parameters:
  • ele (EleStruct) –

    beambeam element

  • n_slice (int) –

    Number of slices

  • z_slice (1D array of float) –

    Array of slice positions 1:n_slice. zero padded for indexes greater than n_slice

beam_envelope_ibs

Fortran source: bmad/multiparticle/envelope_mod.f90

beam_envelope_ibs(sigma_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], tail_cut: bool, tau: typing.SupportsFloat | typing.SupportsIndex, energy: typing.SupportsFloat | typing.SupportsIndex, n_part: typing.SupportsFloat | typing.SupportsIndex, species: typing.SupportsInt | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"]

Subroutine beam_envelope_ibs(sigma_mat, ibs_mat, tail_cut, tau, energy, n_part, species)

This is a sigma matrix based IBS calculation. It takes the beam sigma matrix and returns a matrix with changes to the 2nd order moments due to IBS.

Use ibs_mat to change the sigma matrix like this: sigma_matrix_updated = sigma_matrix + ibs_mat*element_length See subroutine transport_with_sr_and_ibs in this module.

Parameters:
  • sigma_mat (2D array of float (shape: 6,6)) –

    beam sigma_matrix at element entrance

  • tail_cut (bool) –

    If true, then apply tail cut to coulomb logarithm.

  • tau (float) –

    horizontal betatron damping rate. Needed if tail_cut is true.

  • energy (float) –

    beam energy in eV

  • n_part (float) –

    number of particles in the bunch

  • species (int) –

    Partical species.

Returns:
  • ibs_mat( 2D array of float (shape: 6,6) ) –

    changes in 2nd order moments due to IBS are ibs_mat*element_length

beam_equal_beam

Fortran source: bmad/modules/bmad_routine_interface.f90

beam_equal_beam(beam1: pybmad._pybmad.BeamStruct, beam2: pybmad._pybmad.BeamStruct) -> None

Wrapper for Fortran routine beam_equal_beam

Parameters:

beam_init_setup

Fortran source: bmad/modules/bmad_routine_interface.f90

beam_init_setup(beam_init_in: pybmad._pybmad.BeamInitStruct, ele: pybmad._pybmad.EleStruct, species: typing.SupportsInt | typing.SupportsIndex, modes: pybmad._pybmad.NormalModesStruct | None = None) -> pybmad._pybmad.BeamInitSetup

Wrapper for Fortran routine beam_init_setup

Parameters:
Returns:
  • beam_init_set( BeamInitStruct ) –

    See above.

  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

beam_tilts

Fortran source: bmad/modules/mode3_mod.f90

beam_tilts(S: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.BeamTilts

Subroutine beam_tilts(S, angle_xy, angle_xz, angle_yz, angle_xpz, angle_ypz)

Given a 6x6 matrix of second-order moments, this routine returns the beam tilts.

angle_xy is obtained from the projection of the beam envelop into the xy plane. The angle is that between the major axis of the projected beam envelope and the +x axis. Positive angles are measured towards the +y axis.

angle_xz is obtained from the projection of the beam envelop into the xy plane. The angle is that between the major axis of the projected beam envelope and the +z axis. Positive angles are measured towards the +x axis.

angle_yz is obtained from the projection of the beam envelop into the yz plane. The angle is that between the major axis of the projected beam envelope and the +z axis. Positive angles are measured towards the +y axis.

Parameters:
  • S (2D array of float (shape: 6,6)) –

    matrix of second order moments of beam envelope

Returns:
  • angle_xy( float ) –

    transverse tilt of beam envelope

  • angle_xz( float ) –

    horizontal crabbing of beam envelope

  • angle_yz( float ) –

    vertical crabbing of beam envelope

  • angle_xpz( float ) –

    x-pz coupling

  • angle_ypz( float ) –

    y-pz coupling

beambeam_fibre_setup

Fortran source: bmad/ptc/ptc_interface_mod.f90

beambeam_fibre_setup(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.Fibre

Subroutine beambeam_fibre_setup(ele, ptc_fibre)

Routine to setup a fibre to handle the beambeam interaction.

Parameters:
Returns:
  • ptc_fibre( Fibre ) –

    Corresponding PTC fibre.

bend_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

bend_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orb: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None, track_spin: bool | None = None) -> None

Subroutine bend_edge_kick (ele, param, particle_at, orb, mat6, make_matrix, track_spin)

Subroutine to track through the edge field of an sbend. This routine is called by apply_element_edge_kick only.

Parameters:
  • ele (EleStruct) –

    SBend element.

  • param (LatParamStruct) –

    Rel charge.

  • particle_at (int) –

    first_track_edge\(, or second_track_edge\).

  • orb (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orb: Coords after tracking.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before fringe. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix including fringe.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

  • track_spin (bool) –

    If True then track the spin through the edge fields. Default: False.

bend_exact_multipole_field

Fortran source: bmad/modules/bmad_routine_interface.f90

bend_exact_multipole_field(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct, local_ref_frame: bool, calc_dfield: bool | None = None, calc_potential: bool | None = None) -> pybmad._pybmad.EmFieldStruct

Wrapper for Fortran routine bend_exact_multipole_field

Parameters:
  • ele (EleStruct) –

    Bend element.

  • param (LatParamStruct) –

    Lattice branch parameters.

  • orbit (CoordStruct) –

    particle position.

  • local_ref_frame (bool) –

    Is the particle position in the local element ref frame (as opposed to the lab frame)?

  • calc_dfield (bool) –

    If present and True then calculate the field derivatives.

  • calc_potential (bool) –

    Calc electric and magnetic potentials? Default is false.

Returns:

bend_length_has_been_set

Fortran source: bmad/modules/bmad_routine_interface.f90

bend_length_has_been_set(ele: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine bend_length_has_been_set

Parameters:
Returns:
  • is_set( bool ) –

    Note: will be set True for non-bend elements.

bend_photon_e_rel_init

Fortran source: bmad/photon/photon_init_mod.f90

bend_photon_e_rel_init(r_in: typing.SupportsFloat | typing.SupportsIndex | None = None) -> float

Function bend_photon_e_rel_init (r_in) result (E_rel)

Routine to convert a random number in the interval [0,1] to a photon energy. The photon probability spectrum is: P(E_rel) = (3 / (5 * Pi)) * Integral_{E_rel}^{Infty} K_{5/3}(x) dx Where P(E_rel)) = Probability of finding a photon at relative energy E_rel. E_rel = Relative photon energy: E / E_crit, E_crit = Critical energy. K_{5/3} = Modified Bessel function.

Notice that the P(E) is not the same as the distribution radiation energy since the photons must be energy weighted.

There is a cut-off built into the calculation so that E_rel will be in the range [0, 31.4]. The error in neglecting photons with E_rel > 31.4 translates to neglecting one photon for every 10^15 generated. If r_in is present: r_in = 0 => E_rel = 0 r_in = 1 => E_rel = 31.4

Parameters:
  • r_in (float) –

    Integrated probability in the range [0,1]. If not present, a random number will be used.

Returns:
  • E_rel( float ) –

    Relative photon energy E/E_crit.

bend_photon_energy_integ_prob

Fortran source: bmad/photon/photon_init_mod.f90

bend_photon_energy_integ_prob(E_photon: typing.SupportsFloat | typing.SupportsIndex, g_bend: typing.SupportsFloat | typing.SupportsIndex, gamma: typing.SupportsFloat | typing.SupportsIndex) -> float

Function bend_photon_energy_integ_prob (E_photon, g_bend, gamma) result (integ_prob)

Routine to find the integrated probability corresponding to emitting a photon from a bend in the range [0, E_photon].

Parameters:
  • E_photon (float) –

    Photon energy.

  • g_bend (float) –

    1/rho bending strength.

  • gamma (float) –

    Relativistic gamma factor of generating charged particle.

Returns:
  • integ_prob( float ) –

    Integrated probability. Will be in the range [0, 1].

bend_photon_energy_normalized_probability

Fortran source: bmad/photon/photon_init_mod.f90

bend_photon_energy_normalized_probability(E_rel: typing.SupportsFloat | typing.SupportsIndex) -> float

Function bend_photon_energy_normalized_probability (E_rel) result (prob)

Routine to return the normalized probability that a photon will be emitted in a bend with energy E_rel relative to the critical energy. The probability is normalized such that Integral[0,Infinity] dE_rel P(E_rel) = 1

Parameters:
  • E_rel (float) –

    Photon energy relative to the critical energy.

Returns:
  • prob( float ) –

    Normalized probability.

bend_photon_init

Fortran source: bmad/photon/photon_init_mod.f90

bend_photon_init(g_bend_x: typing.SupportsFloat | typing.SupportsIndex, g_bend_y: typing.SupportsFloat | typing.SupportsIndex, gamma: typing.SupportsFloat | typing.SupportsIndex, E_min: typing.SupportsFloat | typing.SupportsIndex | None = None, E_max: typing.SupportsFloat | typing.SupportsIndex | None = None, E_integ_prob: typing.SupportsFloat | typing.SupportsIndex | None = None, vert_angle_min: typing.SupportsFloat | typing.SupportsIndex | None = None, vert_angle_max: typing.SupportsFloat | typing.SupportsIndex | None = None, vert_angle_symmetric: bool | None = None, emit_probability: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.CoordStruct

Subroutine bend_photon_init (g_bend_x, g_bend_y, gamma, orbit, E_min, E_max, E_integ_prob, vert_angle_min, vert_angle_max, vert_angle_symmetric, emit_probability)

Routine to initalize a photon for dipole bends and wigglers (but not undulators). The photon is initialized using the standard formulas for bending radiation.

The energy of the photon is calculated in one of two ways:

1) If E_integ_prob is present and non-negative, the photon energy E will be such that the integrated probability [E_min, E] relative to the integrated probability in the range [E_min, E_max] is E_integ_prob. That is, E_integ_prob can be used to to give a set of photon energies equally spaced in terms of the integrated probability distribution.

2) If E_integ_prob is not present, or is negative, the photon energy is chosen at random in the range [E_min, E_max].

An E_integ_prob of zero means that the generated photon will have energy E_min. An E_integ_prob of one means that the generated photon will have energy E_max.

The photon's polarization, will have unit amplitude.

This routine assumes that the emitting charged particle is on-axis and moving in the forward direction. To correct for the actual charged particle postion use the routine absolute_photon_position

Parameters:
  • g_bend_x (float) –

    Bending 1/rho component in horizontal plane.

  • g_bend_y (float) –

    Bending 1/rho component in vertical plane.

  • gamma (float) –

    Relativistic gamma factor of generating charged particle.

  • E_min (float) –

    Minimum photon energy. Default is zero. Ignored if negative.

  • E_max (float) –

    Maximum photon energy. Default is Infinity. Ignored if negative. If non-positive then E_max will be taken to be Infinity.

  • E_integ_prob (float) –

    , optional :: integrated energy probability. See above. If E_integ_prob is non-negative, it must be in the range [0, 1].

  • vert_angle_min (float) –

    Minimum vertical angle to emit a photon. -pi/2 is used if argument not present or if argument is less than -pi/2.

  • vert_angle_max (float) –

    Maximum vertical angle to emit a photon. pi/2 is used if argument not present or if argument is greater than pi/2.

  • vert_angle_symmetric (bool) –

    Default is False. If True, photons will be emitted in the range [-vert_angle_max, -vert_angle_min] as well as the range [vert_angle_min, vert_angle_max]. In this case vert_angle_min/max must be positive.

  • emit_probability (float) –

    Probability of emitting a photon in the range [E_min, E_max] or in the vertical angular range given. The probability is normalized so that the probability of emitting if no ranges are given is 1.

Returns:

bend_photon_polarization_init

Fortran source: bmad/photon/photon_init_mod.f90

bend_photon_polarization_init(g_bend_x: typing.SupportsFloat | typing.SupportsIndex, g_bend_y: typing.SupportsFloat | typing.SupportsIndex, E_rel: typing.SupportsFloat | typing.SupportsIndex, gamma_phi: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.CoordStruct

Subroutine bend_photon_polarization_init (g_bend_x, g_bend_y, E_rel, gamma_phi, orbit)

Routine to set a photon's polarization. The photon's polarization will be either in the plane of the bend or out of the plane and the magnitude will be 1.

Parameters:
  • g_bend_x (float) –

    Bending 1/rho component in horizontal plane.

  • g_bend_y (float) –

    Bending 1/rho component in vertical plane.

  • E_rel (float) –

    Relative photon energy E/E_crit.

  • gamma_phi (float) –

    gamma * phi where gamma is the beam relativistic factor and phi is the vertical photon angle (in radians).

Returns:

bend_photon_vert_angle_init

Fortran source: bmad/photon/photon_init_mod.f90

bend_photon_vert_angle_init(E_rel: typing.SupportsFloat | typing.SupportsIndex, gamma: typing.SupportsFloat | typing.SupportsIndex, r_in: typing.SupportsFloat | typing.SupportsIndex | None = None, invert: bool | None = None) -> float

Function bend_photon_vert_angle_init (E_rel, gamma, r_in, invert) result (phi)

Routine to convert an integrated probability to a vertical angle for emitting a photon from a bend. The integrated probability is in the range [0,1] with 0 corresponding to a phi = -pi/2 and integrated probability of 1 corresponding to phi = pi/2.

Parameters:
  • E_rel (float) –

    Relative photon energy E/E_crit.

  • gamma (float) –

    beam relativistic factor

  • r_in (float) –

    Integrated probability in the range [0,1]. If not present, a random number will be used.

  • invert (bool) –

    If True then take r_in as the inverse integrated probability with inverted probability = 1 - probability. This is useful to avoid round-off errors when for looking at the tail of the distribution where the integrated prob is very close to 1 and small deviations can have large effects. Default is False.

Returns:
  • phi( float ) –

    The photon vertical emission angle (in radians). Note: phi is an increasing monotonic function of r_in.

bend_shift

Fortran source: bmad/modules/bmad_routine_interface.f90

bend_shift(position1: pybmad._pybmad.FloorPositionStruct, g: typing.SupportsFloat | typing.SupportsIndex, delta_s: typing.SupportsFloat | typing.SupportsIndex, ref_tilt: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.BendShift

Wrapper for Fortran routine bend_shift

Parameters:
  • position1 (FloorPositionStruct) –

    Position of particle in inital coordinate frame.

  • g (float) –

    Curvature (1/rho)

  • delta_s (float) –

    S-position of final frame relative to the initial frame.

  • ref_tilt (float) –

    ref_tilt. Default: 0

Returns:
  • position2( FloorPositionStruct ) –

    particle coordinates relative to the final frame.

  • w_mat( 2D array of float (shape: 3,3), optional ) –

    W matrix used in the transformation

bend_vert_angle_integ_prob

Fortran source: bmad/photon/photon_init_mod.f90

bend_vert_angle_integ_prob(vert_angle: typing.SupportsFloat | typing.SupportsIndex, E_rel: typing.SupportsFloat | typing.SupportsIndex, gamma: typing.SupportsFloat | typing.SupportsIndex) -> float

Function bend_vert_angle_integ_prob (vert_angle, E_rel, gamma) result (integ_prob)

Routine to find the integrated probability corresponding to emitting a photon from a bend and with relative energy E_rel in the vertical angle range [-pi/2, vert_angle/2].

Note: vert_angle is allowed to be out of the range [-pi/2, pi/2]. In this case, integ_prob will be set to 0 or 1 as appropriate.

Parameters:
  • vert_angle (float) –

    Vertical angle.

  • E_rel (float) –

    Relative photon energy E/E_crit.

  • gamma (float) –

    Relativistic gamma factor of generating charged particle.

Returns:
  • integ_prob( float ) –

    Integrated probability. Will be in the range [0, 1].

bl_via_vlassov

Fortran source: bmad/multiparticle/ibs_mod.f90

bl_via_vlassov(current: typing.SupportsFloat | typing.SupportsIndex, alpha: typing.SupportsFloat | typing.SupportsIndex, Energy: typing.SupportsFloat | typing.SupportsIndex, sigma_p: typing.SupportsFloat | typing.SupportsIndex, Vrf: typing.SupportsFloat | typing.SupportsIndex, omega: typing.SupportsFloat | typing.SupportsIndex, U0: typing.SupportsFloat | typing.SupportsIndex, circ: typing.SupportsFloat | typing.SupportsIndex, R: typing.SupportsFloat | typing.SupportsIndex, L: typing.SupportsFloat | typing.SupportsIndex) -> float

Subroutine bl_via_vlassov(current,alpha,Energy,sigma_p,Vrf,omega,U0,circ,R,L,sigma_z)

This is a frontend for get_bl_from_fwhm from longitudinal_profile_mod. See longitudinal_profile_mod for details. In short, this implements a model of potential well distortion based on the Vlassov equation which uses an effective Resistive, Inductive, and Capacitive impedance.

Parameters:
  • current (float) –

    Beam current in amps

  • alpha (float) –

    Momentum compaction

  • Energy (float) –

    beam energy

  • sigma_p (float) –

    energy spread

  • Vrf (float) –

    total RF voltage in Volts

  • omega (float) –

    rf frequency in radians/s

  • U0 (float) –

    energy loss per turn (eV)

  • circ (float) –

    circumpherence

  • R (float) –

    Resistive part of effective impedance

  • L (float) –

    Inductive part of effective impedance

Returns:
  • sigma_z( float ) –

    Bunch length. FWHM/TwoRootTwoLogTwo from bunch profile

bmad_parser

Fortran source: bmad/modules/bmad_routine_interface.f90

bmad_parser(lat_file: str, make_mats6: bool | None = None, use_line: str | None = None) -> pybmad._pybmad.BmadParser

Wrapper for Fortran routine bmad_parser

Parameters:
  • lat_file (str) –

    Name of the input file.

  • make_mats6 (bool) –

    Compute the 6x6 transport matrices for the Elements? Default is True. Do not set False unless you know what you are doing.

  • use_line (str) –

    If present and not blank, override the use statement in the lattice file and use use_line instead.

Returns:
  • lat( LatStruct ) –

    Lat structure. See bmad_struct.f90 for more details.

  • digested_read_ok( (bool, optional) ) –

    Set True if the digested file was successfully read. False otherwise.

  • err_flag( (bool, optional) ) –

    Set true if there is an error, false otherwise. Note: err_flag does not include errors in lat_make_mat6 since if there is a match element, there is an error raised since the Twiss parameters have not been set but this is expected.

  • parse_lat( (LatStruct, optional) ) –

    List of elements used to construct the lattice. Useful if bmad_parser2 will be called. See bmad_parser2 documentation.

bmad_parser2

Fortran source: bmad/modules/bmad_routine_interface.f90

bmad_parser2(lat_file: str, lat: pybmad._pybmad.LatStruct, orbit: pybmad._pybmad.CoordStructArray1D | None = None, make_mats6: bool | None = None, err_flag: bool | None = None, parse_lat: pybmad._pybmad.LatStruct | None = None) -> None

Wrapper for Fortran routine bmad_parser2

Parameters:
  • lat_file (str) –

    Input file name.

  • lat (LatStruct) –

    lattice with existing layout. This parameter is an input/output and is modified in-place. As an output, lat: lattice with modifications.

  • orbit (1D array of CoordStruct) –

    closed orbit for when bmad_parser2 calls lat_make_mat6

  • make_mats6 (bool) –

    Make the 6x6 transport matrices for then Elements? Default is True.

  • err_flag (bool) –
  • parse_lat (LatStruct) –

    Used by bmad_parser to pass to bmad_parser2 a list of elements that were defined in the lattice file but not used. This is useful in preventing errors being generated if group/overlay elements definded by lat_file refer to unused slaves in parse_lat.

bmad_patch_parameters_to_ptc

Fortran source: bmad/ptc/ptc_interface_mod.f90

bmad_patch_parameters_to_ptc(ang: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], exi: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"]) -> None

Wrapper for Fortran routine bmad_patch_parameters_to_ptc

Parameters:
  • ang (1D array of float (shape: 3)) –
  • exi (2D array of float (shape: 3,3)) –

bp_set_ran_status

Fortran source: bmad/parsing/bmad_parser_mod.f90

bp_set_ran_status() -> None

Wrapper for Fortran routine bp_set_ran_status

branch_equal_branch

Fortran source: bmad/modules/bmad_routine_interface.f90

branch_equal_branch(branch1: pybmad._pybmad.BranchStruct, branch2: pybmad._pybmad.BranchStruct) -> None

Wrapper for Fortran routine branch_equal_branch

Parameters:

branch_name

Fortran source: bmad/modules/bmad_routine_interface.f90

branch_name(branch: pybmad._pybmad.BranchStruct) -> str

Wrapper for Fortran routine branch_name

Parameters:
Returns:
  • name( str ) –

    Encoded name

branch_to_ptc_m_u

Fortran source: bmad/ptc/ptc_layout_mod.f90

branch_to_ptc_m_u(branch: pybmad._pybmad.BranchStruct) -> None

Subroutine branch_to_ptc_m_u (branch)

Subroutine to create a PTC layout from a Bmad lattice branch. Note: If lat_to_ptc_layout has already been setup, you should first do a call kill_ptc_layouts(lat) This deallocates the pointers in PTC

Note: If not already done, before you call this routine you need to first call: call set_ptc (...) [This is normally done in bmad_parser.]

Note: If a Bmad element is using a hard edge model (EG: RFcavity element), there will be three corresponding PTC fibre elements: (drift, RF. drift) for example. In this case, ele%ptc_fibre will be set to point to the last PTC fibre. That is the exit end of ele will correspond to the exit end of ele%ptc_fibre.

Parameters:
  • branch (BranchStruct) –

    Input branch. This parameter is an input/output and is modified in-place. As an output, branch: Pointers to generated layouts. This parameter is an input/output and is modified in-place. As an output, branch: Pointer to PTC fibres

bunch_equal_bunch

Fortran source: bmad/modules/bmad_routine_interface.f90

bunch_equal_bunch(bunch1: pybmad._pybmad.BunchStruct, bunch2: pybmad._pybmad.BunchStruct) -> None

Wrapper for Fortran routine bunch_equal_bunch

Parameters:

c_to_cbar

Fortran source: bmad/modules/bmad_routine_interface.f90

c_to_cbar(ele: pybmad._pybmad.EleStruct) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(2)"]], "FixedSize(2)"]

Wrapper for Fortran routine c_to_cbar

Parameters:
  • ele (EleStruct) –

    Element with C matrix and Twiss parameters.

Returns:
  • cbar_mat( 2D array of float (shape: 2,2) ) –

    Cbar matrix.

calc_bunch_params

Fortran source: bmad/multiparticle/beam_utils.f90

calc_bunch_params(bunch: pybmad._pybmad.BunchStruct, print_err: bool | None = None, is_time_coords: bool | None = None, ele: pybmad._pybmad.EleStruct | None = None) -> pybmad._pybmad.CalcBunchParams

Subroutine calc_bunch_params (bunch, bunch_params, error, print_err, n_mat, is_time_coords, ele)

Finds all bunch parameters defined in bunch_params_struct, both normal-mode and projected. Projected parameters are found purely from the geometrical distribution of the beam. Normal-Mode parameters are found using the method developed in: "Alternate approach to general coupled linear optics" A. Wolski, PRST AB 9, 024001 (2006)

Note: If less than two particle remain then the various parameters will be set to zero.

Parameters:
  • bunch (BunchStruct) –

    Bunch_struct

  • print_err (bool) –

    If present and False then suppress "no eigen-system found" messages.

  • is_time_coords (bool) –

    Are particle coords using time coords. Default is False.

  • ele (EleStruct) –

    Element being tracked through. Must be present if is_time_coords = True.

Returns:
  • bunch_params( BunchParamsStruct ) –
  • error( bool ) –

    Set True if there is an error.

  • n_mat( 2D array of float (shape: 6,6), optional ) –

    N matrix defined in Wolski Eq 44 and used to convert from action-angle coords to lab coords (Wolski Eq 51.).

calc_bunch_params_slice

Fortran source: bmad/multiparticle/beam_utils.f90

calc_bunch_params_slice(bunch: pybmad._pybmad.BunchStruct, bunch_params: pybmad._pybmad.BunchParamsStruct, plane: typing.SupportsInt | typing.SupportsIndex, slice_center: typing.SupportsFloat | typing.SupportsIndex, slice_spread: typing.SupportsFloat | typing.SupportsIndex, print_err: bool | None = None, is_time_coords: bool | None = None, ele: pybmad._pybmad.EleStruct | None = None) -> bool

subroutine calc_bunch_params_slice (bunch, bunch_params, plane, slice_center, slice_spread, err, print_err, is_time_coords, ele)

Finds bunch parameters for a slice of the beam.

Parameters:
  • bunch (BunchStruct) –

    bunch_struct

  • plane (int) –

    plane to slice through (x\(, px\), & etc...)

  • slice_center (float) –

    Center to take slice about

  • slice_spread (float) –

    +/- spread in slice about center.

  • print_err (bool) –

    If present and False then suppress "no eigen-system found" messages.

  • is_time_coords (bool) –

    Default is False. If True, input bunch is using time coordinates in which case there will be a conversion to s-coords before bunch_params are computed.

  • ele (EleStruct) –

    Element being tracked through. Must be present if is_time_coords = True.

Returns:
  • err( bool ) –

    Set True if there is an error.

calc_bunch_params_z_slice

Fortran source: bmad/multiparticle/beam_utils.f90

calc_bunch_params_z_slice(bunch: pybmad._pybmad.BunchStruct, bunch_params: pybmad._pybmad.BunchParamsStruct, slice_bounds: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], print_err: bool | None = None, is_time_coords: bool | None = None, ele: pybmad._pybmad.EleStruct | None = None) -> bool

subroutine calc_bunch_params_z_slice (bunch, bunch_params, slice_bounds, err, print_err, is_time_coords, ele)

Finds bunch parameters for a slice of the beam.

The slice is specified in terms of percentage of particles ordered by z-position. For example, slice_bounds = [0.0, 0.5] specifies the trailing half of the bunch

Parameters:
  • bunch (BunchStruct) –

    bunch_struct

  • slice_bounds (1D array of float (shape: 2)) –

    Slice bounds in percentage of particles ordered by z-position. 0.0 is the back of the bunch and 1.0 is the front of the bunch.

  • print_err (bool) –

    If present and False then suppress "no eigen-system found" messages.

  • is_time_coords (bool) –

    Default is False. If True, input bunch is using time coordinates in which case there will be a conversion to s-coords before bunch_params are computed.

  • ele (EleStruct) –

    Element being tracked through. Must be present if is_time_coords = True.

Returns:
  • err( bool ) –

    Set True if there is an error.

calc_bunch_sigma_matrix_etc

Fortran source: bmad/multiparticle/beam_utils.f90

calc_bunch_sigma_matrix_etc(particle: pybmad._pybmad.CoordStructArray1D, charge: pybmad._pybmad.RealArray1D, is_time_coords: bool | None = None, ele: pybmad._pybmad.EleStruct | None = None) -> pybmad._pybmad.BunchParamsStruct

Subroutine calc_bunch_sigma_matrix_etc (particle, charge, bunch_params, is_time_coords, ele)

Routine to find the sigma matrix elements of a particle distribution.

Parameters:
  • particle (1D array of CoordStruct) –

    Array of particles.

  • charge (1D array of float) –

    Particle charge or photon intensity.

Returns:
  • bunch_params( BunchParamsStruct ) –

    Bunch parameters. .sigma(6,6) .centroid.vec(6) .centroid.p0c .rel_max(6) .rel_min(6)

calc_emittances_and_twiss_from_sigma_matrix

Fortran source: bmad/multiparticle/beam_utils.f90

calc_emittances_and_twiss_from_sigma_matrix(sigma_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], print_err: bool | None = None) -> pybmad._pybmad.CalcEmittancesAndTwissFromSigmaMatrix

Subroutine calc_emittances_and_twiss_from_sigma_matrix(sigma_mat, bunch_params, error, print_err, n_mat)

Routine to calc emittances and Twiss function from a beam sigma matrix. See: Andy Wolski "Alternative approach to general coupled linear optics".

Parameters:
  • sigma_mat (2D array of float (shape: 6,6)) –

    Sigma matrix.

  • print_err (bool) –

    If present and False then suppress "no eigen-system found" messages.

Returns:
  • bunch_params( BunchParamsStruct ) –

    Holds Twiss and emittance info.

  • error( bool ) –

    Set True if there is an error. Can happen if the emittance of a mode is zero.

  • n_mat( 2D array of float (shape: 6,6), optional ) –

    N matrix defined in Wolski Eq 44 and used to convert from action-angle coords to lab coords (Wolski Eq 51.).

calc_spin_params

Fortran source: bmad/multiparticle/beam_utils.f90

calc_spin_params(bunch: pybmad._pybmad.BunchStruct) -> pybmad._pybmad.BunchParamsStruct

Subroutine calc_spin_params (bunch, bunch_params)

Rotine to calculate spin averages

Parameters:
Returns:

calc_super_slave_key

Fortran source: bmad/modules/bmad_routine_interface.f90

calc_super_slave_key(lord1: pybmad._pybmad.EleStruct, lord2: pybmad._pybmad.EleStruct, create_jumbo_slave: bool | None = None) -> pybmad._pybmad.EleStruct

Wrapper for Fortran routine calc_super_slave_key

Parameters:
  • lord1 (EleStruct) –

    First slave. .key .sub_key

  • lord2 (EleStruct) –

    Second slave. .key .sub_key

  • create_jumbo_slave (bool) –

    If True then slave.key will be set to em_field. Default is False.

Returns:
  • slave( EleStruct ) –

    Super_slave element.

calc_wall_radius

Fortran source: bmad/modules/wall3d_mod.f90

calc_wall_radius(v: pybmad._pybmad.Wall3DVertexStructArray1D, cos_ang: typing.SupportsFloat | typing.SupportsIndex, sin_ang: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.CalcWallRadius

Subroutine calc_wall_radius (v, cos_ang, sin_ang, r_wall, dr_dtheta, ix_vertex)

Routine to calculate the wall radius at a given angle for a given cross-section Additionally, the transverse directional derivative is calculated.

Module needed: use wall3d_mod

Parameters:
  • v (1D array of Wall3dVertexStruct) –

    Array of vertices that make up the cross-section.

  • cos_ang (float) –

    cosine of the transverse photon position.

  • sin_ang (float) –

    sine of the transverse photon position.

Returns:
  • r_wall( float ) –

    Wall radius at given angle.

  • dr_dtheta( float ) –

    derivative of r_wall.

  • ix_vertex( (int, optional) ) –

    Wall at given angle is between v(ix_vertex-1) and v(ix_vertex). If ix_vertex = 1 then Wall at given angle is between v(N) and v(1) where N = size(v).

calc_z_tune

Fortran source: bmad/modules/bmad_routine_interface.f90

calc_z_tune(branch: pybmad._pybmad.BranchStruct) -> None

Wrapper for Fortran routine calc_z_tune

Parameters:
  • branch (BranchStruct) –

    Lattice branch This parameter is an input/output and is modified in-place. As an output, branch: Synchrotron tune (radians). If unstable tune = 0. This parameter is an input/output and is modified in-place. As an output, branch: Is the mode stable? If no rf then tune is zero but is stable. This parameter is an input/output and is modified in-place. As an output, branch: 6x6 1-turn matrix.

canonical_to_angle_coords

Fortran source: bmad/modules/bmad_routine_interface.f90

canonical_to_angle_coords(orbit: pybmad._pybmad.CoordStruct, coord_type: str | None = None) -> None

Wrapper for Fortran routine canonical_to_angle_coords

Parameters:
  • orbit (CoordStruct) –

    Orbit in canonical coordinates. This parameter is an input/output and is modified in-place. As an output, orbit: Orbit in angular coordinates.

  • coord_type (str) –

    Angular coordinates type '' (default): (x, x' = dx/ds, y, y' = dy/ds, z, pz) 'ZGOUBI': (x, x' = dx/ds, y, y' = dy/ds, dt = -z / (beta * c), pz)

cbar_to_c

Fortran source: bmad/modules/bmad_routine_interface.f90

cbar_to_c(cbar_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]], "FixedSize(2)"], a: pybmad._pybmad.TwissStruct, b: pybmad._pybmad.TwissStruct) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(2)"]], "FixedSize(2)"]

Wrapper for Fortran routine cbar_to_c

Parameters:
  • cbar_mat (2D array of float (shape: 2,2)) –

    Cbar matrix.

  • a (TwissStruct) –

    a-mode Twiss parameters

  • b (TwissStruct) –

    b-mode Twiss parameters

Returns:
  • c_mat( 2D array of float (shape: 2,2) ) –

    C matrix.

check_aperture_limit

Fortran source: bmad/modules/bmad_routine_interface.f90

check_aperture_limit(orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, param: pybmad._pybmad.LatParamStruct, old_orb: pybmad._pybmad.CoordStruct | None = None, check_momentum: bool | None = None) -> None

Wrapper for Fortran routine check_aperture_limit

Parameters:
  • orb (CoordStruct) –

    coordinates of a particle.

  • ele (EleStruct) –

    Element holding the aperture

  • particle_at (int) –

    first_track_edge\(, second_track_edge\), surface\(, in_between\)

  • param (LatParamStruct) –

    Lattice global parameter structure.

  • old_orb (CoordStruct) –

    Old coordinates at last check. Needed if ele.aperture_at = wall_transition$. If not present then wall transitions will be ignored.

  • check_momentum (bool) –

    If present and false then checking of p_x and p_y will be disabled.

check_controller_controls

Fortran source: bmad/modules/bmad_routine_interface.f90

check_controller_controls(ele_key: typing.SupportsInt | typing.SupportsIndex, contrl: pybmad._pybmad.ControlStructArray1D, name: str) -> bool

Wrapper for Fortran routine check_controller_controls

Parameters:
  • ele_key (int) –

    Element type. overlay$, etc.

  • contrl (1D array of ControlStruct) –

    control info. 1 element for each slave.

  • name (str) –

    Lord name. Used for error reporting.

Returns:
  • err( bool ) –

    Set true if there is a problem. False otherwise.

check_for_superimpose_problem

Fortran source: bmad/parsing/bmad_parser_mod.f90

check_for_superimpose_problem(branch: pybmad._pybmad.BranchStruct, super_ele: pybmad._pybmad.EleStruct, err_flag: bool, wrap: bool, ref_ele: pybmad._pybmad.EleStruct | None = None) -> None

Subroutine check_for_superimpose_problem (branch, super_ele, err_flag, ref_ele, wrap)

Subroutine to check if there is a problem superimposing an element when there is multipass. In particular will check that: 1) If the ref_ele is part of a multipass region then super_ele must be superimposed within the region. Or: 2) If the ref_ele is not part of a multipass region then super_ele must also not be part of a multipass region.

This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

check_if_s_in_bounds

Fortran source: bmad/modules/bmad_routine_interface.f90

check_if_s_in_bounds(branch: pybmad._pybmad.BranchStruct, s: typing.SupportsFloat | typing.SupportsIndex, print_err: bool | None = None) -> pybmad._pybmad.CheckIfSInBounds

Wrapper for Fortran routine check_if_s_in_bounds

Parameters:
  • branch (BranchStruct) –

    Branch

  • s (float) –

    longitudinal position in the given branch.

  • print_err (bool) –

    Print error message if there is an error? Default is True.

Returns:
  • err_flag( bool ) –

    Set True if s position is out-of-bounds. False otherwise.

  • translated_s( (float, optional) ) –

    position translated to the range [0, branch_length]

choose_quads_for_set_tune

Fortran source: bmad/modules/bmad_routine_interface.f90

choose_quads_for_set_tune(branch: pybmad._pybmad.BranchStruct, mask: str | None = None) -> pybmad._pybmad.ChooseQuadsForSetTune

Wrapper for Fortran routine choose_quads_for_set_tune

Parameters:
  • branch (BranchStruct) –

    Lattice branch.

  • mask (str) –

    If present, assign weight of zero for all quads that do not match. That is, no variation for matching quads.

Returns:
  • dk1( 1D array of float ) –

    Weights for the quadrupoles. All values will be +1 or -1.

  • eles( 1D array of ElePointerStruct ) –

    eles(i).ele points to element with dk1(i) weight.

  • err_flag( (bool, optional) ) –

    Set True if there is not one quad with positive dk1 and one quad with negative dk1.

chrom_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

chrom_calc(lat: pybmad._pybmad.LatStruct, delta_e: typing.SupportsFloat | typing.SupportsIndex, pz: typing.SupportsFloat | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, orb0: pybmad._pybmad.CoordStruct | None = None) -> pybmad._pybmad.ChromCalc

Wrapper for Fortran routine chrom_calc

Parameters:
  • lat (LatStruct) –

    Lat

  • delta_e (float) –

    +/- Delta energy used for the calculation. Notice that the energy difference between high and low is 2 * delta_e. If 0 then default of 1.0d-4 is used. This parameter is an input/output and is modified in-place. As an output, delta_e: Set to 1.0d-4 if on input DELTA_E =< 0.

  • pz (float) –

    reference momentum about which to calculate. Default is 0.

  • ix_branch (int) –

    Index of the lattice branch to use. Default is 0.

  • orb0 (CoordStruct) –

    On-energy orbit at start (fixer point). Default is the branch.particle_start. Only needed if lattice branch has an open geometry.

Returns:
  • delta_e( float ) –

    +/- Delta energy used for the calculation. Notice that the energy difference between high and low is 2 * delta_e. If 0 then default of 1.0d-4 is used. This parameter is an input/output and is modified in-place. As an output, delta_e: Set to 1.0d-4 if on input DELTA_E =< 0.

  • chrom_a( float ) –

    a-mode chromaticity.

  • chrom_b( float ) –

    b-mode chromaticity.

  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

  • low_E_lat( (LatStruct, optional) ) –

    Lattice with RF off and matrices computed at E_lat +pz - delta_e

  • high_E_lat( (LatStruct, optional) ) –

    Lattice with RF off and matrices computed at E_lat +pz + delta_e

  • low_E_orb( 1D array of CoordStruct, optional ) –

    Orbit computed at E_lat + pz - delta_e.

  • high_E_orb( 1D array of CoordStruct, optional ) –

    Orbit computed at E_lat + pz + delta_e.

chrom_tune

Fortran source: bmad/modules/bmad_routine_interface.f90

chrom_tune(lat: pybmad._pybmad.LatStruct, delta_e: typing.SupportsFloat | typing.SupportsIndex, target_x: typing.SupportsFloat | typing.SupportsIndex, target_y: typing.SupportsFloat | typing.SupportsIndex, err_tol: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.ChromTune

Wrapper for Fortran routine chrom_tune

Parameters:
  • lat (LatStruct) –

    Lat to use, This parameter is an input/output and is modified in-place. As an output, lat: Lat with sextupole set

  • delta_e (float) –

    Delta energy used for the calculation. If 0 then default of 1.0d-4 is used. This parameter is an input/output and is modified in-place. As an output, delta_e: Set to 1.0d-4 if on input DELTA_E =< 0.

  • target_x (float) –

    Target X Chromaticity

  • target_y (float) –

    Target Y Chromaticity

  • err_tol (float) –

    Max allowable Error: Error = | X_Target - X_Actual | + | Y_Target -Y_Actual | A good number is: err_tol = 0.05_rp

Returns:
  • delta_e( float ) –

    Delta energy used for the calculation. If 0 then default of 1.0d-4 is used. This parameter is an input/output and is modified in-place. As an output, delta_e: Set to 1.0d-4 if on input DELTA_E =< 0.

  • err_flag( bool ) –

    .false. if match successful, .true. if failed Fails if takes longer than 100 iterations. If it fails the sextupoles are set to the last value calculated. Note: This subroutine assumes the Twiss parameters have been computed.

classical_radius

Fortran source: bmad/modules/bmad_routine_interface.f90

classical_radius(species: typing.SupportsInt | typing.SupportsIndex) -> float

Wrapper for Fortran routine classical_radius

Parameters:
  • species (int) –

    Species of particle.

Returns:
  • radius( float ) –

    Classical radius.

clear_lat_1turn_mats

Fortran source: bmad/modules/bmad_routine_interface.f90

clear_lat_1turn_mats() -> pybmad._pybmad.LatStruct

Wrapper for Fortran routine clear_lat_1turn_mats

Returns:
  • lat( LatStruct ) –

    Lat with 1-turn matrices cleared.

clear_taylor_maps_from_elements

Fortran source: bmad/modules/bmad_routine_interface.f90

clear_taylor_maps_from_elements(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine clear_taylor_maps_from_elements

Parameters:
  • lat (LatStruct) –

    Lattice This parameter is an input/output and is modified in-place. As an output, lat: Lattice with all maps cleared

closed_orbit_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

closed_orbit_calc(lat: pybmad._pybmad.LatStruct, closed_orb: pybmad._pybmad.CoordStructAlloc1D, i_dim: typing.SupportsInt | typing.SupportsIndex | None = None, direction: typing.SupportsInt | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, print_err: bool | None = None) -> bool

Wrapper for Fortran routine closed_orbit_calc

Parameters:
  • lat (LatStruct) –

    Lat to track through.

  • closed_orb (1D array of CoordStruct) –

    closed_orb(nt) is the initial guess where nt = 0 for direction = 1 and nt = lat.n_ele_track for direction = -1. Additionally, if i_dim = 4, then closed_orb(nt).vec(6) is used as the energy around which the closed orbit is calculated. This parameter is an input/output and is modified in-place. As an output, closed_orb: Closed orbit. closed_orb(i)

  • i_dim (int) –

    Phase space dimensions to use: = 4 Transverse closed orbit at constant energy (RF off). (dE/E = closed_orb(0).vec(6)) = 5 Transverse closed orbit at constant energy (RF off) with the energy adjusted so that vec(5) is the same at the beginning and at the end. = 6 True closed orbit. Default: 4 if RF is off, 6 if RF is on.

  • direction (int) –

    Direction of tracking.

  • ix_branch (int) –

    Lattice branch to find the closed orbit of. Default is 0 (main branch).

  • print_err (bool) –

    Print error message if calc does not converge? Default is True. Note: Condition messages like no RF voltage with i_dim = 6 will always be printed.

Returns:
  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

closed_orbit_from_tracking

Fortran source: bmad/modules/bmad_routine_interface.f90

closed_orbit_from_tracking(lat: pybmad._pybmad.LatStruct, i_dim: typing.SupportsInt | typing.SupportsIndex, eps_rel: pybmad._pybmad.RealArray1D | None = None, eps_abs: pybmad._pybmad.RealArray1D | None = None, init_guess: pybmad._pybmad.CoordStruct | None = None) -> pybmad._pybmad.ClosedOrbitFromTracking

Wrapper for Fortran routine closed_orbit_from_tracking

Parameters:
  • lat (LatStruct) –

    Lat to track through.

  • i_dim (int) –

    = 2,4 Transverse closed orbit at constant energy. = 6 Full closed orbit using the entire transfer 6x6 matrix.

  • eps_rel (1D array of float) –

    Relative allowed error. Default is bmad_com.rel_tol_tracking

  • eps_abs (1D array of float) –

    Absolute allowed error. Default is bmad_com.abs_tol_tracking

  • init_guess (CoordStruct) –

    Starting guess for the closed orbit at the start of the lattice. Set init_guess.vec(6) to the appropriate value of pz when calculating off-energy orbits. If not present then the origin will be used.

Returns:
  • closed_orb( 1D array of CoordStruct ) –

    closed orbit. This routine will allocate this array for you.

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

cmplx_re_str

Fortran source: bmad/output/write_lattice_file_mod.f90

cmplx_re_str(cmp: typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex, str_out: str) -> None

Wrapper for Fortran routine cmplx_re_str

Parameters:
  • cmp (complex) –
  • str_out (str) –

combine_consecutive_elements

Fortran source: bmad/modules/bmad_routine_interface.f90

combine_consecutive_elements(lat: pybmad._pybmad.LatStruct) -> bool

Wrapper for Fortran routine combine_consecutive_elements

Parameters:
  • lat (LatStruct) –

    Lattice. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with elements combined.

Returns:
  • error( bool ) –

    Set True if there is an error. False otherwise.

complex_taylor_clean

Fortran source: bmad/modules/complex_taylor_mod.f90

complex_taylor_clean(complex_taylor: pybmad._pybmad.ComplexTaylorStruct) -> None

Wrapper for Fortran routine complex_taylor_clean

Parameters:

complex_taylor_coef

Fortran sources (overloaded):

complex_taylor_coef(args, *kwargs) Overloaded function.

  1. complex_taylor_coef(complex_taylor: pybmad._pybmad.ComplexTaylorStruct, exp: pybmad._pybmad.IntArray1D, coef: typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex) -> None

Function complex_taylor_coef (complex_taylor, exp) Function complex_taylor_coef (complex_taylor, i1, i2, i3, i4, i5, i6, i7, i8, i9)

Function to return the coefficient for a particular complex_taylor term from a complex_taylor Series.

Note: complex_taylor_coef is overloaded by: complex_taylor_coef1 (complex_taylor, exp) complex_taylor_coef2 (complex_taylor, i1, i2, i3, i4, i5, i6, i7, i8, i9) Using the complex_taylor_coef2 form limits obtaining coefficients to 9th order or less. Also: complex_taylor_coef2 does not check that all i1, ..., i9 are between 1 and 6.

For example: To get the 2nd order term corresponding to y(out) = Coef * p_z(in)^2 [This is somtimes refered to as the T_366 term] The call would be: type (complex_taylor_struct) complex_taylor(6) ! complex_taylor Map ... coef = complex_taylor_coef (complex_taylor(3), 6, 6) ! 1st possibility or ... coef = complex_taylor_coef (complex_taylor(3), [0, 0, 0, 0, 0, 2 ])

Input (complex_taylor_coef1): complex_taylor -- complex_taylor_struct: complex_taylor series. exp(6) -- Integer: Array of exponent indices.

Input (complex_taylor_coef2): complex_taylor -- complex_taylor_struct: complex_taylor series. i1, ..., i9 -- Integer, optional: indexes (each between 1 and 6).

  1. complex_taylor_coef(complex_taylor: pybmad._pybmad.ComplexTaylorStruct, coef: typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex, i1: typing.SupportsInt | typing.SupportsIndex | None = None, i2: typing.SupportsInt | typing.SupportsIndex | None = None, i3: typing.SupportsInt | typing.SupportsIndex | None = None, i4: typing.SupportsInt | typing.SupportsIndex | None = None, i5: typing.SupportsInt | typing.SupportsIndex | None = None, i6: typing.SupportsInt | typing.SupportsIndex | None = None, i7: typing.SupportsInt | typing.SupportsIndex | None = None, i8: typing.SupportsInt | typing.SupportsIndex | None = None, i9: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Function complex_taylor_coef (complex_taylor, exp) Function complex_taylor_coef (complex_taylor, i1, i2, i3, i4, i5, i6, i7, i8, i9)

Function to return the coefficient for a particular complex_taylor term from a complex_taylor Series.

Note: complex_taylor_coef is overloaded by: complex_taylor_coef1 (complex_taylor, exp) complex_taylor_coef2 (complex_taylor, i1, i2, i3, i4, i5, i6, i7, i8, i9) Using the complex_taylor_coef2 form limits obtaining coefficients to 9th order or less. Also: complex_taylor_coef2 does not check that all i1, ..., i9 are between 1 and 6.

For example: To get the 2nd order term corresponding to y(out) = Coef * p_z(in)^2 [This is somtimes refered to as the T_366 term] The call would be: type (complex_taylor_struct) complex_taylor(6) ! complex_taylor Map ... coef = complex_taylor_coef (complex_taylor(3), 6, 6) ! 1st possibility or ... coef = complex_taylor_coef (complex_taylor(3), [0, 0, 0, 0, 0, 2 ])

Input (complex_taylor_coef1): complex_taylor -- complex_taylor_struct: complex_taylor series. exp(6) -- Integer: Array of exponent indices.

Input (complex_taylor_coef2): complex_taylor -- complex_taylor_struct: complex_taylor series. i1, ..., i9 -- Integer, optional: indexes (each between 1 and 6).

complex_taylor_equal_complex_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

complex_taylor_equal_complex_taylor(complex_taylor1: pybmad._pybmad.ComplexTaylorStruct, complex_taylor2: pybmad._pybmad.ComplexTaylorStruct) -> None

Wrapper for Fortran routine complex_taylor_equal_complex_taylor

Parameters:

complex_taylor_exponent_index

Fortran source: bmad/modules/complex_taylor_mod.f90

complex_taylor_exponent_index(expn: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(6)"]) -> int

Function complex_taylor_exponent_index(expn) result(index)

Function to associate a unique number with a complex_taylor exponent.

The number associated with a complex_taylor_term that is used for the sort is: number = sum(exp(i))10^6 + exp(6)10^5 + ... + exp(1)*10^0 where exp(1) is the exponent for x, exp(2) is the exponent for P_x, etc.

Parameters:
  • expn (1D array of int (shape: 6)) –

    complex_taylor exponent

Returns:
  • index( int ) –

    Sorted complex_taylor series.

complex_taylor_make_unit

Fortran source: bmad/modules/complex_taylor_mod.f90

complex_taylor_make_unit(complex_taylor: pybmad._pybmad.ComplexTaylorStructArray1D) -> None

Subroutine complex_taylor_make_unit (complex_taylor)

Subroutine to make the unit complex_taylor map: r(out) = Map * r(in) = r(in)

complex_taylor_to_mat6

Fortran source: bmad/modules/complex_taylor_mod.f90

complex_taylor_to_mat6(a_complex_taylor: pybmad._pybmad.ComplexTaylorStructArray1D, r_in: pybmad._pybmad.ComplexArray1D, r_out: pybmad._pybmad.ComplexArray1D | None = None) -> pybmad._pybmad.ComplexTaylorToMat6

Subroutine complex_taylor_to_mat6 (a_complex_taylor, r_in, vec0, mat6, r_out)

Subroutine to calculate, from a complex_taylor map and about some trajectory: The 1st order (Jacobian) transfer matrix.

Parameters:
  • a_complex_taylor (1D array of ComplexTaylorStruct (shape: 6)) –

    complex_taylor map.

  • r_in (1D array of complex) –

    Coordinates at the input.

  • r_out (1D array of complex) –

    Coordinates at output.

Returns:
  • vec0( 1D array of complex (shape: 6) ) –

    0th order tranfsfer map

  • mat6( 2D array of complex (shape: 6,6) ) –

    1st order transfer map (6x6 matrix).

complex_taylors_equal_complex_taylors

Fortran source: bmad/modules/bmad_routine_interface.f90

complex_taylors_equal_complex_taylors(complex_taylor1: pybmad._pybmad.ComplexTaylorStructArray1D, complex_taylor2: pybmad._pybmad.ComplexTaylorStructArray1D) -> None

Wrapper for Fortran routine complex_taylors_equal_complex_taylors

Parameters:
  • complex_taylor1 (1D array of ComplexTaylorStruct) –
  • complex_taylor2 (1D array of ComplexTaylorStruct) –

compute_slave_coupler

Fortran source: bmad/modules/bookkeeper_mod.f90

compute_slave_coupler(slave: pybmad._pybmad.EleStruct) -> None

Subroutine compute_slave_coupler (slave)

This routine is not meant for general use.

concat_ele_taylor

Fortran source: bmad/ptc/ptc_interface_mod.f90

concat_ele_taylor(orb_taylor: pybmad._pybmad.TaylorStructArray1D, ele: pybmad._pybmad.EleStruct, spin_taylor: pybmad._pybmad.TaylorStructArray1D | None = None) -> bool

Subroutine concat_ele_taylor (orb_taylor, ele, err_flag, spin_taylor)

Routine to concatinate an orbital taylor map and, optionally if present and bmad_com%spin_tracking_on = T, a spin taylor map.

Transform: orb_taylor[x] -> ele_taylor(orb_taylor[x]) If ele%taylor_map_includes_offsets = True: ele_taylor == ele%taylor If ele%taylor_map_includes_offsets = False: ele_taylor == ele%taylor + offset corrections.

Also see: concat_taylor

Parameters:
  • orb_taylor (1D array of TaylorStruct) –

    Orbital Taylor map. This parameter is an input/output and is modified in-place. As an output, orb_taylor: Concatinated orbital map

  • ele (EleStruct) –

    Element containing a Taylor map.

  • spin_taylor (1D array of TaylorStruct) –

    Spin map to propagate This parameter is an input/output and is modified in-place. As an output, spin_taylor: Concatinated spin map.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

concat_taylor

Fortran source: bmad/ptc/ptc_interface_mod.f90

concat_taylor(taylor1: pybmad._pybmad.TaylorStructArray1D, taylor2: pybmad._pybmad.TaylorStructArray1D, taylor3: pybmad._pybmad.TaylorStructArray1D) -> None

Subroutine concat_taylor (taylor1, taylor2, taylor3)

Subroutine to concatinate two taylor maps: taylor3[x] = taylor2(taylor1[x])

Note: In general, if taylor2 is a component of an ele_struct, use concat_ele_taylor instead.

Parameters:
  • taylor1 (1D array of TaylorStruct) –

    Taylor map.

  • taylor2 (1D array of TaylorStruct) –

    Taylor map.

  • taylor3 (1D array of TaylorStruct) –

    Concatinated map

concat_transfer_mat

Fortran source: bmad/modules/transfer_map_mod.f90

concat_transfer_mat(mat_1: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], vec_1: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], mat_0: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], vec_0: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]) -> pybmad._pybmad.ConcatTransferMat

Subroutine concat_transfer_mat (mat_1, vec_1, mat_0, vec_0, mat_out, vec_out)

Routine to concatinate two linear maps: mat_out = matmul(mat_1, mat_0) vec_out = matmul(mat_1, vec_0) + vec_1

Parameters:
  • mat_1 (2D array of float (shape: 6,6)) –

    Map from s1 to s2

  • vec_1 (1D array of float (shape: 6)) –

    Map from s1 to s2

  • mat_0 (2D array of float (shape: 6,6)) –

    Map from s0 to s1

  • vec_0 (1D array of float (shape: 6)) –

    Map from s0 to s1

Returns:
  • mat_out( 2D array of float (shape: 6,6) ) –

    Map from s0 to s2

  • vec_out( 1D array of float (shape: 6) ) –

    Map from s0 to s2

control_bookkeeper

Fortran source: bmad/modules/bmad_routine_interface.f90

control_bookkeeper(lat: pybmad._pybmad.LatStruct, ele: pybmad._pybmad.EleStruct | None = None, err_flag: bool | None = None) -> None

Wrapper for Fortran routine control_bookkeeper

Parameters:
  • lat (LatStruct) –

    lattice to be used

  • ele (EleStruct) –

    Element whose attribute values have been changed. If not present bookkeeping will be done for all elements.

  • err_flag (bool) –

    Set True if there is an error. False otherwise.

convert_bend_exact_multipole

Fortran source: bmad/modules/bmad_routine_interface.f90

convert_bend_exact_multipole(g: typing.SupportsFloat | typing.SupportsIndex, out_type: typing.SupportsInt | typing.SupportsIndex, an: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(21)"], bn: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(21)"]) -> None

Wrapper for Fortran routine convert_bend_exact_multipole

Parameters:
  • g (float) –

    1/rho bending strength.

  • out_type (int) –

    Output type: horizontally_pure$ or vertically_pure$.

  • an (1D array of float (shape: 0:n_pole_maxx)) –

    Skew multipoles. This parameter is an input/output and is modified in-place. As an output, an: Converted skew multipoles.

  • bn (1D array of float (shape: 0:n_pole_maxx)) –

    Non-skew multipoles. This parameter is an input/output and is modified in-place. As an output, bn: Converted Non-skew multipoles.

convert_coords

Fortran source: bmad/modules/bmad_routine_interface.f90

convert_coords(in_type_str: str, coord_in: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.ConvertCoords

Wrapper for Fortran routine convert_coords

Parameters:
  • in_type_str (str) –

    type of the input coords.

  • coord_in (CoordStruct) –

    Input coordinates.

  • ele (EleStruct) –

    Provides the Twiss parameters.

Returns:
  • out_type_str( str ) –

    type of the output coords.

  • coord_out( CoordStruct ) –

    Output coordinates.

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise. in_type_str and out_type_str can be: 'LAB' {x, x', y, y', z, z'} 'MODE' {a, a', b, b', z, z'} 'NORMALIZED' {a_bar, a'_bar, b_bar, b'_bar, z_bar, z'_bar} 'ACTION-ANGLE' {j_a, phi_a, j_b, phi_b, j_z, phi_z} x_vec = V_mat * (a_vec + eta_vec * z') a_bar = sqrt(2j_a) * cos(phi_a) a'_bar = -sqrt(2j_a) * sin(phi_a)

convert_field_ele_to_lab

Fortran source: bmad/modules/em_field_mod.f90

convert_field_ele_to_lab(ele: pybmad._pybmad.EleStruct, s_here: typing.SupportsFloat | typing.SupportsIndex, forward_transform: bool, calc_dfield: bool | None = None, calc_potential: bool | None = None) -> pybmad._pybmad.EmFieldStruct

Subroutine convert_field_ele_to_lab (ele, s_here, forward_transform, field, calc_dfield, calc_potential)

Convert fields: ele to lab coords

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • s_here (float) –

    real(rp) S-position.

  • forward_transform (bool) –

    Transform foward (to lab) or reverse.

  • calc_dfield (bool) –

    If present and True then calculate the field derivatives.

  • calc_potential (bool) –

    Calc electric and magnetic potentials? Default is false. This is experimental and only implemented for wigglers at present.

Returns:

convert_local_cartesian_to_local_curvilinear

Fortran source: bmad/interface/gpt_interface_mod.f90

convert_local_cartesian_to_local_curvilinear(x: typing.SupportsFloat | typing.SupportsIndex, z: typing.SupportsFloat | typing.SupportsIndex, g: typing.SupportsFloat | typing.SupportsIndex, xout: typing.SupportsFloat | typing.SupportsIndex, sout: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine convert_local_cartesian_to_local_curvilinear

Parameters:
  • x (float) –
  • z (float) –
  • g (float) –
  • xout (float) –
  • sout (float) –

convert_local_curvilinear_to_local_cartesian

Fortran source: bmad/interface/gpt_interface_mod.f90

convert_local_curvilinear_to_local_cartesian(x: typing.SupportsFloat | typing.SupportsIndex, s: typing.SupportsFloat | typing.SupportsIndex, g: typing.SupportsFloat | typing.SupportsIndex, xout: typing.SupportsFloat | typing.SupportsIndex, zout: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine convert_local_curvilinear_to_local_cartesian

Parameters:
  • x (float) –
  • s (float) –
  • g (float) –
  • xout (float) –
  • zout (float) –

convert_particle_coordinates_s_to_t

Fortran source: bmad/modules/bmad_routine_interface.f90

convert_particle_coordinates_s_to_t(particle: pybmad._pybmad.CoordStruct, s_body: typing.SupportsFloat | typing.SupportsIndex, orientation: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine convert_particle_coordinates_s_to_t

Parameters:
  • particle (CoordStruct) –

    Particle with .vec(:) in s-coords.

  • s_body (float) –

    s-position in element body coords.

  • orientation (int) –

    ele.orientation for vec(6).

convert_particle_coordinates_t_to_s

Fortran source: bmad/modules/bmad_routine_interface.f90

convert_particle_coordinates_t_to_s(particle: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, use_downstream_p0c: bool | None = None) -> float

Wrapper for Fortran routine convert_particle_coordinates_t_to_s

Parameters:
  • particle (CoordStruct) –

    Particle with .vec(:) in t-coords.

  • ele (EleStruct) –

    Element particle is going through.

  • use_downstream_p0c (bool) –

    If True (the default), use ele.value(p0c\() as the reference momentum. If False, use ele.value(p0c_start\)) as the reference.

Returns:
  • s_body( (float, optional) ) –

    s-position in element body coords.

convert_pc_to

Fortran source: bmad/modules/bmad_routine_interface.f90

convert_pc_to(pc: typing.SupportsFloat | typing.SupportsIndex, particle: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.ConvertPcTo

Wrapper for Fortran routine convert_pc_to

Parameters:
  • pc (float) –

    Particle momentum

  • particle (int) –

    Type of particle. positron$, etc.

Returns:
  • E_tot( (float, optional) ) –

    Total energy of the particle.

  • gamma( (float, optional) ) –

    Gamma factor.

  • kinetic( (float, optional) ) –

    Kinetic energy

  • beta( (float, optional) ) –

    velocity / c_light

  • brho( (float, optional) ) –

    Nominal B_field*rho_bend

  • beta1( (float, optional) ) –

    1 - beta. Equal to 1/(2*gamma^2) in ultra-rel limit.

  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

convert_total_energy_to

Fortran source: bmad/modules/bmad_routine_interface.f90

convert_total_energy_to(E_tot: typing.SupportsFloat | typing.SupportsIndex, particle: typing.SupportsInt | typing.SupportsIndex, print_err: bool | None = None) -> pybmad._pybmad.ConvertTotalEnergyTo

Wrapper for Fortran routine convert_total_energy_to

Parameters:
  • E_tot (float) –

    Total energy of the particle.

  • particle (int) –

    Type of particle. positron$, etc.

  • print_err (bool) –

    Print error message if E_tot < particle mass? Default is True.

Returns:
  • gamma( (float, optional) ) –

    Gamma factor. Set to -1 for photons.

  • kinetic( (float, optional) ) –

    Kinetic energy

  • beta( (float, optional) ) –

    velocity / c_light

  • pc( (float, optional) ) –

    Particle momentum

  • brho( (float, optional) ) –

    Nominal B_field*rho_bend

  • beta1( (float, optional) ) –

    1 - beta. Equal to 1/(2*gamma^2) in ultra-rel limit.

  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

converter_distribution_parser

Fortran source: bmad/modules/bmad_routine_interface.f90

converter_distribution_parser(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.ConverterDistributionParser

Wrapper for Fortran routine converter_distribution_parser

Parameters:
  • ele (EleStruct) –

    Converter element. This parameter is an input/output and is modified in-place. As an output, ele: Converter element with .converter field set.

Returns:
  • delim( str ) –

    Ending delimitor.

  • delim_found( bool ) –

    Has a delimitor been found?

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

coord_equal_coord

Fortran source: bmad/modules/bmad_routine_interface.f90

coord_equal_coord(coord2: pybmad._pybmad.CoordStruct) -> pybmad._pybmad.CoordStruct

Subroutine coord_equal_coord (coord1, coord2)

Subroutine that is used to set one coord equal to another.

Note: This subroutine is called by the overloaded equal sign: coord1 = coord2

Parameters:
Returns:

coord_state_name

Fortran source: bmad/modules/bmad_struct.f90

coord_state_name(coord_state: typing.SupportsInt | typing.SupportsIndex, one_word: bool | None = None) -> str

Function coord_state_name (coord_state) result (state_str)

Routine to return the string representation of a coord%state state.

Parameters:
  • coord_state (int) –

    coord.state value

Returns:
  • state_str( str ) –

    String representation.

coords_body_to_local

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_body_to_local(body_position: pybmad._pybmad.FloorPositionStruct, ele: pybmad._pybmad.EleStruct, calculate_angles: bool | None = None) -> pybmad._pybmad.CoordsBodyToLocal

Wrapper for Fortran routine coords_body_to_local

Parameters:
  • body_position (FloorPositionStruct) –

    Element body frame coordinates. .r(3) [x, y, s] position with s = Position from entrance end of element.

  • ele (EleStruct) –

    element that local_position coordinates are relative to.

  • calculate_angles (bool) –

    calculate angles for local_position Default: True. False returns local_position angles (.theta, .phi, .psi) = 0.

Returns:
  • local_position( FloorPositionStruct ) –

    Local laboratory coordinates. .r(3) [x, y, s] position with s = Position from entrance end of element.

  • w_mat( 2D array of float (shape: 3,3), optional ) –

    W matrix at to transform vectors. v_local = w_mat . v_body v_body = transpose(w_mat) . v_local

coords_body_to_rel_exit

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_body_to_rel_exit(body_position: pybmad._pybmad.FloorPositionStruct, ele: pybmad._pybmad.EleStruct, calculate_angles: bool | None = None) -> pybmad._pybmad.CoordsBodyToRelExit

Wrapper for Fortran routine coords_body_to_rel_exit

Parameters:
  • body_position (FloorPositionStruct) –

    Element body frame coordinates. .r [x, y, s] position with s = Position from entrance end of element .

  • ele (EleStruct) –

    element that rel_exit coordinates are relative to.

  • calculate_angles (bool) –

    calculate angles for rel_exit Default: True. False returns rel_exit angles (.theta, .phi, .psi) = 0.

Returns:
  • rel_exit( FloorPositionStruct ) –

    Cartesian coordinates relative to exit of the element.

  • w_mat( 2D array of float (shape: 3,3), optional ) –

    W matrix at to transform vectors. v_rel_exit = w_mat . v_body v_body = transpose(w_mat) . v_rel_exit

coords_curvilinear_to_floor

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_curvilinear_to_floor(xys: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], branch: pybmad._pybmad.BranchStruct) -> pybmad._pybmad.CoordsCurvilinearToFloor

Wrapper for Fortran routine coords_curvilinear_to_floor

Parameters:
  • xys (1D array of float (shape: 3)) –

    (x, y, s) lab frame position vector.

  • branch (BranchStruct) –

    Lattice branch that defines the local reference coordinates.

Returns:
  • err_flag( bool ) –

    Set True if global floor position cannot be computed.

  • global( FloorPositionStruct ) –

    Global floor position corresponding to (x, y, s) -- .w -- W matrix to transform vectors: v_global = w_mat * v_local

coords_floor_to_curvilinear

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_floor_to_curvilinear(floor_coords: pybmad._pybmad.FloorPositionStruct, ele0: pybmad._pybmad.EleStruct) -> pybmad._pybmad.CoordsFloorToCurvilinear

Wrapper for Fortran routine coords_floor_to_curvilinear

Parameters:
Returns:
  • status( int ) –

    ok$ -> Local_coords found. patch_problem$ -> No solution due to a patch element. outside$ -> Outside of lattice ends (for open lattices).

  • local_coords( FloorPositionStruct ) –

    .r = [x, y, s] position in curvilinear coordinates with respect to ele1 with s relative to start the lattice branch.

  • ele1( (EleStruct, optional) ) –

    Element that local_coords is with respect to.

  • w_mat( 2D array of float (shape: 3,3), optional ) –

    W matrix at s, to transform vectors from floor to local. w_mat will only be well defined if status = ok$

coords_floor_to_local_curvilinear

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_floor_to_local_curvilinear(global_position: pybmad._pybmad.FloorPositionStruct, ele: pybmad._pybmad.EleStruct, relative_to: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.CoordsFloorToLocalCurvilinear

Wrapper for Fortran routine coords_floor_to_local_curvilinear

Parameters:
  • global_position (FloorPositionStruct) –

    .r = [X, Y, Z] position in global coordinates

  • ele (EleStruct) –

    element to find local coordinates of.

  • relative_to (int) –

    not_set$ (default), upstream_end\(, or downstream_end\). Force which end is used for z = 0. If upstream_end$, local_position.r(3) is relative to the upstream end which will not be the entrance end if ele.orientation = -1.

Returns:
  • status( int ) –

    longitudinal position: inside\(: Inside the element. upstream_end\): At upstream end of element or beyound. downstream_end$: At downstream end of element or beyound.

  • local_position( FloorPositionStruct ) –

    .r = [x, y, z] position in local curvilinear coordinates.

  • w_mat( 2D array of float (shape: 3,3), optional ) –

    W matrix at s, to transform vectors. v_global = w_mat.v_local v_local = transpose(w_mat).v_global

coords_floor_to_relative

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_floor_to_relative(floor0: pybmad._pybmad.FloorPositionStruct, global_position: pybmad._pybmad.FloorPositionStruct, calculate_angles: bool | None = None, is_delta_position: bool | None = None) -> pybmad._pybmad.FloorPositionStruct

Wrapper for Fortran routine coords_floor_to_relative

Parameters:
  • floor0 (FloorPositionStruct) –

    reference position

  • global_position (FloorPositionStruct) –

    global position

  • calculate_angles (bool) –

    calculate angles for local_position Default: True. False returns local_position angles (.theta, .phi, .psi) = 0.

  • is_delta_position (bool) –

    If True then treat global_position.r as a difference position in global space and only rotate the position but not shift it. Default: False.

Returns:

coords_local_curvilinear_to_body

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_local_curvilinear_to_body(local_position: pybmad._pybmad.FloorPositionStruct, ele: pybmad._pybmad.EleStruct, calculate_angles: bool | None = None) -> pybmad._pybmad.CoordsLocalCurvilinearToBody

Wrapper for Fortran routine coords_local_curvilinear_to_body

Parameters:
  • local_position (FloorPositionStruct) –

    local coordinates. .r(3) [x, y, s] position with s = Position from entrance end of element.

  • ele (EleStruct) –

    element that coordinates are relative to.

  • calculate_angles (bool) –

    calculate angles for body_position Default: True. False returns body_position angles (.theta, .phi, .psi) = 0.

Returns:
  • body_position( FloorPositionStruct ) –

    Element coordinates relative to exit of the element. .r(3) [x, y, s] position with s = Position from entrance end of element.

  • w_mat( 2D array of float (shape: 3,3), optional ) –

    W matrix at to transform vectors. v_local = w_mat . v_body v_body = transpose(w_mat) . v_local

coords_local_curvilinear_to_floor

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_local_curvilinear_to_floor(local_position: pybmad._pybmad.FloorPositionStruct, ele: pybmad._pybmad.EleStruct, in_body_frame: bool | None = None, calculate_angles: bool | None = None, end_origin: typing.SupportsInt | typing.SupportsIndex | None = None, downstream_dir_ref: bool | None = None) -> pybmad._pybmad.CoordsLocalCurvilinearToFloor

Wrapper for Fortran routine coords_local_curvilinear_to_floor

Parameters:
  • local_position (FloorPositionStruct) –

    Floor position in local curvilinear coordinates, with .r = [x, y, z_local] where z_local is wrt the entrance end of the element except if end_origin = downstream_end\(. In this case, z_local is a distance -ele.value(l\)) from the exit end (important for patch elements).

  • ele (EleStruct) –

    element that local_position coordinates are relative to.

  • in_body_frame (bool) –

    True => local_position is in ele body frame and includes misalignments. Ignored if element is a patch. Default: False.

  • calculate_angles (bool) –

    calculate angles for global_position Default: True. False returns local_position angles (.theta, .phi, .psi) = 0.

  • end_origin (int) –

    not_set$ (default), upstream_end\(, or downstream_end\). Force which end is used for z = 0. If upstream_end$, local_position.r(3) is relative to the upstream end which will not be the entrance end if ele.orientation = -1.

  • downstream_dir_ref (bool) –

    Default False. The output theta angle is calculated so that moduo 2pi this angle is near ele.floor.theta. If the element is reversed (ele.direction = -1), the element body coords point upstream which is not always wanted. If this arg is set True, ele.floor.theta+pi modulo to be in the range [-pi, pi] is the reference.

Returns:
  • global_position( FloorPositionStruct ) –

    Position in global coordinates.

  • w_mat( 2D array of float (shape: 3,3), optional ) –

    W matrix at z, to transform vectors. v_global = w_mat . v_local/body v_local/body = transpose(w_mat) . v_global

coords_relative_to_floor

Fortran source: bmad/modules/bmad_routine_interface.f90

coords_relative_to_floor(floor0: pybmad._pybmad.FloorPositionStruct, dr: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], theta: typing.SupportsFloat | typing.SupportsIndex | None = None, phi: typing.SupportsFloat | typing.SupportsIndex | None = None, psi: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.FloorPositionStruct

Wrapper for Fortran routine coords_relative_to_floor

Parameters:
  • floor0 (FloorPositionStruct) –

    Initial reference frame.

  • dr (1D array of float (shape: 3)) –

    (x, y, z) positional shift of the reference frame.

  • theta (float) –

    Angular shift of the reference frame. See the Bmad manual on the Global Coordinate system for more details. All angles must either be absent or present.

  • phi (float) –

    Angular shift of the reference frame. See the Bmad manual on the Global Coordinate system for more details. All angles must either be absent or present.

  • psi (float) –

    Angular shift of the reference frame. See the Bmad manual on the Global Coordinate system for more details. All angles must either be absent or present.

Returns:

coulombfun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

coulombfun(u: typing.SupportsFloat | typing.SupportsIndex, v: typing.SupportsFloat | typing.SupportsIndex, w: typing.SupportsFloat | typing.SupportsIndex, gam: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine coulombfun

Parameters:
  • u (float) –
  • v (float) –
  • w (float) –
  • gam (float) –
  • res (float) –

create_concatenated_wall3d

Fortran source: bmad/modules/wall3d_mod.f90

create_concatenated_wall3d(lat: pybmad._pybmad.LatStruct, err: bool) -> None

Subroutine create_concatenated_wall3d (lat)

Routine to concatinate lat%branch(i)ele(:)%wall3d%section(:) arrays into one lat%branch(i)%wall3d%section(:) array.

Exceptions: capillary and aperture elements do not have their walls included.

Module needed: use wall3d_mod

Parameters:
  • lat (LatStruct) –

    lattice This parameter is an input/output and is modified in-place. As an output, lat: Lattice

create_element_slice

Fortran source: bmad/modules/bmad_routine_interface.f90

create_element_slice(ele_in: pybmad._pybmad.EleStruct, l_slice: typing.SupportsFloat | typing.SupportsIndex, offset: typing.SupportsFloat | typing.SupportsIndex, param: pybmad._pybmad.LatParamStruct, include_upstream_end: bool, include_downstream_end: bool, old_slice: pybmad._pybmad.EleStruct | None = None, orb_in: pybmad._pybmad.CoordStruct | None = None) -> pybmad._pybmad.CreateElementSlice

Wrapper for Fortran routine create_element_slice

Parameters:
  • ele_in (EleStruct) –

    Original element to slice

  • l_slice (float) –

    Length of the slice

  • offset (float) –

    Offset of entrance end of sliced_ele from entrance end of ele_in.

  • param (LatParamStruct) –

    lattice paramters.

  • include_upstream_end (bool) –

    Sliced_ele contains the ele's entrance end?

  • include_downstream_end (bool) –

    Sliced_ele contains the ele's exit end?

  • old_slice (EleStruct) –

    Previous slice or, if offset = 0, the previous element. If present this saves computation time of the reference energy and time at the start of the present slice. Also makes the ref energy continuous (there can be some small differences when using, say, runge_kutta tracking due to tracking tolerances).

  • orb_in (CoordStruct) –

    Incoming orbit if calling routine is doing tracking through the slice. This is used when old_slice is not present and there may be an adjustment needed to the orbit ref energy (EG space charge tracking does not keep track of ref energy through an lcavity).

Returns:
  • sliced_ele( EleStruct ) –

    Sliced_ele element with appropriate values set.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

create_feedback

Fortran source: bmad/modules/bmad_routine_interface.f90

create_feedback(lord: pybmad._pybmad.EleStruct, input: pybmad._pybmad.CharacterAlloc1D, output: pybmad._pybmad.CharacterAlloc1D, err_flag: bool) -> None

Wrapper for Fortran routine create_feedback

Parameters:
  • lord (EleStruct) –

    Feedback element. This parameter is an input/output and is modified in-place. As an output, lord: Modified feedback elment.

  • input (1D array of str) –

    Names of input slaves.

  • output (1D array of str) –

    Names of output slaves.

  • err_flag (bool) –

    Set True if there is a problem.

create_field_overlap

Fortran source: bmad/modules/bmad_routine_interface.f90

create_field_overlap(lat: pybmad._pybmad.LatStruct, lord_name: str, slave_name: str) -> bool

Wrapper for Fortran routine create_field_overlap

Parameters:
  • lat (LatStruct) –

    Lattice

  • lord_name (str) –

    Name of the element with a field extending beyound it's bounds.

  • slave_name (str) –

    Name of the element the lord's field overlaps.

Returns:
  • err_flag( bool ) –

    Set true if there is a problem (like no elements found).

create_girder

Fortran source: bmad/modules/bmad_routine_interface.f90

create_girder(lat: pybmad._pybmad.LatStruct, ix_girder: typing.SupportsInt | typing.SupportsIndex, contrl: pybmad._pybmad.ControlStructArray1D, girder_info: pybmad._pybmad.EleStruct, err_flag: bool) -> None

Wrapper for Fortran routine create_girder

Parameters:
  • lat (LatStruct) –

    Lat to modify. This parameter is an input/output and is modified in-place. As an output, lat: Modified lattice.

  • ix_girder (int) –

    Index of girder element.

  • contrl (1D array of ControlStruct) –

    Array of elements that are supported by the girder.

  • girder_info (EleStruct) –

    Element containing attributes to be transfered to the Girder element: girder_info.name girder_info.alias girder_info.descrip girder_info.value(:)

  • err_flag (bool) –

create_group

Fortran source: bmad/modules/bmad_routine_interface.f90

create_group(lord: pybmad._pybmad.EleStruct, contrl: pybmad._pybmad.ControlStructArray1D, err: bool) -> None

Wrapper for Fortran routine create_group

Parameters:
  • lord (EleStruct) –

    Group element. .control.type This parameter is an input/output and is modified in-place. As an output, lord: Modified group elment

  • contrl (1D array of ControlStruct) –

    control info. 1 element for each slave.

  • err (bool) –

    Set True if an attribute is not free to be controlled.

create_lat_ele_nametable

Fortran source: bmad/modules/bmad_routine_interface.f90

create_lat_ele_nametable(lat: pybmad._pybmad.LatStruct) -> pybmad._pybmad.NametableStruct

Wrapper for Fortran routine create_lat_ele_nametable

Parameters:
Returns:

create_overlay

Fortran source: bmad/modules/bmad_routine_interface.f90

create_overlay(lord: pybmad._pybmad.EleStruct, contrl: pybmad._pybmad.ControlStructArray1D, err: bool) -> None

Wrapper for Fortran routine create_overlay

Parameters:
  • lord (EleStruct) –

    Overlay element. .control.type This parameter is an input/output and is modified in-place. As an output, lord: Modified overlay elment

  • contrl (1D array of ControlStruct) –

    control info. 1 element for each slave.

  • err (bool) –

    Set True if an attribute is not free to be controlled.

create_planar_wiggler_model

Fortran source: bmad/modules/element_modeling_mod.f90

create_planar_wiggler_model(wiggler_in: pybmad._pybmad.EleStruct, print_err: bool | None = None) -> pybmad._pybmad.CreatePlanarWigglerModel

Subroutine create_planar_wiggler_model (wiggler_in, lat, err_flag, print_err)

Routine to create series of bend and drift elements to serve as a replacement model for a planar wiggler.

This routine is helpful for translating bmad lattices to a language that does not implement the Bmad wiggler model.

This routine uses the mrqmin nonlinear optimizer to vary the parameters in the wiggler model to match: Integral g^2 (I_2 radiation integral) Integral g^3 (I_3 radiation integral) Transfer matrix. Also the endding horizontal transverse offset of the reference orbit (floor%r(1)) is matched to zero.

Note: The resulting model does not have the vertical cubic nonlinearity that the actual wiggler has.

Parameters:
  • print_err (bool) –

    If True (default) print an error message if there is an error.

Returns:
  • lat( LatStruct ) –

    Lattice containing the wiggler model

  • err_flag( (bool, optional) ) –

    Set True if there is an error.

create_ramper

Fortran source: bmad/modules/bmad_routine_interface.f90

create_ramper(lord: pybmad._pybmad.EleStruct, contrl: pybmad._pybmad.ControlStructArray1D, err: bool) -> None

Wrapper for Fortran routine create_ramper

Parameters:
  • lord (EleStruct) –

    Ramper element. .control.type This parameter is an input/output and is modified in-place. As an output, lord: Modified ramper elment

  • contrl (1D array of ControlStruct) –

    control info. 1 element for each slave.

  • err (bool) –

    Set True if an attribute is not free to be controlled.

create_sol_quad_model

Fortran source: bmad/modules/element_modeling_mod.f90

create_sol_quad_model(sol_quad: pybmad._pybmad.EleStruct, lat: pybmad._pybmad.LatStruct) -> None

Subroutine create_sol_quad_model (sol_quad, lat)

Routine to create series of solenoid and quadrupole elements to serve as a replacement model for a sol_quad element.

This routine is helpful for translating bmad lattices to a language that does not implement a combination solenoid/quadrupole.

Not yet implemented!

create_unique_ele_names

Fortran source: bmad/modules/bmad_routine_interface.f90

create_unique_ele_names(lat: pybmad._pybmad.LatStruct, key: typing.SupportsInt | typing.SupportsIndex, suffix: str) -> None

Wrapper for Fortran routine create_unique_ele_names

Parameters:
  • lat (LatStruct) –

    Lattice holding the elements. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with names made unique.

  • key (int) –

    Class key of elements to consider.

  • suffix (str) –

    Suffix string. Must have a single "?" character.

create_wiggler_cartesian_map

Fortran source: bmad/modules/bmad_routine_interface.f90

create_wiggler_cartesian_map(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.CartesianMapStruct

Wrapper for Fortran routine create_wiggler_cartesian_map

Parameters:
  • ele (EleStruct) –

    Wiggler or undulator element.

Returns:

crystal_attribute_bookkeeper

Fortran source: bmad/modules/bmad_routine_interface.f90

crystal_attribute_bookkeeper(ele: pybmad._pybmad.EleStruct) -> None

Wrapper for Fortran routine crystal_attribute_bookkeeper

Parameters:

crystal_h_misalign

Fortran source: bmad/photon/track1_photon_mod.f90

crystal_h_misalign(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, h_vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> None

Subroutine crystal_h_misalign (ele, orbit, h_vec)

Routine reorient the crystal H vector due to local imperfections in the crystal lattice.

Parameters:
  • ele (EleStruct) –

    Crystal element

  • orbit (CoordStruct) –

    Photon position at crystal surface.

  • h_vec (1D array of float (shape: 3)) –

    H vector before misalignment. This parameter is an input/output and is modified in-place. As an output, h_vec: H vector after misalignment.

crystal_type_to_crystal_params

Fortran source: bmad/interface/xraylib_interface.f90

crystal_type_to_crystal_params(ele: pybmad._pybmad.EleStruct) -> bool

Subroutine crystal_type_to_crystal_params (ele, err_flag)

Routine to set the crystal parameters based upon the crystal type.

Crystal types are of the form: "ZZZ(ijk)" Where "ZZZ" is the atomic formula of the crystal material and "ijk" is the reciprical lattice vetor specifying the diffraction plans.

Parameters:
  • ele (EleStruct) –

    Crystal element. This parameter is an input/output and is modified in-place. As an output, ele: Crystal element with computed parameter..

Returns:
  • err_flag( bool ) –

    Set True if crystal type is unrecognized. False otherwise.

custom_attribute_ubound_index

Fortran source: bmad/modules/attribute_mod.f90

custom_attribute_ubound_index(ele_class: typing.SupportsInt | typing.SupportsIndex) -> int

Function custom_attribute_ubound_index(ele_class) result (ix_ubound)

Routine to return, for a given element class, the upper bound index for the ele%custom(:) array which is needed to accomodate the registered custom attributes for that class.

Parameters:
  • ele_class (int) –

    Element class (key). EG: quadrupole$, etc.

Returns:
  • ix_ubound( int ) –

    Maximum index needed.

custom_ele_attrib_name_list

Fortran source: bmad/modules/attribute_mod.f90

custom_ele_attrib_name_list() -> pybmad._pybmad.CustomEleAttribNameList

Subroutine custom_ele_attrib_name_list (index_list, name_list)

Routine to create an array (index_list(i), name_list(i)) of custom element attribute names and indexes. Each name in the name_list is of the form: "{::}" where: :: is an optional class prefix. is the name of the attribute.

Returns:
  • index_list( 1D array of int ) –

    Index of the custom attribute.

  • name_list( 1D array of str ) –

    List of custom attributes.

damping_matrix_d

Fortran source: bmad/multiparticle/envelope_mod.f90

damping_matrix_d(gamma: typing.SupportsFloat | typing.SupportsIndex, g_tot: typing.SupportsFloat | typing.SupportsIndex, B0: typing.SupportsFloat | typing.SupportsIndex, B1: typing.SupportsFloat | typing.SupportsIndex, delta: typing.SupportsFloat | typing.SupportsIndex, species: typing.SupportsInt | typing.SupportsIndex, mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> None

Wrapper for Fortran routine damping_matrix_d

Parameters:
  • gamma (float) –
  • g_tot (float) –
  • B0 (float) –
  • B1 (float) –
  • delta (float) –
  • species (int) –
  • mat (2D array of float (shape: 6,6)) –

deallocate_ele_pointers

Fortran source: bmad/modules/bmad_routine_interface.f90

deallocate_ele_pointers(ele: pybmad._pybmad.EleStruct, nullify_only: bool | None = None, nullify_branch: bool | None = None, dealloc_poles: bool | None = None) -> None

Wrapper for Fortran routine deallocate_ele_pointers

Parameters:
  • ele (EleStruct) –

    Element with pointers. This parameter is an input/output and is modified in-place. As an output, ele: Element with deallocated pointers.

  • nullify_only (bool) –

    If present and True: Nullify & do not deallocate.

  • nullify_branch (bool) –

    Nullify ele.branch? Default is True.

  • dealloc_poles (bool) –

    Dealloc ele.a/b_pole, ele.a/b_pole_elec? Default is True.

deallocate_expression_tree

Fortran source: bmad/modules/expression_mod.f90

deallocate_expression_tree(tree: pybmad._pybmad.ExpressionTreeStruct) -> None

Subroutine deallocate_expression_tree(tree)

Routine to deallocate an expression tree.

Parameters:
  • tree (ExpressionTreeStruct) –

    Tree to deallocate. This parameter is an input/output and is modified in-place. As an output, tree: Deallocated tree.

deallocate_lat_pointers

Fortran source: bmad/modules/bmad_routine_interface.f90

deallocate_lat_pointers(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine deallocate_lat_pointers

Parameters:
  • lat (LatStruct) –

    Lat with pointers. This parameter is an input/output and is modified in-place. As an output, lat: Lat with deallocated pointers.

default_tracking_species

Fortran source: bmad/modules/bmad_routine_interface.f90

default_tracking_species(param: pybmad._pybmad.LatParamStruct) -> int

Wrapper for Fortran routine default_tracking_species

Parameters:
Returns:
  • species( int ) –

    Default species to be used for tracking.

detector_pixel_pt

Fortran source: bmad/photon/photon_target_mod.f90

detector_pixel_pt(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> typing.Annotated[list[int], "FixedSize(2)"]

Function detector_pixel_pt (orbit, ele) result (ix_pix)

Routine to return the pixel a particle is hitting.

Parameters:
Returns:
  • ix_pix( 1D array of int (shape: 2) ) –

    index of ele.photon.pixel.pt(:,:) the particle is in.

diffraction_plate_or_mask_hit_spot

Fortran source: bmad/modules/bmad_routine_interface.f90

diffraction_plate_or_mask_hit_spot(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct) -> int

Wrapper for Fortran routine diffraction_plate_or_mask_hit_spot

Parameters:
Returns:
  • ix_section( int ) –

    integer, Set to index of clear section hit. Set to zero if photon is outside all clear areas.

diffusion_matrix_b

Fortran source: bmad/multiparticle/envelope_mod.f90

diffusion_matrix_b(gamma: typing.SupportsFloat | typing.SupportsIndex, g_tot: typing.SupportsFloat | typing.SupportsIndex, species: typing.SupportsInt | typing.SupportsIndex, mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> None

Wrapper for Fortran routine diffusion_matrix_b

Parameters:
  • gamma (float) –
  • g_tot (float) –
  • species (int) –
  • mat (2D array of float (shape: 6,6)) –

distance_to_aperture

Fortran source: bmad/modules/bmad_routine_interface.f90

distance_to_aperture(orbit: pybmad._pybmad.CoordStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.DistanceToAperture

Wrapper for Fortran routine distance_to_aperture

Parameters:
  • orbit (CoordStruct) –

    Particle position.

  • particle_at (int) –

    first_track_edge\(, second_track_edge\), or in_between$

  • ele (EleStruct) –

    Element containing aperture.

Returns:
  • no_aperture_here( bool ) –

    True if aperture does not exist at the longitudinal location of the particle.

  • dist( float ) –

    Normalized distance of the particle from the aperture.

do_mode_flip

Fortran source: bmad/modules/bmad_routine_interface.f90

do_mode_flip(ele: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine do_mode_flip

Parameters:
  • ele (EleStruct) –

    Starting Element This parameter is an input/output and is modified in-place. As an output, ele: Flipped element

Returns:
  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

dpc_given_de

Fortran source: bmad/modules/bmad_routine_interface.f90

dpc_given_de(pc_old: typing.SupportsFloat | typing.SupportsIndex, mass: typing.SupportsFloat | typing.SupportsIndex, dE: typing.SupportsFloat | typing.SupportsIndex, dpc: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine dpc_given_de

Parameters:
  • pc_old (float) –
  • mass (float) –
  • dE (float) –
  • dpc (float) –

drift_and_pipe_track_methods_adjustment

Fortran source: bmad/parsing/bmad_parser_mod.f90

drift_and_pipe_track_methods_adjustment(lat: pybmad._pybmad.LatStruct) -> None

Subroutine drift_and_pipe_track_methods_adjustment(lat)

Drift and pipe elements can be used in both photon and non-photon lines. A problem occures if, for example, a lattice file with both photon and non-photon lines contains a line like: drift::*[tracking_method] = taylor So this routine resets drift and pipe tracking_method and mat6_calc_method parameters in photon lines to bmad_standard if needed.

Parameters:
  • lat (LatStruct) –

    Lattice This parameter is an input/output and is modified in-place. As an output, lat: Lattice with tracking methods adjusted if needed.

drift_multipass_name_correction

Fortran source: bmad/parsing/bmad_parser_mod.f90

drift_multipass_name_correction(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine drift_multipass_name_correction

Parameters:

drift_orbit_time

Fortran source: bmad/modules/time_tracker_mod.f90

drift_orbit_time(orbit: pybmad._pybmad.CoordStruct, beta0: typing.SupportsFloat | typing.SupportsIndex, delta_s: typing.SupportsFloat | typing.SupportsIndex | None = None, delta_t: typing.SupportsFloat | typing.SupportsIndex | None = None) -> None

Subroutine drift_orbit_time(orbit, beta0, delta_s, delta_t)

Simple routine to drift a particle orbit in time-based coordinates by a distance delta_s or a time delta_t If the particle has zero longitudinal velocity, then the particle is not drifted and a warning is printed.

Parameters:
  • orbit (CoordStruct) –

    particle orbit in time-based coordinates.

  • beta0 (float) –

    reference velocity v/c.

  • delta_s (float) –

    s-coordinate distance to drift particle.

  • delta_t (float) –

    -coordinate distancet to drift particle.

drift_particle_to_s

Fortran source: bmad/space_charge/space_charge_mod.f90

drift_particle_to_s(p: pybmad._pybmad.CoordStruct, s: typing.SupportsFloat | typing.SupportsIndex, branch: pybmad._pybmad.BranchStruct) -> None

Subroutine drift_particle_to_s (p, s, branch)

Drift a particle to a given s-coordinate

Parameters:
  • p (CoordStruct) –

    Init particle position. This parameter is an input/output and is modified in-place. As an output, p: Final particle position.

  • s (float) –

    Target s coordinate.

  • branch (BranchStruct) –

    Branch being tracked through.

drift_particle_to_t

Fortran source: bmad/space_charge/space_charge_mod.f90

drift_particle_to_t(p: pybmad._pybmad.CoordStruct, t: typing.SupportsFloat | typing.SupportsIndex, branch: pybmad._pybmad.BranchStruct) -> None

Subroutine drift_particle_to_t (p, t, branch)

Drift a particle to a given t-coordinate

Parameters:
  • p (CoordStruct) –

    Init particle position. This parameter is an input/output and is modified in-place. As an output, p: Final particle position.

  • t (float) –

    Target t coordinate.

  • branch (BranchStruct) –

    Lattice branch being tracked through.

dspline_len

Fortran source: bmad/space_charge/csr_and_space_charge_mod.f90

dspline_len(s_chord0: typing.SupportsFloat | typing.SupportsIndex, s_chord1: typing.SupportsFloat | typing.SupportsIndex, spline: pybmad._pybmad.SplineStruct, dtheta_ref: typing.SupportsFloat | typing.SupportsIndex | None = None) -> float

Function dspline_len (s_chord0, s_chord1, spline, dtheta_ref) result (dlen)

Routine to calculate the difference in length between the spline curve length and a referece line. Referece line is centroid chord (referece system of the spline) rotated by dtheta_ref.

Parameters:
  • s_chord0 (float) –

    Start position along centroid chord.

  • s_chord1 (float) –

    Stop position along central_chord.

  • spline (SplineStruct) –

    Spline of x-position as a function of s.

  • dtheta_ref (float) –

    angle to rotate the reference line from the centroid chord. Default is 0.

Returns:
  • dlen( float ) –

    L_spline - L_chord

dynamic_aperture_point

Fortran source: bmad/modules/dynamic_aperture_mod.f90

dynamic_aperture_point(branch: pybmad._pybmad.BranchStruct, ele0: pybmad._pybmad.EleStruct, orb0: pybmad._pybmad.CoordStruct, theta_xy: typing.SupportsFloat | typing.SupportsIndex, ap_param: pybmad._pybmad.ApertureParamStruct, check_xy_init: bool | None = None) -> pybmad._pybmad.AperturePointStruct

Subroutine dynamic_aperture_point (branch, ele0, orb0, theta_xy, ap_param, ap_point, check_xy_init)

Subroutine to determine one dynamic aperture point by tracking. This routine works by determining where on a radial line y = const * x the aperture is. Here x and y are deviations from the reference orbit.

Parameters:
  • branch (BranchStruct) –

    Lattice branch to track through.

  • ele0 (EleStruct) –

    Lattice element at start of tracking

  • orb0 (CoordStruct) –

    reference orbit at the start of tracking.

  • theta_xy (float) –

    Angle of radial line (in radians) in x-y space. Angle is "normalized" by .x_init, .y_init.

  • ap_param (ApertureParamStruct) –

    Structure holding the input data:

  • check_xy_init (bool) –

    If True, do not check that aperture_param.x_init and .y_init are non-zero. Default is True.

Returns:

dynamic_aperture_scan

Fortran source: bmad/modules/dynamic_aperture_mod.f90

dynamic_aperture_scan(aperture_param: pybmad._pybmad.ApertureParamStruct, pz_start: pybmad._pybmad.RealArray1D, lat: pybmad._pybmad.LatStruct, print_timing: bool | None = None) -> pybmad._pybmad.ApertureScanStructAlloc1D

Subroutine dynamic_aperture_scan(aperture_scan, aperture_param, pz_start, lat, print_timing)

Routine to do a set of dynamic aperture scans.

Parameters:
  • aperture_param (ApertureParamStruct) –

    Scan parameters

  • pz_start (1D array of float) –

    Starting phase space pz values.

  • lat (LatStruct) –

    Lattice.

  • print_timing (bool) –

    If True print info on calculation time. Default is True.

Returns:
  • aperture_scan( 1D array of ApertureScanStruct ) –

    Set of scans. One for each pz_start(:).

e_accel_field

Fortran source: bmad/modules/bmad_routine_interface.f90

e_accel_field(ele: pybmad._pybmad.EleStruct, voltage_or_gradient: typing.SupportsInt | typing.SupportsIndex, bmad_standard_tracking: bool | None = None) -> float

Wrapper for Fortran routine e_accel_field

Parameters:
  • ele (EleStruct) –

    Lcavity or rfcavity element.

  • voltage_or_gradient (int) –

    voltage$ or gradient$

  • bmad_standard_tracking (bool) –

    Using bmad_standard tracking? Default is False.

Returns:
  • field( float ) –

    Cavity field or gradient.

e_crit_photon

Fortran source: bmad/photon/photon_init_mod.f90

e_crit_photon(gamma: typing.SupportsFloat | typing.SupportsIndex, g_bend: typing.SupportsFloat | typing.SupportsIndex) -> float

Function E_crit_photon (gamma, g_bend) result (E_crit)

Routine to calculate the photon critical energy in a bend.

Parameters:
  • gamma (float) –

    Gamma factor of charged particle emitting photon.

  • g_bend (float) –

    1/radius bending strength.

Returns:
  • E_crit( float ) –

    Critical photon energy.

eigen_decomp_6mat

Fortran source: bmad/modules/mode3_mod.f90

eigen_decomp_6mat(mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.EigenDecomp6mat

Subroutine eigen_decomp_6mat(mat, eval, evec, tunes, err_flag)

Compute eigenvalues and eigenvectors of a real 6x6 matrix. The evals and evecs are in general complex.

Parameters:
  • mat (2D array of float (shape: 6,6)) –

    6x6 real matrix. Usually a transfer matrix or sigma matrix.

Returns:
  • eval( 1D array of complex (shape: 6) ) –

    complex eigenvalues.

  • evec( 2D array of complex (shape: 6,6) ) –

    complex eigenvectors arranged down columns.

  • err_flag( bool ) –

    set to true if an error has occured.

  • tunes( 1D array of float (shape: 3), optional ) –

    Mode tunes, in radians.

ele_compute_ref_energy_and_time

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_compute_ref_energy_and_time(ele0: pybmad._pybmad.EleStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, err_flag: bool) -> None

Wrapper for Fortran routine ele_compute_ref_energy_and_time

Parameters:
  • ele0 (EleStruct) –

    Previous element in lattice with starting energy and time values.

  • ele (EleStruct) –

    Lattice element This parameter is an input/output and is modified in-place. As an output, ele: Lattice element with reference energy and time.

  • param (LatParamStruct) –

    Lattice parameters.

  • err_flag (bool) –

    Set true if there is an error. False otherwise.

ele_equal_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_equal_ele(ele_out: pybmad._pybmad.EleStruct, ele_in: pybmad._pybmad.EleStruct) -> None

Wrapper for Fortran routine ele_equal_ele

Parameters:

ele_equals_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_equals_ele(ele_in: pybmad._pybmad.EleStruct, update_nametable: bool) -> pybmad._pybmad.EleStruct

Subroutine ele_equals_ele (ele_out, ele_in, update_nametable)

Subroutine that is used to set an element equal to another. Note: Use ele_equal_ele instead unless you know what you are doing.

Parameters:
  • ele_in (EleStruct) –

    Input element.

  • update_nametable (bool) –

    If true, update the nametable. If false, do not. Note: nametable updates can take time if this routine is called a many times. See remove_eles_from_lat as an example.

Returns:

ele_finalizer

Fortran source: bmad/modules/bmad_struct.f90

ele_finalizer(ele: pybmad._pybmad.EleStruct) -> None

Subroutine ele_finalizer(ele)

Finalizer routine for ele_struct instances. NOTE: Not currently used.

Parameters:
  • ele (EleStruct) –

    Element to cleanup. This parameter is an input/output and is modified in-place. As an output, ele: Element with pointers deallocated as needed.

ele_full_name

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_full_name(ele: pybmad.pybmad.EleStruct, template: str | None = None) -> str

Wrapper for Fortran routine ele_full_name

Parameters:
Returns:
  • str( str ) –

    : Name/location string.

ele_geometry

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_geometry(floor_start: pybmad._pybmad.FloorPositionStruct, ele: pybmad._pybmad.EleStruct, len_scale: typing.SupportsFloat | typing.SupportsIndex | None = None, ignore_patch_err: bool | None = None) -> pybmad._pybmad.FloorPositionStruct

Wrapper for Fortran routine ele_geometry

Parameters:
  • floor_start (FloorPositionStruct) –

    Starting floor coordinates at upstream end. Not used for fiducial and girder elements.

  • ele (EleStruct) –

    Element to propagate the geometry through.

  • len_scale (float) –

    factor to scale the length of the element. 1.0_rp => Output is geometry at end of element (default). 0.5_rp => Output is geometry at center of element. -1.0_rp => Used to propagate geometry in reverse.

  • ignore_patch_err (bool) –

    If present and True, ignore flexible patch errors. This is used by ele_compute_ref_energy_and_time to suppress unnecessary messages.

Returns:
  • floor_end( (FloorPositionStruct, optional) ) –

    Output floor position. If not present then ele.floor will be used and ele.bookkeeping_state.floor_position will be set to ok$.

ele_geometry_with_misalignments

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_geometry_with_misalignments(ele: pybmad._pybmad.EleStruct, len_scale: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.FloorPositionStruct

Wrapper for Fortran routine ele_geometry_with_misalignments

Parameters:
  • ele (EleStruct) –

    Lattice element under consideration.

  • len_scale (float) –

    factor to scale the length of the element. 1.0_rp => Output is geometry at end of element (default). 0.5_rp => Output is geometry at center of element. -1.0_rp => Used to propagate geometry in reverse.

Returns:

ele_has_constant_ds_dt_ref

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_has_constant_ds_dt_ref(ele: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine ele_has_constant_ds_dt_ref

Parameters:
Returns:
  • is_const( bool ) –

    True if reference velocity must be a constant.

ele_has_nonzero_kick

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_has_nonzero_kick(ele: pybmad._pybmad.EleStruct, has_kick: bool) -> None

Wrapper for Fortran routine ele_has_nonzero_kick

Parameters:
  • ele (EleStruct) –

    Element with possible nonzero kicks. This parameter is an input/output and is modified in-place. As an output, ele: Element with no kicks.

  • has_kick (bool) –

ele_has_nonzero_offset

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_has_nonzero_offset(ele: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine ele_has_nonzero_offset

Parameters:
  • ele (EleStruct) –

    Element with possible nonzero offsets.

Returns:
  • has_offset( bool ) –

    Set true is element has a non-zero offset.

ele_is_monitor

Fortran source: bmad/modules/measurement_mod.f90

ele_is_monitor(ele: pybmad._pybmad.EleStruct, print_warning: bool | None = None) -> bool

Function ele_is_monitor (ele, print_warning) result (is_monitor)

Routine to check that an element is either a detector, instrument, monitor, or marker. These are the elements where measurement errors can be defined.

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • print_warning (bool) –

    If True print a warning message if the element not a monitor like element. Default is True.

Returns:
  • is_monitor( bool ) –

    Set True if the element is a monitor like element.

ele_loc

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_loc(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.LatEleLocStruct

Wrapper for Fortran routine ele_loc

Parameters:
  • ele (EleStruct) –

    Element to be identified

Returns:

ele_loc_name

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_loc_name(ele: pybmad._pybmad.EleStruct, show_branch0: bool | None = None, parens: str | None = None) -> str

Wrapper for Fortran routine ele_loc_name

Parameters:
  • ele (EleStruct) –

    Element in a lattice

  • show_branch0 (bool) –

    Explicitly show branch for main lattice elements? Default is False.

  • parens (str) –

    If present, enclose location string using the two characters supplied. Typically parens will be set to "()" or "[]".

Returns:
  • str( str ) –

    Output string. Left justified.

ele_misalignment_l_s_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_misalignment_l_s_calc(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.EleMisalignmentLSCalc

Wrapper for Fortran routine ele_misalignment_l_s_calc

Parameters:
Returns:
  • L_mis( 1D array of float (shape: 3) ) –

    Misalignment vector relative to center of element

  • S_mis( 2D array of float (shape: 3,3) ) –

    Misalignment matrix relative to center of element

ele_nametable_index

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_nametable_index(ele: pybmad._pybmad.EleStruct) -> int

Wrapper for Fortran routine ele_nametable_index

Parameters:
Returns:
  • ix_nt( int ) –

    Nametable index. lat.nametable.name(ix_nt) and lat.nametable.index(ix_nt) correspond with ele. Set to -1 if ele is not a lattice element. For example, a slice_slave is not a lattice element.

ele_order_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_order_calc(lat: pybmad._pybmad.LatStruct) -> pybmad._pybmad.LatEleOrderStruct

Wrapper for Fortran routine ele_order_calc

Parameters:
Returns:

ele_reference_energy_correction

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_reference_energy_correction(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine ele_reference_energy_correction

Parameters:
  • ele (EleStruct) –

    Element being tracked through.

  • orbit (CoordStruct) –

    Coordinates to correct.

  • particle_at (int) –

    first_track_edge$ (that is, entering the element), or second_track_edge$ (that is, leaving the element), or upstream_end$ (inherit ele.value(p0c_start\() ref), or downstream_end\) (inherit ele.value(p0c\()). inside\) (or anything else) -> Do nothing.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before correction. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix including correction.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

ele_rf_step_index

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_rf_step_index(E_ref: typing.SupportsFloat | typing.SupportsIndex, s_rel: typing.SupportsFloat | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct) -> int

Wrapper for Fortran routine ele_rf_step_index

Parameters:
  • E_ref (float) –

    Reference energy of step. If negative, ignore and use s_rel.

  • s_rel (float) –

    S-position relative to the beginning of the element

  • ele (EleStruct) –

    RF cavity.

Returns:
  • ix_step( int ) –

    Corresponding index in the ele.rf.steps(:) array.

ele_to_fibre

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_to_fibre(ele: pybmad._pybmad.EleStruct, use_offsets: bool, integ_order: typing.SupportsInt | typing.SupportsIndex | None = None, steps: typing.SupportsInt | typing.SupportsIndex | None = None, for_layout: bool | None = None, ref_in: pybmad._pybmad.CoordStruct | None = None) -> pybmad._pybmad.EleToFibre

Wrapper for Fortran routine ele_to_fibre

Parameters:
  • ele (EleStruct) –

    Bmad element.

  • use_offsets (bool) –

    Does ptc_fibre include element offsets, pitches and tilt?

  • integ_order (int) –

    Order for the sympletic integrator. Possibilities are: 2, 4, or 6 Overrides ele.value(integrator_order$). default = 2 (if not set with set_ptc).

  • steps (int) –

    Number of integration steps. Overrides ele.value(ds_step$).

  • for_layout (bool) –

    If True then fibre will be put in the PTC layout. Default is False.

  • ref_in (CoordStruct) –

    Particle to be tracked. ref_particle\(, electron\), etc. This argument should only be present when the fibre is not to be put in a layout.

Returns:
  • err_flag( bool ) –

    Set True if setup OK. False otherwise.

  • ptc_fibre( (Fibre, optional) ) –

    PTC fibre element.

ele_to_ptc_magnetic_bn_an

Fortran source: bmad/ptc/ptc_interface_mod.f90

ele_to_ptc_magnetic_bn_an(ele: pybmad._pybmad.EleStruct, bn: pybmad._pybmad.RealArray1D, an: pybmad._pybmad.RealArray1D) -> int

Subroutine ele_to_ptc_magnetic_bn_an (ele, bn, an, n_max)

Routine to compute the a(n) and b(n) magnetic multipole components of a magnet. This is used to interface between eles and PTC fibres

Note: The multipole index uses the PTC convention of starting from 1 instead of zero.

Note: On the PTC side bn(1) is error field when creating a fibre but is the total field when the fibre is being modified. This routine returns the error field.

Parameters:
  • ele (EleStruct) –

    Bmad Element.

  • bn (1D array of float) –

    Normal multipole component.

  • an (1D array of float) –

    Skew multipole component.

Returns:
  • n_max( (int, optional) ) –

    Maximum non-zero multipole component. Set to zero if there are no multipoles.

ele_to_spin_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_to_spin_taylor(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orb0: pybmad._pybmad.CoordStruct) -> None

Wrapper for Fortran routine ele_to_spin_taylor

Parameters:
  • ele (EleStruct) –

    Lattice element. This parameter is an input/output and is modified in-place. As an output, ele: Element with spin map.

  • param (LatParamStruct) –

    Branch parameters.

  • orb0 (CoordStruct) –

    Starting ref coords.

ele_to_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_to_taylor(ele: pybmad._pybmad.EleStruct, orb0: pybmad._pybmad.CoordStruct | None = None, taylor_map_includes_offsets: bool | None = None, include_damping: bool | None = None) -> pybmad._pybmad.EleToTaylor

Wrapper for Fortran routine ele_to_taylor

Parameters:
  • ele (EleStruct) –

    Element to construct map for.

  • orb0 (CoordStruct) –

    Starting coords around which the Taylor map is evaluated. Default is the zero orbit.

  • taylor_map_includes_offsets (bool) –

    If present then value overrides ele.taylor_map_includes_offsets.

  • include_damping (bool) –

    Sets if radiation damping is included. Default is what is set in ptc_private.base_state.

Returns:
  • orbital_taylor( 1D array of TaylorStruct (shape: 6), optional ) –

    Orbital taylor map. If not present then the map is put in ele.taylor.

  • spin_taylor( 1D array of TaylorStruct (shape: 0:3), optional ) –

    Spin taylor map. If not present then the map is put in ele.spin_taylor.

ele_unique_name

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_unique_name(ele: pybmad._pybmad.EleStruct, order: pybmad._pybmad.LatEleOrderStruct) -> str

Wrapper for Fortran routine ele_unique_name

Parameters:
  • ele (EleStruct) –

    Element to construct a unique name for.

  • order (LatEleOrderStruct) –

    Information on element ordering. Before calling this routine, use the routine ele_order_calc to compute this argument.

Returns:
  • unique_name( str ) –

    Unique name that can can be used to identify ele. The simplist name will be constructed. For example, if the element name is unique, unique_name will be set to the element name.

ele_value_has_changed

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_value_has_changed(ele: pybmad._pybmad.EleStruct, list: pybmad._pybmad.IntArray1D, abs_tol: pybmad._pybmad.RealArray1D, set_old: bool) -> bool

Wrapper for Fortran routine ele_value_has_changed

Parameters:
  • ele (EleStruct) –

    Element under consideration. This parameter is an input/output and is modified in-place. As an output, ele: ele.old_value may be set depending upon setting of set_old

  • list (1D array of int) –

    List of indexes of ele.value(:) array to check.

  • abs_tol (1D array of float) –

    List of values such that if the change in parameter value is less than this it is not considered to have changed significantly.

  • set_old (bool) –

    If True then set ele.old_value(j) = ele.value(j) for j in list

Returns:
  • has_changed( bool ) –

    Set True if a value has changed significantly.

ele_vec_equal_ele_vec

Fortran source: bmad/modules/bmad_routine_interface.f90

ele_vec_equal_ele_vec(ele1: pybmad._pybmad.EleStructArray1D, ele2: pybmad._pybmad.EleStructArray1D) -> None

Wrapper for Fortran routine ele_vec_equal_ele_vec

Parameters:
  • ele1 (1D array of EleStruct) –
  • ele2 (1D array of EleStruct) –

elec_multipole_field

Fortran source: bmad/modules/bmad_routine_interface.f90

elec_multipole_field(a: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex, coord: pybmad._pybmad.CoordStruct) -> pybmad._pybmad.ElecMultipoleField

Wrapper for Fortran routine elec_multipole_field

Parameters:
  • a (float) –

    Multipole skew component.

  • b (float) –

    Multipole normal component.

  • n (int) –

    Multipole order.

  • coord (CoordStruct) –
Returns:
  • Ex( float ) –

    X field component

  • Ey( float ) –

    Y field component.

  • dE( 2D array of float (shape: 2,2), optional ) –

    Field derivatives: dfield(x,y)/d(x,y).

  • compute_dE( (bool, optional) ) –

    If False, do not compute the field derivatives even if dE is present. Default is True.

element_at_s

Fortran sources (overloaded):

element_at_s(args, *kwargs) Overloaded function.

  1. element_at_s(branch: pybmad._pybmad.BranchStruct, s: typing.SupportsFloat | typing.SupportsIndex, choose_max: bool, print_err: bool | None = None) -> pybmad._pybmad.ElementAtSBranch

Function element_at_s (...) result (ix_ele)

Function to return the index of the element at position s.

element_at_s is an overloaded name for: function element_at_s_lat (lat, s, choose_max, ix_branch, err_flag, s_eff, position, print_err) result (ix_ele) function element_at_s_branch (branch, s, choose_max, err_flag, s_eff, position, print_err) result (ix_ele)

The differnce between these two routine is that with element_at_s_lat, the branch is given by the lat and ix_ele arguments: branch = lat%branch(ix_ele). With element_at_s_branch, the branch is an argument.

Also see: pointer_to_element_at_s

ix_ele is choisen such that: If choose_max = True: If s = branch%ele(ix_end_of_branch): ix_ele = ix_end_of_branch Else: branch%ele(ix_ele)%s_start <= s < branch%ele(ix_ele)%s If choose_max = False: If s = branch%ele(0)%s: ix_ele = 0 Else: branch%ele(ix_ele)%s_start < s <= branch%ele(ix_ele)%s That is, if s corresponds to an element boundary between elements with indexes ix1 and ix2 = ix1 + 1: choose_max = True => ix_ele = ix2 choose_max = False => ix_ele = ix1

The setting of choose_max only makes a difference when s corresponds to an element boundary.

Note: For a circular lattice, s is evaluated at the effective s which is modulo the branch length: s_eff = s - branch_length * floor(s/branch_length)

Note: If there are multiple elements that are at the given s position due to the presence of an element with a negative length, which of the possible elements is actually chosen is ill-defined.

Parameters:
  • branch (BranchStruct) –

    Branch to use

  • s (float) –

    Longitudinal position.

  • choose_max (bool) –

    See above

  • print_err (bool) –

    Print error message if there is an error? Default is True.

Returns:
  • ix_ele( int ) –

    Index of element at s.

  • err_flag( (bool, optional) ) –

    Set True if s is out of bounds. False otherwise.

  • s_eff( (float, optional) ) –

    Effective s. Equal to s with a open lattice. See above.

  • position( (CoordStruct, optional) ) –

    Positional information.

  • 2. element_at_s(lat: pybmad._pybmad.LatStruct, s: typing.SupportsFloat | typing.SupportsIndex, choose_max: bool, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, print_err: bool | None = None) -> pybmad._pybmad.ElementAtSLat
  • Function element_at_s (...) result (ix_ele)
  • Function to return the index of the element at position s.
  • element_at_s is an overloaded name for:

    function element_at_s_lat (lat, s, choose_max, ix_branch, err_flag, s_eff, position, print_err) result (ix_ele) function element_at_s_branch (branch, s, choose_max, err_flag, s_eff, position, print_err) result (ix_ele)

  • The differnce between these two routine is that with element_at_s_lat, the branch is given by the lat

    and ix_ele arguments: branch = lat%branch(ix_ele). With element_at_s_branch, the branch is an argument.

  • Also see: pointer_to_element_at_s
  • ix_ele is choisen such that:
  • If choose_max = True:

    If s = branch%ele(ix_end_of_branch): ix_ele = ix_end_of_branch Else: branch%ele(ix_ele)%s_start <= s < branch%ele(ix_ele)%s

  • If choose_max = False:

    If s = branch%ele(0)%s: ix_ele = 0 Else: branch%ele(ix_ele)%s_start < s <= branch%ele(ix_ele)%s

  • That is, if s corresponds to an element boundary between elements with indexes ix1 and ix2 = ix1 + 1:

    choose_max = True => ix_ele = ix2 choose_max = False => ix_ele = ix1

  • The setting of choose_max only makes a difference when s corresponds to an element boundary.
  • Note( For a circular lattice, s is evaluated at the effective s which ) –
  • is modulo the branch length:

    s_eff = s - branch_length * floor(s/branch_length)

  • Note( If there are multiple elements that are at the given s position due to the presence of ) –
  • an element with a negative length, which of the possible elements is actually chosen is ill-defined.
Parameters:
  • lat (LatStruct) –

    Lattice of elements.

  • s (float) –

    Longitudinal position.

  • choose_max (bool) –

    See above

  • ix_branch (int) –

    Branch index. Default is 0.

  • print_err (bool) –

    Print error message if there is an error? Default is True.

Returns:
  • ix_ele( int ) –

    Index of element at s.

  • err_flag( (bool, optional) ) –

    Set True if s is out of bounds. False otherwise.

  • s_eff( (float, optional) ) –

    Effective s. Equal to s with a open lattice. See above.

  • position( (CoordStruct, optional) ) –

    Positional information.

element_slice_iterator

Fortran source: bmad/modules/bmad_routine_interface.f90

element_slice_iterator(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, i_slice: typing.SupportsInt | typing.SupportsIndex, n_slice_tot: typing.SupportsInt | typing.SupportsIndex, sliced_ele: pybmad._pybmad.EleStruct, s_start: typing.SupportsFloat | typing.SupportsIndex | None = None, s_end: typing.SupportsFloat | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine element_slice_iterator

Parameters:
  • ele (EleStruct) –

    Element to slice and dice.

  • param (LatParamStruct) –

    Lattice parameters

  • i_slice (int) –

    Slice index

  • n_slice_tot (int) –

    Total number of slices.

  • sliced_ele (EleStruct) –
  • s_start (float) –

    Starting edge of slice relative to beginning of element.

  • s_end (float) –

    Ending edge of slice relative to beginning of element.

ellipinc_test

Fortran source: bmad/space_charge/csr3d_mod.f90

ellipinc_test() -> None

Wrapper for Fortran routine ellipinc_test

em_field_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

em_field_calc(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, s_pos: typing.SupportsFloat | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, local_ref_frame: bool, calc_dfield: bool | None = None, calc_potential: bool | None = None, use_overlap: bool | None = None, grid_allow_s_out_of_bounds: bool | None = None, rf_time: typing.SupportsFloat | typing.SupportsIndex | None = None, used_eles: pybmad._pybmad.ElePointerStructAlloc1D | None = None, print_err: bool | None = None, original_ele: pybmad._pybmad.EleStruct | None = None) -> pybmad._pybmad.EmFieldCalc

Wrapper for Fortran routine em_field_calc

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • param (LatParamStruct) –

    Lattice parameters.

  • s_pos (float) –

    Longitudinal position. If local_ref_frame = T: In Body coords relative to the entrance edge of the element. If local_ref_frame = F: In Lab coords relative to the upstream edge of the element.

  • orbit (CoordStruct) –

    Transverse coordinates.

  • local_ref_frame (bool) –

    Logical, If True then take the input coordinates and output fields as being with respect to the frame of referene of the element (ignore misalignments).

  • calc_dfield (bool) –

    If present and True then calculate the field derivatives.

  • calc_potential (bool) –

    Calc electric and magnetic potentials? Default is false. This is experimental and only implemented for wigglers at present.

  • use_overlap (bool) –

    Add in overlap fields from other elements? Default is True.

  • grid_allow_s_out_of_bounds (bool) –

    For grids, allow s-coordinate to be grossly out of bounds and return zero instead of an error? Default: False. Used internally for overlapping fields.

  • rf_time (float) –

    Set the time relative to the RF clock. Normally this time is calculated using orbit.t or orbit.vec(5) but sometimes it is convenient to be able to override this. For example, time_runge_kutta uses this.

  • used_eles (1D array of ElePointerStruct) –

    For internal use only when this routine is called recursively. Used to prevent double counting when there is field overlap.

  • print_err (bool) –

    Print an error message? Default is True. For example, if the particle is out of bounds when the field is defined on a grid.

  • original_ele (EleStruct) –

    Used with recursive calls that pass the lord as the ele argument. In this case original_ele is the original ele argument.

Returns:
  • field( EmFieldStruct ) –

    E and B fields and derivatives.

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

em_field_derivatives

Fortran source: bmad/modules/em_field_mod.f90

em_field_derivatives(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, s_pos: typing.SupportsFloat | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, local_ref_frame: bool, grid_allow_s_out_of_bounds: bool | None = None, rf_time: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.EmFieldStruct

Subroutine em_field_derivatives (ele, param, s_pos, orbit, local_ref_frame, dfield, grid_allow_s_out_of_bounds, rf_time)

Routine to calculate field derivatives. In theory this should be handled by em_filed_calc. In practice, em_field_calc is currently incomplete.

Parameters:
  • ele (EleStruct) –

    Element

  • param (LatParamStruct) –

    Lattice parameters.

  • s_pos (float) –

    Longitudinal position relative to the upstream edge of the element.

  • orbit (CoordStruct) –

    Transverse coordinates.

  • local_ref_frame (bool) –

    Logical, If True then take the input coordinates and output fields as being with respect to the frame of referene of the element (ignore misalignments).

  • grid_allow_s_out_of_bounds (bool) –

    For grids, allow s-coordinate to be grossly out of bounds and return zero instead of an error? Default: False. Used internally for overlapping fields.

  • rf_time (float) –

    RF clock time. If not present then the time will be calculated using the standard algorithm.

Returns:
  • dfield( EmFieldStruct ) –

    E and B field derivatives. dfield.E and dfield.B are not touched.

em_field_kick_vector_time

Fortran source: bmad/modules/time_tracker_mod.f90

em_field_kick_vector_time(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, rf_time: typing.SupportsFloat | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, err_flag: bool, print_err: bool | None = None, extra_field: pybmad._pybmad.EmFieldStruct | None = None) -> typing.Annotated[list[float], "FixedSize(10)"]

Subroutine em_field_kick_vector_time (ele, param, rf_time, orbit, dvec_dt, err_flag, print_err, extra_field))

Subroutine to convert particle coordinates from t-based to s-based system.

Parameters:
  • ele (EleStruct) –

    input particle

  • param (LatParamStruct) –

    Reference momentum. The sign indicates direction of p_s.

  • rf_time (float) –

    RF time.

  • orbit (CoordStruct) –

    in t-based system

  • err_flag (bool) –

    Set True if there is an error. False otherwise.

  • print_err (bool) –

    Passed to em_field_calc

  • extra_field (EmFieldStruct) –

    Static field to be added to the element field. Eg used with space charge.

Returns:
  • dvec_dt( 1D array of float (shape: 10) ) –

    Derivatives.

em_field_plus_em_field

Fortran source: bmad/modules/bmad_routine_interface.f90

em_field_plus_em_field(field1: pybmad._pybmad.EmFieldStruct, field2: pybmad._pybmad.EmFieldStruct, field_tot: pybmad._pybmad.EmFieldStruct) -> None

Wrapper for Fortran routine em_field_plus_em_field

Parameters:

emit_6d

Fortran source: bmad/modules/rad_6d_mod.f90

emit_6d(ele_ref: pybmad._pybmad.EleStruct, include_opening_angle: bool, closed_orbit: pybmad._pybmad.CoordStructArray1D | None = None) -> pybmad._pybmad.Emit6d

Subroutine emit_6d (ele_ref, include_opening_angle, mode, sigma_mat, closed_orbit, rad_int_by_ele)

Routine to calculate the three normal mode emittances, damping partition numbers, radiation integrals, etc. Since the emattances, etc. are only an invariant in the limit of zero damping, the calculated values will vary depending upon the reference element.

If the lattice geometry is open, only the radiation integrals is computed.

Parameters:
  • ele_ref (EleStruct) –

    Origin of the 1-turn maps used to evaluate the emittances.

  • include_opening_angle (bool) –

    If True include the effect of the vertical opening angle of emitted radiation. Generally use True unless comparing against other codes.

  • closed_orbit (1D array of CoordStruct) –

    Closed orbit. If not present this routine will calculate it.

Returns:
  • mode( NormalModesStruct ) –

    Emittance and other info.

  • sigma_mat( 2D array of float (shape: 6,6) ) –

    Sigma matrix.

  • rad_int_by_ele( (RadIntAllEleStruct, optional) ) –

    Radiation integrals element-by-element.

entering_element

Fortran source: bmad/modules/bmad_routine_interface.f90

entering_element(orbit: pybmad._pybmad.CoordStruct, particle_at: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine entering_element

Parameters:
  • orbit (CoordStruct) –

    Particle orbit.

  • particle_at (int) –

    First_track_edge$ or second_track_edge$

Returns:
  • is_entering( bool ) –

    Set True if particle is going from outside to inside and vice versa.

envelope_radints

Fortran source: bmad/multiparticle/envelope_mod.f90

envelope_radints(Lambda: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], Theta: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], Iota: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], alpha: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], emit: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> None

subroutine envelope_radints(Lambda,Theta,Iota,alpha,emit)

Calculates damping decrement and emittance of the three normal modes from the integrate diffusion, damping, and vertical excitation matrices names Lambda, Theta, and Iota, respectively. These three matrices are obtained from the subroutine integrated_mats.

The damping times can obtained from alpha using: tau = lattice_length/c_light/alpha

envelope_radints_ibs

Fortran source: bmad/multiparticle/envelope_mod.f90

envelope_radints_ibs(Lambda: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], Theta: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], Iota: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], eles: pybmad._pybmad.EleStructArray1D, mode: pybmad._pybmad.NormalModesStruct, tail_cut: bool, npart: typing.SupportsFloat | typing.SupportsIndex, species: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.EnvelopeRadintsIbs

subroutine envelope_radints_ibs(Lambda, Theta, Iota, eles, alpha, emit, mode, tail_cut, npart, species)

Calculates damping decrement and emittance of the three normal modes by integrating the IBS, SR diffusion, and SR damping matrices.

The IBS depends on the envelope, and so this routine iterates to locate the equilibrium beam envelope. This iterative process can fail to converge.

The damping times can obtained from alpha using: tau = lattice_length/c_light/alpha

alpha and emit are quantities for the three normal modes. alpha and emit are ordered by plane dominance.

Only radiation from sbends and rbends is taken into account. The one-turn transfer matrix at each element (slice) is obtained by concatenating the individual element transfer matrices.

Parameters:
  • Lambda (2D array of complex (shape: 6,6)) –

    Integrated damping matrix.

  • Theta (2D array of complex (shape: 6,6)) –

    Integrated diffusion matrix.

  • Iota (2D array of complex (shape: 6,6)) –

    Integrated vertical excitation matrix.

  • eles (1D array of EleStruct) –

    array of element structures representing ring.

  • mode (NormalModesStruct) –

    normal_modes_struct

  • tail_cut (bool) –

    apply tail cut.

  • npart (float) –

    number of particles in bunch.

  • species (int) –

    Particle species.

Returns:
  • alpha( 1D array of float (shape: 3) ) –

    Normal mode damping decrements.

  • emit( 1D array of float (shape: 3) ) –

    Normal mode emittances.

eq_ac_kicker

Fortran source: bmad/modules/equality_mod.f90

eq_ac_kicker(f1: pybmad._pybmad.AcKickerStruct, f2: pybmad._pybmad.AcKickerStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_ac_kicker

Parameters:

eq_ac_kicker_freq

Fortran source: bmad/modules/equality_mod.f90

eq_ac_kicker_freq(f1: pybmad._pybmad.AcKickerFreqStruct, f2: pybmad._pybmad.AcKickerFreqStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_ac_kicker_freq

Parameters:

eq_ac_kicker_time

Fortran source: bmad/modules/equality_mod.f90

eq_ac_kicker_time(f1: pybmad._pybmad.AcKickerTimeStruct, f2: pybmad._pybmad.AcKickerTimeStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_ac_kicker_time

Parameters:

eq_anormal_mode

Fortran source: bmad/modules/equality_mod.f90

eq_anormal_mode(f1: pybmad._pybmad.AnormalModeStruct, f2: pybmad._pybmad.AnormalModeStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_anormal_mode

Parameters:

eq_aperture_param

Fortran source: bmad/modules/equality_mod.f90

eq_aperture_param(f1: pybmad._pybmad.ApertureParamStruct, f2: pybmad._pybmad.ApertureParamStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_aperture_param

Parameters:

eq_aperture_point

Fortran source: bmad/modules/equality_mod.f90

eq_aperture_point(f1: pybmad._pybmad.AperturePointStruct, f2: pybmad._pybmad.AperturePointStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_aperture_point

Parameters:

eq_aperture_scan

Fortran source: bmad/modules/equality_mod.f90

eq_aperture_scan(f1: pybmad._pybmad.ApertureScanStruct, f2: pybmad._pybmad.ApertureScanStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_aperture_scan

Parameters:

eq_beam

Fortran source: bmad/modules/equality_mod.f90

eq_beam(f1: pybmad._pybmad.BeamStruct, f2: pybmad._pybmad.BeamStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_beam

Parameters:

eq_beam_init

Fortran source: bmad/modules/equality_mod.f90

eq_beam_init(f1: pybmad._pybmad.BeamInitStruct, f2: pybmad._pybmad.BeamInitStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_beam_init

Parameters:

eq_bmad_common

Fortran source: bmad/modules/equality_mod.f90

eq_bmad_common(f1: pybmad._pybmad.BmadCommonStruct, f2: pybmad._pybmad.BmadCommonStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_bmad_common

Parameters:

eq_bookkeeping_state

Fortran source: bmad/modules/equality_mod.f90

eq_bookkeeping_state(f1: pybmad._pybmad.BookkeepingStateStruct, f2: pybmad._pybmad.BookkeepingStateStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_bookkeeping_state

Parameters:

eq_bpm_phase_coupling

Fortran source: bmad/modules/equality_mod.f90

eq_bpm_phase_coupling(f1: pybmad._pybmad.BpmPhaseCouplingStruct, f2: pybmad._pybmad.BpmPhaseCouplingStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_bpm_phase_coupling

Parameters:

eq_branch

Fortran source: bmad/modules/equality_mod.f90

eq_branch(f1: pybmad._pybmad.BranchStruct, f2: pybmad._pybmad.BranchStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_branch

Parameters:

eq_bunch

Fortran source: bmad/modules/equality_mod.f90

eq_bunch(f1: pybmad._pybmad.BunchStruct, f2: pybmad._pybmad.BunchStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_bunch

Parameters:

eq_bunch_params

Fortran source: bmad/modules/equality_mod.f90

eq_bunch_params(f1: pybmad._pybmad.BunchParamsStruct, f2: pybmad._pybmad.BunchParamsStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_bunch_params

Parameters:

eq_cartesian_map

Fortran source: bmad/modules/equality_mod.f90

eq_cartesian_map(f1: pybmad._pybmad.CartesianMapStruct, f2: pybmad._pybmad.CartesianMapStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_cartesian_map

Parameters:

eq_cartesian_map_term

Fortran source: bmad/modules/equality_mod.f90

eq_cartesian_map_term(f1: pybmad._pybmad.CartesianMapTermStruct, f2: pybmad._pybmad.CartesianMapTermStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_cartesian_map_term

Parameters:

eq_cartesian_map_term1

Fortran source: bmad/modules/equality_mod.f90

eq_cartesian_map_term1(f1: pybmad._pybmad.CartesianMapTerm1Struct, f2: pybmad._pybmad.CartesianMapTerm1Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_cartesian_map_term1

Parameters:

eq_complex_taylor

Fortran source: bmad/modules/equality_mod.f90

eq_complex_taylor(f1: pybmad._pybmad.ComplexTaylorStruct, f2: pybmad._pybmad.ComplexTaylorStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_complex_taylor

Parameters:

eq_complex_taylor_term

Fortran source: bmad/modules/equality_mod.f90

eq_complex_taylor_term(f1: pybmad._pybmad.ComplexTaylorTermStruct, f2: pybmad._pybmad.ComplexTaylorTermStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_complex_taylor_term

Parameters:

eq_control

Fortran source: bmad/modules/equality_mod.f90

eq_control(f1: pybmad._pybmad.ControlStruct, f2: pybmad._pybmad.ControlStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_control

Parameters:

eq_control_ramp1

Fortran source: bmad/modules/equality_mod.f90

eq_control_ramp1(f1: pybmad._pybmad.ControlRamp1Struct, f2: pybmad._pybmad.ControlRamp1Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_control_ramp1

Parameters:

eq_control_var1

Fortran source: bmad/modules/equality_mod.f90

eq_control_var1(f1: pybmad._pybmad.ControlVar1Struct, f2: pybmad._pybmad.ControlVar1Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_control_var1

Parameters:

eq_controller

Fortran source: bmad/modules/equality_mod.f90

eq_controller(f1: pybmad._pybmad.ControllerStruct, f2: pybmad._pybmad.ControllerStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_controller

Parameters:

eq_coord

Fortran source: bmad/modules/equality_mod.f90

eq_coord(f1: pybmad._pybmad.CoordStruct, f2: pybmad._pybmad.CoordStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_coord

Parameters:

eq_coord_array

Fortran source: bmad/modules/equality_mod.f90

eq_coord_array(f1: pybmad._pybmad.CoordArrayStruct, f2: pybmad._pybmad.CoordArrayStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_coord_array

Parameters:

eq_cylindrical_map

Fortran source: bmad/modules/equality_mod.f90

eq_cylindrical_map(f1: pybmad._pybmad.CylindricalMapStruct, f2: pybmad._pybmad.CylindricalMapStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_cylindrical_map

Parameters:

eq_cylindrical_map_term

Fortran source: bmad/modules/equality_mod.f90

eq_cylindrical_map_term(f1: pybmad._pybmad.CylindricalMapTermStruct, f2: pybmad._pybmad.CylindricalMapTermStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_cylindrical_map_term

Parameters:

eq_cylindrical_map_term1

Fortran source: bmad/modules/equality_mod.f90

eq_cylindrical_map_term1(f1: pybmad._pybmad.CylindricalMapTerm1Struct, f2: pybmad._pybmad.CylindricalMapTerm1Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_cylindrical_map_term1

Parameters:

eq_ele

Fortran source: bmad/modules/equality_mod.f90

eq_ele(f1: pybmad._pybmad.EleStruct, f2: pybmad._pybmad.EleStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_ele

Parameters:

eq_ellipse_beam_init

Fortran source: bmad/modules/equality_mod.f90

eq_ellipse_beam_init(f1: pybmad._pybmad.EllipseBeamInitStruct, f2: pybmad._pybmad.EllipseBeamInitStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_ellipse_beam_init

Parameters:

eq_em_field

Fortran source: bmad/modules/equality_mod.f90

eq_em_field(f1: pybmad._pybmad.EmFieldStruct, f2: pybmad._pybmad.EmFieldStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_em_field

Parameters:

eq_expression_atom

Fortran source: bmad/modules/equality_mod.f90

eq_expression_atom(f1: pybmad._pybmad.ExpressionAtomStruct, f2: pybmad._pybmad.ExpressionAtomStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_expression_atom

Parameters:

eq_floor_position

Fortran source: bmad/modules/equality_mod.f90

eq_floor_position(f1: pybmad._pybmad.FloorPositionStruct, f2: pybmad._pybmad.FloorPositionStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_floor_position

Parameters:

eq_gen_grad1

Fortran source: bmad/modules/equality_mod.f90

eq_gen_grad1(f1: pybmad._pybmad.GenGrad1Struct, f2: pybmad._pybmad.GenGrad1Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_gen_grad1

Parameters:

eq_gen_grad_map

Fortran source: bmad/modules/equality_mod.f90

eq_gen_grad_map(f1: pybmad._pybmad.GenGradMapStruct, f2: pybmad._pybmad.GenGradMapStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_gen_grad_map

Parameters:

eq_gg_taylor

Fortran source: bmad/modules/equality_mod.f90

eq_gg_taylor(f1: pybmad._pybmad.GgTaylorStruct, f2: pybmad._pybmad.GgTaylorStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_gg_taylor

Parameters:

eq_gg_taylor_term

Fortran source: bmad/modules/equality_mod.f90

eq_gg_taylor_term(f1: pybmad._pybmad.GgTaylorTermStruct, f2: pybmad._pybmad.GgTaylorTermStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_gg_taylor_term

Parameters:

eq_grid_beam_init

Fortran source: bmad/modules/equality_mod.f90

eq_grid_beam_init(f1: pybmad._pybmad.GridBeamInitStruct, f2: pybmad._pybmad.GridBeamInitStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_grid_beam_init

Parameters:

eq_grid_field

Fortran source: bmad/modules/equality_mod.f90

eq_grid_field(f1: pybmad._pybmad.GridFieldStruct, f2: pybmad._pybmad.GridFieldStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_grid_field

Parameters:

eq_grid_field_pt

Fortran source: bmad/modules/equality_mod.f90

eq_grid_field_pt(f1: pybmad._pybmad.GridFieldPtStruct, f2: pybmad._pybmad.GridFieldPtStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_grid_field_pt

Parameters:

eq_grid_field_pt1

Fortran source: bmad/modules/equality_mod.f90

eq_grid_field_pt1(f1: pybmad._pybmad.GridFieldPt1Struct, f2: pybmad._pybmad.GridFieldPt1Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_grid_field_pt1

Parameters:

eq_high_energy_space_charge

Fortran source: bmad/modules/equality_mod.f90

eq_high_energy_space_charge(f1: pybmad._pybmad.HighEnergySpaceChargeStruct, f2: pybmad._pybmad.HighEnergySpaceChargeStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_high_energy_space_charge

Parameters:

eq_interval1_coef

Fortran source: bmad/modules/equality_mod.f90

eq_interval1_coef(f1: pybmad._pybmad.Interval1CoefStruct, f2: pybmad._pybmad.Interval1CoefStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_interval1_coef

Parameters:

eq_kv_beam_init

Fortran source: bmad/modules/equality_mod.f90

eq_kv_beam_init(f1: pybmad._pybmad.KvBeamInitStruct, f2: pybmad._pybmad.KvBeamInitStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_kv_beam_init

Parameters:

eq_lat

Fortran source: bmad/modules/equality_mod.f90

eq_lat(f1: pybmad._pybmad.LatStruct, f2: pybmad._pybmad.LatStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_lat

Parameters:

eq_lat_ele_loc

Fortran source: bmad/modules/equality_mod.f90

eq_lat_ele_loc(f1: pybmad._pybmad.LatEleLocStruct, f2: pybmad._pybmad.LatEleLocStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_lat_ele_loc

Parameters:

eq_lat_param

Fortran source: bmad/modules/equality_mod.f90

eq_lat_param(f1: pybmad._pybmad.LatParamStruct, f2: pybmad._pybmad.LatParamStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_lat_param

Parameters:

eq_linac_normal_mode

Fortran source: bmad/modules/equality_mod.f90

eq_linac_normal_mode(f1: pybmad._pybmad.LinacNormalModeStruct, f2: pybmad._pybmad.LinacNormalModeStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_linac_normal_mode

Parameters:

eq_mode3

Fortran source: bmad/modules/equality_mod.f90

eq_mode3(f1: pybmad._pybmad.Mode3Struct, f2: pybmad._pybmad.Mode3Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_mode3

Parameters:

eq_mode_info

Fortran source: bmad/modules/equality_mod.f90

eq_mode_info(f1: pybmad._pybmad.ModeInfoStruct, f2: pybmad._pybmad.ModeInfoStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_mode_info

Parameters:

eq_normal_modes

Fortran source: bmad/modules/equality_mod.f90

eq_normal_modes(f1: pybmad._pybmad.NormalModesStruct, f2: pybmad._pybmad.NormalModesStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_normal_modes

Parameters:

eq_photon_element

Fortran source: bmad/modules/equality_mod.f90

eq_photon_element(f1: pybmad._pybmad.PhotonElementStruct, f2: pybmad._pybmad.PhotonElementStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_photon_element

Parameters:

eq_photon_material

Fortran source: bmad/modules/equality_mod.f90

eq_photon_material(f1: pybmad._pybmad.PhotonMaterialStruct, f2: pybmad._pybmad.PhotonMaterialStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_photon_material

Parameters:

eq_photon_reflect_surface

Fortran source: bmad/modules/equality_mod.f90

eq_photon_reflect_surface(f1: pybmad._pybmad.PhotonReflectSurfaceStruct, f2: pybmad._pybmad.PhotonReflectSurfaceStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_photon_reflect_surface

Parameters:

eq_photon_reflect_table

Fortran source: bmad/modules/equality_mod.f90

eq_photon_reflect_table(f1: pybmad._pybmad.PhotonReflectTableStruct, f2: pybmad._pybmad.PhotonReflectTableStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_photon_reflect_table

Parameters:

eq_photon_target

Fortran source: bmad/modules/equality_mod.f90

eq_photon_target(f1: pybmad._pybmad.PhotonTargetStruct, f2: pybmad._pybmad.PhotonTargetStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_photon_target

Parameters:

eq_pixel_detec

Fortran source: bmad/modules/equality_mod.f90

eq_pixel_detec(f1: pybmad._pybmad.PixelDetecStruct, f2: pybmad._pybmad.PixelDetecStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_pixel_detec

Parameters:

eq_pixel_pt

Fortran source: bmad/modules/equality_mod.f90

eq_pixel_pt(f1: pybmad._pybmad.PixelPtStruct, f2: pybmad._pybmad.PixelPtStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_pixel_pt

Parameters:

eq_pre_tracker

Fortran source: bmad/modules/equality_mod.f90

eq_pre_tracker(f1: pybmad._pybmad.PreTrackerStruct, f2: pybmad._pybmad.PreTrackerStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_pre_tracker

Parameters:

eq_rad_int1

Fortran source: bmad/modules/equality_mod.f90

eq_rad_int1(f1: pybmad._pybmad.RadInt1Struct, f2: pybmad._pybmad.RadInt1Struct, is_eq: bool) -> None

Wrapper for Fortran routine eq_rad_int1

Parameters:

eq_rad_int_all_ele

Fortran source: bmad/modules/equality_mod.f90

eq_rad_int_all_ele(f1: pybmad._pybmad.RadIntAllEleStruct, f2: pybmad._pybmad.RadIntAllEleStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_rad_int_all_ele

Parameters:

eq_rad_int_branch

Fortran source: bmad/modules/equality_mod.f90

eq_rad_int_branch(f1: pybmad._pybmad.RadIntBranchStruct, f2: pybmad._pybmad.RadIntBranchStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_rad_int_branch

Parameters:

eq_rad_map

Fortran source: bmad/modules/equality_mod.f90

eq_rad_map(f1: pybmad._pybmad.RadMapStruct, f2: pybmad._pybmad.RadMapStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_rad_map

Parameters:

eq_rad_map_ele

Fortran source: bmad/modules/equality_mod.f90

eq_rad_map_ele(f1: pybmad._pybmad.RadMapEleStruct, f2: pybmad._pybmad.RadMapEleStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_rad_map_ele

Parameters:

eq_ramper_lord

Fortran source: bmad/modules/equality_mod.f90

eq_ramper_lord(f1: pybmad._pybmad.RamperLordStruct, f2: pybmad._pybmad.RamperLordStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_ramper_lord

Parameters:

eq_space_charge_common

Fortran source: bmad/modules/equality_mod.f90

eq_space_charge_common(f1: pybmad._pybmad.SpaceChargeCommonStruct, f2: pybmad._pybmad.SpaceChargeCommonStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_space_charge_common

Parameters:

eq_spin_polar

Fortran source: bmad/modules/equality_mod.f90

eq_spin_polar(f1: pybmad._pybmad.SpinPolarStruct, f2: pybmad._pybmad.SpinPolarStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_spin_polar

Parameters:

eq_spline

Fortran source: bmad/modules/equality_mod.f90

eq_spline(f1: pybmad._pybmad.SplineStruct, f2: pybmad._pybmad.SplineStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_spline

Parameters:

eq_strong_beam

Fortran source: bmad/modules/equality_mod.f90

eq_strong_beam(f1: pybmad._pybmad.StrongBeamStruct, f2: pybmad._pybmad.StrongBeamStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_strong_beam

Parameters:

eq_surface_curvature

Fortran source: bmad/modules/equality_mod.f90

eq_surface_curvature(f1: pybmad._pybmad.SurfaceCurvatureStruct, f2: pybmad._pybmad.SurfaceCurvatureStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_surface_curvature

Parameters:

eq_surface_displacement

Fortran source: bmad/modules/equality_mod.f90

eq_surface_displacement(f1: pybmad._pybmad.SurfaceDisplacementStruct, f2: pybmad._pybmad.SurfaceDisplacementStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_surface_displacement

Parameters:

eq_surface_displacement_pt

Fortran source: bmad/modules/equality_mod.f90

eq_surface_displacement_pt(f1: pybmad._pybmad.SurfaceDisplacementPtStruct, f2: pybmad._pybmad.SurfaceDisplacementPtStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_surface_displacement_pt

Parameters:

eq_surface_h_misalign

Fortran source: bmad/modules/equality_mod.f90

eq_surface_h_misalign(f1: pybmad._pybmad.SurfaceHMisalignStruct, f2: pybmad._pybmad.SurfaceHMisalignStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_surface_h_misalign

Parameters:

eq_surface_h_misalign_pt

Fortran source: bmad/modules/equality_mod.f90

eq_surface_h_misalign_pt(f1: pybmad._pybmad.SurfaceHMisalignPtStruct, f2: pybmad._pybmad.SurfaceHMisalignPtStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_surface_h_misalign_pt

Parameters:

eq_surface_segmented

Fortran source: bmad/modules/equality_mod.f90

eq_surface_segmented(f1: pybmad._pybmad.SurfaceSegmentedStruct, f2: pybmad._pybmad.SurfaceSegmentedStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_surface_segmented

Parameters:

eq_surface_segmented_pt

Fortran source: bmad/modules/equality_mod.f90

eq_surface_segmented_pt(f1: pybmad._pybmad.SurfaceSegmentedPtStruct, f2: pybmad._pybmad.SurfaceSegmentedPtStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_surface_segmented_pt

Parameters:

eq_target_point

Fortran source: bmad/modules/equality_mod.f90

eq_target_point(f1: pybmad._pybmad.TargetPointStruct, f2: pybmad._pybmad.TargetPointStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_target_point

Parameters:

eq_taylor

Fortran source: bmad/modules/equality_mod.f90

eq_taylor(f1: pybmad._pybmad.TaylorStruct, f2: pybmad._pybmad.TaylorStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_taylor

Parameters:

eq_taylor_term

Fortran source: bmad/modules/equality_mod.f90

eq_taylor_term(f1: pybmad._pybmad.TaylorTermStruct, f2: pybmad._pybmad.TaylorTermStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_taylor_term

Parameters:

eq_track

Fortran source: bmad/modules/equality_mod.f90

eq_track(f1: pybmad._pybmad.TrackStruct, f2: pybmad._pybmad.TrackStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_track

Parameters:

eq_track_point

Fortran source: bmad/modules/equality_mod.f90

eq_track_point(f1: pybmad._pybmad.TrackPointStruct, f2: pybmad._pybmad.TrackPointStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_track_point

Parameters:

eq_twiss

Fortran source: bmad/modules/equality_mod.f90

eq_twiss(f1: pybmad._pybmad.TwissStruct, f2: pybmad._pybmad.TwissStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_twiss

Parameters:

eq_wake

Fortran source: bmad/modules/equality_mod.f90

eq_wake(f1: pybmad._pybmad.WakeStruct, f2: pybmad._pybmad.WakeStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wake

Parameters:

eq_wake_lr

Fortran source: bmad/modules/equality_mod.f90

eq_wake_lr(f1: pybmad._pybmad.WakeLrStruct, f2: pybmad._pybmad.WakeLrStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wake_lr

Parameters:

eq_wake_lr_mode

Fortran source: bmad/modules/equality_mod.f90

eq_wake_lr_mode(f1: pybmad._pybmad.WakeLrModeStruct, f2: pybmad._pybmad.WakeLrModeStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wake_lr_mode

Parameters:

eq_wake_sr

Fortran source: bmad/modules/equality_mod.f90

eq_wake_sr(f1: pybmad._pybmad.WakeSrStruct, f2: pybmad._pybmad.WakeSrStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wake_sr

Parameters:

eq_wake_sr_mode

Fortran source: bmad/modules/equality_mod.f90

eq_wake_sr_mode(f1: pybmad._pybmad.WakeSrModeStruct, f2: pybmad._pybmad.WakeSrModeStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wake_sr_mode

Parameters:

eq_wake_sr_z_long

Fortran source: bmad/modules/equality_mod.f90

eq_wake_sr_z_long(f1: pybmad._pybmad.WakeSrZLongStruct, f2: pybmad._pybmad.WakeSrZLongStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wake_sr_z_long

Parameters:

eq_wall3d

Fortran source: bmad/modules/equality_mod.f90

eq_wall3d(f1: pybmad._pybmad.Wall3DStruct, f2: pybmad._pybmad.Wall3DStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wall3d

Parameters:
  • f1 (Wall3dStruct) –
  • f2 (Wall3dStruct) –
  • is_eq (bool) –

eq_wall3d_section

Fortran source: bmad/modules/equality_mod.f90

eq_wall3d_section(f1: pybmad._pybmad.Wall3DSectionStruct, f2: pybmad._pybmad.Wall3DSectionStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wall3d_section

Parameters:
  • f1 (Wall3dSectionStruct) –
  • f2 (Wall3dSectionStruct) –
  • is_eq (bool) –

eq_wall3d_vertex

Fortran source: bmad/modules/equality_mod.f90

eq_wall3d_vertex(f1: pybmad._pybmad.Wall3DVertexStruct, f2: pybmad._pybmad.Wall3DVertexStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_wall3d_vertex

Parameters:
  • f1 (Wall3dVertexStruct) –
  • f2 (Wall3dVertexStruct) –
  • is_eq (bool) –

eq_xy_disp

Fortran source: bmad/modules/equality_mod.f90

eq_xy_disp(f1: pybmad._pybmad.XyDispStruct, f2: pybmad._pybmad.XyDispStruct, is_eq: bool) -> None

Wrapper for Fortran routine eq_xy_disp

Parameters:

equal_sign_here

Fortran source: bmad/parsing/bmad_parser_mod.f90

equal_sign_here(ele: pybmad._pybmad.EleStruct, delim: str, is_here: bool) -> None

Wrapper for Fortran routine equal_sign_here

Parameters:
  • ele (EleStruct) –
  • delim (str) –
  • is_here (bool) –

equivalent_taylor_attributes

Fortran source: bmad/modules/bmad_routine_interface.f90

equivalent_taylor_attributes(ele_taylor: pybmad._pybmad.EleStruct, ele2: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine equivalent_taylor_attributes

Parameters:
  • ele_taylor (EleStruct) –

    Element with a Taylor map

  • ele2 (EleStruct) –

    Element that might receive the Taylor map from ele_taylor.

Returns:
  • equiv( bool ) –

    True if elements are equivalent.

etdiv

Fortran source: bmad/multiparticle/envelope_mod.f90

etdiv(A: typing.SupportsFloat | typing.SupportsIndex, B: typing.SupportsFloat | typing.SupportsIndex, C: typing.SupportsFloat | typing.SupportsIndex, D: typing.SupportsFloat | typing.SupportsIndex, E: typing.SupportsFloat | typing.SupportsIndex, F: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine etdiv

Parameters:
  • A (float) –
  • B (float) –
  • C (float) –
  • D (float) –
  • E (float) –
  • F (float) –

evaluate_array_index

Fortran source: bmad/parsing/bmad_parser_mod.f90

evaluate_array_index(delim_list1: str, delim_list2: str) -> pybmad._pybmad.EvaluateArrayIndex

Function evaluate_array_index (err_flag, delim_list1, word2, delim_list2, delim2) result (this_index)

Function of evaluate the index of an array. Typically the text being parsed looks like: "5) = ..." or "6).COMP = ..."

Parameters:
  • delim_list1 (str) –

    Delimitor after the integer. Normally ')'.

  • delim_list2 (str) –

    Delimitor list to mark the end of word2. Normally '='.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

  • word2( str ) –

    Word found after delim1. Normally this should be blank.

  • delim2( str ) –

    Actual delimitor found after word2.

  • this_index( int ) –

    Integer value

evaluate_logical

Fortran source: bmad/parsing/bmad_parser_mod.f90

evaluate_logical(word: str) -> pybmad._pybmad.EvaluateLogical

Function evaluate_logical (word, iostat) result (this_logic)

Function of convert a string into a logical value. Accepted possibilities are: .TRUE. .FALSE. TRUE FALSE T F

Parameters:
  • word (str) –

    Input string.

Returns:
  • iostat( int ) –

    Status: Returns 0 if conversion successful.

  • this_logic( bool ) –

    Result.

exact_bend_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

exact_bend_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orb: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine exact_bend_edge_kick (ele, param, particle_at, orb, mat6, make_matrix)

Subroutine to track through the edge field of an sbend. Uses routines adapted from PTC

Parameters:
  • ele (EleStruct) –

    SBend element.

  • param (LatParamStruct) –
  • particle_at (int) –

    first_track_edge\(, or second_track_edge\).

  • orb (CoordStruct) –

    Coords after tracking.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the edge. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix through the edge.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

exp_bessi0

Fortran source: bmad/multiparticle/touschek_mod.f90

exp_bessi0(t: typing.SupportsFloat | typing.SupportsIndex, B1: typing.SupportsFloat | typing.SupportsIndex, B2: typing.SupportsFloat | typing.SupportsIndex, func_retval__: typing.SupportsFloat | typing.SupportsIndex) -> None

Function exp_bessi0(t, B1, B2)

This is essentially the Numercal Recipes bessi0 function multiplied by exp(-B1*t).

This overcomes an issue where exp(B2t) may be huge and exp(-B1t) may be small. Evaluating exp(B2t) may result in overflow, but exp((B2-B1)t) has a moderate value. Simplifying the algebra of B2-B1 suggests that is should always have a moderate magnitude.

Parameters:
  • t (float) –

    Scalar agrument to evaluate function at.

  • B1 (float) –

    Scalar value. Eq. 33 from Piwinski's paper.

  • B2 (float) –

    Scalar value. Eq. 34 from Piwinski's paper.

expect_one_of

Fortran source: bmad/parsing/bmad_parser_mod.f90

expect_one_of(delim_list: str, check_input_delim: bool, ele_name: str, delim: str, delim_found: bool, is_ok: bool) -> pybmad._pybmad.ExpectOneOf

Function expect_one_of (delim_list, check_input_delim, ele_name, delim, delim_found) result (is_ok)

Routine to check either that the current delimitor or the next character in the parse stream is the expected delimitor. This routine is used for Bmad lattice file parsing and is not meant for general use.

Also see: expect_this

Parameters:
  • delim_list (str) –

    List of expected (valid) delimitors. If list contains a space character then no delimitor (indicating the end of the command) is a valid possibility.

  • check_input_delim (bool) –

    If True, then check if delim argument is in the delim_list. If False, check that the next character in the parse stream is an expected delimitor.

  • ele_name (str) –

    Lattice element under construction. Used for error messages.

  • delim (str) –

    Current delimitor that will be checked if check_input_delim = .true. This parameter is an input/output and is modified in-place. As an output, delim: Next delim if check_input_delim = False.

Returns:
  • delim( str ) –

    Current delimitor that will be checked if check_input_delim = .true. This parameter is an input/output and is modified in-place. As an output, delim: Next delim if check_input_delim = False.

expect_this

Fortran source: bmad/parsing/bmad_parser_mod.f90

expect_this(expecting: str, check_delim: bool, call_check: bool, err_str: str, ele: pybmad._pybmad.EleStruct, is_ok: bool) -> pybmad._pybmad.ExpectThis

Function expect_this (expecting, check_delim, call_check, err_str, ele, delim, delim_found) result (is_ok)

Checks that the next character or characters in the parse stream corresponds to the characters in the expecting argument. For example, if expecting is ')={' these three characters should be the next non-blank characters in the parse stream.

Also see: expect_one_of

Parameters:
  • expecting (str) –

    list of characters that are expected to be next in the parse stream.

  • check_delim (bool) –

    If True then use delim argument as first token to check. A blank character indicates end of command is expected.

  • call_check (bool) –

    If True then check for 'call::' construct.

  • err_str (str) –

    String used for error messages.

  • ele (EleStruct) –

    Element parameters being parsed.

Returns:
  • delim( str ) –

    Final delim

  • delim_found( bool ) –

    Is there a final delim (as opposed to end of command).

expression_stack_to_string

Fortran source: bmad/modules/expression_mod.f90

expression_stack_to_string(stack: pybmad._pybmad.ExpressionAtomStructArray1D, polish: bool | None = None) -> str

Function expression_stack_to_string (stack, polish) result (str)

Routine to convert an expression stack to a string

Parameters:
  • stack (1D array of ExpressionAtomStruct) –

    arithmetic expression

  • polish (bool) –

    logical, optional, Construct expression in reverse polish? Default is False.

Returns:
  • str( str ) –

    : Expression in string form.

expression_stack_value

Fortran source: bmad/modules/expression_mod.f90

expression_stack_value(stack: pybmad._pybmad.ExpressionAtomStructArray1D, var: pybmad._pybmad.ControlVar1StructArray1D | None = None, use_old: bool | None = None) -> pybmad._pybmad.ExpressionStackValue

Function expression_stack_value (stack, err_flag, err_str, var, use_old) result (value)

Routine to evaluate a mathematical expression represented by an "expression stack". Expression stacks are created by expression_string_to_stack.

Note: Stack elements with stack(i)%type == variable$ need to be evalauated before calling this routine and the value placed in stack(i)%value.

Also see: expression_value expression_string_to_stack

Parameters:
  • stack (1D array of ExpressionAtomStruct) –

    Expression to evaluate.

  • var (1D array of ControlVar1Struct) –

    Array of control variables. Used with Bmad controller elements.

  • use_old (bool) –

    Use var.old_value? Must be present if var(:) is present.

Returns:
  • err_flag( bool ) –

    True if there is an evaluation problem. False otherwise.

  • err_str( str ) –

    Error string explaining error if there is one.

  • value( float ) –

    Value of the expression.

expression_string_to_stack

Fortran source: bmad/modules/expression_mod.f90

expression_string_to_stack(string: str) -> pybmad._pybmad.ExpressionStringToStack

Subroutine expression_string_to_stack (string, stack, n_stack, err_flag, err_str)

This routine creates an expression stack array which can be used to evaluate an arithmethic expression.

Stack end elements not used are marked stack(i)%type = end_stack$

Stack elements with stack(i)%type = variable$ are elements that need to be evaluated before calling expression_stack_value.

Also see: expression_value expression_stack_value

Parameters:
  • string (str) –

    Expression to be converted.

Returns:
  • stack( 1D array of ExpressionAtomStruct ) –

    Expression evaluation stack.

  • n_stack( int ) –

    number of "atoms" used by the expression

  • err_flag( bool ) –

    Set True if there is an error (EG divide by 0).

  • err_str( str ) –

    String describing the error.

expression_string_to_tree

Fortran source: bmad/modules/expression_mod.f90

expression_string_to_tree(string: str, root_tree: pybmad._pybmad.ExpressionTreeStruct) -> pybmad._pybmad.ExpressionStringToTree

Subroutine expression_string_to_tree (string, root_tree, err_flag, err_str)

Routine to create an expression tree array which can be used to evaluate an arithmethic expression.

Also see: expression_value expression_tree_value deallocate_expression_tree

Important! trees use pointers as opposed to allocatable arrays due to the ifort compiler not being able to handle node%node(:) being an allocatable array. Thus deallocate_expression_tree must be called before any tree instance goes out of scope.

Note types used: plus\(, minus\), times\(, divide\), power\(, unary_minus\), unary_plus$ constant\(, numeric\), variable\(, function\) root\(, parens\), func_parens\(, square_brackets\), curly_brackets$ arrow\(, equal\), colon\(, double_colon\), vertical_bar\(, compound\)

An expression string will be split on: Two character operators: "->", "::" operators: + - * / ^ = : & brackets: [] () {} comma: ,

Root node name is "root" and is of type root$ Brackets in the expression string must be matched. The corresponding tree node will have a name / type of: "[]" / square_brackets\(, "()" / parens\) or func_parens\(, "{}" / curley_brackets\)

The root node, equal nodes, and all bracket nodes, will have an array of child nodes all of which will be comma nodes.

Parameters:
  • string (str) –

    Expression to be converted.

  • root_tree (ExpressionTreeStruct) –

    Only used when recursively called.

Returns:
  • err_flag( bool ) –

    Set True if there is an error (EG divide by 0).

  • err_str( str ) –

    String describing the error. Make length large to hold the expression.

expression_tree_to_string

Fortran source: bmad/modules/expression_mod.f90

expression_tree_to_string(tree: pybmad._pybmad.ExpressionTreeStruct, include_root: bool | None = None, n_node: typing.SupportsInt | typing.SupportsIndex | None = None, parent: pybmad._pybmad.ExpressionTreeStruct | None = None) -> str

Function expression_tree_to_string (tree, include_root, n_node, parent) result(str_out)

Routine to convert an expression tree to a expression string.

Parameters:
  • tree (ExpressionTreeStruct) –

    Root of tree to print.

  • include_root (bool) –

    Default is True. If True, do not inculde in the output string the root node. Note: If the root node is of type root$, this node is always ignored.

  • n_node (int) –

    Node index. parent.node(n_node) === tree. Internal use only. Used with recursive calls.

  • parent (ExpressionTreeStruct) –

    Internal use only. Used with recusive calls.

Returns:
  • str_out( str ) –

    Expression string.

expression_value

Fortran source: bmad/modules/expression_mod.f90

expression_value(expression: str, var: pybmad._pybmad.ControlVar1StructArray1D | None = None, use_old: bool | None = None) -> pybmad._pybmad.ExpressionValue

Function expression_value (expression, err_flag, err_str, var, use_old) result (value)

Routine to evaluate a mathematical expression encoded in a string.

Also see: expression_string_to_stack expression_stack_value

Parameters:
  • expression (str) –

    Expression string.

  • var (1D array of ControlVar1Struct) –

    Array of control variables. Used with Bmad controller elements.

  • use_old (bool) –

    Use var.old_value? Must be present if var(:) is present.

Returns:
  • err_flag( bool ) –

    True if there is an evaluation problem. False otherwise.

  • value( float ) –

    Value of the expression.

  • err_str( (str, optional) ) –

    Error string explaining error if there is one.

fft1

Fortran source: bmad/space_charge/fast_fourier_am.f90

fft1(a: pybmad._pybmad.RealArray1D, b: pybmad._pybmad.RealArray1D, n: typing.SupportsInt | typing.SupportsIndex, isn: typing.SupportsInt | typing.SupportsIndex) -> int

Wrapper for Fortran routine fft1

Parameters:
  • a (1D array of float) –
  • b (1D array of float) –
  • n (int) –
  • isn (int) –
Returns:
  • ierr( int ) –

fibre_to_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

fibre_to_ele(ptc_fibre: pybmad._pybmad.Fibre, branch: pybmad._pybmad.BranchStruct, ix_ele: typing.SupportsInt | typing.SupportsIndex, from_mad: bool | None = None) -> pybmad._pybmad.FibreToEle

Wrapper for Fortran routine fibre_to_ele

Parameters:
  • ptc_fibre (Fibre) –

    PTC fibre.

  • branch (BranchStruct) –

    branch containing elements.

  • ix_ele (int) –

    Index in ele(:) array of element last used. This parameter is an input/output and is modified in-place. As an output, ix_ele: Index to element created (upper index if more than one created).

  • from_mad (bool) –

    If True, ignore PTC specific parameters like integrator_order. Default is False. True is used when the fibre has been created via MAD. In this case, the PTC specific parameters may not have good values.

Returns:
  • ix_ele( int ) –

    Index in ele(:) array of element last used. This parameter is an input/output and is modified in-place. As an output, ix_ele: Index to element created (upper index if more than one created).

  • err_flag( bool ) –

    Set true if there is an error. False otherwise. To do: lcavity energy change !? open or closed geometry? Energy patch

field_attribute_free

Fortran source: bmad/modules/attribute_mod.f90

field_attribute_free(ele: pybmad._pybmad.EleStruct, attrib_name: str) -> bool

Function field_attribute_free (ele, attrib_name) result (free)

Routine to check if a field attribute is free to vary.

Field attributes are either normalized (EG K2 of a sextupole) or unnormalized (EG B2_GRADIENT of a sextupole). Whether normalized or unnormalized attributes are free to vary will depend on the setting of ele%field_master.

Generally, this routine should not be called directly. Use the routine attribute_free instead.

Parameters:
  • ele (EleStruct) –

    Element containing the attribute

  • attrib_name (str) –

    Name of the field attribute. Assumed upper case.

Returns:
  • free( bool ) –

    Is the attribute free to vary? If the attribute is not recognized, free = True will be returned.

finalize_reflectivity_table

Fortran source: bmad/photon/photon_reflection_mod.f90

finalize_reflectivity_table(table: pybmad._pybmad.PhotonReflectTableStruct, in_degrees: bool) -> None

Subroutine finalize_reflectivity_table (table, in_degrees)

Routine to finalize the construction of the reflectivity tables for a surface.

Parameters:
  • table (PhotonReflectTableStruct) –

    Surface tables to be finalized. This parameter is an input/output and is modified in-place. As an output, table: Finalized surface tables.

  • in_degrees (bool) –

    Table angles in degrees?

find_element_ends

Fortran source: bmad/modules/bmad_routine_interface.f90

find_element_ends(ele: pybmad._pybmad.EleStruct, ix_multipass: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.FindElementEnds

Wrapper for Fortran routine find_element_ends

Parameters:
  • ele (EleStruct) –

    Element to find the ends for.

  • ix_multipass (int) –

    Which multipass pass to follow. Default is 1. This is ignored if there is no multipass elements.

Returns:
  • ele1( (EleStruct, optional) ) –

    Pointer to element just before ele.

  • ele2( (EleStruct, optional) ) –

    Pointer to ele itself or the last sub-element within ele. Note: ele1 and ele2 will be nullified if ele is in the lord part of the lattice and does not have any slaves. Note: For an element in the tracking part of the lattice: ele1.ix_ele = ele.ix_ele - 1 ele2 => ele Exception: For Beginning element (index 0), ele1 => ele

find_fwhm

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

find_fwhm(bound: typing.SupportsFloat | typing.SupportsIndex, args: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"]) -> float

Subroutine find_fwhm(bound,args,fwhm)

Finds the full width at half max of psi(t). fwhm * c_light / TwoRtTwoLnTwo is taken as the bunch length.

Steps followed: Find value for p(0) that normalizes the solution to dpsi/dt. Find max value of p(t) for the value of p(0) found in the previous step. Find find tlower, tlower < 0, such that p(tlower) = pmax/2. Find find tupper, tupper > 0, such that p(tupper) = pmax/2. fwhm is tupper-tlower

Parameters:
  • bound (float) –

    -bound and +bound is integration bound.

  • args (1D array of float (shape: 1:8)) –

    Parameters and constants of dpsi/dt. See comments of psi_prime for details.

Returns:
  • fwhm( float ) –

    Full width at half max of psi(t)

find_matching_fieldmap

Fortran source: bmad/modules/bmad_routine_interface.f90

find_matching_fieldmap(file_name: str, ele: pybmad._pybmad.EleStruct, fm_type: typing.SupportsInt | typing.SupportsIndex, ignore_slaves: bool | None = None) -> pybmad._pybmad.FindMatchingFieldmap

Wrapper for Fortran routine find_matching_fieldmap

Parameters:
  • file_name (str) –

    File name associated with field to match to.

  • ele (EleStruct) –

    Element holding the field to be matched.

  • fm_type (int) –

    Type of fieldmap: cartesian_map\(, cylindircal_map\), or gen_grad_map\(, grid_field\)

  • ignore_slaves (bool) –

    If True, ignore any multipass slaves. Default is False.

Returns:
  • ix_field( int ) –

    index of field. For example: matching field => match_ele.cartesian_map(ix_field) Set to -1 if no match found.

  • match_ele( (EleStruct, optional) ) –

    Pointer to element with matched field. Nullified if no match found.

find_normalization

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

find_normalization(bound: typing.SupportsFloat | typing.SupportsIndex, p0: typing.SupportsFloat | typing.SupportsIndex, args: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"]) -> float

Subroutine find_normalization(bound,p0,args,pnrml)

Finds value for boundary condition psi(0) that results in integral of psi(t) from -bound to +bound to be 1.0. This is done with the secant method. Repeadedly calls integrate_psi with different values for psi(0).

Parameters:
  • bound (float) –

    -bound and +bound are integration boundaries

  • p0 (float) –

    Boundary condition psi(0)

  • args (1D array of float (shape: 1:8)) –

    Parameters and constants of DEQ. See psi_prime comments for details.

Returns:
  • pnrml( float ) –

    Value for psi(0) that results in integral of psi(t) from -bound to +bound being equal to 1.0

floor_angles_to_w_mat

Fortran source: bmad/modules/bmad_routine_interface.f90

floor_angles_to_w_mat(theta: typing.SupportsFloat | typing.SupportsIndex, phi: typing.SupportsFloat | typing.SupportsIndex, psi: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.FloorAnglesToWMat

Wrapper for Fortran routine floor_angles_to_w_mat

Parameters:
  • theta (float) –

    Azimuth angle.

  • phi (float) –

    Pitch angle.

  • psi (float) –

    Roll angle.

Returns:
  • w_mat( 2D array of float (shape: 3,3), optional ) –

    Orientation matrix.

  • w_mat_inv( 2D array of float (shape: 3,3), optional ) –

    Inverse Orientation matrix.

floor_w_mat_to_angles

Fortran source: bmad/modules/bmad_routine_interface.f90

floor_w_mat_to_angles(w_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"], floor0: pybmad._pybmad.FloorPositionStruct | None = None) -> pybmad._pybmad.FloorWMatToAngles

Wrapper for Fortran routine floor_w_mat_to_angles

Parameters:
  • w_mat (2D array of float (shape: 3,3)) –

    Orientation matrix.

  • floor0 (FloorPositionStruct) –

    There are two solutions related by: [theta, phi, psi] & [pi+theta, pi-phi, pi+psi] If floor0 is present, choose the solution "nearest" the angles in floor0.

Returns:
  • theta( float ) –

    Azimuth angle.

  • phi( float ) –

    Pitch angle.

  • psi( float ) –

    Roll angle.

form_complex_taylor

Fortran source: bmad/ptc/ptc_interface_mod.f90

form_complex_taylor(re_taylor: pybmad._pybmad.TaylorStruct, im_taylor: pybmad._pybmad.TaylorStruct) -> pybmad._pybmad.ComplexTaylorStruct

Subroutine form_complex_taylor (re_taylor, im_taylor, complex_taylor)

Subroutine to form a complex taylor from two taylor series representing the real and imaginary parts

Parameters:
Returns:

form_digested_bmad_file_name

Fortran source: bmad/parsing/bmad_parser_mod.f90

form_digested_bmad_file_name(lat_file: str, use_line: str | None = None) -> pybmad._pybmad.FormDigestedBmadFileName

Subroutine form_digested_bmad_file_name (lat_file, digested_file, full_lat_file, use_line)

Subroutine to form the standard name of the Bmad digested file. The standard digested file name has the suffix added to the file name: suffix = '.digested' + bmad_inc_version$ Exception: If the use_line argument is present and not blank, the suffix will be: suffix = '.' + use_line + '.digested' + bmad_inc_version$

Parameters:
  • lat_file (str) –

    Input lattice file name.

  • use_line (str) –

    Line used for lattice expansion. If not present or blank, the line used is the one that was specified in the lattice file.

Returns:
  • digested_file( str ) –

    Name of the digested file.

  • full_lat_file( (str, optional) ) –

    Input lattice file name with full directory. Can be used for error messages.

fringe_here

Fortran source: bmad/modules/bmad_routine_interface.f90

fringe_here(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, particle_at: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine fringe_here

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • orbit (CoordStruct) –

    Particle position.

  • particle_at (int) –

    Either first_track_edge$ or second_track_edge$.

Returns:
  • is_here( bool ) –

    True if there is a fringe. False if not.

g_bend_from_em_field

Fortran source: bmad/modules/em_field_mod.f90

g_bend_from_em_field(b: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], e: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], orbit: pybmad._pybmad.CoordStruct) -> typing.Annotated[list[float], "FixedSize(3)"]

Function g_bend_from_em_field (B, E, orbit) result (g_bend)

Routine to calculate the bending strength (1/bending_radius) for a given particle for a given field. This will include the dipole bending field of an sbend.

Parameters:
  • B (1D array of float (shape: 3)) –

    Magnetic field.

  • E (1D array of float (shape: 3)) –

    Electric field

  • orbit (CoordStruct) –

    particle orbit

Returns:
  • g_bend( 1D array of float (shape: 3) ) –

    bending strength vector.

g_bending_strength_from_em_field

Fortran source: bmad/modules/bmad_routine_interface.f90

g_bending_strength_from_em_field(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, s_rel: typing.SupportsFloat | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, local_ref_frame: bool) -> pybmad._pybmad.GBendingStrengthFromEmField

Wrapper for Fortran routine g_bending_strength_from_em_field

Parameters:
  • ele (EleStruct) –

    Element being tracked thorugh.

  • param (LatParamStruct) –

    Lattice parameters.

  • s_rel (float) –

    Distance from the start of the element to the particle.

  • orbit (CoordStruct) –

    Particle position in lab (not element) frame.

  • local_ref_frame (bool) –

    Logical, If True then take the input coordinates and output g as being with respect to the frame of referene of the element (ignore misalignments).

Returns:
  • g( 1D array of float (shape: 3) ) –

    g = (g_x, g_y, g_s) bending strength vector (|g| = 1/bend_radius).

  • dg( 2D array of float (shape: 3,3), optional ) –

    dg(:)/dr gradient. Takes into account dg_x/dx in a bend due to curvilinear coords.

g_integrals_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

g_integrals_calc(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine g_integrals_calc

Parameters:
  • lat (LatStruct) –

    Lattice to integrate through.

gamma_ref

Fortran source: bmad/modules/bmad_routine_interface.f90

gamma_ref(ele: pybmad._pybmad.EleStruct) -> float

Wrapper for Fortran routine gamma_ref

Parameters:
  • ele (EleStruct) –

    Element to evaluate at.

Returns:
  • gamma( float ) –

    Relativistic gamma factor Energy/mass*c^2.

gen_grad1_to_gg_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

gen_grad1_to_gg_taylor(ele: pybmad._pybmad.EleStruct, gen_grad: pybmad._pybmad.GenGradMapStruct, iz: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.GgTaylorStructArray1D

Wrapper for Fortran routine gen_grad1_to_gg_taylor

Parameters:
  • ele (EleStruct) –

    Element containing the map.

  • gen_grad (GenGradMapStruct) –

    Gen_grad map.

  • iz (int) –

    z-plane index to evaluate.

Returns:
  • gg_taylor( 1D array of GgTaylorStruct (shape: 3) ) –

    Map for (Bx, By, Bz) or (Ex, Ey, Ez) fields.

gen_grad_at_s_to_gg_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

gen_grad_at_s_to_gg_taylor(ele: pybmad._pybmad.EleStruct, gen_grad: pybmad._pybmad.GenGradMapStruct, s_pos: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.GgTaylorStructArray1D

Wrapper for Fortran routine gen_grad_at_s_to_gg_taylor

Parameters:
  • ele (EleStruct) –

    Element containing the map.

  • gen_grad (GenGradMapStruct) –

    Gen_grad map.

  • s_pos (float) –

    Position to evaluate gg_taylor at.

Returns:
  • gg_taylor( 1D array of GgTaylorStruct (shape: 3) ) –

    Map for (Bx, By, Bz) or (Ex, Ey, Ez) fields.

gen_grad_field

Fortran source: bmad/modules/em_field_mod.f90

gen_grad_field(deriv: pybmad._pybmad.RealArray1D, gg: pybmad._pybmad.GenGrad1Struct, rho: typing.SupportsFloat | typing.SupportsIndex, theta: typing.SupportsFloat | typing.SupportsIndex, field: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> None

Wrapper for Fortran routine gen_grad_field

Parameters:
  • deriv (1D array of float) –
  • gg (GenGrad1Struct) –
  • rho (float) –
  • theta (float) –
  • field (1D array of float (shape: 3)) –

get_bl_from_fwhm

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

get_bl_from_fwhm(bound: typing.SupportsFloat | typing.SupportsIndex, args: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"]) -> float

Subroutine get_bl_from_fwhm(bound,args,sigma)

Calculate bunch length as fwhm * c_light / TwoRtTwoLnTwo. Where fwhm is full width at half max of solution to dpsi/dt.

Parameters:
  • bound (float) –

    -bound and +bound are lower and upper integration bound.

  • args (1D array of float (shape: 1:8)) –

    Parameters and constants of dpsi/dt. See comments of psi_prime for details.

Returns:
  • sigma( float ) –

    Bunch length

get_called_file

Fortran source: bmad/parsing/bmad_parser_mod.f90

get_called_file(delim: str, call_file: str, err: bool) -> None

Wrapper for Fortran routine get_called_file

Parameters:
  • delim (str) –
  • call_file (str) –
  • err (bool) –

get_emit_from_sigma_mat

Fortran source: bmad/modules/mode3_mod.f90

get_emit_from_sigma_mat(sigma_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], Nmat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None) -> pybmad._pybmad.GetEmitFromSigmaMat

Subroutine get_emit_from_sigma_mat(sigma_mat, normal, Nmat, err_flag)

Given a beam envelop sigma matrix sigma_mat, this returns the 3 normal mode emittances.

The normal mode emittance of the sigma matrix are the eigenvalues of sigma_mat . S

If Nmat is present, then the modes are ordered such that the eigensystem most closely resembles Nmat. If Nmat is not present, then the modes are ordered according to which plane they dominate.

/ 0  1  0  0  0  0 \
|-1  0  0  0  0  0 |

S = | 0 0 0 1 0 0 | | 0 0 -1 0 0 0 | | 0 0 0 0 0 1 | \ 0 0 0 0 -1 0 /

Parameters:
  • sigma_mat (2D array of float (shape: 6,6)) –

    beam envelop sigma matrix

  • Nmat (2D array of float (shape: 6,6)) –

    If present, then the emittanced will be ordered such that the eigensystem most closely resembles Nmat.

Returns:
  • normal( 1D array of float (shape: 3) ) –

    normal mode emittances

  • err_flag( bool ) –

    Set to true if something went wrong. Otherwise set to false.

get_list_of_names

Fortran source: bmad/parsing/bmad_parser_mod.f90

get_list_of_names(ele: pybmad._pybmad.EleStruct, err_str: str, name_list: pybmad._pybmad.CharacterAlloc1D, delim: str, delim_found: bool, err_flag: bool) -> None

Subroutine get_list_of_names (ele, err_str, delim, delim_found)

This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

get_next_word

Fortran source: bmad/parsing/bmad_parser_mod.f90

get_next_word(word: str, delim_list: str, upper_case_word: bool | None = None, call_check: bool | None = None) -> pybmad._pybmad.GetNextWord

Subroutine get_next_word (word, ix_word, delim_list, delim, delim_found, upper_case_word, call_check, err_flag)

Subroutine to get the next word from the input stream. This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

Parameters:
  • word (str) –

    Word returned

  • delim_list (str) –

    List of valid delimiters

  • upper_case_word (bool) –

    if True then convert word to upper case. Default is True.

  • call_check (bool) –

    If present and True then check for 'call::' construct. Default is False.

Returns:
  • ix_word( int ) –

    length of word argument

  • delim( str ) –

    Actual delimiter found

  • delim_found( bool ) –

    Set true if a delimiter found. A delimiter may not be found if the end of the line is reached first.

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

get_sequence_args

Fortran source: bmad/parsing/bmad_parser_mod.f90

get_sequence_args(seq_name: str, arg_list: pybmad._pybmad.CharacterAlloc1D, delim: str, err_flag: bool) -> None

Subroutine get_sequence_args (seq_name, arg_list, delim, err_flag)

Subroutine to get the argument list for a replacement_line or a list. This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

get_slave_list

Fortran source: bmad/modules/bmad_routine_interface.f90

get_slave_list(lord: pybmad._pybmad.EleStruct) -> pybmad._pybmad.GetSlaveList

Wrapper for Fortran routine get_slave_list

Parameters:
Returns:
  • slaves( 1D array of ElePointerStruct ) –

    : Array of slaves.

  • n_slave( int ) –

    Number of slaves.

get_switch

Fortran source: bmad/parsing/bmad_parser_mod.f90

get_switch(name: str, name_list: pybmad.pybmad.CharacterAlloc1D, switch: typing.SupportsInt | typing.SupportsIndex, err: bool, ele: pybmad._pybmad.EleStruct, delim: str, delim_found: bool) -> None

Wrapper for Fortran routine get_switch

Parameters:
  • name (str) –
  • name_list (1D array of str) –
  • err (bool) –
  • ele (EleStruct) –
  • delim (str) –
  • delim_found (bool) –

gg_taylor_equal_gg_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

gg_taylor_equal_gg_taylor(gg_taylor1: pybmad._pybmad.GgTaylorStruct, gg_taylor2: pybmad._pybmad.GgTaylorStruct) -> None

Wrapper for Fortran routine gg_taylor_equal_gg_taylor

Parameters:

gg_taylors_equal_gg_taylors

Fortran source: bmad/modules/bmad_routine_interface.f90

gg_taylors_equal_gg_taylors(gg_taylor1: pybmad._pybmad.GgTaylorStructArray1D, gg_taylor2: pybmad._pybmad.GgTaylorStructArray1D) -> None

Wrapper for Fortran routine gg_taylors_equal_gg_taylors

Parameters:
  • gg_taylor1 (1D array of GgTaylorStruct) –
  • gg_taylor2 (1D array of GgTaylorStruct) –

gpt_field_grid_scaling

Fortran source: bmad/interface/gpt_interface_mod.f90

gpt_field_grid_scaling(ele: pybmad._pybmad.EleStruct, dimensions: typing.SupportsInt | typing.SupportsIndex, field_scale: typing.SupportsFloat | typing.SupportsIndex, ref_time: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine gpt_field_grid_scaling

Parameters:
  • ele (EleStruct) –
  • dimensions (int) –
  • field_scale (float) –
  • ref_time (float) –

gpt_max_field_reference

Fortran source: bmad/interface/gpt_interface_mod.f90

gpt_max_field_reference(pt0: pybmad._pybmad.GridFieldPt1Struct, ele: pybmad._pybmad.EleStruct, field_value: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine gpt_max_field_reference

Parameters:

gpt_to_particle_bunch

Fortran source: bmad/interface/gpt_interface_mod.f90

gpt_to_particle_bunch(gpt_file: str, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.GptToParticleBunch

Subroutine gpt_to_particle_bunch (gpt_file, ele, bunch, err_flag)

Routine to initialize a bunch of particles from a GPT screen file.

Parameters:
  • gpt_file (str) –

    Name of GPT data file.

  • ele (EleStruct) –

    Lattice element whose downstream end coincident with the GPT screen.

Returns:
  • bunch( BunchStruct ) –

    Particle bunch

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

gradient_shift_sr_wake

Fortran source: bmad/modules/bmad_routine_interface.f90

gradient_shift_sr_wake(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> float

Wrapper for Fortran routine gradient_shift_sr_wake

Parameters:
Returns:
  • grad_shift( float ) –

    Shift in gradient

grid_field_interpolate

Fortran source: bmad/modules/em_field_mod.f90

grid_field_interpolate(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, grid: pybmad._pybmad.GridFieldStruct, err_flag: bool, x1: typing.SupportsFloat | typing.SupportsIndex, x2: typing.SupportsFloat | typing.SupportsIndex | None = None, x3: typing.SupportsFloat | typing.SupportsIndex | None = None, allow_s_out_of_bounds: bool | None = None, print_err: bool | None = None) -> pybmad._pybmad.GridFieldPt1Struct

Subroutine grid_field_interpolate (ele, orbit, grid, field, err_flag, x1, x2, x3, & allow_s_out_of_bounds, print_err)

Subroutine to interpolate the E and B fields on a rectilinear grid.

Parameters:
  • ele (EleStruct) –

    Element containing the grid.

  • orbit (CoordStruct) –

    Used for constructing an error message if the particle is out of bounds.

  • grid (GridFieldStruct) –

    Grid to interpolate.

  • err_flag (bool) –

    Set to true if there is an error. False otherwise.

  • x1 (float) –

    dimension 1 interpolation point.

  • x2 (float) –

    dimension 2 interpolation point.

  • x3 (float) –

    dimension 3 interpolation point.

  • allow_s_out_of_bounds (bool) –

    allow s-coordinate grossly out of bounds to return zero field without an error. This is used when the field of one element overlaps the field of another. Default is False.

  • print_err (bool) –

    print an error message if the particle is out of bounds? Default is True.

hard_multipole_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

hard_multipole_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine hard_multipole_edge_kick (ele, param, particle_at, orbit, mat6, make_matrix)

Routine to track through the hard edge field of a multipole. The dipole component is ignored and only quadrupole and higher multipoles are included.

This routine handles elements of type: sad_mult, sbend, quadrupole, sextupole

For sad_mult elements, ele%a_pole and ele%b_pole ae used for the multipole values. For the other elements, k1 or k2 is used and it is assumed that we are in the element frame of reference so tilt = 0.

Parameters:
  • ele (EleStruct) –

    Element with fringe.

  • param (LatParamStruct) –

    Tracking parameters.

  • particle_at (int) –

    Either first_track_edge$ or second_track_edge$.

  • orbit (CoordStruct) –

    Starting coordinates. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coordinates.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the fringe. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix including the fringe.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

has_attribute

Fortran source: bmad/modules/attribute_mod.f90

has_attribute(ele: pybmad._pybmad.EleStruct, attrib: str, has_it: bool) -> None

Wrapper for Fortran routine has_attribute

Parameters:
  • ele (EleStruct) –
  • attrib (str) –
  • has_it (bool) –

has_curvature

Fortran source: bmad/photon/photon_utils_mod.f90

has_curvature(phot_ele: pybmad._pybmad.PhotonElementStruct) -> bool

Function has_curvature (phot_ele) result (curved)

Routine to determine if a surface is potentially curved or is flat.

Parameters:
Returns:
  • curved( bool ) –

    Set True if phot_eleace is curved.

has_orientation_attributes

Fortran source: bmad/modules/attribute_mod.f90

has_orientation_attributes(ele: pybmad._pybmad.EleStruct) -> bool

Function has_orientation_attributes (ele) result (has_attribs)

Routine to determine whether an element has orientation attributes like x_offset, etc. Also see: has_attribute function.

Parameters:
Returns:
  • has_attribs( bool ) –

    True if ele has orientation attributes. False otherwise.

hdf5_write_beam

Fortran source: bmad/modules/bmad_routine_interface.f90

hdf5_write_beam(file_name: str, bunches: pybmad._pybmad.BunchStructArray1D, append: bool, error: bool, lat: pybmad._pybmad.LatStruct | None = None, alive_only: bool | None = None) -> None

Wrapper for Fortran routine hdf5_write_beam

Parameters:
  • file_name (str) –
  • bunches (1D array of BunchStruct) –
  • append (bool) –
  • error (bool) –
  • lat (LatStruct) –
  • alive_only (bool) –

hdf5_write_grid_field

Fortran source: bmad/modules/bmad_routine_interface.f90

hdf5_write_grid_field(file_name: str, ele: pybmad._pybmad.EleStruct, g_field: pybmad._pybmad.GridFieldStructArray1D, err_flag: bool) -> None

Wrapper for Fortran routine hdf5_write_grid_field

Parameters:
  • file_name (str) –
  • ele (EleStruct) –
  • g_field (1D array of GridFieldStruct) –
  • err_flag (bool) –

hwang_bend_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

hwang_bend_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orb: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine hwang_bend_edge_kick (ele, param, particle_at, orb, mat6, make_matrix)

Subroutine to track through the edge field of an sbend using a 2nd order map. Adapted from: Hwang and S. Y. Lee, "Dipole Fringe Field Thin Map for Compact Synchrotrons", Phys. Rev. ST Accel. Beams, 12, 122401, (2015). See the Bmad manual for details.

Parameters:
  • ele (EleStruct) –

    SBend element.

  • param (LatParamStruct) –

    Rel charge.

  • particle_at (int) –

    first_track_edge\(, or second_track_edge\)

  • orb (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orb: Coords after tracking.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the edge. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix including the edge.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

ibs_matrix_c

Fortran source: bmad/multiparticle/envelope_mod.f90

ibs_matrix_c(sigma_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], tail_cut: bool, tau: typing.SupportsFloat | typing.SupportsIndex, energy: typing.SupportsFloat | typing.SupportsIndex, n_part: typing.SupportsFloat | typing.SupportsIndex, species: typing.SupportsInt | typing.SupportsIndex, ibs_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> None

Wrapper for Fortran routine ibs_matrix_c

Parameters:
  • sigma_mat (2D array of float (shape: 6,6)) –
  • tail_cut (bool) –
  • tau (float) –
  • energy (float) –
  • n_part (float) –
  • species (int) –
  • ibs_mat (2D array of float (shape: 6,6)) –

igfcoulombfun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

igfcoulombfun(u: typing.SupportsFloat | typing.SupportsIndex, v: typing.SupportsFloat | typing.SupportsIndex, w: typing.SupportsFloat | typing.SupportsIndex, gam: typing.SupportsFloat | typing.SupportsIndex, dx: typing.SupportsFloat | typing.SupportsIndex, dy: typing.SupportsFloat | typing.SupportsIndex, dz: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine igfcoulombfun

Parameters:
  • u (float) –
  • v (float) –
  • w (float) –
  • gam (float) –
  • dx (float) –
  • dy (float) –
  • dz (float) –
  • res (float) –

igfexfun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

igfexfun(u: typing.SupportsFloat | typing.SupportsIndex, v: typing.SupportsFloat | typing.SupportsIndex, w: typing.SupportsFloat | typing.SupportsIndex, gam: typing.SupportsFloat | typing.SupportsIndex, dx: typing.SupportsFloat | typing.SupportsIndex, dy: typing.SupportsFloat | typing.SupportsIndex, dz: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine igfexfun

Parameters:
  • u (float) –
  • v (float) –
  • w (float) –
  • gam (float) –
  • dx (float) –
  • dy (float) –
  • dz (float) –
  • res (float) –

igfeyfun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

igfeyfun(u: typing.SupportsFloat | typing.SupportsIndex, v: typing.SupportsFloat | typing.SupportsIndex, w: typing.SupportsFloat | typing.SupportsIndex, gam: typing.SupportsFloat | typing.SupportsIndex, dx: typing.SupportsFloat | typing.SupportsIndex, dy: typing.SupportsFloat | typing.SupportsIndex, dz: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine igfeyfun

Parameters:
  • u (float) –
  • v (float) –
  • w (float) –
  • gam (float) –
  • dx (float) –
  • dy (float) –
  • dz (float) –
  • res (float) –

igfezfun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

igfezfun(u: typing.SupportsFloat | typing.SupportsIndex, v: typing.SupportsFloat | typing.SupportsIndex, w: typing.SupportsFloat | typing.SupportsIndex, gam: typing.SupportsFloat | typing.SupportsIndex, dx: typing.SupportsFloat | typing.SupportsIndex, dy: typing.SupportsFloat | typing.SupportsIndex, dz: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine igfezfun

Parameters:
  • u (float) –
  • v (float) –
  • w (float) –
  • gam (float) –
  • dx (float) –
  • dy (float) –
  • dz (float) –
  • res (float) –

init_attribute_name1

Fortran source: bmad/modules/attribute_mod.f90

init_attribute_name1(is_ok: bool, ix_key: typing.SupportsInt | typing.SupportsIndex, ix_attrib: typing.SupportsInt | typing.SupportsIndex, name: str, attrib_state: typing.SupportsInt | typing.SupportsIndex | None = None, override: bool | None = None) -> pybmad._pybmad.InitAttributeName1

subroutine init_attribute_name1 (is_ok, ix_key, ix_attrib, name, attrib_state, override)

Routine to initialize a single name in the element attribute name table.

Parameters:
  • is_ok (bool) –

    Initial setting. This parameter is an input/output and is modified in-place. As an output, is_ok: Set False if there is a problem. Otherwise untouched.

  • ix_key (int) –

    Key index.

  • ix_attrib (int) –

    Attribute index.

  • name (str) –

    Attribute name. Should be uppercase if attrib_state = is_free\(. Should contain non-uppercase characters if attrib_state = private\).

  • attrib_state (int) –

    Class of attribute: does_not_exist\(, is_free\), etc. Defaults to is_free$.

  • override (bool) –

    Normally this routine throws an error if the [ix_key, ix_attrib] has been set previously. If override = True then the set is done and no error is generated.

Returns:
  • is_ok( bool ) –

    Initial setting. This parameter is an input/output and is modified in-place. As an output, is_ok: Set False if there is a problem. Otherwise untouched.

init_attribute_name_array

Fortran source: bmad/modules/attribute_mod.f90

init_attribute_name_array() -> None

Subroutine init_attribute_name_array ()

Private routine to initialize the attribute name array used by routines in attribute_mod. Not meant for general use.

init_beam_distribution

Fortran source: bmad/multiparticle/beam_utils.f90

init_beam_distribution(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, beam_init: pybmad._pybmad.BeamInitStruct, modes: pybmad._pybmad.NormalModesStruct | None = None, print_p0c_shift_warning: bool | None = None, conserve_momentum: bool | None = None) -> pybmad._pybmad.InitBeamDistribution

Subroutine init_beam_distribution (ele, param, beam_init, beam, err_flag, modes, beam_init_set, print_p0c_shift_warning, conserve_momentum)

Subroutine to initialize a beam of particles. Initialization uses the downstream parameters of ele.

Note: This routine sets the random number generator according to the settings in beam_int and at the end resets things to their initial state.

For more information on individual bunch initialization, see the init_bunch_distribution routine.

Note: The optional "modes" argument generally is used to pass in normal mode parameters as calculated from the lattice. If present, and if a parameter like beam_init%a_emit are set negative, then the corresponding parameter in the modes structure is used. If not present, a warning message is issued and the parameter is set to zero. This is only used for parameters that cannot be negative.

Parameters:
  • ele (EleStruct) –

    element to initialize distribution at (downstream end).

  • param (LatParamStruct) –

    Lattice parameters

  • beam_init (BeamInitStruct) –

    Use "getf beam_init_struct" for more details.

  • modes (NormalModesStruct) –

    Normal mode parameters. See above.

  • print_p0c_shift_warning (bool) –

    Default is True. See hdf5_read_beam doc. Only used when reading hdf5 file.

Returns:
  • beam( BeamStruct ) –

    Structure with initialized particles.

  • err_flag( (bool, optional) ) –

    Set true if there is an error, false otherwise.

  • beam_init_set( (BeamInitStruct, optional) ) –

    Set to input beam_init with components like .a_emit set what is used in constructing the beam (which is different from beam_init.a_emit if this is set negative).

init_bmad

Fortran source: bmad/modules/bmad_routine_interface.f90

init_bmad() -> None

Wrapper for Fortran routine init_bmad

init_bmad_parser_common

Fortran source: bmad/modules/bmad_routine_interface.f90

init_bmad_parser_common(lat: pybmad._pybmad.LatStruct | None = None) -> None

Wrapper for Fortran routine init_bmad_parser_common

Parameters:

init_bunch_distribution

Fortran source: bmad/multiparticle/beam_utils.f90

init_bunch_distribution(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, beam_init: pybmad._pybmad.BeamInitStruct, ix_bunch: typing.SupportsInt | typing.SupportsIndex, modes: pybmad._pybmad.NormalModesStruct | None = None, print_p0c_shift_warning: bool | None = None, conserve_momentum: bool | None = None) -> pybmad._pybmad.InitBunchDistribution

Subroutine init_bunch_distribution (ele, param, beam_init, ix_bunch, bunch, err_flag, modes, beam_init_used, print_p0c_shift_warning, conserve_momentum)

Subroutine to initialize a distribution of particles of a bunch. Initialization uses the downstream parameters of ele.

There are four distributions available: '', or 'ran_gauss' -- Random gaussian distribution. 'ellipse' -- concentric ellipses representing a Gaussian distribution 'grid' -- uniform rectangular grid 'KV' -- Kapchinsky-Vladimirsky distribution See the Bmad manual for more information.

The distribution is matched to the Twiss parameters, centroid position, and Energy - z correlation as specified. Coupling in the element ele is incorporated into the distribution.

Note: Except for the random number seed, the random number generator parameters used for this routine are set from the beam_init argument. That is, these parameters are independent of what is used everywhere else.

Note: Make sure: |beam_init%dpz_dz| < mode%sigE_E / mode%sig_z

Note: The optional "modes" argument generally is used to pass in normal mode parameters as calculated from the lattice. If present, and if a parameter like beam_init%a_emit are set negative, then the corresponding parameter in the modes structure is used. If not present, a warning message is issued and the parameter is set to zero. This is only used for parameters that cannot be negative.

Note: To get good results, It is important to make sure that for circular rings that beam_init%center is the correct closed orbit. The closed orbit will shift if, for example, radiation damping is turned on.

Parameters:
  • ele (EleStruct) –

    element to initialize distribution at (downstream end).

  • param (LatParamStruct) –

    Lattice parameters

  • beam_init (BeamInitStruct) –

    Use "getf beam_init_struct" for more details.

  • ix_bunch (int) –

    Bunch index. 0 = bunch generated at time = 0.

  • modes (NormalModesStruct) –

    Normal mode parameters. See above.

  • print_p0c_shift_warning (bool) –

    Default is True. See hdf5_read_beam doc. Only used when reading hdf5 file.

Returns:
  • bunch( BunchStruct ) –

    Structure with initialized particles.

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

  • beam_init_used( (BeamInitStruct, optional) ) –

    Set to input beam_init with components like .a_emit set what is used in constructing the beam (which can be different from beam_init.a_emit if this is set negative). If reading from a file, beam_init_used will equal beam_init.

init_complex_taylor_series

Fortran source: bmad/modules/bmad_routine_interface.f90

init_complex_taylor_series(complex_taylor: pybmad._pybmad.ComplexTaylorStruct, n_term: typing.SupportsInt | typing.SupportsIndex, save: bool | None = None) -> None

Subroutine init_complex_taylor_series (complex_taylor, n_term, save)

Subroutine to initialize a Bmad complex_taylor series (6 of these series make a complex_taylor map). Note: This routine does not zero the structure. The calling routine is responsible for setting all values.

Parameters:
  • complex_taylor (ComplexTaylorStruct) –

    Old structure. This parameter is an input/output and is modified in-place. As an output, complex_taylor: Initalized structure.

  • n_term (int) –

    Number of terms to allocate. n_term < 1 => complex_taylor.term pointer will be disassociated.

  • save (bool) –

    If True then save any old terms when complex_taylor is resized. Default is False.

init_coord

Fortran sources (overloaded):

init_coord(args, *kwargs) Overloaded function.

  1. init_coord(orb: pybmad._pybmad.CoordStruct, vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], ele: pybmad._pybmad.EleStruct | None = None, element_end: typing.SupportsInt | typing.SupportsIndex | None = None, particle: typing.SupportsInt | typing.SupportsIndex | None = None, direction: typing.SupportsInt | typing.SupportsIndex | None = None, E_photon: typing.SupportsFloat | typing.SupportsIndex | None = None, t_offset: typing.SupportsFloat | typing.SupportsIndex | None = None, shift_vec6: bool | None = None, spin: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None, s_pos: typing.SupportsFloat | typing.SupportsIndex | None = None, random_on: bool | None = None) -> None

Subroutine init_coord (...)

Routine to initialize a coord_struct.

This routine is an overloaded name for: Subroutine init_coord1 (orb, vec, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on) Subroutine init_coord2 (orb, orb_in, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on) Subroutine init_coord3 (orb, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on)

Note: Unless shift_vec6 is set to False, if ele is a beginning_ele (IE, the element at the beginning of the lattice), or e_gun, orb%vec(6) is shifted so that a particle with orb%vec(6) = 0 will end up with a value of orb%vec(6) corresponding to the beginning_ele's value of ele%value(p0c_start$).

Note: For non-photons, if orb_in%vec(5) is set to real_garbage$, orb_in%t will be used to set orb%vec(5) instead of the standard which is to set orb%t from orb%vec(5).

For photons: orb%vec(5) is set depending upon where the photon is relative to the element. If orb is a photon, and orb_in is not a photon, photon is launched in same direciton as particle except if direction is set.

Parameters:
  • orb (CoordStruct) –

    Input orbit

  • vec (1D array of float (shape: 6)) –

    Coordinate vector. If not present then taken to be zero.

  • ele (EleStruct) –

    Particle is initialized to start at element_end of this ele.

  • element_end (int) –

    upstream_end\(, downstream_end\), inside\(, or start_end\). Must be present if ele argument is present. start_end$ -> upstream_end$ if dir = 1 and start_end$ -> downstream_end$ if dir = -1. Default is upstream_end$. Note: If ele is the beginning element (index zero), the setting of element_end will not matter.

  • particle (int) –

    Particle type (electron\(, etc.). If particle = not_set\) and orb_in is present, use orb_in.species instead.

  • direction (int) –

    +1 -> moving downstream +s direciton, -1 -> moving upstream. 0 -> Ignore. Default is to not change orb.direction except for photons which get set according to orb.vec(6).

  • E_photon (float) –

    Photon energy if particle is a photon. Ignored otherwise.

  • t_offset (float) –

    Offset of the reference time. This is non-zero when there are multiple bunches and the reference time for a particular particle is pegged to the time of the center of the bunch.

  • shift_vec6 (bool) –

    If present and False, prevent the shift of orb.vec(6).

  • spin (1D array of float (shape: 3)) –

    Particle spin. Taken to be zero if not present.

  • s_pos (float) –

    Particle s-position. Only relavent if element_end = inside$.

  • random_on (bool) –

    Default is True. Used only for photons being initalized with a photon_init element. If True, vary the photon coords using a random number generator. If False, the photon coords will be centered within the distribution specified in the photon_init ele.

  • Subroutine
  • Routine
  • This

    Subroutine init_coord1 (orb, vec, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on) Subroutine init_coord2 (orb, orb_in, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on) Subroutine init_coord3 (orb, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on)

  • Note
  • or
  • corresponding
  • Note
  • of
  • For

    orb%vec(5) is set depending upon where the photon is relative to the element. If orb is a photon, and orb_in is not a photon, photon is launched in same direciton as particle except if direction is set.

Parameters:
  • orb_in (CoordStruct) –

    Input orbit

  • ele (EleStruct) –

    Particle is initialized to start at element_end of this ele.

  • element_end (int) –

    upstream_end\(, downstream_end\), inside\(, or start_end\). Must be present if ele argument is present. start_end$ -> upstream_end$ if dir = 1 and start_end$ -> downstream_end$ if dir = -1. Default is upstream_end$. Note: If ele is the beginning element (index zero), the setting of element_end will not matter.

  • particle (int) –

    Particle type (electron\(, etc.). If particle = not_set\) and orb_in is present, use orb_in.species instead.

  • direction (int) –

    +1 -> moving downstream +s direciton, -1 -> moving upstream. 0 -> Ignore. Default is to not change orb.direction except for photons which get set according to orb.vec(6).

  • E_photon (float) –

    Photon energy if particle is a photon. Ignored otherwise.

  • t_offset (float) –

    Offset of the reference time. This is non-zero when there are multiple bunches and the reference time for a particular particle is pegged to the time of the center of the bunch.

  • shift_vec6 (bool) –

    If present and False, prevent the shift of orb.vec(6).

  • spin (1D array of float (shape: 3)) –

    Particle spin. Taken to be zero if not present.

  • s_pos (float) –

    Particle s-position. Only relavent if element_end = inside$.

  • random_on (bool) –

    Default is True. Used only for photons being initalized with a photon_init element. If True, vary the photon coords using a random number generator. If False, the photon coords will be centered within the distribution specified in the photon_init ele.

Returns:
  • orb_out( CoordStruct ) –

    Initialized coordinate

  • 3. init_coord(orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct | None = None, element_end: typing.SupportsInt | typing.SupportsIndex | None = None, particle: typing.SupportsInt | typing.SupportsIndex | None = None, direction: typing.SupportsInt | typing.SupportsIndex | None = None, E_photon: typing.SupportsFloat | typing.SupportsIndex | None = None, t_offset: typing.SupportsFloat | typing.SupportsIndex | None = None, shift_vec6: bool | None = None, spin: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None) -> None
  • Subroutine init_coord (...)
  • Routine to initialize a coord_struct.
  • This routine is an overloaded name for:

    Subroutine init_coord1 (orb, vec, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on) Subroutine init_coord2 (orb, orb_in, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on) Subroutine init_coord3 (orb, ele, element_end, particle, direction, E_photon, t_offset, shift_vec6, spin, s_pos, random_on)

  • Note( Unless shift_vec6 is set to False, if ele is a beginning_ele (IE, the element at the beginning of the lattice), ) –
  • or e_gun, orb%vec(6) is shifted so that a particle with orb%vec(6) = 0 will end up with a value of orb%vec(6)
  • corresponding to the beginning_ele's value of ele%value(p0c_start$).
  • Note( For non-photons, if orb_in%vec(5) is set to real_garbage$, orb_in%t will be used to set orb%vec(5) instead ) –
  • of the standard which is to set orb%t from orb%vec(5).
  • For photons:

    orb%vec(5) is set depending upon where the photon is relative to the element. If orb is a photon, and orb_in is not a photon, photon is launched in same direciton as particle except if direction is set.

Parameters:
  • orb (CoordStruct) –

    Input orbit

  • ele (EleStruct) –

    Particle is initialized to start at element_end of this ele.

  • element_end (int) –

    upstream_end\(, downstream_end\), inside\(, or start_end\). Must be present if ele argument is present. start_end$ -> upstream_end$ if dir = 1 and start_end$ -> downstream_end$ if dir = -1. Default is upstream_end$. Note: If ele is the beginning element (index zero), the setting of element_end will not matter.

  • particle (int) –

    Particle type (electron\(, etc.). If particle = not_set\) and orb_in is present, use orb_in.species instead.

  • direction (int) –

    +1 -> moving downstream +s direciton, -1 -> moving upstream. 0 -> Ignore. Default is to not change orb.direction except for photons which get set according to orb.vec(6).

  • E_photon (float) –

    Photon energy if particle is a photon. Ignored otherwise.

  • t_offset (float) –

    Offset of the reference time. This is non-zero when there are multiple bunches and the reference time for a particular particle is pegged to the time of the center of the bunch.

  • shift_vec6 (bool) –

    If present and False, prevent the shift of orb.vec(6).

  • spin (1D array of float (shape: 3)) –

    Particle spin. Taken to be zero if not present.

init_custom

Fortran source: bmad/modules/bmad_routine_interface.f90

init_custom(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine init_custom

Parameters:

init_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

init_ele(key: typing.SupportsInt | typing.SupportsIndex | None = None, sub_key: typing.SupportsInt | typing.SupportsIndex | None = None, ix_ele: typing.SupportsInt | typing.SupportsIndex | None = None, branch: pybmad._pybmad.BranchStruct | None = None) -> pybmad._pybmad.EleStruct

Wrapper for Fortran routine init_ele

Parameters:
  • key (int) –

    Key to initialize to. EG: quadrupole$, etc.

  • sub_key (int) –

    Sub-key to initialize to.

  • ix_ele (int) –

    ix_ele index to initalize to. Default = -1.

  • branch (BranchStruct) –

    Branch to point ele.branch and ele.ix_branch to. Otherwise ele.branch is nullified and ele.ix_branch = 0.

Returns:

init_gg_taylor_series

Fortran source: bmad/modules/bmad_routine_interface.f90

init_gg_taylor_series(gg_taylor: pybmad._pybmad.GgTaylorStruct, n_term: typing.SupportsInt | typing.SupportsIndex, save_old: bool | None = None) -> None

Subroutine init_gg_taylor_series (gg_taylor, n_term, save_old)

Subroutine to initialize a Bmad gg_taylor series (6 of these series make a gg_taylor map). Note: This routine does not zero the structure. The calling routine is responsible for setting all values.

Parameters:
  • gg_taylor (GgTaylorStruct) –

    Old structure. This parameter is an input/output and is modified in-place. As an output, gg_taylor: Initalized structure.

  • n_term (int) –

    Number of terms to allocate. n_term < 0 => gg_taylor.term pointer will be disassociated.

  • save_old (bool) –

    If True then save any old terms when gg_taylor is resized. Default is False.

init_lat

Fortran source: bmad/modules/bmad_routine_interface.f90

init_lat(n: typing.SupportsInt | typing.SupportsIndex | None = None, init_beginning_ele: bool | None = None) -> pybmad._pybmad.LatStruct

Wrapper for Fortran routine init_lat

Parameters:
  • n (int) –

    Upper bound lat.ele(0:) array is initialized to. Default is 10.

  • init_beginning_ele (bool) –

    Init lat.ele(0)? Default is False.

Returns:

init_multipole_cache

Fortran source: bmad/modules/bmad_routine_interface.f90

init_multipole_cache(ele: pybmad._pybmad.EleStruct) -> None

Wrapper for Fortran routine init_multipole_cache

Parameters:
  • ele (EleStruct) –

    Element to init This parameter is an input/output and is modified in-place. As an output, ele: Initalized element.

init_photon_from_a_photon_init_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

init_photon_from_a_photon_init_ele(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, random_on: bool | None = None) -> pybmad._pybmad.CoordStruct

Wrapper for Fortran routine init_photon_from_a_photon_init_ele

Parameters:
  • ele (EleStruct) –

    patch element.

  • param (LatParamStruct) –

    lat_param_struct.

  • random_on (bool) –

    : Default is True. If False then use zero for all random numbers needed in the calc.

Returns:

init_photon_integ_prob

Fortran source: bmad/photon/photon_init_mod.f90

init_photon_integ_prob(gamma: typing.SupportsFloat | typing.SupportsIndex, g: typing.SupportsFloat | typing.SupportsIndex, E_min: typing.SupportsFloat | typing.SupportsIndex, E_max: typing.SupportsFloat | typing.SupportsIndex, vert_angle_min: typing.SupportsFloat | typing.SupportsIndex | None = None, vert_angle_max: typing.SupportsFloat | typing.SupportsIndex | None = None, vert_angle_symmetric: bool | None = None, energy_integ_prob: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.InitPhotonIntegProb

Function init_photon_integ_prob(gamma, g, E_min, E_max, vert_angle_min, vert_angle_max, vert_angle_symmetric, energy_integ_prob, E_photon) result (integ_prob)

Routine to calcuate the integrated probability of emitting a photon in a given vertical angle range and in a given energy range

Parameters:
  • gamma (float) –

    Gamma factor of charged particle emitting photon.

  • g (float) –

    1/rho bending strength.

  • E_min (float) –

    Minimum photon energy.

  • E_max (float) –

    Maximum photon energy.

  • vert_angle_min (float) –

    Lower bound of vertical angle range.

  • vert_angle_max (float) –

    Upper bound of vertical angle range.

  • vert_angle_symmetric (bool) –

    Use two symmetric ranges [-vert_angle_max, -vert_angle_min] and [vert_angle_min, vert_angle_max] instead of just [vert_angle_min, vert_angle_max]?

  • energy_integ_prob (float) –

    If present, E_photon will be set to the photon energy such that the integrated probability of generating a photon in the given angle and energy range in the interval [E_min, E_photon] is energy_integ_prob. That is, energy_integ_prob = 0 => E_photon = E_min and energy_integ_prob = 1 => E_photon = E_max.

Returns:
  • integ_prob( float ) –

    Integrated probablility of emitting a photon in given angle and energy range.

  • E_photon( (float, optional) ) –

    See energy_integ_prob. E_photon must be present if energy_integ_prob is.

init_spin_distribution

Fortran source: bmad/multiparticle/beam_utils.f90

init_spin_distribution(beam_init: pybmad._pybmad.BeamInitStruct, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.BunchStruct

Subroutine init_spin_distribution (beam_init, bunch, ele)

Initializes a spin distribution according to beam_init%spin.

Parameters:
Returns:
  • bunch( BunchStruct ) –

    Bunch of particles. .particle(:).spin

init_surface_segment

Fortran source: bmad/parsing/bmad_parser_mod.f90

init_surface_segment(phot: pybmad._pybmad.PhotonElementStruct, ix_pt: typing.SupportsInt | typing.SupportsIndex, iy_pt: typing.SupportsInt | typing.SupportsIndex) -> None

Subroutine init_surface_segment (phot, ix_pt, iy_pt)

Routine to init the componentes in ele%photon%segmented%pt(ix_pt,iy_pt) for use with segmented surface calculations.

Parameters:
  • phot (PhotonElementStruct) –

    Surface structure.

  • ix_pt (int) –

    index of grid point to init.

  • iy_pt (int) –

    index of grid point to init.

init_taylor_series

Fortran source: bmad/modules/bmad_routine_interface.f90

init_taylor_series(bmad_taylor: pybmad._pybmad.TaylorStruct, n_term: typing.SupportsInt | typing.SupportsIndex, save_old: bool | None = None) -> None

Wrapper for Fortran routine init_taylor_series

Parameters:
  • bmad_taylor (TaylorStruct) –

    Old structure. This parameter is an input/output and is modified in-place. As an output, bmad_taylor: Initalized structure.

  • n_term (int) –

    Number of terms to allocate. n_term < 0 => bmad_taylor.term pointer will be disassociated.

  • save_old (bool) –

    If True then save any old terms and ref orbit when bmad_taylor is resized. If False zero the ref orbit. Default is False.

init_wake

Fortran source: bmad/modules/bmad_routine_interface.f90

init_wake(n_sr_long: typing.SupportsInt | typing.SupportsIndex, n_sr_trans: typing.SupportsInt | typing.SupportsIndex, n_sr_z: typing.SupportsInt | typing.SupportsIndex, n_lr_mode: typing.SupportsInt | typing.SupportsIndex, always_allocate: bool | None = None) -> pybmad._pybmad.WakeStruct | None

Wrapper for Fortran routine init_wake

Parameters:
  • n_sr_long (int) –

    Number of terms: wake.sr.long.

  • n_sr_trans (int) –

    Number of terms: wake.sr.trans.

  • n_sr_z (int) –

    Number of terms: wake.sr.z.

  • n_lr_mode (int) –

    Number of terms: wake.lr.mode.

  • always_allocate (bool) –

    If present and True then allways allocate wake even if n_lr_mode, etc. are all 0. Default is False.

Returns:
  • wake( (WakeStruct, optional) ) –

    Initialized structure.

insert_element

Fortran source: bmad/modules/bmad_routine_interface.f90

insert_element(lat: pybmad._pybmad.LatStruct, insert_ele: pybmad._pybmad.EleStruct, ix_ele: typing.SupportsInt | typing.SupportsIndex, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, orbit: pybmad._pybmad.CoordStructAlloc1D | None = None) -> None

Wrapper for Fortran routine insert_element

Parameters:
  • lat (LatStruct) –

    lattice that will be modified This parameter is an input/output and is modified in-place. As an output, lat: lattice with new element inserted

  • insert_ele (EleStruct) –

    element to insert into the lat

  • ix_ele (int) –

    branch.ele(:) index where the new element is inserted.

  • ix_branch (int) –

    : branch index for the insertion. Default = 0.

  • orbit (1D array of CoordStruct) –

    orbit array to enlarge. This parameter is an input/output and is modified in-place. As an output, orbit: Enlarged orbit array.

integrand_base

Fortran source: bmad/multiparticle/touschek_mod.f90

integrand_base(t: typing.SupportsFloat | typing.SupportsIndex, args: pybmad._pybmad.RealArray1D, func_retval__: typing.SupportsFloat | typing.SupportsIndex) -> None

Function integrand_base(t)

This vectorized private function is the integrand in equation 31 of Piwinski's paper.

This intetegrand has a sharp exponential decay, and so a change of variables from t to y where t=exp(y) is applied. This COV makes the integrand more evenly distributed over the domain of integration, which makes it easier for qtrap to integrate.

The change of variables is done using integrand_base_cov, which is then integrated using qtrap.

Parameters:
  • t (float) –

    Array of reals over which to evaluate the integrand.

integrate_psi

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

integrate_psi(bound: typing.SupportsFloat | typing.SupportsIndex, p0: typing.SupportsFloat | typing.SupportsIndex, args: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"]) -> float

Subroutine integrate_psi(bound,p0,args,result)

Integrate psi(t) from -bound to +bound. The integration is done in two parts. First from 0 to -bound, then from 0 to +bound.

Parameters:
  • bound (float) –

    integration bound

  • p0 (float) –

    psi(0). Boundary condition.

  • args (1D array of float (shape: 1:8)) –

    Parameters and constants of DEQ. See psi_prime comments for details.

Returns:
  • result( float ) –

    Integral of psi from -bound to +bound.

integrated_mats

Fortran source: bmad/multiparticle/envelope_mod.f90

integrated_mats(eles: pybmad._pybmad.EleStructArray1D, coos: pybmad._pybmad.CoordStructArray1D, Lambda: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], Theta: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], Iota: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], mode: pybmad._pybmad.NormalModesStruct) -> None

subroutine integrated_mats(eles,coos,Lambda,Theta,Iota,mode)

integration_timer

Fortran sources (overloaded):

integration_timer(args, *kwargs) Overloaded function.

  1. integration_timer(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, start: pybmad._pybmad.CoordStruct, orb_max: pybmad._pybmad.CoordStruct, tol: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine integration_timer_ele

Parameters:
Parameters:
  • a_fibre (Fibre) –
  • orbit (1D array of float (shape: 6)) –
  • orbit_max (1D array of float (shape: 6)) –
  • tol_dp (float) –

ion_kick

Fortran source: bmad/modules/bmad_routine_interface.f90

ion_kick(orbit: pybmad._pybmad.CoordStruct, r_beam: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], n_beam_part: typing.SupportsFloat | typing.SupportsIndex, a_twiss: pybmad._pybmad.TwissStruct, b_twiss: pybmad._pybmad.TwissStruct, sig_ee: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[float], "FixedSize(3)"]

Wrapper for Fortran routine ion_kick

Parameters:
  • orbit (CoordStruct) –

    Ion position.

  • r_beam (1D array of float (shape: 2)) –

    Beam (x, y) position.

  • n_beam_part (float) –

    Number of beam particles.

  • a_twiss (TwissStruct) –

    Horizontal like beam twiss parameters.

  • b_twiss (TwissStruct) –

    vertical like beam twiss parameters.

  • sig_ee (float) –

    Sigma_E/E beam energy spread.

Returns:
  • kick( 1D array of float (shape: 3) ) –

    (x, y, s) kick in m/sec.

is_attribute

Fortran source: bmad/modules/bmad_struct.f90

is_attribute(ix_attrib: typing.SupportsInt | typing.SupportsIndex, which: typing.SupportsInt | typing.SupportsIndex) -> bool

Function is_attribute (ix_attrib, which) result (is_attrib)

Routine to determine if an attribute index corresponds to a control variable for overlys/groups.

Parameters:
  • ix_attrib (int) –

    Attribute index.

  • which (int) –

    control_var\(, old_control_var\), all_control_var\(, multipole\), elec_multipole$

Returns:
  • is_attrib( bool ) –

    True if a control variable

key_name_to_key_index

Fortran source: bmad/modules/bmad_routine_interface.f90

key_name_to_key_index(key_str: str, abbrev_allowed: bool | None = None) -> int

Wrapper for Fortran routine key_name_to_key_index

Parameters:
  • key_str (str) –

    Name of the key. Result is case insensitive.

  • abbrev_allowed (bool) –

    Abbreviations (eg: "quad") allowed? Default is False. At least 3 characters are needed (except for rfcavity elements) if True.

Returns:
  • key_index( int ) –

    Index of the key. Set to -1 if key_name not recognized.

kick_vector_calc

Fortran source: bmad/modules/runge_kutta_mod.f90

kick_vector_calc(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, s_body: typing.SupportsFloat | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, print_err: bool | None = None) -> pybmad._pybmad.KickVectorCalc

Subroutine kick_vector_calc (ele, param, s_rel, orbit, dr_ds, field, err, print_err)

Subroutine to calculate the dr/ds "kick vector" where r = [x, p_x, y, p_y, z, p_z, t, spin_x,y,z]

Remember: In order to simplify the calculation, in the body of any element, P0 is taken to be the P0 at the exit end of the element.

dr(1)/ds = dx/ds = dx/dt * dt/ds where: dx/dt = v_x = p_x / (1 + p_z) dt/ds = (1 + g*x) / v_s g = 1/rho, rho = bending radius (nonzero only in a dipole)

dr(2)/ds = dp_x/ds = dP_x/dt * dt/ds / P0 + g_x * P_z where: dP_x/dt = EM_Force_x g_x = bending in x-plane.

dr(3)/ds = dy/ds = dy/dt * dt/ds where: dy/dt = v_x

dr(4)/ds = dp_y/ds = dP_y/dt * ds/dt / P0 + g_y * P_z where: dP_y/dt = EM_Force_y g_y = bending in y-plane.

NOTE: dr(5)/ds IS IGNORED WHEN CALCULATING Z. SEE TRANSFER_THIS_ORBIT ABOVE. dr(5)/ds = dz/ds = beta * c_light * [dt/ds(ref) - dt/ds] + dbeta/ds * c_light * [t(ref) - t] = beta * c_light * [dt/ds(ref) - dt/ds] + dbeta/ds * vec(5) / beta where: dt/ds(ref) = 1 / beta(ref)

dr(6)/ds = dp_z/ds = d(EM_Force dot v_hat) * dt/ds / P0 where: v_hat = velocity normalized to 1.

dr(7)/ds = dt/ds

dr(8:10)/ds = Spin omega vector

dr(11)/ds = dt_ref/ds

Parameters:
Returns:
  • dr_ds( 1D array of float (shape: 11) ) –

    Kick vector.

  • err( bool ) –

    Set True if there is an error.

kill_complex_taylor

Fortran source: bmad/modules/complex_taylor_mod.f90

kill_complex_taylor(complex_taylor: pybmad._pybmad.ComplexTaylorStructArray1D) -> None

Subroutine kill_complex_taylor (complex_taylor)

Subroutine to deallocate a Bmad complex_taylor map.

Parameters:
  • complex_taylor (1D array of ComplexTaylorStruct) –

    complex_taylor to be deallocated. It is OK if complex_taylor has already been deallocated. This parameter is an input/output and is modified in-place. As an output, complex_taylor: deallocated complex_taylor structure.

kill_ptc_layouts

Fortran source: bmad/modules/bmad_routine_interface.f90

kill_ptc_layouts(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine kill_ptc_layouts

Parameters:
  • lat (LatStruct) –

    Bmad lattice with associated layouts.

kill_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

kill_taylor(bmad_taylor: pybmad._pybmad.TaylorStructArray1D) -> None

Wrapper for Fortran routine kill_taylor

Parameters:
  • bmad_taylor (1D array of TaylorStruct) –

    Taylor to be deallocated. This parameter is an input/output and is modified in-place. As an output, bmad_taylor: deallocated Taylor structure.

kind_name

Fortran source: bmad/ptc/ptc_interface_mod.f90

kind_name(this_kind: typing.SupportsInt | typing.SupportsIndex) -> str

Function kind_name (this_kind) result (kind_str)

function to return the name of a PTC kind.

Parameters:
  • this_kind (int) –

    PTC kind

Returns:
  • kind_str( str ) –

    String representation

knot_interpolate

Fortran source: bmad/modules/bmad_routine_interface.f90

knot_interpolate(x_knot: pybmad._pybmad.RealArray1D, y_knot: pybmad._pybmad.RealArray1D, x_pt: typing.SupportsFloat | typing.SupportsIndex, interpolation: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.KnotInterpolate

Wrapper for Fortran routine knot_interpolate

Parameters:
  • x_knot (1D array of float) –

    Knot x-values.

  • y_knot (1D array of float) –

    Knot y-values.

  • x_pt (float) –

    Point to evaluate at.

  • interpolation (int) –

    Interpolation type. cubic$ or linear$.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

  • y_pt( float ) –

    Interpolated y-value.

knots_to_string

Fortran source: bmad/modules/bmad_routine_interface.f90

knots_to_string(x_knot: pybmad._pybmad.RealArray1D, y_knot: pybmad._pybmad.RealArray1D, str: str) -> None

Wrapper for Fortran routine knots_to_string

Parameters:
  • x_knot (1D array of float) –
  • y_knot (1D array of float) –
  • str (str) –

lafun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

lafun(x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, z: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine lafun

Parameters:
  • x (float) –
  • y (float) –
  • z (float) –
  • res (float) –

lat_compute_ref_energy_and_time

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_compute_ref_energy_and_time(lat: pybmad._pybmad.LatStruct) -> bool

Wrapper for Fortran routine lat_compute_ref_energy_and_time

Parameters:
Returns:
  • err_flag( bool ) –

    Set true if there is an error. False otherwise.

lat_ele_locator

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_ele_locator(loc_str: str, lat: pybmad._pybmad.LatStruct, eles: pybmad._pybmad.ElePointerStructAlloc1D, n_loc: typing.SupportsInt | typing.SupportsIndex, above_ubound_is_err: bool | None = None, ix_dflt_branch: typing.SupportsInt | typing.SupportsIndex | None = None, order_by_index: bool | None = None, append_eles: bool | None = None) -> pybmad._pybmad.LatEleLocator

Wrapper for Fortran routine lat_ele_locator

Parameters:
  • loc_str (str) –

    Element names or indexes. May be lower case.

  • lat (LatStruct) –

    Lattice to search through.

  • eles (1D array of ElePointerStruct) –

    If append_eles is True, save existing elements. This parameter is an input/output and is modified in-place. As an output, eles: Array of matching elements.

  • n_loc (int) –

    Number of existing elements. Used if append_eles is True. This parameter is an input/output and is modified in-place. As an output, n_loc: Number of locations found.

  • above_ubound_is_err (bool) –

    Default is True. If the upper bound "e2" on an "e1:e2" range construct is an integer and above the maximum element index then treat this as an error? If False, treat e2 as the maximum element index.

  • ix_dflt_branch (int) –

    If present and not -1 then restrict search to specified branch. If not present or -1: Search all branches. Exception: For elements specified using an integer index (EG: "43"), if ix_dflt_branch is not present or -1 use branch 0.

  • order_by_index (bool) –

    False is default. If True, order a component of loc_str like "quad::*" by element index instead of longitudinal s-position. Index ordering and s-position ordering are different when there are super lords and super slaves.

  • append_eles (bool) –

    Default is False. If True, found elements are appended to eles(:) array.

Returns:
  • n_loc( int ) –

    Number of existing elements. Used if append_eles is True. This parameter is an input/output and is modified in-place. As an output, n_loc: Number of locations found.

  • err( (bool, optional) ) –

    Set True if there is a decode error. Note: Not finding any matching element is not an error.

lat_equal_lat

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_equal_lat(lat_out: pybmad._pybmad.LatStruct, lat_in: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine lat_equal_lat

Parameters:

lat_geometry

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_geometry(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine lat_geometry

Parameters:

lat_make_mat6

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_make_mat6(lat: pybmad._pybmad.LatStruct, ix_ele: typing.SupportsInt | typing.SupportsIndex | None = None, ref_orb: pybmad._pybmad.CoordStructArray1D | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine lat_make_mat6

Parameters:
  • lat (LatStruct) –

    Lat containing the elements.

  • ix_ele (int) –

    Index of the element. If not present or negative, the matrices for all elements will be calculated.

  • ref_orb (1D array of CoordStruct) –

    Coordinates of the reference orbit around which the matrix is calculated. If not present then the referemce is taken to be the origin.

  • ix_branch (int) –

    Branch index. Default is 0 (main lattice). -1 => All branches/all elements (ref_orb & ix_ele will be ignored).

Returns:
  • err_flag( (bool, optional) ) –

    True if there is an error. False otherwise.

lat_sanity_check

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_sanity_check(lat: pybmad._pybmad.LatStruct) -> bool

Wrapper for Fortran routine lat_sanity_check

Parameters:
Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

lat_to_ptc_layout

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_to_ptc_layout(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine lat_to_ptc_layout

Parameters:

lat_vec_equal_lat_vec

Fortran source: bmad/modules/bmad_routine_interface.f90

lat_vec_equal_lat_vec(lat1: pybmad._pybmad.LatStructArray1D, lat2: pybmad._pybmad.LatStructArray1D) -> None

Wrapper for Fortran routine lat_vec_equal_lat_vec

Parameters:
  • lat1 (1D array of LatStruct) –
  • lat2 (1D array of LatStruct) –

lattice_bookkeeper

Fortran source: bmad/modules/bmad_routine_interface.f90

lattice_bookkeeper(lat: pybmad._pybmad.LatStruct) -> bool

Wrapper for Fortran routine lattice_bookkeeper

Parameters:
  • lat (LatStruct) –

    Lattice needing bookkeeping. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with bookkeeping done.

Returns:
  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

lcavity_rf_step_setup

Fortran source: bmad/modules/bmad_routine_interface.f90

lcavity_rf_step_setup(ele: pybmad._pybmad.EleStruct) -> None

Wrapper for Fortran routine lcavity_rf_step_setup

Parameters:
  • ele (EleStruct) –

    Lcavity element. This parameter is an input/output and is modified in-place. As an output, ele: Element with ele.rf properly setup.

linear_bend_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

linear_bend_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orb: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine linear_bend_edge_kick (ele, param, particle_at, orb, mat6, make_matrix)

Subroutine to track through the edge field of an sbend. Apply only the first order kick, which is edge focusing.

Parameters:
  • ele (EleStruct) –

    SBend element.

  • param (LatParamStruct) –

    Rel charge.

  • particle_at (int) –

    first_track_edge\(, or second_track_edge\),

  • orb (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orb: Coords after tracking.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the edge. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix including the edge.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

linear_coef

Fortran source: bmad/modules/expression_mod.f90

linear_coef(stack: pybmad._pybmad.ExpressionAtomStructArray1D) -> pybmad._pybmad.LinearCoef

Function linear_coef (stack, err_flag) result (coef)

Routine to return the linear coefficient of a linear expression.

Parameters:
  • stack (1D array of ExpressionAtomStruct) –

    Expression stack.

Returns:
  • err_flag( bool ) –

    Set True if the expression is not linear

  • coef( float ) –

    Linear coefficient.

linear_to_spin_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

linear_to_spin_taylor(q_map: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(7)"]], "FixedSize(4)"]) -> pybmad._pybmad.TaylorStructArray1D

Wrapper for Fortran routine linear_to_spin_taylor

Parameters:
  • q_map (2D array of float (shape: 0:3, 0:6)) –

    Linear quaternion map.

Returns:
  • spin_taylor( 1D array of TaylorStruct (shape: 0:3) ) –

    Taylor map

load_parse_line

Fortran source: bmad/parsing/bmad_parser_mod.f90

load_parse_line(action: str, ix_start: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.LoadParseLine

Subroutine load_parse_line (action, ix_start, end_of_file, err_flag)

Subroutine to load characters from the input file. This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

Parameters:
  • action (str) –

    'continue', 'new_command', or 'init'

  • ix_start (int) –

    Index in bp_com.parse_line string where to append stuff.

Returns:
  • end_of_file( bool ) –

    End of file reached?

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise

lord_edge_aligned

Fortran source: bmad/modules/bmad_routine_interface.f90

lord_edge_aligned(slave: pybmad._pybmad.EleStruct, slave_edge: typing.SupportsInt | typing.SupportsIndex, lord: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine lord_edge_aligned

Parameters:
  • slave (EleStruct) –

    Slave element.

  • slave_edge (int) –

    End under consideration: entrance_end\(, exit_end\), in_between$, etc.

  • lord (EleStruct) –

    Lord element.

Returns:
  • is_aligned( bool ) –

    True if a lord edge is aligned with the slave edge. If slave_edge is not entrance_end$ nor exit_end$ then is_aligned is False.

low_energy_z_correction

Fortran source: bmad/modules/bmad_routine_interface.f90

low_energy_z_correction(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, ds: typing.SupportsFloat | typing.SupportsIndex, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> float

Wrapper for Fortran routine low_energy_z_correction

Parameters:
  • orbit (CoordStruct) –

    Position before correction

  • ele (EleStruct) –

    Element being tracked through.

  • ds (float) –

    Longitudinal distance traveled by reference particle.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the multipole. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix including multipole.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • dz( float ) –

    Change in z.

mad_add_offsets_and_multipoles

Fortran source: bmad/modules/mad_mod.f90

mad_add_offsets_and_multipoles(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_add_offsets_and_multipoles (ele, map)

Subroutine to add in the effect of element offsets and/or multipoles on the 2nd order transport map for the element.

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_concat_map2

Fortran source: bmad/modules/mad_mod.f90

mad_concat_map2(map1: pybmad._pybmad.MadMapStruct, map2: pybmad._pybmad.MadMapStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_concat_map2 (map1, map2, map3)

Subroutine to concatinate two 2nd order transport maps. map3 = map2(map1) The equivalent MAD-8 routine is: TMCAT1

Parameters:
Returns:

mad_drift

Fortran source: bmad/modules/mad_mod.f90

mad_drift(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_drift (ele, energy, map)

Subroutine to make a transport map for a drift space. The equivalent MAD-8 routine is: TMDRF

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_elsep

Fortran source: bmad/modules/mad_mod.f90

mad_elsep(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_elsep (ele, energy, map)

Subroutine to make a transport map for an electric separator. The equivalent MAD-8 routine is: TMSEP

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_map_to_taylor

Fortran source: bmad/modules/mad_mod.f90

mad_map_to_taylor(map: pybmad._pybmad.MadMapStruct, energy: pybmad._pybmad.MadEnergyStruct, taylor: pybmad._pybmad.TaylorStructArray1D) -> None

Subroutine mad_map_to_taylor (map, energy, taylor)

Subroutine to convert a MAD order 2 map to a Bmad taylor map. The conversion will also convert between MAD's (t, dE) and Bmad's (beta*t, dP) coords.

Parameters:

mad_quadrupole

Fortran source: bmad/modules/mad_mod.f90

mad_quadrupole(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_quadrupole (ele, energy, map)

Subroutine to make a transport map for an quadrupole element. The equivalent MAD-8 routine is: TMSEXT

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_rfcavity

Fortran source: bmad/modules/mad_mod.f90

mad_rfcavity(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_rfcavity (ele, energy, map)

Subroutine to make a transport map for an rfcavity element. The equivalent MAD-8 routine is: TMRF

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_sbend

Fortran source: bmad/modules/mad_mod.f90

mad_sbend(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_sbend (ele, energy, map)

Subroutine to make a transport map for a sector bend element. The equivalent MAD-8 routine is: TMBEND

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_sbend_body

Fortran source: bmad/modules/mad_mod.f90

mad_sbend_body(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_sbend_body (ele, energy, map)

Subroutine to make a transport map for the body of a sector dipole. The equivalent MAD-8 routine is: TMSECT

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_sbend_fringe

Fortran source: bmad/modules/mad_mod.f90

mad_sbend_fringe(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct, into: bool) -> pybmad._pybmad.MadMapStruct

Subroutine mad_sbend_fringe (ele, energy, into, map)

Subroutine to make a transport map for the fringe field of a dipole. The equivalent MAD-8 routine is: TMFRNG

Parameters:
  • ele (EleStruct) –

    Solenoid element.

  • energy (MadEnergyStruct) –

    particle energy structure.

  • into (bool) –

    If True then map is for particle entering a dipole

Returns:

mad_sextupole

Fortran source: bmad/modules/mad_mod.f90

mad_sextupole(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_sextupole (ele, energy, map)

Subroutine to make a transport map for an sextupole. The equivalent MAD-8 routine is: TMSEXT

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_solenoid

Fortran source: bmad/modules/mad_mod.f90

mad_solenoid(ele: pybmad._pybmad.EleStruct, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine mad_solenoid (ele, energy, map)

Subroutine to make a transport map for an solenoid. The equivalent MAD-8 routine is: TMSEXT

Parameters:
Returns:
  • map( MadMapStruct ) –

    Structure holding the transfer map.

mad_tmfoc

Fortran source: bmad/modules/mad_mod.f90

mad_tmfoc(el: typing.SupportsFloat | typing.SupportsIndex, sk1: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.MadTmfoc

Subroutine mad_tmfoc (el, sk1, c, s, d, f)

Subroutine to compute the linear focussing functions. The equivalent MAD-8 routine is: TMFOC

Parameters:
  • el (float) –

    Length.

  • sk1 (float) –

    Quadrupole strength.

Returns:
  • c( float ) –

    Cosine-like function. c(k,l)

  • s( float ) –

    Sine-like function. s(k,l)

  • d( float ) –

    Dispersion function. d(k,l)

  • f( float ) –

    Integral of dispersion function. f(k,l)

mad_tmsymm

Fortran source: bmad/modules/mad_mod.f90

mad_tmsymm(te: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]], "FixedSize(6)"]) -> None

subroutine mad_tmsymm (te)

subroutine to symmertrize the 2nd order map t. The equivalent MAD-8 routine is: tmsymm

Parameters:
  • te (3D array of float (shape: 6,6,6)) –

    array to be symmertrized. This parameter is an input/output and is modified in-place. As an output, te: symmetrized array.

mad_tmtilt

Fortran source: bmad/modules/mad_mod.f90

mad_tmtilt(map: pybmad._pybmad.MadMapStruct, tilt: typing.SupportsFloat | typing.SupportsIndex) -> None

Subroutine mad_tmtilt (map, tilt)

Subroutine to apply a tilt to a transport map. The equivalent MAD-8 routine is: TMTILT

Parameters:
  • map (MadMapStruct) –

    Unrotated transport map. This parameter is an input/output and is modified in-place. As an output, map: Rotated transport map.

  • tilt (float) –

    Tilt

mad_track1

Fortran source: bmad/modules/mad_mod.f90

mad_track1(c0: pybmad._pybmad.CoordStruct, map: pybmad._pybmad.MadMapStruct) -> pybmad._pybmad.CoordStruct

Subroutine mad_track1 (c0, map, c1)

Subroutine to track through a 2nd order transfer map. The equivalent MAD-8 routine is: TMTRAK

Parameters:
Returns:

make_g2_mats

Fortran source: bmad/modules/bmad_routine_interface.f90

make_g2_mats(twiss: pybmad._pybmad.TwissStruct, g2_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]], "FixedSize(2)"], g2_inv_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]], "FixedSize(2)"]) -> None

Wrapper for Fortran routine make_g2_mats

Parameters:
  • twiss (TwissStruct) –

    Twiss parameters.

  • g2_mat (2D array of float (shape: 2,2)) –
  • g2_inv_mat (2D array of float (shape: 2,2)) –

make_g_mats

Fortran source: bmad/modules/bmad_routine_interface.f90

make_g_mats(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.MakeGMats

Wrapper for Fortran routine make_g_mats

Parameters:
Returns:
  • g_mat( 2D array of float (shape: 4,4) ) –

    Normal mode to betaless coords

  • g_inv_mat( 2D array of float (shape: 4,4) ) –

    The inverse of G_MAT

make_hvbp

Fortran source: bmad/modules/mode3_mod.f90

make_hvbp(N: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.MakeHvbp

Subroutine make_HVBP(N, B, V, H, Vbar, Hbar)

Parameterizes the eigen-decomposition of the 6x6 transfer matrix into HVBP as defined in: "From the beam-envelop matrix to synchrotron-radiation integrals" by Ohmi, Hirata, and Oide.

This routine takes N, which is usually made from make_N (also in this module), and decomposes it into H, V, B, and P.

N is defined by: M = N.U.Inverse[N] where U is block diagonal and the blocks are 2x2 rotation matrices. and it is decomposed by this subroutine as, N = H.V.B.P P has the same free parameters as B B "Twiss matrix" has 6 free parameters (Twiss alphas and betas) B blocks have the form / sqrt(beta) 0 \ \ -alpha/sqrt(beta) 1/sqrt(beta) / V "Teng matrix" has 4 free parameters (xy, xpy, ypx, and pxpy coupling) H "Dispersion matrix" has 8 free parameters (xz, xpz, pxz, pxpz, yz, ypz, pyz, pypz coupling)

Parameters:
  • N (2D array of float (shape: 6,6)) –

    Matrix of eigenvectors prepared by make_N

Returns:
  • B( 2D array of float (shape: 6,6) ) –

    Block diagonal matrix of Twiss parameters

  • V( 2D array of float (shape: 6,6) ) –

    horizontal-vertical coupling information

  • H( 2D array of float (shape: 6,6) ) –

    horizontal-longitudinal and vertical-longitudinal coupling information

  • Vbar( 2D array of float (shape: 6,6), optional ) –

    mat_symp_conj(B).V.B

  • Hbar( 2D array of float (shape: 6,6), optional ) –

    mat_symp_conj(B).H.B

make_hybrid_lat

Fortran source: bmad/modules/bmad_routine_interface.f90

make_hybrid_lat(lat_in: pybmad._pybmad.LatStruct, use_taylor: bool | None = None, orb0_arr: pybmad._pybmad.CoordArrayStructArray1D | None = None) -> pybmad._pybmad.LatStruct

Wrapper for Fortran routine make_hybrid_lat

Parameters:
  • lat_in (LatStruct) –

    Input lattice.

  • use_taylor (bool) –

    If present and True then the hybrid elements will have a taylor series instead of a simple linear matrix. If an element to be concatenated has a taylor series then this taylor series will be concatenated with the other elements in the hybrid element.

  • orb0_arr (1D array of CoordArrayStruct) –

    Central orbit for taylor stuff. Each orb0_arr(i).orbit(:) holds the orbit for the i^th lattice branch

Returns:
  • lat_out( LatStruct ) –

    Lattice with hybrid elements. Note: Lat_out must not be the same actual argument as lat_in.

make_mad_map

Fortran source: bmad/modules/mad_mod.f90

make_mad_map(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> pybmad._pybmad.MakeMadMap

Subroutine make_mad_map (ele, param, energy, map)

Subroutine to make a 2nd order transport map a la MAD.

Parameters:
Returns:

make_mat6

Fortran source: bmad/modules/bmad_routine_interface.f90

make_mat6(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, start_orb: pybmad._pybmad.CoordStruct | None = None) -> pybmad._pybmad.MakeMat6

Wrapper for Fortran routine make_mat6

Parameters:
  • ele (EleStruct) –

    Element holding the transfer matrix.

  • param (LatParamStruct) –

    Lattice global parameters.

  • start_orb (CoordStruct) –

    Reference coordinates at the beginning of element. If not present, default is to use the zero orbit.

Returns:
  • end_orb( (CoordStruct, optional) ) –

    Reference coordinates at the end of element.

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

make_mat6_bmad

Fortran source: bmad/modules/bmad_routine_interface.f90

make_mat6_bmad(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, start_orb: pybmad._pybmad.CoordStruct) -> pybmad._pybmad.MakeMat6Bmad

Wrapper for Fortran routine make_mat6_bmad

Parameters:
  • ele (EleStruct) –

    Element to track through. This parameter is an input/output and is modified in-place. As an output, ele: Element with transfer matrix.

  • param (LatParamStruct) –

    Parameters are needed for some elements.

  • start_orb (CoordStruct) –

    Starting coords.

Returns:
  • end_orb( CoordStruct ) –

    Coordinates at the end of element.

  • err( (bool, optional) ) –

    Set True if there is an error. False otherwise.

make_mat6_bmad_photon

Fortran source: bmad/modules/bmad_routine_interface.f90

make_mat6_bmad_photon(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, start_orb: pybmad._pybmad.CoordStruct) -> pybmad._pybmad.MakeMat6BmadPhoton

Wrapper for Fortran routine make_mat6_bmad_photon

Parameters:
  • ele (EleStruct) –

    Element with transfer matrix This parameter is an input/output and is modified in-place. As an output, ele: Element with transfer matrix.

  • param (LatParamStruct) –

    Parameters are needed for some elements.

  • start_orb (CoordStruct) –

    Coordinates at the beginning of element.

Returns:
  • end_orb( CoordStruct ) –

    Coordinates at the end of element.

  • err( (bool, optional) ) –

    Set True if there is an error. False otherwise.

make_mat6_high_energy_space_charge

Fortran source: bmad/space_charge/high_energy_space_charge_mod.f90

make_mat6_high_energy_space_charge(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> None

Subroutine make_mat6_high_energy_space_charge (ele, param)

Routine to add the ultra relativistic space charge kick to the element transfer matrix. The routine setup_space_charge_calc must be called initially before any tracking is done. This routine assumes a Gaussian bunch and is only valid with relativistic particles where the effect of the space charge is small.

Parameters:

make_mat6_mad

Fortran source: bmad/modules/mad_mod.f90

make_mat6_mad(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, c0: pybmad._pybmad.CoordStruct) -> pybmad._pybmad.CoordStruct

Subroutine make_mat6_mad (ele, param, c0, c1)

Subroutine to make the 6x6 transfer matrix for an element from the 2nd order MAD transport map. The map is stored in ele%taylor. If the map exists then it is simply used to calculate ele%mat6. If ele%taylor doesn't exist then calculate it.

Parameters:
Returns:
  • c1( CoordStruct ) –

    Coordinates at the end of element.

make_mat6_symp_lie_ptc

Fortran source: bmad/modules/bmad_routine_interface.f90

make_mat6_symp_lie_ptc(ele: pybmad._pybmad.EleStruct, start_orb: pybmad._pybmad.CoordStruct) -> pybmad._pybmad.CoordStruct

Wrapper for Fortran routine make_mat6_symp_lie_ptc

Parameters:
  • ele (EleStruct) –

    Element with transfer matrix This parameter is an input/output and is modified in-place. As an output, ele: Element with transfer matrix.

  • start_orb (CoordStruct) –

    Coordinates at the beginning of element.

Returns:
  • end_orb( CoordStruct ) –

    Coordinates at end of element.

make_mat6_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

make_mat6_taylor(ele: pybmad._pybmad.EleStruct, start_orb: pybmad._pybmad.CoordStruct, err_flag: bool | None = None) -> pybmad._pybmad.CoordStruct

Wrapper for Fortran routine make_mat6_taylor

Parameters:
  • ele (EleStruct) –

    Element to track through. This parameter is an input/output and is modified in-place. As an output, ele: Element with transfer matrix.

  • start_orb (CoordStruct) –

    Starting coords.

  • err_flag (bool) –
Returns:
  • end_orb( CoordStruct ) –

    Coordinates at the end of element.

make_mat6_tracking

Fortran source: bmad/modules/bmad_routine_interface.f90

make_mat6_tracking(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, start_orb: pybmad._pybmad.CoordStruct, spin_only: bool | None = None) -> pybmad._pybmad.MakeMat6Tracking

Wrapper for Fortran routine make_mat6_tracking

Parameters:
  • ele (EleStruct) –

    Element with transfer matrix This parameter is an input/output and is modified in-place. As an output, ele: Element with transfer matrix.

  • param (LatParamStruct) –

    Parameters are needed for some elements.

  • start_orb (CoordStruct) –

    Coordinates at the beginning of element.

  • spin_only (bool) –

    Default False. If True, only calculate ele.spin_taylor.

Returns:
  • end_orb( CoordStruct ) –

    Coordinates at the end of element.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

make_n

Fortran source: bmad/modules/mode3_mod.f90

make_n(t6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], abz_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None) -> pybmad._pybmad.MakeN

Subroutine make_N(t6, N, err_flag, abz_tunes, tunes_out, U)

Given a 1-turn transfer matrix, this returns the matrix N. N converts between normal invarients and phases and canonical coordinates: X = N.J

N is obtained from the Eigen decomposition of the 1-turn transfer matrix. It is obtained by applying certain normalizations to the matrix of Eigen vectors, then making the result real using Q.

If abz_tunes is present, then the eigensystem is ordered by matching the tunes. If abz_tunes is not present, then the eigensystem is ordered by plane dominance.

It is assumed that the synchrotron tune is less than pi.

Parameters:
  • t6 (2D array of float (shape: 6,6)) –

    1-turn transfer matrix

  • abz_tunes (1D array of float (shape: 3)) –

    a-mode is abz_tunes(1), b-mode is abz_tunes(2), synch tune is abz_tunes(3)

Returns:
  • N( 2D array of float (shape: 6,6) ) –

    X = N.J

  • err_flag( bool ) –

    Set to true on error. Often means Eigen decomposition failed.

  • tunes_out( 1D array of float (shape: 3), optional ) –

    Fractional tune (in radians) of the 3 normal modes of t6.

  • U( 2D array of float (shape: 6,6), optional ) –

    U = Inverse(N).t6.N. Block diagonal matrix of 2x2 rotation matrices.

make_pbrh

Fortran source: bmad/multiparticle/envelope_mod.f90

make_pbrh(M: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], abz_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> pybmad._pybmad.MakePbrh

subroutine make_PBRH(M, P, Bp, R, H, abz_tunes)

Decomposes the 1-turn transfer matrix into normal mode twiss-like parameters, according to Sec. IIIB of Ohmi, Hirata, and Oide paper.

Note: The Twiss parameters generated by this function are identical to those delivered by mode3_mod.

Parameters:
  • M (2D array of float (shape: 6,6)) –

    1-turn transfer matrix

  • abz_tunes (1D array of float (shape: 3)) –

    tunes for a,b, and c modes. Used to identify which eigenvector is associated with which mode.

Returns:
  • P( 2D array of complex (shape: 6,6) ) –

    Eqn. 97. Phase advances.

  • Bp( 2D array of complex (shape: 6,6) ) –

    Eqns. 89 & 101. Beta functions.

  • R( 2D array of complex (shape: 6,6) ) –

    Eqn. 99. Transverse coupling.

  • H( 2D array of complex (shape: 6,6) ) –

    Eqn. 100. Longitudinal coupling.

make_smat_from_abc

Fortran source: bmad/modules/mode3_mod.f90

make_smat_from_abc(t6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], mode: pybmad._pybmad.NormalModesStruct) -> pybmad._pybmad.MakeSmatFromAbc

Subroutine make_smat_from_abc(t6, mode, sigma_mat, err_flag, Nout)

Given the 1-turn transfer matrix and a normal_modes_struct containing the normal mode emittances, this routine returns the beam envelop sigma matrix.

sigma_mat = N.D.transpose(N) equivalent to: sigma_mat.S = N.D.mat_symp_conj(N)

One way to populate mode%a%tune and mode%b%tune: mode%a%tune = mod(lat%ele(lat%n_ele_track)%a%phi, twopi) mode%b%tune = mod(lat%ele(lat%n_ele_track)%b%phi, twopi)

Parameters:
  • t6 (2D array of float (shape: 6,6)) –

    1-turn transfer matrix

  • mode (NormalModesStruct) –

    normal mode emittances

Returns:
  • sigma_mat( 2D array of float (shape: 6,6) ) –

    beam envelop sigma matrix

  • err_flag( bool ) –

    set to true if something goes wrong. Usually means Eigen decomposition of the 1-turn matrix failed.

  • Nout( 2D array of float (shape: 6,6), optional ) –

    Contains the normalized eigenvectors that were used to make the sigma matrix.

make_unit_mad_map

Fortran source: bmad/modules/mad_mod.f90

make_unit_mad_map(map: pybmad._pybmad.MadMapStruct) -> None

Subroutine make_unit_mad_map (map)

Subroutine to initialize a 2nd order transport map to unity.

Parameters:
  • map (MadMapStruct) –

    2nd order transport map. This parameter is an input/output and is modified in-place. As an output, map: Unity 2nd order map.

make_v

Fortran source: bmad/multiparticle/envelope_mod.f90

make_v(M: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], V: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], abz_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> None

subroutine make_V(M,V,abz_tunes)

For a one-turn transfer matrix M, this routine find the eigen matrix V. V is ordered such that the per turn phase advance of its column pairs agree with abz_tunes. It is normalized to be symplectic.

make_v_mats

Fortran source: bmad/modules/bmad_routine_interface.f90

make_v_mats(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.MakeVMats

Wrapper for Fortran routine make_v_mats

Parameters:
Returns:
  • v_mat( 2D array of float (shape: 4,4), optional ) –

    Normal mode to X-Y coords transformation

  • v_inv_mat( 2D array of float (shape: 4,4), optional ) –

    X-Y coords to Normal mode transformation

makeup_control_slave

Fortran source: bmad/modules/bookkeeper_mod.f90

makeup_control_slave(lat: pybmad._pybmad.LatStruct, slave: pybmad._pybmad.EleStruct, err_flag: bool) -> None

Subroutine makeup_control_slave (lat, slave, err_flag)

This routine is not meant for general use.

makeup_group_lord

Fortran source: bmad/modules/bookkeeper_mod.f90

makeup_group_lord(lat: pybmad._pybmad.LatStruct, lord: pybmad._pybmad.EleStruct, err_flag: bool) -> None

Subroutine makeup_group_lord (lat, lord, err_flag)

Subroutine to calculate the attributes of group slave elements. This routine is private to bookkeeper_mod.

makeup_multipass_slave

Fortran source: bmad/modules/bookkeeper_mod.f90

makeup_multipass_slave(lat: pybmad._pybmad.LatStruct, slave: pybmad._pybmad.EleStruct, err_flag: bool) -> None

Subroutine makeup_multipass_slave (lat, slave, err_flag)

Subroutine to calcualte the attributes of multipass slave elements. This routine is not meant for guse.

makeup_super_slave

Fortran source: bmad/modules/bookkeeper_mod.f90

makeup_super_slave(lat: pybmad._pybmad.LatStruct, slave: pybmad._pybmad.EleStruct, err_flag: bool) -> None

Subroutine makeup_super_slave (lat, slave, err_flag)

Subroutine to calcualte the attributes of superposition slave elements. This routine is not meant for general use.

makeup_super_slave1

Fortran source: bmad/modules/bookkeeper_mod.f90

makeup_super_slave1(slave: pybmad._pybmad.EleStruct, lord: pybmad._pybmad.EleStruct, offset: typing.SupportsFloat | typing.SupportsIndex, param: pybmad._pybmad.LatParamStruct, include_upstream_end: bool, include_downstream_end: bool) -> bool

Subroutine makeup_super_slave1 (slave, lord, offset, param, include_upstream_end, include_downstream_end)

Routine to construct a super_slave from a super_lord when the slave has only one lord. Note: Reference energy and times are not computed in this routine.

Parameters:
  • slave (EleStruct) –

    Slave element. This parameter is an input/output and is modified in-place. As an output, slave: Slave element with appropriate values set.

  • lord (EleStruct) –

    Lord element.

  • offset (float) –

    offset of entrance end of slave from entrance end of the lord.

  • param (LatParamStruct) –

    lattice paramters.

  • include_upstream_end (bool) –

    Slave contains the lord's entrance end?

  • include_downstream_end (bool) –

    Slave contains the lord's exit end?

Returns:
  • err_flag( bool ) –

    Set true if there is an error. False otherwise.

map1_inverse

Fortran source: bmad/modules/bmad_routine_interface.f90

map1_inverse(map1: pybmad._pybmad.SpinOrbitMap1Struct) -> pybmad._pybmad.SpinOrbitMap1Struct

Wrapper for Fortran routine map1_inverse

Parameters:
Returns:

map1_make_unit

Fortran source: bmad/modules/bmad_routine_interface.f90

map1_make_unit() -> pybmad._pybmad.SpinOrbitMap1Struct

Wrapper for Fortran routine map1_make_unit

Returns:

map1_times_map1

Fortran source: bmad/modules/bmad_routine_interface.f90

map1_times_map1(map2: pybmad._pybmad.SpinOrbitMap1Struct, map1: pybmad._pybmad.SpinOrbitMap1Struct, map_out: pybmad._pybmad.SpinOrbitMap1Struct) -> None

Wrapper for Fortran routine map1_times_map1

Parameters:

map_to_angle_coords

Fortran source: bmad/modules/bmad_routine_interface.f90

map_to_angle_coords(t_canon: pybmad._pybmad.TaylorStructArray1D) -> pybmad._pybmad.TaylorStructArray1D

Wrapper for Fortran routine map_to_angle_coords

Parameters:
  • t_canon (1D array of TaylorStruct (shape: 6)) –

    Taylor map in canonical coords.

Returns:
  • t_angle( 1D array of TaylorStruct (shape: 6) ) –

    Taylor map in angle coords.

mark_patch_regions

Fortran source: bmad/modules/wall3d_mod.f90

mark_patch_regions(branch: pybmad._pybmad.BranchStruct) -> None

Subroutine mark_patch_regions (branch)

Routine to mark which regions in a wall3d structure contain patch elements. This routine should be called by any routine that creates a beam chamber wall.

Parameters:
  • branch (BranchStruct) –

    Lattice branch with .wall3d beam chamber wall. This parameter is an input/output and is modified in-place. As an output, branch: Lattice branch with .wall3d.section(i).patch_in_region marked.

master_parameter_value

Fortran source: bmad/modules/bmad_routine_interface.f90

master_parameter_value(master_parameter: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct) -> float

Wrapper for Fortran routine master_parameter_value

Parameters:
  • master_parameter (int) –

    Index of the master parameter.

  • ele (EleStruct) –

    Element containing the fieldmap.

Returns:
  • value( float ) –

    Value of the master parameter.

mat4_multipole

Fortran source: bmad/modules/bmad_routine_interface.f90

mat4_multipole(knl: typing.SupportsFloat | typing.SupportsIndex, tilt: typing.SupportsFloat | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(4)"]], "FixedSize(4)"]

Wrapper for Fortran routine mat4_multipole

Parameters:
  • knl (float) –

    Strength of multipole

  • tilt (float) –

    Tilt of multipole

  • n (int) –
  • orbit (CoordStruct) –

    coordinates of particle

Returns:
  • kick_mat( 2D array of float (shape: 4,4) ) –

    Kick matrix (Jacobian) at orbit.

mat6_add_offsets

Fortran source: bmad/modules/bmad_routine_interface.f90

mat6_add_offsets(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> None

Wrapper for Fortran routine mat6_add_offsets

Parameters:

mat6_add_pitch

Fortran source: bmad/modules/bmad_routine_interface.f90

mat6_add_pitch(x_pitch_tot: typing.SupportsFloat | typing.SupportsIndex, y_pitch_tot: typing.SupportsFloat | typing.SupportsIndex, orientation: typing.SupportsInt | typing.SupportsIndex, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> None

Wrapper for Fortran routine mat6_add_pitch

Parameters:
  • x_pitch_tot (float) –

    Horizontal pitch

  • y_pitch_tot (float) –

    Vertical pitch

  • orientation (int) –

    Element longitudinal orientation. +1 or -1.

  • mat6 (2D array of float (shape: 6,6)) –

    1st order part of the transfer map (Jacobian). This parameter is an input/output and is modified in-place. As an output, mat6: 1st order xfer map with pitches.

mat6_to_complex_taylor

Fortran source: bmad/modules/complex_taylor_mod.f90

mat6_to_complex_taylor(vec0: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.ComplexTaylorStructArray1D

Subroutine mat6_to_complex_taylor (vec0, mat6, complex_taylor)

Subroutine to form a first order complex_taylor map from the 6x6 transfer matrix and the 0th order transfer vector.

Parameters:
  • vec0 (1D array of complex (shape: 6)) –

    0th order transfer vector.

  • mat6 (2D array of complex (shape: 6,6)) –

    6x6 transfer matrix.

Returns:
  • complex_taylor( 1D array of ComplexTaylorStruct (shape: 6) ) –

    first order complex_taylor map.

mat_symp_decouple

Fortran source: bmad/modules/bmad_routine_interface.f90

mat_symp_decouple(t0: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]], "FixedSize(4)"], type_out: bool) -> pybmad._pybmad.MatSympDecouple

Wrapper for Fortran routine mat_symp_decouple

Parameters:
  • t0 (2D array of float (shape: 4,4)) –

    Input matrix

  • type_out (bool) –

    If .true. then an error message is typed out for a non ok$ STAT

Returns:
  • stat( int ) –

    status of results: ok\(, in_stop_band\), or unstable$

  • u( 2D array of float (shape: 4,4) ) –

    See MGB CBN 85-2 and PPB/DLR PAC89 papers for more info.

  • v( 2D array of float (shape: 4,4) ) –

    See MGB CBN 85-2 and PPB/DLR PAC89 papers for more info.

  • ubar( 2D array of float (shape: 4,4) ) –

    See MGB CBN 85-2 and PPB/DLR PAC89 papers for more info.

  • vbar( 2D array of float (shape: 4,4) ) –

    See MGB CBN 85-2 and PPB/DLR PAC89 papers for more info.

  • g( 2D array of float (shape: 4,4) ) –

    See MGB CBN 85-2 and PPB/DLR PAC89 papers for more info.

  • twiss1( TwissStruct ) –

    Twiss params for the "upper left" mode.

  • twiss2( TwissStruct ) –

    Twiss params for the "lower right" mode.

  • gamma( float ) –

    gamma_c factor.

match_ele_to_mat6

Fortran source: bmad/modules/bmad_routine_interface.f90

match_ele_to_mat6(ele: pybmad._pybmad.EleStruct, start_orb: pybmad._pybmad.CoordStruct, include_delta_time: bool | None = None, set_trombone: bool | None = None) -> pybmad._pybmad.MatchEleToMat6

Wrapper for Fortran routine match_ele_to_mat6

Parameters:
  • ele (EleStruct) –

    Match element.

  • start_orb (CoordStruct) –

    Starting orbit.

  • include_delta_time (bool) –

    If False, ignore any finite ele.value(delta_time$). Default is True.

  • set_trombone (bool) –

    Default is False. If True, set the beginning and ending Twiss values in the element to create a phase trombone.

Returns:
  • mat6( 2D array of float (shape: 6,6) ) –

    Transfer matrix (1st order part of xfer map).

  • vec0( 1D array of float (shape: 6) ) –

    0th order part of the transfer map.

  • err_flag( bool ) –

    Set true if there is an error. False otherwise. Note: Currently err_flag is never set True.

mexp

Fortran source: bmad/modules/bmad_routine_interface.f90

mexp(x: typing.SupportsFloat | typing.SupportsIndex, m: typing.SupportsInt | typing.SupportsIndex) -> float

Wrapper for Fortran routine mexp

Parameters:
  • x (float) –

    Number.

  • m (int) –

    Exponent.

Returns:
  • this_exp( float ) –

    Result.

mfft1

Fortran source: bmad/space_charge/fast_fourier_am.f90

mfft1(a: pybmad._pybmad.RealArray1D, b: pybmad._pybmad.RealArray1D, n: pybmad._pybmad.IntArray1D, ndim: typing.SupportsInt | typing.SupportsIndex, isn: typing.SupportsInt | typing.SupportsIndex) -> int

Wrapper for Fortran routine mfft1

Parameters:
  • a (1D array of float) –
  • b (1D array of float) –
  • n (1D array of int) –
  • ndim (int) –
  • isn (int) –
Returns:
  • ierr( int ) –

misalign_ptc_fibre

Fortran source: bmad/ptc/ptc_interface_mod.f90

misalign_ptc_fibre(ele: pybmad._pybmad.EleStruct, use_offsets: bool, for_layout: bool) -> pybmad._pybmad.Fibre | None

Subroutine misalign_ptc_fibre (ele, use_offsets, ptc_fibre, for_layout)

Routine to misalign a fibre associated with a Bmad element.

Parameters:
  • ele (EleStruct) –

    Bmad element with misalignments.

  • use_offsets (bool) –

    Does ptc_fibre include element offsets, pitches and tilt? This argument is ignored if the element is a patch.

  • for_layout (bool) –

    If True then fibre is being created as part of a layout as opposed to a stand-alone fibre

Returns:
  • ptc_fibre( (Fibre, optional) ) –

    PTC fibre element with misalignments.

momentum_compaction

Fortran source: bmad/modules/bmad_routine_interface.f90

momentum_compaction(branch: pybmad._pybmad.BranchStruct) -> float

Wrapper for Fortran routine momentum_compaction

Parameters:
Returns:
  • mom_comp( float ) –

    Momentum compaction.

multi_turn_tracking_analysis

Fortran source: bmad/modules/bmad_routine_interface.f90

multi_turn_tracking_analysis(track: pybmad._pybmad.CoordStructArray1D, i_dim: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.MultiTurnTrackingAnalysis

Wrapper for Fortran routine multi_turn_tracking_analysis

Parameters:
  • track (1D array of CoordStruct) –

    multi-turn tracking data to analyze. track(i) is the particle position at a given point in the lat on the i^th turn.

  • i_dim (int) –

    number of dimensions used in the tracking: 2, or 4.

Returns:
  • track0( CoordStruct ) –

    Closed orbit.

  • ele( EleStruct ) –

    structure holding the 1-turn matrix and Twiss parameters.

  • stable( bool ) –

    Is motion stable?

  • growth_rate( float ) –

    Unstable growth rate (= 0 if stable).

  • chi( float ) –

    How symplectic the computed 1-turn matrix is. See mat_symp_check for more details.

  • err_flag( bool ) –

    Set true if there is an error. False otherwise.

multilayer_type_to_multilayer_params

Fortran source: bmad/interface/xraylib_interface.f90

multilayer_type_to_multilayer_params(ele: pybmad._pybmad.EleStruct) -> bool

Subroutine multilayer_type_to_multilayer_params (ele, err_flag)

Routine to set the multilayer parameters based upon the multilayer type.

Multilayer types are of the form: "AAA:BBB" Where "AAA" is the atomic formula for the top layer crystal and "BBB" is the second layer atomic formula.

Parameters:
Returns:
  • err_flag( bool ) –

    Set True if multilayer type is unrecognized. False otherwise.

multipass_chain

Fortran source: bmad/modules/bmad_routine_interface.f90

multipass_chain(ele: pybmad._pybmad.EleStruct, use_super_lord: bool | None = None) -> pybmad._pybmad.MultipassChain

Wrapper for Fortran routine multipass_chain

Parameters:
  • ele (EleStruct) –

    Element in a multipass chain.

  • use_super_lord (bool) –

    If present and True and if ele is a super_slave, construct the chain_ele(:) array using the corresponding super_lords.

Returns:
  • ix_pass( int ) –

    Multipass pass number of the input element. Set to -1 if input element is not in a multipass section.

  • n_links( int ) –

    Number of times the physical element is passed through.

  • chain_ele( 1D array of ElePointerStruct, optional ) –

    pointers to the elements of the chain. Note: chain_ele(ix_pass).ele => ele

multipole1_ab_to_kt

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole1_ab_to_kt(an: typing.SupportsFloat | typing.SupportsIndex, bn: typing.SupportsFloat | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.Multipole1AbToKt

Wrapper for Fortran routine multipole1_ab_to_kt

Parameters:
  • an (float) –

    Skew multipole component.

  • bn (float) –

    Normal multipole component.

  • n (int) –

    Order of multipole.

Returns:
  • knl( float ) –

    Multitude magnatude.

  • tn( float ) –

    Multipole angle.

multipole1_kt_to_ab

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole1_kt_to_ab(knl: typing.SupportsFloat | typing.SupportsIndex, knsl: typing.SupportsFloat | typing.SupportsIndex, tn: typing.SupportsFloat | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.Multipole1KtToAb

Wrapper for Fortran routine multipole1_kt_to_ab

Parameters:
  • knl (float) –

    Normal multitude component.

  • knsl (float) –

    Skew multitude component.

  • tn (float) –

    Multipole angle.

  • n (int) –

    Multipole order.

Returns:
  • an( float ) –

    Skew multipole component.

  • bn( float ) –

    Normal multipole component.

multipole_ab_to_kt

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole_ab_to_kt(an: pybmad._pybmad.RealArray1D, bn: pybmad._pybmad.RealArray1D, knl: pybmad._pybmad.RealArray1D, tn: pybmad._pybmad.RealArray1D) -> None

Wrapper for Fortran routine multipole_ab_to_kt

Parameters:
  • an (1D array of float) –

    Skew multipole component.

  • bn (1D array of float) –

    Normal multipole component.

  • knl (1D array of float) –

    Multitude magnatude.

  • tn (1D array of float) –

    Multipole angle.

multipole_ele_to_ab

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole_ele_to_ab(ele: pybmad._pybmad.EleStruct, use_ele_tilt: bool, pole_type: typing.SupportsInt | typing.SupportsIndex | None = None, include_kicks: typing.SupportsInt | typing.SupportsIndex | None = None, original: bool | None = None) -> pybmad._pybmad.MultipoleEleToAb

Wrapper for Fortran routine multipole_ele_to_ab

Parameters:
  • ele (EleStruct) –

    Element.

  • use_ele_tilt (bool) –

    If True then include ele.value(tilt_tot\() in calculations. use_ele_tilt is ignored in the case of multipole\) elements.

  • pole_type (int) –

    Type of multipole. magnetic$ (default) or electric$.

  • include_kicks (int) –

    Ignored for for pole_type == electric$ for non-elseparator elements. Possibilities are:

  • original (bool) –

    Default is false. If True, no scaling is applied.

Returns:
  • ix_pole_max( int ) –

    Index of largest nonzero a(:) or b(:) pole. Set to -1 if all multipoles are zero. ix_pole_max is set independent of a nonzero b1 (if present).

  • a( 1D array of float (shape: 0:n_pole_maxx) ) –

    Array of multipole values.

  • b( 1D array of float (shape: 0:n_pole_maxx) ) –

    Array of multipole values.

  • b1( (float, optional) ) –

    If present, b1 is set to the value of the b(1) component of the b(:) array and b(1) is set to zero. Also ix_pole_max is ajusted as needed. This is used by routines that want to handle b(1) in a special way in tracking.

multipole_ele_to_kt

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole_ele_to_kt(ele: pybmad._pybmad.EleStruct, use_ele_tilt: bool, knl: pybmad._pybmad.RealArray1D, tilt: pybmad._pybmad.RealArray1D, pole_type: typing.SupportsInt | typing.SupportsIndex | None = None, include_kicks: typing.SupportsInt | typing.SupportsIndex | None = None) -> int

Wrapper for Fortran routine multipole_ele_to_kt

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • use_ele_tilt (bool) –

    If True then include ele.value(tilt_tot\() in calculations. use_ele_tilt is ignored in the case of multipole\) elements.

  • knl (1D array of float) –

    Vector of strengths, MAD units.

  • tilt (1D array of float) –

    Vector of tilts.

  • pole_type (int) –

    Type of multipole. magnetic$ (default) or electric$.

  • include_kicks (int) –

    Possibilities are:

Returns:
  • ix_pole_max( int ) –

    Index of largest nonzero pole.

multipole_init

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole_init(who: typing.SupportsInt | typing.SupportsIndex, zero: bool | None = None) -> pybmad._pybmad.EleStruct

Wrapper for Fortran routine multipole_init

Parameters:
  • who (int) –

    electric\(, magnetic\), or all$

  • zero (bool) –

    If present and True then zero the arrays even if they already exist when this routine is called. Default is False which means that if the arrays already exist then this routine will do nothing.

Returns:
  • ele( EleStruct ) –

    Element holding the multipoles.

multipole_kick

Fortran source: bmad/modules/multipole_mod.f90

multipole_kick(knl: typing.SupportsFloat | typing.SupportsIndex, tilt: typing.SupportsFloat | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex, ref_species: typing.SupportsInt | typing.SupportsIndex, ele_orientation: typing.SupportsInt | typing.SupportsIndex, coord: pybmad._pybmad.CoordStruct, pole_type: typing.SupportsInt | typing.SupportsIndex | None = None, ref_orb_offset: bool | None = None) -> None

Subroutine multipole_kick (knl, tilt, n, ref_species, ele_orientation, coord, pole_type, ref_orb_offset)

Subroutine to put in the kick due to a multipole. Note: The kick for an electric multipole does not include any energy change.

Parameters:
  • knl (float) –

    Multipole integrated strength.

  • tilt (float) –

    Multipole tilt.

  • n (int) –

    Multipole order.

  • ref_species (int) –

    Reference species.

  • ele_orientation (int) –

    Element orientation +1 = normal, -1 = reversed.

  • coord (CoordStruct) –

    Particle position and direction of travel.

  • pole_type (int) –

    Type of multipole. magnetic$ (default) or electric$.

  • ref_orb_offset (bool) –

    If True and n = 0 then use the MAD convention and model the multipole as a zero length bend with bending angle knl. Default is False.

multipole_kick_mat

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole_kick_mat(knl: pybmad._pybmad.RealArray1D, tilt: pybmad._pybmad.RealArray1D, ref_species: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, factor: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"]

Wrapper for Fortran routine multipole_kick_mat

Parameters:
  • knl (1D array of float) –

    Strength of multipoles

  • tilt (1D array of float) –

    Tilt of multipoles

  • ref_species (int) –

    Reference species.

  • ele (EleStruct) –

    Lattice element containing multipoles.

  • orbit (CoordStruct) –

    coordinates of particle around which the multipole kick matrix is computed.

  • factor (float) –

    Factor to scale knl by.

Returns:
  • mat6( 2D array of float (shape: 6,6) ) –

    matrix with kick values at mat6(2:4:2, 1:3:2). The rest of the matrix is untouched.

multipole_kicks

Fortran source: bmad/modules/multipole_mod.f90

multipole_kicks(knl: pybmad._pybmad.RealArray1D, tilt: pybmad._pybmad.RealArray1D, ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, pole_type: typing.SupportsInt | typing.SupportsIndex | None = None, ref_orb_offset: bool | None = None) -> None

Subroutine multipole_kicks (knl, tilt, ele, orbit, pole_type, ref_orb_offset)

Subroutine to put in the kick due to a multipole element. Also see the ab_multipole_kicks routine.

Parameters:
  • knl (1D array of float) –

    Multipole strengths.

  • tilt (1D array of float) –

    Multipole tilts.

  • ele (EleStruct) –

    Lattice element containing the multipoles.

  • orbit (CoordStruct) –

    Particle position. This parameter is an input/output and is modified in-place. As an output, orbit: Kicked particle.

  • pole_type (int) –

    Type of multipole. magnetic$ (default) or electric$.

  • ref_orb_offset (bool) –

    If present and n = 0 then the multipole simulates a zero length bend with bending angle knl.

multipole_kt_to_ab

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole_kt_to_ab(knl: pybmad._pybmad.RealArray1D, knsl: pybmad._pybmad.RealArray1D, tn: pybmad._pybmad.RealArray1D, an: pybmad._pybmad.RealArray1D, bn: pybmad._pybmad.RealArray1D) -> None

Wrapper for Fortran routine multipole_kt_to_ab

Parameters:
  • knl (1D array of float) –

    Normal multitude component.

  • knsl (1D array of float) –

    Skew multitude component.

  • tn (1D array of float) –

    Multipole angle.

  • an (1D array of float) –

    Skew multipole component.

  • bn (1D array of float) –

    Normal multipole component.

multipole_spin_tracking

Fortran source: bmad/modules/bmad_routine_interface.f90

multipole_spin_tracking(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Wrapper for Fortran routine multipole_spin_tracking

Parameters:

mytan

Fortran source: bmad/modules/mode3_mod.f90

mytan(y: typing.SupportsFloat | typing.SupportsIndex, x: typing.SupportsFloat | typing.SupportsIndex, arg: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine mytan

Parameters:
  • y (float) –
  • x (float) –
  • arg (float) –

n_attrib_string_max_len

Fortran source: bmad/modules/attribute_mod.f90

n_attrib_string_max_len() -> int

Function n_attrib_string_max_len () result (max_len)

Routine to return the the maximum number of characters in any attribute name known to bmad.

Returns:
  • max_len( int ) –

    Maximum number of characters in any attribute name.

new_control

Fortran source: bmad/modules/bmad_routine_interface.f90

new_control(lat: pybmad._pybmad.LatStruct, ele_name: str | None = None) -> int

Wrapper for Fortran routine new_control

Parameters:
  • lat (LatStruct) –

    Lat used

  • ele_name (str) –

    Name of the new element.

Returns:
  • ix_ele( int ) –

    Index of the new control element

nint_chk

Fortran source: bmad/parsing/bmad_parser_mod.f90

nint_chk(re_val: typing.SupportsFloat | typing.SupportsIndex) -> int

Function nint_chk (re_val) result (int_val)

Returns the nearest integer to re_val. Also does out-of-bounds error checking. Used with bmad parsing.

Parameters:
  • re_val (float) –

    Input real number.

Returns:
  • int_val( int ) –

    Output nearest integer.

normal_form_complex_taylors

Fortran source: bmad/ptc/ptc_layout_mod.f90

normal_form_complex_taylors(one_turn_taylor: pybmad._pybmad.TaylorStructArray1D, rf_on: bool, F: pybmad._pybmad.ComplexTaylorStructArray1D | None = None, L: pybmad._pybmad.ComplexTaylorStructArray1D | None = None, A: pybmad._pybmad.TaylorStructArray1D | None = None, A_inverse: pybmad._pybmad.TaylorStructArray1D | None = None, order: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine normal_form_complex_taylors

Parameters:
  • one_turn_taylor (1D array of TaylorStruct (shape: 6)) –
  • rf_on (bool) –
  • F (1D array of ComplexTaylorStruct (shape: 6)) –
  • L (1D array of ComplexTaylorStruct (shape: 6)) –
  • A (1D array of TaylorStruct (shape: 6)) –
  • A_inverse (1D array of TaylorStruct (shape: 6)) –
  • order (int) –

normal_form_taylors

Fortran source: bmad/ptc/ptc_layout_mod.f90

normal_form_taylors(one_turn_taylor: pybmad._pybmad.TaylorStructArray1D, rf_on: bool) -> pybmad._pybmad.NormalFormTaylors

Subroutine normal_form_taylors(one_turn_taylor, rf_on, dhdj, A, A_inverse)

Do a normal form decomposition on a one-turn taylor map M: M = A o R o A_inverse where A maps Floquet (fully normalized) coordinates to lab coordinates. In Floquet coordinates, the amplitudes are defined as J_i = (1/2) (x_i^2 + p_i^2). The map R = exp(:h:) is a pure rotation with h = h(J) is a function of the amplitudes only. The angles (phase advances) are given by phi_i = 2pi*dh/dJ_i. The taylor terms of dhdj are therefore the tunes, chromaticities, amplitude dependent tune shifts, etc.

The mapping procedure for one turn is: z_Floquet_in = A_inverse o z_Lab_in [phi_a, phi_b, phi_c] = 2 pi * dhdj o z_Floquet_in z_Floquet_out = RotationMatrix(phi_a, phi_b, phi_c) . z_Floquet_in z_Lab_out = A o z_Floquet_out

Parameters:
  • one_turn_taylor (1D array of TaylorStruct (shape: 6)) –

    one turn taylor map

  • rf_on (bool) –

    Was the map calculated with RF on?

Returns:
  • dhdj( 1D array of TaylorStruct (shape: 6), optional ) –

    Map from Floquet coordinates to phase advances

  • A( 1D array of TaylorStruct (shape: 6), optional ) –

    Map from Floquet coordinates to Lab coordinates

  • A_inverse( 1D array of TaylorStruct (shape: 6), optional ) –

    Map from Lab coordinates to Floquet coordinates

normal_mode3_calc

Fortran source: bmad/modules/mode3_mod.f90

normal_mode3_calc(t6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], above_transition: bool | None = None, abz_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None) -> pybmad._pybmad.NormalMode3Calc

Subroutine normal_mode3_calc (mat, tune, B, HV, above_transition)

Does an Eigen decomposition of the 1-turn transfer matrix (mat) and generates B, V, H.

If the above_transition argument is present and false, then the 3rd (z) mode is assumed to have a positive slip factor (z-mode rotates counter clockwise in phase space). Default is True ==> z-mode has a negative slip factor so the mode rotates clock-wise in phase space.

Parameters:
  • above_transition (bool) –

    If present and false, then z-mode assumes positive slip factor. Else negative slip factor assumed.

  • abz_tunes (1D array of float (shape: 3)) –

    Tunes to order eigensystem by.

Returns:
  • tune( 1D array of float (shape: 3) ) –

    Tunes of the 3 normal modes (radians)

  • B( 2D array of float (shape: 6,6) ) –

    B is block diagonal and related to the normal mode Twiss parameters.

  • HV( 2D array of float (shape: 6,6) ) –

    Transforms from normal mode coordinates to canonical coordinates: x = H.V.a

normal_mode_dispersion

Fortran source: bmad/modules/bmad_routine_interface.f90

normal_mode_dispersion(ele: pybmad._pybmad.EleStruct, reverse: bool | None = None) -> None

Wrapper for Fortran routine normal_mode_dispersion

Parameters:
  • ele (EleStruct) –

    Element whose dispersions are to be adjusted. This parameter is an input/output and is modified in-place. As an output, ele: Element with adjusted dispersions.

  • reverse (bool) –

    Default is False. If True, calculate the x,y dispersions from the normal mode ones.

normalize_evecs

Fortran source: bmad/modules/mode3_mod.f90

normalize_evecs(evec: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> bool

Subroutine normalize_evecs(evec, err_flag)

Normalizes eigenvectors such that transpose(E).S.E = iS, where E = evec_r + i evec_i

Parameters:
  • evec (2D array of complex (shape: 6,6)) –

    complex eigenvectors arranged down columns. This parameter is an input/output and is modified in-place. As an output, evec: Eigensystem normalized to be symplectic.

Returns:
  • err_flag( bool ) –

    Set true of normalization is not possible due to amplitude is zero.

num_field_eles

Fortran source: bmad/modules/bmad_routine_interface.f90

num_field_eles(ele: pybmad._pybmad.EleStruct) -> int

Wrapper for Fortran routine num_field_eles

Parameters:
  • ele (EleStruct) –

    Element with sum number of associated field elements.

Returns:
  • n_field_ele( int ) –

    Number of associated field elements.

num_lords

Fortran source: bmad/modules/bmad_routine_interface.f90

num_lords(slave: pybmad._pybmad.EleStruct, lord_type: typing.SupportsInt | typing.SupportsIndex) -> int

Wrapper for Fortran routine num_lords

Parameters:
  • slave (EleStruct) –

    Slave element.

  • lord_type (int) –

    Type of lord. super_lord\(, multipass_lord\), girder_lord\(, group_lord\), overlay_lord\(, and governor\) (= group + overlay + control + girder)

Returns:
  • num( int ) –

    Number of lords of the given type.

odeint_bmad

Fortran source: bmad/modules/runge_kutta_mod.f90

odeint_bmad(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, s1_body: typing.SupportsFloat | typing.SupportsIndex, s2_body: typing.SupportsFloat | typing.SupportsIndex, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> pybmad._pybmad.OdeintBmad

Subroutine odeint_bmad (orbit, ele, param, s1_body, s2_body, err_flag, track, mat6, make_matrix)

Subroutine to do Runge Kutta tracking. This routine is adapted from Numerical Recipes. See the NR book for more details.

Notice that this routine has an two tolerances: bmad_com%rel_tol_adaptive_tracking bmad_com%abs_tol_adaptive_tracking

Note: For elements where the reference energy is not constant (lcavity, etc.), and with elements where the reference particle does not follow the reference trajectory (wigglers for example), the calculation of z is "off" while the particle is inside the element. At the ends there is no problem.

Parameters:
  • orbit (CoordStruct) –

    Starting coords: (x, px, y, py, z, delta) in element body coords. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coords

  • ele (EleStruct) –

    Element to track through.

  • param (LatParamStruct) –

    Lattice parameters.

  • s1_body (float) –

    Starting point relative to physical entrance.

  • s2_body (float) –

    Ending point relative physical entrance.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix propagated through the element.

  • make_matrix (bool) –

    If True then make the 6x6 transfer matrix.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise. Note: a particle getting lost, for example hitting an aperture, is not an error.

  • track( (TrackStruct, optional) ) –

    Structure holding the track information.

odeint_bmad_time

Fortran source: bmad/modules/time_tracker_mod.f90

odeint_bmad_time(orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, t_dir: typing.SupportsInt | typing.SupportsIndex, rf_time: typing.SupportsFloat | typing.SupportsIndex, track: pybmad._pybmad.TrackStruct | None = None, t_end: typing.SupportsFloat | typing.SupportsIndex | None = None, extra_field: pybmad._pybmad.EmFieldStruct | None = None) -> pybmad._pybmad.OdeintBmadTime

Subroutine odeint_bmad_time (orb, ele, param, t_dir, rf_time, err_flag, track, t_end, dt_step, extra_field)

Subroutine to do Runge Kutta tracking in time. This routine is adapted from Numerical Recipes. See the NR book for more details.

Tracking is done until the particle is lost or exits the element.

Parameters:
  • orb (CoordStruct) –

    Starting coords: (x, px, y, py, s, ps) [t-based] This parameter is an input/output and is modified in-place. As an output, orb: Ending coords

  • ele (EleStruct) –

    Element to track through.

  • param (LatParamStruct) –

    Beam parameters.

  • t_dir (int) –

    Direction of time travel = +/-1. Can be negative for patches. Will be -1 if element has a negative length.

  • rf_time (float) –

    Time relative to RF clock. This parameter is an input/output and is modified in-place. As an output, rf_time: Updated time.

  • track (TrackStruct) –

    Structure holding the track information.

  • t_end (float) –

    If present, maximum time to which the particle will be tracked. Used for tracking with given time steps. The time orb.t at which tracking stops may be less than this if the particle gets to the end of the element

  • extra_field (EmFieldStruct) –

    Static field to be added to the element field. Eg used with space charge.

Returns:
  • rf_time( float ) –

    Time relative to RF clock. This parameter is an input/output and is modified in-place. As an output, rf_time: Updated time.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

  • dt_step( (float, optional) ) –

    Next RK time step that this tracker would take based on the error tolerance. Used by track_bunch_time.

offset_particle

Fortran source: bmad/modules/bmad_routine_interface.f90

offset_particle(ele: pybmad._pybmad.EleStruct, set: bool, orbit: pybmad._pybmad.CoordStruct, set_tilt: bool | None = None, set_hvkicks: bool | None = None, drift_to_edge: typing.SupportsInt | typing.SupportsIndex | None = None, s_pos: typing.SupportsFloat | typing.SupportsIndex | None = None, set_spin: bool | None = None, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None, time: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.OffsetParticle

Wrapper for Fortran routine offset_particle

Parameters:
  • ele (EleStruct) –

    Element

  • set (bool) –

    T (= set\() -> Translate from lab coords to the local element coords. F (= unset\)) -> Translate back from element to lab coords.

  • orbit (CoordStruct) –

    Coordinates of the particle. This parameter is an input/output and is modified in-place. As an output, orbit: Coordinates of particle.

  • set_tilt (bool) –

    Default is True. T -> Rotate using ele.value(tilt\() and ele.value(roll\)) for sbends. F -> Do not rotate

  • set_hvkicks (bool) –

    Default is True. T -> Apply 1/2 any hkick or vkick.

  • drift_to_edge (int) –

    no$ -> Do not propagate (drift) particle. no$ is default if s_pos is present. upstream_end$ -> Propagate to upsteam edge. This is default if set = set$ and s_pos is not present. downstream_end$ -> Propagate to downsteam edge. This is default if set = unset$ and s_pos is not present. Note: "edge" is body edge if set = set$ and is laboratory (nominal non-misaligned) edge if set = unset$

  • s_pos (float) –

    Longitudinal particle position: If set = set\(: Relative to upstream end (in lab coords). If set = unset\): Relative to entrance end (in body coords).

  • set_spin (bool) –

    Default if False. Rotate spin coordinates? Also bmad_com.spin_tracking_on must be T to rotate.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before off setting. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix after offsets applied.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

  • time (float) –

    Particle time before drifting. Typically this is an RF clock time which may not be equal to orb.t This parameter is an input/output and is modified in-place. As an output, time: Updated time.

Returns:
  • s_out( (float, optional) ) –

    Longitudinal particle position. If set = set\(: Relative to entrance end (in body coords). If set = unset\): Relative to upstream end (in lab coords).

  • spin_qrot( 1D array of float (shape: 0:3), optional ) –

    Spin rotation quaternion

  • time( (float, optional) ) –

    Particle time before drifting. Typically this is an RF clock time which may not be equal to orb.t This parameter is an input/output and is modified in-place. As an output, time: Updated time.

offset_photon

Fortran source: bmad/modules/bmad_routine_interface.f90

offset_photon(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, set: bool, offset_position_only: bool | None = None, rot_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"] | None = None) -> None

Wrapper for Fortran routine offset_photon

Parameters:
  • ele (EleStruct) –

    Element

  • orbit (CoordStruct) –

    Coordinates of the particle. This parameter is an input/output and is modified in-place. As an output, orbit: Coordinates of particle.

  • set (bool) –

    T (= set\() -> Translate from lab coords to element coords. F (= unset\)) -> Translate from element coords to lab coords.

  • offset_position_only (bool) –

    If present and True, only offset the position coordinates.

  • rot_mat (2D array of float (shape: 3,3)) –

    Rotation matrix from starting coords to ending coords.

one_turn_mat_at_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

one_turn_mat_at_ele(ele: pybmad._pybmad.EleStruct, phi_a: typing.SupportsFloat | typing.SupportsIndex, phi_b: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(4)"]], "FixedSize(4)"]

Wrapper for Fortran routine one_turn_mat_at_ele

Parameters:
  • ele (EleStruct) –

    Reference element.

  • phi_a (float) –

    "a" mode tune in radians.

  • phi_b (float) –

    "b" mode tune in radians.

Returns:
  • mat4( 2D array of float (shape: 4,4) ) –

    1-Turn coupled matrix.

open_binary_file

Fortran source: bmad/parsing/binary_parser_mod.f90

open_binary_file(file_name: str, action: str, r_name: str) -> pybmad._pybmad.OpenBinaryFile

Function open_binary_file (file_name, action, iu, r_name, iver) result (is_ok)

Routine to open a binary file for reading or writing.

Parameters:
  • file_name (str) –

    File to create.

  • action (str) –

    'READ' or 'WRITE'

  • r_name (str) –

    Calling routine name for error messages.

Returns:
  • iu( int ) –

    Unit number of opened file.

  • iver( int ) –

    Version number if action = 'READ'

  • is_ok( bool ) –

    Open OK?

orbit_amplitude_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

orbit_amplitude_calc(ele: pybmad._pybmad.EleStruct, orb: pybmad._pybmad.CoordStruct) -> pybmad._pybmad.OrbitAmplitudeCalc

Wrapper for Fortran routine orbit_amplitude_calc

Parameters:
  • ele (EleStruct) –

    Element holding the Twiss parameters, dispersion and coupling info.

  • orb (CoordStruct) –

    Orbit coordinates at the exit end of ele.

Returns:
  • amp_a( (float, optional) ) –

    a-mode amplitude

  • amp_b( (float, optional) ) –

    b-mode amplitude

  • amp_na( (float, optional) ) –

    a-mode, energy normalized, amplitude.

  • amp_nb( (float, optional) ) –

    b-mode, energy normalized, amplitude.

orbit_reference_energy_correction

Fortran source: bmad/modules/bmad_routine_interface.f90

orbit_reference_energy_correction(orbit: pybmad._pybmad.CoordStruct, p0c_new: typing.SupportsFloat | typing.SupportsIndex, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine orbit_reference_energy_correction

Parameters:
  • orbit (CoordStruct) –

    Coordinates to correct.

  • p0c_new (float) –

    New reference momentum.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before correction. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix including correction.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

orbit_to_floor_phase_space

Fortran source: bmad/modules/bmad_routine_interface.f90

orbit_to_floor_phase_space(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> typing.Annotated[list[float], "FixedSize(6)"]

Wrapper for Fortran routine orbit_to_floor_phase_space

Parameters:
  • orbit (CoordStruct) –

    Particle orbit in local (not element) coordinates.

  • ele (EleStruct) –

    Lattice element particle is in.

Returns:
  • floor_phase_space( 1D array of float (shape: 6) ) –

    Floor phase space

orbit_to_local_curvilinear

Fortran source: bmad/modules/bmad_routine_interface.f90

orbit_to_local_curvilinear(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, z_direction: typing.SupportsInt | typing.SupportsIndex | None = None, relative_to: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.FloorPositionStruct

Wrapper for Fortran routine orbit_to_local_curvilinear

Parameters:
  • orbit (CoordStruct) –

    Particle orbit in laboratory (not body) coordinates.

  • ele (EleStruct) –

    Lattice element particle is in.

  • z_direction (int) –

    Set to +1 or -1. Z-direction of particle velocity relative to element z-axis. Default is ele.orientation * orbit.direction.

  • relative_to (int) –

    not_set$ (default), upstream_end\(, downstream_end\). If not_set$ then origin is at the entrance end.

Returns:

orbit_too_large

Fortran source: bmad/modules/bmad_routine_interface.f90

orbit_too_large(orbit: pybmad._pybmad.CoordStruct, check_momentum: bool | None = None) -> pybmad._pybmad.OrbitTooLarge

Wrapper for Fortran routine orbit_too_large

Parameters:
  • orbit (CoordStruct) –

    Particle orbit.

  • check_momentum (bool) –

    If True (default) check the momentum.

Returns:
  • is_too_large( bool ) –

    True if orbit is too large. False otherwise.

  • param( (LatParamStruct, optional) ) –

order_evecs_by_n_similarity

Fortran source: bmad/modules/mode3_mod.f90

order_evecs_by_n_similarity(eval: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], mat_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], Nmat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.OrderEvecsByNSimilarity

Subroutine order_evecs_by_N_similarity(evec, eval, mat_tunes, Nmat, err_flag)

This subroutine orderes the eigensystem such that Nmat.mat_symp_conj(N) is closest to the identity. Nmat is supplied externally.

Parameters:
  • eval (1D array of complex (shape: 6)) –

    complex eigenvalues.

  • mat_tunes (1D array of float (shape: 3)) –

    Three normal mode tunes, in radians. This parameter is an input/output and is modified in-place. As an output, mat_tunes: Ordered normal mode tunes, in radians.

  • Nmat (2D array of float (shape: 6,6)) –

    Normalized, real eigen matrix from make_N.

Returns:
  • evec( 2D array of complex (shape: 6,6) ) –

    complex eigenvectors arranged down columns.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise

order_evecs_by_plane_dominance

Fortran source: bmad/modules/mode3_mod.f90

order_evecs_by_plane_dominance(evec: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], eval: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], mat_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None) -> None

Subroutine order_evecs_by_plane_dominance(evec, eval, mat_tunes)

This subroutine orderes the eigensystem according to which modes dominate the horizontal, vertical, and longitudinal planes. This subroutine works well in machines that are not strongly coupled. In machines with strong coupling, where the relation between the three eigenmodes a, b, c and the three lab coordinates x, y, z can change through the machine, this subroutine will not provide consistent ordering.

Parameters:
  • evec (2D array of complex (shape: 6,6)) –

    complex eigenvectors arranged down columns. This parameter is an input/output and is modified in-place. As an output, evec: Ordered complex eigenvectors.

  • eval (1D array of complex (shape: 6)) –

    complex eigenvalues. This parameter is an input/output and is modified in-place. As an output, eval: Ordered complex eigenvalues.

  • mat_tunes (1D array of float (shape: 3)) –

    Three normal mode tunes, in radians. This parameter is an input/output and is modified in-place. As an output, mat_tunes: Reordered same as evecs.

order_evecs_by_tune

Fortran source: bmad/modules/mode3_mod.f90

order_evecs_by_tune(evec: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], eval: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], mat_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], abz_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> bool

Subroutine order_evecs_by_tune(evec, eval, mat_tunes, abz_tunes, err_flag)

This subroutine orders the eigensystem by matching the tunes of the eigensystem to externally supplied tunes abz_tunes. abz_tunes is in radians.

Parameters:
  • evec (2D array of complex (shape: 6,6)) –

    complex eigenvectors arranged down columns. This parameter is an input/output and is modified in-place. As an output, evec: Ordered eigenvectors.

  • eval (1D array of complex (shape: 6)) –

    complex eigenvalues. This parameter is an input/output and is modified in-place. As an output, eval: Ordered eigenvalues.

  • mat_tunes (1D array of float (shape: 3)) –

    Three normal mode tunes, in radians.

  • abz_tunes (1D array of float (shape: 3)) –

    Tunes to order eigensystem by.

Returns:
  • err_flag( bool ) –

    Set to true if an error occured.

order_particles_in_z

Fortran source: bmad/multiparticle/wake_mod.f90

order_particles_in_z(bunch: pybmad._pybmad.BunchStruct) -> None

Subroutine order_particles_in_z (bunch)

Routine to order the particles longitudinally in terms of decreasing %vec(5). That is from large z (head of bunch) to small z. Only live particles are ordered.

Parameters:

order_super_lord_slaves

Fortran source: bmad/modules/bmad_routine_interface.f90

order_super_lord_slaves(lat: pybmad._pybmad.LatStruct, ix_lord: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine order_super_lord_slaves

Parameters:
  • lat (LatStruct) –

    Lat. This parameter is an input/output and is modified in-place. As an output, lat: Lat with fixed controls.

  • ix_lord (int) –

    Index of lord element.

osc_alloc_freespace_array

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

osc_alloc_freespace_array(nlo: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], nhi: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], npad: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"]) -> None

Wrapper for Fortran routine osc_alloc_freespace_array

Parameters:
  • nlo (1D array of int (shape: 3)) –
  • nhi (1D array of int (shape: 3)) –
  • npad (1D array of int (shape: 3)) –

osc_alloc_image_array

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

osc_alloc_image_array(nlo: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], nhi: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], npad: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"]) -> None

Wrapper for Fortran routine osc_alloc_image_array

Parameters:
  • nlo (1D array of int (shape: 3)) –
  • nhi (1D array of int (shape: 3)) –
  • npad (1D array of int (shape: 3)) –

osc_alloc_rectpipe_arrays

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

osc_alloc_rectpipe_arrays(nlo: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], nhi: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], npad: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"]) -> None

Wrapper for Fortran routine osc_alloc_rectpipe_arrays

Parameters:
  • nlo (1D array of int (shape: 3)) –
  • nhi (1D array of int (shape: 3)) –
  • npad (1D array of int (shape: 3)) –

osc_getgrnpipe

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

osc_getgrnpipe(gam: typing.SupportsFloat | typing.SupportsIndex, a: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, delta: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], umin: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], npad: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"]) -> None

Wrapper for Fortran routine osc_getgrnpipe

Parameters:
  • gam (float) –
  • a (float) –
  • b (float) –
  • delta (1D array of float (shape: 3)) –
  • umin (1D array of float (shape: 3)) –
  • npad (1D array of int (shape: 3)) –

osc_read_rectpipe_grn

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

osc_read_rectpipe_grn() -> None

Wrapper for Fortran routine osc_read_rectpipe_grn

osc_write_rectpipe_grn

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

osc_write_rectpipe_grn(apipe: typing.SupportsFloat | typing.SupportsIndex, bpipe: typing.SupportsFloat | typing.SupportsIndex, delta: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], umin: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], umax: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], nlo: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], nhi: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"], gamma: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine osc_write_rectpipe_grn

Parameters:
  • apipe (float) –
  • bpipe (float) –
  • delta (1D array of float (shape: 3)) –
  • umin (1D array of float (shape: 3)) –
  • umax (1D array of float (shape: 3)) –
  • nlo (1D array of int (shape: 3)) –
  • nhi (1D array of int (shape: 3)) –
  • gamma (float) –

parse_cartesian_map

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_cartesian_map(ct_map: pybmad._pybmad.CartesianMapStruct, ele: pybmad._pybmad.EleStruct, lat: pybmad._pybmad.LatStruct, delim: str, delim_found: bool, err_flag: bool) -> None

Subroutine parse_cartesian_map (ct_map, ele, lat, delim, delim_found, err_flag)

Subroutine to parse a "cartesian_map = {}" construct

This subroutine is used by bmad_parser and bmad_parser2. This subroutine is private to bmad_parser_mod. This must read in: {type = , dr = , r0 = , pt(i,j,k) = ( (ex_re, ex_im), .... (bz_re, bz_im) ) . . . ) },

parse_cylindrical_map

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_cylindrical_map(cl_map: pybmad._pybmad.CylindricalMapStruct, ele: pybmad._pybmad.EleStruct, lat: pybmad._pybmad.LatStruct, delim: str, delim_found: bool, err_flag: bool) -> None

Wrapper for Fortran routine parse_cylindrical_map

Parameters:

parse_gen_grad_map

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_gen_grad_map(gg_map: pybmad._pybmad.GenGradMapStruct, ele: pybmad._pybmad.EleStruct, lat: pybmad._pybmad.LatStruct, delim: str, delim_found: bool, err_flag: bool) -> None

Subroutine parse_gen_grad_map (gg_map, ele, lat, delim, delim_found, err_flag)

Subroutine to parse a "gen_grad_map = {}" construct

parse_grid_field

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_grid_field(g_field: pybmad._pybmad.GridFieldStruct, ele: pybmad._pybmad.EleStruct, lat: pybmad._pybmad.LatStruct, delim: str, delim_found: bool, err_flag: bool) -> None

Wrapper for Fortran routine parse_grid_field

Parameters:

parse_integer_list

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_integer_list(err_str: str, lat: pybmad._pybmad.LatStruct, int_array: pybmad._pybmad.IntArray1D, exact_size: bool, delim: str, delim_found: bool, is_ok: bool, open_delim: str | None = None, separator: str | None = None, close_delim: str | None = None, default_value: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Function parse_integer_list (err_str, lat, int_array, exact_size, delim, delim_found, open_delim, separator, close_delim, default_value) result (is_ok)

Routine to parse a list of integers of the form: open_delim integer_1 separator integer_2 . . . close_delim Example: "(1.2, 2.3, 4.4, 8.5)"

Similar to parse_integer_list2 except does not use allocatable array. See parse_integer_list2 for more details

parse_integer_list2

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_integer_list2(err_str: str, lat: pybmad._pybmad.LatStruct, int_array: pybmad._pybmad.IntAlloc1D, num_expected: typing.SupportsInt | typing.SupportsIndex | None = None, open_delim: str | None = None, separator: str | None = None, close_delim: str | None = None, default_value: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.ParseIntegerList2

Function parse_integer_list2 (err_str, lat, int_array, num_found, delim, delim_found, num_expected, open_delim, separator, close_delim, default_value) result (is_ok)

Routine to parse a list of integers of the form open_delim integer_1 separator integer_2 . . . close_delim Example: (1, 2, 4, 8)

Parameters:
  • err_str (str) –

    Error string to print if there is an error.

  • lat (LatStruct) –

    lattice

  • int_array (1D array of int) –

    the array to be read in Optional: This parameter is an input/output and is modified in-place. As an output, int_array: Array of values.

Returns:
  • num_found( int ) –

    number of elements.

  • delim( str ) –

    Delimiter found where the parsing of the input line stops.

  • delim_found( bool ) –

    Delimiter found? False if end of input command.

  • is_ok( bool ) –

    Set True if everything is ok.

parse_real_list

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_real_list(lat: pybmad._pybmad.LatStruct, err_str: str, real_array: pybmad._pybmad.RealArray1D, exact_size: bool, is_ok: bool, open_delim: str | None = None, separator: str | None = None, close_delim: str | None = None, default_value: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.ParseRealList

Function parse_real_list (lat, err_str, real_array, exact_size, delim, delim_found, open_delim, separator, close_delim, default_value, num_found) result (is_ok)

Routine to parse a list of reals of the form: open_delim real_1 separator real_2 . . . close_delim Example: "(1.2, 2.3, 4.4, 8.5)"

Similar to parse_real_list2 except does not use allocatable array. Also see: parse_real_matrix.

Parameters:
  • lat (LatStruct) –

    Lattice

  • err_str (str) –

    Error string to print if there is an error.

  • real_array (1D array of float) –
  • exact_size (bool) –
  • open_delim (str) –
  • separator (str) –
  • close_delim (str) –
  • default_value (float) –
Returns:
  • delim( str ) –
  • delim_found( bool ) –
  • num_found( (int, optional) ) –

parse_real_list2

Fortran source: bmad/parsing/bmad_parser_mod.f90

parse_real_list2(lat: pybmad._pybmad.LatStruct, err_str: str, real_array: pybmad._pybmad.RealAlloc1D, num_expected: typing.SupportsInt | typing.SupportsIndex | None = None, open_brace: str | None = None, separator: str | None = None, close_brace: str | None = None, default_value: typing.SupportsFloat | typing.SupportsIndex | None = None, single_value: bool | None = None) -> pybmad._pybmad.ParseRealList2

Function parse_real_list2 (lat, err_str, real_array, num_found, delim, delim_found, num_expected, open_delim, separator, close_delim, default_value, single_value) result (is_ok)

Routine to parse a list of reals of the form: open_brace real_1 separator real_2 . . . close_brace Example: "(1.2, 2.3, 4.4, 8.5)"

Also see: pase_real_list parse_real_matrix.

Parameters:
  • lat (LatStruct) –

    lattice

  • err_str (str) –

    Error string to print if there is an error.

  • real_array (1D array of float) –

    the array to be read in This parameter is an input/output and is modified in-place. As an output, real_array: Array of values

Returns:
  • num_found( int ) –

    number of elements

  • delim( str ) –

    Delimiter found where the parsing of the input line stops.

  • delim_found( bool ) –

    Stopping delimiter found? False if end of input command.

  • is_ok( bool ) –

    Set True if everything is ok

parser_add_constant

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_add_constant(word: str, lat: pybmad._pybmad.LatStruct, redef_is_error: bool) -> None

Wrapper for Fortran routine parser_add_constant

Parameters:
  • word (str) –
  • lat (LatStruct) –
  • redef_is_error (bool) –

parser_call_check

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_call_check(word: str, ix_word: typing.SupportsInt | typing.SupportsIndex, delim: str, delim_found: bool, call_found: bool, err_flag: bool | None = None) -> None

Subroutine parser_call_check(word, ix_word, delim, delim_found, call_found, err_flag))

Routine to check if there is a "call::XXX" construct in the input stream.

parser_fast_complex_read

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_fast_complex_read(cmplx_vec: pybmad._pybmad.ComplexArray1D, ele: pybmad._pybmad.EleStruct, err_str: str) -> pybmad._pybmad.ParserFastComplexRead

Function parser_fast_complex_read (cmplx_vec, ele, delim, err_str) result (is_ok)

Routine to read an array of complex numbers.

This routine assumes that the array values are pure numbers in the form "" or "( )" where and are real numbers (not expressions) and there are no commas except possibly at the end of the array.

Parameters:
  • cmplx_vec (1D array of complex) –

    Complex vector.

  • ele (EleStruct) –

    Lattice element associated with the array. Used for error messages.

  • err_str (str) –

    String used when printing error messages identifying where in the lattice file the error is occuring.

Returns:
  • delim( str ) –

    Delimitor at end of array. Must be "," or "}"

  • is_ok( bool ) –

    True if everything OK. False otherwise.

parser_fast_integer_read

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_fast_integer_read(int_vec: pybmad._pybmad.IntArray1D, ele: pybmad._pybmad.EleStruct, delim_wanted: str, err_str: str, is_ok: bool) -> None

Function parser_fast_integer_read (int_vec, ele, delim_wanted, err_str) result (is_ok)

parser_fast_real_read

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_fast_real_read(real_vec: pybmad._pybmad.RealArray1D, ele: pybmad._pybmad.EleStruct, end_delims: str, err_str: str, exact_size: bool | None = None) -> pybmad._pybmad.ParserFastRealRead

Function parser_fast_real_read (real_vec, ele, end_delims, delim, err_str, exact_size, n_real) result (is_ok)

Routine to read an array of real numbers.

This routine assumes that the array values are pure numbers in the form " ...," where , , etc. are real numbers (not expressions) and there are no commas except possibly, at the end of the array.

Note: if end_delim is "," and next character is a delim but not ",", the next character is taken as the delim.

Parameters:
  • real_vec (1D array of float) –

    Real vector.

  • ele (EleStruct) –

    Lattice element associated with the array. Used for error messages.

  • end_delims (str) –

    List of possible ending delimitors.

  • err_str (str) –

    String used when printing error messages identifying where in the lattice file the error is occuring.

  • exact_size (bool) –

    If True (default), number of values must match real_vec size.

Returns:
  • delim( str ) –

    Delimitor at end of array.

  • is_ok( bool ) –

    True if everything OK. False otherwise.

  • n_real( (int, optional) ) –

    Number of elements found.

parser_file_stack

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_file_stack(how: str, file_name_in: str | None = None, finished: bool | None = None, err: bool | None = None, open_file: bool | None = None, abort_on_open_error: bool | None = None) -> None

Subroutine parser_file_stack (how, file_name_in, finished, err, open_file, abort_on_open_error)

Subroutine to keep track of the files that are opened for reading. This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

parser_get_integer

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_get_integer(int_val: typing.SupportsInt | typing.SupportsIndex, word: str, ix_word: typing.SupportsInt | typing.SupportsIndex, delim: str, delim_found: bool, err: bool, str1: str | None = None, str2: str | None = None) -> None

Wrapper for Fortran routine parser_get_integer

Parameters:
  • int_val (int) –
  • word (str) –
  • ix_word (int) –
  • delim (str) –
  • delim_found (bool) –
  • err (bool) –
  • str1 (str) –
  • str2 (str) –

parser_get_logical

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_get_logical(attrib_name: str, this_logic: bool, ele_name: str, delim: str, delim_found: bool, err: bool) -> None

Wrapper for Fortran routine parser_get_logical

Parameters:
  • attrib_name (str) –
  • this_logic (bool) –
  • ele_name (str) –
  • delim (str) –
  • delim_found (bool) –
  • err (bool) –

parser_identify_fork_to_element

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_identify_fork_to_element(lat: pybmad._pybmad.LatStruct) -> None

Subroutine parser_identify_fork_to_element (lat)

Routine to identify the elements the forks in a lattice are branching to.

This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

parser_init_custom_elements

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_init_custom_elements(lat: pybmad._pybmad.LatStruct) -> None

Subroutine parser_init_custom_elements (lat)

parser_print_line

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_print_line(lat: pybmad._pybmad.LatStruct, end_of_file: bool) -> None

Subroutine parser_print_line(end_of_file)

This routine is called when a print statement is found in the lattice file.

parser_read_lr_wake

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_read_lr_wake(ele: pybmad._pybmad.EleStruct, delim: str, delim_found: bool, err_flag: bool) -> None

Subroutine parser_read_lr_wake (ele, delim, delim_found, err_flag)

Subroutine to read in a long-range wake field from an external file. This subroutine is used by bmad_parser and bmad_parser2.

Parameters:
  • ele (EleStruct) –

    Element containing wake structure. This parameter is an input/output and is modified in-place. As an output, ele: Element with wake information.

parser_read_old_format_lr_wake

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_read_old_format_lr_wake(ele: pybmad._pybmad.EleStruct, lr_file_name: str) -> None

Subroutine parser_read_old_format_lr_wake (ele, lr_file_name)

Subroutine to read in a long-range wake field from an external file. This subroutine is used by bmad_parser and bmad_parser2.

Parameters:
  • ele (EleStruct) –

    Element containing wake structure. This parameter is an input/output and is modified in-place. As an output, ele: Element with wake information.

  • lr_file_name (str) –

    Name of long-range wake field file.

parser_read_old_format_sr_wake

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_read_old_format_sr_wake(ele: pybmad._pybmad.EleStruct, sr_file_name: str) -> None

Subroutine parser_read_old_format_sr_wake (ele, sr_file_name)

Subroutine to read in a short-range wake field from an external file. This subroutine is used by bmad_parser and bmad_parser2.

Parameters:
  • ele (EleStruct) –

    Element containing wake structure. This parameter is an input/output and is modified in-place. As an output, ele: Element with wake information.

  • sr_file_name (str) –

    Name of short-range wake field file.

parser_read_sr_wake

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_read_sr_wake(ele: pybmad._pybmad.EleStruct, delim: str, delim_found: bool, err_flag: bool) -> None

Subroutine parser_read_sr_wake (ele, delim, delim_found, err_flag)

Subroutine to read in a short-range wake field. This subroutine is used by bmad_parser and bmad_parser2.

Parameters:
  • ele (EleStruct) –

    Element containing wake structure. This parameter is an input/output and is modified in-place. As an output, ele: Element with wake information.

parser_transfer_control_struct

Fortran source: bmad/parsing/bmad_parser_mod.f90

parser_transfer_control_struct(con_in: pybmad._pybmad.ControlStruct, lord: pybmad._pybmad.EleStruct, ix_var: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.ControlStruct

Subroutine parser_transfer_control_struct (con_in, con_out, lord, ix_var)

Routine to transfer the information from an input control_struct (which stores the user input parameters) to a control_struct that will be stored in the lat%control or lord%control%ramp for a ramper.

Parameters:
  • con_in (ControlStruct) –

    Input control structure.

  • lord (EleStruct) –

    Lord element associated with the control_struct.

  • ix_var (int) –

    If an expression stack evaluates to a constant, this routine will modify the expression stack to evaluate to the value of: lord.control.var(ix_var) * constant

Returns:

particle_in_global_frame

Fortran source: bmad/modules/time_tracker_mod.f90

particle_in_global_frame(orb: pybmad._pybmad.CoordStruct, branch: pybmad._pybmad.BranchStruct, in_time_coordinates: bool | None = None, in_body_frame: bool | None = None, w_mat_out: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"] | None = None) -> pybmad._pybmad.CoordStruct

Function particle_in_global_frame (orb, in_time_coordinates, in_body_frame, w_mat_out) result (particle)

Returns the particle in global time coordinates given is coordinates orb in lattice lat.

Parameters:
  • orb (CoordStruct) –

    particle in s-coordinates

  • branch (BranchStruct) –

    branch that contains branch.ele(orb.ix_ele)

  • in_time_coordinates (bool) –

    Default is false. If true, orb will taken as in time coordinates.

  • in_body_frame (bool) –

    Default is true. If false, ele offsets will be ignored.

Returns:
  • particle( CoordStruct ) –

    particle in global time coordinates

particle_is_moving_backwards

Fortran source: bmad/modules/bmad_routine_interface.f90

particle_is_moving_backwards(orbit: pybmad._pybmad.CoordStruct) -> bool

Wrapper for Fortran routine particle_is_moving_backwards

Parameters:
Returns:
  • is_moving_backwards( bool ) –

    True if moving backward. False otherwise.

particle_is_moving_forward

Fortran source: bmad/modules/bmad_routine_interface.f90

particle_is_moving_forward(orbit: pybmad._pybmad.CoordStruct, dir: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine particle_is_moving_forward

Parameters:
  • orbit (CoordStruct) –

    Particle coordinates

  • dir (int) –

    +1 if tracking forward(default) or -1 to return True if tracking backwards.

Returns:
  • is_moving_forward( bool ) –

    True if moving forward. False otherwise.

particle_rf_time

Fortran source: bmad/modules/bmad_routine_interface.f90

particle_rf_time(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, reference_active_edge: bool | None = None, s_rel: typing.SupportsFloat | typing.SupportsIndex | None = None, time_coords: bool | None = None, rf_freq: typing.SupportsFloat | typing.SupportsIndex | None = None, abs_time: bool | None = None) -> float

Wrapper for Fortran routine particle_rf_time

Parameters:
  • orbit (CoordStruct) –

    Particle coordinates

  • ele (EleStruct) –

    Element being tracked through.

  • reference_active_edge (bool) –

    If True, and ele is a rfcavity or lcavity, use the active edge (edge of the region with non-zero field) as the reference point.

  • s_rel (float) –

    Longitudinal position relative to the upstream edge of the element. Needed for relative time tracking when the particle is inside the element. Default is 0.

  • time_coords (bool) –

    Default False. If True then orbit is using time based phase space coordinates.

  • rf_freq (float) –

    If present, the returned time shifted by an integer multiple of 1/rf_freq to be in the range [-1/2rf_freq, 1/2rf_freq]. This is useful to avoid round-off errors.

  • abs_time (bool) –

    If False (default) use setting of bmad_com.absolute_time_tracking. If True, use absolute time instead of relative time.

Returns:
  • time( float ) –

    Current time.

patch_flips_propagation_direction

Fortran source: bmad/modules/bmad_routine_interface.f90

patch_flips_propagation_direction(x_pitch: typing.SupportsFloat | typing.SupportsIndex, y_pitch: typing.SupportsFloat | typing.SupportsIndex) -> bool

Wrapper for Fortran routine patch_flips_propagation_direction

Parameters:
  • x_pitch (float) –

    Rotaion around y-axis

  • y_pitch (float) –

    Rotation around x-axis.

Returns:
  • is_flip( bool ) –

    True if patch does a flip

patch_length

Fortran source: bmad/modules/bmad_routine_interface.f90

patch_length(patch: pybmad._pybmad.EleStruct, ref_coords: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine patch_length

Parameters:
  • patch (EleStruct) –

    Patch element.

  • ref_coords (int) –

    Reference coords to use. entrance_end\(, exit_end\) Default is nint(patch.value(ref_coords$)).

Returns:
  • length( float ) –

    Length of patch.

photon_absorption_and_phase_shift

Fortran source: bmad/interface/xraylib_interface.f90

photon_absorption_and_phase_shift(material: str, Energy: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.PhotonAbsorptionAndPhaseShift

Subroutine photon_absorption_and_phase_shift (material, Energy, absorption, phase_shift, err_flag)

Routine to calcualte the absorption and phase shift values for a photon with a given energy going through a particular material.

Parameters:
  • material (str) –

    Material name.

  • Energy (float) –

    Photon energy (eV).

Returns:
  • absorption( float ) –

    E_field ~ Exp(-absorption * length)

  • phase_shift( float ) –

    E_field Phase shift (radians) per unit length relative to vacuum.

  • err_flag( bool ) –

    Set true if material not recognized.

photon_add_to_detector_statistics

Fortran source: bmad/photon/photon_target_mod.f90

photon_add_to_detector_statistics(orbit0: pybmad._pybmad.CoordStruct, orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, pixel_pt: pybmad._pybmad.PixelPtStruct | None = None) -> pybmad._pybmad.PhotonAddToDetectorStatistics

Subroutine photon_add_to_detector_statistics (orbit0, orbit, ele, ix_pt, iy_pt, pixel_pt)

Routine to add photon statistics to the appropriate pixel of a "detector" grid.

It is assumed that track_to_surface has been called so that the photon is at the detector surface and that orbit%vec(1) and %vec(3) are in surface coords (needed for curved detectors).

Parameters:
  • orbit0 (CoordStruct) –

    Photon coords at beginning of lattice

  • orbit (CoordStruct) –

    Photon coords at the detector.

  • ele (EleStruct) –

    Element with grid. This parameter is an input/output and is modified in-place. As an output, ele: Element with updatted grid.

  • pixel_pt (PixelPtStruct) –

    If present then use this grid point instead of the grid point determined by the (x, y) coords of the photon

Returns:
  • ix_pt( (int, optional) ) –

    Index of upgraded ele.photon.surface.grid.pt(:,:) point. These arguments are not set if the pixel_pt argument is present.

  • iy_pt( (int, optional) ) –

    Index of upgraded ele.photon.surface.grid.pt(:,:) point. These arguments are not set if the pixel_pt argument is present.

photon_reflection

Fortran source: bmad/photon/photon_reflection_mod.f90

photon_reflection(graze_angle_in: typing.SupportsFloat | typing.SupportsIndex, energy: typing.SupportsFloat | typing.SupportsIndex, surface: pybmad._pybmad.PhotonReflectSurfaceStruct) -> pybmad._pybmad.PhotonReflection

Subroutine photon_reflection (graze_angle_in, energy, surface, graze_angle_out, phi_out)

Routine to reflect a photon from a surface including both diffuse and specular reflections.

Parameters:
  • graze_angle_in (float) –

    Incident grazing (not polar) angle in radians.

  • energy (float) –

    Photon energy in eV.

  • surface (PhotonReflectSurfaceStruct) –

    surface info

Returns:
  • graze_angle_out( float ) –

    graze_angle in radians.

  • phi_out( float ) –

    Azimuthal angle in radians.

photon_reflection_std_surface_init

Fortran source: bmad/photon/photon_reflection_mod.f90

photon_reflection_std_surface_init() -> pybmad._pybmad.PhotonReflectSurfaceStruct

Subroutine photon_reflection_std_surface_init (surface)

Routine to initialize the standard proton reflection probability tables. The standard tables are for 10 nm C film on Al substrate. The surface roughness for diffuse scattering is 200 nm and the the surface roughness correlation length is 5.5 um.

Returns:

photon_reflectivity

Fortran source: bmad/photon/photon_reflection_mod.f90

photon_reflectivity(angle: typing.SupportsFloat | typing.SupportsIndex, energy: typing.SupportsFloat | typing.SupportsIndex, surface: pybmad._pybmad.PhotonReflectSurfaceStruct) -> pybmad._pybmad.PhotonReflectivity

Subroutine photon_reflectivity (angle, energy, surface, p_reflect, rel_p_specular)

Routine to evaluate the photon reflectivity. probability of absorption = 1 - p_reflect probability of reflection = p_reflect probability of specular reflection = p_reflect * rel_p_specular probability of diffuse reflection = p_reflect * (1 - rel_p_specular)

Use photon_reflection_std_surface_init or read_surface_reflection_file to get surface info.

Parameters:
  • angle (float) –

    Incident grazing angle in radians.

  • energy (float) –

    Photon energy in eV.

  • surface (PhotonReflectSurfaceStruct) –

    surface info

Returns:
  • p_reflect( float ) –

    Reflection probability.

  • rel_p_specular( float ) –

    Relative specular reflection probability.

photon_target_corner_calc

Fortran source: bmad/photon/photon_target_mod.f90

photon_target_corner_calc(aperture_ele: pybmad._pybmad.EleStruct, x_lim: typing.SupportsFloat | typing.SupportsIndex, y_lim: typing.SupportsFloat | typing.SupportsIndex, z_lim: typing.SupportsFloat | typing.SupportsIndex, source_ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.TargetPointStruct

Subroutine photon_target_corner_calc (aperture_ele, x_lim, y_lim, z_lim, source_ele, corner)

Routine to calculate the corner coords in the source_ele ref frame.

Parameters:
  • aperture_ele (EleStruct) –

    Element containing the aperture

  • x_lim (float) –

    Transverse corner points in aperture_ele coord frame.

  • y_lim (float) –

    Transverse corner points in aperture_ele coord frame.

  • source_ele (EleStruct) –

    Photon source element.

Returns:

photon_target_setup

Fortran source: bmad/photon/photon_target_mod.f90

photon_target_setup(ele: pybmad._pybmad.EleStruct) -> None

Subroutine photon_target_setup (ele)

Routine to calculate and store the parmeters needed for photon targeting. This routine is called by Bmad parsing routines and is not meant for general use.

Photon initialization with targeting is done by the routine init_photon_from_a_photon_init_ele Which is called by init_coord.

Parameters:
  • ele (EleStruct) –

    Source element to setup. Element will be of type: sample, diffraction_plate or photon_init. This parameter is an input/output and is modified in-place. As an output, ele: Source element with target parameters setup in ele.photon.target.

photon_type

Fortran source: bmad/photon/photon_utils_mod.f90

photon_type(ele: pybmad._pybmad.EleStruct) -> int

Function photon_type (ele) result (e_type)

Routine to return the type of photon to be tracked: coherent$ or incoherent$.

Parameters:
  • ele (EleStruct) –

    Element being tracked through.

Returns:
  • e_type( int ) –

    coherent$ or incoherent$

physical_ele_end

Fortran source: bmad/modules/bmad_routine_interface.f90

physical_ele_end(track_end: typing.SupportsInt | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, ele_orientation: typing.SupportsInt | typing.SupportsIndex, return_stream_end: bool | None = None) -> int

Wrapper for Fortran routine physical_ele_end

Parameters:
  • track_end (int) –

    first_track_edge\(, second_track_edge\), surface\(, or in_between\)

  • orbit (CoordStruct) –

    Particle position.

  • ele_orientation (int) –

    Either 1 = Normal or -1 = element reversed.

  • return_stream_end (bool) –

    If True return the stream end instead of the physical end. Default is False.

Returns:
  • physical_end( int ) –

    Return_stream_end -> Possibilities False -> entrance_end\(, exit_end\), surface\(, or in_between\) True -> upstream_end\(, downstream_end\)

point_photon_emission

Fortran source: bmad/photon/track1_photon_mod.f90

point_photon_emission(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct, direction: typing.SupportsInt | typing.SupportsIndex, max_target_area: typing.SupportsFloat | typing.SupportsIndex, w_to_surface: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"] | None = None) -> None

Subroutine point_photon_emission (ele, param, orbit, direction, max_target_area, w_to_surface)

Routine to emit a photon from a point that may be on a surface. If there is a downstream target, the emission calc will take this into account.

Parameters:
  • ele (EleStruct) –

    Emitting element.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords of photon. -- Will be in curved surface coords if there is a curved surface. This parameter is an input/output and is modified in-place. As an output, orbit: Final phase-space coords

  • direction (int) –

    +1 -> Emit in forward +z direction, -1 -> emit backwards.

  • max_target_area (float) –

    Area of the solid angle photons may be emitted over. max_target_area is used for normalizing the photon field. generally will be equal to twopi or fourpi.

  • w_to_surface (2D array of float (shape: 3,3)) –

    Rotation matrix for curved surface.

pointer_to_branch

Fortran sources (overloaded):

pointer_to_branch(args, *kwargs) Overloaded function.

  1. pointer_to_branch(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.BranchStruct | None

Function pointer_to_branch

Routine to return a pointer to the lattice branch associated with a given name or a given element.

This routine is an overloaded name for: pointer_to_branch_given_ele (ele) result (branch_ptr)) pointer_to_branch_given_name (branch_name, lat, parameter_is_branch0, blank_branch) result (branch_ptr)

The lattice branch associated with a given element is not necessarily the branch where the element is located. For example, all lords live in branch #0. But the branch associated with a super_lord element is the branch of its slaves.

To get the branch where the element is located, simply use ele%ix_branch.

Note: Result is ambiguous if ele argument is associated with multiple branches which can happen, for example, with overlay elements.

Parameters:
  • ele (EleStruct) –

    Element contained in the branch.

Returns:
  • branch_ptr( (BranchStruct, optional) ) –

    Pointer to the branch. Nullified if there is no associated branch.

  • 2. pointer_to_branch(branch_name: str, lat: pybmad._pybmad.LatStruct, parameter_is_branch0: bool | None = None, blank_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.BranchStruct | None
  • Function pointer_to_branch
  • Routine to return a pointer to the lattice branch associated with a given name
  • or a given element.
  • This routine is an overloaded name for:

    pointer_to_branch_given_ele (ele) result (branch_ptr)) pointer_to_branch_given_name (branch_name, lat, parameter_is_branch0, blank_branch) result (branch_ptr)

  • The lattice branch *associated* with a given element is not necessarily the
  • branch where the element is *located*. For example, all lords live in branch #0.
  • But the branch associated with a super_lord element is the branch of its slaves.
  • To get the branch where the element is located, simply use ele%ix_branch.
  • Note( Result is ambiguous if ele argument is associated with multiple branches ) –
  • which can happen, for example, with overlay elements.
Parameters:
  • branch_name (str) –

    May be a branch name or a branch index.

  • lat (LatStruct) –

    Lattice to search.

  • parameter_is_branch0 (bool) –

    If True, 'PARAMETER' is taken to be an alternative name for branch(0). Default is False.

  • blank_branch (int) –

    Branch index if branch_name = ''. Default is blank is an error.

Returns:
  • branch_ptr( (BranchStruct, optional) ) –

    Pointer to the branch. Nullified if there is no associated branch.

pointer_to_ele

Fortran sources (overloaded):

pointer_to_ele(args, *kwargs) Overloaded function.

  1. pointer_to_ele(lat: pybmad._pybmad.LatStruct, ix_ele: typing.SupportsInt | typing.SupportsIndex, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.EleStruct | None

Function pointer_to_ele (...)

Routine to return a pointer to an element. pointer_to_ele is an overloaded name for: Function pointer_to_ele1 (lat, ix_ele, ix_branch) result (ele_ptr) Function pointer_to_ele2 (lat, ele_loc) result (ele_ptr) Function pointer_to_ele3 (lat, ele_name) result (ele_ptr) Function pointer_to_ele4 (lat, foreign_ele) result (ele_ptr)

pointer_to_ele4(lat, foreign_ele) is useful when foreign_ele is associated with a separate lattice that has an identical layout. pointer_to_ele4 will then return the corresponding element in lat.

Note that using ele_name to locate an element is potentially dangerous if there are multiple elements that have the same name. Better in this case is to use: lat_ele_locator

Also see: pointer_to_slave pointer_to_lord

Parameters:
  • lat (LatStruct) –

    Lattice.

  • ix_ele (int) –

    Index of element in lat.branch(ix_branch).

  • ix_branch (int) –

    Index of the lat.branch(:) containing the element.

Returns:
  • ele_ptr( (EleStruct, optional) ) –

    Pointer to the element. Nullified if no match or error.

  • 2. pointer_to_ele(lat: pybmad._pybmad.LatStruct, ele_loc: pybmad._pybmad.LatEleLocStruct) -> pybmad._pybmad.EleStruct | None
  • Function pointer_to_ele (...)
  • Routine to return a pointer to an element.
  • pointer_to_ele is an overloaded name for:

    Function pointer_to_ele1 (lat, ix_ele, ix_branch) result (ele_ptr) Function pointer_to_ele2 (lat, ele_loc) result (ele_ptr) Function pointer_to_ele3 (lat, ele_name) result (ele_ptr) Function pointer_to_ele4 (lat, foreign_ele) result (ele_ptr)

  • pointer_to_ele4(lat, foreign_ele) is useful when foreign_ele is associated with a separate
  • lattice that has an identical layout. pointer_to_ele4 will then return the corresponding
  • element in lat.
  • Note that using ele_name to locate an element is potentially dangerous if there
  • are multiple elements that have the same name. Better in this case is to use:

    lat_ele_locator

  • Also see:

    pointer_to_slave pointer_to_lord

Parameters:
Returns:
  • ele_ptr( (EleStruct, optional) ) –

    Pointer to the element. Nullified if no match or error.

  • 3. pointer_to_ele(lat: pybmad._pybmad.LatStruct, ele_name: str) -> pybmad._pybmad.EleStruct | None
  • Function pointer_to_ele (...)
  • Routine to return a pointer to an element.
  • pointer_to_ele is an overloaded name for:

    Function pointer_to_ele1 (lat, ix_ele, ix_branch) result (ele_ptr) Function pointer_to_ele2 (lat, ele_loc) result (ele_ptr) Function pointer_to_ele3 (lat, ele_name) result (ele_ptr) Function pointer_to_ele4 (lat, foreign_ele) result (ele_ptr)

  • pointer_to_ele4(lat, foreign_ele) is useful when foreign_ele is associated with a separate
  • lattice that has an identical layout. pointer_to_ele4 will then return the corresponding
  • element in lat.
  • Note that using ele_name to locate an element is potentially dangerous if there
  • are multiple elements that have the same name. Better in this case is to use:

    lat_ele_locator

  • Also see:

    pointer_to_slave pointer_to_lord

Parameters:
  • lat (LatStruct) –

    Lattice.

  • ele_name (str) –

    Name or index of element.

Returns:
  • ele_ptr( (EleStruct, optional) ) –

    Pointer to the element. Nullified if no match or error.

  • 4. pointer_to_ele(lat: pybmad._pybmad.LatStruct, foreign_ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.EleStruct | None
  • Function pointer_to_ele (...)
  • Routine to return a pointer to an element.
  • pointer_to_ele is an overloaded name for:

    Function pointer_to_ele1 (lat, ix_ele, ix_branch) result (ele_ptr) Function pointer_to_ele2 (lat, ele_loc) result (ele_ptr) Function pointer_to_ele3 (lat, ele_name) result (ele_ptr) Function pointer_to_ele4 (lat, foreign_ele) result (ele_ptr)

  • pointer_to_ele4(lat, foreign_ele) is useful when foreign_ele is associated with a separate
  • lattice that has an identical layout. pointer_to_ele4 will then return the corresponding
  • element in lat.
  • Note that using ele_name to locate an element is potentially dangerous if there
  • are multiple elements that have the same name. Better in this case is to use:

    lat_ele_locator

  • Also see:

    pointer_to_slave pointer_to_lord

Parameters:
  • lat (LatStruct) –

    Lattice.

  • foreign_ele (EleStruct) –

    Lattice element in another lattice.

Returns:
  • ele_ptr( (EleStruct, optional) ) –

    Pointer to the element. Nullified if no match or error.

pointer_to_element_at_s

Fortran source: bmad/modules/element_at_s_mod.f90

pointer_to_element_at_s(branch: pybmad._pybmad.BranchStruct, s: typing.SupportsFloat | typing.SupportsIndex, choose_max: bool, print_err: bool | None = None) -> pybmad._pybmad.PointerToElementAtS

Function pointer_to_element_at_s (branch, s, choose_max, err_flag, s_eff, position) result (ele)

Function to return a pointer to the element at position s. That is, return ele => branch%ele(ix_ele) such that: If choose_max = True: If s = branch%ele(ix_end_of_branch): ix_ele = ix_end_of_branch Else: branch%ele(ix_ele)%s_strat <= s < branch%ele(ix_ele)%s If choose_max = False: If s = branch%ele(0): ix_ele = 0 Else: branch%ele(ix_ele)%s_start < s <= branch%ele(ix_ele)%s That is, if s corresponds to an element boundary between elements with indexes ix1 and ix2 = ix1 + 1: choose_max = True => ix_ele = ix2 choose_max = False => ix_ele = ix1

Also see: element_at_s

The setting of choose_max only makes a difference when s corresponds to an element boundary.

Note: For a circular lattice, s is evaluated at the effective s which is modulo the branch length: s_eff = s - branch_length * floor(s/branch_length)

Note: If there are multiple elements that are at the given s position due to the presence of an element with a negative length, which of the possible elements is actually chosen is ill-defined.

Parameters:
  • branch (BranchStruct) –

    Branch to use

  • s (float) –

    Longitudinal position.

  • choose_max (bool) –

    See above.

  • print_err (bool) –

    Print error message if there is an error? Default is True.

Returns:
  • err_flag( (bool, optional) ) –

    Set True if s is out of bounds. False otherwise.

  • s_eff( (float, optional) ) –

    Effective s. Equal to s with a open lattice. See above.

  • position( (CoordStruct, optional) ) –

    Positional information.

  • ele( (EleStruct, optional) ) –

    Pointer to element at s.

pointer_to_fibre

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_fibre(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.Fibre | None

Wrapper for Fortran routine pointer_to_fibre

Parameters:
Returns:
  • assoc_fibre( (Fibre, optional) ) –

    Pointer to the associated fibre.

pointer_to_field_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_field_ele(ele: pybmad._pybmad.EleStruct, ix_field_ele: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.PointerToFieldEle

Wrapper for Fortran routine pointer_to_field_ele

Parameters:
  • ele (EleStruct) –

    Element with sum number of associated field elements.

  • ix_field_ele (int) –

    Index of the field element to point to. This index runs from 1 to num_field_eles(ele).

Returns:
  • dz_offset( (float, optional) ) –

    Longitudinal offset of ele upstream edge from the field ele pointed to.

  • field_ele( (EleStruct, optional) ) –

    Pointer to the field element with index ix_field_ele. Will point to null if ix_field_ele is out of range.

pointer_to_girder

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_girder(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.PointerToGirder

Wrapper for Fortran routine pointer_to_girder

Parameters:
Returns:
  • ix_slave_back( (int, optional) ) –

    Index back to ele. That is, pointer_to_slave(girder, ix_slave_back) will point back to ele. Set to -1 if no girder present

  • girder( (EleStruct, optional) ) –

    : Pointer to the girder. Null if ele is not girder supported.

pointer_to_lord

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_lord(slave: pybmad._pybmad.EleStruct, ix_lord: typing.SupportsInt | typing.SupportsIndex, lord_type: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.PointerToLord

Wrapper for Fortran routine pointer_to_lord

Parameters:
  • slave (EleStruct) –

    Slave element.

  • ix_lord (int) –

    Index of the lord.

  • lord_type (int) –

    See above.

Returns:
  • control( (ControlStruct, optional) ) –

    Pointer to control info for this lord/slave relationship. Nullified if there is an error.

  • ix_slave_back( (int, optional) ) –

    Index back to the slave. That is, pointer_to_slave(lord_ptr, ix_slave_back) will point back to slave. Set to -1 if there is an error or the slave is a slice_slave.

  • ix_control( (int, optional) ) –

    Index in lat.control(:) array the control argument is at. For ramper lord elements, ix_control is index for the lord.control.ramper(:) array.

  • ix_ic( (int, optional) ) –

    Index of the lat.ic(:) element associated with the control argument.

  • lord_ptr( (EleStruct, optional) ) –

    Pointer to the lord. Nullified if there is an error.

pointer_to_multipass_lord

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_multipass_lord(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.PointerToMultipassLord

Wrapper for Fortran routine pointer_to_multipass_lord

Parameters:
Returns:
  • ix_pass( (int, optional) ) –

    Multipass turn number. Set to 0 if element is a multipass_lord. Set to -1 if element is not a multipass_slave.

  • super_lord( (EleStruct, optional) ) –

    super_lord of the element. Set to NULL if ele is not a super_slave or super_lord. Note: if ele is a multipass_lord there are multiple possible super_lord slaves.

  • multi_lord( (EleStruct, optional) ) –

    multipass_lord if there is one. Set to NULL if there is no multipass_lord.

pointer_to_next_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_next_ele(this_ele: pybmad._pybmad.EleStruct, next_ele: pybmad._pybmad.EleStruct, offset: typing.SupportsInt | typing.SupportsIndex | None = None, skip_beginning: bool | None = None, follow_fork: bool | None = None) -> None

Wrapper for Fortran routine pointer_to_next_ele

Parameters:
  • this_ele (EleStruct) –

    Starting element.

  • next_ele (EleStruct) –

    Element after this_ele (if offset = 1). Nullified if there is an error. EG bad this_ele.

  • offset (int) –

    +1 -> return next element, +2 -> element after that, etc. Can be negative. Default = +1.

  • skip_beginning (bool) –

    If True then skip beginning element #0 when wrapping around. Default is False.

  • follow_fork (bool) –

    If True then fork at any fork element. Default is False.

pointer_to_slave

Fortran source: bmad/modules/bmad_struct.f90

pointer_to_slave(lord: pybmad._pybmad.EleStruct, ix_slave: typing.SupportsInt | typing.SupportsIndex, slave_type: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.PointerToSlave

Function pointer_to_slave (lord, ix_slave, control, slave_type, ix_lord_back, ix_control, ix_ic) result (slave_ptr)

Function to point to a slave of a lord. Note: Ramper lords do not have any associated slaves (slaves are assigned dynamically at run time).

If slave_type = all$ (the default) the range for ix_slave is: 1 to lord%n_slave for "regular" slaves. lord%n_slave+1 to lord%n_slave+lord%n_slave_field for field overlap slaves.

If slave_type = field_slave$, only the field overlap slaves may be accessed and the range for ix_slave is: 1 to lord%n_slave_field

Also see: pointer_to_lord pointer_to_super_lord pointer_to_ele num_lords

Parameters:
  • lord (EleStruct) –

    Lord element

  • ix_slave (int) –

    Index of the slave in the list of slaves controled by the lord..

  • slave_type (int) –

    See above.

Returns:
  • control( (ControlStruct, optional) ) –

    Pointer to control info for this lord/slave relationship. Nullified if there is an error.

  • ix_lord_back( (int, optional) ) –

    Index back to the lord. That is, pointer_to_lord(slave_ptr, ix_lord_back) will point back to the lord. Set to -1 if there is an error.

  • ix_control( (int, optional) ) –

    Index in lat.control(:) array the control argument is at.

  • ix_ic( (int, optional) ) –

    Index of the lat.ic(:) element associated with the control argument.

  • slave_ptr( (EleStruct, optional) ) –

    Pointer to the slave. Nullified if there is an error.

pointer_to_super_lord

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_super_lord(slave: pybmad._pybmad.EleStruct, lord_type: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.PointerToSuperLord

Wrapper for Fortran routine pointer_to_super_lord

Parameters:
  • slave (EleStruct) –

    Slave element.

  • lord_type (int) –

    If present, only return a super_lord of this type.

Returns:
  • control( (ControlStruct, optional) ) –

    Pointer to control info for this lord/slave relationship. Nullified if there is an error.

  • ix_slave_back( (int, optional) ) –

    Index back to the slave. That is, pointer_to_slave(lord_ptr, ix_slave_back) will point back to slave. Set to -1 if there is an error or the slave is a slice_slave.

  • ix_control( (int, optional) ) –

    Index in lat.control(:) array the control argument is at. For ramper lord elements, ix_control is index for the lord.control.ramper(:) array.

  • ix_ic( (int, optional) ) –

    Index of the lat.ic(:) element associated with the control argument.

  • lord_ptr( (EleStruct, optional) ) –

    Pointer to the lord.

pointer_to_surface_displacement_pt

Fortran source: bmad/photon/photon_utils_mod.f90

pointer_to_surface_displacement_pt(ele: pybmad._pybmad.EleStruct, nearest: bool, x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, extend_grid: bool | None = None) -> pybmad._pybmad.PointerToSurfaceDisplacementPt

Function pointer_to_surface_displacement_pt (ele, nearest, x, y, ix, iy, extend_grid, xx, yy) result (pt)

Routine to point to the grid point struct associated with point (x,y).

Note: If nearest = True, the grid boundary is a length dr/2 from the boundary grid points.

Parameters:
  • ele (EleStruct) –

    Element containing the grid

  • nearest (bool) –

    If True, return pointer to nearest grid point. If False, return pointer to the grid point lower and left of (x,y).

  • x (float) –

    Photon position.

  • y (float) –

    Photon position.

  • extend_grid (bool) –

    If (x,y) past grid pretend (x,y) is at grid boundary. Default is False.

Returns:
  • ix( (int, optional) ) –

    Grid point index.

  • iy( (int, optional) ) –

    Grid point index.

  • xx( (float, optional) ) –

    Set equal to (x, y) except if (x,y) is outside of the grid. In this case, (xx, yy) will be set to be on the nearest grid boundary point.

  • yy( (float, optional) ) –

    Set equal to (x, y) except if (x,y) is outside of the grid. In this case, (xx, yy) will be set to be on the nearest grid boundary point.

  • pt( (SurfaceDisplacementPtStruct, optional) ) –

    Pointer to grid point. Will not be associated if (x,y) outside the grid.

pointer_to_surface_segmented_pt

Fortran source: bmad/photon/photon_utils_mod.f90

pointer_to_surface_segmented_pt(ele: pybmad._pybmad.EleStruct, nearest: bool, x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, extend_grid: bool | None = None) -> pybmad._pybmad.PointerToSurfaceSegmentedPt

Function pointer_to_surface_segmented_pt (ele, nearest, x, y, ix, iy, extend_grid, xx, yy) result (pt)

Routine to point to the grid point struct associated with point (x,y).

Note: If nearest = True, the grid boundary is a length dr/2 from the boundary grid points.

Parameters:
  • ele (EleStruct) –

    Element containing the grid

  • nearest (bool) –

    If True, return pointer to nearest grid point. If False, return pointer to the grid point lower and left of (x,y).

  • x (float) –

    Photon position.

  • y (float) –

    Photon position.

  • extend_grid (bool) –

    If (x,y) past grid pretend (x,y) is at grid boundary. Default is False.

Returns:
  • ix( (int, optional) ) –

    Grid point index.

  • iy( (int, optional) ) –

    Grid point index.

  • xx( (float, optional) ) –

    Set equal to (x, y) except if (x,y) is outside of the grid. In this case, (xx, yy) will be set to be on the nearest grid boundary point.

  • yy( (float, optional) ) –

    Set equal to (x, y) except if (x,y) is outside of the grid. In this case, (xx, yy) will be set to be on the nearest grid boundary point.

  • pt( (SurfaceSegmentedPtStruct, optional) ) –

    Pointer to grid point. Will not be associated if (x,y) outside the grid.

pointer_to_wake_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

pointer_to_wake_ele(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.PointerToWakeEle

Wrapper for Fortran routine pointer_to_wake_ele

Parameters:
Returns:
  • delta_s( (float, optional) ) –

    distance of wake locaiton from beginning of ele.

  • wake_ele( (EleStruct, optional) ) –

    Element having the associated wake. wake_ele will be nullified if there is no associated wake.

pointer_to_wall3d

Fortran source: bmad/modules/wall3d_mod.f90

pointer_to_wall3d(ele: pybmad._pybmad.EleStruct, ix_wall: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.PointerToWall3d

Function pointer_to_wall3d (ele, ix_wall, ds_offset, is_branch_wall) result (wall3d)

Function to return a pointer to a wall3d structure associated with a given lattice element.

Note: The wall associated with a the vacuum chamber is the branch%wall3d.

Parameters:
  • ele (EleStruct) –

    lattice element.

  • ix_wall (int) –

    index in wall3d(:) array. Default is 1.

Returns:
  • ds_offset( (float, optional) ) –

    Element offset: s(beginning of ele) - s(beginning of wall3d)

  • is_branch_wall( (bool, optional) ) –

    Set True if wall3d points to branch.wall3d.

  • wall3d( (Wall3dStruct, optional) ) –

    Pointer to the associated wall structure. Will be nullified if there is no associated wall.

polar_to_spinor

Fortran source: bmad/modules/bmad_routine_interface.f90

polar_to_spinor(polar: pybmad._pybmad.SpinPolarStruct) -> typing.Annotated[list[complex], "FixedSize(2)"]

Wrapper for Fortran routine polar_to_spinor

Parameters:
Returns:
  • spinor( 1D array of complex (shape: 2) ) –

    Spinor

polar_to_vec

Fortran source: bmad/modules/bmad_routine_interface.f90

polar_to_vec(polar: pybmad._pybmad.SpinPolarStruct) -> typing.Annotated[list[float], "FixedSize(3)"]

Wrapper for Fortran routine polar_to_vec

Parameters:
Returns:
  • vec( 1D array of float (shape: 3) ) –

    Real(3)

project_emit_to_xyz

Fortran source: bmad/modules/mode3_mod.f90

project_emit_to_xyz(ring: pybmad._pybmad.LatStruct, ix: typing.SupportsInt | typing.SupportsIndex, mode: pybmad._pybmad.NormalModesStruct) -> pybmad._pybmad.ProjectEmitToXyz

Subroutine project_emit_to_xyz(ring, ix, mode, sigma_x, sigma_y, sigma_z)

Obtains the projected x, y, and z beamsizes by building the sigma matrix from the normal mode emittances and 1-turn transfer matrix. These projectes beamsize are what would be seen by instrumentation.

This method of projecting takes into account transverse and longitudinal coupling.

This method of obtaining the projected beam sizes is from "Alternitive approach to general coupled linear optics" by Andrzej Wolski.

The normal mode emittances used to generate a beam envelop sigma matrix from the 1-turn transfer matrix. The projected sizes are from the 1, 1 3, 3 and 5, 5 elements of the sigma matrix.

Parameters:
  • ring (LatStruct) –

    the storage ring

  • ix (int) –

    element at which to make the projection

  • mode (NormalModesStruct) –

    normal mode emittances

Returns:
  • sigma_x( float ) –

    projected horizontal beamsize

  • sigma_y( float ) –

    projected vertical beamsize

  • sigma_z( float ) –

    projected longitudinal beamsize

psi_prime_sca

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

psi_prime_sca(t: typing.SupportsFloat | typing.SupportsIndex, p: typing.SupportsFloat | typing.SupportsIndex, args: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"]) -> float

Subroutine psi_prime_sca(t, p, dpdt, args)

This wraps the array-valued psi_prime function as a scalar.

See psi_prime comments for details.

Parameters:
  • t (float) –

    time relative to RF bucket

  • p (float) –

    psi(t)

  • args (1D array of float (shape: 1:8)) –

    parameters and constants of DEQ

Returns:
  • dpdt( float ) –

    dpsi_dt

ptc_bookkeeper

Fortran source: bmad/modules/bmad_routine_interface.f90

ptc_bookkeeper(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine ptc_bookkeeper

Parameters:

ptc_calculate_tracking_step_size

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_calculate_tracking_step_size(ptc_layout: pybmad._pybmad.Layout, kl_max: typing.SupportsFloat | typing.SupportsIndex, ds_max: typing.SupportsFloat | typing.SupportsIndex | None = None, even_steps: pybmad._pybmad.BoolAlloc1D | None = None, r_typical: typing.SupportsFloat | typing.SupportsIndex | None = None, dx_tol_bend: typing.SupportsFloat | typing.SupportsIndex | None = None, use_2nd_order: bool | None = None, crossover: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(2)"] | None = None, crossover_wiggler: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(2)"] | None = None) -> None

Subroutine ptc_calculate_tracking_step_size (ptc_layout, kl_max, ds_max, even_steps, r_typical, dx_tol_bend, use_2nd_order)

Routine to calculate the optimum number of tracking steps and order of the integrator (2, 4, or 6) for each fibre in a layout.

See the Bmad manual chapter on PTC for more details.

Parameters:
  • ptc_layout (Layout) –

    This parameter is an input/output and is modified in-place. As an output, ptc_layout: Lattice with the optimum number of tracking steps and integrator order.

  • kl_max (float) –

    Maximum K1*L per tracking step.

  • ds_max (float) –

    Maximum ds for any step. Useful when including other physicas like space charge.

  • even_steps (1D array of bool (shape: 2)) –

    Always use an even number of steps for a fibre? Useful if need to evaluate at the center of fibres.

  • r_typical (float) –

    Typical transverse offset. Used for computing the effective contribution of K1*L due to sextupoles.

  • dx_tol_bend (float) –

    Tolerable residual orbit in a bend.

  • use_2nd_order (bool) –

    If present and True then force the use of 2nd order integrator.

  • crossover (1D array of int (shape: 2)) –

    crossover points between orders for all elements except wigglers. Default is [4, 18].

  • crossover_wiggler (1D array of int (shape: 2)) –

    crossover points for wigglers. Default is [30, 60].

ptc_check_for_lost_particle

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_check_for_lost_particle(do_reset: bool) -> pybmad._pybmad.PtcCheckForLostParticle

Subroutine ptc_check_for_lost_particle (state, ptc_fibre, do_reset)

Routine to check if a particle has been lost when tracking with PTC.

Parameters:
  • do_reset (bool) –

    If True then reset ptc flags.

Returns:
  • state( int ) –

    Same as coord_struct.state. alive\(, lost\), lost_neg_x$, etc.

  • ptc_fibre( (Fibre, optional) ) –

    Pointer to fibre where particle lost. Nullified if particle alive.

ptc_closed_orbit_calc

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_closed_orbit_calc(branch: pybmad._pybmad.BranchStruct, radiation_damping_on: bool | None = None) -> pybmad._pybmad.CoordStructAlloc1D

Subroutine ptc_closed_orbit_calc (branch, closed_orbit, radiation_damping_on)

Routine to calculate the closed orbit of a lattice branch using PTC. This routine assumes the associated PTC layout has been crated with lat_to_ptc_layout.

Parameters:
  • branch (BranchStruct) –

    Branch of a lattice.

  • radiation_damping_on (bool) –

    If True, radiation dampling is included in the calculation. Default is the setting of bmad_com..radiation_damping_on.

Returns:
  • closed_orbit( 1D array of CoordStruct ) –

    closed_orbit

ptc_emit_calc

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_emit_calc(ele: pybmad._pybmad.EleStruct, sigma_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.PtcEmitCalc

Subroutine ptc_emit_calc (ele, norm_mode, sigma_mat, closed_orb)

Routine to calculate emittances, etc.

Note: This routine calls the PTC init_all routine.

Parameters:
  • ele (EleStruct) –

    Element at which to evaluate the parameters.

Returns:
  • norm_mode( NormalModesStruct ) –

    Normal_modes_struct %a%tune, %b%tune, %z%tune %a%alpha_damp, etc. %a%emittance, etc.

  • closed_orb( CoordStruct ) –

    Closed orbit at ele (Bmad coordinates). Notice: This closed orbit is the closed orbit with radiation on.

ptc_layouts_resplit

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_layouts_resplit(dKL_max: typing.SupportsFloat | typing.SupportsIndex, l_max: typing.SupportsFloat | typing.SupportsIndex, l_max_drift_only: bool, bend_dorb: typing.SupportsFloat | typing.SupportsIndex, sex_dx: typing.SupportsFloat | typing.SupportsIndex, even: bool | None = None, crossover: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(2)"] | None = None, crossover_wiggler: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(2)"] | None = None) -> None

Subroutine ptc_layouts_resplit (dKL_max, l_max, l_max_drift_only, bend_dorb, sex_dx, even, crossover, crossover_wiggler)

Routine to resplit (that is, recalculate the number of integration steps for an element) For the fibres in all layouts. After doing a resplit, the tune (and any other relavent "adjustable" parameters) should be adjusted to the correct values.

Parameters:
  • dKL_max (float) –

    Maximum K1 * L quadrupole strength allowed for an integration step. Reasonable value would be something like 0.04.

  • l_max (float) –

    Maximum step length. Ignored if set to 0.

  • l_max_drift_only (bool) –

    If True then l_max is only used for splitting drifts.

  • bend_dorb (float) –

    Residual bend orbit error. With some integration methods a zero orbit at the start of the bend will not be zero at the end. In this case, bend_dorb sets a maximum allowable orbit deviation. If set to zero, this argument will be ignored. A resonable value is 10d-7. Note that the actual orbit deviation is not simply related to bend_dorb and can be larger. In any case, lowering bend_dorb (without making it zero) will lower the

  • sex_dx (float) –

    To split sextupoles, sex_dx is used as the reference position about which the quadrupole strength is calculated. This quadrupole strength is then used with dKL_max to calculate the number of integration steps. Set to zero to ignore.

  • even (bool) –

    If True then each fibre will have an even number of steps. If False then the number of steps will be odd. If not present then number of steps is not constrained to be even or odd.

  • crossover (1D array of int (shape: 2)) –

    crossover(1) sets the maximum number of 2nd order integration steps to use. If the number of steps would exceed crossover(1) then integration is switched to 4th order. crossover(2) sets the maximum number of 4th order integration steps. If this number is exceeded, 6th order integration is used. Currently the default in PTC is [4, 18].

  • crossover_wiggler (1D array of int (shape: 2)) –

    crossover for wiggler elements.

ptc_one_turn_mat_and_closed_orbit_calc

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_one_turn_mat_and_closed_orbit_calc(branch: pybmad._pybmad.BranchStruct, pz: typing.SupportsFloat | typing.SupportsIndex | None = None) -> None

Subroutine ptc_one_turn_mat_and_closed_orbit_calc (branch, pz)

Routine to compute the transfer matrices for the individual elements and closed orbit for a lattice branch with closed geometry.

Note: PTC itself does not compute Twiss parameters. Use twiss_from_mat6 to compute this.

Parameters:
  • branch (BranchStruct) –

    Lattice branch. This parameter is an input/output and is modified in-place. As an output, branch: Lattice branch containing the matrices.

  • pz (float) –

    energy offset around which to calculate the matrices if there is no RF.

ptc_ran_seed_put

Fortran source: bmad/modules/bmad_routine_interface.f90

ptc_ran_seed_put(iseed: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine ptc_ran_seed_put

Parameters:
  • iseed (int) –

    0 -> Use system clock.

ptc_read_flat_file

Fortran source: bmad/modules/bmad_routine_interface.f90

ptc_read_flat_file(flat_file: pybmad._pybmad.CharacterAlloc1D, create_end_marker: bool | None = None, from_mad: bool | None = None) -> pybmad._pybmad.PtcReadFlatFile

Wrapper for Fortran routine ptc_read_flat_file

Parameters:
  • flat_file (1D array of str) –

    Name(s) of PTC flat file(s).

  • create_end_marker (bool) –

    Put a marker element named END at the end of the lattice brances? Default is True.

  • from_mad (bool) –

    If True, ignore PTC specific parameters like integrator_order. Default is False. True is used when the fibre has been created via MAD. In this case, the PTC specific parameters may not have good values.

Returns:
  • err_flag( bool ) –

    Set True if there is a problem.

  • lat( (LatStruct, optional) ) –

    If present then setup a Bmad lattice.

ptc_set_rf_state_for_c_normal

Fortran source: bmad/modules/bmad_routine_interface.f90

ptc_set_rf_state_for_c_normal(nocavity: bool) -> None

Wrapper for Fortran routine ptc_set_rf_state_for_c_normal

Parameters:
  • nocavity (bool) –

    True -> RF is off and vice versa.

ptc_set_taylor_order_if_needed

Fortran source: bmad/ptc/ptc_interface_mod.f90

ptc_set_taylor_order_if_needed() -> None

Subroutine ptc_set_taylor_order_if_needed()

Routine to see if the taylor_order for PTC needs to be set/changed. For example, for a change in bmad_com%taylor_order.

ptc_spin_calc

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_spin_calc(ele: pybmad._pybmad.EleStruct, sigma_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.PtcSpinCalc

Subroutine ptc_spin_calc (ele, norm_mode, sigma_mat, closed_orb)

Routine to equilibrium polarizations, etc.

Parameters:
  • ele (EleStruct) –

    Element at which to evaluate the parameters.

Returns:
  • norm_mode( NormalModesStruct ) –

    Normal_modes_struct %a%tune, %b%tune, %z%tune %a%alpha_damp, etc. %a%emittance, etc.

  • closed_orb( CoordStruct ) –

    Closed orbit at ele (Bmad coordinates). Notice: This closed orbit is the closed orbit with radiation on.

ptc_track_all

Fortran source: bmad/ptc/ptc_layout_mod.f90

ptc_track_all(branch: pybmad._pybmad.BranchStruct, orbit: pybmad._pybmad.CoordStructAlloc1D) -> pybmad._pybmad.PtcTrackAll

Subroutine ptc_track_all (branch, orbit, track_state, err_flag)

Routine to track from the start to the end of a lattice branch.

Parameters:
  • branch (BranchStruct) –

    Lat to track through.

  • orbit (1D array of CoordStruct) –

    Coordinates at beginning of branch. This parameter is an input/output and is modified in-place. As an output, orbit: Orbit array.

Returns:
  • track_state( (int, optional) ) –

    Set to moving_forward$ if everything is OK. Otherwise: set to index of element where particle was lost.

  • err_flag( (bool, optional) ) –

    Set true if particle lost or error. False otherwise

ptc_transfer_map_with_spin

Fortran source: bmad/modules/bmad_routine_interface.f90

ptc_transfer_map_with_spin(branch: pybmad._pybmad.BranchStruct, t_map: pybmad._pybmad.TaylorStructArray1D, s_map: pybmad._pybmad.TaylorStructArray1D, orb0: pybmad._pybmad.CoordStruct, ix1: typing.SupportsInt | typing.SupportsIndex | None = None, ix2: typing.SupportsInt | typing.SupportsIndex | None = None, one_turn: bool | None = None, unit_start: bool | None = None) -> bool

Wrapper for Fortran routine ptc_transfer_map_with_spin

Parameters:
  • branch (BranchStruct) –

    Lattice branch used in the calculation.

  • t_map (1D array of TaylorStruct (shape: 6)) –

    Initial orbital map (used when unit_start = False) This parameter is an input/output and is modified in-place. As an output, t_map: Orbital transfer map.

  • s_map (1D array of TaylorStruct (shape: 4)) –

    Initial spin map (used when unit_start = False) This parameter is an input/output and is modified in-place. As an output, s_map: Quaternion spin transfer map.

  • orb0 (CoordStruct) –

    Initial orbit around which the map is made.

  • ix1 (int) –

    Element start index for the calculation. Default is 0.

  • ix2 (int) –

    Element end index for the calculation. Default is branch.n_ele_track.

  • one_turn (bool) –

    If present and True, and if ix1 = ix2, and the lattice is circular, then construct the one-turn map from ix1 back to ix1. Default = False.

  • unit_start (bool) –

    If present and False then t_map will be used as the starting map instead of the unit map. Default = True

Returns:
  • err_flag( bool ) –

    Set True if problem like number overflow, etc.

pwd_mat

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

pwd_mat(lat: pybmad._pybmad.LatStruct, t6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], inductance: typing.SupportsFloat | typing.SupportsIndex, sig_z: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"]

Function pwd_mat(t6, inductance, sig_z) result (t6_pwd)

Calculates potential well distortion as RF defocusing. Calculates t6_pwd=t6.Mpwd, where Mpwd is identity with 65 element proportional to the inductance.

Vpwd = -inductance * lat%param%n_part * e_charge * c_light3 / SQRT(twopi) / sig_z3 / omega_RF !effective RF voltage from PWD Mpwd(6,5) = omega_RF * Vpwd / c_light / lat%ele(0)%value(E_TOT\() * branch%ele(i)%value(l\)) / lat%param%total_length

Parameters:
  • lat (LatStruct) –

    TYPE(lat_struct)

  • t6 (2D array of float (shape: 6,6)) –

    1-turn transfer matrix

  • inductance (float) –

    Longitudinal inductance in Henrys. Something on the order of nH.

  • sig_z (float) –

    Bunch length.

Returns:
  • t6_pwd( 2D array of float (shape: 6,6) ) –

    1-turn transfer matrix with PWD defocusing applied

rad1_damp_and_stoc_mats

Fortran source: bmad/modules/rad_6d_mod.f90

rad1_damp_and_stoc_mats(ele: pybmad._pybmad.EleStruct, include_opening_angle: bool, orb_in: pybmad._pybmad.CoordStruct, orb_out: pybmad._pybmad.CoordStruct, g2_tol: typing.SupportsFloat | typing.SupportsIndex, g3_tol: typing.SupportsFloat | typing.SupportsIndex, ele0: pybmad._pybmad.EleStruct | None = None) -> pybmad._pybmad.Rad1DampAndStocMats

Subroutine rad1_damp_and_stoc_mats (ele, include_opening_angle, orb_in, orb_out, rad_map, g2_tol, g3_tol, err_flag, ele0, rad_int1)

Routine to calculate the damping and stochastic matrices for a given lattice element.

Parameters:
  • ele (EleStruct) –

    Element under consideration.

  • include_opening_angle (bool) –

    If True include the effect of the vertical opening angle of emitted radiation. Generally use True unless comparing against other codes.

  • orb_in (CoordStruct) –

    Entrance orbit about which to compute the matrices.

  • orb_out (CoordStruct) –

    Exit orbit.

  • g2_tol (float) –

    Tollerance on g^2 per unit length (damping tolerance).

  • g3_tol (float) –

    Tollerance on g^3 per unit length (stocastic tolerance).

  • ele0 (EleStruct) –

    Element before ele. Needed if and only if rad_int1 is present

Returns:
  • rad_map( RadMapStruct ) –

    Damping and stochastic matrices.

  • err_flag( bool ) –

    Set true if there is an error. False otherwise.

  • rad_int1( (RadInt1Struct, optional) ) –

    Radiation integrals

rad_damp_and_stoc_mats

Fortran source: bmad/modules/rad_6d_mod.f90

rad_damp_and_stoc_mats(ele1: pybmad._pybmad.EleStruct, ele2: pybmad._pybmad.EleStruct, include_opening_angle: bool, closed_orbit: pybmad._pybmad.CoordStructArray1D | None = None) -> pybmad._pybmad.RadDampAndStocMats

Subroutine rad_damp_and_stoc_mats (ele1, ele2, include_opening_angle, rmap, mode, xfer_nodamp_mat, err_flag, closed_orbit, rad_int_branch)

Routine to calculate the damping and stochastic variance matrices from exit end of ele1 to the exit end of ele2. Use ele1 = ele2 to get 1-turn matrices.

If ele2 is before ele1 the integration range if from ele1 to the branch end plus from the beginning to ele2.

Note: The ele%mat6 matrices will be remade. By convention, these matrices do not include damping.

Parameters:
  • ele1 (EleStruct) –

    Start element of integration range.

  • ele2 (EleStruct) –

    End element of integration range.

  • include_opening_angle (bool) –

    If True include the effect of the vertical opening angle of emitted radiation. Generally use True unless comparing against other codes.

  • closed_orbit (1D array of CoordStruct) –

    Closed orbit. If not present this routine will calculate it.

Returns:
  • rmap( RadMapStruct ) –

    Damping and stochastic mats

  • mode( NormalModesStruct ) –
  • xfer_nodamp_mat( 2D array of float (shape: 6,6) ) –

    Transfer matrix without damping.

  • err_flag( bool ) –

    Set true if there is a problem.

  • rad_int_branch( (RadIntBranchStruct, optional) ) –

    Array of element-by-element radiation integrals.

rad_g_integrals

Fortran source: bmad/modules/rad_6d_mod.f90

rad_g_integrals(ele: pybmad._pybmad.EleStruct, where: typing.SupportsInt | typing.SupportsIndex, orb_in: pybmad._pybmad.CoordStruct, orb_out: pybmad._pybmad.CoordStruct, int_g2: typing.SupportsFloat | typing.SupportsIndex, g_tol: typing.SupportsFloat | typing.SupportsIndex, g2_tol: typing.SupportsFloat | typing.SupportsIndex, g3_tol: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.RadGIntegrals

Subroutine rad_g_integrals (ele, where, orb_in, orb_out, int_g, int_g2, int_g3, g_tol, g2_tol, g3_tol)

Routine to calculate bending strength integrals (g(s) = 1/trajectory_bending_radius(s)) in laboratory coords.

Parameters:
  • ele (EleStruct) –

    Element under consideration.

  • where (int) –

    What part of ele to integrate over. upstream$ -> 1st half of element, downsteam$ -> 2nd half, all$ -> everything.

  • orb_in (CoordStruct) –

    Entrance orbit about which to compute the matrices.

  • orb_out (CoordStruct) –

    Exit orbit.

  • g_tol (float) –

    Tollerance on |g| per unit length.

  • g2_tol (float) –

    Tollerance on g^2 per unit length.

  • g3_tol (float) –

    Tollerance on g^3 per unit length.

Returns:
  • int_g( 1D array of float (shape: 2) ) –

    Integrals of (gx,gy) vector.

  • int_g3( float ) –

    integrals of |g|^2 and |g|^3.

radiation_integrals

Fortran source: bmad/modules/bmad_routine_interface.f90

radiation_integrals(lat: pybmad._pybmad.LatStruct, orbit: pybmad._pybmad.CoordStructArray1D, ix_cache: typing.SupportsInt | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.RadiationIntegrals

Wrapper for Fortran routine radiation_integrals

Parameters:
  • lat (LatStruct) –

    Lattice to use. The calculation assumes that the Twiss parameters have been calculated.

  • orbit (1D array of CoordStruct) –

    Closed orbit for the branch.

  • ix_cache (int) –

    Cache pointer. This parameter is an input/output and is modified in-place. As an output, ix_cache: Cache pointer. If ix_cache = 0 at input then

  • ix_branch (int) –

    Lattice branch index. Default is 0.

Returns:
  • mode( NormalModesStruct ) –

    Parameters for the ("horizontal like") a-mode, ("vertical like") b-mode, and the z-mode

  • ix_cache( (int, optional) ) –

    Cache pointer. This parameter is an input/output and is modified in-place. As an output, ix_cache: Cache pointer. If ix_cache = 0 at input then

  • rad_int_by_ele( (RadIntAllEleStruct, optional) ) –

    Radiation integrals element by element.

radiation_map_setup

Fortran source: bmad/modules/radiation_mod.f90

radiation_map_setup(ele: pybmad._pybmad.EleStruct, ref_orbit_in: pybmad._pybmad.CoordStruct | None = None) -> bool

Subroutine radiation_map_setup (ele, err_flag, ref_orbit_in)

Routine to calculate the radiation kick for a lattice element.

Parameters:
  • ele (EleStruct) –

    Element whose map is to be setup. This parameter is an input/output and is modified in-place. As an output, ele: Element with map calculated.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

ramper_slave_setup

Fortran source: bmad/modules/bmad_routine_interface.f90

ramper_slave_setup(lat: pybmad._pybmad.LatStruct, force_setup: bool | None = None) -> None

Wrapper for Fortran routine ramper_slave_setup

Parameters:
  • lat (LatStruct) –

    Lattice to be setup. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with ramper slaves setup.

  • force_setup (bool) –

    Default False. If True, do the setup even if lat.ramper_slave_bookkeeping = ok\(. But the setup will never be done if lat.ramper_slave_bookkeeping = super_ok\).

ramper_value

Fortran source: bmad/modules/bmad_routine_interface.f90

ramper_value(ramper: pybmad._pybmad.EleStruct, r1: pybmad._pybmad.ControlRamp1Struct) -> pybmad._pybmad.RamperValue

Wrapper for Fortran routine ramper_value

Parameters:
Returns:
  • err_flag( bool ) –

    Set True if there is an error, False otherwise.

  • value( float ) –

    Value of the slave function.

randomize_lr_wake_frequencies

Fortran source: bmad/multiparticle/wake_mod.f90

randomize_lr_wake_frequencies(ele: pybmad._pybmad.EleStruct) -> bool

Subroutine randomize_lr_wake_frequencies (ele, set_done)

Routine to randomize the frequencies of the lr wake HOMs according to: freq = freq_in * (1 + lr_freq_spread) * rr) where rr is a Gaussian distributed random number with unit variance.

Parameters:
  • ele (EleStruct) –

    Element with wake. If no wake then nothing is done. This parameter is an input/output and is modified in-place. As an output, ele: Element with wake frequencies set.

Returns:
  • set_done( (bool, optional) ) –

    Set True if there where lr wakes to be set. False otherwise.

rchomp

Fortran source: bmad/output/write_lattice_file_mod.f90

rchomp(rel: typing.SupportsFloat | typing.SupportsIndex, plc: typing.SupportsInt | typing.SupportsIndex, out: str) -> None

Wrapper for Fortran routine rchomp

Parameters:
  • rel (float) –
  • plc (int) –
  • out (str) –

re_allocate

Fortran sources (overloaded):

re_allocate(args, *kwargs) Overloaded function.

  1. re_allocate(section: pybmad._pybmad.Wall3DSectionStructAlloc1D, n: typing.SupportsInt | typing.SupportsIndex, exact: bool | None = None) -> None

Wrapper for Fortran routine re_allocate_wall3d_section_array

Parameters:
  • section (1D array of Wall3dSectionStruct) –
  • n (int) –
  • exact (bool) –
  • Wrapper
Parameters:
  • v (1D array of Wall3dVertexStruct) –
  • n (int) –
  • exact (bool) –

re_allocate_eles

Fortran source: bmad/modules/bmad_routine_interface.f90

re_allocate_eles(eles: pybmad._pybmad.ElePointerStructAlloc1D, n: typing.SupportsInt | typing.SupportsIndex, save_old: bool | None = None, exact: bool | None = None) -> None

Wrapper for Fortran routine re_allocate_eles

Parameters:
  • eles (1D array of ElePointerStruct) –

    Array of element pointers with possible old data. This parameter is an input/output and is modified in-place. As an output, eles: Array of element pointers.

  • n (int) –

    Array size to set.

  • save_old (bool) –

    If present and True then save the old data.

  • exact (bool) –

    If present and True then eles will have size = n If False (default), reallcation will not be done if eles is already large enough

re_associate_node_array

Fortran source: bmad/modules/expression_mod.f90

re_associate_node_array(tree: pybmad._pybmad.ExpressionTreeStruct, n: typing.SupportsInt | typing.SupportsIndex, exact: bool | None = None) -> None

Subroutine re_associate_node_array(tree, n, exact)

Routine to resize the tree%node(:) array.

Note: The data of the array is preserved but data at the end of the array will be lost if n is less than the original size of the array

Parameters:
  • tree (ExpressionTreeStruct) –
  • n (int) –

    Size wanted.

  • exact (bool) –

    Default is False. If False, the size of the output array is permitted to be larger than n.

re_str

Fortran sources (overloaded):

re_str(args, *kwargs) Overloaded function.

  1. re_str(rel: typing.SupportsFloat | typing.SupportsIndex, str_out: str) -> None

Wrapper for Fortran routine re_str_qp

Parameters:
  • rel (float) –
  • str_out (str) –
  • Wrapper
Parameters:
  • rel (float) –
  • str_out (str) –

read_beam_ascii

Fortran source: bmad/multiparticle/beam_file_io.f90

read_beam_ascii(file_name: str, beam_init: pybmad._pybmad.BeamInitStruct) -> pybmad._pybmad.ReadBeamAscii

Subroutine read_beam_ascii (file_name, beam, beam_init, err_flag, ele, print_mom_shift_warning, conserve_momentum)

Subroutine to read in a beam definition file. If non_zero, the following components of beam_init are used to rescale the beam: %n_bunch %n_particle %charge_tot

If the beam file has '.h5' or '.hdf5' suffix then the file is taken to be an HDF5 file. Otherwise the file is assumed to be ASCII.

Parameters:
  • file_name (str) –

    Name of beam file.

  • beam_init (BeamInitStruct) –

    See above.

Returns:
  • beam( BeamStruct ) –

    Structure holding the beam information.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

read_beam_file

Fortran source: bmad/multiparticle/beam_file_io.f90

read_beam_file(file_name: str, beam_init: pybmad._pybmad.BeamInitStruct, ele: pybmad._pybmad.EleStruct | None = None, print_mom_shift_warning: bool | None = None, conserve_momentum: bool | None = None) -> pybmad._pybmad.ReadBeamFile

Subroutine read_beam_file (file_name, beam, beam_init, err_flag, ele, print_mom_shift_warning, conserve_momentum)

Subroutine to read in a beam definition file. If non_zero, the following components of beam_init are used to rescale the beam: %n_bunch %n_particle %bunch_charge -> charge_tot %species

If the beam file has '.h5' or '.hdf5' suffix then the file is taken to be an HDF5 file. Otherwise the file is assumed to be ASCII.

Parameters:
  • file_name (str) –

    Name of beam file.

  • beam_init (BeamInitStruct) –

    See above.

  • ele (EleStruct) –

    Element with reference energy, etc.

  • print_mom_shift_warning (bool) –

    Default is True. See hdf5_read_beam doc. Only used when reading hdf5 file.

Returns:
  • beam( BeamStruct ) –

    Structure holding the beam information.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

read_binary_cartesian_map

Fortran source: bmad/parsing/binary_parser_mod.f90

read_binary_cartesian_map(file_name: str, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.ReadBinaryCartesianMap

Subroutine read_binary_cartesian_map (file_name, ele, cart_map, err_flag)

Routine to read a binary cartesian_map structure.

Parameters:
  • file_name (str) –

    File to create.

  • ele (EleStruct) –

    Element associated with the map.

Returns:
  • cart_map( CartesianMapStruct ) –

    cartesian_map_struct, cartesian map.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

read_binary_cylindrical_map

Fortran source: bmad/parsing/binary_parser_mod.f90

read_binary_cylindrical_map(file_name: str, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.ReadBinaryCylindricalMap

Subroutine read_binary_cylindrical_map (file_name, ele, cl_map, err_flag)

Routine to read a binary cylindrical_map structure.

Parameters:
  • file_name (str) –

    File to create.

  • ele (EleStruct) –

    Element associated with the map.

Returns:
  • cl_map( CylindricalMapStruct ) –

    cylindrical_map_struct, cylindrical map.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

read_binary_grid_field

Fortran source: bmad/parsing/binary_parser_mod.f90

read_binary_grid_field(file_name: str, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.ReadBinaryGridField

Subroutine read_binary_grid_field (file_name, ele, g_field, err_flag)

Routine to read a binary grid_field structure.

Parameters:
  • file_name (str) –

    File to create.

  • ele (EleStruct) –

    Element associated with the map.

Returns:
  • g_field( GridFieldStruct ) –

    grid_field_struct, cylindrical map.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

read_digested_bmad_file

Fortran source: bmad/modules/bmad_routine_interface.f90

read_digested_bmad_file(digested_file: str) -> pybmad._pybmad.ReadDigestedBmadFile

Wrapper for Fortran routine read_digested_bmad_file

Parameters:
  • digested_file (str) –

    Name of the digested file.

Returns:
  • lat( LatStruct ) –

    Output lattice structure

  • inc_version( int ) –

    bmad version number stored in the lattice file. If the file is current this number should be the same as the global parameter bmad_inc_version$. Set to -1 if there is a read error.

  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

  • parser_calling( (bool, optional) ) –

    Is this routine being called from a parser routine (like bmad_parser)? Default is False. This argument determines what are considered errors. For example, a moved digested file is considered an error if this routine is called from a parser but not otherwise. The reason for this dichotomy is that a parser is able to reread the original lattice file.

  • lat_files( 1D array of str, optional ) –

    List of Bmad lattice files that defined this lattice.

read_surface_reflection_file

Fortran source: bmad/photon/photon_reflection_mod.f90

read_surface_reflection_file(file_name: str) -> pybmad._pybmad.PhotonReflectSurfaceStruct

Subroutine read_surface_reflection_file (file_name, surface)

Routine to read the reflection probability data for a given type of surface from a file.

Parameters:
  • file_name (str) –

    Name of the file.

Returns:

reallocate_beam

Fortran source: bmad/modules/bmad_routine_interface.f90

reallocate_beam(beam: pybmad._pybmad.BeamStruct, n_bunch: typing.SupportsInt | typing.SupportsIndex, n_particle: typing.SupportsInt | typing.SupportsIndex | None = None, extend: bool | None = None) -> None

Wrapper for Fortran routine reallocate_beam

Parameters:
  • beam (BeamStruct) –

    Beam bunches are saved if save = True. This parameter is an input/output and is modified in-place. As an output, beam: Allocated beam_struct structure.

  • n_bunch (int) –

    Number of bunches.

  • n_particle (int) –

    Number of particles. Must be non-negative. If save = True then the number of particles in existing bunches will not be touched. If not present, beam.bunch(i).particle(:) will be in an undefined state.

  • extend (bool) –

reallocate_bp_com_const

Fortran source: bmad/parsing/bmad_parser_mod.f90

reallocate_bp_com_const() -> None

Wrapper for Fortran routine reallocate_bp_com_const

reallocate_bunch

Fortran source: bmad/modules/bmad_routine_interface.f90

reallocate_bunch(n_particle: typing.SupportsInt | typing.SupportsIndex, save: bool | None = None) -> pybmad._pybmad.BunchStruct

Wrapper for Fortran routine reallocate_bunch

Parameters:
  • n_particle (int) –

    Number of particles. Must be non-negative.

  • save (bool) –

    If present and True then save the old bunch info.

Returns:
  • bunch( BunchStruct ) –

    Allocated bunch_struct structure.

reallocate_control

Fortran source: bmad/modules/bmad_routine_interface.f90

reallocate_control(lat: pybmad._pybmad.LatStruct, n: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine reallocate_control

Parameters:
  • lat (LatStruct) –

    Lattice.

  • n (int) –

    Array size for lat.control(:) and lat.ic(:).

reallocate_coord

Fortran sources (overloaded):

reallocate_coord(args, *kwargs) Overloaded function.

  1. reallocate_coord(coord_array: pybmad._pybmad.CoordArrayStructAlloc1D, lat: pybmad._pybmad.LatStruct) -> None

Subroutine reallocate_coord (...)

Routine to allocate or reallocate at allocatable coord_struct array. reallocate_coord is an overloaded name for: reallocate_coord_n (coord, n_coord) reallocate_coord_lat (coord, lat, ix_branch)

Subroutine to allocate an allocatable coord_struct array to at least: coord(0:n_coord) if n_coord arg is used. coord(0:lat%branch(ix_branch)%n_ele_max) if lat arg is used.

The old coordinates are saved If, at input, coord(:) is not allocated, coord(0)%vec is set to zero. In any case, coord(n)%vec for n > 0 is set to zero.

Parameters:
  • lat (LatStruct) –

    Lattice

  • Subroutine
  • Routine
  • reallocate_coord

    reallocate_coord_n (coord, n_coord) reallocate_coord_lat (coord, lat, ix_branch)

  • Subroutine

    coord(0:n_coord) if n_coord arg is used. coord(0:lat%branch(ix_branch)%n_ele_max) if lat arg is used.

  • The
  • If
  • at
  • In
Parameters:
  • coord (1D array of CoordStruct) –

    Allocatable array. This parameter is an input/output and is modified in-place. As an output, coord: Allocated array.

  • lat (LatStruct) –

    Lattice

  • ix_branch (int) –

    Branch to use. Default is 0 (main branch).

  • Subroutine
  • Routine
  • reallocate_coord

    reallocate_coord_n (coord, n_coord) reallocate_coord_lat (coord, lat, ix_branch)

  • Subroutine

    coord(0:n_coord) if n_coord arg is used. coord(0:lat%branch(ix_branch)%n_ele_max) if lat arg is used.

  • The
  • If
  • at
  • In
Parameters:
  • coord (1D array of CoordStruct) –

    Allocatable array. This parameter is an input/output and is modified in-place. As an output, coord: Allocated array.

  • n_coord (int) –

    Minimum array upper bound wanted.

reallocate_expression_stack

Fortran source: bmad/modules/bmad_routine_interface.f90

reallocate_expression_stack(stack: pybmad._pybmad.ExpressionAtomStructAlloc1D, n: typing.SupportsInt | typing.SupportsIndex, exact: bool | None = None) -> None

Wrapper for Fortran routine reallocate_expression_stack

Parameters:
  • stack (1D array of ExpressionAtomStruct) –

    Existing stack array. This parameter is an input/output and is modified in-place. As an output, stack: Resized stack.

  • n (int) –

    Array size needed.

  • exact (bool) –

    If present and False then the size of the output array is permitted to be larger than n. Default is True.

rel_tracking_charge_to_mass

Fortran source: bmad/modules/bmad_routine_interface.f90

rel_tracking_charge_to_mass(orbit: pybmad._pybmad.CoordStruct, ref_species: typing.SupportsInt | typing.SupportsIndex) -> float

Wrapper for Fortran routine rel_tracking_charge_to_mass

Parameters:
  • orbit (CoordStruct) –

    Particle position structure.

  • ref_species (int) –

    Reference species

Returns:
  • rel_charge( float ) –

    Relative charge/mass

relative_mode_flip

Fortran source: bmad/modules/bmad_routine_interface.f90

relative_mode_flip(ele1: pybmad._pybmad.EleStruct, ele2: pybmad._pybmad.EleStruct, func_retval__: bool) -> None

Wrapper for Fortran routine relative_mode_flip

Parameters:

release_rad_int_cache

Fortran source: bmad/modules/radiation_mod.f90

release_rad_int_cache(ix_cache: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.ReleaseRadIntCache

Subroutine release_rad_int_cache (ix_cache)

Subroutine to release the memory associated with caching wiggler values. See the radiation_integrals routine for further details.

Parameters:
  • ix_cache (int) –

    Cache number. This parameter is an input/output and is modified in-place. As an output, ix_cache: Cache number set to 0,

Returns:
  • ix_cache( int ) –

    Cache number. This parameter is an input/output and is modified in-place. As an output, ix_cache: Cache number set to 0,

remove_constant_taylor

Fortran source: bmad/ptc/ptc_interface_mod.f90

remove_constant_taylor(taylor_in: pybmad._pybmad.TaylorStructArray1D, taylor_out: pybmad._pybmad.TaylorStructArray1D, c0: pybmad._pybmad.RealArray1D, remove_higher_order_terms: bool) -> None

Subroutine remove_constant_taylor (taylor_in, taylor_out, c0, remove_higher_order_terms)

Subroutine to remove the constant part of a taylor map. Optionally terms that are higher order than bmad_com%taylor_order can be removed.

Note: It is assumed that taylor_out has been deallocated before the call to this routine. Calling this routine with the first two actual arguments the same is prohibited.

Parameters:
  • taylor_in (1D array of TaylorStruct) –

    Input taylor map.

  • taylor_out (1D array of TaylorStruct) –

    Taylor with constant terms removed.

  • c0 (1D array of float) –

    The constant part of the taylor map

  • remove_higher_order_terms (bool) –

    If True then terms that are higher order than bmad_com.taylor_order are removed.

remove_dead_from_bunch

Fortran source: bmad/modules/bmad_routine_interface.f90

remove_dead_from_bunch(bunch_in: pybmad._pybmad.BunchStruct) -> pybmad._pybmad.BunchStruct

Wrapper for Fortran routine remove_dead_from_bunch

Parameters:
  • bunch_in (BunchStruct) –

    Input bunch with alive and dead particles.

Returns:
  • bunch_out( BunchStruct ) –

    Output bunch with only alive and pre_born particles. Note: bunch_out can be the same actual argument as bunch_in.

remove_eles_from_lat

Fortran source: bmad/modules/bmad_routine_interface.f90

remove_eles_from_lat(lat: pybmad._pybmad.LatStruct, check_sanity: bool | None = None) -> None

Wrapper for Fortran routine remove_eles_from_lat

Parameters:
  • lat (LatStruct) –

    Lattice to compress. This parameter is an input/output and is modified in-place. As an output, lat: Compressed lattice.

  • check_sanity (bool) –

    If True (default) then call lat_sanity_check

Fortran source: bmad/modules/bmad_routine_interface.f90

remove_lord_slave_link(lord: pybmad._pybmad.EleStruct, slave: pybmad._pybmad.EleStruct) -> None

Wrapper for Fortran routine remove_lord_slave_link

Parameters:
  • lord (EleStruct) –

    Lord element This parameter is an input/output and is modified in-place. As an output, lord: Lord element with link info removed

  • slave (EleStruct) –

    Slave element This parameter is an input/output and is modified in-place. As an output, slave: Slave element with link info removed

reverse_lat

Fortran source: bmad/modules/bmad_routine_interface.f90

reverse_lat(lat_in: pybmad._pybmad.LatStruct, track_antiparticle: bool | None = None) -> pybmad._pybmad.LatStruct

Wrapper for Fortran routine reverse_lat

Parameters:
  • lat_in (LatStruct) –

    Input lattice to reverse.

  • track_antiparticle (bool) –

    Set the particle species of the reversed lat to the anti-particle of lat_in? Default is True.

Returns:

rf_coupler_kick

Fortran source: bmad/modules/bmad_routine_interface.f90

rf_coupler_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, phase: typing.SupportsFloat | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

No longer in the codebase function rf_clock_setup (branch, n_rf_included, n_rf_excluded) result (ok) import implicit none type (branch_struct), target :: branch integer n_rf_included, n_rf_excluded logical ok end function

Parameters:
  • ele (EleStruct) –

    Element being tracked through

  • param (LatParamStruct) –

    branch parameters.

  • particle_at (int) –

    first_track_edge\(, or second_track_edge\).

  • phase (float) –

    phase of cavity

  • orbit (CoordStruct) –

    Position before kick. This parameter is an input/output and is modified in-place. As an output, orbit: Position after kick.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix through the element.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

rf_is_on

Fortran source: bmad/modules/bmad_routine_interface.f90

rf_is_on(branch: pybmad._pybmad.BranchStruct, ix_ele1: typing.SupportsInt | typing.SupportsIndex | None = None, ix_ele2: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine rf_is_on

Parameters:
  • branch (BranchStruct) –

    Lattice branch to check.

  • ix_ele1 (int) –

    Start of range of elements to check. Default is 0.

  • ix_ele2 (int) –

    End of range of elements to check. Default is branch.n_ele_track.

Returns:
  • is_on( bool ) –

    True if any rfcavity is powered. False otherwise.

rf_ref_time_offset

Fortran source: bmad/modules/bmad_routine_interface.f90

rf_ref_time_offset(ele: pybmad._pybmad.EleStruct, ds: typing.SupportsFloat | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine rf_ref_time_offset

Parameters:
  • ele (EleStruct) –

    RF Element being tracked through.

  • ds (float) –

    Distance of particle from start edge. Default is zero.

Returns:
  • time( float ) –

    Offset time.

rfun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

rfun(u: typing.SupportsFloat | typing.SupportsIndex, v: typing.SupportsFloat | typing.SupportsIndex, w: typing.SupportsFloat | typing.SupportsIndex, gam: typing.SupportsFloat | typing.SupportsIndex, a: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, hz: typing.SupportsFloat | typing.SupportsIndex, i: typing.SupportsInt | typing.SupportsIndex, j: typing.SupportsInt | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine rfun

Parameters:
  • u (float) –
  • v (float) –
  • w (float) –
  • gam (float) –
  • a (float) –
  • b (float) –
  • hz (float) –
  • i (int) –
  • j (int) –
  • res (float) –

rk_adaptive_time_step

Fortran source: bmad/modules/time_tracker_mod.f90

rk_adaptive_time_step(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orb: pybmad._pybmad.CoordStruct, t_dir: typing.SupportsInt | typing.SupportsIndex, rf_time: typing.SupportsFloat | typing.SupportsIndex, dt_try: typing.SupportsFloat | typing.SupportsIndex, dt_did: typing.SupportsFloat | typing.SupportsIndex, dt_next: typing.SupportsFloat | typing.SupportsIndex, err_flag: bool, extra_field: pybmad._pybmad.EmFieldStruct | None = None) -> None

Wrapper for Fortran routine rk_adaptive_time_step

Parameters:

rk_time_step1

Fortran source: bmad/modules/time_tracker_mod.f90

rk_time_step1(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, rf_time: typing.SupportsFloat | typing.SupportsIndex, orb: pybmad._pybmad.CoordStruct, dt: typing.SupportsFloat | typing.SupportsIndex, new_orb: pybmad._pybmad.CoordStruct, err_flag: bool, dr_dt: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(10)"] | None = None, print_err: bool | None = None, extra_field: pybmad._pybmad.EmFieldStruct | None = None) -> typing.Annotated[list[float], "FixedSize(10)"]

Wrapper for Fortran routine rk_time_step1

Parameters:
Returns:
  • r_err( 1D array of float (shape: 10) ) –

rotate3

Fortran source: bmad/interface/astra_interface_mod.f90

rotate3(vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], angle: typing.SupportsFloat | typing.SupportsIndex, rvec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> None

Wrapper for Fortran routine rotate3

Parameters:
  • vec (1D array of float (shape: 3)) –
  • angle (float) –
  • rvec (1D array of float (shape: 3)) –

rotate_em_field

Fortran source: bmad/modules/em_field_mod.f90

rotate_em_field(field: pybmad._pybmad.EmFieldStruct, w_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"], w_inv: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"], calc_dfield: bool | None = None, calc_potential: bool | None = None) -> None

Subroutine rotate_em_field (field, w_mat, w_inv, calc_dfield, calc_potential)

Routine to transform the fields using the given rotation matrices.

Parameters:
  • field (EmFieldStruct) –

    E and B fields and derivatives.

  • w_mat (2D array of float (shape: 3,3)) –

    rotation matrix.

  • w_inv (2D array of float (shape: 3,3)) –

    rotation matrix inverse = transpose(w_mat)

  • calc_dfield (bool) –

    If present and True then rotate the field derivatives.

  • calc_potential (bool) –

    Rotate the magnetic vector potential? Default is false.

rotate_field_zx

Fortran source: bmad/interface/gpt_interface_mod.f90

rotate_field_zx(field: pybmad._pybmad.EmFieldStruct, theta: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine rotate_field_zx

Parameters:

rotate_for_curved_surface

Fortran source: bmad/modules/bmad_routine_interface.f90

rotate_for_curved_surface(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, set: bool, rot_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"]) -> None

Wrapper for Fortran routine rotate_for_curved_surface

Parameters:
  • ele (EleStruct) –

    reflecting element

  • orbit (CoordStruct) –

    Photon position.

  • set (bool) –

    True -> Transform body coords to local curved body coords. False -> Transform local curved body to body coords.

  • rot_mat (2D array of float (shape: 3,3)) –

    When set = False, rotation matrix calculated from previous call with set = True. This parameter is an input/output and is modified in-place. As an output, rot_mat: When set = True, calculated rotation matrix.

rotate_spin

Fortran source: bmad/modules/bmad_routine_interface.f90

rotate_spin(rot_vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], spin: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> typing.Annotated[list[float], "FixedSize(4)"]

Wrapper for Fortran routine rotate_spin

Parameters:
  • rot_vec (1D array of float (shape: 3)) –

    Rotation axis. Magnitude of rot_vec is the rotation angle.

  • spin (1D array of float (shape: 3)) –

    Initial coords. This parameter is an input/output and is modified in-place. As an output, spin: Final coords.

Returns:
  • qrot( 1D array of float (shape: 0:3), optional ) –

    : rotation quaternion.

rotate_spin_a_step

Fortran source: bmad/modules/bmad_routine_interface.f90

rotate_spin_a_step(orbit: pybmad._pybmad.CoordStruct, field: pybmad._pybmad.EmFieldStruct, ele: pybmad._pybmad.EleStruct, ds: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine rotate_spin_a_step

Parameters:
  • orbit (CoordStruct) –

    Initial orbit. This parameter is an input/output and is modified in-place. As an output, orbit: Orbit with rotated spin

  • field (EmFieldStruct) –

    EM Field

  • ele (EleStruct) –

    ele_struct, Element being tracked through.

  • ds (float) –

    Longitudinal step in element body frame.

rotate_spin_given_field

Fortran source: bmad/modules/bmad_routine_interface.f90

rotate_spin_given_field(orbit: pybmad._pybmad.CoordStruct, sign_z_vel: typing.SupportsInt | typing.SupportsIndex, BL: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None, EL: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None, qrot: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None) -> None

Wrapper for Fortran routine rotate_spin_given_field

Parameters:
  • orbit (CoordStruct) –

    Initial orbit. This parameter is an input/output and is modified in-place. As an output, orbit: Orbit with rotated spin

  • sign_z_vel (int) –

    +/- 1. Sign of direction of travel relative to the element.

  • BL (1D array of float (shape: 3)) –

    Integrated field strength. Assumed zero if not present.

  • EL (1D array of float (shape: 3)) –

    Integrated field strength. Assumed zero if not present.

  • qrot (1D array of float (shape: 0:3)) –

    Initial rotation quaternion. This parameter is an input/output and is modified in-place. As an output, qrot: Rotation quaternion with rotation due to the field added in.

s_body_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

s_body_calc(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> float

Wrapper for Fortran routine s_body_calc

Parameters:
Returns:
  • s_body( float ) –

    Body postion.

s_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

s_calc(lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine s_calc

Parameters:

sad_mult_hard_bend_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

sad_mult_hard_bend_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine sad_mult_hard_bend_edge_kick (ele, param, particle_at, orbit, mat6, make_matrix)

Routine to track through the hard edge bend fringe field for a bend or sad_mult element. Only the bend field is taken into account here. Higher order multipolse must be handled elsewhere.

This routine assumes that the particle coordinates are with respect to the actual magnet face. Thus finite e1/e2 must be taken into account by other routines.

SAD calls this the "linear" fringe even though it is nonlinear.

Parameters:
  • ele (EleStruct) –

    Element with fringe.

  • param (LatParamStruct) –

    Tracking parameters.

  • particle_at (int) –

    Either first_track_edge$ or second_track_edge$.

  • orbit (CoordStruct) –

    Starting coordinates. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coordinates.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the fringe. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix including the fringe.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

sad_soft_bend_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

sad_soft_bend_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orb: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine sad_soft_bend_edge_kick (ele, param, particle_at, orb, mat6, make_matrix)

Subroutine to track through the ("linear") bend soft edge field of an sbend or sad_mult.

Parameters:
  • ele (EleStruct) –

    SBend or sad_mult element.

  • param (LatParamStruct) –
  • particle_at (int) –

    first_track_edge\(, or second_track_edge\).

  • orb (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orb: Coords after tracking.

  • mat6 (2D array of float (shape: 6,6)) –

    Starting matrix This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix after fringe field

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

save_a_beam_step

Fortran source: bmad/modules/bmad_routine_interface.f90

save_a_beam_step(ele: pybmad._pybmad.EleStruct, beam: pybmad._pybmad.BeamStruct, bunch_tracks: pybmad._pybmad.BunchTrackStructArray1D | None = None, s_body: typing.SupportsFloat | typing.SupportsIndex | None = None, is_time_coords: bool | None = None) -> None

Wrapper for Fortran routine save_a_beam_step

Parameters:
  • ele (EleStruct) –

    Element being tracked through.

  • beam (BeamStruct) –

    Bunches in the beam whose parameters are to be saved.

  • bunch_tracks (1D array of BunchTrackStruct) –

    Track up to now. If bunch_tracks.n_pt < 0, the structure will be reinitialized. This parameter is an input/output and is modified in-place. As an output, bunch_tracks: Track with current bunch info appended on. This routine does nothing

  • s_body (float) –

    Body s-position from beginning of element.

  • is_time_coords (bool) –

    Default is False. If True, input beam is using time coordinates in which case there will be a conversion to s-coords before bunch_params are computed.

save_a_bunch_step

Fortran source: bmad/modules/bmad_routine_interface.f90

save_a_bunch_step(ele: pybmad._pybmad.EleStruct, bunch: pybmad._pybmad.BunchStruct, bunch_track: pybmad._pybmad.BunchTrackStruct | None = None, s_body: typing.SupportsFloat | typing.SupportsIndex | None = None, is_time_coords: bool | None = None) -> None

Wrapper for Fortran routine save_a_bunch_step

Parameters:
  • ele (EleStruct) –

    Element being tracked through.

  • bunch (BunchStruct) –

    Bunch whose parameters are to be saved.

  • bunch_track (BunchTrackStruct) –

    Track up to now. If bunch_track.n_pt < 0, the structure will be reinitialized. This parameter is an input/output and is modified in-place. As an output, bunch_track: Track with current bunch info appended on. This routine does nothing

  • s_body (float) –

    Body s-position from beginning of element.

  • is_time_coords (bool) –

    Default is False. If True, input bunch is using time coordinates in which case there will be a conversion to s-coords before bunch_params are computed.

save_a_step

Fortran source: bmad/modules/bmad_routine_interface.f90

save_a_step(track: pybmad._pybmad.TrackStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, local_ref_frame: bool, orb: pybmad._pybmad.CoordStruct, s_rel: typing.SupportsFloat | typing.SupportsIndex, save_field: bool | None = None, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None, rf_time: typing.SupportsFloat | typing.SupportsIndex | None = None, strong_beam: pybmad._pybmad.StrongBeamStruct | None = None) -> None

Wrapper for Fortran routine save_a_step

Parameters:
  • track (TrackStruct) –

    Track up to now. If track.n_pt < 0, the structure will be reinitialized. This parameter is an input/output and is modified in-place. As an output, track: Track with current position appended on.

  • ele (EleStruct) –

    Element being tracked through.

  • param (LatParamStruct) –

    Lattice parameters.

  • local_ref_frame (bool) –

    If True then input orb is with respect to body coordinates.

  • orb (CoordStruct) –

    trajectory at s with respect to element coordinates.

  • s_rel (float) –

    Longitudinal position wrt the element. If local_ref_frame = F: Lab coords. If local_ref_frame = T: body coords.

  • save_field (bool) –

    Save electric and magnetic field values? Default is False.

  • mat6 (2D array of float (shape: 6,6)) –

    Matrix to store.

  • make_matrix (bool) –

    Is mat6 a valid matrix? Default is False.

  • rf_time (float) –

    RF clock time used for calculating the field.. If not present then the time will be calculated using the standard algorithm. This is only needed if save_field = True.

  • strong_beam (StrongBeamStruct) –

    Strong beam info if tracking through a beambeam element.

sbend_body_with_k1_map

Fortran source: bmad/modules/bmad_routine_interface.f90

sbend_body_with_k1_map(ele: pybmad._pybmad.EleStruct, dg: typing.SupportsFloat | typing.SupportsIndex, b1: typing.SupportsFloat | typing.SupportsIndex, param: pybmad._pybmad.LatParamStruct, n_step: typing.SupportsInt | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine sbend_body_with_k1_map

Parameters:
  • ele (EleStruct) –

    Sbend element.

  • dg (float) –

    Field error.

  • b1 (float) –

    b1 quadrupole strength * rel_charge_dir

  • param (LatParamStruct) –

    Branch parameters.

  • n_step (int) –

    Number of steps to divide the bend into. Only one step is taken by this routine.

  • orbit (CoordStruct) –

    Orbit at beginning of the bend. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coordinates.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix with body added in.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

sc_adaptive_step

Fortran source: bmad/space_charge/space_charge_mod.f90

sc_adaptive_step(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, include_image: bool, t_now: typing.SupportsFloat | typing.SupportsIndex, dt_step: typing.SupportsFloat | typing.SupportsIndex, sc_field: pybmad._pybmad.EmFieldStructArray1D) -> pybmad._pybmad.ScAdaptiveStep

Subroutine sc_adaptive_step(bunch, ele, include_image, t_now, dt_step, dt_next)

Routine to track a bunch of particles with space charge for one step using adaptive step size control and determine appropriate step size for the next step

Parameters:
  • bunch (BunchStruct) –

    Starting bunch position in t-based coordinates This parameter is an input/output and is modified in-place. As an output, bunch: Ending bunch position in t-based coordinates.

  • ele (EleStruct) –

    Nominal lattice element being tracked through.

  • include_image (bool) –

    Include image charge forces? This parameter is an input/output and is modified in-place. As an output, include_image: Set False if image charge calc no longer needed (Note

  • t_now (float) –

    Current time at the beginning of tracking

  • dt_step (float) –

    Initial SC time step to take This parameter is an input/output and is modified in-place. As an output, dt_step: Step done.

  • sc_field (1D array of EmFieldStruct) –

    : Array to hold space charge fields. Its length should be the number of particles.

Returns:
  • include_image( bool ) –

    Include image charge forces? This parameter is an input/output and is modified in-place. As an output, include_image: Set False if image charge calc no longer needed (Note

  • dt_step( float ) –

    Initial SC time step to take This parameter is an input/output and is modified in-place. As an output, dt_step: Step done.

  • dt_next( float ) –

    Next SC time step the tracker would take based on the error tolerance

sc_step

Fortran source: bmad/space_charge/space_charge_mod.f90

sc_step(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, include_image: bool, t_end: typing.SupportsFloat | typing.SupportsIndex, sc_field: pybmad._pybmad.EmFieldStructArray1D) -> pybmad._pybmad.ScStep

Subroutine sc_step(bunch, ele, include_image, t_end, n_emit)

Subroutine to track a bunch through a given time step with space charge

Parameters:
  • bunch (BunchStruct) –

    Starting bunch position in t-based coordinates This parameter is an input/output and is modified in-place. As an output, bunch: Ending bunch position in t-based coordinates after space charge kick.

  • ele (EleStruct) –

    Nominal element being tracked through.

  • include_image (bool) –

    Include image charge forces? This parameter is an input/output and is modified in-place. As an output, include_image: Set False if image charge calc no longer needed (Note

  • t_end (float) –

    Time at which the tracking ends.

  • sc_field (1D array of EmFieldStruct) –

    : Array to hold space charge fields. Its length should be the number of particles.

Returns:
  • include_image( bool ) –

    Include image charge forces? This parameter is an input/output and is modified in-place. As an output, include_image: Set False if image charge calc no longer needed (Note

  • n_emit( (int, optional) ) –

    The number of particles emitted in this step.

set_active_fixer

Fortran source: bmad/modules/fixer_mod.f90

set_active_fixer(fixer: pybmad._pybmad.EleStruct, turn_on: bool | None = None) -> pybmad._pybmad.CoordStruct

Subroutine set_active_fixer(fixer, turn_on, orbit)

Set the acvitive fixer element. All other fixer/beginning_ele elements in the branch will be deactivated.

If turn_on is True (default), the fixer argument becomes the active fixer. If turn_on is False, and fixer%is_on is also False, there is nothing to be done. If turn_on is False, and fixer%is_on is True, turn this fixer off and turn on the beginning element.

Parameters:
  • fixer (EleStruct) –

    Fixer element to make active. This parameter is an input/output and is modified in-place. As an output, fixer: Element is now active.

  • turn_on (bool) –

    If True (default), make this fixer the active element. If False, make the beginning element active.

Returns:
  • orbit( (CoordStruct, optional) ) –

    Load with stored fixer phase space and spin values.

set_custom_attribute_name

Fortran source: bmad/modules/attribute_mod.f90

set_custom_attribute_name(custom_name: str, custom_index: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Subroutine set_custom_attribute_name (custom_name, err_flag, custom_index)

Routine to add custom element attributes to the element attribute name table.

Parameters:
  • custom_name (str) –

    Name of the custom attribute. If prefixed by "::" then the custom name will be set only for that element class. Example: "quadrupole::error" will set the alias custom namefor quadrupoles.

  • custom_index (int) –

    Index used in assigning where in the ele_struct the custom attribute is put. If not present or 0 then the next unused slot is used.

Returns:
  • err_flag( bool ) –

    Set True if an error. False otherwise.

set_ele_attribute

Fortran source: bmad/modules/bmad_routine_interface.f90

set_ele_attribute(ele: pybmad._pybmad.EleStruct, set_string: str, err_print_flag: bool | None = None, set_lords: bool | None = None) -> pybmad._pybmad.SetEleAttribute

Wrapper for Fortran routine set_ele_attribute

Parameters:
  • ele (EleStruct) –

    Element with attribute to set. This parameter is an input/output and is modified in-place. As an output, ele: Element with attribute set.

  • set_string (str) –

    Attribute and value for set.

  • err_print_flag (bool) –

    If present and False then suppress printing of an error message if attribute is, for example, not free.

  • set_lords (bool) –

    Default False. If True, set the super_lord(s) if the element is a super_slave.

Returns:
  • err_flag( bool ) –

    Set True if there is an error, False otherwise.

  • err_id( (int, optional) ) –

    Set to an integer which identifies the error type. 0 = no error. The higher the error the further along the error was encountered.

set_ele_defaults

Fortran source: bmad/modules/bmad_routine_interface.f90

set_ele_defaults(ele: pybmad._pybmad.EleStruct, do_allocate: bool | None = None) -> None

Wrapper for Fortran routine set_ele_defaults

Parameters:
  • ele (EleStruct) –

    Element to init. This parameter is an input/output and is modified in-place. As an output, ele: Initialized element.

  • do_allocate (bool) –

    Do default allocation of element components? Default is True.

set_ele_name

Fortran source: bmad/modules/bmad_routine_interface.f90

set_ele_name(ele: pybmad._pybmad.EleStruct, name: str) -> None

Wrapper for Fortran routine set_ele_name

Parameters:
  • ele (EleStruct) –

    Element whose name is to be set. This parameter is an input/output and is modified in-place. As an output, ele: Element with name set.

  • name (str) –

    Name to set.

set_ele_real_attribute

Fortran source: bmad/modules/bmad_routine_interface.f90

set_ele_real_attribute(ele: pybmad._pybmad.EleStruct, attrib_name: str, value: typing.SupportsFloat | typing.SupportsIndex, err_print_flag: bool | None = None) -> bool

Wrapper for Fortran routine set_ele_real_attribute

Parameters:
  • ele (EleStruct) –

    Element with attribute to set. This parameter is an input/output and is modified in-place. As an output, ele: Element with attribute set.

  • attrib_name (str) –

    Attribute name.

  • value (float) –

    value to set to.

  • err_print_flag (bool) –

    If present and False then suppress printing of an error message if attribute is, for example, not free.

Returns:
  • err_flag( bool ) –

    Set True if there is an error, False otherwise.

set_ele_status_stale

Fortran source: bmad/modules/bmad_routine_interface.f90

set_ele_status_stale(ele: pybmad._pybmad.EleStruct, status_group: typing.SupportsInt | typing.SupportsIndex, set_slaves: bool | None = None, old_eles: pybmad._pybmad.ElePointerStructAlloc1D | None = None) -> None

Wrapper for Fortran routine set_ele_status_stale

Parameters:
  • ele (EleStruct) –

    Element to set. This parameter is an input/output and is modified in-place. As an output, ele: Element.

  • status_group (int) –

    Which flag groups to set. Possibilities are: attribute_group\(, control_group\), floor_position_group\(, s_position_group\), s_and_floor_position_group\(, ref_energy_group\), or mat6_group\(, all_groups\)

  • set_slaves (bool) –

    If present and False then do not set the status for any slaves. Default is True.

  • old_eles (1D array of ElePointerStruct) –

    List of elements already set. This argument is only used when this routine is called recursively.

set_flags_for_changed_attribute

Fortran sources (overloaded):

set_flags_for_changed_attribute(args, *kwargs) Overloaded function.

  1. set_flags_for_changed_attribute(ele: pybmad._pybmad.EleStruct, attrib: typing.SupportsInt | typing.SupportsIndex, set_dependent: bool | None = None) -> None

Subroutine set_flags_for_changed_attribute (...)

Routine to mark an element or lattice as modified. Also will do some dependent variable bookkeeping when a particular attribute has been altered.

This routine should be called after the attribute has been set.

set_flags_for_changed_attribute is an overloaded name for: set_flags_for_changed_lat_attribute (lat, set_dependent) set_flags_for_changed_real_attribute (ele, real_attrib, set_dependent) set_flags_for_changed_inteter_attribute (ele, int_attrib, set_dependent) set_flags_for_changed_logical_attribute (ele, logic_attrib, set_dependent) set_flags_for_changed_all_attribute (ele, all_attrib, set_dependent)

The set_flags_for_changed_lat_attribute (lat) routine is used when one does not know what has changed and wants a complete bookkeeping done.

NOTE: The attribute argument MUST be the component that was changed. For example: ele%value(x_offset\() = off_value call set_flags_for_changed_attribute (ele, ele%value(x_offset\))) And NOT: call set_flags_for_changed_attribute (ele, off_value) ! WRONG

Parameters:
  • ele (EleStruct) –

    ele_struct, Element being modified.

  • set_dependent (bool) –

    If False then dependent parameter bookkeeping will not be done. False is used, for example, during parsing when dependent bookkeepin is not wanted. Default is True. Do not set False unless you know what you are doing.

  • Subroutine
  • Routine
  • Also
  • been
  • This
  • set_flags_for_changed_attribute

    set_flags_for_changed_lat_attribute (lat, set_dependent) set_flags_for_changed_real_attribute (ele, real_attrib, set_dependent) set_flags_for_changed_inteter_attribute (ele, int_attrib, set_dependent) set_flags_for_changed_logical_attribute (ele, logic_attrib, set_dependent) set_flags_for_changed_all_attribute (ele, all_attrib, set_dependent)

  • The
  • does
  • NOTE

    ele%value(x_offset\() = off_value call set_flags_for_changed_attribute (ele, ele%value(x_offset\)))

  • And

    call set_flags_for_changed_attribute (ele, off_value) ! WRONG

Parameters:
  • lat (LatStruct) –

    Lattice being modified. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with appropriate changes.

  • set_dependent (bool) –

    If False then dependent parameter bookkeeping will not be done. False is used, for example, during parsing when dependent bookkeepin is not wanted. Default is True. Do not set False unless you know what you are doing.

  • Subroutine
  • Routine
  • Also
  • been
  • This
  • set_flags_for_changed_attribute

    set_flags_for_changed_lat_attribute (lat, set_dependent) set_flags_for_changed_real_attribute (ele, real_attrib, set_dependent) set_flags_for_changed_inteter_attribute (ele, int_attrib, set_dependent) set_flags_for_changed_logical_attribute (ele, logic_attrib, set_dependent) set_flags_for_changed_all_attribute (ele, all_attrib, set_dependent)

  • The
  • does
  • NOTE

    ele%value(x_offset\() = off_value call set_flags_for_changed_attribute (ele, ele%value(x_offset\)))

  • And

    call set_flags_for_changed_attribute (ele, off_value) ! WRONG

Parameters:
  • ele (EleStruct) –

    ele_struct, Element being modified.

  • set_dependent (bool) –

    If False then dependent parameter bookkeeping will not be done. False is used, for example, during parsing when dependent bookkeepin is not wanted. Default is True. Do not set False unless you know what you are doing.

  • Subroutine
  • Routine
  • Also
  • been
  • This
  • set_flags_for_changed_attribute

    set_flags_for_changed_lat_attribute (lat, set_dependent) set_flags_for_changed_real_attribute (ele, real_attrib, set_dependent) set_flags_for_changed_inteter_attribute (ele, int_attrib, set_dependent) set_flags_for_changed_logical_attribute (ele, logic_attrib, set_dependent) set_flags_for_changed_all_attribute (ele, all_attrib, set_dependent)

  • The
  • does
  • NOTE

    ele%value(x_offset\() = off_value call set_flags_for_changed_attribute (ele, ele%value(x_offset\)))

  • And

    call set_flags_for_changed_attribute (ele, off_value) ! WRONG

Parameters:
  • ele (EleStruct) –

    ele_struct, Element being modified.

  • set_dependent (bool) –

    If False then dependent parameter bookkeeping will not be done. False is used, for example, during parsing when dependent bookkeepin is not wanted. Default is True. Do not set False unless you know what you are doing.

set_fringe_on_off

Fortran source: bmad/modules/bmad_routine_interface.f90

set_fringe_on_off(fringe_at: typing.SupportsFloat | typing.SupportsIndex, ele_end: typing.SupportsInt | typing.SupportsIndex, on_or_off: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.SetFringeOnOff

Wrapper for Fortran routine set_fringe_on_off

Parameters:
  • fringe_at (float) –

    Present fringe_at setting. entrance_end\(, exit_end\), both_ends\(, or no_end\) This parameter is an input/output and is modified in-place. As an output, fringe_at: Modified fringe setting.

  • ele_end (int) –

    Element edge: entrance_end$ or exit_end$

  • on_or_off (int) –

    Turn on$ or off$

Returns:
  • fringe_at( float ) –

    Present fringe_at setting. entrance_end\(, exit_end\), both_ends\(, or no_end\) This parameter is an input/output and is modified in-place. As an output, fringe_at: Modified fringe setting.

set_lords_status_stale

Fortran source: bmad/modules/bmad_routine_interface.f90

set_lords_status_stale(ele: pybmad._pybmad.EleStruct, stat_group: typing.SupportsInt | typing.SupportsIndex, control_bookkeeping: bool | None = None, flag: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine set_lords_status_stale

Parameters:
  • ele (EleStruct) –

    Element

  • stat_group (int) –

    which status group to set. floor_position_group$, etc. See set_ele_status_stale for more details.

  • control_bookkeeping (bool) –

    Call control_bookkeeper for each lord if needed? Default if False.

  • flag (int) –

    Do not use. For coordinating recursion.

set_on_off

Fortran source: bmad/modules/bmad_routine_interface.f90

set_on_off(key: typing.SupportsInt | typing.SupportsIndex, lat: pybmad.pybmad.LatStruct, switch: typing.SupportsInt | typing.SupportsIndex, orb: pybmad._pybmad.CoordStructArray1D | None = None, use_ref_orb: bool | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, saved_values: pybmad._pybmad.RealAlloc1D | None = None, attribute: str | None = None, set_val: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine set_on_off

Parameters:
  • key (int) –

    Class name of elements to be turned on or off. [quadrupole$, etc.]

  • lat (LatStruct) –

    lattice structure holding the elements. This parameter is an input/output and is modified in-place. As an output, lat: Modified lattice.

  • orb (1D array of CoordStruct) –

    Needed for lat_make_mat6

  • use_ref_orb (bool) –

    If present and true then use ele.map_ref_orb for the reference orbit for calculating .mat6. Default is false.

  • ix_branch (int) –

    If present then only set for this lattice branch.

  • saved_values (1D array of float) –

    Element-by element saved values of the component. Must be present if needed (EG if switch = restore_state$, etc.). This parameter is an input/output and is modified in-place. As an output, saved_values: Saved values of the component.

  • attribute (str) –

    Attribute to turn on/off. Eg: 'K2', 'MULTIPOLE_ON', etc. Default is 'IS_ON'. Must be upper case.

  • set_val (int) –

    Value to set to. Overrides normal set value.

set_orbit_to_zero

Fortran source: bmad/modules/bmad_routine_interface.f90

set_orbit_to_zero(orbit: pybmad._pybmad.CoordStructArray1D, n1: typing.SupportsInt | typing.SupportsIndex, n2: typing.SupportsInt | typing.SupportsIndex, ix_noset: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine set_orbit_to_zero

Parameters:
  • orbit (1D array of CoordStruct) –

    Array with particle positions in the range orbit(n1:n2) set to zero except for orbit(ix_noset).

  • n1 (int) –

    Lower bound of orbit(:) array subset.

  • n2 (int) –

    Upper bound of orbit(:) array subset.

  • ix_noset (int) –

    If present then orbit(ix_noset) will not be zeroed.

set_ptc

Fortran source: bmad/modules/bmad_routine_interface.f90

set_ptc(e_tot: typing.SupportsFloat | typing.SupportsIndex | None = None, particle: typing.SupportsInt | typing.SupportsIndex | None = None, taylor_order: typing.SupportsInt | typing.SupportsIndex | None = None, integ_order: typing.SupportsInt | typing.SupportsIndex | None = None, n_step: typing.SupportsInt | typing.SupportsIndex | None = None, no_cavity: bool | None = None, force_init: bool | None = None) -> None

Wrapper for Fortran routine set_ptc

Parameters:
  • e_tot (float) –

    Energy in eV.

  • particle (int) –

    Type of particle: electron\(, proton\), etc.

  • taylor_order (int) –

    Maximum order of the taylor polynomials. 0 => Use default.

  • integ_order (int) –

    Default Order for the drift-kick-drift sympletic integrator. Possibilities are: 2, 4, or 6 Default = 2

  • n_step (int) –

    Default Number of integration steps. Default = 1

  • no_cavity (bool) –

    No RF Cavity exists? Default = False. Corresponds to the nocavity option of the PTC init routine. no_cavity = .true. will turn any cavity into a drift.

  • force_init (bool) –

    If present and True then force a PTC init.

set_ptc_base_state

Fortran source: bmad/modules/bmad_routine_interface.f90

set_ptc_base_state(component: str, set_val: bool) -> bool

Wrapper for Fortran routine set_ptc_base_state

Parameters:
  • component (str) –

    Name of component. "TOTALPATH", "SPIN", "NOCAVITY", "TIME", etc. See the PTC internal_state structure for component names.

  • set_val (bool) –

    Value to set to. For TOTALPATH, True => 1, False => 0.

Returns:
  • old_val( (bool, optional) ) –

    Old value.

set_ptc_com_pointers

Fortran source: bmad/ptc/ptc_interface_mod.f90

set_ptc_com_pointers() -> None

Subroutine set_ptc_com_pointers ()

Routine to set ptc_com pointers to PTC global variables.

set_ptc_quiet

Fortran source: bmad/ptc/ptc_interface_mod.f90

set_ptc_quiet(channel: typing.SupportsInt | typing.SupportsIndex, set: bool, old_val: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.SetPtcQuiet

Subroutine set_ptc_quiet (channel, set, old_val)

Routine to set the lielib_print(:) array or c_verbose logical to suppress informational messages that can clutter the output from a program using PTC.

Note: Only suppress printing if ptc_com%print_info_messages = F.

Parameters:
  • channel (int) –

    Index in the lielib_print(:) array to set. 0 => c_verbose.

  • set (bool) –

    If set$ then set lielib_print(:). If unset$ then undo a previous set$.

  • old_val (int) –

    Old value needed for set = unset\(. This parameter is an input/output and is modified in-place. As an output, old_val: Saved value for set = set\).

Returns:
  • old_val( int ) –

    Old value needed for set = unset\(. This parameter is an input/output and is modified in-place. As an output, old_val: Saved value for set = set\).

set_ptc_verbose

Fortran source: bmad/ptc/ptc_layout_mod.f90

set_ptc_verbose(on: bool) -> None

Wrapper for Fortran routine set_ptc_verbose

Parameters:
  • on (bool) –

set_pwd_ele

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

set_pwd_ele(lat: pybmad._pybmad.LatStruct, mode0: pybmad._pybmad.NormalModesStruct, inductance: typing.SupportsFloat | typing.SupportsIndex) -> None

Subroutine set_pwd_ele(lat,mode0,inductance)

Simulates the effect of potential well distortion by adjusting lat%ele(ix_pwd)%taylor(6)%term(2)%coef for an element in the lattice. This element will apply a pz kick based on the z coordinate. Element is assumed to be at lat%ele(1). The ibs_ring driver program inserts a taylor element into lat%ele(1) if set to perform pwd calculations.

Parameters:
  • lat (LatStruct) –

    lattice

  • mode0 (NormalModesStruct) –

    .sig_z and .z.sige_e should be populated before calling this subroutine.

  • inductance (float) –

    An inductance-like parameter describing the distortion of the potential well.

set_status_flags

Fortran source: bmad/modules/bmad_routine_interface.f90

set_status_flags(stat: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.BookkeepingStateStruct

Wrapper for Fortran routine set_status_flags

Parameters:
  • stat (int) –

    bookkeeping status. ok\(, stale\), etc.

Returns:

set_tune

Fortran source: bmad/modules/bmad_routine_interface.f90

set_tune(phi_a_set: typing.SupportsFloat | typing.SupportsIndex, phi_b_set: typing.SupportsFloat | typing.SupportsIndex, dk1: pybmad._pybmad.RealArray1D, eles: pybmad._pybmad.ElePointerStructArray1D, branch: pybmad._pybmad.BranchStruct, orb: pybmad._pybmad.CoordStructAlloc1D, print_err: bool | None = None) -> bool

Wrapper for Fortran routine set_tune

Parameters:
  • phi_a_set (float) –

    Horizontal set tune (radians)

  • phi_b_set (float) –

    Vertical set tune (radians)

  • dk1 (1D array of float) –

    Relative amount to vary a quad in tuning. The variation will be proportional to dk1. Those quads with a positive dk1(i) will be varied as one group and the quads with negative dk1(i) will be varied as another group. The routine choose_quads_for_set_tune can be used to calculate values for dk1.

  • eles (1D array of ElePointerStruct) –

    eles(i).ele points to quadrupole corresponding to dk1(i).

  • branch (BranchStruct) –

    Lattice branch to tune. This parameter is an input/output and is modified in-place. As an output, branch: Q_tuned lattice branch

  • orb (1D array of CoordStruct) –

    If RF is off: Energy dE/E at which the tune is computed. This parameter is an input/output and is modified in-place. As an output, orb: New closed orbit.

  • print_err (bool) –

    Print error message if there is a problem? Default is True.

Returns:
  • ok( bool ) –

    Set True if everything is ok. False otherwise.

set_twiss

Fortran source: bmad/modules/bmad_routine_interface.f90

set_twiss(branch: pybmad._pybmad.BranchStruct, twiss_ele: pybmad._pybmad.EleStruct, ix_ele: typing.SupportsInt | typing.SupportsIndex, match_deta_ds: bool, err_flag: bool, print_err: bool | None = None) -> None

Wrapper for Fortran routine set_twiss

Parameters:
  • branch (BranchStruct) –

    Branch to modify.

  • twiss_ele (EleStruct) –

    Element with desired Twiss parameters.

  • ix_ele (int) –

    Match branch.ele(ix_ele) Twiss to twiss_ele.

  • match_deta_ds (bool) –

    If True, match deta_ds. If False, match etap.

  • err_flag (bool) –

    Set True if there is an error. False otherwise.

  • print_err (bool) –

    Print an error message if there is an error? Default is True.

set_z_tune

Fortran source: bmad/modules/bmad_routine_interface.f90

set_z_tune(branch: pybmad._pybmad.BranchStruct, z_tune: typing.SupportsFloat | typing.SupportsIndex, print_err: bool | None = None) -> bool

Wrapper for Fortran routine set_z_tune

Parameters:
  • branch (BranchStruct) –
  • z_tune (float) –

    Longitudinal tune in radians (must be negative above transition).

  • print_err (bool) –

    Default is True. If False, suppress error messages

Returns:
  • ok( (bool, optional) ) –

    If present, returns true or false if set was successful. If not present, set_z_tune will bomb if tune could not be set.

settable_dep_var_bookkeeping

Fortran source: bmad/parsing/bmad_parser_mod.f90

settable_dep_var_bookkeeping(ele: pybmad._pybmad.EleStruct) -> None

Subroutine settable_dep_var_bookkeeping (ele)

Subroutine to initialize dependent variables in an element.

This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

setup_high_energy_space_charge_calc

Fortran source: bmad/space_charge/high_energy_space_charge_mod.f90

setup_high_energy_space_charge_calc(calc_on: bool, branch: pybmad._pybmad.BranchStruct, n_part: typing.SupportsFloat | typing.SupportsIndex, mode: pybmad._pybmad.NormalModesStruct, beam_init: pybmad._pybmad.BeamInitStruct | None = None, closed_orb: pybmad._pybmad.CoordStructArray1D | None = None) -> None

Subroutine setup_high_energy_space_charge_calc (calc_on, branch, n_part, mode, beam_init, closed_orb)

Routine to initialize constants needed by the ultra relativistic space charge tracking routine track1_high_energy_space_charge. This setup routine must be called if the lattice or any of the other input parameters are changed.

Parameters used: a-mode emittance b-mode emittance sig_z bunch length sig_pz relative energy spread

Parameters:
  • calc_on (bool) –

    Turns on or off the space charge calculation.

  • branch (BranchStruct) –

    Lattice for tracking.

  • n_part (float) –

    Number of actual particles in a bunch. Used to compute the bunch charge.

  • mode (NormalModesStruct) –

    Structure holding the beam info. Will be combined with info in beam_init.

  • beam_init (BeamInitStruct) –

    Structure holding beam info. Will be combined with info in mode.

  • closed_orb (1D array of CoordStruct) –

    Closed orbit. If not present the closed orbit is taken to be zero.

sigma_mat_ptc_to_bmad

Fortran source: bmad/ptc/ptc_interface_mod.f90

sigma_mat_ptc_to_bmad(sigma_mat_ptc: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], beta0: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"]

Subroutine sigma_mat_ptc_to_bmad (sigma_mat_ptc, beta0, sigma_mat_bmad)

Routine to convert a PTC sigma matrix to a Bmad sigma matrix. The conversion includes the conversion between Bmad and PTC time coordinate systems.

Since PTC uses delta_E/P0c and Bmad uses delta_P/P0c coordinates, and since the relationship between delta_E and delta_P is nonlinear, this routine simplifies the calculation and assumes that the particle beta is constant over the range of particle energies.

Parameters:
  • sigma_mat_ptc (2D array of float (shape: 6,6)) –

    PTC sigma matrix.

  • beta0 (float) –

    Reference particle velocity

Returns:
  • sigma_mat_bmad( 2D array of float (shape: 6,6) ) –

    Bmad sigma matrix.

significant_difference

Fortran source: bmad/modules/bmad_routine_interface.f90

significant_difference(value1: typing.SupportsFloat | typing.SupportsIndex, value2: typing.SupportsFloat | typing.SupportsIndex, abs_tol: typing.SupportsFloat | typing.SupportsIndex | None = None, rel_tol: typing.SupportsFloat | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine significant_difference

Parameters:
  • value1 (float) –

    First value.

  • value2 (float) –

    Second value.

  • abs_tol (float) –

    Absolute tolerance. Default is 0.

  • rel_tol (float) –

    Relative tolerance. Default is 0.

Returns:
  • is_different( bool ) –

    Set True if the difference is significant. False otherwise.

skip_ele_blender

Fortran source: bmad/interface/blender_interface_mod.f90

skip_ele_blender(ele: pybmad._pybmad.EleStruct, skip: bool) -> None

Wrapper for Fortran routine skip_ele_blender

Parameters:

slice_lattice

Fortran source: bmad/modules/bmad_routine_interface.f90

slice_lattice(lat: pybmad._pybmad.LatStruct, ele_list: str, do_bookkeeping: bool | None = None, set_phase_zero: bool | None = None) -> bool

Wrapper for Fortran routine slice_lattice

Parameters:
  • lat (LatStruct) –

    Lattice to slice. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with unwanted elements sliced out.

  • ele_list (str) –

    List of elements to retain. See the documentation for the lat_ele_locator routine for the syntax of the list.

  • do_bookkeeping (bool) –

    Default is True. If false, the calling routine is responsible for: * Modifying lat.particle_start if needed. * Calculating Twiss functions.

  • set_phase_zero (bool) –

    Default is True. Set betatron phase to zero?

Returns:
  • error( bool ) –

    Set True if there is an error Set False if not.

soft_quadrupole_edge_kick

Fortran source: bmad/modules/fringe_mod.f90

soft_quadrupole_edge_kick(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, particle_at: typing.SupportsInt | typing.SupportsIndex, orbit: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Subroutine soft_quadrupole_edge_kick (ele, param, particle_at, orbit, mat6, make_matrix)

Routine to add the SAD "linear" soft edge (for finite f1 or f2). This routine assumes that the particle orbit has been rotated to the element reference frame. This routine is called with sad_mult and quadrupole elements.

Parameters:
  • ele (EleStruct) –

    Element being tracked through

  • param (LatParamStruct) –

    Tracking parameters.

  • particle_at (int) –

    first_track_edge\(, or second_track_edge\).

  • orbit (CoordStruct) –

    Position before kick. This parameter is an input/output and is modified in-place. As an output, orbit: Position after kick.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the edge. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix with edge kick added on.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

sol_quad_mat6_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

sol_quad_mat6_calc(ks_in: typing.SupportsFloat | typing.SupportsIndex, k1_in: typing.SupportsFloat | typing.SupportsIndex, tilt: typing.SupportsFloat | typing.SupportsIndex, length: typing.SupportsFloat | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine sol_quad_mat6_calc

Parameters:
  • ks_in (float) –
  • k1_in (float) –
  • tilt (float) –

    quadrupole tilt.

  • length (float) –

    Sol_quad length.

  • ele (EleStruct) –

    Sol_quad element.

  • orbit (CoordStruct) –

    Orbit at beginning of the sol_quad.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the sol_quad. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix includeing the sol_quad.

  • make_matrix (bool) –

    Extend the matrix?

solve_psi_adaptive

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

solve_psi_adaptive(t0: typing.SupportsFloat | typing.SupportsIndex, t1: typing.SupportsFloat | typing.SupportsIndex, p0: typing.SupportsFloat | typing.SupportsIndex, args: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"]) -> float

Subroutine solve_psi_adaptive(t0,t1,p0,args,p1)

Solve dpsi/dt for psi(t1) using adaptive steps and method: "Implicit Bulirsch-Stoer method of Bader and Deuflhard."

The boundary condition p0 is psi(t0)

Parameters:
  • t0 (float) –

    initial time

  • t1 (float) –

    final time

  • p0 (float) –

    Boundary condition psi(t0)

  • args (1D array of float (shape: 1:8)) –

    Parameters. See psi_prime comments for details.

Returns:
  • p1( float ) –

    psi(t1)

solve_psi_fixed_steps

Fortran source: bmad/multiparticle/longitudinal_profile_mod.f90

solve_psi_fixed_steps(t0: typing.SupportsFloat | typing.SupportsIndex, t1: typing.SupportsFloat | typing.SupportsIndex, p0: typing.SupportsFloat | typing.SupportsIndex, args: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"], t: pybmad._pybmad.RealArray1D, p: pybmad._pybmad.RealArray1D) -> None

Subroutine solve_psi_fixed_steps(t0,t1,p0,args,t,p)

Solve dpsi/dt for psi(t1) using fixed steps and method: "Implicit Bulirsch-Stoer method of Bader and Deuflhard."

The boundary condition p0 is psi(t0).

Number of steps is determined by SIZE(p).

Parameters:
  • t0 (float) –

    initial time

  • t1 (float) –

    final time

  • p0 (float) –

    Boundary condition psi(t0)

  • args (1D array of float (shape: 1:8)) –

    Parameters. See psi_prime comments for details.

  • t (1D array of float) –

    Array of times from t0 to t1

  • p (1D array of float) –

    Array of psi evaluated at t(:)

sort_complex_taylor_terms

Fortran source: bmad/modules/complex_taylor_mod.f90

sort_complex_taylor_terms(complex_taylor_in: pybmad._pybmad.ComplexTaylorStruct) -> pybmad._pybmad.ComplexTaylorStruct

subroutine sort_complex_taylor_terms (complex_taylor_in, complex_taylor_sorted)

Subroutine to sort the complex_taylor terms from "lowest" to "highest" of a complex_taylor series. This subroutine is needed because what comes out of PTC is not sorted.

Uses function complex_taylor_exponent_index to sort.

Note: complex_taylor_sorted needs to have been initialized. Note: complex_taylor_sorted cannot be complex_taylor_in. That is it is not legal to write: call sort_complex_taylor_terms (this_complex_taylor, this_complex_taylor)

Parameters:
Returns:

spin_dn_dpz_from_mat8

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_dn_dpz_from_mat8(mat_1turn: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(8)"]], "FixedSize(8)"], dn_dpz_partial: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"] | None = None) -> pybmad._pybmad.SpinDnDpzFromMat8

Wrapper for Fortran routine spin_dn_dpz_from_mat8

Parameters:
  • mat_1turn (2D array of float (shape: 8,8)) –

    Spin-orbital matrix.

  • dn_dpz_partial (2D array of float (shape: 3,3)) –

    dn_dpz_partial(i,:) is dn_dpz with only one osccilation mode "excited". So dn_dpz_partial(1,:) represents a-mode excitation, etc.

Returns:
  • error( bool ) –

    Set True if there is an error. False otherwise.

  • dn_dpz( 1D array of float (shape: 3) ) –

    dn_dpz (l,n,m) coordinates.

spin_dn_dpz_from_qmap

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_dn_dpz_from_qmap(orb_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], q_map: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(7)"]], "FixedSize(4)"], dn_dpz_partial: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"], dn_dpz_partial2: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"], n0: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None) -> pybmad._pybmad.SpinDnDpzFromQmap

Wrapper for Fortran routine spin_dn_dpz_from_qmap

Parameters:
  • orb_mat (2D array of float (shape: 6,6)) –

    1-turn orbital matrix.

  • q_map (2D array of float (shape: 0:3,0:6)) –

    1-turn spin linear quaternion map.

  • dn_dpz_partial (2D array of float (shape: 3,3)) –

    ) is dn_dpz with only one osccilation mode "excited". So dn_dpz_partial(1,:) represents a-mode excitation, etc.

  • dn_dpz_partial2 (2D array of float (shape: 3,3)) –

    ) is dn_dpz with only two osccilation modes "excited". So dn_dpz_partial(1,:) represents b-mode and c-mode excitation without the a-mode, etc.

  • n0 (1D array of float (shape: 3)) –

    3,0).

Returns:
  • error( bool ) –

    Set True if there is an error. False otherwise.

  • dn_dpz( 1D array of float (shape: 3) ) –

    dn_dpz.

spin_map1_normalize

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_map1_normalize(spin1: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(7)"]], "FixedSize(4)"]) -> None

Wrapper for Fortran routine spin_map1_normalize

Parameters:
  • spin1 (2D array of float (shape: 0:3,0:6)) –

    Unnormalized spin map. This parameter is an input/output and is modified in-place. As an output, spin1: Normalized spin map.

spin_mat8_resonance_strengths

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_mat8_resonance_strengths(orb_evec: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], mat8: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"]) -> pybmad._pybmad.SpinMat8ResonanceStrengths

Wrapper for Fortran routine spin_mat8_resonance_strengths

Parameters:
  • orb_evec (1D array of complex (shape: 6)) –

    Orbital eigenvector.

  • mat8 (2D array of float (shape: 6,6)) –

    Spin/orbital matrix.

Returns:
  • xi_sum( float ) –

    Sum resonance strength.

  • xi_diff( float ) –

    Difference resonance strength.

spin_mat_to_eigen

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_mat_to_eigen(orb_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], spin_map: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(7)"]], "FixedSize(4)"]) -> pybmad._pybmad.SpinMatToEigen

Wrapper for Fortran routine spin_mat_to_eigen

Parameters:
  • orb_mat (2D array of float (shape: 6,6)) –

    Orbital matrix.

  • spin_map (2D array of float (shape: 0:3,0:6)) –

    Quaternion 0th & 1st order map.

Returns:
  • orb_eval( 1D array of complex (shape: 6) ) –

    Eigenvalues.

  • orb_evec( 2D array of complex (shape: 6,6) ) –

    Orbital eigenvectors. orb_evec(j,:) is the j^th vector.

  • n0( 1D array of float (shape: 3) ) –

    n_0 invariant spin

  • spin_evec( 2D array of complex (shape: 6,3) ) –

    Spin eigenvectors. spin_evec(j,:) is the j^th vector.

  • error( bool ) –

    Set true if there is an error. False otherwise.

spin_omega

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_omega(field: pybmad._pybmad.EmFieldStruct, orbit: pybmad._pybmad.CoordStruct, sign_z_vel: typing.SupportsInt | typing.SupportsIndex, omega: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], phase_space_coords: bool | None = None) -> None

Wrapper for Fortran routine spin_omega

Parameters:
  • field (EmFieldStruct) –
  • orbit (CoordStruct) –
  • sign_z_vel (int) –
  • omega (1D array of float (shape: 3)) –
  • phase_space_coords (bool) –

spin_quat_resonance_strengths

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_quat_resonance_strengths(orb_evec: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], spin_q: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(7)"]], "FixedSize(4)"]) -> pybmad._pybmad.SpinQuatResonanceStrengths

Wrapper for Fortran routine spin_quat_resonance_strengths

Parameters:
  • orb_evec (1D array of complex (shape: 6)) –

    Orbital eigenvector.

  • spin_q (2D array of float (shape: 0:3,0:6)) –

    First order spin map.

Returns:
  • xi_sum( float ) –

    Sum resonance strength.

  • xi_diff( float ) –

    Difference resonance strength.

spin_taylor_to_linear

Fortran source: bmad/modules/bmad_routine_interface.f90

spin_taylor_to_linear(spin_taylor: pybmad._pybmad.TaylorStructArray1D, normalize: bool, dref_orb: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], is_on: bool) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(7)"]], "FixedSize(4)"]

Wrapper for Fortran routine spin_taylor_to_linear

Parameters:
  • spin_taylor (1D array of TaylorStruct (shape: 0:3)) –

    Taylor spin map.

  • normalize (bool) –

    If True, normalize the linear map.

  • dref_orb (1D array of float (shape: 6)) –

    Change in Reference orbit: output_map1_ref - input_taylor_ref.

  • is_on (bool) –

    Is map turned on? If not spin_map1 will be the unit map.

Returns:
  • spin_map1( 2D array of float (shape: 0:3,0:6) ) –

    First order spin map.

spinor_to_polar

Fortran source: bmad/modules/bmad_routine_interface.f90

spinor_to_polar(spinor: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]) -> pybmad._pybmad.SpinPolarStruct

Wrapper for Fortran routine spinor_to_polar

Parameters:
  • spinor (1D array of complex (shape: 2)) –

    Spinor

Returns:
  • polar( SpinPolarStruct ) –

    The resultant Unitary Vector in polar coordinates

spinor_to_vec

Fortran source: bmad/modules/bmad_routine_interface.f90

spinor_to_vec(spinor: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]) -> typing.Annotated[list[float], "FixedSize(3)"]

Wrapper for Fortran routine spinor_to_vec

Parameters:
  • spinor (1D array of complex (shape: 2)) –

    Spinor

Returns:
  • vec( 1D array of float (shape: 3) ) –

    spin vector in cartesian coordinates

spline_fit_orbit

Fortran source: bmad/modules/bmad_routine_interface.f90

spline_fit_orbit(start_orb: pybmad._pybmad.CoordStruct, end_orb: pybmad._pybmad.CoordStruct, spline_x: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], spline_y: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]) -> None

Wrapper for Fortran routine spline_fit_orbit

Parameters:
  • start_orb (CoordStruct) –

    Starting coords.

  • end_orb (CoordStruct) –

    Ending coords.

  • spline_x (1D array of float (shape: 0:3)) –

    Spline coefs for the horizontal trajectory.

  • spline_y (1D array of float (shape: 0:3)) –

    Spline coefs for vertical trajectory.

split_expression_string

Fortran source: bmad/modules/expression_mod.f90

split_expression_string(expr: str, width: typing.SupportsInt | typing.SupportsIndex, indent: typing.SupportsInt | typing.SupportsIndex, break_str: str | None = None) -> pybmad._pybmad.CharacterAlloc1D

Subroutine split_expression_string (expr, width, indent, lines)

Routine to break an expression into a number of lines for a nicer display. Used when printing expressions.

Parameters:
  • expr (str) –

    String containing the expression.

  • width (int) –

    Maximum width of split expression.

  • indent (int) –

    If positive: Number of spaces to indent for every line after the first. If negative: No indentation but first line is shortened by |indent|.

  • break_str (str) –

    If present, only break lines at places where this string is.

Returns:
  • lines( 1D array of str ) –

    Split expression.

split_lat

Fortran source: bmad/modules/bmad_routine_interface.f90

split_lat(lat: pybmad._pybmad.LatStruct, s_split: typing.SupportsFloat | typing.SupportsIndex, ix_branch: typing.SupportsInt | typing.SupportsIndex, add_suffix: bool | None = None, check_sanity: bool | None = None, save_null_drift: bool | None = None, choose_max: bool | None = None, ix_insert: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.SplitLat

Wrapper for Fortran routine split_lat

Parameters:
  • lat (LatStruct) –

    Original lat structure. This parameter is an input/output and is modified in-place. As an output, lat: Modified lat structure.

  • s_split (float) –

    Position at which lat.branch(ix_branch) is to be split.

  • ix_branch (int) –

    Index of lat.branch(:) to use.

  • add_suffix (bool) –

    If True (default) add '#1' and '#2" suffixes to the split elements.

  • check_sanity (bool) –

    If True (default) then call lat_sanity_check after the split to make sure everything is ok.

  • save_null_drift (bool) –

    Save a copy of a drift to be split as a null_ele? This is useful when superpositions are done. See add_superimpose for more info. Default is False.

  • choose_max (bool) –

    If no splitting of an element is needed, that is, s_split is at an element boundary, there can be multiple possible values for ix_split if there exist zero length elements at the split point. If choose_max = True, ix_split will be chosen to be the maximum possible index and if choose_max = False ix_split will be chosen to be the minimal possible index. If s_split is not at an element boundary, the setting of choose_max is immaterial. If ix_insert is present, the default value of choose_max is set to give the closest element to ix_insert. If ix_insert is not present, the default value of choose_max is False.

  • ix_insert (int) –

    Element index near the point to be split. ix_insert is useful in the case where there is a patch with a negative length which can create an ambiguity as to where to do the split In this case ix_insert will remove the ambiguity. Also useful to ensure where to split if there are elements with zero length nearby. Ignored if negative.

Returns:
  • ix_split( int ) –

    Index of element just before the s = s_split point.

  • split_done( bool ) –

    True if lat was split.

  • err_flag( (bool, optional) ) –

    Set true if there is an error, false otherwise.

sprint_spin_taylor_map

Fortran source: bmad/modules/bmad_routine_interface.f90

sprint_spin_taylor_map(ele: pybmad._pybmad.EleStruct, start_orbit: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"] | None = None) -> None

Wrapper for Fortran routine sprint_spin_taylor_map

Parameters:
  • ele (EleStruct) –

    Element to form map for. This parameter is an input/output and is modified in-place. As an output, ele: Element with map.

  • start_orbit (1D array of float (shape: 6)) –

    Reference orbit for the map. Default is zero orbit.

sr_longitudinal_wake_particle

Fortran source: bmad/multiparticle/wake_mod.f90

sr_longitudinal_wake_particle(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine sr_longitudinal_wake_particle (ele, orbit)

Routine to apply the short-range wake longitudinal component kick to a particle and then add to the existing longitudinal wake the contribution from the particle.

Parameters:
  • ele (EleStruct) –

    Element with wakes.

  • orbit (CoordStruct) –

    Particle coords. This parameter is an input/output and is modified in-place. As an output, orbit: coords after the kick.

sr_transverse_wake_particle

Fortran source: bmad/multiparticle/wake_mod.f90

sr_transverse_wake_particle(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine sr_transverse_wake_particle (ele, orbit)

Subroutine to apply the short-range wake transverse component of the kick to a particle and then add to the existing transverse wake the contribution from the particle.

Parameters:
  • ele (EleStruct) –

    Element with wakes.

  • orbit (CoordStruct) –

    Starting particle coords. This parameter is an input/output and is modified in-place. As an output, orbit: Ending particle coords.

sr_z_long_wake

Fortran source: bmad/multiparticle/wake_mod.f90

sr_z_long_wake(ele: pybmad._pybmad.EleStruct, bunch: pybmad._pybmad.BunchStruct, z_ave: typing.SupportsFloat | typing.SupportsIndex) -> None

Subroutine sr_z_long_wake (ele, bunch, z_ave)

Subroutine to apply the short-range z-wake kick to a particle.

Parameters:
  • ele (EleStruct) –

    Element with wake.

  • bunch (BunchStruct) –

    Bunch before wake applied.

  • z_ave (float) –

    Average z-position of all live particles.

srdt_calc

Fortran source: bmad/modules/srdt_mod.f90

srdt_calc(lat: pybmad._pybmad.LatStruct, order: typing.SupportsInt | typing.SupportsIndex, n_slices_gen_opt: typing.SupportsInt | typing.SupportsIndex | None = None, n_slices_sxt_opt: typing.SupportsInt | typing.SupportsIndex | None = None, per_ele_out: pybmad._pybmad.SummationRdtStructAlloc1D | None = None) -> pybmad._pybmad.SummationRdtStruct

Subroutine srdt_calc(lat, srdt_sums, order, n_slices_gen_opt, n_slices_sxt_opt)

Calculate summation RDT terms up to order=1 or order=2 while slicing sextupoles n_slices_sxt_opt times and all other elements n_slices_gen_opt times.

These formulas are documented in "The Sextupole Scheme for the Swiss Light Source (SLS): An Analytic Approach" by Johan Bengtsson. SLS Note 9/97.

The 2nd order formulas are documented in "Second-order driving terms due to sextupoles and chromatic effects of quadrupoles" by Chun-xi Wang. AOP-TN-2009-020.

Parameters:
  • lat (LatStruct) –

    lattice with Twiss parameters calculated.

  • order (int) –

    1 to calculate only first order terms. 2 to also calculate 2nd order terms.

  • n_slices_gen_opt (int) –

    number of times to slice elements other than sextupoles. Default is 10.

  • n_slices_sxt_opt (int) –

    nubmer of times to slice sextupoles. Default is 20.

Returns:

srdt_lsq_solution

Fortran source: bmad/modules/srdt_mod.f90

srdt_lsq_solution(lat: pybmad._pybmad.LatStruct, var_indexes: pybmad._pybmad.IntArray1D, n_slices_gen_opt: typing.SupportsInt | typing.SupportsIndex | None = None, n_slices_sxt_opt: typing.SupportsInt | typing.SupportsIndex | None = None, chrom_set_x_opt: typing.SupportsFloat | typing.SupportsIndex | None = None, chrom_set_y_opt: typing.SupportsFloat | typing.SupportsIndex | None = None, weight_in: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(10)"] | None = None) -> pybmad._pybmad.RealAlloc1D

Subroutine srdt_lsq_solution(lat, var_indexes, ls_soln, n_slices_gen_opt, n_slices_sxt_opt, chrom_set_x_opt, chrom_set_y_opt, weight_in)

Given lat, finds K2 moments that set the chromaticity and zeros-out the real and complex parts of the first order driving terms, that minimizes the sum of the squares of the K2 moments. i.e. the weakest sextupole scheme that sets chromaticity and zeros out the first order terms.

Note: This subroutine does not, in its present form, work well with knobs, overlays, or in lattices where multiple elements have the same name.

This subroutine assumes that Nsext > 18.

Parameters:
  • lat (LatStruct) –

    lattice with Twiss parameters calculated.

  • var_indexes (1D array of int) –

    indexes in lat.ele that are K2 variables. Must be sorted smallest index to largest index.

  • n_slices_gen_opt (int) –

    number of times to slice elements other than sextupoles. Default is 10.

  • n_slices_sxt_opt (int) –

    nubmer of times to slice sextupoles. Default is 20.

  • chrom_set_x_opt (float) –

    what to set x chromaticity to. Default zero.

  • chrom_set_y_opt (float) –

    what to set y chromaticity to. Default zero.

  • weight_in (1D array of float (shape: 10)) –

    moment weights. Terms are: [wgt_chrom_x, wgt_chrom_y, wgt_h20001, wgt_h00201, wgt_h10002, wgt_h21000, wgt_h30000, wgt_h10110, wgt_h10020, wgt_h10200, If present, any terms equal to zero are given default values which is 1.0e4 for wgt_chrom_x and wgt_chrom_y and is 1.0 for everything else.

Returns:
  • ls_soln( 1D array of float ) –

    contains K2 for the indexes in var_indexes

start_branch_at

Fortran source: bmad/modules/bmad_routine_interface.f90

start_branch_at(lat: pybmad._pybmad.LatStruct, ele_start: str, move_end_marker: bool) -> bool

Wrapper for Fortran routine start_branch_at

Parameters:
  • lat (LatStruct) –

    Lattice to modify. This parameter is an input/output and is modified in-place. As an output, lat: Modified lattice.

  • ele_start (str) –

    Start element. Ele_start will identify the lattice branch to modify.

  • move_end_marker (bool) –

    If True then the end marker (if it is present) will be shifted like any other element. False means that the end marker will stay at the end.

Returns:
  • error( bool ) –

    Set True if there is an error Set False if not.

stream_ele_end

Fortran source: bmad/modules/bmad_routine_interface.f90

stream_ele_end(physical_end: typing.SupportsInt | typing.SupportsIndex, ele_orientation: typing.SupportsInt | typing.SupportsIndex) -> int

Wrapper for Fortran routine stream_ele_end

Parameters:
  • physical_end (int) –

    entrance_end\(, exit_end\), surface$, etc.

  • ele_orientation (int) –

    Either 1 = Normal or -1 = element reversed.

Returns:
  • stream_end( int ) –

    upstream_end\(, downstream_end\), or set equal to physical_end if physical_end is neither entrance_end$ nor exit_end$

string_attrib

Fortran source: bmad/modules/attribute_mod.f90

string_attrib(attrib_name: str, ele: pybmad._pybmad.EleStruct) -> str

Subroutine string_attrib (attrib_name, ele, attrib_value)

Routine to return the value of a string attribute of a lattice element. This routine is useful when attrib_name is specified by the program user.

For example: call string_attrib ('NAME', ele, attrib_value) ! Will return attrib_value = ele%name

Parameters:
  • attrib_name (str) –

    Name of the type of element attribute.

  • ele (EleStruct) –

    Lattice element.

Returns:
  • attrib_value( str ) –

    The string associated with the attribute.

strong_beam_sigma_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

strong_beam_sigma_calc(ele: pybmad._pybmad.EleStruct, s_pos: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.StrongBeamSigmaCalc

Wrapper for Fortran routine strong_beam_sigma_calc

Parameters:
  • ele (EleStruct) –

    Beambeam element.

  • s_pos (float) –

    Longitudinal position in lab coords of slice (used with hourglass effect correction).

Returns:
  • sigma( 1D array of float (shape: 2) ) –

    Strong beam x,y sigmas.

  • bbi_const( float ) –

    BBI kick scale factor.

  • dsigma_ds( 1D array of float (shape: 2) ) –

    sig_x and sig_y longitudinal derivatives.

strong_beam_strength

Fortran source: bmad/modules/bmad_routine_interface.f90

strong_beam_strength(ele: pybmad._pybmad.EleStruct) -> float

Wrapper for Fortran routine strong_beam_strength

Parameters:
Returns:
  • strength( float ) –

    Strong beam strength.

surface_grid_displacement

Fortran source: bmad/photon/photon_utils_mod.f90

surface_grid_displacement(ele: pybmad._pybmad.EleStruct, x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, extend_grid: bool | None = None) -> pybmad._pybmad.SurfaceGridDisplacement

Subroutine surface_grid_displacement (ele, x, y, err_flag, z, dz_dxy, extend_grid)

Routine to add in the z displacement defined by the grid

Parameters:
  • ele (EleStruct) –

    Element containing the grid

  • x (float) –

    Photon coords at surface.

  • y (float) –

    Photon coords at surface.

  • extend_grid (bool) –

    If (x,y) past grid pretend (x,y) is at grid boundary. Default is False.

Returns:
  • err_flag( bool ) –

    Set True if there is a problem.

  • z( float ) –

    surface height at (x, y).

  • dz_dxy( 1D array of float (shape: 2), optional ) –

    Surface slope at (x, y).

switch_attrib_value_name

Fortran source: bmad/modules/attribute_mod.f90

switch_attrib_value_name(attrib_name: str, attrib_value: typing.SupportsFloat | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.SwitchAttribValueName

Function switch_attrib_value_name (attrib_name, attrib_value, ele, is_default, name_list) result (attrib_val_name)

Routine to return the name corresponding to the value of a given switch attribute.

This routine is for "switch" and "species" attributes. For example, the "aperture_type" attribute can have value names of "Entrance_End", "Exit_End", etc.

Optionally, this routine can determine if the attribute value corresponds to the default value. That is, the value that the attribute would have if not specified in the lattice file.

Use the routine attribute_type to first test if the type of the attribute corresponds to is_switch$.

Parameters:
  • attrib_name (str) –

    Name of the attribute. Must be upper case.

  • attrib_value (float) –

    Value of the attribute.

  • ele (EleStruct) –

    Lattice element that the attribute is contained in. Generally only needed to determine the default value.

Returns:
  • attrib_val_name( str ) –

    Name corresponding to the value. Set to null_name$ if there is a problem.

  • is_default( (bool, optional) ) –

    If True then the value of the attiribute corresponds to the default value. If this argument is present, the ele argument must also be present.

  • name_list( 1D array of str, optional ) –

    List of names the switch can take. Deallocated if there is an error.

symp_lie_bmad

Fortran source: bmad/modules/bmad_routine_interface.f90

symp_lie_bmad(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None, offset_ele: bool | None = None) -> pybmad._pybmad.TrackStruct

Wrapper for Fortran routine symp_lie_bmad

Parameters:
  • ele (EleStruct) –

    Element with transfer matrix This parameter is an input/output and is modified in-place. As an output, ele: Element with transfer matrix.

  • param (LatParamStruct) –

    Parameters are needed for some elements.

  • orbit (CoordStruct) –

    Coordinates at the beginning of element. This parameter is an input/output and is modified in-place. As an output, orbit: Coordinates at the end of element.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix propagated through the element.

  • make_matrix (bool) –

    If True then make the 6x6 transfer matrix.

  • offset_ele (bool) –

    Offset the element using ele.value(x_offset$), etc. Default is True.

Returns:
  • track( (TrackStruct, optional) ) –

    Structure holding the track information. When tracking through multiple elements, the trajectory in an element is appended to the existing trajectory. To reset: Set track.n_pt = -1.

t6_to_b123

Fortran source: bmad/modules/mode3_mod.f90

t6_to_b123(t6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], abz_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> pybmad._pybmad.T6ToB123

Subroutine t6_to_B123(N, abz_tunes, B1, B2, B3, err_flag)

This decomposes the one-turn matrix according to Equation 56 from "Alternative approach to general coupled linear optics" by A. Wolski. PRSTAB.

Note that a sigma matrix can be assembeled from: sigma = B1emit_a + B2emit_b + B3*emit_c

Parameters:
  • t6 (2D array of float (shape: 6,6)) –

    1-turn transfer matrix. RF assumed to be on.

  • abz_tunes (1D array of float (shape: 3)) –

    a-mode and b-mode tunes. Used to order eigensystem.

Returns:
  • B1( 2D array of float (shape: 6,6) ) –

    Beta matrix associated with a-mode.

  • B2( 2D array of float (shape: 6,6) ) –

    Beta matrix associated with b-mode.

  • B3( 2D array of float (shape: 6,6) ) –

    Beta matrix associated with c-mode.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise

taper_mag_strengths

Fortran source: bmad/modules/bmad_routine_interface.f90

taper_mag_strengths(lat: pybmad.pybmad.LatStruct, ref_lat: pybmad._pybmad.LatStruct | None = None, except: str | None = None, err_flag: bool | None = None) -> None

Wrapper for Fortran routine taper_mag_strengths

Parameters:
  • lat (LatStruct) –

    Lattice to vary. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with magnet strengths varied.

  • ref_lat (LatStruct) –

    Reference lattice. If not present, lat will be used as the ref.

  • except (str) –

    List of elements not to vary.

  • err_flag (bool) –

target_min_max_calc

Fortran source: bmad/photon/track1_photon_mod.f90

target_min_max_calc(r_corner1: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], r_corner2: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], y_min: typing.SupportsFloat | typing.SupportsIndex, y_max: typing.SupportsFloat | typing.SupportsIndex, phi_min: typing.SupportsFloat | typing.SupportsIndex, phi_max: typing.SupportsFloat | typing.SupportsIndex, initial: bool | None = None) -> pybmad._pybmad.TargetMinMaxCalc

Subroutine target_min_max_calc (r_corner1, r_corner2, y_min, y_max, phi_min, phi_max, initial)

Routine to calculate the min/max values for (y, phi). min/max values are cumulative.

Parameters:
  • r_corner1 (1D array of float (shape: 3)) –

    In target coords: A corner of the target. Must be normalized to 1.

  • r_corner2 (1D array of float (shape: 3)) –

    In target coords: Adjacent corner of the target. Must be normalized to 1.

  • y_min (float) –

    min/max values. Only needed if initial = False.

  • y_max (float) –

    min/max values. Only needed if initial = False.

  • phi_min (float) –

    min/max values. Only needed if initial = False.

  • phi_max (float) –

    min/max values. Only needed if initial = False.

  • initial (bool) –

    If present and True then this is the first edge for computation.

Returns:
  • y_min( float ) –

    min/max values. Only needed if initial = False.

  • y_max( float ) –

    min/max values. Only needed if initial = False.

  • phi_min( float ) –

    min/max values. Only needed if initial = False.

  • phi_max( float ) –

    min/max values. Only needed if initial = False.

target_rot_mats

Fortran source: bmad/photon/track1_photon_mod.f90

target_rot_mats(r_center: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> pybmad._pybmad.TargetRotMats

Subroutine target_rot_mats (r_center, w_to_target, w_to_ele)

Routine to calculate the rotation matrices between ele coords and "target" coords. By definition, in target coords r_center = [0, 0, 1].

Parameters:
  • r_center (1D array of float (shape: 3)) –

    In lab coords: Center of target relative to phton emission point.

Returns:
  • w_to_target( 2D array of float (shape: 3,3) ) –

    Rotation matrix from ele to target coords.

  • w_to_ele( 2D array of float (shape: 3,3) ) –

    Rotation matrix from target to ele coords.

taylor_equal_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

taylor_equal_taylor(taylor1: pybmad._pybmad.TaylorStruct, taylor2: pybmad._pybmad.TaylorStruct) -> None

Wrapper for Fortran routine taylor_equal_taylor

Parameters:

taylor_inverse

Fortran source: bmad/ptc/ptc_interface_mod.f90

taylor_inverse(taylor_in: pybmad._pybmad.TaylorStructArray1D, taylor_inv: pybmad._pybmad.TaylorStructArray1D) -> bool

Subroutine taylor_inverse (taylor_in, taylor_inv, err)

Subroutine to invert a taylor map. Since the inverse map is truncated, it is not exact.

Parameters:
  • taylor_in (1D array of TaylorStruct) –

    Input taylor map.

  • taylor_inv (1D array of TaylorStruct) –

    Inverted taylor map.

Returns:
  • err( (bool, optional) ) –

    Set True if there is no inverse. If not present then print an error message.

taylor_propagate1

Fortran source: bmad/ptc/ptc_interface_mod.f90

taylor_propagate1(orb_taylor: pybmad._pybmad.TaylorStructArray1D, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, ref_in: pybmad._pybmad.CoordStruct | None = None, spin_taylor: pybmad._pybmad.TaylorStructArray1D | None = None) -> bool

Subroutine taylor_propagate1 (orb_taylor, ele, param, err_flag, ref_in, spin_taylor)

Subroutine to track (symplectic integration) a orbital map, and optionally a spin map, through an element. The spin tracking is only done if spin_taylor is present and bmad_com%spin_tracking_on = T. The alternative routine, if ele has a taylor map, is concat_taylor.

This routine will fail if there is no corresponding ptc fibre for this element. In general, the transfer_map_calc routine should be used instead.

Parameters:
  • orb_taylor (1D array of TaylorStruct) –

    Map to be tracked This parameter is an input/output and is modified in-place. As an output, orb_taylor: Map through element.

  • ele (EleStruct) –

    Element to track through

  • param (LatParamStruct) –
  • ref_in (CoordStruct) –

    Particle to be tracked. Must be present if the particle to be tracked is not the reference particle or if the direction of propagation is backwards.

  • spin_taylor (1D array of TaylorStruct) –

    Spin map to be tracked This parameter is an input/output and is modified in-place. As an output, spin_taylor: Tracked spin map.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

taylor_to_mad_map

Fortran source: bmad/modules/mad_mod.f90

taylor_to_mad_map(taylor: pybmad._pybmad.TaylorStructArray1D, energy: pybmad._pybmad.MadEnergyStruct) -> pybmad._pybmad.MadMapStruct

Subroutine taylor_to_mad_map (taylor, energy, map)

Subroutine to convert a Taylor map to a mad order 2 map. If any of the Taylor terms have order greater than 2 they are ignored.

Parameters:
  • taylor (1D array of TaylorStruct) –

    Taylor map.

  • energy (MadEnergyStruct) –

    Energy numbers.

Returns:

taylors_equal_taylors

Fortran source: bmad/modules/bmad_routine_interface.f90

taylors_equal_taylors(taylor1: pybmad._pybmad.TaylorStructArray1D, taylor2: pybmad._pybmad.TaylorStructArray1D) -> None

Wrapper for Fortran routine taylors_equal_taylors

Parameters:
  • taylor1 (1D array of TaylorStruct) –
  • taylor2 (1D array of TaylorStruct) –

tilt_coords

Fortran source: bmad/modules/bmad_routine_interface.f90

tilt_coords(tilt_val: typing.SupportsFloat | typing.SupportsIndex, coord: pybmad._pybmad.RealArray1D, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine tilt_coords

Parameters:
  • tilt_val (float) –

    Tilt value (could be the roll value for a bend)

  • coord (1D array of float) –

    Coordinates of particle before rotation. This parameter is an input/output and is modified in-place. As an output, coord: Coordinates of particle after rotation.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before tilt. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix transfer matrix after tilt applied.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

tilt_coords_photon

Fortran source: bmad/modules/bmad_routine_interface.f90

tilt_coords_photon(tilt_val: typing.SupportsFloat | typing.SupportsIndex, coord: pybmad._pybmad.RealArray1D, w_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"] | None = None) -> None

Wrapper for Fortran routine tilt_coords_photon

Parameters:
  • tilt_val (float) –

    Tilt value (could be the roll value for a bend)

  • coord (1D array of float) –

    Coordinates of particle before rotation. This parameter is an input/output and is modified in-place. As an output, coord: Coordinates of particle after rotation.

  • w_mat (2D array of float (shape: 3,3)) –

    Rotation matrix before tilt. This parameter is an input/output and is modified in-place. As an output, w_mat: Rotation matrix after tilt.

tilt_mat6

Fortran source: bmad/modules/bmad_routine_interface.f90

tilt_mat6(mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], tilt: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine tilt_mat6

Parameters:
  • mat6 (2D array of float (shape: 6,6)) –

    Untilted matrix. This parameter is an input/output and is modified in-place. As an output, mat6: Tilted matrix.

  • tilt (float) –

    Tilt angle.

to_eta_reading

Fortran source: bmad/modules/measurement_mod.f90

to_eta_reading(eta_actual: pybmad._pybmad.RealArray1D, ele: pybmad._pybmad.EleStruct, axis: typing.SupportsInt | typing.SupportsIndex, add_noise: bool) -> pybmad._pybmad.ToEtaReading

Subroutine to_eta_reading (eta, ele, axis, add_noise, reading, err)

Compute the measured dispersion reading given the true dispersion and the monitor offsets, noise, etc.

This routine will only give a nonzero reading for Bmad markers, monitors, and instruments.

Parameters:
  • eta_actual (1D array of float) –

    Actual (eta_x, eta_y) dispersion.

  • ele (EleStruct) –

    Element where the orbit is measured.

  • axis (int) –

    x_plane$ or y_plane$

  • add_noise (bool) –

    If True add noise to the reading

Returns:
  • reading( float ) –

    BPM reading

  • err( bool ) –

    Set True if there is an error. False otherwise.

to_fieldmap_coords

Fortran source: bmad/modules/em_field_mod.f90

to_fieldmap_coords(ele: pybmad._pybmad.EleStruct, local_orb: pybmad._pybmad.CoordStruct, s_body: typing.SupportsFloat | typing.SupportsIndex, ele_anchor_pt: typing.SupportsInt | typing.SupportsIndex, r0: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], curved_ref_frame: bool) -> pybmad._pybmad.ToFieldmapCoords

Subroutine to_fieldmap_coords (ele, local_orb, s_body, ele_anchor_pt, r0, curved_ref_frame, x, y, z, cos_ang, sin_ang, err_flag)

Routine to return the (x,y,s) position relative to a field map.

Parameters:
  • ele (EleStruct) –

    Element being tracked through.

  • local_orb (CoordStruct) –

    Particle orbit. Must be in local element coordinates.

  • s_body (float) –

    Longitudinal position relative to the entrance end of the element.

  • ele_anchor_pt (int) –

    anchor point of the field map (anchor_beginning\(, anchor_center\), or anchor_end$).

  • r0 (1D array of float (shape: 3)) –

    origin point of the fieldmap.

  • curved_ref_frame (bool) –

    If the element is a bend: Does the field map follow the bend reference coords?

Returns:
  • x( float ) –

    Coords relative to the field map.

  • y( float ) –

    Coords relative to the field map.

  • z( float ) –

    Coords relative to the field map.

  • cos_ang( float ) –

    cos and sin of coordinate rotation angle.

  • sin_ang( float ) –

    cos and sin of coordinate rotation angle.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

to_orbit_reading

Fortran source: bmad/modules/measurement_mod.f90

to_orbit_reading(orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, axis: typing.SupportsInt | typing.SupportsIndex, add_noise: bool) -> pybmad._pybmad.ToOrbitReading

Subroutine to_orbit_reading (orb, ele, axis, add_noise, reading, err)

Calculate the measured reading on a bpm given the actual orbit and the BPM's offsets, noise, etc.

This routine will only give a nonzero reading for Bmad markers, monitors, and instruments.

Parameters:
  • orb (CoordStruct) –

    Orbit position at BPM.

  • ele (EleStruct) –

    Element where the orbit is measured.

  • axis (int) –

    x_plane$ or y_plane$

  • add_noise (bool) –

    If True add noise to the reading

Returns:
  • reading( float ) –

    BPM reading

  • err( bool ) –

    Set True if there is no valid reading. For example, if ele.is_on = False.

to_phase_and_coupling_reading

Fortran source: bmad/modules/measurement_mod.f90

to_phase_and_coupling_reading(ele: pybmad._pybmad.EleStruct, add_noise: bool) -> pybmad._pybmad.ToPhaseAndCouplingReading

Subroutine to_phase_and_coupling_reading (ele, add_noise, reading, err)

Find the measured coupling values given the actual ones

This routine will only give a nonzero reading for Bmad markers, monitors, and instruments.

Parameters:
  • ele (EleStruct) –

    Element where phase is measured.

  • add_noise (bool) –

    If True add noise to the reading

Returns:
  • reading( BpmPhaseCouplingStruct ) –

    K and Cbar coupling parameters

  • err( bool ) –

    Set True if there is an error. False otherwise.

to_photon_angle_coords

Fortran source: bmad/photon/photon_target_mod.f90

to_photon_angle_coords(orb_in: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.CoordStruct

Function to_photon_angle_coords (orb_in, ele) result (orb_out)

Routine to convert from standard photon coords to "angle" coords defined as: x, angle_x, y, angle_y, z, E-E_ref

Parameters:
  • orb_in (CoordStruct) –

    orbit in standard photon coords.

  • ele (EleStruct) –

    Reference element (generally the detector element.)

Returns:

to_surface_coords

Fortran source: bmad/modules/bmad_routine_interface.f90

to_surface_coords(lab_orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.CoordStruct

Wrapper for Fortran routine to_surface_coords

Parameters:
  • lab_orbit (CoordStruct) –

    Photon position in laboratory coords.

  • ele (EleStruct) –

    Detector element.

Returns:
  • surface_orbit( CoordStruct ) –

    Photon position in element body coordinates.

touschek_lifetime

Fortran source: bmad/multiparticle/touschek_mod.f90

touschek_lifetime(mode: pybmad._pybmad.NormalModesStruct, lat: pybmad._pybmad.LatStruct) -> float

Subroutine touschek_lifetime(mode, Tl, lat)

Calculates the touschek lifetime for a lattice by calling touschek_rate1 for each element. The loss rate at each element is averaged over one turn to obtain the lifetime.

This function assumes that the twiss parameters and closed orbit have been calculated, and that mode has been populated.

This subroutine assumes a fixed momentum aperture. The loss rate at each element uses the same momentum aperture, mode%pz_aperture.

A common way to call this function is to first populate mode using radiation integrals. If an ideal lattice is used, the vertical emittance must also be set to a reasonable value. If the vertical emittance is due only to quantum excitation, then it will likely be several orders of magnitude smaller than any real physical situation, in which case the integral in this function will have problems converging.

In addition to setting mode, also set lat%param%n_part to the number of particles per bunch.

Parameters:
Returns:
  • Tl( float ) –

    Touschek lifetime in seconds

touschek_rate1

Fortran source: bmad/multiparticle/touschek_mod.f90

touschek_rate1(mode: pybmad._pybmad.NormalModesStruct, lat: pybmad._pybmad.LatStruct, ix: typing.SupportsInt | typing.SupportsIndex | None = None, s: typing.SupportsFloat | typing.SupportsIndex | None = None) -> float

Subroutine touschek_rate1(mode, rate, lat, ix, s)

Calculates the touschek rate at the location specified by s or ix This calculation is based on Piwinski 1998 "The Touschek Effect In Strong Focusing Storage Rings". This is the most general case, equation 31.

This function uses twiss_and_track_at_s to determine the Twiss parameters at the location s or element index ix.

A common way to call this function is to first populate mode using radiation integrals. If an ideal lattice is used, the vertical emittance must also be set to a reasonable value. If the vertical emittance is due only to quantum excitation, then it will likely be several orders of magnitude smaller than any real physical situation, in which case the integral in this function will have problems converging. Additionally, mode%pz_aperture needs to be set to the momentum aperture.

In addition to setting mode, also set lat%param%n_part to the number of particles per bunch.

IMPORTANT NOTE: If the lattice type is a circular lattice, then mode%a%emittance and mode%b%emittance are assumed to contain the normalized emittences. If lattice geometry is open, the emittances are assumed to be unnormalized.

IMPORTANT NOTE: The output of this subroutine is the loss rate assuming that two particles are lost per collision, one with too much energy, and one with too little energy. This agrees with Piwinski's original derivation, which assumes that the positive energy aperture is equal in magnitude to the negative energy aperture. If you are studying an accelerator with a non-symmetric energy aperture, then this subroutine should be called twice, once with the positive aperture, and once with the negative aperture, and rate from each call should be halved and summed.

Parameters:
  • mode (NormalModesStruct) –

    beam properties

  • lat (LatStruct) –

    Lattice

  • ix (int) –

    element index (either s or ix must be specified)

  • s (float) –

    location in meters (either s or ix must be specified)

Returns:
  • rate( float ) –

    Touschek rate, in units particle per second, assuming two particles per event.

touschek_rate1_zap

Fortran source: bmad/multiparticle/touschek_mod.f90

touschek_rate1_zap(mode: pybmad._pybmad.NormalModesStruct, rate: typing.SupportsFloat | typing.SupportsIndex, lat: pybmad._pybmad.LatStruct, ix: typing.SupportsInt | typing.SupportsIndex | None = None, s: typing.SupportsFloat | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine touschek_rate1_zap

Parameters:

track1

Fortran source: bmad/modules/bmad_routine_interface.f90

track1(start_orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, track: pybmad._pybmad.TrackStruct | None = None, ignore_radiation: bool | None = None, make_map1: bool | None = None, init_to_edge: bool | None = None) -> pybmad._pybmad.Track1

Wrapper for Fortran routine track1

Parameters:
  • start_orb (CoordStruct) –

    Starting position.

  • ele (EleStruct) –

    Element to track through. This parameter is an input/output and is modified in-place. As an output, ele: Modified if make_map1 is True.

  • param (LatParamStruct) –

    Reference particle info.

  • track (TrackStruct) –

    Structure holding existing track. This parameter is an input/output and is modified in-place. As an output, track: Structure holding the track information if the

  • ignore_radiation (bool) –

    If present and True then do not include radiation effects along with space charge effects.

  • make_map1 (bool) –

    Make ele.mat6 and ele.spin_q components? Default is false.

  • init_to_edge (bool) –

    Default is True. If True then force the tracked particle to begin at the element's edge. See above. Do not use this argument unless you know what you are doing.

Returns:
  • end_orb( CoordStruct ) –

    End position.

  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise. Note: The particle getting lost (EG hitting an aperture) is not an error. An error is something like start_orb not being properly initialized.

track1_beam

Fortran source: bmad/multiparticle/beam_mod.f90

track1_beam(beam: pybmad._pybmad.BeamStruct, ele: pybmad._pybmad.EleStruct, centroid: pybmad._pybmad.CoordStructArray1D | None = None, direction: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Subroutine track1_beam (beam, ele, err, centroid, direction)

Subroutine to track a beam of particles through an element.

Parameters:
  • beam (BeamStruct) –

    Starting beam position. This parameter is an input/output and is modified in-place. As an output, beam: Ending beam position.

  • ele (EleStruct) –

    element to track through.

  • centroid (1D array of CoordStruct) –

    Approximate centroid orbit. Only needed if CSR is on. Hint: Calculate this before beam tracking by tracking a single particle.

  • direction (int) –

    +1 (default) -> Track forward, -1 -> Track backwards.

Returns:
  • err( bool ) –

    Set true if there is an error. EG: Too many particles lost for a CSR calc.

track1_bmad

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_bmad(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> pybmad._pybmad.Track1Bmad

Wrapper for Fortran routine track1_bmad

Parameters:
  • orbit (CoordStruct) –

    Starting position This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Element

  • param (LatParamStruct) –
  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix propagated through the element.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

  • track( (TrackStruct, optional) ) –

    Structure holding the track information if the lattice element does tracking step-by-step. See track1 for more details.

track1_bmad_photon

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_bmad_photon(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> bool

Wrapper for Fortran routine track1_bmad_photon

Parameters:
  • orbit (CoordStruct) –

    Starting position This parameter is an input/output and is modified in-place. As an output, orbit: End position

  • ele (EleStruct) –

    Element

  • param (LatParamStruct) –
Returns:
  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

track1_bunch

Fortran source: bmad/multiparticle/beam_mod.f90

track1_bunch(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, centroid: pybmad._pybmad.CoordStructArray1D | None = None, direction: typing.SupportsInt | typing.SupportsIndex | None = None, bunch_track: pybmad._pybmad.BunchTrackStruct | None = None) -> bool

Subroutine track1_bunch (bunch, ele, err, centroid, direction, bunch_track)

Subroutine to track a bunch of particles through an element.

Parameters:
  • bunch (BunchStruct) –

    Starting bunch position. This parameter is an input/output and is modified in-place. As an output, bunch: Ending bunch position.

  • ele (EleStruct) –

    element to track through.

  • centroid (1D array of CoordStruct) –

    Approximate centroid orbit. Only needed if CSR is on. Hint: Calculate this before beam tracking by tracking a single particle.

  • direction (int) –

    +1 (default) -> Track forward, -1 -> Track backwards.

  • bunch_track (BunchTrackStruct) –

    Existing tracks. If bunch_track.n_pt = -1 then Overwrite any existing track. This parameter is an input/output and is modified in-place. As an output, bunch_track: Track information appended to track.

Returns:
  • err( bool ) –

    Set true if there is an error. EG: Too many particles lost for a CSR calc.

track1_bunch_csr

Fortran source: bmad/space_charge/csr_and_space_charge_mod.f90

track1_bunch_csr(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, centroid: pybmad._pybmad.CoordStructArray1D, s_start: typing.SupportsFloat | typing.SupportsIndex | None = None, s_end: typing.SupportsFloat | typing.SupportsIndex | None = None, bunch_track: pybmad._pybmad.BunchTrackStruct | None = None) -> bool

Subroutine track1_bunch_csr (bunch, ele, centroid, err, s_start, s_end, bunch_track)

Routine to track a bunch of particles through an element with csr radiation effects.

Parameters:
  • bunch (BunchStruct) –

    Starting bunch position. This parameter is an input/output and is modified in-place. As an output, bunch: Ending bunch position.

  • ele (EleStruct) –

    The element to track through. Must be part of a lattice.

  • centroid (1D array of CoordStruct) –

    coord_struct, Approximate beam centroid orbit for the lattice branch. Calculate this before beam tracking by tracking a single particle.

  • s_start (float) –

    Starting position relative to ele. Default = 0

  • s_end (float) –

    Ending position. Default is ele length.

  • bunch_track (BunchTrackStruct) –

    Existing tracks. If bunch_track.n_pt = -1 then Overwrite any existing track. This parameter is an input/output and is modified in-place. As an output, bunch_track: track information if the tracking method does

Returns:
  • err( bool ) –

    Set true if there is an error. EG: Too many particles lost.

track1_bunch_csr3d

Fortran source: bmad/space_charge/csr_and_space_charge_mod.f90

track1_bunch_csr3d(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, centroid: pybmad._pybmad.CoordStructArray1D, s_start: typing.SupportsFloat | typing.SupportsIndex | None = None, s_end: typing.SupportsFloat | typing.SupportsIndex | None = None, bunch_track: pybmad._pybmad.BunchTrackStruct | None = None) -> bool

Subroutine track1_bunch_csr3d (bunch, ele, centroid, err, bunch_track)

EXPERIMENTAL. NOT CURRENTLY OPERATIONAL!

Routine to track a bunch of particles through an element using steady-state 3D CSR.

Parameters:
  • bunch (BunchStruct) –

    Starting bunch position. This parameter is an input/output and is modified in-place. As an output, bunch: Ending bunch position.

  • ele (EleStruct) –

    The element to track through. Must be part of a lattice.

  • centroid (1D array of CoordStruct) –

    coord_struct, Approximate beam centroid orbit for the lattice branch. Calculate this before beam tracking by tracking a single particle.

  • s_start (float) –

    Starting position relative to ele. Default = 0

  • s_end (float) –

    Ending position. Default is ele length.

  • bunch_track (BunchTrackStruct) –

    Existing tracks. If bunch_track.n_pt = -1 then Overwrite any existing track. This parameter is an input/output and is modified in-place. As an output, bunch_track: track information if the tracking method does

Returns:
  • err( bool ) –

    Set true if there is an error. EG: Too many particles lost.

Notes

The core routines are from the OpenCSR package developed at: https://github.com/ChristopherMayes/OpenCSR

track1_bunch_hom

Fortran source: bmad/multiparticle/beam_utils.f90

track1_bunch_hom(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, direction: typing.SupportsInt | typing.SupportsIndex | None = None, bunch_track: pybmad._pybmad.BunchTrackStruct | None = None) -> None

Subroutine track1_bunch_hom (bunch, ele, direction, bunch_track)

Subroutine to track a bunch of particles through an element including wakefields.

Parameters:
  • bunch (BunchStruct) –

    Starting bunch position. This parameter is an input/output and is modified in-place. As an output, bunch: Ending bunch position.

  • ele (EleStruct) –

    The element to track through.

  • direction (int) –

    +1 (default) -> Track forward, -1 -> Track backwards.

  • bunch_track (BunchTrackStruct) –

    Existing tracks. If bunch_track.n_pt = -1 then Overwrite any existing track. This parameter is an input/output and is modified in-place. As an output, bunch_track: Track information appended to track.

track1_bunch_space_charge

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_bunch_space_charge(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, track_to_same_s: bool | None = None, bunch_track: pybmad._pybmad.BunchTrackStruct | None = None) -> bool

Wrapper for Fortran routine track1_bunch_space_charge

Parameters:
  • bunch (BunchStruct) –

    Starting bunch position. This parameter is an input/output and is modified in-place. As an output, bunch: Ending bunch position.

  • ele (EleStruct) –

    Element to track through. Must be part of a lattice.

  • track_to_same_s (bool) –

    Default is True. If True, drift particles to all have the same s-position.

  • bunch_track (BunchTrackStruct) –

    Existing tracks. If bunch_track.n_pt = -1 then Overwrite any existing track. This parameter is an input/output and is modified in-place. As an output, bunch_track: track information if the tracking method does

Returns:
  • err( bool ) –

    Set true if there is an error. EG: Too many particles lost for a CSR calc.

track1_crystal

Fortran source: bmad/photon/track1_photon_mod.f90

track1_crystal(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_crystal (ele, param, orbit)

Routine to track diffraction from a crystal.

Parameters:
  • ele (EleStruct) –

    Element tracking through.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords to be transformed This parameter is an input/output and is modified in-place. As an output, orbit: final phase-space coords

track1_diffraction_plate_or_mask

Fortran source: bmad/photon/track1_photon_mod.f90

track1_diffraction_plate_or_mask(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_diffraction_plate_or_mask (ele, param, orbit)

Routine to track through diffraction plate and mask elements.

Parameters:
  • ele (EleStruct) –

    Diffraction plate or mask element.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords to be transformed This parameter is an input/output and is modified in-place. As an output, orbit: final phase-space coords

track1_high_energy_space_charge

Fortran source: bmad/space_charge/high_energy_space_charge_mod.f90

track1_high_energy_space_charge(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_high_energy_space_charge (ele, param, orbit)

Routine to apply the ultra-relative space charge kick to a particle at the end of an element. The routine setup_high_energy_space_charge_calc must be called initially before any tracking is done. This routine assumes a Gaussian bunch and is only valid with relativistic particles where the effect of the space charge is small.

Parameters:
  • ele (EleStruct) –

    Element tracked through.

  • param (LatParamStruct) –
  • orbit (CoordStruct) –

    Starting position This parameter is an input/output and is modified in-place. As an output, orbit: End position

track1_lens

Fortran source: bmad/photon/track1_photon_mod.f90

track1_lens(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_lens (ele, param, orbit)

Routine to track through a lens.

Parameters:
  • ele (EleStruct) –

    Element tracking through.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords to be transformed This parameter is an input/output and is modified in-place. As an output, orbit: final phase-space coords

track1_linear

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_linear(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> None

Wrapper for Fortran routine track1_linear

Parameters:
  • orbit (CoordStruct) –

    Starting position This parameter is an input/output and is modified in-place. As an output, orbit: End position

  • ele (EleStruct) –

    Element

  • param (LatParamStruct) –

track1_lr_wake

Fortran source: bmad/multiparticle/wake_mod.f90

track1_lr_wake(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct) -> None

Subroutine track1_lr_wake (bunch, ele)

Subroutine to put in the long-range wakes for particle tracking.

Parameters:
  • bunch (BunchStruct) –

    Bunch to track. This parameter is an input/output and is modified in-place. As an output, bunch: Kicked bunch.

  • ele (EleStruct) –

    Element with wakes. This parameter is an input/output and is modified in-place. As an output, ele: Element with updated wake amplitudes.

track1_mad

Fortran source: bmad/modules/mad_mod.f90

track1_mad(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> None

Subroutine track1_mad (orbit, ele, param)

Subroutine to track through an element using a 2nd order transfer map. Note: If map does not exist then one will be created.

Parameters:
  • orbit (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coords.

  • ele (EleStruct) –

    Element to track through.

  • param (LatParamStruct) –

    Lattice parameters.

track1_mirror

Fortran source: bmad/photon/track1_photon_mod.f90

track1_mirror(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_mirror (ele, param, orbit)

Routine to track reflection from a mirror.

Parameters:
  • ele (EleStruct) –

    Element tracking through.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords to be transformed This parameter is an input/output and is modified in-place. As an output, orbit: final phase-space coords

track1_mosaic_crystal

Fortran source: bmad/photon/track1_photon_mod.f90

track1_mosaic_crystal(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_mosaic_crystal (ele, param, orbit)

Routine to track diffraction from a crystal.

Parameters:
  • ele (EleStruct) –

    Element tracking through.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords to be transformed This parameter is an input/output and is modified in-place. As an output, orbit: final phase-space coords

track1_multilayer_mirror

Fortran source: bmad/photon/track1_photon_mod.f90

track1_multilayer_mirror(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_multilayer_mirror (ele, param, orbit)

Routine to track reflection from a multilayer_mirror. Basic equations are from Kohn, "On the Theory of Reflectivity of an X-Ray Multilayer Mirror".

Parameters:
  • ele (EleStruct) –

    Element tracking through.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords to be transformed This parameter is an input/output and is modified in-place. As an output, orbit: final phase-space coords

track1_radiation

Fortran source: bmad/modules/radiation_mod.f90

track1_radiation(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, edge: typing.SupportsInt | typing.SupportsIndex) -> None

Subroutine track1_radiation (orbit, ele, edge)

Subroutine to apply a kick to a particle to account for radiation dampling and/or fluctuations.

For tracking through a given element, this routine should be called initially when the particle is at the entrance end and at the end when the particle is at the exit end, when the orbit is with respect to laboratory (not element body) coordinates. That is, each time this routine is called it applies half the radiation kick for the entire element.

Note: This routine is called by track1.

Parameters:
  • orbit (CoordStruct) –

    Particle position before radiation applied. This parameter is an input/output and is modified in-place. As an output, orbit: Particle position after radiation has been applied.

  • ele (EleStruct) –

    Element generating radiation.

  • edge (int) –

    Where the particle is: start_edge$ or end_edge$.

track1_radiation_center

Fortran source: bmad/modules/radiation_mod.f90

track1_radiation_center(orbit: pybmad._pybmad.CoordStruct, ele1: pybmad._pybmad.EleStruct, ele2: pybmad._pybmad.EleStruct, rad_damp: bool | None = None, rad_fluct: bool | None = None) -> None

Subroutine track1_radiation_center (orbit, ele1, ele2, rad_damp, rad_fluct)

Used for elements that have been split in half: This routine applies a kick to a particle to account for radiation dampling and/or fluctuations.

Also see: track1_radiation.

Parameters:
  • orbit (CoordStruct) –

    Particle at center of element before radiation applied. This parameter is an input/output and is modified in-place. As an output, orbit: Particle position after radiation has been applied.

  • ele1 (EleStruct) –

    First half of the split element.

  • ele2 (EleStruct) –

    Second half of the split element.

  • rad_damp (bool) –

    If present, override setting of bmad_com.radiation_damping_on.

  • rad_fluct (bool) –

    If present, override setting of bmad_com.radiation_fluctuations_on.

track1_runge_kutta

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_runge_kutta(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> pybmad._pybmad.Track1RungeKutta

Wrapper for Fortran routine track1_runge_kutta

Parameters:
  • orbit (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coords.

  • ele (EleStruct) –

    Ele_struct

  • param (LatParamStruct) –

    Lattice parameters.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix propagated through the element.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

  • track( (TrackStruct, optional) ) –

    Structure holding the track information.

track1_sample

Fortran source: bmad/photon/track1_photon_mod.f90

track1_sample(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, orbit: pybmad._pybmad.CoordStruct) -> None

Subroutine track1_sample (ele, param, orbit)

Routine to track reflection from a sample element.

Parameters:
  • ele (EleStruct) –

    Element tracking through.

  • param (LatParamStruct) –

    lattice parameters.

  • orbit (CoordStruct) –

    phase-space coords to be transformed This parameter is an input/output and is modified in-place. As an output, orbit: final phase-space coords

track1_spin

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_spin(start_orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, end_orb: pybmad._pybmad.CoordStruct, make_quaternion: bool | None = None) -> None

Wrapper for Fortran routine track1_spin

Parameters:
  • start_orb (CoordStruct) –

    Starting coords.

  • ele (EleStruct) –

    Element to track through.

  • param (LatParamStruct) –

    Beam parameters.

  • end_orb (CoordStruct) –

    Ending coords.

  • make_quaternion (bool) –

    If present and true then calculate the 1st order spin map which is represented as a quaternion.

track1_spin_integration

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_spin_integration(start_orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, end_orb: pybmad._pybmad.CoordStruct) -> None

Wrapper for Fortran routine track1_spin_integration

Parameters:

track1_spin_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_spin_taylor(start_orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> pybmad._pybmad.CoordStruct

Wrapper for Fortran routine track1_spin_taylor

Parameters:
Returns:

track1_sr_wake

Fortran source: bmad/multiparticle/wake_mod.f90

track1_sr_wake(bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct) -> None

Subroutine track1_sr_wake (bunch, ele)

Subroutine to apply the short range wake fields to a bunch.

Parameters:
  • bunch (BunchStruct) –

    Bunch of particles. This parameter is an input/output and is modified in-place. As an output, bunch: Bunch with wakefields applied to the particles.

  • ele (EleStruct) –

    Element with wakefields.

track1_symp_lie_ptc

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_symp_lie_ptc(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> pybmad._pybmad.TrackStruct

Wrapper for Fortran routine track1_symp_lie_ptc

Parameters:
  • orbit (CoordStruct) –

    Starting position This parameter is an input/output and is modified in-place. As an output, orbit: End position

  • ele (EleStruct) –

    Element

  • param (LatParamStruct) –
Returns:
  • track( (TrackStruct, optional) ) –

    Structure holding the track information.

track1_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_taylor(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, taylor: pybmad._pybmad.TaylorStructArray1D | None = None, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track1_taylor

Parameters:
  • orbit (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coords.

  • ele (EleStruct) –

    Element to track through.

  • taylor (1D array of TaylorStruct (shape: 6)) –

    Alternative map to use instead of ele.taylor.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track1_time_runge_kutta

Fortran source: bmad/modules/bmad_routine_interface.f90

track1_time_runge_kutta(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, t_end: typing.SupportsFloat | typing.SupportsIndex | None = None, dt_step: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.Track1TimeRungeKutta

Wrapper for Fortran routine track1_time_runge_kutta

Parameters:
  • orbit (CoordStruct) –

    starting position, z-based coords This parameter is an input/output and is modified in-place. As an output, orbit: end position, z-based coords

  • ele (EleStruct) –

    element

  • param (LatParamStruct) –

    lattice parameters

  • t_end (float) –

    If present, maximum time to which the particle will be tracked. Used for tracking with given time steps. The time orb.t at which tracking stops may be less than this if the particle gets to the end of the element

  • dt_step (float) –

    If positive, next RK time step to take. This overrides bmad_com.init_ds_adaptive_tracking. Used by track_bunch_time. This parameter is an input/output and is modified in-place. As an output, dt_step: Next RK time step that this tracker would take based on the error tolerance.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise

  • track( (TrackStruct, optional) ) –

    Contains array of the step-by-step particle trajectory along with the field at these positions. When tracking through multiple elements, the trajectory in an element is appended to the existing trajectory. To reset: Set track.n_pt = -1.

  • dt_step( (float, optional) ) –

    If positive, next RK time step to take. This overrides bmad_com.init_ds_adaptive_tracking. Used by track_bunch_time. This parameter is an input/output and is modified in-place. As an output, dt_step: Next RK time step that this tracker would take based on the error tolerance.

track_a_beambeam

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_beambeam(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> pybmad._pybmad.TrackABeambeam

Wrapper for Fortran routine track_a_beambeam

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Beambeam element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • track( (TrackStruct, optional) ) –

    Structure holding the track information if the lattice element does tracking step-by-step. See track1 for more details.

  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_bend

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_bend(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine track_a_bend

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Bend element.

  • param (LatParamStruct) –

    Lattice parameters.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix to the element end.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

track_a_bend_photon

Fortran source: bmad/photon/track1_photon_mod.f90

track_a_bend_photon(orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, length: typing.SupportsFloat | typing.SupportsIndex) -> None

Subroutine track_a_bend_photon (orb, ele, length)

Routine to track a photon through a dipole bend. The photon is traveling in a straight line but the reference frame is curved in a circular shape.

Parameters:
  • orb (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orb: End position.

  • ele (EleStruct) –

    Bend element.

  • length (float) –

    length to track.

track_a_capillary

Fortran source: bmad/photon/capillary_mod.f90

track_a_capillary(orb: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> None

Subroutine track_a_capillary (orb, ele)

Routine to track through a capillary.

Parameters:
  • orb (CoordStruct) –

    Input photon coordinates. This parameter is an input/output and is modified in-place. As an output, orb: Output photon coordinates.

  • ele (EleStruct) –

    Capillary element

track_a_converter

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_converter(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_converter

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    converter element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_crab_cavity

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_crab_cavity(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_crab_cavity

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    crab_cavity element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_drift

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_drift(orb: pybmad._pybmad.CoordStruct, length: typing.SupportsFloat | typing.SupportsIndex, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None, ele_orientation: typing.SupportsInt | typing.SupportsIndex | None = None, include_ref_motion: bool | None = None, time: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.TrackADrift

Wrapper for Fortran routine track_a_drift

Parameters:
  • orb (CoordStruct) –

    Orbit at start of the drift. This parameter is an input/output and is modified in-place. As an output, orb: Orbit at end of the drift.

  • length (float) –

    Length to drift through in body coordinates. -- If orb.direction = 1, positive length is in +z direction and vice versa.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the drift. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix including the drift.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

  • ele_orientation (int) –

    Element orientation. Default is orb.direction.

  • include_ref_motion (bool) –

    Include effect of the motion of the reference particle? Default is True. False is basically only used by offset_particle. Additionally, if False, orb.s is not changed.

  • time (float) –

    Particle time before drifting. Typically this is an RF clock time which may not be equal to orb.t This parameter is an input/output and is modified in-place. As an output, time: Updated time.

Returns:
  • time( (float, optional) ) –

    Particle time before drifting. Typically this is an RF clock time which may not be equal to orb.t This parameter is an input/output and is modified in-place. As an output, time: Updated time.

track_a_drift_photon

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_drift_photon(orb: pybmad._pybmad.CoordStruct, length: typing.SupportsFloat | typing.SupportsIndex, phase_relative_to_ref: bool) -> None

Wrapper for Fortran routine track_a_drift_photon

Parameters:
  • orb (CoordStruct) –

    Orbit at start of the drift. This parameter is an input/output and is modified in-place. As an output, orb: Orbit at end of the drift

  • length (float) –

    Longitudinal length to drift through.

  • phase_relative_to_ref (bool) –

    If true then E field phase shift is relative to ref particle.

track_a_foil

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_foil(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_foil

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    foil element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is False.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_gkicker

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_gkicker(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine track_a_gkicker

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Gkicker

  • param (LatParamStruct) –

    Lattice parameters.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix through the element.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

track_a_lcavity

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_lcavity(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine track_a_lcavity

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Thick multipole element.

  • param (LatParamStruct) –

    Lattice parameters.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix through the element.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

track_a_lcavity_old

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_lcavity_old(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine track_a_lcavity_old

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Thick multipole element.

  • param (LatParamStruct) –

    Lattice parameters.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix through the element.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

track_a_mask

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_mask(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_mask

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Mask element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_match

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_match(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, err_flag: bool | None = None, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_match

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Match element.

  • param (LatParamStruct) –

    Lattice parameters.

  • err_flag (bool) –
  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_patch

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_patch(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, drift_to_exit: bool | None = None, track_spin: bool | None = None, make_matrix: bool | None = None) -> pybmad._pybmad.TrackAPatch

Wrapper for Fortran routine track_a_patch

Parameters:
  • ele (EleStruct) –

    patch element.

  • orbit (CoordStruct) –

    Starting phase space coords This parameter is an input/output and is modified in-place. As an output, orbit: Coords after applying a patch transformation.

  • drift_to_exit (bool) –

    If False then do not drift the particle from beginning to end face. Also do not correct for a reference energy shift. Default is True.

  • track_spin (bool) –

    If True rotate the spin vector appropriately. If ele.spin_tracking_method = symp_lie_ptc -> default = True. Else default = False.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • s_ent( (float, optional) ) –

    Longitudinal coordinate of the initial particle position in the frame of reference of the face where the particle exits. For a patch with positive z_offset and all other attributes zero, s_ent = -z_offset.

  • ds_ref( (float, optional) ) –

    Distance reference particle travels from entrance to exit.

  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_patch_photon

Fortran source: bmad/photon/track1_photon_mod.f90

track_a_patch_photon(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, drift_to_exit: bool | None = None, use_z_pos: bool | None = None) -> None

Subroutine track_a_patch_photon (ele, orbit, drift_to_exit, use_z_pos)

Routine to track through a patch element with a photon. The steps for tracking are: 1) Transform from entrance to exit coordinates. 2) Drift particle from the entrance to the exit coordinants.

Parameters:
  • ele (EleStruct) –

    patch element.

  • orbit (CoordStruct) –

    Starting phase space coords This parameter is an input/output and is modified in-place. As an output, orbit: Coords after applying a patch transformation.

  • drift_to_exit (bool) –

    If False then do not drift the particle from start to ending faces. Default is True.

  • use_z_pos (bool) –

    If present and True, use orbit.vec(5) as the true z-position relative to the start of the element instead of assuming that the particle is at the patch edge.

track_a_pickup

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_pickup(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, err_flag: bool | None = None, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_pickup

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Pickup element.

  • param (LatParamStruct) –

    Lattice parameters.

  • err_flag (bool) –
  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_quadrupole

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_quadrupole(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_quadrupole

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Quadrupole element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_rfcavity

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_rfcavity(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_rfcavity

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    rfcavity element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_sad_mult

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_sad_mult(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine track_a_sad_mult

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Sad_mult element.

  • param (LatParamStruct) –

    Lattice parameters.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix up to the sad_mult. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

track_a_sol_quad

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_sol_quad(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_sol_quad

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Sol_quad or solenoid element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_thick_multipole

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_thick_multipole(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, mat6: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"] | None = None, make_matrix: bool | None = None) -> None

Wrapper for Fortran routine track_a_thick_multipole

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Thick multipole element.

  • param (LatParamStruct) –

    Lattice parameters.

  • mat6 (2D array of float (shape: 6,6)) –

    Transfer matrix before the element. This parameter is an input/output and is modified in-place. As an output, mat6: Transfer matrix through the element.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

track_a_wiggler

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_wiggler(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, make_matrix: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"] | None

Wrapper for Fortran routine track_a_wiggler

Parameters:
  • orbit (CoordStruct) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, orbit: End position.

  • ele (EleStruct) –

    Wiggler element.

  • param (LatParamStruct) –

    Lattice parameters.

  • make_matrix (bool) –

    Propagate the transfer matrix? Default is false.

Returns:
  • mat6( 2D array of float (shape: 6,6), optional ) –

    Transfer matrix through the element.

track_a_zero_length_element

Fortran source: bmad/modules/bmad_routine_interface.f90

track_a_zero_length_element(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> pybmad._pybmad.TrackAZeroLengthElement

Wrapper for Fortran routine track_a_zero_length_element

Parameters:
  • orbit (CoordStruct) –

    Starting coords. This parameter is an input/output and is modified in-place. As an output, orbit: Ending coords.

  • ele (EleStruct) –

    Element tracked through.

  • param (LatParamStruct) –

    Lattice parameters.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

  • track( (TrackStruct, optional) ) –

    Structure holding the track information.

track_all

Fortran source: bmad/modules/bmad_routine_interface.f90

track_all(lat: pybmad._pybmad.LatStruct, orbit: pybmad._pybmad.CoordStructAlloc1D, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, init_lost: bool | None = None) -> pybmad._pybmad.TrackAll

Wrapper for Fortran routine track_all

Parameters:
  • lat (LatStruct) –

    Lat to track through.

  • orbit (1D array of CoordStruct) –

    orbit(0) is the starting coordinates for tracking. If not allocated, the zero orbit will be used. This parameter is an input/output and is modified in-place. As an output, orbit: Orbit array.

  • ix_branch (int) –

    Index of branch to track. Default is 0 (main branch).

  • init_lost (bool) –

    Default if False. If True, initialize orbit(N) terms that are not tracked through due to particle loss.

Returns:
  • track_state( (int, optional) ) –

    Set to moving_forward$ if everything is OK. Otherwise: set to index of element where particle was lost.

  • err_flag( (bool, optional) ) –

    Set true if particle lost or error. False otherwise

  • orbit0( 1D array of CoordStruct, optional ) –

    Orbit array for branch 0. Used to fill in the orbit at lord elemenets. Only needed when orbit(:) is not the orbit for branch 0.

track_beam

Fortran source: bmad/multiparticle/beam_mod.f90

track_beam(lat: pybmad._pybmad.LatStruct, beam: pybmad._pybmad.BeamStruct, ele1: pybmad._pybmad.EleStruct | None = None, ele2: pybmad._pybmad.EleStruct | None = None, centroid: pybmad._pybmad.CoordStructArray1D | None = None, direction: typing.SupportsInt | typing.SupportsIndex | None = None, bunch_tracks: pybmad._pybmad.BunchTrackStructArray1D | None = None) -> bool

Subroutine track_beam (lat, beam, ele1, ele2, err, centroid, direction, bunch_tracks)

Subroutine to track a beam of particles from the end of ele1 Through to the end of ele2. Both must be in the same lattice branch.

Note: To zero wakes between runs, zero_lr_wakes_in_lat needs to be called.

Parameters:
  • lat (LatStruct) –

    Lattice to track through.

  • beam (BeamStruct) –

    Beam at end of element ix1. This parameter is an input/output and is modified in-place. As an output, beam: Beam at end of element ix2.

  • ele1 (EleStruct) –

    Starting element (this element is NOT tracked through). Default is lat.ele(0).

  • ele2 (EleStruct) –

    Ending element. Default is lat.ele(lat.n_ele_track).

  • centroid (1D array of CoordStruct) –

    Approximate centroid orbit. Only needed if CSR is on. Hint: Calculate this before beam tracking by tracking a single particle.

  • direction (int) –

    +1 (default) -> Track forward, -1 -> Track backwards.

  • bunch_tracks (1D array of BunchTrackStruct) –

    Existing tracks. If bunch_track.n_pt = -1 then Overwrite any existing track. This parameter is an input/output and is modified in-place. As an output, bunch_tracks: track information if the tracking method does

Returns:
  • err( bool ) –

    Set true if there is an error. EG: Too many particles lost for a CSR calc.

track_bunch

Fortran source: bmad/multiparticle/beam_mod.f90

track_bunch(lat: pybmad._pybmad.LatStruct, bunch: pybmad._pybmad.BunchStruct, ele1: pybmad._pybmad.EleStruct | None = None, ele2: pybmad._pybmad.EleStruct | None = None, centroid: pybmad._pybmad.CoordStructArray1D | None = None, direction: typing.SupportsInt | typing.SupportsIndex | None = None, bunch_track: pybmad._pybmad.BunchTrackStruct | None = None) -> bool

Subroutine track_bunch (lat, bunch, ele1, ele2, err, centroid, direction, bunch_track)

Subroutine to track a particle bunch from the end of ele1 Through to the end of ele2. Both must be in the same lattice branch. With forward tracking, if ele2 is at or before ele1, the tracking will "wrap" around the ends of the lattice.

Note: To zero wakes between runs, zero_lr_wakes_in_lat needs to be called.

Parameters:
  • lat (LatStruct) –

    Lattice to track through.

  • bunch (BunchStruct) –

    Bunch at end of element ix1. This parameter is an input/output and is modified in-place. As an output, bunch: Bunch at end of element ix2.

  • ele1 (EleStruct) –

    Starting element (this element is NOT tracked through). Default is lat.ele(0).

  • ele2 (EleStruct) –

    Ending element. Default is lat.ele(lat.n_ele_track).

  • centroid (1D array of CoordStruct) –

    Approximate centroid orbit. Only needed if CSR is on. Hint: Calculate this before bunch tracking by tracking a single particle.

  • direction (int) –

    +1 (default) -> Track forward, -1 -> Track backwards.

  • bunch_track (BunchTrackStruct) –

    Existing tracks. If bunch_track.n_pt = -1 then Overwrite any existing track. This parameter is an input/output and is modified in-place. As an output, bunch_track: track information if the tracking method does

Returns:
  • err( bool ) –

    Set true if there is an error. EG: Too many particles lost for a CSR calc.

track_bunch_time

Fortran source: bmad/modules/bmad_routine_interface.f90

track_bunch_time(bunch: pybmad._pybmad.BunchStruct, branch: pybmad._pybmad.BranchStruct, t_end: typing.SupportsFloat | typing.SupportsIndex, s_end: typing.SupportsFloat | typing.SupportsIndex, dt_step: pybmad._pybmad.RealArray1D | None = None, extra_field: pybmad._pybmad.EmFieldStructArray1D | None = None) -> None

Wrapper for Fortran routine track_bunch_time

Parameters:
  • bunch (BunchStruct) –

    Coordinates must be time-coords in element body frame. This parameter is an input/output and is modified in-place. As an output, bunch: Coordinates will be time-coords in element body frame.

  • branch (BranchStruct) –

    Lattice branch being tracked through.

  • t_end (float) –

    Ending time.

  • s_end (float) –

    Ending s-position.

  • dt_step (1D array of float) –

    Initial step to take for each particle. Overrides bmad_com.init_ds_adaptive_tracking. This parameter is an input/output and is modified in-place. As an output, dt_step: Next RK time step that this tracker would take based on the error tolerance.

  • extra_field (1D array of EmFieldStruct) –

    Per particle static field to be added to the lattice element field. Eg used with space charge.

track_bunch_to_s

Fortran source: bmad/space_charge/space_charge_mod.f90

track_bunch_to_s(bunch: pybmad._pybmad.BunchStruct, s: typing.SupportsFloat | typing.SupportsIndex, branch: pybmad._pybmad.BranchStruct) -> None

Subroutine track_bunch_to_s (bunch, s, branch)

Drift a bunch of particles to the same s coordinate

Parameters:
  • bunch (BunchStruct) –

    Input bunch position in s-based coordinate. This parameter is an input/output and is modified in-place. As an output, bunch: Output bunch position in s-based coordinate. Particles will be at the same s coordinate

  • s (float) –

    Target coordinate.

  • branch (BranchStruct) –

    Branch being tracked through.

track_bunch_to_t

Fortran source: bmad/space_charge/space_charge_mod.f90

track_bunch_to_t(bunch: pybmad._pybmad.BunchStruct, t_target: typing.SupportsFloat | typing.SupportsIndex, branch: pybmad._pybmad.BranchStruct) -> None

Subroutine track_bunch_to_t (bunch, t_target, branch)

Drift a bunch of particles to the same t coordinate

Parameters:
  • bunch (BunchStruct) –

    Input bunch position in s-based coordinate. This parameter is an input/output and is modified in-place. As an output, bunch: Output bunch position in s-based coordinate. Particles will be at the same t coordinate

  • t_target (float) –

    Target t coordinate.

  • branch (BranchStruct) –

    Lattice branch being tracked through.

track_complex_taylor

Fortran source: bmad/modules/complex_taylor_mod.f90

track_complex_taylor(start_orb: pybmad._pybmad.ComplexArray1D, complex_taylor: pybmad._pybmad.ComplexTaylorStructArray1D, end_orb: pybmad._pybmad.ComplexArray1D) -> None

Subroutine track_complex_taylor (start_orb, complex_taylor, end_orb)

Subroutine to track using a complex_taylor map.

Parameters:
  • start_orb (1D array of complex) –

    Starting coords.

  • complex_taylor (1D array of ComplexTaylorStruct) –

    complex_taylor map.

  • end_orb (1D array of complex) –

    Ending coords.

track_from_s_to_s

Fortran source: bmad/modules/bmad_routine_interface.f90

track_from_s_to_s(lat: pybmad._pybmad.LatStruct, s_start: typing.SupportsFloat | typing.SupportsIndex, s_end: typing.SupportsFloat | typing.SupportsIndex, orbit_start: pybmad._pybmad.CoordStruct, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, ix_ele_end: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.TrackFromSToS

Wrapper for Fortran routine track_from_s_to_s

Parameters:
  • lat (LatStruct) –

    Lattice to track through

  • s_start (float) –

    Starting s-position.

  • s_end (float) –

    Ending s-position. If <= s_start then will wrap

  • orbit_start (CoordStruct) –

    Starting coordinates.

  • ix_branch (int) –

    Lattice branch index. Default is 0 (main branch).

  • ix_ele_end (int) –

    If present, ignore s_end and track to in between ix_ele_end and ix_ele_end+1

Returns:
  • orbit_end( CoordStruct ) –

    Ending coordinates.

  • all_orb( 1D array of CoordStruct, optional ) –

    If present then the orbit at the exit ends of the elements tracked through will be recorded in this structure.

  • track_state( (int, optional) ) –

    Set to moving_forward$ if everything is OK. Otherwise: set to index of element where particle was lost.

track_many

Fortran source: bmad/modules/bmad_routine_interface.f90

track_many(lat: pybmad._pybmad.LatStruct, orbit: pybmad._pybmad.CoordStructArray1D, ix_start: typing.SupportsInt | typing.SupportsIndex, ix_end: typing.SupportsInt | typing.SupportsIndex, direction: typing.SupportsInt | typing.SupportsIndex, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> int

Wrapper for Fortran routine track_many

Parameters:
  • lat (LatStruct) –

    Lat to track through.

  • orbit (1D array of CoordStruct) –

    Coordinates at start of tracking. This parameter is an input/output and is modified in-place. As an output, orbit: Orbit.

  • ix_start (int) –

    Start index (See Note).

  • ix_end (int) –

    End index (See Note).

  • direction (int) –

    Direction to track. = +1 -> Track forward (+s) = -1 -> Track backward (-s)

  • ix_branch (int) –

    Branch to track. Default is 0 (main lattice).

Returns:
  • track_state( (int, optional) ) –

    Set to moving_forward$ if everything is OK. Otherwise: set to index of element where particle was lost.

track_to_surface

Fortran source: bmad/modules/bmad_routine_interface.f90

track_to_surface(ele: pybmad._pybmad.EleStruct, orbit: pybmad._pybmad.CoordStruct, param: pybmad._pybmad.LatParamStruct) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(3)"]], "FixedSize(3)"]

Wrapper for Fortran routine track_to_surface

Parameters:
  • ele (EleStruct) –

    Element

  • orbit (CoordStruct) –

    Coordinates in the element coordinate frame This parameter is an input/output and is modified in-place. As an output, orbit: At surface in local surface coordinate frame

  • param (LatParamStruct) –

    Branch parameters.

Returns:
  • w_surface( 2D array of float (shape: 3,3) ) –

    real(rp), rotation matrix to transform to surface coords.

track_until_dead

Fortran source: bmad/modules/time_tracker_mod.f90

track_until_dead(start_orb: pybmad._pybmad.CoordStruct, lat: pybmad._pybmad.LatStruct) -> pybmad._pybmad.TrackUntilDead

subroutine track_until_dead (start_orb, lat, end_orb, track)

Subroutine to track a particle arbitrarily through a lattice, forwards or backwards, until it is lost or exits the lattice.

The starting element is located using start_orb%s.

Parameters:
  • start_orb (CoordStruct) –

    Starting coords.

  • lat (LatStruct) –

    lattice that contains and element at start_orb.s

Returns:

tracking_rad_map_setup

Fortran source: bmad/modules/bmad_routine_interface.f90

tracking_rad_map_setup(ele: pybmad._pybmad.EleStruct, tollerance: typing.SupportsFloat | typing.SupportsIndex, ref_edge: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.TrackingRadMapSetup

Wrapper for Fortran routine tracking_rad_map_setup

Parameters:
  • ele (EleStruct) –

    Element to setup. Matrices will be with respect to the map reference orbit.

  • tollerance (float) –

    Tolerance used for the computation.

  • ref_edge (int) –

    Edge that the matrices are referenced to. upstream_end$ or downstream_end$.

Returns:
  • rad_map( RadMapStruct ) –

    Structure holding the matrices.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

transfer_ac_kick

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_ac_kick(ac_in: pybmad._pybmad.AcKickerStruct) -> pybmad._pybmad.AcKickerStruct | None

Wrapper for Fortran routine transfer_ac_kick

Parameters:
Returns:

transfer_branch

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_branch(branch1: pybmad._pybmad.BranchStruct) -> pybmad._pybmad.BranchStruct

Wrapper for Fortran routine transfer_branch

Parameters:
Returns:

transfer_branch_parameters

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_branch_parameters(branch_in: pybmad._pybmad.BranchStruct) -> pybmad._pybmad.BranchStruct

Wrapper for Fortran routine transfer_branch_parameters

Parameters:
Returns:
  • branch_out( BranchStruct ) –

    Output branch with parameters set.

transfer_branches

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_branches(branch1: pybmad._pybmad.BranchStructArray1D, branch2: pybmad._pybmad.BranchStructArray1D) -> None

Wrapper for Fortran routine transfer_branches

Parameters:
  • branch1 (1D array of BranchStruct) –
  • branch2 (1D array of BranchStruct) –

transfer_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_ele(ele1: pybmad._pybmad.EleStruct, nullify_pointers: bool | None = None) -> pybmad._pybmad.EleStruct

Wrapper for Fortran routine transfer_ele

Parameters:
  • ele1 (EleStruct) –
  • nullify_pointers (bool) –

    If present and True then nullify the pointers in ele2 except for the ele2.lat and ele2.lord pointers. This gives a "bare bones" copy where one does not have to worry about deallocating allocated structure components later.

Returns:

transfer_ele_taylor

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_ele_taylor(ele_in: pybmad._pybmad.EleStruct, taylor_order: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.EleStruct

Wrapper for Fortran routine transfer_ele_taylor

Parameters:
  • ele_in (EleStruct) –

    Element with the Taylor map.

  • taylor_order (int) –

    Order to truncate the Taylor map at.

Returns:
  • ele_out( EleStruct ) –

    Element receiving the Taylor map truncated to order taylor_order.

transfer_eles

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_eles(ele1: pybmad._pybmad.EleStructArray1D, ele2: pybmad._pybmad.EleStructArray1D) -> None

Wrapper for Fortran routine transfer_eles

Parameters:
  • ele1 (1D array of EleStruct) –
  • ele2 (1D array of EleStruct) –

transfer_fieldmap

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_fieldmap(ele_in: pybmad._pybmad.EleStruct, who: typing.SupportsInt | typing.SupportsIndex) -> pybmad._pybmad.EleStruct

Wrapper for Fortran routine transfer_fieldmap

Parameters:
  • ele_in (EleStruct) –

    Input element.

  • who (int) –

    Possibilities are: all\(, cartesian_map\), cylindrical_map\(, or grid_field\)

Returns:

transfer_fixer_params

Fortran source: bmad/modules/fixer_mod.f90

transfer_fixer_params(fixer: pybmad._pybmad.EleStruct, to_stored: bool, orbit: pybmad._pybmad.CoordStruct | None = None, who: str | None = None) -> bool

Function transfer_fixer_params(fixer, to_stored, orbit, who) result (is_ok)

Set parameters of fixer.

Parameters:
  • fixer (EleStruct) –

    Fixer element to set.

  • to_stored (bool) –

    If False, set real Twiss from stored. If True, set stored Twiss from real.

  • orbit (CoordStruct) –

    Used for 'phase_space' transfers. Used for input if to_stored = True. This parameter is an input/output and is modified in-place. As an output, orbit: Used for 'phase_space' transfers. Used for output if to_stored = False.

  • who (str) –

    Who to set. Possibilities are: Groups: 'all', ' ' (default and same as 'all') Note: This excludes all 'start' sets., 'twiss', 'a_twiss', 'b_twiss', 'cmat', 'x_dispersion', 'y_dispersion', 'dispersion', 'chromatic', 'orbit', 'phase_space', 'spin', 'x_plane', 'y_plane', 'z_plane', 'start', 'start_spin', 'start_phase_space', Individula Parameters: 'x', 'px', 'cmat_11', etc.

Returns:
  • is_ok( bool ) –

    logical

transfer_lat

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_lat(lat1: pybmad._pybmad.LatStruct) -> pybmad._pybmad.LatStruct

Wrapper for Fortran routine transfer_lat

Parameters:
Returns:

transfer_lat_parameters

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_lat_parameters(lat_in: pybmad._pybmad.LatStruct) -> pybmad._pybmad.LatStruct

Wrapper for Fortran routine transfer_lat_parameters

Parameters:
Returns:
  • lat_out( LatStruct ) –

    Output lat with parameters set.

transfer_map_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_map_calc(lat: pybmad._pybmad.LatStruct, orb_map: pybmad._pybmad.TaylorStructArray1D, ix1: typing.SupportsInt | typing.SupportsIndex | None = None, ix2: typing.SupportsInt | typing.SupportsIndex | None = None, ref_orb: pybmad._pybmad.CoordStruct | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, one_turn: bool | None = None, unit_start: bool | None = None, concat_if_possible: bool | None = None, spin_map: pybmad._pybmad.TaylorStructArray1D | None = None) -> bool

Wrapper for Fortran routine transfer_map_calc

Parameters:
  • lat (LatStruct) –

    Lattice used in the calculation.

  • orb_map (1D array of TaylorStruct) –

    Initial map (used when unit_start = False) This parameter is an input/output and is modified in-place. As an output, orb_map: Transfer map.

  • ix1 (int) –

    Element start index for the calculation. Default is 0.

  • ix2 (int) –

    Element end index for the calculation. Default is lat.n_ele_track.

  • ref_orb (CoordStruct) –

    Reference orbit/particle at s1 around which the map is made. This arg is needed if: unit_start = True or particle is not the same as the reference particle of the lattice.

  • ix_branch (int) –

    Lattice branch index. Default is 0.

  • one_turn (bool) –

    If present and True, and if ix1 = ix2, and the lattice is circular, then construct the one-turn map from ix1 back to ix1. Default = False.

  • unit_start (bool) –

    If present and False then orb_map will be used as the starting map instead of the unit map. Default = True

  • concat_if_possible (bool) –

    If present and True then use map concatenation rather than tracking if a map is present for a given lattice element. See above. Default is False.

  • spin_map (1D array of TaylorStruct) –

    Input quaternion spin map. Output only computed if bmad_com.spin_tracking_on = T This parameter is an input/output and is modified in-place. As an output, spin_map: Quaternion spin map.

Returns:
  • err_flag( bool ) –

    Set True if problem like number overflow, etc.

transfer_map_from_s_to_s

Fortran source: bmad/modules/transfer_map_mod.f90

transfer_map_from_s_to_s(lat: pybmad._pybmad.LatStruct, t_map: pybmad._pybmad.TaylorStructArray1D, s1: typing.SupportsFloat | typing.SupportsIndex | None = None, s2: typing.SupportsFloat | typing.SupportsIndex | None = None, ref_orb_in: pybmad._pybmad.CoordStruct | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, one_turn: bool | None = None, unit_start: bool | None = None, concat_if_possible: bool | None = None, spin_map: pybmad._pybmad.TaylorStructArray1D | None = None) -> pybmad._pybmad.TransferMapFromSToS

Subroutine transfer_map_from_s_to_s (lat, t_map, s1, s2, ref_orb_in, ref_orb_out, ix_branch, one_turn, unit_start, err_flag, concat_if_possible, spin_map)

Subroutine to calculate the transfer map between longitudinal positions s1 to s2.

If s2 < s1 and lat%param%geometry is closed$ then the calculation will 'wrap around' the lattice end. For example, if s1 = 900 and s2 = 10 then the t_map is the map from element 900 to the lattice end plus from 0 through 10.

If s2 < s1 and lat%param%geometry is open$ then the inverse of the forward map of s2 -> s1 is computed.

If s2 = s1 then you get the unit map except if one_turn = True and the lattice is circular.

Parameters:
  • lat (LatStruct) –

    Lattice used in the calculation.

  • t_map (1D array of TaylorStruct) –

    Initial map (used when unit_start = False) This parameter is an input/output and is modified in-place. As an output, t_map: Transfer map.

  • s1 (float) –

    Element start position for the calculation. Default is 0.

  • s2 (float) –

    Element end position for the calculation. Default is lat.param.total_length.

  • ref_orb_in (CoordStruct) –

    Reference orbit/particle at s1 around which the map is made. This arg is needed if: unit_start = True or particle is not the same as the reference particle of the lattice.

  • ix_branch (int) –

    Lattice branch index. Default is 0 (main branch).

  • one_turn (bool) –

    If present and True, and s1 = s2, and the lattice is circular: Construct the one-turn map from s1 back to s1. Otherwise t_map is unchanged or the unit map if unit_start = T. Default = False.

  • unit_start (bool) –

    If present and False then t_map will be used as the starting map instead of the unit map. Default = True

  • concat_if_possible (bool) –

    If present and True then use map concatenation rather than tracking if a map is present for a given lattice element. See above. Default is False.

  • spin_map (1D array of TaylorStruct) –

    Initial spin map. This parameter is an input/output and is modified in-place. As an output, spin_map: Final spin map. Only computed if bmad_com.spin_tracking_on = T.

Returns:
  • ref_orb_out( (CoordStruct, optional) ) –

    Ending coordinates of the reference orbit. This is also the actual orbit of particle

  • err_flag( (bool, optional) ) –

    Set true if there is an error. False otherwise.

transfer_mat2_from_twiss

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_mat2_from_twiss(twiss1: pybmad._pybmad.TwissStruct, twiss2: pybmad._pybmad.TwissStruct) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(2)"]], "FixedSize(2)"]

Wrapper for Fortran routine transfer_mat2_from_twiss

Parameters:
  • twiss1 (TwissStruct) –

    Twiss parameters at the initial point.

  • twiss2 (TwissStruct) –

    Twiss parameters at the end point.

Returns:
  • mat( 2D array of float (shape: 2,2) ) –

    Transfer matrix between the two points.

transfer_mat_from_twiss

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_mat_from_twiss(ele1: pybmad._pybmad.EleStruct, ele2: pybmad._pybmad.EleStruct, orb1: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"], orb2: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(6)"]], "FixedSize(6)"]

Wrapper for Fortran routine transfer_mat_from_twiss

Parameters:
  • ele1 (EleStruct) –

    Element with twiss parameters for the starting point.

  • ele2 (EleStruct) –

    Element with twiss parameters for the ending point.

  • orb1 (1D array of float (shape: 6)) –

    Reference orbit at ele1 (affects m(i,6) dispersion terms).

  • orb2 (1D array of float (shape: 6)) –

    Reference orbit at ele2 (affects m(i,6) dispersion terms).

Returns:
  • m( 2D array of float (shape: 6,6) ) –

    Transfer matrix between the two points.

transfer_matrix_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_matrix_calc(lat: pybmad._pybmad.LatStruct, xfer_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"]], "FixedSize(6)"], xfer_vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(6)"] | None = None, ix1: typing.SupportsInt | typing.SupportsIndex | None = None, ix2: typing.SupportsInt | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, one_turn: bool | None = None) -> None

Wrapper for Fortran routine transfer_matrix_calc

Parameters:
  • lat (LatStruct) –

    Lattice used in the calculation.

  • xfer_mat (2D array of float (shape: 6,6)) –
  • xfer_vec (1D array of float (shape: 6)) –
  • ix1 (int) –

    Element start index for the calculation. Default is 0.

  • ix2 (int) –

    Element end index for the calculation. Defaults: If ix1 is not present: ix2 = lat.n_ele_track If ix1 is present and lattice is closed: Calculate the one-turn matrix from ix1 back to ix1.

  • ix_branch (int) –

    Branch index. Default is 0.

  • one_turn (bool) –

    If present and True, and ix1 = ix2, and the lattice is closed: Construct the one-turn matrix from ix1 back to ix1. If False, (the default), and ix1 = ix2, mat6 is the unit matrix.

transfer_twiss

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_twiss(ele_in: pybmad._pybmad.EleStruct, reverse: bool | None = None) -> pybmad._pybmad.EleStruct

Wrapper for Fortran routine transfer_twiss

Parameters:
  • ele_in (EleStruct) –

    Element with existing Twiss parameters.

  • reverse (bool) –

    Reverse alpha and coupling as if particle is going in the reversed direction? Default is False.

Returns:
  • ele_out( EleStruct ) –

    Element receiving the Twiss parameters.

transfer_wake

Fortran source: bmad/modules/bmad_routine_interface.f90

transfer_wake(wake_in: pybmad._pybmad.WakeStruct) -> pybmad._pybmad.WakeStruct | None

Wrapper for Fortran routine transfer_wake

Parameters:
Returns:
  • wake_out( (WakeStruct, optional) ) –

    Output wake.

truncate_complex_taylor_to_order

Fortran source: bmad/modules/complex_taylor_mod.f90

truncate_complex_taylor_to_order(complex_taylor_in: pybmad._pybmad.ComplexTaylorStructArray1D, order: typing.SupportsInt | typing.SupportsIndex, complex_taylor_out: pybmad._pybmad.ComplexTaylorStructArray1D) -> None

Subroutine truncate_complex_taylor_to_order (complex_taylor_in, order, complex_taylor_out)

Subroutine to throw out all terms in a complex_taylor map that are above a certain order.

Parameters:
  • complex_taylor_in (1D array of ComplexTaylorStruct) –

    Input complex_taylor map.

  • order (int) –

    Order above which terms are dropped.

  • complex_taylor_out (1D array of ComplexTaylorStruct) –

    Truncated complex_taylor map.

twiss1_propagate

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss1_propagate(twiss1: pybmad._pybmad.TwissStruct, mat2: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]], "FixedSize(2)"], ele_key: typing.SupportsInt | typing.SupportsIndex, length: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Twiss1Propagate

Wrapper for Fortran routine twiss1_propagate

Parameters:
  • twiss1 (TwissStruct) –

    Input Twiss parameters.

  • mat2 (2D array of float (shape: 2,2)) –

    The transfer matrix.

  • ele_key (int) –

    quadrupole$, etc.

  • length (float) –

    Determines whether the phase is increasing or decreasing.

Returns:
  • twiss2( TwissStruct ) –

    Output Twiss parameters.

  • err( bool ) –

    Set True if there is an error, false otherwise.

twiss3_at_start

Fortran source: bmad/modules/mode3_mod.f90

twiss3_at_start(lat: pybmad._pybmad.LatStruct, err_flag: bool, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> typing.Annotated[list[float], "FixedSize(3)"]

Subroutine twiss3_at_start (lat, error, ix_branch, tune3)

Subroutine to calculate the 3D twiss parameters of the three modes of the full 6D 1-turn transfer matrix. This routine is for lattices with closed geometries. For open lattices see: twiss3_from_twiss2.

Note: The rf must be on for this calculation.

Parameters:
  • lat (LatStruct) –

    Lattice with

  • ix_branch (int) –

    Branch index. 0 = default.

Returns:
  • tune3( 1D array of float (shape: 3), optional ) –

    Normal mode tunes

twiss3_from_twiss2

Fortran source: bmad/modules/mode3_mod.f90

twiss3_from_twiss2(ele: pybmad._pybmad.EleStruct) -> None

Subroutine twiss3_from_twiss2 (ele)

Routine to calculate the 3D Twiss parameters given the 2D transverse Twiss parameters and some longitudinal parameters. Also see: twiss3_at_start

Parameters:
  • ele (EleStruct) –

    Lattice element at which the calculation is made. This parameter is an input/output and is modified in-place. As an output, ele: Element

twiss3_propagate1

Fortran source: bmad/modules/mode3_mod.f90

twiss3_propagate1(ele1: pybmad._pybmad.EleStruct, ele2: pybmad._pybmad.EleStruct, err_flag: bool) -> None

Subroutine twiss3_propagate1 (ele1, ele2, err_flag)

Subroutine to propagate the twiss parameters using all three normal modes. Subroutine from original mode3_mod.

twiss3_propagate_all

Fortran source: bmad/modules/mode3_mod.f90

twiss3_propagate_all(lat: pybmad._pybmad.LatStruct, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Subroutine twiss3_propagate_all (lat, ix_branch)

Subroutine to propagate the twiss parameters using all three normal modes. Subroutine from original mode3_mod.

Parameters:
  • lat (LatStruct) –

    Lattice

  • ix_branch (int) –

    : Branch index. 0 = default.

twiss_and_track

Fortran sources (overloaded):

twiss_and_track(args, *kwargs) Overloaded function.

  1. twiss_and_track(lat: pybmad._pybmad.LatStruct, orb_array: pybmad._pybmad.CoordArrayStructAlloc1D, print_err: bool | None = None, calc_chrom: bool | None = None, use_particle_start: bool | None = None) -> int

Subroutine twiss_and_track

This routine is an overloaded name for: Subroutine twiss_and_track_branch (lat, orb, status, ix_branch, print_err, calc_chrom, orb_start, use_particle_start) Subroutine twiss_and_track_all (lat, orb_array, status, print_err, calc_chrom, use_particle_start)

Routine to calculate the twiss parameters, transport matrices and orbit.

The essential difference between these two procedures is that twiss_and_track_branch only does the main branch while twiss_and_track_all does everything but the photon_fork elements.

Note: This is not necessarily the fastest way to do things since this routine does the entire calculation from scratch.

For a circular ring: If the RF is on, the computed orbit will be the 6D closed orbit. If the RF is off, the 4D transverse closed orbit using orbi(0)%vec(6) is computed.

For an open lattice, the orbit will be computed using orb(0) as starting conditions.

If there is a problem the status argument settings are: in_stop_band\(, unstable\), non_symplectic\(, in_stop_band\), non_symplectic\(, xfer_mat_clac_failure\), twiss_propagate_failure\(, no_complete_orbit\), or no_closed_orbit\(. Note: in_stop_band\), unstable\(, and non_symplectic\) refer to the 1-turn matrix which is computed with closed lattices. For an open geometry branch, status = no_complete_orbit$ is for where the particle is lost in tracking. A negative sign is used to differentiate an error occuring in the first call to twiss_at_start from the second call to twiss_at_start.

If there is a problem in an open geometry branch, status argument setting is -N where N is the element where the particle was lost in tracking (negative numbers are used here to avoid confusion with ok$ which is mapped to 1.

Parameters:
  • lat (LatStruct) –

    lattice. This parameter is an input/output and is modified in-place. As an output, lat: Lat with computed twiss parameters.

  • orb_array (1D array of CoordArrayStruct) –

    Array of orbit arrays. As an output, orb_array: Used as the starting point for an open lattice.

  • print_err (bool) –

    Default is True. If False, suppress error messages.

  • calc_chrom (bool) –

    Default is False. If True, calculate the chromatic functions.

  • use_particle_start (bool) –

    Default is False. If True use branch.particle_start for the starting orbit. Do not use both this and orb_start.

Returns:
  • status( (int, optional) ) –

    Set ok$ if everything is OK and set to something else otherwise. See above for more details.

  • 2. twiss_and_track(lat: pybmad._pybmad.LatStruct, orb: pybmad._pybmad.CoordStructAlloc1D, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, print_err: bool | None = None, calc_chrom: bool | None = None, orb_start: pybmad._pybmad.CoordStruct | None = None, use_particle_start: bool | None = None) -> int
  • Subroutine twiss_and_track
  • This routine is an overloaded name for:

    Subroutine twiss_and_track_branch (lat, orb, status, ix_branch, print_err, calc_chrom, orb_start, use_particle_start) Subroutine twiss_and_track_all (lat, orb_array, status, print_err, calc_chrom, use_particle_start)

  • Routine to calculate the twiss parameters, transport matrices and orbit.
  • The essential difference between these two procedures is that
  • twiss_and_track_branch only does the main branch while twiss_and_track_all
  • does everything but the photon_fork elements.
  • Note( This is not necessarily the fastest way to do things since this ) –
  • routine does the entire calculation from scratch.
  • For a circular ring: If the RF is on, the computed orbit will be the 6D closed orbit.
  • If the RF is off, the 4D transverse closed orbit using orbi(0)%vec(6) is computed.
  • For an open lattice, the orbit will be computed using orb(0) as
  • starting conditions.
  • If there is a problem the status argument settings are: in_stop_band$,
  • unstable$, non_symplectic$, in_stop_band$, non_symplectic$, xfer_mat_clac_failure$,
  • twiss_propagate_failure$, no_complete_orbit$, or no_closed_orbit$. Note: in_stop_band$, unstable$,
  • and non_symplectic$ refer to the 1-turn matrix which is computed with closed lattices.
  • For an open geometry branch, status = no_complete_orbit$ is for
  • where the particle is lost in tracking. A negative sign is used to differentiate an
  • error occuring in the first call to twiss_at_start from the second call to twiss_at_start.
  • If there is a problem in an open geometry branch, status argument setting is -N where N is the element
  • where the particle was lost in tracking (negative numbers are used here to avoid confusion with ok$
  • which is mapped to 1.
Parameters:
  • lat (LatStruct) –

    lattice. This parameter is an input/output and is modified in-place. As an output, lat: Lat with computed twiss parameters.

  • orb (1D array of CoordStruct) –

    Orbit to be computed As an output, orb: Initial conditions to be used for an open geometry lattices. As an output, orb: Energy at which the closed orbit is computed. This parameter is an input/output and is modified in-place. As an output, orb: Computed orbit.

  • ix_branch (int) –

    Branch to track.

  • print_err (bool) –

    Default is True. If False, suppress error messages.

  • calc_chrom (bool) –

    Default is False. If True, calculate the chromatic functions.

  • orb_start (CoordStruct) –

    If present, use this as the starting orbit.

  • use_particle_start (bool) –

    Default is False. If True use branch.particle_start for the starting orbit. Do not use both this and orb_start.

Returns:
  • status( (int, optional) ) –

    Set ok$ if everything is OK and set to something else otherwise. See above for more details.

twiss_and_track_at_s

Fortran source: bmad/modules/twiss_and_track_mod.f90

twiss_and_track_at_s(lat: pybmad._pybmad.LatStruct, s: typing.SupportsFloat | typing.SupportsIndex, ele_at_s: pybmad._pybmad.EleStruct | None = None, orb: pybmad._pybmad.CoordStructArray1D | None = None, orb_at_s: pybmad._pybmad.CoordStruct | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, use_last: bool | None = None, compute_floor_coords: bool | None = None) -> bool

Subroutine twiss_and_track_at_s (lat, s, ele_at_s, orb, orb_at_s, ix_branch, err, use_last, compute_floor_coords)

Subroutine to return the twiss parameters and particle orbit at a given longitudinal position.

When calculating the Twiss parameters, this routine assumes that the lattice elements already contain the Twiss parameters calculated for the ends of the elements.

Additionally, the orbit at the ends of the elements (contained in orb(:)) must be precomputed when orb_at_s is present.

Precomputation of Twiss and orbit at the element ends may be done with the twiss_and_track routine.

See also: twiss_and_track_from_s_to_s twiss_and_track_intra_ele

Parameters:
  • lat (LatStruct) –

    Lattice.

  • s (float) –

    Longitudinal position. If s is negative the the position is taken to be lat.param.total_length - s.

  • ele_at_s (EleStruct) –

    If the use_last argument is True, ele_at_s is taken to contain valid Twiss parameters stored from a previous call to this routine. This parameter is an input/output and is modified in-place. As an output, ele_at_s: Element structure holding the Twiss parameters.

  • orb (1D array of CoordStruct) –

    Orbit through the Lattice.

  • orb_at_s (CoordStruct) –

    If the use_last argument is True, orb_at_s is taken to contain the valid orbit stored from a previous call. This parameter is an input/output and is modified in-place. As an output, orb_at_s: Particle position at the position s.

  • ix_branch (int) –

    Branch index, Default is 0 (main lattice).

  • use_last (bool) –

    If present and True, and if ele_at_s.s < s, then use ele_at_s and orb_at_s as the starting point for the present calculation. This can speed things up when the present s-position is in the middle of a long complicated element and the tracking (EG: Runge-Kutta) is slow.

  • compute_floor_coords (bool) –

    If present and True then the global "floor" coordinates (without misalignments) will be calculated and put in ele_at_s.floor.

Returns:
  • err( (bool, optional) ) –

    Set True if there is a problem in the calculation, False otherwise.

twiss_and_track_from_s_to_s

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_and_track_from_s_to_s(branch: pybmad._pybmad.BranchStruct, orbit_start: pybmad._pybmad.CoordStruct, s_end: typing.SupportsFloat | typing.SupportsIndex, ele_start: pybmad._pybmad.EleStruct | None = None, compute_floor_coords: bool | None = None, compute_twiss: bool | None = None) -> pybmad._pybmad.TwissAndTrackFromSToS

Wrapper for Fortran routine twiss_and_track_from_s_to_s

Parameters:
  • branch (BranchStruct) –

    Lattice branch to track through.

  • orbit_start (CoordStruct) –

    Starting phase space coordinates at s_start.

  • s_end (float) –

    Ending position.

  • ele_start (EleStruct) –

    Holds the starting parameters at s_start.

  • compute_floor_coords (bool) –

    If present and True then the global "floor" coordinates will be calculated and put in ele_end.floor.

  • compute_twiss (bool) –

    Default True. If False, to save a little time, do not compute Twiss parameters.

Returns:
  • orbit_end( CoordStruct ) –

    End phase space coordinates.

  • ele_end( (EleStruct, optional) ) –

    Holds the ending Twiss parameters and the transfer matrix. If present then the ele_start argument must also be present.

  • err( (bool, optional) ) –

    Set True if there is a problem like the particle gets lost in tracking

twiss_and_track_intra_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_and_track_intra_ele(ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct, l_start: typing.SupportsFloat | typing.SupportsIndex, l_end: typing.SupportsFloat | typing.SupportsIndex, track_upstream_end: bool, track_downstream_end: bool, orbit_start: pybmad._pybmad.CoordStruct | None = None, ele_start: pybmad._pybmad.EleStruct | None = None, ele_end: pybmad._pybmad.EleStruct | None = None, compute_floor_coords: bool | None = None, compute_twiss: bool | None = None, reuse_ele_end: bool | None = None) -> pybmad._pybmad.TwissAndTrackIntraEle

Wrapper for Fortran routine twiss_and_track_intra_ele

Parameters:
  • ele (EleStruct) –

    Element to track through.

  • param (LatParamStruct) –
  • l_start (float) –

    Start position measured from the beginning of the element.

  • l_end (float) –

    Stop position measured from the beginning of the element.

  • track_upstream_end (bool) –

    If True then entrance effects are included in the tracking. But only if l_start = 0 and orbit_start.location /= inside$.

  • track_downstream_end (bool) –

    If True then exit effects are included in the tracking but only if l_end = ele.value(l$) (within bmad_com.significant_length tol)

  • orbit_start (CoordStruct) –

    Starting phase space coordinates at l_start.

  • ele_start (EleStruct) –

    Holds the starting Twiss parameters at l_start.

  • ele_end (EleStruct) –

    If reuse_ele_end is set True then reuse ele_end from trancking instead of recomputing ele_end from scratch. This can save time. This parameter is an input/output and is modified in-place. As an output, ele_end: Holds the ending Twiss parameters at l_end (except for photons).

  • compute_floor_coords (bool) –

    If present and True then the global "floor" coordinates (without misalignments) will be calculated and put in ele_end.floor.

  • compute_twiss (bool) –

    Default True. If False, to save a little time, do not compute Twiss parameters. Also if ele_start is not present, no Twiss parameters are computed.

  • reuse_ele_end (bool) –

    If present and True, and if ele_end has the correct lonigitudianal length and key type, reuse ele_end from trancking instead of recomputing ele_end from scratch. This can save time.

Returns:
  • orbit_end( (CoordStruct, optional) ) –

    End phase space coordinates. If present then the orbit_start argument must also be present.

  • err( (bool, optional) ) –

    Set True if there is a problem like the particle gets lost in tracking

twiss_at_element

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_at_element(ele: pybmad._pybmad.EleStruct) -> pybmad._pybmad.TwissAtElement

Wrapper for Fortran routine twiss_at_element

Parameters:
Returns:
  • start( (EleStruct, optional) ) –

    Twiss and s at start of element.

  • end( (EleStruct, optional) ) –

    Twiss and s at end of element.

  • average( (EleStruct, optional) ) –

    Average Twiss and s of element.

twiss_at_start

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_at_start(lat: pybmad._pybmad.LatStruct, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, type_out: bool | None = None) -> int

Wrapper for Fortran routine twiss_at_start

Parameters:
  • lat (LatStruct) –

    Lat This parameter is an input/output and is modified in-place. As an output, lat: Lattice with twiss parameters computed.

  • ix_branch (int) –

    Branch to use. Default is 0 (main branch).

  • type_out (bool) –

    If True (the default), print an error message If the 1-turn matrix is unstable.

Returns:
  • status( (int, optional) ) –

    Calculation status: ok\(, in_stop_band\), unstable\(, or non_symplectic\)

twiss_from_tracking

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_from_tracking(lat: pybmad._pybmad.LatStruct, ref_orb0: pybmad._pybmad.CoordStruct, d_orb: pybmad._pybmad.RealArray1D | None = None) -> pybmad._pybmad.TwissFromTracking

Wrapper for Fortran routine twiss_from_tracking

Parameters:
  • lat (LatStruct) –

    Lat to track through. This parameter is an input/output and is modified in-place. As an output, lat: Structure holding the Twiss parameters.

  • ref_orb0 (CoordStruct) –

    Reference orbit at lat.ele(0).

  • d_orb (1D array of float) –

    Vector of offsets to use. If not present or zero bmad_com.d_orb(:) will be used.

Returns:
  • symp_err( float ) –

    A measure of how symplectic the constructed matrices were before symplecitification. mat_symp_check for more details.

  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

twiss_propagate1

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_propagate1(ele1: pybmad._pybmad.EleStruct, ele2: pybmad._pybmad.EleStruct, forward: bool | None = None) -> bool

Wrapper for Fortran routine twiss_propagate1

Parameters:
  • ele1 (EleStruct) –

    Element holding the starting Twiss parameters for forwards propagation. This parameter is an input/output and is modified in-place. As an output, ele1: Element for the ending Twiss parameters for backwards propagation.

  • ele2 (EleStruct) –

    Element holding the transfer matrix and, if backwards propagation, the starting Twiss. This parameter is an input/output and is modified in-place. As an output, ele2: Element for the ending Twiss parameters for forward propagation.

  • forward (bool) –

    Default is True. If false, propagate the Twiss backwards.

Returns:
  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

twiss_propagate_all

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_propagate_all(lat: pybmad._pybmad.LatStruct, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, ie_start: typing.SupportsInt | typing.SupportsIndex | None = None, ie_end: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine twiss_propagate_all

Parameters:
  • lat (LatStruct) –

    lattice. This parameter is an input/output and is modified in-place. As an output, lat: Lattice with parameters computed for the branch.

  • ix_branch (int) –

    Branch index. Default is 0 (main lattice).

  • ie_start (int) –

    Starting element index. Default is 0. Note: The first element at which the Twiss parameters are calculated is ie_start+1.

  • ie_end (int) –

    Ending element index, Default is branch.n_ele_track.

Returns:
  • err_flag( (bool, optional) ) –

    Set True if there is an error. False otherwise.

twiss_to_1_turn_mat

Fortran source: bmad/modules/bmad_routine_interface.f90

twiss_to_1_turn_mat(twiss: pybmad._pybmad.TwissStruct, phi: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(2)"]], "FixedSize(2)"]

Wrapper for Fortran routine twiss_to_1_turn_mat

Parameters:
  • twiss (TwissStruct) –

    Structure holding the Twiss parameters. .beta .alpha

  • phi (float) –

    Tune in radians.

Returns:
  • mat2( 2D array of float (shape: 2,2) ) –

    1-turn matrix.

type_complex_taylors

Fortran source: bmad/modules/complex_taylor_mod.f90

type_complex_taylors(complex_taylor: pybmad._pybmad.ComplexTaylorStructArray1D, max_order: typing.SupportsInt | typing.SupportsIndex | None = None, file_id: typing.SupportsInt | typing.SupportsIndex | None = None, out_type: str | None = None, clean: bool | None = None) -> pybmad._pybmad.TypeComplexTaylors

Subroutine type_complex_taylors (complex_taylor, max_order, lines, n_lines, file_id, out_type, clean)

Subroutine to print or put in a string array a Bmad taylor map. If the lines(:) argument is not present, the element information is printed to the terminal.

Parameters:
  • complex_taylor (1D array of ComplexTaylorStruct) –

    Array of taylors.

  • max_order (int) –

    Maximum order to print.

  • file_id (int) –

    If present, write output to a file with handle file_id.

  • out_type (str) –

    Determins the string to be used for the output type column. '' (default) -> '1', '2', '3', etc. 'PHASE' -> 'X', 'Px, 'Y', 'Py', 'Z', 'Pz' 'SPIN' -> 'S1', 'Sx', 'Sy', 'Sz' ! If size = 4: quaternion representation 'SPIN' -> 'Sx', 'Sy', 'Sz' ! If size = 3: 'NONE' -> No out column Anything else -> Use this for the output column.

  • clean (bool) –

    If True then do not include terms whose coefficients are negligible. Default is false

Returns:
  • lines( 1D array of str, optional ) –

    : Character array to hold the output. If not present, the information is printed to the terminal. Char width should be 120 or above for out_type = 'PHASE' but can be less for other out_types.

  • n_lines( (int, optional) ) –

    Number of lines in lines(:) that hold valid output. n_lines must be present if lines(:) is.

type_coord

Fortran source: bmad/modules/bmad_routine_interface.f90

type_coord(coord: pybmad._pybmad.CoordStruct) -> None

Wrapper for Fortran routine type_coord

Parameters:

type_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

type_ele(ele: pybmad._pybmad.EleStruct, type_zero_attrib: bool | None = None, type_mat6: typing.SupportsInt | typing.SupportsIndex | None = None, type_taylor: bool | None = None, twiss_out: typing.SupportsInt | typing.SupportsIndex | None = None, type_control: typing.SupportsInt | typing.SupportsIndex | None = None, type_wake: bool | None = None, type_floor_coords: bool | None = None, type_field: typing.SupportsInt | typing.SupportsIndex | None = None, type_wall: bool | None = None, type_rad_kick: bool | None = None, type_internal: bool | None = None) -> pybmad._pybmad.TypeEle

Wrapper for Fortran routine type_ele

Parameters:
  • ele (EleStruct) –

    Element

  • type_zero_attrib (bool) –

    If False then surpress printing of real attributes whose value is 0 or switch attributes that have their default value. Default is False.

  • type_mat6 (int) –

    = 0 => Do not type ele.mat6 = 4 => Type 4X4 xy submatrix = 6 => Type full 6x6 matrix (Default)

  • type_taylor (bool) –

    Print out taylor map terms? If ele.taylor is not allocated then this is ignored. Default is False.

  • twiss_out (int) –

    Print the Twiss parameters at the element end? = 0 => Do not print the Twiss parameters = radians$ => Print Twiss, phi in radians (Default). = degrees$ => Print Twiss, phi in degrees. = cycles$ => Print Twiss, phi in radians/2pi.

  • type_control (int) –

    Print control status? If ele.branch.lat is not associated cannot print status info. = no$ => One line of info. = short$ => Almost all info except long knot point lists are truncated (default). = all$ => Everything.

  • type_wake (bool) –

    If True then print the long-range and short-range wakes information. If False then just print how many terms the wake has. Default is True. If ele.wake is not allocated then this is ignored.

  • type_floor_coords (bool) –

    Default is False. If True then print the global ("floor") coordinates at the exit end of the element.

  • type_field (int) –

    Print field maps? = no$ => One line of info (default). = short$ => Header info. No tables. = all$ => Everything.

  • type_wall (bool) –

    Default is False. If True, print wall info.

  • type_rad_kick (bool) –

    Default is False. If True, print synch rad kick info.

  • type_internal (bool) –

    Default is False. If True, print some internal parameters.

Returns:
  • lines( 1D array of str, optional ) –

    Character array to hold the output. If not present, the information is printed to the terminal.

  • n_lines( (int, optional) ) –

    Number of lines in lines(:) that hold valid output. n_lines must be present if lines(:) is.

type_end_stuff

Fortran source: bmad/ptc/ptc_interface_mod.f90

type_end_stuff(li: pybmad._pybmad.CharacterAlloc1D, nl: typing.SupportsInt | typing.SupportsIndex, lines: pybmad._pybmad.CharacterAlloc1D | None = None, n_lines: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine type_end_stuff

Parameters:
  • li (1D array of str) –
  • nl (int) –
  • lines (1D array of str) –
  • n_lines (int) –

type_expression_tree

Fortran source: bmad/modules/expression_mod.f90

type_expression_tree(tree: pybmad._pybmad.ExpressionTreeStruct, indent: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Subroutine type_expression_tree (tree, indent)

Routine to print an expression tree in tree form. Good for debugging.

Parameters:

type_ptc_fibre

Fortran source: bmad/ptc/ptc_interface_mod.f90

type_ptc_fibre(ptc_fibre: pybmad._pybmad.Fibre, print_coords: bool | None = None) -> pybmad._pybmad.TypePtcFibre

Subroutine type_ptc_fibre (ptc_fibre, print_coords, lines, n_lines)

Routine to put information on a PTC fibre element into a string array. If "lines" is not present, the information will be printed to the screen.

Parameters:
  • ptc_fibre (Fibre) –

    Fibre to type info of.

  • print_coords (bool) –

    If True then print coordinate and patch information. Default is True.

Returns:
  • lines( 1D array of str, optional ) –

    Character array to hold the output.

  • n_lines( (int, optional) ) –

    Number of lines used in lines(:)

type_ptc_layout

Fortran source: bmad/ptc/ptc_layout_mod.f90

type_ptc_layout(lay: pybmad._pybmad.Layout) -> None

Subroutine type_ptc_layout (lay)

Subroutine to print the global information in a layout

type_taylors

Fortran source: bmad/modules/bmad_routine_interface.f90

type_taylors(bmad_taylor: pybmad._pybmad.TaylorStructArray1D, max_order: typing.SupportsInt | typing.SupportsIndex | None = None, lines: pybmad._pybmad.CharacterAlloc1D | None = None, n_lines: typing.SupportsInt | typing.SupportsIndex | None = None, file_id: typing.SupportsInt | typing.SupportsIndex | None = None, out_style: str | None = None, clean: bool | None = None, out_var_suffix: str | None = None, append: bool | None = None) -> pybmad._pybmad.TypeTaylors

Wrapper for Fortran routine type_taylors

Parameters:
  • bmad_taylor (1D array of TaylorStruct) –

    Array of taylors.

  • max_order (int) –

    Maximum order to print.

  • lines (1D array of str) –

    Used with append = True. Output will start at n_lines+1 This parameter is an input/output and is modified in-place. As an output, lines: Array to hold the output.

  • n_lines (int) –

    Used with append = True. Output will start at n_lines+1. This parameter is an input/output and is modified in-place. As an output, n_lines: Number of lines in lines(

  • file_id (int) –

    If present, write output to a file with handle file_id.

  • out_style (str) –

    Determins the string to be used for the output type column. '' (default) -> 'X', 'Px, 'Y', 'Py', 'Z', 'Pz' If size(bmad_taylor) = 6 -> 'S1', 'Sx', 'Sy', 'Sz' (Spin quaternions) If size(bmad_taylor) = 4 -> '1', '2', '3', etc. Otherwiase 'NUMBER' -> '1', '2', '3', etc. 'BMAD' -> Bmad lattice file format.

  • clean (bool) –

    If True then do not include terms whose coefficients are negligible. Default is false.

  • out_var_suffix (str) –

    If out_style = 'SCIBMAD', out_var_suffix is used as the suffix of the variable holding the taylor map. Default is "z". For example, if "z" is the suffix then: Descriptor = "d_z", orbital map name = "v_z", ref orbit name = v0_z, and spin map name = "q_z".

  • append (bool) –

    Default is False. If True, n_lines on input is the number of existing lines in lines(:) to save.

Returns:
  • n_lines( (int, optional) ) –

    Used with append = True. Output will start at n_lines+1. This parameter is an input/output and is modified in-place. As an output, n_lines: Number of lines in lines(

type_twiss

Fortran source: bmad/modules/bmad_routine_interface.f90

type_twiss(ele: pybmad._pybmad.EleStruct, frequency_units: typing.SupportsInt | typing.SupportsIndex | None = None, compact_format: bool | None = None, lines: pybmad._pybmad.CharacterAlloc1D | None = None) -> int

Wrapper for Fortran routine type_twiss

Parameters:
  • ele (EleStruct) –

    Element containing the Twiss parameters.

  • frequency_units (int) –

    Units for phi: = radians$ => Type Twiss, use radians for phi (Default). = degrees$ => Type Twiss, use degrees for phi. = cycles$ => Type Twiss, use cycles (1 = 2pi) units.

  • compact_format (bool) –

    If present and True then use a compact output form.

  • lines (1D array of str) –

    : Character array to hold the output. The string length should be at least 120 characters. 13 lines are needed for the verbose form. If not present, the information is printed to the terminal.

Returns:
  • n_lines( (int, optional) ) –

    Number of lines in lines(:) that hold valid output. n_lines must be present if lines(:) is.

update_ele_from_fibre

Fortran source: bmad/ptc/ptc_layout_mod.f90

update_ele_from_fibre(ele: pybmad._pybmad.EleStruct) -> None

Subroutine update_ele_from_fibre (ele)

Routine to update a bmad lattice element when the associated PTC fibre has been modified. Remember to call lattice_bookkeeper after calling this routine.

Parameters:
  • ele (EleStruct) –

    Element with corresponding ele.ptc_fibre fibre. This parameter is an input/output and is modified in-place. As an output, ele: Modified element.

update_fibre_from_ele

Fortran source: bmad/modules/bmad_routine_interface.f90

update_fibre_from_ele(ele: pybmad._pybmad.EleStruct) -> bool

Wrapper for Fortran routine update_fibre_from_ele

Parameters:
  • ele (EleStruct) –

    Element with corresponding PTC fibre.

Returns:
  • survey_needed( bool ) –

    Set True if a call to survey will be needed. Calling survey is avoided in this routine to save time if multiple elements are being updated.

update_floor_angles

Fortran source: bmad/modules/bmad_routine_interface.f90

update_floor_angles(floor: pybmad._pybmad.FloorPositionStruct, floor0: pybmad._pybmad.FloorPositionStruct | None = None) -> None

Wrapper for Fortran routine update_floor_angles

Parameters:
  • floor (FloorPositionStruct) –

    Position with input w matrix. This parameter is an input/output and is modified in-place. As an output, floor: Position with output angles.

  • floor0 (FloorPositionStruct) –

    Reference position. There are two solutions related by: [theta, phi, psi] & [pi+theta, pi-phi, pi+psi] If floor0 is present, choose the solution "nearest" the angles in floor0.

valid_field_calc

Fortran source: bmad/modules/bmad_routine_interface.f90

valid_field_calc(ele: pybmad._pybmad.EleStruct, field_calc: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine valid_field_calc

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • field_calc (int) –

    bmad_standard$, etc.

Returns:
  • is_valid( bool ) –

    True if a valid method. False otherwise.

valid_fringe_type

Fortran source: bmad/modules/bmad_routine_interface.f90

valid_fringe_type(ele: pybmad._pybmad.EleStruct, fringe_type: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine valid_fringe_type

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • fringe_type (int) –

    bmad_standard$, etc.

Returns:
  • is_valid( bool ) –

    True if a valid method. False otherwise.

valid_mat6_calc_method

Fortran source: bmad/modules/bmad_routine_interface.f90

valid_mat6_calc_method(ele: pybmad._pybmad.EleStruct, species: typing.SupportsInt | typing.SupportsIndex, mat6_calc_method: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine valid_mat6_calc_method

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • species (int) –

    Type of particle being tracked. electron\(, etc. or not_set\)

  • mat6_calc_method (int) –

    bmad_standard$, etc.

Returns:
  • is_valid( bool ) –

    True if a valid method. False otherwise.

valid_spin_tracking_method

Fortran source: bmad/modules/bmad_routine_interface.f90

valid_spin_tracking_method(ele: pybmad._pybmad.EleStruct, spin_tracking_method: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine valid_spin_tracking_method

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • spin_tracking_method (int) –

    bmad_standard$, etc.

Returns:
  • is_valid( bool ) –

    True if a valid method. False otherwise.

valid_tracking_method

Fortran source: bmad/modules/bmad_routine_interface.f90

valid_tracking_method(ele: pybmad._pybmad.EleStruct, species: typing.SupportsInt | typing.SupportsIndex, tracking_method: typing.SupportsInt | typing.SupportsIndex) -> bool

Wrapper for Fortran routine valid_tracking_method

Parameters:
  • ele (EleStruct) –

    Lattice element.

  • species (int) –

    Type of particle being tracked. electron\(, etc. or not_set\)

  • tracking_method (int) –

    bmad_standard$, etc.

Returns:
  • is_valid( bool ) –

    True if a valid method. False otherwise.

value_of_attribute

Fortran source: bmad/modules/bmad_routine_interface.f90

value_of_attribute(ele: pybmad._pybmad.EleStruct, attrib_name: str, err_print_flag: bool | None = None, err_value: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.ValueOfAttribute

Wrapper for Fortran routine value_of_attribute

Parameters:
  • ele (EleStruct) –

    After this routine finishes Ptr_attrib will point to a variable within this element.

  • attrib_name (str) –

    Name of attribute. Must be uppercase. For example: "HKICK".

  • err_print_flag (bool) –

    If present and True then print an error message if there is an error.

  • err_value (float) –

    Value to set value argument if there is an error. Default is 0.

Returns:
  • value( float ) –

    Value of the attribute. Set to err_value if not found.

  • err_flag( (bool, optional) ) –

    Set True if attribtute not found. False otherwise.

value_to_line

Fortran source: bmad/output/write_lattice_file_mod.f90

value_to_line(line: str, value: typing.SupportsFloat | typing.SupportsIndex, str: str, typ: str, ignore_if_zero: bool | None = None, use_comma: bool | None = None) -> None

Wrapper for Fortran routine value_to_line

Parameters:
  • line (str) –
  • value (float) –
  • str (str) –
  • typ (str) –
  • ignore_if_zero (bool) –
  • use_comma (bool) –

vec_to_polar

Fortran source: bmad/modules/bmad_routine_interface.f90

vec_to_polar(vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], phase: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.SpinPolarStruct

Wrapper for Fortran routine vec_to_polar

Parameters:
  • vec (1D array of float (shape: 3)) –

    unitary spin vector

  • phase (float) –

    Phase of the spinor, if not given then set to zero

Returns:

vec_to_spinor

Fortran source: bmad/modules/bmad_routine_interface.f90

vec_to_spinor(vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], phase: typing.SupportsFloat | typing.SupportsIndex | None = None) -> typing.Annotated[list[complex], "FixedSize(2)"]

Wrapper for Fortran routine vec_to_spinor

Parameters:
  • vec (1D array of float (shape: 3)) –

    Spin vector in cartesian coordinates

  • phase (float) –

    Phase of the spinor, if not given then set to zero

Returns:
  • spinor( 1D array of complex (shape: 2) ) –

    Spinor.

verify_valid_name

Fortran source: bmad/parsing/bmad_parser_mod.f90

verify_valid_name(name: str, ix_name: typing.SupportsInt | typing.SupportsIndex, pure_name: bool | None = None, include_wild: bool | None = None) -> bool

Function verify_valid_name (name, ix_name, pure_name, include_wild) result (is_valid)

Routine to check if a name is well formed. Examples: "0>>Q0" -- Invalid (will only be valid after lattice expansion). "Q1##1" -- Invalid (double hash not accepted). "Q2A_C.\7#" -- Pure name (no "[", "]", "(", ")", "%" characters present). "Q3[GRID_FIELD(1)%FIELD_SCALE]" -- Valid but not a pure name. "RFCAVITY::*" -- Valid if include_wild = True.

This subroutine is used by bmad_parser and bmad_parser2. This subroutine is not intended for general use.

Parameters:
  • name (str) –

    Name(1:ix_name) is the string to check.

  • ix_name (int) –

    Number of characters in the name.

  • pure_name (bool) –

    If True, reject names that contain "[", "]", "(", ")", "." characters. Default is False.

  • include_wild (bool) –

    Name can include wild card characters and additionally type prefixes like "QUAD::". Default is False.

Returns:
  • is_valid( bool ) –

    True if name is well formed. False otherwise.

w_mat_for_bend_angle

Fortran source: bmad/modules/bmad_routine_interface.f90

w_mat_for_bend_angle(angle: typing.SupportsFloat | typing.SupportsIndex, ref_tilt: typing.SupportsFloat | typing.SupportsIndex, r_vec: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"] | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(3)"]], "FixedSize(3)"]

Wrapper for Fortran routine w_mat_for_bend_angle

Parameters:
  • angle (float) –

    Bending angle.

  • ref_tilt (float) –

    Reference tilt.

  • r_vec (1D array of float (shape: 3)) –

    Starting position. This parameter is an input/output and is modified in-place. As an output, r_vec: position with ref_tilt transformation

Returns:
  • w_mat( 2D array of float (shape: 3,3) ) –

    W matrix

w_mat_for_tilt

Fortran source: bmad/modules/bmad_routine_interface.f90

w_mat_for_tilt(tilt: typing.SupportsFloat | typing.SupportsIndex, return_inverse: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(3)"]], "FixedSize(3)"]

Wrapper for Fortran routine w_mat_for_tilt

Parameters:
  • tilt (float) –

    pitch angle

  • return_inverse (bool) –

    If True, return the inverse matrix. Default is False.

Returns:
  • w_mat( 2D array of float (shape: 3,3) ) –

    Transformation matrix.

w_mat_for_x_pitch

Fortran source: bmad/modules/bmad_routine_interface.f90

w_mat_for_x_pitch(x_pitch: typing.SupportsFloat | typing.SupportsIndex, return_inverse: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(3)"]], "FixedSize(3)"]

Wrapper for Fortran routine w_mat_for_x_pitch

Parameters:
  • x_pitch (float) –

    pitch angle

  • return_inverse (bool) –

    If True, return the inverse matrix. Default is False.

Returns:
  • w_mat( 2D array of float (shape: 3,3) ) –

    Transformation matrix.

w_mat_for_y_pitch

Fortran source: bmad/modules/bmad_routine_interface.f90

w_mat_for_y_pitch(y_pitch: typing.SupportsFloat | typing.SupportsIndex, return_inverse: bool | None = None) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(3)"]], "FixedSize(3)"]

Wrapper for Fortran routine w_mat_for_y_pitch

Parameters:
  • y_pitch (float) –

    pitch angle

  • return_inverse (bool) –

    If True, return the inverse matrix. Default is False.

Returns:
  • w_mat( 2D array of float (shape: 3,3) ) –

    Transformation matrix.

wall3d_d_radius

Fortran source: bmad/modules/wall3d_mod.f90

wall3d_d_radius(position: pybmad._pybmad.RealArray1D, ele: pybmad._pybmad.EleStruct, ix_wall: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.Wall3dDRadius

Function wall3d_d_radius (position, ele, ix_wall, perp, ix_section, no_wall_here, origin, radius_wall, err_flag) result (d_radius)

Routine to calculate the difference radius = particle_radius - wall_radius. Radiuses are measured along a line from the wall origin with the line passing through the particle position. The wall origin itself lies on a line connecting the centers of the bounding sections.

Module needed: use wall3d_mod

Parameters:
  • position (1D array of float) –

    Particle position in element coordinates. In a patch, with respect to entrance coords. [position(1), position(3)] = [x, y] transverse coords. position(5) = Longitudinal position relative to beginning of element. position(6) = Longitudinal velocity (only +/- sign matters).

  • ele (EleStruct) –

    Element with wall

  • ix_wall (int) –

    Index of wall in .wall3d(:) array. Default is 1.

Returns:
  • d_radius( float ) –

    r_particle - r_wall

  • perp( 1D array of float (shape: 3), optional ) –

    Perpendicular normal to the wall.

  • ix_section( (int, optional) ) –

    Set to wall slice section particle is in. That is between ix_section and ix_section+1.

  • no_wall_here( (bool, optional) ) –

    True if the sub-chamber under consideration does not exist at the longitudinal location of the particle.

  • origin( 1D array of float (shape: 3), optional ) –

    (x, y, s) origin with respect to the radius is measured. Uses the same coords as position.

  • radius_wall( (float, optional) ) –

    Radius of the wall.

  • err_flag( (bool, optional) ) –

    Set True if error. (EG noassociated .wall3d), false otherwise.

wall3d_initializer

Fortran source: bmad/modules/wall3d_mod.f90

wall3d_initializer(wall3d: pybmad._pybmad.Wall3DStruct) -> bool

Subroutine wall3d_initializer (wall3d, err)

Routine to initialize a wall3d_struct 1) Add vertex points if there is symmetry. 2) Compute circular and elliptical centers. 3) Compute spline coefficients, etc.

Parameters:
  • wall3d (Wall3dStruct) –

    Wall. This parameter is an input/output and is modified in-place. As an output, wall3d: Initialized wall.

Returns:
  • err( bool ) –

    Set true if there is a problem.

wall3d_section_initializer

Fortran source: bmad/modules/wall3d_mod.f90

wall3d_section_initializer(section: pybmad._pybmad.Wall3DSectionStruct) -> bool

Subroutine wall3d_section_initializer (section, err)

Routine to initialize a wall3d_section_struct: 1) Add vertex points if there is symmetry. 2) Compute circular and elliptical centers.

Parameters:
  • section (Wall3dSectionStruct) –

    Wall3d section. This parameter is an input/output and is modified in-place. As an output, section: Initialized section-section.

Returns:
  • err( bool ) –

    Set true if there is a problem.

wall3d_to_position

Fortran source: bmad/modules/wall3d_mod.f90

wall3d_to_position(orbit: pybmad._pybmad.CoordStruct, ele: pybmad._pybmad.EleStruct) -> typing.Annotated[list[float], "FixedSize(6)"]

Function wall3d_to_position (orbit, ele) result (position)

Routine to return the suitable postion to be used in calling wall3d_d_radius

This routine assumes that if in a patch the coordinates of orbit are with respect to the downstream end if orbit%direction*orbit%time_dir = 1 and vice versa.

Parameters:
Returns:
  • position( 1D array of float (shape: 6) ) –

    Position used in wall3d_d_radius call.

word_to_value

Fortran source: bmad/parsing/bmad_parser_mod.f90

word_to_value(word: str, lat: pybmad._pybmad.LatStruct, value: typing.SupportsFloat | typing.SupportsIndex, err_flag: bool, ele: pybmad._pybmad.EleStruct | None = None) -> None

Wrapper for Fortran routine word_to_value

Parameters:
  • word (str) –
  • lat (LatStruct) –
  • value (float) –
  • err_flag (bool) –
  • ele (EleStruct) –

write_ascii_beam_file

Fortran source: bmad/multiparticle/beam_file_io.f90

write_ascii_beam_file(file_name: str, beam: pybmad._pybmad.BeamStruct, new_file: bool | None = None, alive_only: bool | None = None) -> None

Subroutine write_ascii_beam_file (file_name, beam, new_file, alive_only)

Routine to write a beam file in ASCII format (version 4).

Parameters:
  • file_name (str) –

    Name of file.

  • beam (BeamStruct) –

    Beam to write

  • new_file (bool) –

    New file or append? Default = True.

  • alive_only (bool) –

    Only write live (includes pre_born) particles to the file? Default is False.

write_astra_bend

Fortran source: bmad/interface/astra_interface_mod.f90

write_astra_bend(iu: typing.SupportsInt | typing.SupportsIndex, strength: typing.SupportsFloat | typing.SupportsIndex, id: typing.SupportsInt | typing.SupportsIndex, d1: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], d2: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], d3: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], d4: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]) -> None

Wrapper for Fortran routine write_astra_bend

Parameters:
  • iu (int) –
  • strength (float) –
  • id (int) –
  • d1 (1D array of float (shape: 2)) –
  • d2 (1D array of float (shape: 2)) –
  • d3 (1D array of float (shape: 2)) –
  • d4 (1D array of float (shape: 2)) –

write_astra_field_grid_file

Fortran source: bmad/interface/astra_interface_mod.f90

write_astra_field_grid_file(astra_file_unit: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, dz: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.WriteAstraFieldGridFile

Subroutine write_astra_field_grid_file (astra_file_unit, ele, maxfield, err)

Write 1-D field map files for Astra. The format is: z field ...

Note: Simplified from write_opal_field_grid_file

Parameters:
  • astra_file_unit (int) –

    unit number to write to, if > 0 if < 0, nothing is written, and only maxfield is returned

  • ele (EleStruct) –

    element to make map

  • dz (float) –

    z step size in m. Default: 0.001 m

Returns:
  • maxfield( float ) –

    absolute maximum found for element field scaling

  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_astra_field_grid_file_3d

Fortran source: bmad/interface/astra_interface_mod.f90

write_astra_field_grid_file_3d(base_filename: str, ele: pybmad._pybmad.EleStruct, dz: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.WriteAstraFieldGridFile3d

Subroutine write_astra_field_grid_file_3D (base_filename, ele, maxfield, dz, err)

Writes 3-D field map files for Astra. The format is: Nx x[1] x[2] ....... x[Nx-1] x[Nx] Ny y[1] y[2] ....... y[Ny-1] y[Ny] Nz z[1] z[2] ....... z[Nz-1] z[Nz] where field values are produced from a loop as in: do iz = 1, Nz do iy = 1, Ny write single line: field(:, iy, iz)

Note: similar to write_astra_field_grid_file

Parameters:
  • base_filename (str) –

    Base filename. Files will be written as: base_filename.ex, .ey, .ez, .bx, .by, .bz If set to '', no files will be written

  • ele (EleStruct) –

    element to make map

  • dz (float) –

    z step size in m. Default: 0.001 m

Returns:
  • maxfield( float ) –

    absolute maximum on-axis field found for element field scaling

  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_beam_file

Fortran source: bmad/multiparticle/beam_file_io.f90

write_beam_file(file_name: str, beam: pybmad._pybmad.BeamStruct, new_file: bool | None = None, file_format: typing.SupportsInt | typing.SupportsIndex | None = None, lat: pybmad._pybmad.LatStruct | None = None, alive_only: bool | None = None) -> None

Subroutine write_beam_file (file_name, beam, new_file, file_format, lat, alive_only)

Routine to write a beam file.

A '.h5' suffix will be appended to the created file if hdf5$ format is used and file_name does not already have a '.h5' or '.hdf5' suffix.

Parameters:
  • file_name (str) –

    Name of file.

  • beam (BeamStruct) –

    Beam to write

  • new_file (bool) –

    New file or append? Default = True.

  • file_format (int) –

    ascii\(, or hdf5\) (default). old_ascii$ (deprecated) is still accepted.

  • lat (LatStruct) –

    If present, lattice info will be writen to hdf5 files.

  • alive_only (bool) –

    Only write live (includes pre_born) particles to the file? Default is False.

write_beam_floor_positions

Fortran source: bmad/modules/bmad_routine_interface.f90

write_beam_floor_positions(file_name: str, beam: pybmad._pybmad.BeamStruct, ele: pybmad._pybmad.EleStruct, new_file: bool | None = None) -> None

Wrapper for Fortran routine write_beam_floor_positions

Parameters:
  • file_name (str) –

    Name of file.

  • beam (BeamStruct) –

    Beam to write

  • ele (EleStruct) –

    Element that the beam is at.

  • new_file (bool) –

    New file or append? Default = True.

write_binary_cartesian_map

Fortran source: bmad/parsing/binary_parser_mod.f90

write_binary_cartesian_map(file_name: str, ele: pybmad._pybmad.EleStruct, cart_map: pybmad._pybmad.CartesianMapStruct) -> bool

Subroutine write_binary_cartesian_map (file_name, ele, cart_map, err_flag)

Routine to write a binary cartesian_map structure. Note: The file name should have a ".bin" suffix.

Parameters:
  • file_name (str) –

    File to create.

  • ele (EleStruct) –

    Element associated with the map.

  • cart_map (CartesianMapStruct) –

    Cartesian map.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

write_binary_cylindrical_map

Fortran source: bmad/parsing/binary_parser_mod.f90

write_binary_cylindrical_map(file_name: str, ele: pybmad._pybmad.EleStruct, cl_map: pybmad._pybmad.CylindricalMapStruct) -> bool

Subroutine write_binary_cylindrical_map (file_name, ele, cl_map, err_flag)

Routine to write a binary cylindrical_map structure. Note: The file name should have a ".bin" suffix.

Parameters:
Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

write_binary_grid_field

Fortran source: bmad/parsing/binary_parser_mod.f90

write_binary_grid_field(file_name: str, ele: pybmad._pybmad.EleStruct, g_field: pybmad._pybmad.GridFieldStruct) -> bool

Subroutine write_binary_grid_field (file_name, ele, g_field, err_flag)

Routine to write a binary grid_field structure. Note: The file name should have a ".bin" suffix.

Parameters:
  • file_name (str) –

    File to create.

  • ele (EleStruct) –

    Element associated with the map.

  • g_field (GridFieldStruct) –

    Cylindrical map.

Returns:
  • err_flag( bool ) –

    Set True if there is an error. False otherwise.

write_blender_ele

Fortran source: bmad/interface/blender_interface_mod.f90

write_blender_ele(iu: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, old_format: bool | None = None) -> None

Wrapper for Fortran routine write_blender_ele

Parameters:
  • iu (int) –
  • ele (EleStruct) –
  • old_format (bool) –

write_blender_lat_layout

Fortran source: bmad/interface/blender_interface_mod.f90

write_blender_lat_layout(file_name: str, lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine write_blender_lat_layout

Parameters:

write_bmad_lattice_file

Fortran source: bmad/modules/bmad_routine_interface.f90

write_bmad_lattice_file(bmad_file: str, lat: pybmad._pybmad.LatStruct, output_form: typing.SupportsInt | typing.SupportsIndex | None = None, orbit0: pybmad._pybmad.CoordStruct | None = None) -> bool

Wrapper for Fortran routine write_bmad_lattice_file

Parameters:
  • bmad_file (str) –

    Name of the output lattice file.

  • lat (LatStruct) –

    Holds the lattice information.

  • output_form (int) –

    binary$ -> Write grid_field info in binary hdf5 form in separate files. Default. All other fields are writen in separate files in ASCII ascii$ -> Fields will be put in separate ASCII files. one_file$ -> Everything in one file.

  • orbit0 (CoordStruct) –

    Initial orbit. Used to write the inital orbit if the lattice geometry is closed.

Returns:
  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_gpt_field_grid_file_1d

Fortran source: bmad/interface/gpt_interface_mod.f90

write_gpt_field_grid_file_1d(gpt_file_unit: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, dz: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.WriteGptFieldGridFile1d

Subroutine write_gpt_field_grid_file_1D (gpt_file_unit, ele, maxfield, ref_time, dz, err)

Write 1-D field map files for gpt. The format is: z field ...

Note: Simplified from write_opal_field_grid_file

Parameters:
  • gpt_file_unit (int) –

    unit number to write to, if > 0 if < 0, nothing is written, and only maxfield is returned

  • ele (EleStruct) –

    element to make map

  • dz (float) –

    z step size in m. Default: 0.001 m

Returns:
  • maxfield( float ) –

    absolute maximum found for element field scaling

  • ref_time( float ) –

    time that the field was evaluated at

  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_gpt_field_grid_file_2d

Fortran source: bmad/interface/gpt_interface_mod.f90

write_gpt_field_grid_file_2d(gpt_file_unit: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, dr: typing.SupportsFloat | typing.SupportsIndex | None = None, dz: typing.SupportsFloat | typing.SupportsIndex | None = None, r_max: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.WriteGptFieldGridFile2d

Subroutine write_gpt_field_grid_file_2D (gpt_file_unit, ele, maxfield, ref_time, dr, dz, err)

Subroutine to write an GPT lattice file using the information in a lat_struct. Optionally only part of the lattice can be generated.

Parameters:
  • gpt_file_unit (int) –

    unit number to write to, if > 0 if < 0, nothing is written, and only maxfield is returned

  • ele (EleStruct) –

    element to make map

  • dr (float) –

    r step size in m. Default: 0.001 m

  • dz (float) –

    z step size in m. Default: 0.001 m

  • r_max (float) –

    maximum radius in m. Default: 0.02 m

Returns:
  • maxfield( float ) –

    absolute maximum found for element field scaling

  • ref_time( float ) –

    time that the field was evaluated at

  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_gpt_field_grid_file_3d

Fortran source: bmad/interface/gpt_interface_mod.f90

write_gpt_field_grid_file_3d(base_filename: str, ele: pybmad._pybmad.EleStruct, dz: typing.SupportsFloat | typing.SupportsIndex | None = None) -> pybmad._pybmad.WriteGptFieldGridFile3d

Subroutine write_gpt_field_grid_file_3D (base_filename, ele, maxfield, ref_time, dz, err)

Writes 3-D field map files for gpt. The format is:

E-fields: 'x', 'y', 'z', 'ExRe', 'EyRe', 'EzRe', 'ExIm ', 'EyIm ', 'EzIm ' H-fields 'x', 'y', 'z', 'HxRe', 'HyRe', 'HzRe', 'HxIm ', 'HyIm ', 'HzIm '

where the fields oscillate as exp(+i \omega t)

Note: similar to write_gpt_field_grid_file

Parameters:
  • base_filename (str) –

    Base filename. Files will be written as: base_filename_E_ASCII.gpt, _H_ASCII.gpt If set to '', no files will be written

  • ele (EleStruct) –

    element to make map

  • dz (float) –

    z step size in m. Default: 0.001 m

Returns:
  • maxfield( float ) –

    absolute maximum on-axis field found for element field scaling

  • ref_time( float ) –

    time that the field was evaluated at

  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_lat_line

Fortran source: bmad/output/write_lattice_file_mod.f90

write_lat_line(line: str, iu: typing.SupportsInt | typing.SupportsIndex, end_is_neigh: bool, do_split: bool | None = None, ampersand_at_ends: bool | None = None) -> pybmad._pybmad.WriteLatLine

Subroutine write_lat_line (line, iu, end_is_neigh, do_split, ampersand_at_ends)

Routine to write strings to a lattice file. This routine will break the string up into multiple lines if the string is too long and add a continuation character if needed.

If the "line" arg does not represent a full "sentence" (end_is_neigh = False), then only part of the line may be written and the part not written will be returned.

Parameters:
  • line (str) –

    String of text. This parameter is an input/output and is modified in-place. As an output, line: part of the string not written.

  • iu (int) –

    Unit number to write to.

  • end_is_neigh (bool) –

    If true then write out everything. Otherwise wait for a full line of max_char characters or so.

  • do_split (bool) –

    Split line if overlength? Default is True. False is used when line has already been split for expressions since the expression splitting routine does a much better job of it.

  • ampersand_at_ends (bool) –

    Default True. If False then do not include "&" line continuation

Returns:
  • line( str ) –

    String of text. This parameter is an input/output and is modified in-place. As an output, line: part of the string not written.

write_lattice_in_elegant_format

Fortran source: bmad/modules/bmad_routine_interface.f90

write_lattice_in_elegant_format(out_file_name: str, lat: pybmad._pybmad.LatStruct, ref_orbit: pybmad._pybmad.CoordStructAlloc1D | None = None, use_matrix_model: bool | None = None, include_apertures: bool | None = None, dr12_drift_max: typing.SupportsFloat | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine write_lattice_in_elegant_format

Parameters:
  • out_file_name (str) –

    Name of the mad output lattice file.

  • lat (LatStruct) –

    Holds the lattice information.

  • ref_orbit (1D array of CoordStruct) –

    Referece orbit for sad_mult and patch elements. This argument must be present if the lattice has sad_mult or patch elements and is being translated to MAD-8 or SAD.

  • use_matrix_model (bool) –

    Use a drift-matrix_drift model for wigglers/undulators? [A MAD "matrix" is a 2nd order Taylor map.] This switch is ignored for SAD conversion. Default is False -> Use a bend-drift-bend model. Note: sol_quad elements always use a drift-matrix-drift model.

  • include_apertures (bool) –

    If True (the default), add to the output lattice a zero length collimator element next to any non- collimator element that has an aperture. Note: MADX translations for non-drift elements can handle non- collimator elements with an aperture so in this case this argument is ignored.

  • dr12_drift_max (float) –

    Max deviation for drifts allowed before a correction matrix element is added. Default value is 1d-5. A negative number means use default.

  • ix_branch (int) –

    Index of lattice branch to use. Default = 0.

Returns:
  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_lattice_in_foreign_format

Fortran source: bmad/modules/bmad_routine_interface.f90

write_lattice_in_foreign_format(out_type: str, out_file_name: str, lat: pybmad._pybmad.LatStruct, ref_orbit: pybmad._pybmad.CoordStructAlloc1D | None = None, use_matrix_model: bool | None = None, include_apertures: bool | None = None, dr12_drift_max: typing.SupportsFloat | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine write_lattice_in_foreign_format

Parameters:
  • out_type (str) –

    Either 'ELEGANT', 'MAD-8', 'MAD-X', 'SAD', 'OPAL-T', 'PALS', or 'SCIBMAD'.

  • out_file_name (str) –

    Name of the mad output lattice file.

  • lat (LatStruct) –

    Holds the lattice information.

  • ref_orbit (1D array of CoordStruct) –

    Referece orbit for sad_mult and patch elements. This argument must be present if the lattice has sad_mult or patch elements and is being translated to MAD-8 or SAD.

  • use_matrix_model (bool) –

    Use a drift-matrix_drift model for wigglers/undulators? [A MAD "matrix" is a 2nd order Taylor map.] This switch is ignored for SAD conversion. Default is False -> Use a bend-drift-bend model. Note: sol_quad elements always use a drift-matrix-drift model.

  • include_apertures (bool) –

    If True (the default), add to the output lattice a zero length collimator element next to any non- collimator element that has an aperture. Note: MADX translations for non-drift elements can handle non- collimator elements with an aperture so in this case this argument is ignored.

  • dr12_drift_max (float) –

    Max deviation for drifts allowed before a correction matrix element is added. Default value is 1d-5. A negative number means use default.

  • ix_branch (int) –

    Index of lattice branch to use. Default = 0.

Returns:
  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_lattice_in_mad_format

Fortran source: bmad/modules/bmad_routine_interface.f90

write_lattice_in_mad_format(out_type: str, out_file_name: str, lat: pybmad._pybmad.LatStruct, ref_orbit: pybmad._pybmad.CoordStructAlloc1D | None = None, use_matrix_model: bool | None = None, include_apertures: bool | None = None, dr12_drift_max: typing.SupportsFloat | typing.SupportsIndex | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None) -> bool

Wrapper for Fortran routine write_lattice_in_mad_format

Parameters:
  • out_type (str) –

    Either 'MAD-8', or 'MAD-X'

  • out_file_name (str) –

    Name of the mad output lattice file.

  • lat (LatStruct) –

    Holds the lattice information.

  • ref_orbit (1D array of CoordStruct) –

    Referece orbit for sad_mult and patch elements. This argument must be present if the lattice has sad_mult or patch elements and is being translated to MAD-8 or SAD.

  • use_matrix_model (bool) –

    Use a drift-matrix_drift model for wigglers/undulators? [A MAD "matrix" is a 2nd order Taylor map.] This switch is ignored for SAD conversion. Default is False -> Use a bend-drift-bend model. Note: sol_quad elements always use a drift-matrix-drift model.

  • include_apertures (bool) –

    If True (the default), add to the output lattice a zero length collimator element next to any non- collimator element that has an aperture. Note: MADX translations for non-drift elements can handle non- collimator elements with an aperture so in this case this argument is ignored.

  • dr12_drift_max (float) –

    Max deviation for drifts allowed before a correction matrix element is added. Default value is 1d-5. A negative number means use default.

  • ix_branch (int) –

    Index of lattice branch to use. Default = 0.

Returns:
  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_lattice_in_pals

Fortran source: bmad/modules/bmad_routine_interface.f90

write_lattice_in_pals(lat: pybmad._pybmad.LatStruct) -> pybmad._pybmad.WriteLatticeInPals

Wrapper for Fortran routine write_lattice_in_pals

Parameters:
Returns:
  • pals_file( str ) –

    Pals lattice file name.

  • err_flag( (bool, optional) ) –

    Error flag

write_lattice_in_sad_format

Fortran source: bmad/modules/bmad_routine_interface.f90

write_lattice_in_sad_format(out_file_name: str, lat: pybmad._pybmad.LatStruct, include_apertures: bool | None = None, ix_branch: typing.SupportsInt | typing.SupportsIndex | None = None, err: bool | None = None) -> None

Wrapper for Fortran routine write_lattice_in_sad_format

Parameters:
  • out_file_name (str) –
  • lat (LatStruct) –
  • include_apertures (bool) –
  • ix_branch (int) –
  • err (bool) –

write_lattice_in_scibmad

Fortran source: bmad/modules/bmad_routine_interface.f90

write_lattice_in_scibmad(lat: pybmad._pybmad.LatStruct) -> pybmad._pybmad.WriteLatticeInScibmad

Wrapper for Fortran routine write_lattice_in_scibmad

Parameters:
Returns:
  • scibmad_file( str ) –

    SciBmad lattice file name.

  • err_flag( (bool, optional) ) –

    Error flag

write_line_element

Fortran source: bmad/output/write_lattice_file_mod.f90

write_line_element(line: str, iu: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, lat: pybmad._pybmad.LatStruct) -> None

Wrapper for Fortran routine write_line_element

Parameters:

write_opal_field_grid_file

Fortran source: bmad/interface/opal_interface_mod.f90

write_opal_field_grid_file(opal_file_unit: typing.SupportsInt | typing.SupportsIndex, ele: pybmad._pybmad.EleStruct, param: pybmad._pybmad.LatParamStruct) -> pybmad._pybmad.WriteOpalFieldGridFile

Subroutine write_opal_field_grid_file (opal_file_unit, ele, param, maxfield, err)

Subroutine to write an OPAL lattice file using the information in a lat_struct. Optionally only part of the lattice can be generated.

Parameters:
  • opal_file_unit (int) –

    unit number to write to, if > 0 if < 0, nothing is written, and only maxfield is returned

  • ele (EleStruct) –

    element to make map

  • param (LatParamStruct) –

    Contains lattice information

Returns:
  • maxfield( float ) –

    absolute maximum found for element field scaling

  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_opal_lattice_file

Fortran source: bmad/interface/opal_interface_mod.f90

write_opal_lattice_file(opal_file_unit: typing.SupportsInt | typing.SupportsIndex, lat: pybmad._pybmad.LatStruct) -> bool

Subroutine write_opal_lattice_file (opal_file_unit, lat, err)

Subroutine to write an OPAL lattice file using the information in a lat_struct. Optionally only part of the lattice can be generated.

Parameters:
  • opal_file_unit (int) –

    unit number to write to

  • lat (LatStruct) –

    Holds the lattice information.

Returns:
  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

write_time_particle_distribution

Fortran source: bmad/modules/time_tracker_mod.f90

write_time_particle_distribution(time_file_unit: typing.SupportsInt | typing.SupportsIndex, bunch: pybmad._pybmad.BunchStruct, ele: pybmad._pybmad.EleStruct, style: str | None = None, branch: pybmad._pybmad.BranchStruct | None = None, format: str | None = None) -> bool

Subroutine write_time_particle_distribution (time_file_unit, bunch, ele, style, branch, format, err)

Subroutine to write a time-based bunch from a standard Bmad bunch

Note: 'BMAD' style (absolute curvilinear coordinates): n_particles_alive x/m mc^2 \beta_x\gamma/eV y/m mc^2\beta_y\gamma/eV s/m mc^2\beta_z\gamma/eV time/s charge/C

  'OPAL' style (absolute curvilinear coordinates):
  n_particles_alive
  x/m  \beta_x*\gamma  y/m \beta_y*\gamma s/m \beta_s*\gamma

  'ASTRA' style (global Cartesian coordinates, first line is the reference particle used for z, pz, and t calculation):
  x/m y/m  z/m  m*c^2 \beta_x*\gamma/eV m*c^2 \beta_y*\gamma/eV m*c^2 \beta_z*\gamma/eV time/ns charge/nC species status

  'GPT' style (global Cartesian coordinates, with header labeling the columns)
  x/m y/m z/m \beta_x*\gamma \beta_y*\gamma \beta_z*\gamma t/s elementary_charge/C charge/elementary_charge
Parameters:
  • time_file_unit (int) –

    unit number to write to, if > 0

  • bunch (BunchStruct) –

    bunch to be written. Particles are drifted to bmad_bunch.t_center for output

  • ele (EleStruct) –

    Element being tracked through.

  • style (str) –

    Style of output file: 'BMAD' (default), 'OPAL', 'ASTRA', 'GPT'

  • branch (BranchStruct) –

    Required for 'ASTRA' style

  • format (str) –

    format for numerical output. default: 'es15.7'

Returns:
  • err( (bool, optional) ) –

    Set True if, say a file could not be opened.

xlafun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

xlafun(x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, z: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine xlafun

Parameters:
  • x (float) –
  • y (float) –
  • z (float) –
  • res (float) –

xraylib_nist_compound

Fortran source: bmad/interface/xraylib_interface.f90

xraylib_nist_compound(name: str) -> int

Function xraylib_nist_compound (name) result (indx)

Routine to return the xraylib index for a given NIST compound. Taken from file xraylib/include/xraylib-nist_compounds.h

Parameters:
  • name (str) –

    Name of compound

Returns:
  • indx( int ) –

    Compound index. -1 if not found.

ylafun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

ylafun(x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, z: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine ylafun

Parameters:
  • x (float) –
  • y (float) –
  • z (float) –
  • res (float) –

z_at_surface

Fortran source: bmad/photon/photon_utils_mod.f90

z_at_surface(ele: pybmad._pybmad.EleStruct, x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, extend_grid: bool | None = None) -> pybmad._pybmad.ZAtSurface

Function z_at_surface (ele, x, y, err_flag, extend_grid, dz_dxy) result (z)

Routine return the height (z) of the surface for a particular (x,y) position. Remember: +z points into the element.

Parameters:
  • ele (EleStruct) –

    Element

  • x (float) –

    Photon coordinates on surface.

  • y (float) –

    Photon coordinates on surface.

  • extend_grid (bool) –

    If a grid is involved and (x, y) is outside of the grid, and extend_grid = True: Pretend (x, y) is at edge. Default is False.

Returns:
  • err_flag( bool ) –

    Set True if cannot compute z due to, say, point being outside of ellipseoid or grid bounds.

  • z( float ) –

    z coordinate.

  • dz_dxy( 1D array of float (shape: 2), optional ) –

    Surface slope at (x, y).

zero_ele_kicks

Fortran source: bmad/modules/bmad_routine_interface.f90

zero_ele_kicks(ele: pybmad._pybmad.EleStruct) -> None

Wrapper for Fortran routine zero_ele_kicks

Parameters:
  • ele (EleStruct) –

    Element with possible nonzero kicks. This parameter is an input/output and is modified in-place. As an output, ele: Element with no kicks.

zero_ele_offsets

Fortran source: bmad/modules/bmad_routine_interface.f90

zero_ele_offsets(ele: pybmad._pybmad.EleStruct) -> None

Wrapper for Fortran routine zero_ele_offsets

Parameters:
  • ele (EleStruct) –

    Element with possible nonzero offsets, etc. This parameter is an input/output and is modified in-place. As an output, ele: Element with no (mis)orientation.

zero_lr_wakes_in_lat

Fortran source: bmad/multiparticle/wake_mod.f90

zero_lr_wakes_in_lat(lat: pybmad._pybmad.LatStruct) -> None

Subroutine zero_lr_wakes_in_lat (lat)

Routine to zero the long range wake amplitudes for the elements that have long range wakes in a lattice.

Parameters:

zlafun

Fortran source: bmad/space_charge/open_spacecharge_core_mod.f90

zlafun(x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex, z: typing.SupportsFloat | typing.SupportsIndex, res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine zlafun

Parameters:
  • x (float) –
  • y (float) –
  • z (float) –
  • res (float) –