IBS - Intra Beam Scattering

Documentation Status https://mybinder.org/badge_logo.svg

C++ Library with PYBIND11 Python wrapper for IBS calculations, including an ODE model simulation.

Tutorial on Binder

Visit the link below for a live jupyter notebook with the turorial.

https://mybinder.org/v2/gh/tomerten/ibs/main?filepath=IBS%2Fdocs%2Fnotebooks%2FTutorial.ipynb

Requirements

For the installation:

  • CMake >= 3.10.2

  • GCC compiler

  • Python >= 3.7.1

  • Git - for the submodules

For the docs (see docs/requirements.txt - except doxygen):

  • doxygen

  • breathe

  • sphinx-click

  • click

  • cookiecutter

  • semantic-version

  • matplotlib

  • ipython

  • nbsphinx

  • ipykernel

  • pandoc

Quick start

If you do not want to go through the trouble of installing everything on your local system, you can also use either Docker or Singularity containers.

$ git clone https://github.com/tomerten/IBS.git
$ cd IBS
$ docker build -t ibslib:latest .
$ sudo singularity build ibslib.sim ibslib.sdef

For quick access to the runode simulations (make sure input file and Twiss file are in the run directory):

$ ./ibslib.sim JSON_SIM_INPUT_FILE

For using docker have a look at the docker documentation on how to mount folders for using files from your local system. One interesting feature is running jupyter from within the container, giving you direct access to the tutorial notebook.

$ docker run -it --user 1000 -v DIR_TO_MOUNT:/home -p 8889:8888 ibslib:latest jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

After this, open a browser and go to localhost:8889, copy the token from the terminal window and you are good to go. For the turorial navigate to IBS/docs/notebooks/Tutorial.ipynb. In the above case files from the DIR_TO_MOUNT directory will be in the home directory in the container. If you create a notebook and save it there it will also appear on your local (host) system.

Source Installation

The sources for ibs can be downloaded from the Github repo.

We recommend to install everything in a dedicated Conda environment.

$ conda create python=3.8 --name=ibslibenv
$ conda activate ibslibenv
$ conda install pip
$ pip install poetry

Clone the public repository and run the build_all.sh script:

$ git clone git://github.com/tomerten/ibs
$ cd ibs
$ bash build_all.sh

For more details see the installation guidelines on Installation documentation.

Build Docs

Building of the documentation is based on this article making use of Cmake, Doxygen, Breathe and Sphinx. It can be build locally by the following command:

$ bash build_docs.sh

Note

Make sure you have Doxygen and Pandoc installed.

To install Doxygen in a Conda environment:

$ conda install -c conda-forge doxygen

Features

  • Read MADX Twiss module

  • Numeric Functions Lib necessary for the IBS calculations, including necessary constants.

  • Coulomb Log module

  • Radiation Damping module

  • Integration methods module (Simpson, Simpson Decade, Simpson Decade with scaling)

  • IBS models

  • ODE simulation module with CLI interface

Current Supported Models

  • Piwinski smooth lattice approximation

  • Piwinski Lattice element by element weighted

  • Piwinski Lattice Modified taking some vertical effects into account

  • Nagaitsev’s high-energy approximation (standard Coulomb Log and with Tailcut)

  • Bjorken-Mtingwa (standard Coulomb Log and with Tailcut)

  • Conte-Martini (standard Coulomb Log and with Tailcut)

  • Zimmerman (Madx - CERN note AB-2006-002) using TWINT and SIMPSONDECADE methods to perform the integration (standard Coulomb Log and with Tailcut).

Coublomb Log methods

  • twclog - uses element by element twiss data

  • twclogtail - uses element by element twiss data

  • CoublombLog - uses ring averages

  • TailCutCoulombLog - uses ring averages

Integration methods

  • Simpson (standard implementation)

  • SimpsonDecade - Simspon per decade for covering large spread in integration ranges (ususally 50 orders of magnitude difference between low and high)

  • TWINT, SimsponDecade with scaling method

Radiation Damping

  • Radiation Damping using smooth lattice approximation

  • Radiation Damping element by element

  • Equilibrium from pure radiation damping and exitation (taux, tauy, taus, exinf, eyinf, sigeoe2, sigsinf, jx, jy)

  • Radiation losses per turn

  • Critical omega, theta, photon energy

Numeric Functions

  • Method to calculate standard accelerator quantities.

  • Various methods related to RF calculations to derive longitudinal quantities necessary for the IBS algorithms.

  • Numeric functions used by specific IBS models (fmohl, rds).

ODE

The tables below show examples of the output of the ODE method, applied to the BESSY II design lattice. For the examples below the stability threshold set to 1e-3 written to a csv file.

ODE Model using Piwinski Smooth

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70356e-09

5.00852e-10

0.00306037

0.00399018

6.30713e-09

2.50877e-10

0.00307313

0.00598527

6.11027e-09

1.25688e-10

0.00308823

0.00798035

6.01344e-09

6.29943e-11

0.00310801

0.00997544

5.96714e-09

3.15986e-11

0.00313478

0.0119705

5.94682e-09

1.5878e-11

0.00317109

0.0139656

5.94045e-09

8.00908e-12

0.0032197

0.0159607

5.94228e-09

4.07412e-12

0.00328328

0.0179558

5.94964e-09

2.1118e-12

0.00336386

0.0199509

5.96124e-09

1.14043e-12

0.00346161

0.021946

5.97612e-09

6.68309e-13

0.00357279

0.0239411

5.99276e-09

4.47683e-13

0.00368685

0.0259362

6.00853e-09

3.51024e-13

0.00378611

0.0279312

6.02077e-09

3.11398e-13

0.00385566

0.0299263

6.0287e-09

2.9561e-13

0.00389519

0.0319214

6.03326e-09

2.89252e-13

0.00391462

0.0339165

6.03572e-09

2.86635e-13

0.00392341

0.0359116

6.037e-09

2.85538e-13

0.00392724

0.0379067

6.03766e-09

2.85073e-13

0.00392886

0.0399018

6.038e-09

2.84875e-13

0.00392955


ODE Model using Piwinski Lattice

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70593e-09

5.00852e-10

0.00305871

0.00399018

6.31454e-09

2.50877e-10

0.00306793

0.00598527

6.12357e-09

1.25689e-10

0.00307902

0.00798035

6.0344e-09

6.29949e-11

0.00309374

0.00997544

5.99846e-09

3.15995e-11

0.0031139

0.0119705

5.99228e-09

1.58796e-11

0.00314152

0.0139656

6.00505e-09

8.01161e-12

0.00317883

0.0159607

6.03224e-09

4.0781e-12

0.00322806

0.0179558

6.0723e-09

2.11785e-12

0.00329096

0.0199509

6.12447e-09

1.1492e-12

0.00336782

0.021946

6.18669e-09

6.80275e-13

0.00345562

0.0239411

6.2531e-09

4.62741e-13

0.00354548

0.0259362

6.31324e-09

3.6824e-13

0.00362286

0.0279312

6.35764e-09

3.29534e-13

0.00367636

0.0299263

6.38497e-09

3.13888e-13

0.00370659

0.0319214

6.39998e-09

3.07412e-13

0.00372152

0.0339165

6.40776e-09

3.04652e-13

0.00372837

0.0359116

6.4117e-09

3.03451e-13

0.0037314

0.0379067

6.41367e-09

3.02922e-13

0.00373271

0.0399018

6.41466e-09

3.02687e-13

0.00373328


ODE Model using Piwinski Lattice Modified

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70588e-09

5.00852e-10

0.00305869

0.00399018

6.31437e-09

2.50877e-10

0.00306787

0.00598527

6.12325e-09

1.25689e-10

0.00307891

0.00798035

6.03389e-09

6.29948e-11

0.00309357

0.00997544

5.99771e-09

3.15994e-11

0.00311366

0.0119705

5.99121e-09

1.58794e-11

0.00314119

0.0139656

6.00354e-09

8.01139e-12

0.00317838

0.0159607

6.03017e-09

4.07776e-12

0.00322746

0.0179558

6.06954e-09

2.11736e-12

0.00329021

0.0199509

6.12085e-09

1.14849e-12

0.00336691

0.021946

6.18207e-09

6.79323e-13

0.00345459

0.0239411

6.24746e-09

4.61536e-13

0.00354443

0.0259362

6.30673e-09

3.6684e-13

0.00362195

0.0279312

6.35053e-09

3.28024e-13

0.00367567

0.0299263

6.37751e-09

3.12331e-13

0.00370609

0.0319214

6.39232e-09

3.05837e-13

0.00372114

0.0339165

6.4e-09

3.0307e-13

0.00372806

0.0359116

6.40388e-09

3.01867e-13

0.00373112

0.0379067

6.40583e-09

3.01337e-13

0.00373245

0.0399018

6.4068e-09

3.01101e-13

0.00373302


ODE Model using Nagaitsev

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70641e-09

5.00852e-10

0.00305891

0.00399018

6.31624e-09

2.50877e-10

0.00306886

0.00598527

6.12706e-09

1.25688e-10

0.00308136

0.00798035

6.04081e-09

6.29944e-11

0.00309872

0.00997544

6.00958e-09

3.1599e-11

0.0031235

0.0119705

6.01075e-09

1.58793e-11

0.00315867

0.0139656

6.03454e-09

8.01214e-12

0.00320763

0.0159607

6.07752e-09

4.08044e-12

0.00327364

0.0179558

6.13893e-09

2.12371e-12

0.00335865

0.0199509

6.21798e-09

1.1611e-12

0.00346214

0.021946

6.31056e-09

7.01185e-13

0.00357776

0.0239411

6.40554e-09

4.94521e-13

0.00369019

0.0259362

6.48563e-09

4.0963e-13

0.00377859

0.0279312

6.53939e-09

3.76947e-13

0.00383246

0.0299263

6.56968e-09

3.64316e-13

0.0038591

0.0319214

6.58529e-09

3.59257e-13

0.00387079

0.0339165

6.59307e-09

3.57173e-13

0.00387563

0.0359116

6.59691e-09

3.56298e-13

0.00387758

0.0379067

6.59881e-09

3.55927e-13

0.00387836

0.0399018

6.59975e-09

3.55768e-13

0.00387866


ODE Model using Nagaitsev Tailcut

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70613e-09

5.00852e-10

0.00305875

0.00399018

6.31537e-09

2.50876e-10

0.00306835

0.00598527

6.12549e-09

1.25688e-10

0.00308044

0.00798035

6.03829e-09

6.2994e-11

0.00309726

0.00997544

6.00576e-09

3.15983e-11

0.00312131

0.0119705

6.00513e-09

1.58782e-11

0.00315551

0.0139656

6.02644e-09

8.01037e-12

0.00320322

0.0159607

6.06614e-09

4.07767e-12

0.00326771

0.0179558

6.12336e-09

2.11949e-12

0.00335101

0.0199509

6.19741e-09

1.1549e-12

0.00345287

0.021946

6.28466e-09

6.92582e-13

0.00356743

0.0239411

6.37503e-09

4.83552e-13

0.00368009

0.0259362

6.45235e-09

3.9702e-13

0.00377019

0.0279312

6.50506e-09

3.63579e-13

0.00382615

0.0299263

6.53506e-09

3.50678e-13

0.00385424

0.0319214

6.5506e-09

3.45531e-13

0.00386668

0.0339165

6.55836e-09

3.43416e-13

0.00387186

0.0359116

6.56219e-09

3.42531e-13

0.00387396

0.0379067

6.56408e-09

3.42156e-13

0.00387479

0.0399018

6.56501e-09

3.41996e-13

0.00387512


ODE Model using MADX (Zimmerman)

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70657e-09

5.00852e-10

0.00305911

0.00399018

6.31677e-09

2.50877e-10

0.00306952

0.00598527

6.12803e-09

1.25688e-10

0.0030826

0.00798035

6.04237e-09

6.29945e-11

0.00310076

0.00997544

6.01196e-09

3.15993e-11

0.00312663

0.0119705

6.01428e-09

1.58798e-11

0.00316332

0.0139656

6.03962e-09

8.01294e-12

0.0032143

0.0159607

6.08462e-09

4.08176e-12

0.00328288

0.0179558

6.14851e-09

2.12579e-12

0.0033709

0.0199509

6.23042e-09

1.1642e-12

0.00347762

0.021946

6.32588e-09

7.05538e-13

0.00359615

0.0239411

6.42315e-09

5.00076e-13

0.00371046

0.0259362

6.50441e-09

4.15992e-13

0.00379932

0.0279312

6.55845e-09

3.83673e-13

0.00385278

0.0299263

6.5887e-09

3.71172e-13

0.00387893

0.0319214

6.60425e-09

3.66163e-13

0.00389032

0.0339165

6.61199e-09

3.64099e-13

0.00389501

0.0359116

6.61582e-09

3.63234e-13

0.00389689

0.0379067

6.61771e-09

3.62867e-13

0.00389763

0.0399018

6.61864e-09

3.6271e-13

0.00389792


ODE Model using MADX (Zimmerman) with Tailcut

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70628e-09

5.00852e-10

0.00305895

0.00399018

6.31586e-09

2.50876e-10

0.00306899

0.00598527

6.12638e-09

1.25688e-10

0.00308164

0.00798035

6.03973e-09

6.29941e-11

0.00309923

0.00997544

6.00797e-09

3.15986e-11

0.00312435

0.0119705

6.0084e-09

1.58786e-11

0.00316003

0.0139656

6.03117e-09

8.01109e-12

0.00320972

0.0159607

6.07275e-09

4.07887e-12

0.00327673

0.0179558

6.13232e-09

2.12139e-12

0.00336302

0.0199509

6.20908e-09

1.15776e-12

0.0034681

0.021946

6.29909e-09

6.96623e-13

0.00358562

0.0239411

6.3917e-09

4.88756e-13

0.00370027

0.0259362

6.47022e-09

4.03034e-13

0.00379093

0.0279312

6.52325e-09

3.6997e-13

0.00384653

0.0299263

6.55323e-09

3.57209e-13

0.00387414

0.0319214

6.56871e-09

3.52114e-13

0.00388627

0.0339165

6.57643e-09

3.50021e-13

0.00389129

0.0359116

6.58025e-09

3.49146e-13

0.00389331

0.0379067

6.58213e-09

3.48776e-13

0.00389411

0.0399018

6.58306e-09

3.48618e-13

0.00389442


ODE Model using Bjorken-Mtingwa with standard Simpson integration (Fails for ey)

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70592e-09

5.00852e-10

0.00305914

0.00399018

6.31442e-09

2.50877e-10

0.00306961

0.00598527

6.12324e-09

1.25688e-10

0.00308278

0.00798035

6.03382e-09

6.29945e-11

0.00310109

0.00997544

5.99757e-09

3.15992e-11

0.00312728

0.0119705

5.99094e-09

1.58797e-11

0.0031646

0.0139656

6.0029e-09

8.0127e-12

0.00321691

0.0159607

6.02849e-09

4.08115e-12

0.00328826

0.0179558

6.06533e-09

2.12435e-12

0.00338183

0.0199509

6.11143e-09

1.1612e-12

0.0034988

0.021946

6.16299e-09

6.99951e-13

0.00363414

0.0239411

6.21264e-09

4.9115e-13

0.00377133

0.0259362

6.25081e-09

4.03944e-13

0.00388415

0.0279312

6.27298e-09

3.69532e-13

0.00395635

0.0299263

6.28294e-09

3.55913e-13

0.00399412

0.0319214

6.28657e-09

3.50372e-13

0.00401181

0.0339165

6.2876e-09

3.48075e-13

0.00401971

0.0359116

6.28774e-09

3.47115e-13

0.00402317

0.0379067

6.28764e-09

3.46713e-13

0.00402467

0.0399018

6.28751e-09

3.46545e-13

0.00402533


ODE Model using Bjorken-Mtingwa with Simpson Decade Integration

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70657e-09

5.00852e-10

0.00305912

0.00399018

6.31678e-09

2.50877e-10

0.00306953

0.00598527

6.12806e-09

1.25688e-10

0.00308264

0.00798035

6.04244e-09

6.29945e-11

0.00310084

0.00997544

6.01215e-09

3.15992e-11

0.00312686

0.0119705

6.01475e-09

1.58796e-11

0.00316391

0.0139656

6.04077e-09

8.01257e-12

0.00321576

0.0159607

6.08732e-09

4.0809e-12

0.00328631

0.0179558

6.15455e-09

2.12387e-12

0.0033785

0.0199509

6.24298e-09

1.16027e-12

0.0034932

0.021946

6.34966e-09

6.98237e-13

0.00362507

0.0239411

6.46289e-09

4.88268e-13

0.00375769

0.0259362

6.56178e-09

3.99703e-13

0.00386577

0.0279312

6.63052e-09

3.64084e-13

0.00393418

0.0299263

6.67058e-09

3.49592e-13

0.00396944

0.0319214

6.69192e-09

3.43491e-13

0.00398563

0.0339165

6.70288e-09

3.40857e-13

0.00399267

0.0359116

6.70844e-09

3.39703e-13

0.00399566

0.0379067

6.71124e-09

3.39193e-13

0.00399692

0.0399018

6.71266e-09

3.38965e-13

0.00399743


ODE Model using Bjorken-Mtingwa with Simpson Decade Integration and Tailcut

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70628e-09

5.00852e-10

0.00305895

0.00399018

6.31587e-09

2.50876e-10

0.003069

0.00598527

6.12641e-09

1.25688e-10

0.00308167

0.00798035

6.0398e-09

6.29941e-11

0.00309931

0.00997544

6.00815e-09

3.15985e-11

0.00312457

0.0119705

6.00884e-09

1.58785e-11

0.00316059

0.0139656

6.03223e-09

8.01076e-12

0.0032111

0.0159607

6.07526e-09

4.07808e-12

0.00328

0.0179558

6.13793e-09

2.11964e-12

0.0033703

0.0199509

6.22079e-09

1.15415e-12

0.00348311

0.021946

6.32136e-09

6.89875e-13

0.00361367

0.0239411

6.42918e-09

4.77746e-13

0.00374647

0.0259362

6.52476e-09

3.87693e-13

0.00385656

0.0279312

6.59225e-09

3.5138e-13

0.00392758

0.0299263

6.63201e-09

3.36635e-13

0.00396471

0.0319214

6.65329e-09

3.30447e-13

0.00398191

0.0339165

6.66423e-09

3.27782e-13

0.00398943

0.0359116

6.66978e-09

3.26617e-13

0.00399264

0.0379067

6.67258e-09

3.26103e-13

0.00399398

0.0399018

6.674e-09

3.25874e-13

0.00399454


ODE Model using Conte-Martini using Simspon Decade Integration

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70657e-09

5.00852e-10

0.00305911

0.00399018

6.31677e-09

2.50877e-10

0.00306952

0.00598527

6.12803e-09

1.25688e-10

0.0030826

0.00798035

6.04237e-09

6.29945e-11

0.00310076

0.00997544

6.01196e-09

3.15993e-11

0.00312663

0.0119705

6.01428e-09

1.58798e-11

0.00316332

0.0139656

6.03962e-09

8.01294e-12

0.0032143

0.0159607

6.08462e-09

4.08176e-12

0.00328288

0.0179558

6.14851e-09

2.12579e-12

0.0033709

0.0199509

6.23042e-09

1.1642e-12

0.00347762

0.021946

6.32588e-09

7.05538e-13

0.00359615

0.0239411

6.42315e-09

5.00076e-13

0.00371046

0.0259362

6.50441e-09

4.15992e-13

0.00379932

0.0279312

6.55845e-09

3.83673e-13

0.00385278

0.0299263

6.5887e-09

3.71172e-13

0.00387893

0.0319214

6.60425e-09

3.66163e-13

0.00389032

0.0339165

6.61199e-09

3.64099e-13

0.00389501

0.0359116

6.61582e-09

3.63234e-13

0.00389689

0.0379067

6.61771e-09

3.62867e-13

0.00389763

0.0399018

6.61864e-09

3.6271e-13

0.00389792


ODE Model using Conte-Martini using Simspon Decade Integration and Tailcut

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70628e-09

5.00852e-10

0.00305895

0.00399018

6.31586e-09

2.50876e-10

0.00306899

0.00598527

6.12638e-09

1.25688e-10

0.00308164

0.00798035

6.03973e-09

6.29941e-11

0.00309923

0.00997544

6.00797e-09

3.15986e-11

0.00312435

0.0119705

6.0084e-09

1.58786e-11

0.00316003

0.0139656

6.03117e-09

8.01109e-12

0.00320972

0.0159607

6.07275e-09

4.07887e-12

0.00327673

0.0179558

6.13232e-09

2.12139e-12

0.00336302

0.0199509

6.20908e-09

1.15776e-12

0.0034681

0.021946

6.29909e-09

6.96623e-13

0.00358562

0.0239411

6.3917e-09

4.88756e-13

0.00370027

0.0259362

6.47022e-09

4.03034e-13

0.00379093

0.0279312

6.52325e-09

3.6997e-13

0.00384653

0.0299263

6.55323e-09

3.57209e-13

0.00387414

0.0319214

6.56871e-09

3.52114e-13

0.00388627

0.0339165

6.57643e-09

3.50021e-13

0.00389129

0.0359116

6.58025e-09

3.49146e-13

0.00389331

0.0379067

6.58213e-09

3.48776e-13

0.00389411

0.0399018

6.58306e-09

3.48618e-13

0.00389442


ODE Model using MADX (Zimmerman) using Simpson Decade Integration

t

ex

ey

sigs

0

7.5e-09

1e-09

0.005

0.00199509

6.70657e-09

5.00852e-10

0.00305911

0.00399018

6.31677e-09

2.50877e-10

0.00306952

0.00598527

6.12804e-09

1.25688e-10

0.0030826

0.00798035

6.04239e-09

6.29943e-11

0.00310076

0.00997544

6.01202e-09

3.15989e-11

0.00312663

0.0119705

6.01442e-09

1.58793e-11

0.00316332

0.0139656

6.03997e-09

8.01225e-12

0.0032143

0.0159607

6.0855e-09

4.08087e-12

0.00328288

0.0179558

6.15061e-09

2.12468e-12

0.00337091

0.0199509

6.23507e-09

1.16289e-12

0.00347762

0.021946

6.33522e-09

7.04072e-13

0.00359614

0.0239411

6.43947e-09

4.98527e-13

0.0037104

0.0259362

6.52853e-09

4.14409e-13

0.00379909

0.0279312

6.58901e-09

3.8205e-13

0.00385226

0.0299263

6.62354e-09

3.69501e-13

0.00387811

0.0319214

6.64163e-09

3.64449e-13

0.00388928

0.0339165

6.65081e-09

3.62355e-13

0.00389383

0.0359116

6.65542e-09

3.61471e-13

0.00389562

0.0379067

6.65773e-09

3.61093e-13

0.00389632

0.0399018

6.65889e-09

3.60929e-13

0.00389658