Skip to content

Commit 869a07f

Browse files
author
Michael Ehrlichman
committed
ibs_mod front end for proton rings
1 parent 348b27d commit 869a07f

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed

bsim/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ set (EXE_SPECS
2727
cmake_files/cmake.dynamic_aperture
2828
cmake_files/cmake.ibs_linac
2929
cmake_files/cmake.ibs_ring
30+
cmake_files/cmake.ibs_proton_ring
3031
cmake_files/cmake.sodom2
3132
cmake_files/cmake.spin_stroboscope
3233
cmake_files/cmake.synrad
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
set (EXENAME ibs_proton_ring)
2+
3+
set (SRC_FILES
4+
ibs_proton_ring/ibs_proton_ring.f90
5+
)
6+
7+
set (INC_DIRS
8+
)
9+
10+
set (LINK_LIBS
11+
bsim
12+
bmad
13+
sim_utils
14+
${PLOT_LINK_LIBS}
15+
${ACC_BMAD_LINK_LIBS}
16+
)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
!----------------------------------------------------------------------------
2+
!----------------------------------------------------------------------------
3+
!----------------------------------------------------------------------------
4+
!+
5+
! program ibs_proton_ring
6+
!
7+
! Simple program to calculate IBS growth rates for 1 turn in a ring.
8+
!
9+
! Usage: ibs_proton_ring (looks for ibs_proton_ring.in file)
10+
! ibs_proton_ring file.in
11+
!
12+
!-
13+
14+
program ibs_proton_ring
15+
16+
use beam_mod
17+
use twiss_and_track_mod
18+
use ibs_mod
19+
20+
implicit none
21+
22+
type (lat_struct), target :: lat
23+
type (coord_struct), allocatable :: orbit(:)
24+
type (ibs_sim_param_struct) :: ibs_sim_params
25+
type (ibs_struct) rates1turn
26+
27+
integer :: ix, status
28+
integer :: namelist_file
29+
integer i
30+
31+
character(100) :: lat_name, in_file
32+
character(30), parameter :: r_name = 'ibs_proton_ring'
33+
character(4) :: ibs_formula
34+
35+
real(rp) emit_x, emit_y, sig_z, sig_p, granularity
36+
real(rp) Npart
37+
38+
namelist / ibs_params / &
39+
lat_name, ibs_formula, Npart, emit_x, emit_y, sig_z, sig_p, ibs_formula, granularity
40+
41+
!------------------------------------------
42+
!Defaults for namelist
43+
lat_name = 'lat.bmad'
44+
ibs_formula = 'bjmt' ! See ibs_mod
45+
46+
call get_command_argument(1, in_file)
47+
48+
namelist_file = lunget()
49+
print *, 'Opening: ', trim(in_file)
50+
open (namelist_file, file = in_file, status = "old")
51+
read (namelist_file, nml = ibs_params)
52+
close (namelist_file)
53+
54+
! Set params
55+
ibs_sim_params%clog_to_use = 1
56+
ibs_sim_params%formula = ibs_formula
57+
58+
!Parse Lattice
59+
call bmad_parser (lat_name, lat)
60+
61+
lat%param%n_part = Npart
62+
63+
call twiss_and_track(lat, orbit, status)
64+
if (status /= ok$) then
65+
print *, 'problem with twiss_and_track'
66+
stop
67+
endif
68+
69+
do i=0,lat%n_ele_track
70+
lat%ele(i)%a%emit = emit_x
71+
lat%ele(i)%b%emit = emit_y
72+
lat%ele(i)%z%sigma_p = sig_p
73+
lat%ele(i)%z%sigma = sig_z
74+
enddo
75+
76+
call ibs_rates1turn(lat, ibs_sim_params, rates1turn, granularity)
77+
78+
write(*,*) "Ta = ", 1.0d0/rates1turn%inv_Ta/60.0, " (m)"
79+
write(*,*) "Tb = ", 1.0d0/rates1turn%inv_Tb/60.0, " (m)"
80+
write(*,*) "Tz = ", 1.0d0/rates1turn%inv_Tz/60.0, " (m)"
81+
82+
end program
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
&ibs_params
2+
lat_name = 'pEDM.lat'
3+
ibs_formula = 'mpxx'
4+
5+
Npart = 1.64e8
6+
7+
emit_x = 214.0e-9
8+
emit_y = 250.0e-9
9+
sig_z = 0.994
10+
sig_p = 1.177e-4
11+
12+
granularity = -1
13+
/

bsim/ibs_proton_ring/test/pEDM.lat

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
period = 48
2+
l_EBEND = 12.5
3+
l_QUAD = 0.4
4+
l_DRIFT = 1.88
5+
G = anom_moment_proton
6+
gamma_magic = sqrt(1+1/G)
7+
beta_magic = sqrt(1-(1/gamma_magic)^2)
8+
momentum_magic = gamma_magic*beta_magic*m_proton
9+
bend_angle = twopi/period
10+
r_bend = l_EBEND / bend_angle
11+
parameter[geometry] = closed
12+
parameter[particle] = proton
13+
parameter[absolute_time_tracking] = .false.
14+
beginning[p0c] = momentum_magic
15+
bmad_com[spin_tracking_on] = T
16+
particle_start[x] = 0.0
17+
particle_start[px] = 0.0
18+
particle_start[y] = 0.0
19+
particle_start[py] = 0.0
20+
particle_start[z] = 0.0
21+
particle_start[pz] = 0.0
22+
particle_start[spin_x] = 0.0
23+
particle_start[spin_y] = 0.0
24+
particle_start[spin_z] = 1.0
25+
M: Marker
26+
EBEND: sbend
27+
EBEND[fringe_type] = hard_edge_only
28+
!EBEND[fringe_type] = basic_bend
29+
EBEND[l] = l_EBEND
30+
EBEND[b_field] = momentum_magic/(c_light*r_bend) ! magnetic field in T
31+
EBEND[b_field_err] = -momentum_magic/(c_light*r_bend) ! magnetic field in T
32+
EBEND[b0_elec] = -beta_magic*momentum_magic/r_bend ! electric field in V/m
33+
EBEND[r0_elec] = 0.04 ! electrostatic deflector gap 4cm
34+
EBEND[exact_multipoles] = vertically_pure
35+
EBEND[tracking_method] = runge_kutta
36+
EBEND[mat6_calc_method] = tracking
37+
Dr: drift
38+
Dr[L] = l_DRIFT
39+
QF: quadrupole
40+
QF[L] = l_QUAD
41+
QF[b1_gradient] = 0.204889
42+
QD: quadrupole
43+
QD[L] = l_QUAD
44+
QD[b1_gradient] = -0.204889
45+
sector: line = (Dr, QF, Dr, EBEND, Dr, QD, Dr, EBEND)
46+
!ring: line = (M, 24*sector, M)
47+
ring: line = (M, 24*sector, M)
48+
![num_steps]=30
49+
*[tracking_method] = runge_kutta
50+
![mat6_calc_method] = Bmad_Standard
51+
![spin_tracking_method] = tracking
52+
bmad_com[rel_tol_tracking] = 1e-14
53+
bmad_com[abs_tol_tracking] = 1e-14
54+
bmad_com[default_ds_step] = 0.001
55+
use, ring

0 commit comments

Comments
 (0)