Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@syoffe
Copy link
Contributor

@syoffe syoffe commented May 17, 2021

This PR passes the user-defined plasma extent (p_zmin and p_zmax) on to the Particles and ContinuousInjector classes. The values passed currently have been modified to within the initial domain. This change allows the continuous injector to check whether the loading region is within the plasma extent before creating particles that are eventually ignored due to having zero weight. This can save a lot of time for short plasma species with many particles per cell.

…ousInjector objects. This prevents the ContinuousInjector from creating particles when the loading region is outside the plasma extent.
Copy link
Member

@RemiLehe RemiLehe left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!
It seems that some tests are not passing ; I suggest a change which might fix that (hopefully).

fbpic/particles/injection/continuous_injection.py Outdated Show resolved Hide resolved
@syoffe
Copy link
Contributor Author

syoffe commented May 17, 2021

Hi Remi,

I had to modify tests/test_linear_wakefield.py to increase p_zmax. Plasma was previously defined for 39e-6 < z < 41e-6, but since zmax = 40e-6 the plasma extent is only used for the initial loading in the full domain. The continuous injector doesn't check, and so continued loading never-ending plasma as the window moved. The above PR does now check the plasma extent, and so only loaded 2 microns of plasma then vacuum again, so the assert comparisons for the wakefield were bound to fail.

I have reverted to this implementation (which exploits short-circuit evaluation):

Npz = 0 if (self.p_extent is not None and len(self.p_extent)>1 \
            and (zmax < self.p_extent[0] or zmin > self.p_extent[1])) \
        else self.nz_inject

but I would be happy to split it into nested if statements if preferred.

@syoffe syoffe requested a review from RemiLehe May 17, 2021 20:35
@RemiLehe
Copy link
Member

RemiLehe commented Jun 5, 2021

Sorry for the very late review!
After looking at the code more closely, I think that this would require some small modifications in order to work properly in the boosted frame and/or with a moving plasma.
I will modify the PR accordingly in the next few days.

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.