Bsim

Bsim application-level structs and routines (BBU, etc.).

Classes (Fortran Structures)

BbuBeamStruct

Fortran struct: bbu_beam_struct (bsim/code/bbu_track_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
bunch 1D array of BunchStruct Bunches in the lattice
stage 1D array of BbuStageStruct
ix_ele_bunch 1D array of int element where bunch is
ix_bunch_head int Index to head bunch(:)
ix_bunch_end int Index of the end bunch(:). -1 -> no bunches.
n_bunch_in_lat int Number of bunches transversing the lattice.
ix_stage_voltage_max int
hom_voltage_max float
time_now float
one_turn_time float
rf_wavelength_max float

BbuParamStruct

Fortran struct: bbu_param_struct (bsim/code/bbu_track_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
lat_filename str Bmad lattice file name
lat2_filename str Bmad lattice2 file name for secondary parser
bunch_by_bunch_info_file str For outputting bunch-by-bunch info.
hybridize bool Combine non-hom elements to speed up simulation?
write_digested_hybrid_lat bool For debugging purposes.
write_voltage_vs_time_dat bool For debugging purposes.
keep_overlays_and_groups bool Keep when hybridizing?
keep_all_lcavities bool Keep when hybridizing?
use_taylor_for_hybrids bool Use taylor map for hybrids when true. Otherwise tracking method is linear.
stable_orbit_anal bool Write stable_orbit.out and hom_voltage.out?
limit_factor float Init_hom_amp * limit_factor = simulation unstable limit
simulation_turns_max float Sets the duration of the simulation.
bunch_freq float Freq in Hz.
init_particle_offset float Initial particle offset for particles born in the first turn period.
current float Starting current (amps)
rel_tol float Final threshold current accuracy.
drscan bool If true, scan DR variable as in PRSTAB 7 (2004) Fig. 3.
use_interpolated_threshold bool
write_hom_info bool Write HOM parameters to main output file?
elindex int
elname str Element to step length for DRSCAN
nstep int Number of steps for DRSCAN.
begdr float Beginning DR value for DRSCAN.
enddr float End DR value for DRSCAN.
nrep int Number of times to repeat threshold calculation
ran_seed int If set to 0, the output results will vary from run to run.
hom_order_cutoff int If positive -> ignore HOM's with order greater than this.
ran_gauss_sigma_cut float
ele_track_end str
ix_ele_track_end int Default: set to last element with a wake
regression bool Do regression test?
normalize_z_to_rf bool make starting z = mod(z, rf_wavelength)? Ramp parameters
ramp_on bool
ramp_pattern 1D array of float (shape: 1000)
ramp_n_start int Index of start of ramp Internal parameters
n_ramp_pattern int Number of valid ramp_pattern

BbuStageStruct

Fortran struct: bbu_stage_struct (bsim/code/bbu_track_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ix_ele_lr_wake int Element index of element with the wake
ix_ele_stage_end int Element at end of stage.
ix_pass int Pass index when in multipass section
ix_stage_pass1 int Index of corresponding stage on first pass
ix_head_bunch int
ix_hom_max int
hom_voltage_max float
time_at_wake_ele float
ave_orb 1D array of float (shape: 6)
rms_orb 1D array of float (shape: 6)
min_orb 1D array of float (shape: 6)
max_orb 1D array of float (shape: 6)
n_orb int

Procedures

bbu_add_a_bunch

Fortran source: bsim/code/bbu_track_mod.f90

bbu_add_a_bunch(lat: pybmad._pybmad.LatStruct, bbu_beam: pybmad._pybmad.BbuBeamStruct, bbu_param: pybmad._pybmad.BbuParamStruct, beam_init: pybmad._pybmad.BeamInitStruct) -> None

Wrapper for Fortran routine bbu_add_a_bunch

Parameters:

bbu_hom_voltage_calc

Fortran source: bsim/code/bbu_track_mod.f90

bbu_hom_voltage_calc(lat: pybmad._pybmad.LatStruct, bbu_beam: pybmad._pybmad.BbuBeamStruct, n_period: typing.SupportsInt | typing.SupportsIndex, ix_stage_last_tracked: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine bbu_hom_voltage_calc

Parameters:

bbu_remove_head_bunch

Fortran source: bsim/code/bbu_track_mod.f90

bbu_remove_head_bunch(bbu_beam: pybmad._pybmad.BbuBeamStruct) -> None

Wrapper for Fortran routine bbu_remove_head_bunch

Parameters:

bbu_setup

Fortran source: bsim/code/bbu_track_mod.f90

bbu_setup(lat: pybmad._pybmad.LatStruct, dt_bunch: typing.SupportsFloat | typing.SupportsIndex, bbu_param: pybmad._pybmad.BbuParamStruct, bbu_beam: pybmad._pybmad.BbuBeamStruct) -> None

Wrapper for Fortran routine bbu_setup

Parameters:

bbu_track_a_stage

Fortran source: bsim/code/bbu_track_mod.f90

bbu_track_a_stage(lat: pybmad._pybmad.LatStruct, bbu_beam: pybmad._pybmad.BbuBeamStruct, bbu_param: pybmad._pybmad.BbuParamStruct, lost: bool, ix_stage_tracked: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine bbu_track_a_stage

Parameters:

bbu_track_all

Fortran source: bsim/code/bbu_track_mod.f90

bbu_track_all(lat: pybmad._pybmad.LatStruct, bbu_beam: pybmad._pybmad.BbuBeamStruct, bbu_param: pybmad._pybmad.BbuParamStruct, beam_init: pybmad._pybmad.BeamInitStruct) -> pybmad._pybmad.BbuTrackAll

Wrapper for Fortran routine bbu_track_all

Parameters:
Returns:
  • hom_voltage_normalized( float ) –

    HOM voltage normalized

  • growth_rate( float ) –

    Growth rate

  • lost( bool ) –

    Lost

  • irep( int ) –

    irep

check_rf_freq

Fortran source: bsim/code/bbu_track_mod.f90

check_rf_freq(lat: pybmad._pybmad.LatStruct, fb: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine check_rf_freq

Parameters:

count_lines_in_file

Fortran source: bsim/code/count_lines_in_file.f90

count_lines_in_file(file_name: str) -> int

Wrapper for Fortran routine count_lines_in_file

Parameters:
  • file_name (str) –
Returns:
  • lines( int ) –

hom_voltage

Fortran source: bsim/code/bbu_track_mod.f90

hom_voltage(lr_wake: pybmad._pybmad.WakeLrModeStruct, voltage: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine hom_voltage

Parameters:

insert_phase_trombone

Fortran source: bsim/code/bsim_interface.f90

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

Wrapper for Fortran routine insert_phase_trombone

Parameters:
  • branch (BranchStruct) –

    Lattice branch. This parameter is an input/output and is modified in-place. As an output, branch: Lattice branch with trumbone at branch.ele(1).

logical_to_python

Fortran source: bsim/code/bbu_track_mod.f90

logical_to_python(logic: bool, string: str) -> None

Wrapper for Fortran routine logical_to_python

Parameters:
  • logic (bool) –
  • string (str) –

rf_cav_names

Fortran source: bsim/code/bbu_track_mod.f90

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

Wrapper for Fortran routine rf_cav_names

Parameters:

set_tune_3d

Fortran source: bsim/code/bsim_interface.f90

set_tune_3d(branch: pybmad._pybmad.BranchStruct, target_tunes: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], mask: str | None = None, use_phase_trombone: bool | None = None, z_tune_set: bool | None = None, group_knobs: typing.Annotated[collections.abc.Sequence[str], "FixedSize(2)"] | None = None, print_err: bool | None = None) -> bool

Wrapper for Fortran routine set_tune_3d

Parameters:
  • branch (BranchStruct) –

    This parameter is an input/output and is modified in-place. As an output, branch: with adjusted quads and RF to match desired tunes.

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

    tunes for a, b, z modes (rad/2pi). Must include integer part.

  • mask (str) –
  • use_phase_trombone (bool) –

    Default False. If true, use a match element in phase trombone mode to adjust the tunes. The match element must be the first element in the lattice. Use insert_phase_trombone to insert one.

  • z_tune_set (bool) –

    Default True. If false, do not try to set the synch tune.

  • group_knobs (1D array of str (shape: 2)) –

    If set non-blank, use these group elements for tuning.

  • print_err (bool) –

    Print error message if there is a problem? Default is True.

Returns:
  • everything_ok( bool ) –

    Returns true or false if set was successful.

write_bunch_by_bunch_info

Fortran source: bsim/code/bbu_track_mod.f90

write_bunch_by_bunch_info(lat: pybmad._pybmad.LatStruct, bbu_beam: pybmad._pybmad.BbuBeamStruct, bbu_param: pybmad._pybmad.BbuParamStruct, this_stage: pybmad._pybmad.BbuStageStruct) -> None

Wrapper for Fortran routine write_bunch_by_bunch_info

Parameters: