Skip to content

Commit

Permalink
Merge pull request #553 from bmad-sim/devel/step23
Browse files Browse the repository at this point in the history
Update modes_ri to modes_6d where appropriate.
  • Loading branch information
DavidSagan committed Oct 7, 2023
2 parents 67d23af + bdaa9ce commit 676a043
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 42 deletions.
26 changes: 13 additions & 13 deletions tao/code/tao_data_and_eval_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,15 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid
case ('apparent_emit.x', 'norm_apparent_emit.x')
do i = ix_start, ix_ele
if (data_source == 'lat') then
value_vec(i) = tao_lat_emit_calc (x_plane$, apparent_emit$, branch%ele(i), tao_branch%modes_ri)
value_vec(i) = tao_lat_emit_calc (x_plane$, apparent_emit$, branch%ele(i), tao_branch%modes_6d)
else
value_vec(i) = tao_beam_emit_calc (x_plane$, apparent_emit$, branch%ele(i), bunch_params(i))
endif
enddo

if (ix_ref > -1) then
if (data_source == 'lat') then
value_vec(ix_ref) = tao_lat_emit_calc (x_plane$, apparent_emit$, branch%ele(ix_ref), tao_branch%modes_ri)
value_vec(ix_ref) = tao_lat_emit_calc (x_plane$, apparent_emit$, branch%ele(ix_ref), tao_branch%modes_6d)
else
value_vec(ix_ref) = tao_beam_emit_calc (x_plane$, apparent_emit$, branch%ele(i), bunch_params(ix_ref))
endif
Expand All @@ -747,15 +747,15 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid
case ('apparent_emit.y', 'norm_apparent_emit.y')
do i = ix_start, ix_ele
if (data_source == 'lat') then
value_vec(i) = tao_lat_emit_calc (y_plane$, apparent_emit$, branch%ele(i), tao_branch%modes_ri)
value_vec(i) = tao_lat_emit_calc (y_plane$, apparent_emit$, branch%ele(i), tao_branch%modes_6d)
else
value_vec(i) = tao_beam_emit_calc (y_plane$, apparent_emit$, branch%ele(i), bunch_params(i))
endif
enddo

if (ix_ref > -1) then
if (data_source == 'lat') then
value_vec(ix_ref) = tao_lat_emit_calc (y_plane$, apparent_emit$, branch%ele(ix_ref), tao_branch%modes_ri)
value_vec(ix_ref) = tao_lat_emit_calc (y_plane$, apparent_emit$, branch%ele(ix_ref), tao_branch%modes_6d)
call tao_load_this_datum (value_vec, ele_ref, ele_start, ele, datum_value, valid_value, datum, branch, why_invalid)
else
value_vec(ix_ref) = tao_beam_emit_calc (y_plane$, apparent_emit$, branch%ele(i), bunch_params(ix_ref))
Expand Down Expand Up @@ -1300,15 +1300,15 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid
select case (data_type)

case ('damp.j_a')
datum_value = tao_branch%modes_ri%a%j_damp
datum_value = tao_branch%modes_6d%a%j_damp
valid_value = .true.

case ('damp.j_b')
datum_value = tao_branch%modes_ri%b%j_damp
datum_value = tao_branch%modes_6d%b%j_damp
valid_value = .true.

case ('damp.j_z')
datum_value = tao_branch%modes_ri%z%j_damp
datum_value = tao_branch%modes_6d%z%j_damp
valid_value = .true.

case default
Expand Down Expand Up @@ -1488,10 +1488,10 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid
case ('emit.x', 'norm_emit.x')
if (data_source == 'lat') then
do i = ix_start, ix_ele
value_vec(i) = tao_lat_emit_calc (x_plane$, projected_emit$, branch%ele(i), tao_branch%modes_ri)
value_vec(i) = tao_lat_emit_calc (x_plane$, projected_emit$, branch%ele(i), tao_branch%modes_6d)
enddo
if (ix_ref > -1) then
value_vec(ix_ref) = tao_lat_emit_calc (x_plane$, projected_emit$, branch%ele(ix_ref), tao_branch%modes_ri)
value_vec(ix_ref) = tao_lat_emit_calc (x_plane$, projected_emit$, branch%ele(ix_ref), tao_branch%modes_6d)
endif
call tao_load_this_datum (value_vec, ele_ref, ele_start, ele, datum_value, valid_value, datum, branch, why_invalid)
elseif (data_source == 'beam') then
Expand All @@ -1503,10 +1503,10 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid
case ('emit.y', 'norm_emit.y')
if (data_source == 'lat') then
do i = ix_start, ix_ele
value_vec(i) = tao_lat_emit_calc (y_plane$, projected_emit$, branch%ele(i), tao_branch%modes_ri)
value_vec(i) = tao_lat_emit_calc (y_plane$, projected_emit$, branch%ele(i), tao_branch%modes_6d)
enddo
if (ix_ref > -1) then
value_vec(ix_ref) = tao_lat_emit_calc (y_plane$, projected_emit$, branch%ele(ix_ref), tao_branch%modes_ri)
value_vec(ix_ref) = tao_lat_emit_calc (y_plane$, projected_emit$, branch%ele(ix_ref), tao_branch%modes_6d)
endif
call tao_load_this_datum (value_vec, ele_ref, ele_start, ele, datum_value, valid_value, datum, branch, why_invalid)
elseif (data_source == 'beam') then
Expand Down Expand Up @@ -1536,7 +1536,7 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid
ele_ref, ele_start, ele, datum_value, valid_value, datum, branch, why_invalid)
datum_value = datum_value / gamma
else
datum_value = tao_branch%modes_ri%a%emittance
datum_value = tao_branch%modes_6d%a%emittance
valid_value = .true.
endif
elseif (data_source == 'beam') then
Expand All @@ -1557,7 +1557,7 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid
ele_ref, ele_start, ele, datum_value, valid_value, datum, branch, why_invalid)
datum_value = datum_value / gamma
else
datum_value = tao_branch%modes_ri%b%emittance
datum_value = tao_branch%modes_6d%b%emittance
valid_value = .true.
endif
elseif (data_source == 'beam') then
Expand Down
8 changes: 4 additions & 4 deletions tao/code/tao_graph_setup_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2537,14 +2537,14 @@ subroutine this_value_at_s (data_type_select, sub_data_type, value, good1, ok, i
if (curve%data_source == 'beam') then
value = tao_beam_emit_calc (x_plane$, apparent_emit$, ele, bunch_params)
else
value = tao_lat_emit_calc (x_plane$, apparent_emit$, ele, tao_branch%modes_ri)
value = tao_lat_emit_calc (x_plane$, apparent_emit$, ele, tao_branch%modes_6d)
endif
if (data_type_select(1:4) == 'norm') value = value * ele%value(E_tot$) / mass_of(branch%param%particle)
case ('apparent_emit.y', 'norm_apparent_emit.y')
if (curve%data_source == 'beam') then
value = tao_beam_emit_calc (y_plane$, apparent_emit$, ele, bunch_params)
else
value = tao_lat_emit_calc (y_plane$, apparent_emit$, ele, tao_branch%modes_ri)
value = tao_lat_emit_calc (y_plane$, apparent_emit$, ele, tao_branch%modes_6d)
endif
if (data_type_select(1:4) == 'norm') value = value * ele%value(E_tot$) / mass_of(branch%param%particle)
case default
Expand All @@ -2569,14 +2569,14 @@ subroutine this_value_at_s (data_type_select, sub_data_type, value, good1, ok, i
if (curve%data_source == 'beam') then
value = bunch_params%x%emit
else
value = tao_lat_emit_calc (x_plane$, projected_emit$, ele, tao_branch%modes_ri)
value = tao_lat_emit_calc (x_plane$, projected_emit$, ele, tao_branch%modes_6d)
endif
if (data_type_select(1:4) == 'norm') value = value * ele%value(E_tot$) / mass_of(branch%param%particle)
case ('emit.y', 'norm_emit.y')
if (curve%data_source == 'beam') then
value = bunch_params%y%emit
else
value = tao_lat_emit_calc (y_plane$, projected_emit$, ele, tao_branch%modes_ri)
value = tao_lat_emit_calc (y_plane$, projected_emit$, ele, tao_branch%modes_6d)
endif
if (data_type_select(1:4) == 'norm') value = value * ele%value(E_tot$) / mass_of(branch%param%particle)
case default
Expand Down
10 changes: 2 additions & 8 deletions tao/code/tao_lattice_calc_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,7 @@ subroutine tao_single_track (tao_lat, calc_ok, ix_branch, print_err)

if (branch%param%particle /= photon$ .and. s%global%rad_int_calc_on .and. tao_branch%track_state == moving_forward$ .and. &
(s%com%force_rad_int_calc .or. u%calc%rad_int_for_data .or. u%calc%rad_int_for_plotting .or. s%global%track_type == 'beam')) then
call radiation_integrals (tao_lat%lat, tao_branch%orbit, &
tao_branch%modes_ri, tao_branch%ix_rad_int_cache, ix_branch, tao_lat%rad_int)
if (branch%param%geometry == closed$) then
tao_lat%high_e_lat = u%model%lat
ele => tao_lat%high_e_lat%branch(ix_branch)%ele(0)
call emit_6d(ele, .true., tao_branch%modes_6d, sigma)
endif
call emit_6d(branch%ele(0), .true., tao_branch%modes_ri, sigma)
endif

end subroutine tao_single_track
Expand Down Expand Up @@ -884,7 +878,7 @@ subroutine tao_inject_beam (u, model, ix_branch, beam, init_ok)
endif

if (bb%init_starting_distribution .or. u%beam%always_reinit) then
call init_beam_distribution (ele0, branch%param, bb%beam_init, beam, err, tao_branch%modes_ri)
call init_beam_distribution (ele0, branch%param, bb%beam_init, beam, err, tao_branch%modes_6d)
if (err) then
call out_io (s_error$, r_name, 'BEAM_INIT INITIAL BEAM PROPERTIES NOT PROPERLY SET FOR UNIVERSE: ' // int_str(u%ix_uni))
return
Expand Down
32 changes: 16 additions & 16 deletions tao/code/tao_python_cmd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ subroutine tao_python_cmd (input_str)
use tao_dmerit_mod, only: tao_dmodel_dvar_calc
use tao_input_struct, only: tao_ele_shape_input, tao_ele_shape_input_to_struct
use opti_de_mod, only: opti_de_param

use rad_6d_mod, only: emit_6d

implicit none

Expand Down Expand Up @@ -6311,7 +6311,7 @@ subroutine tao_python_cmd (input_str)
pz = tao_branch%orbit(0)%vec(6), ix_branch = branch%ix_branch)
call calc_z_tune(branch)
call radiation_integrals (branch%lat, tao_branch%orbit, tao_branch%modes_ri, tao_branch%ix_rad_int_cache, branch%ix_branch)

call emit_6d(branch%ele(0), .true., tao_branch%modes_ri, mat6)
n = branch%n_ele_track
time1 = branch%ele(n)%ref_time
gamma = branch%ele(0)%value(e_tot$) / mass_of(branch%param%particle)
Expand All @@ -6323,20 +6323,20 @@ subroutine tao_python_cmd (input_str)
nl=incr(nl); write (li(nl), rmt) 'Q_spin;REAL;F;', branch%param%spin_tune/twopi
nl=incr(nl); write (li(nl), rmt) 'chrom_a;REAL;F;', tao_branch%a%chrom
nl=incr(nl); write (li(nl), rmt) 'chrom_b;REAL;F;', tao_branch%b%chrom
nl=incr(nl); write (li(nl), rmt) 'J_damp_a;REAL;F;', tao_branch%modes_ri%a%j_damp
nl=incr(nl); write (li(nl), rmt) 'J_damp_b;REAL;F;', tao_branch%modes_ri%b%j_damp
nl=incr(nl); write (li(nl), rmt) 'J_damp_z;REAL;F;', tao_branch%modes_ri%z%j_damp
nl=incr(nl); write (li(nl), rmt) 'emit_a;REAL;F;', tao_branch%modes_ri%a%emittance
nl=incr(nl); write (li(nl), rmt) 'emit_b;REAL;F;', tao_branch%modes_ri%b%emittance
nl=incr(nl); write (li(nl), rmt) 'alpha_damp_a;REAL;F;', tao_branch%modes_ri%a%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'alpha_damp_b;REAL;F;', tao_branch%modes_ri%b%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'alpha_damp_z;REAL;F;', tao_branch%modes_ri%z%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'damping_time_a;REAL;F;', time1/tao_branch%modes_ri%a%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'damping_time_b;REAL;F;', time1/tao_branch%modes_ri%b%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'damping_time_z;REAL;F;', time1/tao_branch%modes_ri%z%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'sigE_E;REAL;F;', tao_branch%modes_ri%sigE_E
nl=incr(nl); write (li(nl), rmt) 'sig_z;REAL;F;', tao_branch%modes_ri%sig_z
nl=incr(nl); write (li(nl), rmt) 'energy_loss;REAL;F;', tao_branch%modes_ri%e_loss
nl=incr(nl); write (li(nl), rmt) 'J_damp_a;REAL;F;', tao_branch%modes_6d%a%j_damp
nl=incr(nl); write (li(nl), rmt) 'J_damp_b;REAL;F;', tao_branch%modes_6d%b%j_damp
nl=incr(nl); write (li(nl), rmt) 'J_damp_z;REAL;F;', tao_branch%modes_6d%z%j_damp
nl=incr(nl); write (li(nl), rmt) 'emit_a;REAL;F;', tao_branch%modes_6d%a%emittance
nl=incr(nl); write (li(nl), rmt) 'emit_b;REAL;F;', tao_branch%modes_6d%b%emittance
nl=incr(nl); write (li(nl), rmt) 'alpha_damp_a;REAL;F;', tao_branch%modes_6d%a%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'alpha_damp_b;REAL;F;', tao_branch%modes_6d%b%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'alpha_damp_z;REAL;F;', tao_branch%modes_6d%z%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'damping_time_a;REAL;F;', time1/tao_branch%modes_6d%a%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'damping_time_b;REAL;F;', time1/tao_branch%modes_6d%b%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'damping_time_z;REAL;F;', time1/tao_branch%modes_6d%z%alpha_damp
nl=incr(nl); write (li(nl), rmt) 'sigE_E;REAL;F;', tao_branch%modes_6d%sigE_E
nl=incr(nl); write (li(nl), rmt) 'sig_z;REAL;F;', tao_branch%modes_6d%sig_z
nl=incr(nl); write (li(nl), rmt) 'energy_loss;REAL;F;', tao_branch%modes_6d%e_loss
nl=incr(nl); write (li(nl), rmt) 'I0;REAL;F;', tao_branch%modes_ri%synch_int(0)
nl=incr(nl); write (li(nl), rmt) 'I1;REAL;F;', tao_branch%modes_ri%synch_int(1)
nl=incr(nl); write (li(nl), rmt) 'I2;REAL;F;', tao_branch%modes_ri%synch_int(2)
Expand Down
2 changes: 1 addition & 1 deletion tao/version/tao_version_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
!-

module tao_version_mod
character(*), parameter :: tao_version_date = "2023/10/05 21:18:41"
character(*), parameter :: tao_version_date = "2023/10/06 18:11:34"
end module

0 comments on commit 676a043

Please sign in to comment.