Project

General

Profile

Fake Orbit Response Creator

This program creates fake Orbit Response (ORM) from the measured magnet settings and the Booster MADX model.
The source code can be retrieved by issuing the following command:

git clone http://cdcvs.fnal.gov/projects/booster_fake_orm

Requirements

Builds on MacOSX 10.11.6 and 10.12.2 and LINUX on the CLX cluster are supported.

Compiling on MacOSX

The requirements for building fakeORM:

  • Apple Accelerate Framework
  • Apple's implementation of BLAS and LAPACK used for SVD. (comes pre-installed)
  • git
  • Boost library
  • use MacPorts to install
 port install boost 

Boost.Process 0.5. This is the beta version of the process library and needs to be downloaded and installed separately

Boost.Process

  • GNU Scientific library
  • use MacPorts to install
 port install gsl 

Compiling on LINUX (CLX cluster)

The requirements for building fakeORM:
  • git (comes pre-installed)
  • Boost library (CLX has a very old version of Boost and so a new version has to be installed)
  • Download and install Boost
  • CLX does not have bzip installed and so after bootstrap.sh is run, the following command must be used to compile Boost
    ./bootstrap.sh --prefix=/export/home1/cytan
    ./b2 -sNO_BZIP2=1 install
    

    where the argument of the prefix option is where the base directory of where the include directory lives.
    There is a bug in boost/python/ssize_t.hpp. Comment out the following in the file:
    //typedef Py_ssize_t ssize_t;  <----- comment this out
    ssize_t const ssize_t_max = PY_SSIZE_T_MAX;
    ssize_t const ssize_t_min = PY_SSIZE_T_MIN;
    

Boost.Process 0.5. This is the beta version of the process library and needs to be downloaded and installed separately

Boost.Process

  • GNU Scientific Library
  • LAPACK
  • Download (but use ATLAS (see below) to install) LAPACK
  • ATLAS
  • Download and install ATLAS.

configure with

mkdir atlas; cd atlas;
../configure -b 64 -D c -DPentiumCPS=2327.550 --prefix=/export/home1/cytan/loco_new/atlas  --with-netlib-lapack-tarfile=/export/home1/cytan/loco_new/l
apack-3.4.2.tgz

where you must change the prefix and with-netlib-lapack-tarfile options to the location that you desire.

Unfortunately ATLAS configure tries to be smarter than the user and refuses to configure unless throttling is turned off. And the option that disables this check has been disabled!
Therefore, in general, if you are not the superuser, you are SOL'd. But there is a workaround:
edit the file in CONFIG/src/config.c and search for ProbeCPUThrottle() and add the following line:

int ProbeCPUThrottle(int verb, char *targarg, enum OSTYPE OS, enum ASMDIA asmb)
{
  return 0;   // <--- add this line to override throttle check!

and everything should configure.

  • MADX is already installed on the CLX cluster.

Building

Edit the Makefile to put in the appropriate paths if necessary. The Makefile has been set up so that it knows whether it is run on a Mac or on the CLX cluster.

Run

 make

fakeORM should be created. Move fakeORM to your local path.

A pre-built version of fakeORM for MacOSX or CLX LINUX can be requested from the author:

.loco configuration file

The .loco file contains configuration parameters about where some files and directories live. Edit this file to reflect your run environment. Default values are used if these options are not set.
An example of the contents of a .loco file is

[fitit]
g[disp2sdds]
gnufont=/Library/Fonts/Arial.ttf
plotdir=./plots
dispheader=/Users/cytan/expt/booster/loco_new/common/DispHeader.sdds

[orm2sdds]
gnufont=/Library/Fonts/Arial.ttf
plotdir=./plots
ormheader=/Users/cytan/expt/booster/loco_new/common/ORMHeader.sdds

[fitit]
gnufont=/Library/Fonts/Arial.ttf

plots_dir=./plots
common_dir=./common
headers_dir=/Users/cytan/expt/booster/loco_new/common
work_dir=/tmp

lattice=machine.lte
orm_ele=ORM.ele
twiss_ele=twiss.ele

mlattice=booster.madx

magnet_settings=MagnetSettings.txt
rposfile=deltaRPOS.txt
machine_params_sdds=machine_parameters.sdds
params2vary_sdds=parameters2vary.sdds
machine_params_vs_t=machine_params_vs_t.sdds
qsdqsf_fname=qsdqsf.dat

elegant=/Users/cytan/bin/elegant
madx=/Users/cytan/bin/madx

Checking the configuration

To check the configuration of fakeORM, run the following

fakeORM -h

The output should look something like this

fakeORM version 1.0-2-g0c7dfbf-3
config file: /Users/cytan/.loco
         gnuplot font = /Library/Fonts/Arial.ttf
         plots dir = ./plots
         common dir = ./common
         headers dir = /Users/cytan/expt/booster/loco_new/common
         results dir = ./results
         work dir = /tmp
         magnet settings = MagnetSettings.txt
         rpos file = deltaRPOS.txt
         qsdqsf file = qsdqsf.dat
         lattice = booster.madx

command line options and their DEFAULT values

generic options :
  -h [ --help ]                         this message
  -A [ --ormA ] arg                     ORM output file. Either one file with 
                                        both H & V data or two files separated 
                                        by , or space. H first, V second
  -d [ --dfile ] arg                    dispersion output file name
  -e [ --error ] arg (=0.10000000000000001)
                                        fractional error range to be added to 
                                        the bpm values 0<=error<=1.0
  -k [ --krange ] arg (=-2 2 1)         start,stop,step of dipole kicks in A 
                                        (separated by a space) of the fake ramp
                                        data
  -r [ --rposrange ] arg (=-1 3 1)      start,stop,step of rpos in mm 
                                        (separated by a space) of the fake ramp
                                        data
  -t [ --trange ] arg (=3 30 1)         start,stop,step of cycle_time in ms 
                                        (separated by a space) of the fake ramp
                                        data
  -n [ --num_repeats ] arg (=3)         number of times to repeat the 
                                        measurement
  -c [ --config ] arg (=/Users/cytan/.loco)
                                        LOCO configuration file
  -D [ --debug ]                        enable debugging
  -v [ --version ]                      print version

config file options:
  --fitit.gnufont arg                   gnuplot font
  --fitit.plots_dir arg (=./plots)      plot directory
  --fitit.common_dir arg (=./common)    common directory
  --fitit.results_dir arg (=./results)  results directory
  --fitit.headers_dir arg (=./headers)  headers directory
  --fitit.work_dir arg (=/tmp)          work directory for temporary files
  --fitit.rposfile arg (=deltaRPOS.txt) rpos ramp filename
  --fitit.madx arg                      madx path
  --fitit.bad_bpm_list arg (=bad_bpm_list.dat)
                                        bad bpm list
  --fitit.bad_corrector_list arg (=bad_corrector_list.dat)
                                        bad corrector list
  --fitit.magnet_settings arg (=MagnetSettings.txt)
                                        magnet settings up the ramp file
  --fitit.mlattice arg (=booster.madx)  madx lattice file
  --fitit.qsdqsf_fname arg (=qsdqsf.dat)
                                        QL and QS K values in madx format

Creating ormH.txt, ormV.txt and disp.txt files

The requirements are that you have the following files:

  • in the common directory:
  • deltaRPOS.txt -- the RPOS ramp file used for dispersion measurements
  • MagnetSettings.txt -- the ramp file that is the source file for the creation of optics.sdds
  • bad_bpm_list.dat -- the bad bpm list
  • bad_corrector_list.dat -- the bad corrector list
  • QL.dat, QS.dat , DC.dat -- files that are created using
    make_madx_dat -m MagnetSettings.txt 
    It is unnecessary to use the other *.dat files and they can be commented out of the booster.madx file. The switches in the booster.madx file are set as follows
errorSwitch=0;
isLOCO=1;
  • MADX input files that are required in the common directory:
  • booster.madx -- parent file
  • booster.ele -- magnet definitions
  • booster.seq -- lattice file
  • qsdqsf.dat -- QL and QS K values in MADX format

Comment out the following lines in the booster.madx file because the input files S*.dat are unnecessary for the generation of the fake ORMs at this time.

! strengths of corrector package elements:
READMYTABLE,file="QL.dat",table=QLtable;
setvars, table=QLtable,row= timeSlot;
READMYTABLE,file="QS.dat",table=QStable;
setvars, table=QStable,row= timeSlot;
!
! Comment the inputs below out for fakeORM
!
!READMYTABLE,file="SQL.dat",table=SQLtable;
!setvars, table=SQLtable,row= timeSlot;
!READMYTABLE,file="SQS.dat",table=SQStable;
!setvars, table=SQStable,row= timeSlot;
!READMYTABLE,file="SXL.dat",table=SXLtable;
!setvars, table=SXLtable,row= timeSlot;
!READMYTABLE,file="SXS.dat",table=SXStable;
!setvars, table=SXStable,row= timeSlot;
!READMYTABLE,file="SSL.dat",table=SSLtable;
!setvars, table=SSLtable,row= timeSlot;
!READMYTABLE,file="SSS.dat",table=SSStable;
!setvars, table=SSStable,row= timeSlot;

The latest versions of the MADX input files can be downloaded from here

An example of the files in the common directory can be found in common.zip

The files that are generated in the results directory are:

  • ormH.txt, ormV.txt. These are the horizontal and vertical orbit responses respectively. These files store the response at the BPMs for every dipole kick.
  • disp.txt. This is the dispersion file. This file stores the response at the BPMs for every RPOS change.

For example:

fakeORM -A ormH.txt ormV.txt -d disp.txt -t 2.0  4.6 0.37142

will create ormH.txt, ormV.txt and disp.txt files in the results directory for break points starting from 2.0 ms to 4.6 ms in a time step 0.37142 ms.

Note: it takes a while to generate these files. So be patient!