May 17, 2014 - Notes about tracking programs Main = tracking_master All subroutine are in code/ directory Need to figure out how to rebuild finalfocus/ and magneticfield/ after having put all subroutines into code/ tracking_master now propagates through backleg and inflector Inflector apertures at each end are defined in lattice file for rectangular aperture. The "D" shape of the aperture is accessed in TRACK1_CUSTOM - for these elements (check TRACK1_CUSTOM to see whats incorporated) Also scattering in coil ends and cryo window is from TRACK1_CUSTOM Scattering is no longer controlled in input.dat. It can be turned off by removing the marker elements from the lattice file or editing TRACK1_CUSTOM MARK_CRYO_US MARK_INFLECTOR_US MARK_INFLECTOR_DS If in the lattice file inj: line = (inject, inj_to_ring, ring_br) then particles are tracked through the backleg inj: line= (injinf, inj_to_inrg, ring_br) then particles are tracked using taylor maps In both cases, the distribution emittance and twiss parameters is defined at the midpoint of the inflector. The distribution is propagated to the end of the inflector and then back to the opening of the hole in the iron. Note that the taylor maps are not precisely symplectic so the inverse is approximate. If the number of muons is one then the trajectory through the backleg and fringe and inflector is written to unit 71 and the twiss parameters are computed assuming the initial values in the lattice file and written to unit 72. The beam parameters computed from the distribution after propagating through injection line to end of inflector is written to EndInfAfterScatter.dat August 11, 2014 - The subroutine optimize_twiss finds the twiss parameters at the start of the injection line (30 cm upstream of iron) that give the specified (in the input file) twiss parameters at the end of element INFA in the inflector. August 12, 2014 - The routine get_branch_inverse_matrix inverts the transfer matrix through the injection line. It had been using the full line, from 30cm upstream of iron to end of inflector. Set the endpoint in this routine to be at element 'INFA'. August 14, 2014 Modify tracking_master to write phase space for each element in the injection line. Files are named ele%name//"phase_space.dat" Plot using plotting_scripts/hist_any_file.gnu for example like so gnuplot -e "filename='CRYO_USphase_space.dat'" ../plotting_scripts/hist_any_file.gnu Add ability to use matrices for propagation through injection channel. The flag in the input file is inj_matrix_tracking. Definitely more particles make it through. Remember that the map for the fringe field cuts off at 6mm, and 25mm. The code assumes that beyond the boundaries of the map the field is uniform. But of course this gets the focusing effect wrong. Of course the transfer matrices won't be right for the 36mm aperture inflector since the reference trajectory will go beyond the 6mm boundary. August 15, 2014 The field map for the fringe field cuts off at +6mm in x with respect to the center line and +-25mm in y. Beyond the map we assume B has the value at the boundary. This means that for the nominal 9mm inflector that which the reference orbit is all within the bounds of the map, that will not be true for all of the particles in the distribution. 1. Perhaps a reasonable approximation is to use the matrices computed with respect to the reference to propagate the particle distribution. 2. But for the 18mm inflector even the reference orbit is outside the bounds of the map. Are the matrices associated with this reference valid? If not then using matricies to propagate phase space in this case is not sensible. Let's check it out. Compare propagation of beta for 18mm inflector and 9mm. The answer to this question is that the propagation of the twiss functions is very different using these approximations for the field map. It therefore is not sensible to use the related matrices to propagate phase space. In order to calculate with the larger inflector we need a better map. Try to figure out how to read HeHe's map. Meanwhile, update repository. Check out on linux. Repeat calcs in injection_line/ and they look OK. Next step to update g-2 Sanity check. With a single muon, fort.71 is trajectory through injection channel, and fort.72 is the beta. August 20, 2014 Add comments to "create_phase_space" Check that random distribution of muons gives capture efficiency consistent with VD... Note that the emittances in the input file are for 1 sigma and the 95% is 2 sigma (or 4 times the emittance) August 21, 2014 Add lattice name to input.dat Add comments to subroutine collect_times 2014_0904 NSF: Adding Wuzheng's larger B-field map for the ring/backleg/hole. The first 3 lines of the file describe the number of gridpoints in the {xyz}-directions, the number of field components, and the arrangement of the data in the rest of the file. The spatial extent of the map can be read from the first/last data lines after the header: 711 cm < x < 731 cm 0 cm < y < 3 cm -430 cm < z < 10 cm The B-field unit is again Gauss, as it was with the smaller map. Wuzheng did not include Hy(Oe) in the larger map, which helps reduce file size, but makes it more difficult to tell when muons are in the backleg steel (Hy: logical - if true use twiss parameters defined in lattice file to propagate through injection line. so that it is possible to use twiss set in lattice file. This does not converge so well. Return to varying betax and alphax at end of inflector through input file and find that if twiss = 1.7642, 10.0, -0.7502, 0, 2.0, 0., 0., 0., 0.7, 0.7, 0., 0., beam just fits through inflector with max of 44.6mm in ring. f=45/7.7 =>95% emit=34 mm-mrad - Note this is independent of the distribution. (f defined in plotting script) Now it would be nice to see if these better optimized values give more muons. Create new directory BetaTest Copy input file and lattice file from ../KickTimeTest/127cm-20153028 Set optimized beta in input file - 348 stored ? seems low ---------------------------- I would like a fresh calculation of capture with old kicker vs new (including realistic pulse) -create /KickTimeTest/821kick-20150614. Copy input from ../../BetaTest. Restore nominal twiss. and run as a check - ge 398. Looks reasonable and the 348 with the new betas really was low ??? - Meanwhile, I found that KickTimeTest/127cm_table_20150507/Kick1-3Scan/ has the appropriate run with the full pulse - Back to /KickTimeTest/821kick-20150614. Set input for 821 kicker circuit - We get 217 stored with kickers at kicker_params%kicker_field = 210.0e-4 210.0e-4 210.0e-4 - Now do scan ************** Comment out line 175 in fields.f90 that writes to unit 344. This information gives kicker pulse but generates a very large file ********** ------------------------------------------------------ October 12, 2015 code/fields.f90 Edit calculation of quadrupole efield so that - between quad plates (0.05) and chamber wall (0.1) the efield is taken to be plate_voltage/(distance to wall) - beyond the vacuum chamber wall, quad field is set to zero. (This is important for electron tracking) - programs/efield_test.f90 calls fields.f90 and can compute fields. ___________________________________________ December 23, 2015 Add bmad style electrostatic multipoles to lattice file bmad_es_multipoles. Turn on/off bmad multipoles (vs straight expansion in em_field_custom) by setting field_calc = custom (or not) in definition of FULLRING. Update set_quad_params to do the right thing with bmad multipoles The good thing about the bmad style is that the entrance and exit fringe effect is included The bad thing is that there is no easy way to deal with muons (or positrons) near or outside the plates) But maybe the correction to the fringe fixed the peculiar energy dependence of omega_a? Try that out ___________________________________________________________ September 30, 2017 Quads can be represented by - grid map - based on 2D map - grid map - slice from center of 3 D map - bmad standard multipoles - cartesian - bmad standard multipoles - cylindrical Cylindrical multipole coefficients computed with programs/fit_mcmillan - fit to slice from center of 3D curviliner map - track1_preprocess quad ramping if em_field comes from cartesion grid map - do not have multipole or cylindrical version for ramp kill particles that are outside vacuum chamber or headed in direction to be lost. remebering that particles enter ring from outside of Q1-long - em_field_calc quad with grid map field calc are designated custom in bmad file If vec(1) is within boundaries of map, set field_calc to standared and call em_field_calc If vec(1) is outside boundary set E=0, B=1.45 Then add error fields - compute_decayTime After fussing with exponential distribution and gnuplot histogramming realize everything is fine. The problem was that particle type was set in two places in the lattice file and I had set one to antimuon but the other remained as proton ________________________________________________ October 8, 2017 Add an option to create_phase_space.f90 to 'use_as_is' If twiss_ref = 'use_as_is' then use the phase space distribution as read from a file or create with no matching to any particular twiss parameters. The twiss parameters will be that of the distribution. This is added so that I could read the distribution I wrote at the exit of the inflector and propagate around the ring. This distribution was created by starting with Dikty's distribution at the end of M5 and propagating through inflector and then onto design trajectory _______________________________________________- October 22, 2017 Reinstate RF quad. Add a couple of lines to track1_preprocess. This is wrong. The quad must be set in em_field_custom so that the time is updated with each step. Modify set_quad_params so that each quad can be called individually to set field And use new routine set_a_quad(ele, verbose) to translate from quad_params%short_quad_field_index Hardwired for Q2 short only Also add write to unit 197 in em_field_custom.f90 so that it is possible to check to see that it is happening properly Note that if rf_quad frequency is horizontal tune, the output is a bit confusing since only a fraction is sampled Old way: The frequency is 2 *(2pi* rf_quad()%freq_h - lat%a%tune) that is a small change in the tune and then doubled for beta modulation If rf_quad()%freq = 0 then rf_quad%freq > 2Q New way: Frequency is lat%a%tune * rf_quad()%freq_h that is a multiplicative factor times tune. If rf_quad()%freq = 1 then rf_quad%freq = tune Also, use twopi - lat%a%tune for horizontal __________________________________________________________ November 18, 2017 Shape of measured kicker pulse in ring at fermilab by Alex. Data file with time, volts, bfield: /field_maps/kicker1data.txt - coded in input.dat as 20171113 A modified version with reduced secondary pulse amplitude: /field_maps/kicker1data_halftail.txt - coded in input.dat as 20171118 /code/fields.f90 modified to read files /programs/modify_kicker_pulse_map.f90 __________________________________________________________ March 16, 2018 and before Modify create_phase_space to simplify creation of temporal distribution. Create a separate routine , as a part of the create_phase_space.f90 file to generate temporal distribution and vec(5) and rearrange create_phase_space so this same routine is called as required Distinct pulse shapes for the 8 injected pulses based on measurements are in files/pulse_shapes/ Subroutine reads one of the eight files , or the average which is the ninth and creates random distribution with the right shape. Modifiy create_phase_space to read Diktys 400k trajectory file 'particles_M4M5End_400_mod.txt' ____________________________________________________________ March 18, 2018 Create a kicker pulse with width modified for 40ns increase of two additional blumlein sections. The file is /field_maps/kicker1data_flattop.dat. ______________________________________________________________ March 19, 2018 Create a new routine to compute energy loss in fiber harps. Use the energy loss distribution generated by gm2ringsim (provided by Antoine). fiber_energy_loss.f90 generates a random energy loss consistent with gm2ringsim distribution. For the moment it does not account for the fact the that effective thickness depends on the particular trajectory. If the particle hits the fiber then it applies the same energy loss regardless. The file files/fiber_energy_loss/eloss.dat is the 'measured' distribution.