Skip to content

Commit

Permalink
Renamed to in dynamic_aperture program. (#1032)
Browse files Browse the repository at this point in the history
* Renamed `dpz` to `pz` in dynamic_aperture program.

* Minor tweak of generalized_gradient_fit output format.
  • Loading branch information
DavidSagan committed Jun 28, 2024
1 parent 546ed09 commit ee2e16b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
Binary file modified bmad-doc/other_manuals/dynamic_aperture.pdf
Binary file not shown.
18 changes: 9 additions & 9 deletions bsim/dynamic_aperture/doc/dynamic_aperture.tex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

\title{Dynamic_Aperture Program}
\author{}
\date{David Sagan \\ September 24, 2022}
\date{David Sagan \\ June 28, 2024}

\begin{document}
\pdfbookmark[1]{Contents}{contents}
Expand Down Expand Up @@ -285,7 +285,7 @@
bmad_com%radiation_damping_on = F
bmad_com%radiation_fluctuations_on = F

dpz = 0.000, 0.005, 0.010
pz = 0.000, 0.005, 0.010
da_param%min_angle = 0
da_param%max_angle = 3.1415926
da_param%n_angle = 0
Expand Down Expand Up @@ -348,10 +348,10 @@
\item[dat_file] \Newline
Name of the data output file. This name is required.
%
\item[dpz] \Newline
The \vn{dpz} parameter array is a list of $p_z$ values to use. The number of scans (dynamic aperture curves)
that are produced is equal to the number of \vn{pz} values.

\item[pz] \Newline
The \vn{pz} parameter array is a list of $p_z$ values to use. The number of scans (dynamic aperture
curves) that are produced is equal to the number of \vn{pz} values. Note: \vn{pz} used to be named
\vn{dpz}. The program is backwards compatible and will accept the old name.

%
\item[ele_start] \Newline
Expand Down Expand Up @@ -604,7 +604,7 @@
# gnuplot plotting command:
# plot for [IDX=1:3] "da.dat" index (IDX-1) u 1:2 w lines ...

"dpz = 0.000000"
"pz = 0.000000"
"x_ref_orb = 0.000124"
"y_ref_orb = 0.000037"
0.068125 0.000000 544 Hit +X Side Q11E
Expand All @@ -615,7 +615,7 @@
0.034006 0.014403 855 Hit +Y Side SEX_21W
... etc. ...

dpz = 0.005000"
pz = 0.005000"
"x_ref_orb = 0.006591"
"y_ref_orb = 0.006591"
0.073979 0.000000 904 Hit -Y Side SEX_16W
Expand All @@ -627,7 +627,7 @@
\end{code}

The top part of the data file will be a record of input parameter values. This is followed by a number of
data blocks, one for each setting of \vn{dpz}. The five columns of these data blocks are:
data blocks, one for each setting of \vn{pz}. The five columns of these data blocks are:
\begin{code}
1 & 2: x_aperture, y_aperture
3: Number of turns a particle initially at the aperture limit survived.
Expand Down
28 changes: 19 additions & 9 deletions bsim/dynamic_aperture/dynamic_aperture.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ program dynamic_aperture_program

procedure(track_many_hook_def) :: track_many_hook

real(rp) dpz(20), vec(6)
real(rp) dpz(20), pz(20), vec(6)
real(rp) :: ramping_start_time = 0
integer nargs, ios, i, j, n_dpz, nt
integer nargs, ios, i, j, n_pz, nt

logical :: ramping_on = .false., set_rf_off = .false.
logical err

character(200) :: in_file, lat_file = '', dat_file, gnu_command, line

namelist / params / bmad_com, ltt, da_param, set_rf_off, dpz, dat_file, &
namelist / params / bmad_com, ltt, da_param, set_rf_off, dpz, pz, dat_file, &
ramping_start_time, lat_file, ramping_on

!
Expand All @@ -52,6 +52,7 @@ program dynamic_aperture_program
bmad_com%auto_bookkeeper = .false. ! Makes tracking faster
bmad_com%absolute_time_tracking = .true.
dpz = real_garbage$
pz = real_garbage$

! Read parameters
! Read the master input file again after bmad_parser is called so that bmad_com parameters
Expand Down Expand Up @@ -130,16 +131,25 @@ program dynamic_aperture_program

! Read in lattice

n_dpz = count(dpz /= real_garbage$)
print *, 'Note: Number of dpz points: ', n_dpz
n_pz = count(dpz /= real_garbage$)
if (n_pz /= 0) then
print *
print *, 'Note: "dpz" has been renamed to "pz" to be compatable with Tao.'
print *, ' The program will run normally...'
print *
pz = dpz
endif

n_pz = count(pz /= real_garbage$)
print *, 'Number of pz points: ', n_pz

if (.not. bmad_com%absolute_time_tracking) then
print *, 'Note: absolute time tracking is OFF!'
endif

print *, 'Data file: ', trim(dat_file)

write (gnu_command, '(a, i0, 3a)') 'plot for [IDX=1:', n_dpz, '] "', &
write (gnu_command, '(a, i0, 3a)') 'plot for [IDX=1:', n_pz, '] "', &
trim(dat_file), '" index (IDX-1) u 1:2 w lines title columnheader(1)'

! Scan
Expand Down Expand Up @@ -179,9 +189,9 @@ program dynamic_aperture_program
write (1, '(2a)') '## gnuplot plotting command:'
write (1, '(2a)') '## ', trim(gnu_command)

call dynamic_aperture_scan (aperture_scan, da_param, dpz(1:n_dpz), ltt_com%tracking_lat)
call dynamic_aperture_scan (aperture_scan, da_param, pz(1:n_pz), ltt_com%tracking_lat)

do i = 1, n_dpz
do i = 1, n_pz
da => aperture_scan(i)

nt = 10
Expand All @@ -191,7 +201,7 @@ program dynamic_aperture_program

write (1, *)
write (1, *)
write (1, '(a, f14.9, a)') '"dpz =', dpz(i), '"'
write (1, '(a, f14.9, a)') '"pz =', pz(i), '"'
write (1, '(a, f14.9, a)') '"x_ref_orb =', da%ref_orb%vec(1), '" # (x, y) below is with respect to the reference orbit.'
write (1, '(a, f14.9, a)') '"y_ref_orb =', da%ref_orb%vec(3), '"'
write (1, '(a, 6(f14.9, a))') '# ref_orb = (', (da%ref_orb%vec(j), ',', j = 1, 5), da%ref_orb%vec(6), ')'
Expand Down
2 changes: 1 addition & 1 deletion bsim/dynamic_aperture/example/dynamic_aperture.init
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ltt%lat_file = 'chess_arc_pretzel_20150106.lat'
ltt%rfcavity_on = F

dpz = 0, 0.005, 0.01
pz = 0, 0.005, 0.01
da_param%min_angle = 0
da_param%max_angle = 3.1415926
da_param%abs_accuracy = 1e-5
Expand Down
2 changes: 1 addition & 1 deletion util_programs/generalized_gradient_fit/gg_fit_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ subroutine write_gg_bmad()
write (1, '(3a)') ' kind = ', sincos_name(gg%sincos), ','
write (1, '(a, i2)') ' derivs = {'

write (fmt, '(a, i0, a)') '(f15.4, a, ', size(gg%deriv,2), 'es20.12, a)'
write (fmt, '(a, i0, a)') '(f15.6, a, ', size(gg%deriv,2), 'es20.12, a)'
do iz = iz_min, iz_max-1
write (1, fmt) iz*del_meters(3), ':', gg%deriv(iz,:), ','
enddo
Expand Down

0 comments on commit ee2e16b

Please sign in to comment.