Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tracking of subset of particles filtered by energy range #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mattachu
Copy link
Contributor

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.

@mattachu
Copy link
Contributor Author

mattachu commented Mar 30, 2021

The first commit here (aafe992) is already in pull request #14, to reinstate the Doxygen-style comments.
This is included here so that the removed comments are not propagated into later pull requests.

@@ -21,7 +24,7 @@ module Rangerclass
!> find the range (minimum and maxium of a single bunch) and the centroid
!> of a single beam bunch.
!--------------------------------------------------------------------------------------
subroutine singlerange(partcls,nplc,nptot,range,center)
subroutine singlerange_standard(partcls,nplc,nptot,range,center)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

FlagEnergyRange = 1
filter_min = 95.0e6 ! eV
filter_max = 105.0e6 ! eV

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@@ -386,7 +390,7 @@ subroutine in2_Input(onblem,oblength,obnseg,obmpstp,&

end subroutine in2_Input

!> Input all parameters except beam line element parameters.
!> Input parameters for subsequent bunches.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to energy filtering, just clarifying the different subroutines in this module.

@qianglbl
Copy link
Collaborator

not sure about this modification. It looks like that the energy filter range was hard-wired in the code.

@mattachu
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants