BMAD based g-2 tracking code

g2_tracking is a program that is used to explore beam dynamics of the g-2 storage ring. It is based on the Bmad library of accelerator modeling routines, and field maps computed with Opera, Poisson, FEMME, etc. The layout of the injection channel and ring are defined in the Bmad lattice file(s). The lattice file is traditionally named bmad_< stuff >. The geometry of the ring, dipole field, length and locations of inflector, quads and kickers, collimators, apertures, fiber_harps and calorimeters are defined in the lattice file(s). Beam and ring parameters, such as emittance, energy spread, temporal distribution, position and momentum offsets, quad fields, inflector field, etc. are specified in a file named input.dat. Most of the files are referenece with soft links.

Running g2_tracking

To run the g2_tracking program you will need the executable, field maps, temporal maps of muon pulse shape and pulsed injection kicker, muon phase space distributions, lattice file, two quad specific input files (named quad_input.dat and ,quad_plate_misalign.bmad and an input file input.dat for everything else.

Implementation of time dependent dipole fields in the ring quadrupole elements


Bmad code development

You can download all of the bmad and g-2 code and build locally. That way you can tailor the code to your requirements.
  • Acquiring g-2 (and bmad) code.

    g-2/ directory tree
  • Other stuff


    Acquisition Within Wilson Lab of code from the Wilson accelerator code repository


    1. If you have not done this already, make a directory for your local copy of the Bmad (g-2) distribution, programs, etc. Henceforth this directory will be referred to as < DIR >. A possible name might be: "root_dir". Substitute the appropriate directory name for " < DIR >" in the following steps.

    2. To make a local copy of a directory, the commands:

         cd < DIR >
         svn co https://accserv.lepp.cornell.edu/svn/<REPOS_PATH>.

      To find the correct < REPOS_PATH >, use the repository web viewer. For example. to make a local copy of the bmad library, use the commands:


        cd <DIR>
        svn co https://accserv.lepp.cornell.edu/svn/trunk/src/g-2

      This will create the directory <DIR>/g-2

    3. To update your local copy of a library and/or executable so that it has all the revisions that have been introduced into the repository, go to the directory containing the library and/or executable and use the command:

         svn update

    4. To compile the library: (see Environment Variables)

      cd <DIR>/g-2
      mk          # Produces production libraries and/or executables


      Or use "mkd" instead of "mk" if you want to the debug versions of the libraries and/or executables.

      Production libraries and executables are put in the directory:

      <DIR>/production

      and debug libraries and executables are put in:

      <DIR>/debug


    For offsite acquisition and installation see

    Offsite Bmad Setup
  • Field maps/
  • plotting_scripts/
    gnuplot scripts
  • documentation/
    List
    The command /g-2/softlink (or softlink_lnx, or softlink_gm2) depending on what machines you are running will create all the links
  • You will find an example input.dat and the lattice file bmad_all_configs_fringe_inf_grid_calo. already in the test/ subdirectory.
  • To execute - On the command line type < DIR >/production/bin/g2_tracking < CR >

    Examples

    There are many input parameters specified in the input.dat file. Example input files can be found in the examples subdirectory g-2/examples/ along with explanatory documentation in each of the 4 example subdirectories. examples/README.txt gives a summary of what you will find in each of the 5 directories

    Things you can calculate

    Injection channel

    The injection channel branch <start_tracking_at_inflector_exit> = F begins just upstream of the hole in the backleg iron and extends through the fringe field of the main dipole, and through the inflector. The magnetic field is represented as maps computed with the OPERA code. There are separate maps for main dipole fringe field and inflector field. The reference trajectory for this branch is the line tangent to the main ring at a circumference of R + d, where R is the radius of the closed orbit of the magic momentum muon and d =77mm is the displacement of the axis of the inflector from the closed orbit. The initial coordinates (that is at the start of the branch) of the trajectory magic momentum muons that exits the inflector on its axis depends on the fringe field map (presumably fixed) and the inflector map, which can be scaled, <inflector_field>.

    Ring

  • ering:

    Function: The ering executable tracks muons around a ring with radius of 7.112 m. There is a uniform vertical magnetic field and uniform radial electric field. Muon phase space and muon spin are tracked by runge kutta integration

    Input

    Output

    • phase_space_spin.dat -- Phase space coordinates and polarization vs element name, turn, and time
    • floor_plan.dat -- Ring geometry

    Example - test run


    Environment Variables

    In order for the code to build and link various environment variables must be defined. They are for the most part telling the linker where to find the BMAD library subroutines. The easiest way to get these variables is on linux from your home directory to

    cp /home/dlr/.bashrc_g2 .bashrc

    Before you do this you might want to rename your own .bashrc file so that it is not overwritten and then combine the two.


    Structures

    For reference
    The BMAD structures are defined in
    bmad_struct.f90
    The g-2 structures are defined in muon_mod.f90

    References

    1. Evolution of the Muon Distribution in the g-2 Ring June, 2016
    2. Analysis of Phase Space Matching with RF Quad December 2015
    3. Multiple Scattering in Inflector End Coils April, 2014
    4. Inflector Acceptance and Twiss Parameters September, 2013
    5. Matching Dispersion into the Ring June, 2013
    6. Tracking Through the Injection Channel April, 2013
    7. Inflector Acceptance June, 2012