C++ API

Twiss

map<string, double> GetTwissHeader(string filename)

Load Twiss header / summary from file.

Note

Twiss file needs to be produced with Madx.

Parameters

filename – Path to the Twiss file.

Returns

A map of twiss header parameters and their values.

vector<vector<double>> GetTable(string filename, vector<string> columns)

Load the Twiss table as vector of vectors.

Note

Twiss file needs to be produced with Madx.

Parameters
  • filename – Path to the Twiss file.

  • columns – Columns to extract from the Twiss file and store in the table.

Returns

Table with the values of the selected Twiss columns.

map<string, vector<double>> GetTwissTableAsMap(string filename)

Loat the Twiss table as a map (columnNames -> values).

Note

Twiss file needs to be produced with Madx.

Warning

Pre-selection of columns is taken : {“L”, “BETX”, “ALFX”, “BETY”,”ALFY”, “DX”, “DPX”, “DY”, “DPY”, “K1L”, “K1SL”, “ANGLE”}

Parameters

filename – Path to the Twiss file.

Returns

Map with column names as keys and values are the respective Twiss values for that column.

Numeric Constants

const double clight = 299792458.0

Speed of light.

const double hbar = 6.582119569e-25

Reduced Planck constant [GeV].

const double emass = 0.51099895000e-3

Electron mass [GeV].

const double pmass = 0.93827208816

Proton mass [GeV].

const double mumass = 0.1056583755

Muon mass [GeV].

const double atomicmassunit = 0.93149410242

Atomic mass unit [GeV].

const double pi = 3.141592653589793

Pi.

const double ec = 1.602176634e-19

Electric Charge unit [Coulomb].

const double euler = 0.577215664901533

Euler constant.

const double erad = 2.8179403262e-15

Classical radius [m].

const double prad = erad * emass / pmass

Classical proton radius [m].

Numeric Functions

void updateTwiss(map<string, vector<double>> &table)

Add ratiation integrals (I1-I5) per element to the Twiss Table Map. It also adds the relevant quantities to calculate them (e.g. curly H, rho, …).

Parameters

table[inout] Twiss Table Map

void printTwissMap(string key, map<string, vector<double>> &table)

Prints the values of the given Twiss column name. Mostly for debugging.

Parameters
  • key – Name of the column to print out.

  • table – Twiss Table Map to print from.

double BetaRelativisticFromGamma(double gamma)

Calculate relativistic beta given relativistic gamma.

Parameters

gamma – Relativistic gamma factor.

Returns

Relativistic Beta

double eta(double gamma, double gammatr)

Calculate slip factor eta, from gamma and gamma transition.

Parameters
  • gamma – Relativistic Gamma of the particles.

  • gammatr – Transition Relativistic Gamma of the accelerator lattice.

Returns

Slip factor Eta.

double ParticleRadius(double charge, double aatom)

Calculate the classical particle radius from its charge and atomic mass number A.

Parameters
  • charge – Charge of the particle.

  • aatom – Atomic mass number of the particle (A)

Returns

Classical radius of the particle.

double dee_to_dpp(double dee, double beta0)

Convert dE/E to dp/p.

Parameters
  • dee – dE/E

  • beta0 – Relativistic Beta

Returns

dp/p.

double dpp_to_dee(double dpp, double beta0)

Convert dp/p to dE/E.

Parameters
  • dpp – dp/p

  • beta0 – Relativistic Beta

Returns

dE/E.

double sigefromsigs(double omega0, double sigs, double qs, double gamma, double gammatr)

Convert to

Parameters
  • omega0 – Particle revolution angular frequency ( )

  • sigs

  • qs – Synchrotron Tune

  • gamma – Relativistic Gamma

  • gammatr – Transition Relativistic Gamma

Returns

double sigsfromsige(double sige, double gamma, double gammatr, double omegas)

Convert to

Parameters
  • omega0 – Particle revolution angular frequency ( )

  • sige

  • gamma – Relativistic Gamma

  • gammatr – Transition Relativistic Gamma

  • omegas – Synchrotron Frequency ( )

Returns

double EffectiveRFVoltageInElectronVolt(double phi, double charge, int nrf, double harmon[], double voltages[])

Get the energy gain in eV produced by the RF systems for given harmonic numbers and voltages.

Parameters
  • phi – RF phase for the particle

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

Returns

Energy gain [eV]

double EffectiveRFVoltageInElectronVoltPrime(double phi, double charge, int nrf, double harmon[], double voltages[])

Get the derivative of the energy gain in eV produced by the RF systems for given harmonic numbers and voltages.

Parameters
  • phi – RF phase for the particle

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

Returns

Derivative of the Energy gain [eV]

double VeffRFeVRadlosses(double phi, double U0, double charge, int nrf, double harmon[], double voltages[])

Get the energy gain in eV produced by the RF systems for given harmonic numbers and voltages taking radiation losses into account.

Parameters
  • phi – RF phase for the particle

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

Returns

Energy gain [eV] taking radiation losses into account.

double SynchronuousPhase(double target, double init_phi, double U0, double charge, int nrf, double harmon[], double voltages[], double epsilon)

Get the synchronuous phase for a particle for given energy gain, RF settings and radiation losses.

Parameters
  • target – Target energy gain per turn [eV]

  • init_phi – RF phase to start search from.

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

  • epsilon – Accuracy threshold for the target.

Returns

Synchronuous phase.

double VeffRFeVPotentialWellDistortion(double phi, double U0, double charge, int nrf, double harmon[], double voltages[], double L, double N, double sigs, double pc)

Get the energy gain in eV produced by the RF systems for given harmonic numbers and voltages taking potetial well distortion and radiation losses into account.

Parameters
  • phi – RF phase for the particle

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

  • L – Impedance L

  • N – Impedance N

  • sigs – bunch length

  • pc – Particle Momentum in GeV

Returns

Energy gain [eV] with Potential Well Distortion and Radiation Losses.

double VeffRFeVPotentialWellDistortionPrime(double phi, double U0, double charge, int nrf, double harmon[], double voltages[], double L, double N, double sigs, double pc)

Get the derivative of the energy gain in eV produced by the RF systems for given harmonic numbers and voltages taking potetial well distortion and radiation losses into account.

Parameters
  • phi – RF phase for the particle

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

  • L – Impedance L

  • N – Impedance N

  • sigs – bunch length

  • pc – Particle Momentum in GeV

Returns

Derivative of the Energy gain [eV] with Potential Well Distortion and Radiation Losses.

double SynchronuousPhaseWithPWD(double target, double init_phi, double U0, double charge, int nrf, double harmon[], double voltages[], double L, double N, double sigs, double pc, double epsilon)

Get the synchronuous phase with Potential Well Distortion for a particle for given energy gain, RF settings and radiation losses.

Parameters
  • target – Target energy gain per turn [eV]

  • init_phi – RF phase to start search from

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

  • L – Impedance L

  • N – Impedance N

  • sigs – bunch length

  • pc – Particle Momentum in GeV

  • epsilon – Accuracy threshold for the target

Returns

Synchronuous phase with Potential Well Distortion.

double SynchrotronTune(double omega0, double U0, double charge, int nrf, double harmon[], double voltages[], double phis, double eta, double pc)

Synchrotron Tune

Parameters
  • omega0 – Angular revolution frequency of the particle.

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

  • phis – Synchronuous phase of the particle

  • eta – Phase slip factor

  • pc – Particle Momentum [GeV]

Returns

Synchrotron Tune

double SynchrotronTunePWD(double omega0, double U0, double charge, int nrf, double harmon[], double voltages[], double L, double N, double sigs, double phis, double eta, double pc)

Synchrotron Tune with Potential Well Distortion

Parameters
  • omega0 – Angular revolution frequency of the particle.

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

  • L – Impedance L

  • N – Impedance N

  • phis – Synchronuous phase of the particle

  • eta – Phase slip factor

  • pc – Particle Momentum [GeV]

Returns

Synchrotron Tune with Potential Well Distortion

double SigeFromRFAndSigs(double sigs, double U0, double charge, int nrf, double harmon[], double voltages[], double gamma, double gammatr, double pc, double circ, double phis, bool printout)

Convert to using RF parameters

Parameters
  • sigs

  • U0 – Radiation losses per turn [eV]

  • charge – Charge of the particle

  • nrf – Number of RF systems

  • harmon – List of harmonic numbers

  • voltages – List of voltages

  • gamma – Relativistic Gamma

  • gammatr – Transition Relativistic Gamma

  • pc – Particle Momentum [GeV]

  • circ – Accelerator length

  • phis – Synchronuous phase of the particle

  • printout – Flag to print out the summary.

Returns

double fmohl(double a, double b, double q, int n)

Piwinski IBS approximation fmohl function. Reference in IBS models docstring.

Parameters
  • a

  • b

  • q

  • n – Number of iterations for accuracy (standard 1000 is ok)

Returns

Fmohl

double rds(double x, double y, double z)

Nagaitsev’s approximation rds function. Reference in IBS models docstring.

Parameters
  • x

  • y

  • z

Returns

rds

Radiation Damping

void printradint(double out[7])

Method to print out radiation integrals.

Parameters

out – Array output of Radation Damping Methods (Approx and Lattice)

double *RadiationDampingApprox(double latticeLength, double gamma, double gammaTransition, double dipoleBendingRadius, double betax, double betay)

Method for calculating approximate radiation integrals. The approximation is due to using ring averages for the bending radius and beta functions.

Note

Based on formulas in the Accelerator Handbook for Physicists and Engineers.

Parameters
  • latticeLength – Length of the accelerator lattice

  • gamma – Relativistic gamma

  • gammaTransition – Transition relativistic gamma

  • dipoleBendingRadius – Main dipole bending radius

  • betax – Ring averaged horizontal beta

  • betay – Ring averaged vertical beta

Returns

Approximate Radiation Damping integrals:

double *RadiationDampingLattice(map<string, vector<double>> &table)

Method for calculating element weighted radiation integrals. The integrals are calculated element by element and then weighted with the element’s length.

See

GetTwissTableAsMap

Note

Based on formulas in the Accelerator Handbook for Physicists and

Parameters

table – Twiss Table data in Map format.

Returns

Element weighted Radiation Damping integrals:

double *RadiationDampingLifeTimesAndEquilibriumEmittancesWithPartitionNumbers(map<string, double> &twissheadermap, double radiationIntegrals[7], double aatom, double qs)

Method that calculates the radiation damping times, the radiation partition numbers and radiation and quantum excitation equilibria for horizontal emittance, vertical emittance, energy spread squared and bunchlength.

See

RadiationDampingApprox, RadiationDampingLattice

Note

Based on formulas in the Accelerator Handbook for Physicists and

Parameters
  • twissheadermap – Twiss Header Map

  • radiationIntegrals – Output of the Radiation Damping Integrals Methods

  • aatom – Atomic Mass Number

  • qs – Synchrotron Tune

Returns

double RadiationLossesPerTurn(map<string, double> &twiss, double I2, double aatom)

Method to calculated the radiation losses per turn [eV].

Note

Based on formulas in the Accelerator Handbook for Physicists and

Parameters
  • twiss – Twiss Header Map

  • I2 – Second radiation integral

  • aatom – Atomic Mass Number

Returns

Radiation Losses per turn [eV]

double *RadiationCriticalEnergy(double rho, double gamma, double omega)

CALCULATE THE CRITICAL FREQUENCY AND ANGLE OF EMITTED RADIATION

Note

Based on Wolski Accelerator Lectures.

Parameters
  • rho – Average bending radius

  • gamma – Relativistic gamma

  • omega – Angular revolution frequency

Returns

Radiation data as an array containing 0 -> omega critical 1 -> theta critical 2 -> critical photon energy for given omega 3 -> average energy per photon 4 -> average number of photons emitted per turn

double *RadiationDampingElement(double l, double bx, double by, double dx, double dpx, double dy, double dpy, double ax, double ay, double angle, double k1l, double k1sl)

Method to calculate Radiation Damping integrals for single lattice element.

Note

Based on formulas in the Accelerator Handbook for Physicists and

Parameters
  • l – Length of the element

  • bx – Horizontal beta function at the element

  • by – Vertical beta function at the element

  • dx – Horizontal Dispersion at the element

  • dpx – Derivative of the horizontal dispersion at the element

  • dy – Vertical dispersion at the element

  • dpy – Derivative of the vertical dispersion at the element

  • ax – Horizontal alpha

  • ay – Vertical alpha

  • angle – Bending angle

  • k1l – Quadrupole component

  • k1sl – Skew quadrupole component

Returns

Radiation Damping integrals for single lattice element.

Coulomg Log

void twclog(double pnumber, double bx, double by, double dx, double dy, double ex, double ey, double r0, double gamma, double charge, double en0, double amass, double sige, double sigt, double *clog)

Method to calculate Coulomb Log and constant for single lattice element.

Note

Adapted from original code in MADX (copyright CERN). Based on the formulae in AIP physics vade mecum p.264 (1981).

Parameters
  • pnumber – Number of particles in the bunch

  • bx – Horizontal beta function

  • by – Vertical beta function

  • dx – Horizontal dispersion

  • dy – Vertical dispersion

  • ex – Horizontal emittance

  • ey – Vertical emittance

  • r0 – Classical radius of the particles in the bunch

  • gamma – Relativistic Gamma

  • charge – Particle electric charge

  • en0 – Energy of the particle

  • amass – Rest Energy of the partice [GeV]

  • sige – Energy spread

  • sigt – Bunch length

  • clog[out] Ouput array 0 -> Coulomb Log 1 -> IBS Coulomb pre-factor

void twclogtail(double pnumber, double l, double bx, double by, double dx, double dpx, double dy, double dpy, double ax, double ay, double angle, double k1l, double k1sl, double ex, double ey, double r0, double aatom, double gamma, double en0, double len, double amass, double charge, double sige, double sigt, double *clog)

Method to calculate Coulomb Log and constant for single lattice element with Tailcut (taking radiation damping into account).

Note

Based on the formulae in AIP physics vade mecum p.264 (1981).

Parameters
  • pnumber – Number of particles in the bunch

  • l – Element length

  • bx – Horizontal beta function

  • by – Vertical beta function

  • dx – Horizontal dispersion

  • dpx – Horizontal dispersion derivative

  • dy – Vertical dispersion

  • dpy – Vertical dispersion derivative

  • ax – Horizontal alpha

  • ay – Vertical alpha

  • angle – Bending angle

  • k1l – Quadrupole component

  • k1sl – Skew Quadrupole component

  • ex – Horizontal emittance

  • ey – Vertical emittance

  • r0 – Classical radius of the particles in the bunch

  • aatom – Atomic Mass Number

  • gamma – Relativistic Gamma

  • en0 – Energy of the particle

  • len – Accelerator length

  • amass – Rest Energy of the partice [GeV]

  • charge – Particle electric charge

  • sige – Energy spread

  • sigt – Bunch length

  • clog[out] Ouput array 0 -> Coulomb Log 1 -> IBS Coulomb pre-factor

void CoulombLog(double pnumber, double ex, double ey, map<string, double> &twissheader, double sige, double sigt, double r0, bool printout, double *clog)

Method to calculate Coulomb Log and constant using accelerator ring averages.

Note

Based on the formulae in AIP physics vade mecum p.264 (1981).

Parameters
  • pnumber – Number of particles in the bunch

  • ex – Horizontal emittance

  • ey – Vertical emittance

  • twissheader – Twiss Header Map

  • sige – Energy spread

  • sigt – Bunch length

  • r0 – Classical radius of the particles in the bunch

  • printout – Boolean flag to switch verbose mode on or off

  • clog[out] Ouput array 0 -> Coulomb Log 1 -> IBS Coulomb pre-factor

void TailCutCoulombLog(double pnumber, double ex, double ey, map<string, double> &twissheader, double sige, double sigt, double tauradx, double taurady, double taurads, double r0, bool printout, double *clog)

Method to calculate Coulomb Log and constant using accelerator ring averages with tailcut.

Note

Based on the formulae in AIP physics vade mecum p.264 (1981).

Parameters
  • pnumber – Number of particles in the bunch

  • ex – Horizontal emittance

  • ey – Vertical emittance

  • twissheader – Twiss Header Map

  • sige – Energy spread

  • sigt – Bunch length

  • tauradx – Horizontal Radiation Damping Time

  • taurady – Vertical Radiation Damping Time

  • taurads – Longitudinal Radiation Damping Time

  • r0 – Classical radius of the particles in the bunch

  • printout – Boolean flag to switch verbose mode on or off

  • clog[out] Ouput array 0 -> Coulomb Log 1 -> IBS Coulomb pre-factor

Integrals

void SimpsonDecade(double a, double b, double c, double cl, double cx, double cy, double cprime, double cyy, double tl1, double tl2, double tx1, double tx2, double ty1, double ty2, double *tau)

Simpson integrator with decade splitting.

Parameters
  • a – lambda**2 coefficient integral denominator

  • b – lambda coefficient integral denominator

  • c – constant integral denominator

  • cl – longitudinal growth time factor

  • cx – horizontal growth time factor

  • cy – vertical growht time factor

  • cprime – scaling factor

  • cyy – scaling factor adapted to sqrt denominator

  • tl1 – longitudinal lambda coefficient integral numerator

  • tl2 – longitudinal constant term integral numerator

  • tx1 – horizontal lambda coefficient integral numerator

  • tx2 – horizontal constant term integral numerator

  • ty1 – vertical lambda coefficient integral numerator

  • ty2 – vertical constant term integral numerator

  • tau[inout] outputArray 0 -> IBS amplitude growth rate longitudinal 1 -> IBS amplitude growth rate horizontal 2 -> IBS amplitude growth rate vertical

void twsint(double pnumber, double ex, double ey, double sigs, double sige, double gammas, double betax, double betay, double alx, double aly, double dx, double dpx, double dy, double dpy, double *tau)

Zimmerman IBS model growth rates adapted from MADX implementation.

Note

Based on implementation of twsint in MADX (copyright CERN) CERN NOTE CERN-AB-2006-002 EQ 8.

Parameters
  • pnumber – number of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • sige – energy spread dE/E

  • gammas – relativistic gamma

  • betax – horizontal beta function

  • betay – vertical beta function

  • alx – horizontal alpha

  • aly – vertical alpha

  • dx – horizontal dispersion

  • dpx – derivative horizontal dispersion

  • dy – vertical dispersion

  • dpy – derivative vertical dispersion

  • tau[inout] output Array 0 -> IBS longitudinal amplitude growth rate 1 -> IBS horizontal amplitude growth rate 2 -> IBS vertical amplitude growth rate

double IBSIntegralIntegrand(double lambda, double ax, double bx, double a, double b, double c)

The IBS integral integrand function.

Note

CERN NOTE CERN-AB-2006-002 EQ 8

Parameters
  • lambda – integration variable

  • ax – lambda coefficient integral numerator

  • bx – constant term integral numerator

  • a – lambda**2 coefficient integral denominator

  • b – lambda coefficient integral denominator

  • c – constant integral denominator

Returns

integrand value

double simpson(const std::function<double(double, double, double, double, double, double)> &ibsintegrand, double ax, double bx, double a, double b, double c, double al, double bl, int n)

Standard Simpson integration.

Parameters
  • ibsintegrand – IBS integrand as in CERN NOTE CERN-AB-2006-002 EQ 8

  • ax – lambda coefficient integral numerator

  • bx – constant term integral numerator

  • a – lambda**2 coefficient integral denominator

  • b – lambda coefficient integral denominator

  • c – constant integral denominator

  • al – lower integration boundary

  • bl – higher integration boundary

  • n – number of interval splits for the Simpson method

Returns

Simpson integral value

void intSimpson(const std::function<double(double, double, double, double, double, double)> &BjorkenMtingwaIntegrand, double ax, double bx, double ay, double by, double as, double bs, double a, double b, double ci, double *integral)

Standard Simpson integration.

Parameters
  • BjorkenMtingwaIntegrand – IBS Bjorken-Mtingwa integrand as in CERN NOTE CERN-AB-2006-002

  • ax – horizontal lambda coefficient integral numerator

  • bx – horizontal constant term integral numerator

  • ay – vertical lambda coefficient integral numerator

  • by – vertical constant term integral numerator

  • as – longitudinal lambda coefficient integral numerator

  • bs – longitudinal constant term integral numerator

  • a – lambda**2 coefficient integral denominator

  • b – lambda coefficient integral denominator

  • c – constant integral denominator

  • integral[inout] outputArray 0 -> IBS longitudinal amplitude growth rate 1 -> IBS horizontal amplitude growth rate 2 -> IBS vertical amplitude growth rate

void BjorkenMtingwaInt(double pnumber, double ex, double ey, double sigs, double sige, double gammas, double betx, double bety, double alx, double aly, double dx, double dpx, double dy, double dpy, double *tau)

BJorken-Mtingwa IBS model growth rates using Simpson Decade Integratino.

Note

CERN NOTE CERN-AB-2006-002 EQ 8.

Parameters
  • pnumber – number of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • sige – energy spread dE/E

  • gammas – relativistic gamma

  • betax – horizontal beta function

  • betay – vertical beta function

  • alx – horizontal alpha

  • aly – vertical alpha

  • dx – horizontal dispersion

  • dpx – derivative horizontal dispersion

  • dy – vertical dispersion

  • dpy – derivative vertical dispersion

  • tau[inout] output Array 0 -> IBS longitudinal amplitude growth rate 1 -> IBS horizontal amplitude growth rate 2 -> IBS vertical amplitude growth rate

void ConteMartiniInt(double pnumber, double ex, double ey, double sigs, double sige, double gammas, double betx, double bety, double alx, double aly, double dx, double dpx, double dy, double dpy, double *tau)

Conte-Martini IBS model growth rates using Simpson Decade Integratino.

Note

CERN NOTE CERN-AB-2006-002 EQ 8.

Parameters
  • pnumber – number of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • sige – energy spread dE/E

  • gammas – relativistic gamma

  • betax – horizontal beta function

  • betay – vertical beta function

  • alx – horizontal alpha

  • aly – vertical alpha

  • dx – horizontal dispersion

  • dpx – derivative horizontal dispersion

  • dy – vertical dispersion

  • dpy – derivative vertical dispersion

  • tau[inout] output Array 0 -> IBS longitudinal amplitude growth rate 1 -> IBS horizontal amplitude growth rate 2 -> IBS vertical amplitude growth rate

void MadxInt(double pnumber, double ex, double ey, double sigs, double sige, double gammas, double betx, double bety, double alx, double aly, double dx, double dpx, double dy, double dpy, double *tau)

Zimmerman IBS model growth rates using Simpson Decade Integration.

Note

CERN NOTE CERN-AB-2006-002 EQ 8.

Parameters
  • pnumber – number of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • sige – energy spread dE/E

  • gammas – relativistic gamma

  • betax – horizontal beta function

  • betay – vertical beta function

  • alx – horizontal alpha

  • aly – vertical alpha

  • dx – horizontal dispersion

  • dpx – derivative horizontal dispersion

  • dy – vertical dispersion

  • dpy – derivative vertical dispersion

  • tau[inout] output Array 0 -> IBS longitudinal amplitude growth rate 1 -> IBS horizontal amplitude growth rate 2 -> IBS vertical amplitude growth rate

IBS Models

void printouts(double output[3])

Method that prints out IBS growth rates and times from given input array.

Parameters

output – IBS growth rates array.

double *PiwinskiSmooth(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twiss, double r0)

Piwinski smooth approximation model.

Note

HANDBOOK FOR ACCELERATOR PHYSICISTS AND ENGINEERS P.126..

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twiss – Twiss Header Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *PiwinskiLattice(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0)

Piwinski approximation element weighted.

Note

HANDBOOK FOR ACCELERATOR PHYSICISTS AND ENGINEERS P.126..

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *PiwinskiLatticeModified(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0)

Piwinski approximation element weighted taking also dispersion derivatives into account.

Note

HANDBOOK FOR ACCELERATOR PHYSICISTS AND ENGINEERS P.126..

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *Nagaitsev(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0)

Nagaitsev’s high energy approximation element weighted with Coulomb logs calculated element by element.

Note

PRSTAB 8, 064403 (2005

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *Nagaitsevtailcut(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0, double aatom)

Nagaitsev’s high energy approximation element weighted with Coulomb logs calculated element by element and taking tailcut into account.

Note

PRSTAB 8, 064403 (2005)

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

  • aatom – Atomic Mass Number

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *ibsmadx(double pnumber, double ex, double ey, double sigs, double sige, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0, bool printout)

Zimmerman model element weighted with Coulomb logs calculated element by element using scaled Simpson Decade.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • sige

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

  • printout – Boolean flag to switch verbose mode on.

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *ibsmadxtailcut(double pnumber, double ex, double ey, double sigs, double sige, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0, double aatom)

Zimmerman model element weighted with Coulomb logs calculated element by element taking tailcut into account using scaled Simpson Decade.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • sige

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

  • aatom – Atomic Mass Number

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *BjorkenMtingwa2(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0)

Bjorken-Mtingwa model element weighted with Coulomb logs calculated element by element using standard Simpson integration.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • sige

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *BjorkenMtingwa(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0)

Bjorken-Mtingwa model element weighted with Coulomb logs calculated element by element using Simpson Decade integration.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *BjorkenMtingwatailcut(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0, double aatom)

Bjorken-Mtingwa model element weighted with Coulomb logs calculated element by element taking tailcut into account using Simpson Decade integration.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

  • aatom – Atomic Mass Number

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *ConteMartini(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0)

Conte-Martini model element weighted with Coulomb logs calculated element by element using Simpson Decade integration.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *ConteMartinitailcut(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0, double aatom)

Conte-Martini model element weighted with Coulomb logs calculated element by element taking tailcut into account using Simpson Decade integration.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

  • aatom – Atomic Mass Number

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

double *MadxIBS(double pnumber, double ex, double ey, double sigs, double dponp, map<string, double> &twissheader, map<string, vector<double>> &twissdata, double r0)

Zimmerman model element weighted with Coulomb logs calculated element by element using Simpson Decade integration.

Note

CERN NOTE AB-2006002

Parameters
  • pnumber – numper of real particles in the bunch

  • ex – horizontal emittance

  • ey – vertical emittance

  • sigs – bunch length

  • dponp

  • twissheader – Twiss Header Map

  • twissdata – Twiss Table Map

  • r0 – Classical particle radius

Returns

IBS amplitude growth rates (longitudinal, horizontal, vertical)

ODE simulation

void WriteToFile(string filename, vector<double> &t, vector<double> &ex, vector<double> &ey, vector<double> &sigs)

Method to write simulation output to file.

Parameters
  • filename – name of the file to write to

  • t – timesteps

  • ex – horizontal emit steps

  • ey – vertical emit steps

  • sigs – bunch length steps

void ODE(map<string, double> &twiss, map<string, vector<double>> &twissdata, int nrf, double harmon[], double voltages[], vector<double> &t, vector<double> &ex, vector<double> &ey, vector<double> &sigs, vector<double> sige, int model, double pnumber, int couplingpercentage, double threshold, string method)

Run ODE simulation using auto time step.

Note

: Relaxation method based on implementation in BMAD

Parameters
  • twiss – Twiss Header Map

  • twissdata – Twiss Table Map

  • nrf – number of rf systems

  • harmon – list of harmonic numbers for the rf systems

  • voltages – list of voltages for the rf systems

  • t[inout] timesteps

  • ex[inout] horizontal emittance

  • ey[inout] vertical emittance

  • sigs[inout] bunch length

  • sige[inout] energy spread

  • model – IBS model (1-13)

  • pnumber – number of particles per bunch

  • couplingpercentage – hor/ver coupling in percentage

  • threshold – evolution stop threshold

  • method – simulation method (rlx or der)

void ODE(map<string, double> &twiss, map<string, vector<double>> &twissdata, int nrf, double harmon[], double voltages[], vector<double> &t, vector<double> &ex, vector<double> &ey, vector<double> &sigs, vector<double> sige, int model, double pnumber, int nsteps, double stepsize, int couplingpercentage, string method)

Run ODE simulation using auto time step.

Parameters
  • twiss – Twiss Header Map

  • twissdata – Twiss Table Map

  • nrf – number of rf systems

  • harmon – list of harmonic numbers for the rf systems

  • voltages – list of voltages for the rf systems

  • t[inout] timesteps

  • ex[inout] horizontal emittance

  • ey[inout] vertical emittance

  • sigs[inout] bunch length

  • sige[inout] energy spread

  • model – IBS model (1-13)

  • pnumber – number of particles per bunch

  • nsteps – number of simulation steps

  • stepsize – time step size

  • couplingpercentage – hor/ver coupling in percentage

  • method – simulation method (rlx or der)