8000
Skip to content

Repository files navigation

IMPACT-Z is a parallel+serial particle-in-cell code whose primary purpose is to model the dynamics of multiple charged particle beams in linear and ring acceler ators. The code uses longitudinal position (z) as independent variable and includes the effects of externally applied fields from magnets and accelerating cavities as well as the effect of self-fields (space charge fields). Mathematically, the code solves the Vlasov/Poisson equations using a particle-based technique. The code, which is written in Fortran90 with MPI, runs on both single-processor and multi-processor systems. It has been applied to studies of halo formation and coupling resonance in high intensity beams, microbunching instability in high brightness electron linac, beam dynamics in SNS linac, JARPC linac, RIA driver linac, CERN superconducting linac, LEDA halo experiment, Proton Synchrotron at CERN, etc.

This code can be integrated with a parallel multi-objective optimizer (https://github.com/qianglbl/PVPmoo) for beam dynamics optimization.

Additionally, there is a sister parallel beam dynamics tracking code, IMPACT-T (https://github.com/impact-lbl/IMPACT-T), which uses time "t" as the independent variable.

The ImpactZexeMac, ImpactZexeUbuntu, and ImpactZexeWin.exe are old executables.

Main contact: Ji Qiang (jqiang@lbl.gov), Lawrence Berkeley National Laboratory

Citation: J. Qiang, R. Ryne, S. Habib, V. Decyk, "An Object-Oriented Parallel Particle-In-Cell Code for Beam Dynamics Simulation in Linear Accelerators," J. Comp. Phys. vol. 163, 434, (2000).

Installation using Anaconda

Information about Anaconda, including install instructions, can be found on the Conda Reference website.

IMPACT-Z is available through conda-forge and can be installed via:

conda create -n impact
source activate impact # or conda activate impact
# For non-MPI
conda install -c conda-forge impact-z

# For OpenMPI
conda install -c conda-forge impact-z=*=mpi_openmpi*

# For MPICH
conda install -c conda-forge impact-z=*=mpi_mpich*

After these steps, the IMPACT-Z executable ImpactZexe or ImpactZexe-mpi, respectively, will be in your PATH environment variable and is thus ready to use like any regular command-line command.

Using conda to compile IMPACT-Z

conda-forge has all of the necessary compilers and dependencies to build IMPACT-Z from source.

Create a build environment like so:

conda create -n impactz-build -c conda-forge compilers cmake openmpi 'fftw=*=mpi_openmpi*'
conda activate impactz-build

Then to build the non-parallel version:

cmake -S src/ -B build-single
cmake --build build-single -j 4
ls build-single/ImpactZexe

And to build the MPI-parallelized version with OpenMPI:

cmake -S src/ -B build-mpi -DUSE_MPI=ON
cmake --build build-mpi -j 4
ls build-mpi/ImpactZexe-mpi

An MPI-parallelized version with FFTW support:

cmake -S src/ -B build-fftw -DUSE_MPI=ON -DUSE_FFTW=ON
cmake --build build-fftw -j 4
ls build-fftw/ImpactZexe-mpi

For compiling on high core count machines, you should consider setting -march=native in order to take advantage of single instruction, multiple data (SIMD) instructions. These can have a large, beneficial impact on IMPACT-Z's performance.

# Check your FFLAGS first of course!
# Remove any -march or -mtune options that exist.
FFLAGS=$(echo "$FFLAGS" | sed -E 's/-m(arch|tune)=[^ ]+//g')

cmake -S src/ -B build-fftw -DUSE_MPI=ON -DUSE_FFTW=ON -DCMAKE_Fortran_FLAGS="$FFLAGS -march=native -mtune=native"
cmake --build build-fftw -j 4
ls build-fftw/ImpactZexe-mpi

Compiling The Code

If you are new to CMake, this short tutorial from the HEP Software foundation is the perfect place to get started with it.

Unix

Single Processor Code

# inside the IMPACT-Z src/ directory:
cmake -S . -B build
cmake --build build
# the executable in now in build/

# this command needs sudo if you install into system paths:
cmake --build build --target install

Multi Processor Code

# inside the IMPACT-Z src/ directory:
cmake -S . -B build -DUSE_MPI=ON
cmake --build build
cmake --build build --target install

Using WSL on Windows computer

  1. Install WSL under Windows PC's PowerShell terminal using: wsl --install

  2. After installing WSL, restart the PC

  3. Under Windows PowerShell terminal type: wsl

  4. Install Ubuntu under WSL:

    wsl.exe --install Ubuntu
    
    sudo add-apt-repository universe
    
    sudo apt update
    
  5. Install cmake using: sudo apt install cmake

  6. Install Fortran90 compiler using: sudo apt install gfortran

  7. Make a local directory, e.g.: ImpZ

  8. Go to website: https://github.com/impact-lbl/IMPACT-Z/releases

  9. Download source code (zip) into that local ImpZ directory

  10. Under Windows File Explorer, extract all files from the zip file.

  11. Go to the IMPACT-Z-* directory

  12. Go to the src directory

      cmake -S . -B build
    
      cmake --build build
    

Now the executable ImpactZexe is in build/

You can move that executable to the location where you want to run the simulation. When you run a simulation, all input files and the executable must be in the same directory.

For multi-core/processor simulation, install the OpenMPI package in the WSL terminal.

sudo apt install -y openmpi-bin libopenmpi-dev
cmake -S . -B build -DUSE_MPI=ON
cmake --build build

Now the executable ImpactZexe-mpi is in build/

About

For IMPACT-Z beam dynamics code users and developers

Resources

Stars

22 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0