Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fb2a5f9
Added sigmasettings.out and twisslike.out to collimation_k2 test
vkbo Oct 8, 2019
d59ebf2
Removed the redundant loop for writing the sigmasettings ans twisslik…
vkbo Oct 8, 2019
b52b631
Updated sigmasettings and twisslike files as collimator order in the …
vkbo Oct 8, 2019
fb98553
Updated collimator not found warning for LHC and RHIC style naming
vkbo Oct 8, 2019
a0b6d22
Cleaned up formatting of twisslike.out and sigmasettings.out
vkbo Oct 8, 2019
3d55cbc
Merge branch 'coll_type' into coll_cleanup
vkbo Oct 8, 2019
8ee8101
Cleanup collimate_start
vkbo Oct 8, 2019
7d508d1
Remove unnecessary variables for rnlux
vkbo Oct 8, 2019
c0787cf
Moved all the arrays that depend on number of collimators to coll_db …
vkbo Oct 8, 2019
2594d82
Allocate all non-DB arrays depending on DB size in coll_common instead
vkbo Oct 8, 2019
f7927dd
The mux and muy arrays in collimation are not in use, so commenting t…
vkbo Oct 8, 2019
fcf8f9f
Clean up the alloc subroutines
vkbo Oct 8, 2019
bc0a84e
Variable cleanup
vkbo Oct 8, 2019
19f5ecf
Variable cleanup
vkbo Oct 8, 2019
eec4190
Variable cleanup ... again
vkbo Oct 8, 2019
cb079ce
The code at the end of collimate_end_turn is the same collimate_end_e…
vkbo Oct 8, 2019
2762e06
Lots of variable cleanup and moving to place they're used
vkbo Oct 8, 2019
58059c5
Merge branch 'coll_type' into coll_cleanup
vkbo Oct 8, 2019
45b75c2
Fix merge conflicts
vkbo Oct 10, 2019
87737fb
Merged twisslike and sigmasettings file, and moved the mingap check t…
vkbo Oct 10, 2019
4572b77
Moved the element stats calculation to a separate subroutine
vkbo Oct 10, 2019
67e0493
Kill the collimate_start routine
vkbo Oct 10, 2019
30b8069
Redundant firstrun = .false. in thin6d
vkbo Oct 11, 2019
f65e10a
Only allocate and compute the data for the amplitdue.dat file if it's…
vkbo Oct 11, 2019
9d3273c
Added dowrite_efficiency flag to collimation, and made this and the e…
vkbo Oct 11, 2019
f7b4864
No need to compute ix in collimation, just pass it from tracking
vkbo Oct 11, 2019
23254c3
Merge branch 'coll_tracks2' into coll_cleanup
vkbo Oct 11, 2019
df3d334
Updated tracks2 canonicals due to change in variable spacing
vkbo Oct 11, 2019
e93c6ca
Moved the writing of tracks2.dat to a separate subroutine
vkbo Oct 11, 2019
246f303
Moved writin of impacts and absorb files to a separate subroutine
vkbo Oct 11, 2019
288c1f5
Further cle3anup of logic in end_collimator
vkbo Oct 11, 2019
b97dfd2
Moved selected collimator code to a separate routine
vkbo Oct 11, 2019
a6edda0
Cleaned up some duplicate code and merged some loops
vkbo Oct 11, 2019
21b77a9
Updated formatting of impact.dat
vkbo Oct 11, 2019
7962cbc
Some minor cleanup in collimation exit routine
vkbo Oct 11, 2019
3830ab2
Cleaned up efficiency and some more routines, and fixed two bugs in e…
vkbo Oct 11, 2019
622c42a
Updated canonicals for bug in efficiency. On eff_y compared with 4.x,…
vkbo Oct 11, 2019
88672ef
Fix merge conflicts
vkbo Oct 15, 2019
1ce9f8d
Fix variable
vkbo Oct 15, 2019
47267db
Fixed merge conflicts
vkbo Oct 21, 2019
304adbc
Fixed segfault due to unallocated cry_proc array
vkbo Oct 21, 2019
ada46dd
Started cleaup of coll_doCollimator and moved halo code to separate r…
vkbo Oct 21, 2019
01c64b1
Moved the geant4 collimation code to a separate routine
vkbo Oct 21, 2019
9f302da
Cleanup of the main routines in tracking through collimators
vkbo Oct 21, 2019
952d4a5
Cleanup of main collimation routines
vkbo Oct 21, 2019
9dd933e
Some more module header cleanup
vkbo Oct 21, 2019
1a4fb27
Added parentheses and moved calculation of rotation out of loops
vkbo Oct 21, 2019
dd71791
Some final minor stuff
vkbo Oct 21, 2019
db0523b
Fixed merge conflicts
vkbo Oct 24, 2019
3fe649e
Fixed merge conflicts
vkbo Oct 24, 2019
8c6cdd8
Fix indent
vkbo Oct 24, 2019
58006a5
Ensure that the gap_rms_error array does not contain negative zero va…
vkbo Oct 25, 2019
7ad54d1
Fixed merge conflicts
vkbo Oct 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Variable cleanup
  • Loading branch information
vkbo committed Oct 8, 2019
commit bc0a84e70c4b6db4969cfa2213a6ad6155b571c0
208 changes: 112 additions & 96 deletions source/collimation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ module collimation
logical, private, save :: do_oneside = .false.
logical, private, save :: systilt_antisymm = .false.
logical, private, save :: do_mingap = .false.
logical, private, save :: firstcoll = .true.

integer, private, save :: icoll = 0
integer, private, save :: ie = 0
integer, private, save :: iturn = 0
integer, private, save :: icoll = 0
integer, private, save :: ie = 0
integer, private, save :: iturn = 0
integer, public, save :: myix = 0

! Distribution
integer, private, save :: do_thisdis = 0
Expand Down Expand Up @@ -97,74 +99,65 @@ module collimation
! variables for global inefficiencies studies
! of normalized and off-momentum halo
! Last modified: July 2016

real(kind=fPrec), allocatable, save :: neff(:) !(numeff)
real(kind=fPrec), allocatable, save :: rsig(:) !(numeff)

integer, allocatable, save :: counteddpop(:,:) !(npart,numeffdpop)
integer, allocatable, save :: npartdpop(:) !(numeffdpop)
integer, allocatable, save :: counted2d(:,:,:) !(npart,numeff,numeffdpop)
real(kind=fPrec), allocatable, save :: neffdpop(:) !(numeffdpop)
real(kind=fPrec), allocatable, save :: dpopbins(:) !(numeffdpop)

real(kind=fPrec) dpopmin,dpopmax,mydpop
real(kind=fPrec), allocatable, save :: neff2d(:,:) !(numeff,numeffdpop)

integer, allocatable, save :: nimpact(:) !(50)
real(kind=fPrec), allocatable, save :: sumimpact(:) !(50)
real(kind=fPrec), allocatable, save :: sqsumimpact(:) !(50)

integer, allocatable, save :: nampl(:) !(nblz)
real(kind=fPrec), allocatable, save :: sum_ax(:) !(nblz)
real(kind=fPrec), allocatable, save :: sqsum_ax(:) !(nblz)
real(kind=fPrec), allocatable, save :: sum_ay(:) !(nblz)
real(kind=fPrec), allocatable, save :: sqsum_ay(:) !(nblz)

real(kind=fPrec), allocatable, save :: neffx(:) !(numeff)
real(kind=fPrec), allocatable, save :: neffy(:) !(numeff)

integer, allocatable, save :: part_hit_before_pos(:) !(npart)
integer, allocatable, save :: part_hit_before_turn(:) !(npart)

real(kind=fPrec), allocatable, save :: part_indiv(:) !(npart)
real(kind=fPrec), allocatable, save :: part_linteract(:) !(npart)

integer, allocatable, save :: part_hit_pos(:) !(npart)
integer, allocatable, save :: part_hit_turn(:) !(npart)
integer, allocatable, save :: part_abs_pos(:) !(npart)
integer, allocatable, save :: part_abs_turn(:) !(npart)
integer, allocatable, save :: part_select(:) !(npart)
integer, allocatable, save :: nabs_type(:) !(npart)
integer, allocatable, save :: nhit_type(:) !(npart)
integer, save :: n_tot_absorbed
integer, save :: n_absorbed
integer, save :: nabs_total

real(kind=fPrec), allocatable, save :: part_impact(:) !(npart)

integer, save :: nsurvive, nsurvive_end, num_selhit, n_impact

integer, allocatable, save :: counted_r(:,:) !(npart,numeff)
integer, allocatable, save :: counted_x(:,:) !(npart,numeff)
integer, allocatable, save :: counted_y(:,:) !(npart,numeff)

character(len=4), save :: smpl
character(len=80), save :: pfile
integer, allocatable, private, save :: counteddpop(:,:) ! (npart,numeffdpop)
integer, allocatable, private, save :: npartdpop(:) ! (numeffdpop)
integer, allocatable, private, save :: counted2d(:,:,:) ! (npart,numeff,numeffdpop)
integer, allocatable, private, save :: counted_r(:,:) ! (npart,numeff)
integer, allocatable, private, save :: counted_x(:,:) ! (npart,numeff)
integer, allocatable, private, save :: counted_y(:,:) ! (npart,numeff)
real(kind=fPrec), allocatable, private, save :: neffx(:) ! (numeff)
real(kind=fPrec), allocatable, private, save :: neffy(:) ! (numeff)
real(kind=fPrec), allocatable, private, save :: neff(:) ! (numeff)
real(kind=fPrec), allocatable, private, save :: rsig(:) ! (numeff)
real(kind=fPrec), allocatable, private, save :: neffdpop(:) ! (numeffdpop)
real(kind=fPrec), allocatable, private, save :: dpopbins(:) ! (numeffdpop)
real(kind=fPrec), allocatable, private, save :: neff2d(:,:) ! (numeff,numeffdpop)
real(kind=fPrec), private, save :: dpopmin
real(kind=fPrec), private, save :: dpopmax
real(kind=fPrec), private, save :: mydpop


integer, allocatable, private, save :: nimpact(:) !(50)
real(kind=fPrec), allocatable, private, save :: sumimpact(:) !(50)
real(kind=fPrec), allocatable, private, save :: sqsumimpact(:) !(50)

! Arrays allocated to nblz
integer, allocatable, private, save :: nampl(:)
real(kind=fPrec), allocatable, private, save :: sum_ax(:)
real(kind=fPrec), allocatable, private, save :: sqsum_ax(:)
real(kind=fPrec), allocatable, private, save :: sum_ay(:)
real(kind=fPrec), allocatable, private, save :: sqsum_ay(:)

! Arrays allocated to npart
integer, allocatable, private, save :: part_hit_before_pos(:)
integer, allocatable, private, save :: part_hit_before_turn(:)
integer, allocatable, private, save :: part_hit_pos(:)
integer, allocatable, private, save :: part_hit_turn(:)
integer, allocatable, private, save :: part_abs_pos(:)
integer, allocatable, public, save :: part_abs_turn(:)
integer, allocatable, private, save :: part_select(:)
integer, allocatable, private, save :: nabs_type(:)
integer, allocatable, private, save :: nhit_type(:)
real(kind=fPrec), allocatable, private, save :: part_indiv(:)
real(kind=fPrec), allocatable, private, save :: part_linteract(:)
real(kind=fPrec), allocatable, private, save :: part_impact(:)
real(kind=fPrec), allocatable, private, save :: rcx0(:)
real(kind=fPrec), allocatable, private, save :: rcxp0(:)
real(kind=fPrec), allocatable, private, save :: rcy0(:)
real(kind=fPrec), allocatable, private, save :: rcyp0(:)
real(kind=fPrec), allocatable, private, save :: rcp0(:)

integer, private, save :: n_tot_absorbed = 0
integer, private, save :: n_absorbed = 0
integer, private, save :: nabs_total = 0
integer, private, save :: nsurvive = 0
integer, private, save :: nsurvive_end = 0
integer, private, save :: num_selhit = 0
integer, private, save :: n_impact = 0

! Variables for finding the collimator with the smallest gap
! and defining, stroring the gap rms error

character(len=mNameLen) :: coll_mingap2
real(kind=fPrec) :: nsig_err, sig_offset
real(kind=fPrec) :: mingap, gap_h1, gap_h2, gap_h3, gap_h4
integer :: coll_mingap_id

real(kind=fPrec), save :: remitx_dist,remity_dist,remitx_collgap,remity_collgap

logical, save :: firstcoll

integer, save :: myix

real(kind=fPrec), public :: nspx,nspy,mux0,muy0
real(kind=fPrec), private :: ax0,ay0,bx0,by0 ! These are set, but never used

Expand Down Expand Up @@ -201,11 +194,6 @@ module collimation
real(kind=fPrec), save :: c_tilt(2) !tilt in radian
character(len=4), save :: c_material !material

real(kind=fPrec), allocatable, private, save :: rcx0(:) !(npart)
real(kind=fPrec), allocatable, private, save :: rcxp0(:) !(npart)
real(kind=fPrec), allocatable, private, save :: rcy0(:) !(npart)
real(kind=fPrec), allocatable, private, save :: rcyp0(:) !(npart)
real(kind=fPrec), allocatable, private, save :: rcp0(:) !(npart)

real(kind=fPrec), private, save :: xj, xpj, yj, ypj, pj

Expand Down Expand Up @@ -324,6 +312,40 @@ subroutine collimation_expand_arrays(npart_new, nblz_new)

end subroutine collimation_expand_arrays

subroutine coll_shuffleLostPart

use mod_common
use mod_common_main

integer j, tnapx

tnapx = napx
do j=napx,1,-1
if(llostp(j) .eqv. .false.) cycle

part_hit_pos(j:tnapx) = cshift(part_hit_pos(j:tnapx), 1)
part_hit_turn(j:tnapx) = cshift(part_hit_turn(j:tnapx), 1)
part_abs_pos(j:tnapx) = cshift(part_abs_pos(j:tnapx), 1)
part_abs_turn(j:tnapx) = cshift(part_abs_turn(j:tnapx), 1)
part_select(j:tnapx) = cshift(part_select(j:tnapx), 1)
part_impact(j:tnapx) = cshift(part_impact(j:tnapx), 1)
part_indiv(j:tnapx) = cshift(part_indiv(j:tnapx), 1)
part_linteract(j:tnapx) = cshift(part_linteract(j:tnapx), 1)
part_hit_before_pos(j:tnapx) = cshift(part_hit_before_pos(j:tnapx), 1)
part_hit_before_turn(j:tnapx) = cshift(part_hit_before_turn(j:tnapx), 1)

nabs_type(j:tnapx) = cshift(nabs_type(j:tnapx), 1)
nhit_type(j:tnapx) = cshift(nhit_type(j:tnapx), 1)

counted_r(j:tnapx,:) = cshift(counted_r(j:tnapx,:), 1, 1)
counted_x(j:tnapx,:) = cshift(counted_x(j:tnapx,:), 1, 1)
counted_y(j:tnapx,:) = cshift(counted_y(j:tnapx,:), 1, 1)

tnapx = tnapx - 1
end do

end subroutine coll_shuffleLostPart

! ================================================================================================ !
! Collimation Init
! This routine is called once at the start of the simulation and can be used to do any initial
Expand Down Expand Up @@ -402,17 +424,17 @@ subroutine collimate_init
write(lout,"(a,e15.8)") 'COLL> Info: Orbitxp0 [mrad] = ', torbxp(1)
write(lout,"(a,e15.8)") 'COLL> Info: Orbity0 [mm] = ', torby(1)
write(lout,"(a,e15.8)") 'COLL> Info: Orbitpy0 [mrad] = ', torbyp(1)
write(lout,"(a,e15.8)") 'COLL> Info: Emitx0_dist [um] = ', remitx_dist
write(lout,"(a,e15.8)") 'COLL> Info: Emity0_dist [um] = ', remity_dist
write(lout,"(a,e15.8)") 'COLL> Info: Emitx0_collgap [um] = ', remitx_collgap
write(lout,"(a,e15.8)") 'COLL> Info: Emity0_collgap [um] = ', remity_collgap
write(lout,"(a,e15.8)") 'COLL> Info: Emitx0_dist [um] = ', emitnx0_dist*gammar
write(lout,"(a,e15.8)") 'COLL> Info: Emity0_dist [um] = ', emitny0_dist*gammar
write(lout,"(a,e15.8)") 'COLL> Info: Emitx0_collgap [um] = ', emitnx0_collgap*gammar
write(lout,"(a,e15.8)") 'COLL> Info: Emity0_collgap [um] = ', emitny0_collgap*gammar
write(lout,"(a,e15.8)") 'COLL> Info: E0 [MeV] = ', e0
write(lout,"(a)")

myemitx0_dist = remitx_dist*c1m6
myemity0_dist = remity_dist*c1m6
myemitx0_collgap = remitx_collgap*c1m6
myemity0_collgap = remity_collgap*c1m6
myemitx0_dist = emitnx0_dist*gammar*c1m6
myemity0_dist = emitny0_dist*gammar*c1m6
myemitx0_collgap = emitnx0_collgap*gammar*c1m6
myemity0_collgap = emitny0_collgap*gammar*c1m6

myalphax = talphax(1)
myalphay = talphay(1)
Expand Down Expand Up @@ -1355,11 +1377,6 @@ subroutine collimate_postInput(gammar)

call collimation_expand_arrays(npart,nblz)

remitx_dist = emitnx0_dist*gammar
remity_dist = emitny0_dist*gammar
remitx_collgap = emitnx0_collgap*gammar
remity_collgap = emitny0_collgap*gammar

if(myenom == zero) then
write(lerr,"(a)") "COLL> ERROR Beam energy cannot be zero"
call prror
Expand Down Expand Up @@ -1548,8 +1565,9 @@ subroutine collimate_start
use string_tools
use mathlib_bouncer

integer i,j
real(kind=fPrec) dummy
integer i, j, coll_mingap_id
real(kind=fPrec) dummy, nsig_err, sig_offset, mingap, gap_h1, gap_h2, gap_h3, gap_h4
character(len=mNameLen) coll_mingap

! Initialisation
do i=1,numeff
Expand All @@ -1561,8 +1579,6 @@ subroutine collimate_start
dpopbins(i) = real(i-1,fPrec)*4.0e-4_fPrec
end do

firstcoll = .true.

#ifdef BEAMGAS
call beamGasInit(myenom)
#endif
Expand Down Expand Up @@ -1681,37 +1697,37 @@ subroutine collimate_start
if((gap_h1 + sig_offset) <= mingap) then
mingap = gap_h1 + sig_offset
coll_mingap_id = i
coll_mingap2 = cdb_cName(i)
coll_mingap = cdb_cName(i)
else if((gap_h2 + sig_offset) <= mingap) then
mingap = gap_h2 + sig_offset
coll_mingap_id = i
coll_mingap2 = cdb_cName(i)
coll_mingap = cdb_cName(i)
else if((gap_h3 - sig_offset) <= mingap) then
mingap = gap_h3 - sig_offset
coll_mingap_id = i
coll_mingap2 = cdb_cName(i)
coll_mingap = cdb_cName(i)
else if((gap_h4 - sig_offset) <= mingap) then
mingap = gap_h4 - sig_offset
coll_mingap_id = i
coll_mingap2 = cdb_cName(i)
coll_mingap = cdb_cName(i)
end if
end if
end do

write(coll_twissLikeUnit,"(a)") ""
write(coll_twissLikeUnit,"(a)") "# INFO"
write(coll_twissLikeUnit,"(a)") "# MinGap Collimator: '"//trim(coll_mingap2)//"'"
write(coll_twissLikeUnit,"(a)") "# MinGap Collimator: '"//trim(coll_mingap)//"'"
write(coll_twissLikeUnit,"(a,i0)") "# MinGap Coll ID: ",coll_mingap_id
write(coll_twissLikeUnit,"(a,f0.6)") "# Min Gap Sigma: ",mingap
write(coll_twissLikeUnit,"(a,i0)") "# Pencil Initial: ",ipencil

write(coll_sigmaSetUnit, "(a)") ""
write(coll_sigmaSetUnit, "(a)") "# INFO"
write(coll_sigmaSetUnit, "(a)") "# MinGap Collimator: '"//trim(coll_mingap2)//"'"
write(coll_sigmaSetUnit, "(a)") "# MinGap Collimator: '"//trim(coll_mingap)//"'"
write(coll_sigmaSetUnit, "(a,i0)") "# MinGap Coll ID: ",coll_mingap_id
write(coll_sigmaSetUnit, "(a,f0.6)") "# Min Gap Sigma: ",mingap
write(coll_sigmaSetUnit, "(a,i0)") "# Pencil Initial: ",ipencil

! if pencil beam is used and on collimator with smallest gap the
! distribution should be generated, set ipencil to coll_mingap_id
if(ipencil > 0 .and. do_mingap) then
Expand Down
25 changes: 1 addition & 24 deletions source/mainarrays.f90
Original file line number Diff line number Diff line change
Expand Up @@ -266,30 +266,7 @@ subroutine shuffleLostParticles

! Collimation
if(do_coll) then
tnapx = napx
do j=napx,1,-1
if(llostp(j) .eqv. .false.) cycle

part_hit_pos(j:tnapx) = cshift(part_hit_pos(j:tnapx), 1)
part_hit_turn(j:tnapx) = cshift(part_hit_turn(j:tnapx), 1)
part_abs_pos(j:tnapx) = cshift(part_abs_pos(j:tnapx), 1)
part_abs_turn(j:tnapx) = cshift(part_abs_turn(j:tnapx), 1)
part_select(j:tnapx) = cshift(part_select(j:tnapx), 1)
part_impact(j:tnapx) = cshift(part_impact(j:tnapx), 1)
part_indiv(j:tnapx) = cshift(part_indiv(j:tnapx), 1)
part_linteract(j:tnapx) = cshift(part_linteract(j:tnapx), 1)
part_hit_before_pos(j:tnapx) = cshift(part_hit_before_pos(j:tnapx), 1)
part_hit_before_turn(j:tnapx) = cshift(part_hit_before_turn(j:tnapx), 1)

nabs_type(j:tnapx) = cshift(nabs_type(j:tnapx), 1)
nhit_type(j:tnapx) = cshift(nhit_type(j:tnapx), 1)

counted_r(j:tnapx,:) = cshift(counted_r(j:tnapx,:), 1, 1)
counted_x(j:tnapx,:) = cshift(counted_x(j:tnapx,:), 1, 1)
counted_y(j:tnapx,:) = cshift(counted_y(j:tnapx,:), 1, 1)

tnapx = tnapx - 1
end do
call coll_shuffleLostPart
end if

#ifdef FLUKA
Expand Down