Skip to content

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

Open
mattachu wants to merge 3 commits intoimpact-lbl:masterfrom
mattachu:feature/filter-energy
Open

Allow tracking of subset of particles filtered by energy range#16
mattachu wants to merge 3 commits intoimpact-lbl:masterfrom
mattachu:feature/filter-energy

Conversation

@mattachu
Copy link
Copy Markdown
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
Copy Markdown
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.

!> of a single beam bunch.
!--------------------------------------------------------------------------------------
subroutine singlerange(partcls,nplc,nptot,range,center)
subroutine singlerange_standard(partcls,nplc,nptot,range,center)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

end subroutine in2_Input

!> Input all parameters except beam line element parameters.
!> Input parameters for subsequent bunches.
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@mattachu
Copy link
Copy Markdown
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