Allow tracking of subset of particles filtered by energy range#16
Allow tracking of subset of particles filtered by energy range#16mattachu wants to merge 3 commits intoimpact-lbl:masterfrom
Conversation
These were inadvertently removed in commit bcc5e0a
| !> of a single beam bunch. | ||
| !-------------------------------------------------------------------------------------- | ||
| subroutine singlerange(partcls,nplc,nptot,range,center) | ||
| subroutine singlerange_standard(partcls,nplc,nptot,range,center) |
There was a problem hiding this comment.
The singlerange subroutine has not been modified apart from being renamed.
The new functionality is all in the new singlerange_filtered subroutine.
| !> of a single beam bunch, filtering for a certain momentum range. | ||
| !-------------------------------------------------------------------------------------- | ||
| subroutine singlerange_filtered(partcls,nplc,nptot,range,center,& | ||
| fmin, fmax, frange, fcenter, fnptot) |
There was a problem hiding this comment.
The new subroutine contains all the same code as the original subroutine, but with additional ranges and particle counts calculated for the particles filtered by energy range.
The results for singlerange_filtered(partcls,nplc,nptot,range,center,…) should match exactly the results for singlerange_standard(partcls,nplc,nptot,range,center), but also return the additional values fmin, fmax, frange, fcenter, fnptot.
src/Contrl/AccSimulator.f90
Outdated
| FlagEnergyRange = 1 | ||
| filter_min = 95.0e6 ! eV | ||
| filter_max = 105.0e6 ! eV | ||
|
|
There was a problem hiding this comment.
The reading of values from input file is in the next commit.
| ptrange,sgcenter) | ||
| if(FlagEnergyRange == 1) then | ||
| fmin = sqrt((1.0d0 + filter_min/Ebunch(ib)%mass)**2 - 1.0d0) | ||
| fmax = sqrt((1.0d0 + filter_max/Ebunch(ib)%mass)**2 - 1.0d0) |
There was a problem hiding this comment.
This converts the energy range to a momentum range.
| distance = zcent*Scxlt | ||
| dzz = sqrt(1.0d0-1.0d0/gammazavg**2)*Clight*dtless*Dt | ||
| if(FlagEnergyRange == 1) then | ||
| call globalrange(frange, fgrange, fgammaz, fzcent, fnp, ibunch) |
There was a problem hiding this comment.
Main values grange, gammazavg, zcent are not modified, here we use globalrange() to calculate new filtered values just for the purpose of setting distance and zzz
| end subroutine in2_Input | ||
|
|
||
| !> Input all parameters except beam line element parameters. | ||
| !> Input parameters for subsequent bunches. |
There was a problem hiding this comment.
Not related to energy filtering, just clarifying the different subroutines in this module.
|
not sure about this modification. It looks like that the energy filter range was hard-wired in the code. |
It was, but it no longer is. I worked on this feature in two stages, so in commit a572779 the range was hard-coded, but in commit 4781d70 this hard-coded range is removed and the range is read from the input file. If you squash the two commits, the hard-coded range will not be there any more. Perhaps I should have done this before submitting the pull request. |
For beamlines with wide energy spread, such as laser-driven accelerators, it is helpful to be able to base output on a smaller energy range.
This pull request adds extra options to the input file to set a flag to switch on the filtering and define the lower and upper bounds of the target energy range.
Then the distance travelled by the bunch is calculated based on the filtered range rather than the full range of particles.