ORBIT Code Review and Future Directions -...

19
ORBIT Code Review and Future Directions S. Cousineau, A. Shishlo, J. Holmes ECloud07

Transcript of ORBIT Code Review and Future Directions -...

Page 1: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

ORBIT Code Review and Future Directions

S. Cousineau, A. Shishlo, J. Holmes

ECloud07

Page 2: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

ORBIT Code

ORBIT (Objective Ring Beam Injection and Transport code)

• ORBIT is an object-oriented, open-source code started at SNS for simulating high intensity rings.

• ORBIT is a particle tracking code − Macro-particles in 6D phase space− It uses s, not t, as its independent variable.− Uses PIC for collective effects simulations− Accelerator lattice is a set of Nodes

• Its purpose is the design and analysis of high intensity rings. We also use it on beam lines when appropriate.

• ORBIT incorporates a sizeable collection of physics, engineering, and diagnostic models.

• The emphasis in developing ORBIT has always been the incorporation of models that allow application to realistic accelerator problems.

Page 3: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

• Year 1997 - first files created by John Galambos

• Year 1999 - cvs repository was created. Other developers started joining the team.

• Years 1999 – 2006 - active development of collective interaction, collimation, and one-particle dynamic modules, parallel computing based on MPI.

History of ORBIT Development

The base structure of ORBIT is unchanged. Due to this structure developers are able to work practically independently. The parallel capabilities were present from the beginning, but the code was moved from PVM (outdated now) to MPI (latest widely accepted technology).

Page 4: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

ORBIT Programming Structure

SuperCode (SC)Script interpreter + Wrapper files generator

Language: C++Includes: Collection of utility C++ classes

SC ExtensionsInterfaces to C++ classes

(Wrappers Generated by SC)

ORBIT C++ Classes(physics)

ORBIT

External Libraries (FFT, MPI, PTC etc.)

ORBIT is a script interpreter of the extended SuperCode programlanguage. The ORBIT program is a script to be interpreted.

• Programming language for free• No need to compile• Flexible, scripts are easy to create• Can be extended further

Page 5: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Typical simulation with ORBIT

Electron Cloud Node

Transport Map Node

RF Cavity

Injection Point

Typical Simulation at SNS may include: drifts, dipoles, and quadrupoles (transport map)rf-buncher nodeinjection nodelongitudinal space charge node transverse space charge nodes (one per lattice element)one or few Electron Cloud Nodes (ECNs)aperture nodesetc….

In ORBIT, macroparticles are transported through a series of “Nodes” which execute physical operations on the beam.

The user decides which particular physical operations are important for their simulations, and adds the appropriate nodes.

Page 6: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

ORBIT: Inventory of Models

• ORBIT is designed to simulate real machines: it has detailed models for

– Injection foil and painting (Galambos, Holmes, Cousineau, Coupland).– Single particle transport through various types of lattice elements

(Holmes, Galambos, Abrams, Michelotti, Forest, Shishlo).– Magnet Errors, Closed Orbit Calculation, Orbit Correction (Holmes,

Bunch).– RF and acceleration (Galambos, Holmes).– Longitudinal impedance and 1D longitudinal space charge

(Galambos, Beebe-Wang, Luccio).– Transverse impedance (Danilov, Shishlo).– 2.5D transverse space charge with or without conducting wall beam

pipe (Holmes, Galambos)– 3D space charge (Danilov, Holmes)– Feedback for Stabilization (Danilov)– Apertures and collimation (Cousineau, Catalan-Lasheras)– Electron Cloud Model (Shishlo, Sato, Danilov, Holmes)– Tracking in 3D Magnetic Fields (Holmes, Perkett)

Page 7: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Longitudinal Space Charge and Impedances (1)

• ORBIT longitudinal impedances and/or space charge module inherits from ESME code (J. A. MacLachlan, FNAL)− Impedances are represented as longitudinal kicks at localized

nodes− Longitudinal space charge forces are combined with impedances

by using FFT methods and convolution with the beam current harmonics

• Longitudinal Space Charge and Impedance Module has been successfully benchmarked against− analytic Vlasov model calculations of instability thresholds− results of ESME code− experimental data from the Los Alamos Proton Storage Ring

(PSR) showing longitudinal microwave instability− experimental data from the Los Alamos Proton Storage Ring

(PSR) showing long-lived linac micro-bunch structure during beam storage with no rf bunching (S. Cousineau,V. Danilov, and J. Holmes, R. Macek, Phys. Rev. ST Accel. Beams 7, 094201 (2004). )

Page 8: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Longitudinal Space Charge and Impedances (2)S. Cousineau,V. Danilov, and J. Holmes, R. Macek, Space-charge-sustained micro-bunch structure in the Los Alamos Proton Storage RingPhys. Rev. ST Accel. Beams 7, 094201 (2004).

Experimental DataWaterfall plot of the wall current monitor signal for the chopped beam experiment. The beam gap region is displayed in blue. Beam injection ends at 559 turns. The high frequency variations in color indicate the micro-bunch structure of the beam

ORBIT Simulation

Left: with Longitudinal SC

Right: without

Page 9: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

2.5D Space Charge Module Algorithm

′′∝ ⊥⊥

⊥⊥⊥⊥ ∫ rd

ΔrrΔ)rρ()r(F 2

rr

rrr

⊥⊥ ∑ λλ∝ FF

j

ii,

rr

∫ ⋅β>≈<=Δ ⊥⊥ L c

LFdt)r(Fprrrr

The 2.5D space charge model:• It is implemented as a series of transverse momentum kicks between the lattice elements. • Particles are binned in a 2D rectangular grid. • The potential is solved using a fast FFT solver. • The transverse momentum kicks are weighted by the local longitudinal density.• Conducting wall (circular, elliptical, or rectangular beam pipe) boundary conditions can be used.• There is also an alternative direct force solver without beam pipe.

We call this model 2.5D.

Page 10: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

2.5D Space Charge Module Benchmark

This module has been successfully used to explain the beam transverse distribution in the PSR ring:

• Transverse beam profiles are observed to broaden with increasing intensity in the PSR.

• Inclusion of space charge effects improves the agreement between the experimentally observed profiles and the calculated profiles.

• The comparisons are made for a range of injected intensities.

The effect of the space charge on the calculated beam profiles, for the case with no closed orbit bumps during injection and at the highest intensity.

Page 11: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

3D Space Charge Module Algorithm

2D SC problem with the boundary condition

The boundary at the fixed potential

• The 3D space charge model is a simple generalization of the 2.5Droutine. Particles are distributed to a 3D rectangular grid using a second order scheme. Grid slices “feel” the nearest neighbors only.

• Simulations with this module require a multiple CPU computer or parallel cluster, because the numbers of particles and grid points are proportional to the number of transverse slices in the 3D grid.

• For SNS, the difference in results between 2.5D and 3D are small. Most of the time we use 2.5D.

Page 12: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

ORBIT: Electron Cloud ModuleORBIT Code Super Code Interface Modules

Original ORBIT ECloud.cc

Original ORBIT C++ Classes

EP_Node.cc EP_NodeCalculator.cc

E-Cloud Module: Independent C++ Classes

- ORBIT Electron Cloud Module

Electron Cloud Module has a weak link to ORBIT.It can be used outside ORBIT.

Electron Cloud Module:Electron cloud dynamics in electromagnetic fields Coupled dynamics of the electrons and protonsRealistic surface model (M.T.F Pivi and M.A. Furman’s model, PRST-AB 6 034201 (2003) )Accelerator lattice can have arbitrary number of Electron Cloud Nodes

Page 13: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Electron Cloud Node (ECN) Algorithm

Electrons’ dynamics inside ECN:

time is a independent variableelectromagnetic forces from:

•proton bunch•electrons•conducting walls•external magnetic fields

Furman-Pivi surface model

PipeElectron Cloud RegionProton Bunch

LR >> LECN LECN

Protons’ dynamics inside the bunch:

Each proton gets a momentum kick

The effective length is our parameter.

tEqLL

p cloudECN

eff ΔΔ ⋅⋅⋅=rr

Electrons’ and protons’ dynamics are tied together

The PIC method for electrons’ and protons’ electromagnetic fields

Page 14: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Benchmark with PSR: Frequency Spectrum

Robert Macek Talk, LANL, 3/15-18/04PSR Data

turn = 20Simulations

Frequency spectra agree

No injection

Several tens of turns

5 ECNs are switched on

3200 turns of injection

All ECNs are switched off

10,000,000 macro-protons at the end

Stage 2 (main)Stage 1 (preparation)

Page 15: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Benchmark with PSR: EC-Protons Coupling

Instability development for one ECN in the PSR lattice. The lefthalf is the simulation results, and the right half is the real PSR data.

The coupling between proton instabilities and electron production. An intense electron flux coincides with high amplitude coherent proton bunch oscillations at the onset of substantial beam losses.

Page 16: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

SuperCode as Program Language

• It resembles C, with some FORTRAN features Input and output with files and streams.

• It has ‘include’ operator to add external pieces of code.• You can create custom functions.• Extremely easy to extend. It has its own wrapper generator.• Slow ( as all interpreters) • No dynamic loading of language extensions. • Not Object Oriented, no classes.• It has no support now. It was created in the first half of 1990s (

C++ standard was published in July, 1998)

We have to replace it with something else

We do not want just to move ORBIT under a new “driver shell”, we want to restructure the ORBIT code to use the full advantage of the Python language, including the speed of prototyping and development. And, of course, we want to get rid of the SuperCodelegacy completely.

Page 17: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

pyORBIT Interpreterlib

pyth

on.a

MPI

libr

ary

Bas

e O

RB

IT C

++an

d w

rapp

ers

pyORBIT

Main program

C and C++ code

Pure

Pyt

hon

Mod

ules

Exte

rnal

Pyt

hon

Mod

ules

an

d C

++ s

hare

d lib

rarie

s

pyORBIT is an extended Python programming language interpreter.

The following advantages are gained

• Users have a very powerful and modern programming language for free.

• User can use external Python modules (for instance graphics).

• Freedom. Everybody can develop and add his own new modules. If you do not like it, then do not use them.

Page 18: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Other Improvements and new features with pyORBITNew “Bunch Class”• It allows to keep not only 6D coordinates, but additional set of macro-particles

characteristics such as spin, macro-size, etc.• If user wants to add additional information it could be done easily.• User can operate macro particles from the Python interpreter level. No

compilation is necessary.• It is ready for parallel calculation.

A tree-like lattice structure• User can modify the lattice structure “on fly”. • It is small.• It is not mandatory. If you do not like it you can create your own lattice structure.

It is very easy to do in Python

MAD file parser • Pure Python. As a result it is very small (about 800 lines including documentation)

and simple. User can modify it at will.• It can handle MAD math expressions, arbitrary number of “included” child MAD

files.• It skips MAD tracking command.• It is example for the future parsers like MADX including data formats based on

XML

Page 19: ORBIT Code Review and Future Directions - KNUchep.knu.ac.kr/ecloud07/upload/10th_April/ORBIT_presentation.pdf · − Accelerator lattice is a set of Nodes • Its purpose is the design

Preliminary version ready

• We started a new attempt of migration to the Python shell language in ORBIT development

• The loose structure provides freedom for developers

• The initial structure is ready.

• Now pyORBIT includes bunch, TEAPOT, and MAD Parser.

• A lot of work ahead: We need a dedicated group effort to get this done!!