Skip to content

Commit 91e698c

Browse files
authored
Fix bunch size calc within space charge calc. (bmad-sim#1355)
1 parent f3c2dc4 commit 91e698c

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

bmad/multiparticle/beam_utils.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,9 @@ subroutine calc_bunch_params (bunch, bunch_params, error, print_err, n_mat, is_t
14121412
if (bunch_params%n_particle_live < 6) return
14131413

14141414
call calc_emittances_and_twiss_from_sigma_matrix (bunch_params%sigma, bunch_params, error, print_err, n_mat)
1415+
if (error .and. logic_option(.true., print_err)) then
1416+
call out_io(s_blank$, r_name, 'This at element: ' // ele_full_name(ele))
1417+
endif
14151418

14161419
end subroutine calc_bunch_params
14171420

bmad/space_charge/space_charge_mod.f90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,12 @@ subroutine sc_step(bunch, ele, include_image, t_end, sc_field, n_emit)
215215

216216
! Calculate space charge field
217217
if (space_charge_com%particle_sigma_cutoff > 0) then
218-
call calc_bunch_params(bunch, bunch_params, error, is_time_coords=.true., ele=ele)
219-
call sc_field_calc(bunch, ele%branch, include_image, t_end, sc_field, bunch_params)
218+
call calc_bunch_params(bunch, bunch_params, error, .false., is_time_coords=.true., ele=ele)
219+
if (error) then
220+
call sc_field_calc(bunch, ele%branch, include_image, t_end, sc_field)
221+
else
222+
call sc_field_calc(bunch, ele%branch, include_image, t_end, sc_field, bunch_params)
223+
endif
220224
else
221225
call sc_field_calc(bunch, ele%branch, include_image, t_end, sc_field)
222226
endif

tao/code/tao_show_this.f90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ subroutine tao_show_this (what, result_id, lines, nl)
293293
zb = -1
294294

295295
do
296-
call tao_next_switch (what2, [character(16):: '-universe'], .true., switch, err)
296+
call tao_next_switch (what2, [character(16):: '-universe', '-lattice', '-comb', '-z'], .true., switch, err)
297297
if (err) return
298298
if (switch == '') exit
299299

@@ -357,7 +357,7 @@ subroutine tao_show_this (what, result_id, lines, nl)
357357
return
358358
endif
359359

360-
if (what_to_show == '-comb' .and. ele_name == '') then
360+
if (what_to_show == '-comb' .and. ele_name == '') then ! -comb used without comb index.
361361
if (.not. allocated(tao_branch%bunch_params_comb)) then
362362
nl=nl+1; lines(nl) = 'Beam parameter comb not calculated (check comb_ds_save)'
363363
return
@@ -445,6 +445,9 @@ subroutine tao_show_this (what, result_id, lines, nl)
445445
nl=nl+1; write(lines(nl), amt) 'dump_at = ', quote(u%beam%dump_at)
446446
nl=nl+1; write(lines(nl), amt) 'dump_file = ', quote(u%beam%dump_file)
447447
nl=nl+1; write(lines(nl), rmt3) 'comb_ds_save = ', tao_branch%comb_ds_save, ' ! Note: -1 => Use (latice branch length)/plot_page%n_curve_pts'
448+
if (allocated(tao_branch%bunch_params_comb)) then
449+
nl=nl+1; write(lines(nl), amt) 'comb index range = [0, ', int_str(tao_branch%bunch_params_comb(1)%n_pt), ']'
450+
endif
448451
!!!! nl=nl+1; write(lines(nl), rmt) 'comb_max_ds_save = ', tao_branch%bunch_params_comb(1)%max_ds_save
449452
nl=nl+1; write(lines(nl), amt) 'track_start = ', quote(bb%track_start), ' ! ', ele_full_name(branch%ele(bb%ix_track_start))
450453
nl=nl+1; write(lines(nl), amt) 'track_end = ', quote(bb%track_end), ' ! ', ele_full_name(branch%ele(bb%ix_track_end))

tao/version/tao_version_mod.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
!-
77

88
module tao_version_mod
9-
character(*), parameter :: tao_version_date = "2024/12/22 21:46:37"
9+
character(*), parameter :: tao_version_date = "2025/01/07 00:41:27"
1010
end module

0 commit comments

Comments
 (0)