Skip to content

Commit

Permalink
Added charge adjustment to track_a_foil.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan committed Sep 30, 2023
1 parent 68a014c commit f6eab35
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bmad/low_level/track_a_foil.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ subroutine track_a_foil (orbit, ele, param, mat6, make_matrix)
real(rp) x0, xx0, sigma, rnd(2), density, I_excite, mass_material, dE_dx, E0, E1, pc, p2, elec_density
real(rp), parameter :: S2 = 13.6e6_dp, epsilon = 0.088 ! Factor of 1e6 is due to original formula using MeV/c for momentum

integer i, material, z_material, z_part, n_step
integer i, n, material, z_material, z_part, n_step

logical, optional :: make_matrix

Expand Down Expand Up @@ -76,11 +76,16 @@ subroutine track_a_foil (orbit, ele, param, mat6, make_matrix)
dE_dx = -fourpi * mass_of(electron$) * elec_density * (z_part * r_e / orbit%beta)**2 * &
(log(2 * mass_of(electron$) * p2 / I_excite) - orbit%beta**2)
E0 = orbit%p0c * (1.0_rp + orbit%vec(6)) / orbit%beta
E1 = E0 - dE_dx * ele%value(thickness$) / n_step
E1 = E0 + dE_dx * ele%value(thickness$) / n_step
call convert_total_energy_to(E1, orbit%species, beta = orbit%beta, pc = pc)
orbit%vec(6) = (pc - orbit%p0c) / orbit%p0c
enddo

! Charge

n = nint(ele0%value(final_charge$))
orbit%species = set_species_charge(orbit%species, n)

!

if (logic_option(.false., make_matrix)) then
Expand Down

0 comments on commit f6eab35

Please sign in to comment.