Python API

Package ibs

Top-level package for ibs.

ibs.print_model_map() None[source]

Print the IBS model map.

Command line interface runode.

ibs.cli_runode.check_sim_input(sim_input: dict) str[source]

Check correctness of content of simulation input file.

Parameters

sim_input (dict) – output for read_sim_input

Returns

man | auto - sets the timesteps in the simulation to man or auto.

Return type

str

ibs.cli_runode.latexify(fig_width=None, fig_height=None, columns=1)[source]

Set up matplotlib’s RC params for LaTeX plotting. Call this before plotting a figure.

Parameters
  • fig_width (float, optional, inches) –

  • fig_height (float, optional, inches) –

  • columns ({1, 2}) –

ibs.cli_runode.plot(df: pandas.core.frame.DataFrame, sim_input: dict, save: bool = True) None[source]

Method to plot the ODE simulation results quickly.

Parameters
  • df (pd.DataFrame) – DataFrame containing the simulation results.

  • save (bool) – save plot to file

  • sim_input (dict) – output of read_sim_input

ibs.cli_runode.read_sim_input(infile: str) dict[source]

Read the simulation input file (JSON).

Parameters

infile (str) – JSON input file with simulation settings.

Returns

Simulation settings as dict.

Return type

dict

ibs.cli_runode.run_all(sim_input: dict, sim_type: str) dict[source]

Runs the simulation for all available IBS models.

Parameters
  • sim_input (dict) – output of read_sim_input

  • sim_type (str) – output of check_sim_input

Returns

Dict with all simulation outputs, model column is used to distinguish the results for the different models.

Return type

dict

ibs.cli_runode.run_single(sim_input: dict, sim_type: str) dict[source]

Run simulation for single IBS model.

Parameters
  • sim_input (dict) – output of read_sim_input

  • sim_type (str) – output of check_sim_input

Returns

Returns a dict with the simultion output (keys: t, ex, ey, sigs, model).

Return type

dict

Package IBSLib

Python wrapper around C++ IBSLib.

IBSLib.BjorkenMtingwaSimpson(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Bjorken-Mtingwa using Standard Simpson integration.

IBSLib.BjorkenMtingwaSimpsonDecade(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Bjorken-Mtingwa using Simpson Decade integration.

IBSLib.BjorkenMtingwaTailcutSimpsonDecade(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, AtomicMassNumber: float, outputArray: numpy.ndarray[numpy.float64]) None

Bjorken-Mtingwa using Simpson Decade integration with Tailcut

IBSLib.ConteMartiniSimpsonDecade(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Conte-Martini using Simpson Decade integration.

IBSLib.ConteMartiniTailcutSimpsonDecade(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, AtomicMassNumber: float, outputArray: numpy.ndarray[numpy.float64]) None

Conte-Martini using Simpson Decade integration with Tailcut

IBSLib.GetTwissHeader(filename: str) Dict[str, float]

Get the twiss header as a dictionary.

IBSLib.GetTwissTable(filename: str) Dict[str, List[float]]

Get the twiss data table.

IBSLib.Nagaitsev(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Nagaitsev

IBSLib.NagaitsevTailcut(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, AtomicMassNumber: float, outputArray: numpy.ndarray[numpy.float64]) None

Nagaitsev Tailcut

IBSLib.PiwinskiLattice(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Piwinski Lattice

IBSLib.PiwinskiLatticeModified(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Piwinski Lattice Modified

IBSLib.PiwinskiSmooth(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Piwinski smooth

IBSLib.RadiationDampingApprox(latticelength: float, gamma: float, gammaTransition: float, bendingradius: float, betax: float, betay: float, outputArray: numpy.ndarray[numpy.float64]) None

Radiation Damping using Ring averages.

IBSLib.RadiationDampingEquilibria(twissHeaderMap: Dict[str, float], RadIntArray: numpy.ndarray[numpy.float64], AtomicMassNumber: float, synchrotronTune: float, outputArray: numpy.ndarray[numpy.float64]) None

Get radiation damping equilibs.

IBSLib.RadiationDampingLattice(twissTableMap: Dict[str, List[float]], outputArray: numpy.ndarray[numpy.float64]) None

Radiation damping weighted per element.

IBSLib.Zimmerman(pnumber: float, emitx: float, emity: float, bunchLength: float, sige: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, printoutflag: bool, outputArray: numpy.ndarray[numpy.float64]) None

Zimmerman

IBSLib.ZimmermanSimpsonDecade(pnumber: float, emitx: float, emity: float, bunchLength: float, dpop: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, outputArray: numpy.ndarray[numpy.float64]) None

Zimmerman using Simpson Decade

IBSLib.ZimmermanTailcut(pnumber: float, emitx: float, emity: float, bunchLength: float, sige: float, twissHeaderMap: Dict[str, float], twissTableMap: Dict[str, List[float]], classicalRadius: float, AtomicMassNumber: float, outputArray: numpy.ndarray[numpy.float64]) None

Zimmerman Tailcut

IBSLib.beta_relativistic_from_gamma(Gamma: float) float

Beta relativistic.

IBSLib.coulomblog(pnumber: float, emitx: float, emity: float, twissheader: Dict[str, float], sige: float, sigt: float, classialRadius: float, printout: bool, outputArray: numpy.ndarray[numpy.float64]) None

Calculate the Coulomb Log using ring average.

IBSLib.coulomblogtail(pnumber: float, emitx: float, emity: float, twissheader: Dict[str, float], sige: float, sigt: float, tauradx: float, taurady: float, taurads: float, classialRadius: float, printout: bool, outputArray: numpy.ndarray[numpy.float64]) None

Calculate the Coulomb Log with tailcut using ring average.

IBSLib.dee_to_dpp(dee: float, beta: float) float

DE/E to DP/P

IBSLib.dpp_to_dee(dpp: float, beta: float) float

DP/P to DE/E

IBSLib.eta(Gamma: float, GammaTransition: float) float

Slip factor

IBSLib.fmohl(arg0: float, arg1: float, arg2: float, arg3: int) float

Fmohl function

IBSLib.get_energy_loss_per_turn(twissTableMap: Dict[str, float], I2: float, AtomicMassNumber: float) float

Get the energy loss per turn.

IBSLib.get_synchronuous_phase(targetEnergyGain: float, init_phi: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float], epsilon: float) float

Synchronuous Phase

IBSLib.get_synchronuous_phase_with_potential_well_distortion(targetEnergyGain: float, init_phi: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float], L: float, N: float, sigs: float, pc: float, epsilon: float) float

Synchronuous Phase with Potential Well Distortion

IBSLib.get_synchrotron_tune(omega0: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float], phis: float, eta: float, pc: float) float

Synchronuous Tune

IBSLib.get_synchrotron_tune_with_potential_well(omega0: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float], L: float, N: float, sigs: float, phis: float, eta: float, pc: float) float

Synchronuous Tune ith Potential Well Distortion

IBSLib.integral_bjorken_mtingwa(pnumber: float, emitx: float, emity: float, sigs: float, sige: float, gamma: float, betax: float, betay: float, alphax: float, alphay: float, dispersionx: float, dispersionx_der: float, dispersiony: float, dispersiony_der: float, tau: numpy.ndarray[numpy.float64]) None

Bjorken-Mtingwa integral calculated using Simpson Decade

IBSLib.integral_conte_martini(pnumber: float, emitx: float, emity: float, sigs: float, sige: float, gamma: float, betax: float, betay: float, alphax: float, alphay: float, dispersionx: float, dispersionx_der: float, dispersiony: float, dispersiony_der: float, tau: numpy.ndarray[numpy.float64]) None

Conte-Martini integral calculated using Simpson Decade

IBSLib.integral_zimmerman(pnumber: float, emitx: float, emity: float, sigs: float, sige: float, gamma: float, betax: float, betay: float, alphax: float, alphay: float, dispersionx: float, dispersionx_der: float, dispersiony: float, dispersiony_der: float, tau: numpy.ndarray[numpy.float64]) None

Zimmerman integral calculated using Simpson Decade

IBSLib.integrand(int_var: float, ax: float, bx: float, a: float, b: float, c: float) float

IBS integral integrand

IBSLib.integrator_simpson(arg0: Callable[[float, float, float, float, float, float], float], arg1: float, arg2: float, arg3: float, arg4: float, arg5: float, arg6: float, arg7: float, arg8: int) float

standard simpson integration on variable integrand (function)

IBSLib.integrator_simpson_bjorken_mtingwa(arg0: Callable[[float, float, float, float, float, float], float], arg1: float, arg2: float, arg3: float, arg4: float, arg5: float, arg6: float, arg7: float, arg8: float, arg9: float, arg10: numpy.ndarray[numpy.float64]) None

Standard Simpson integral on Bjorken-Mtingwa integrand.

IBSLib.integrator_simpson_decade(a: float, b: float, c: float, cl: float, cx: float, cy: float, cprime: float, cyy: float, tl1: float, tl2: float, tx1: float, tx2: float, ty1: float, ty2: float, tau: numpy.ndarray[numpy.float64]) None

Simpson integrator with decade splitting.

IBSLib.integrator_twsint(pnumber: float, emitx: float, emity: float, sigs: float, sige: float, gamma: float, betax: float, betay: float, alphax: float, alphay: float, dispersionx: float, dispersionx_der: float, dispersiony: float, dispersiony_der: float, tau: numpy.ndarray[numpy.float64]) None

MADX Simpson Decade with scaling integrator

IBSLib.particle_radius(charge: float, AtomicNumber: float) float

Particle radius from charge and atomic mass.

IBSLib.printTwissColumn(columnName: str, twissTableMap: Dict[str, List[float]]) None

Print Twiss column

IBSLib.rds(arg0: float, arg1: float, arg2: float) float

Nagaitsev paper rds function

IBSLib.rf_voltage_in_ev(phi: float, charge: float, harmonicNumbers: List[float], voltages: List[float]) float

RF energy gain per turn [eV]

IBSLib.rf_voltage_in_ev_prime(phi: float, charge: float, harmonicNumbers: List[float], voltages: List[float]) float

Derivative of RF energy gain per turn [eV]

IBSLib.rf_voltage_in_ev_with_rad_losses(phi: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float]) float

RF energy gain per turn [eV] with Radiation Losses

IBSLib.rf_voltage_with_potential_well_distortion(phi: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float], L: float, N: float, sigs: float, pc: float) float

RF energy gain [eV] with Potential Well Distortion

IBSLib.rf_voltage_with_potential_well_distortion_prime(phi: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float], L: float, N: float, sigs: float, pc: float) float

Derivative of RF energy gain [eV] with Potential Well Distortion

IBSLib.runODE(*args, **kwargs)

Overloaded function.

  1. runODE(twissheader: Dict[str, float], twisstable: Dict[str, List[float]], harmonic_rf: List[float], voltages_rf: List[float], t: List[float], ex: List[float], ey: List[float], sigs: List[float], sige: List[float], model: int, pnumber: float, couplingPercentage: int, threshold: float, simulationMethod: str) -> Dict[str, List[float]]

Run ODE simulation using auto time step.

  1. runODE(twissheader: Dict[str, float], twisstable: Dict[str, List[float]], harmonic_rf: List[float], voltages_rf: List[float], t: List[float], ex: List[float], ey: List[float], sigs: List[float], sige: List[float], model: int, pnumber: float, nsteps: int, stepsize: float, couplingPercentage: int, simulationMethod: str) -> Dict[str, List[float]]

Run ODE simulation with fixed number of steps and stepsize.

IBSLib.sige_form_sigs_using_rf(: float, U0: float, charge: float, harmonicNumbers: List[float], voltages: List[float], gamma: float, gammaTransition: float, pc: float, circ: float, phis: float, printout: bool) float

Sigma E from Sigma s using RF settings.

IBSLib.sige_from_sigs(omega0: float, sigs: float, qs: float, gamma: float, gammatr: float) float

Energy spread from bunch length.

IBSLib.sigs_from_sige(sige: float, gamma: float, gammatr: float, omegas: float) float

Bunch length from energy spread.

IBSLib.twclog(pnumber: float, betax: float, betay: float, dispersionx: float, disperisony: float, emitx: float, emity: float, classicalRadius: float, gamma: float, charge: float, energy: float, restEnergy_GeV: float, sige: float, sigt: float, outputArray: numpy.ndarray[numpy.float64]) None

Calculate the Coulomb Log.

IBSLib.twclogtail(pnumber: float, elementLength: float, betax: float, betay: float, dispersionx: float, dispersionx_der: float, dispersiony: float, dispersiony_der: float, alphax: float, alphay: float, angle: float, k1l: float, k1sl: float, emitx: float, emity: float, classicalRadius: float, AtomicMassNumber: float, gamma: float, energy: float, acceleratorLength: float, restEnergy_GeV: float, charge: float, sige: float, sigt: float, outputArray: numpy.ndarray[numpy.float64]) None

Calculate the Coulomb Log with Tailcut.

IBSLib.updateTwiss(table: Dict[str, List[float]]) Dict[str, List[float]]

Extend Twiss Table with rad int, CS gamma, curly H and rho.