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

Reconstruct full 3D fields from cylindrical simulation #232

Merged
merged 10 commits into from
May 21, 2019

Conversation

RemiLehe
Copy link
Member

@RemiLehe RemiLehe commented May 19, 2019

This allows openPMD-viewer to return a 3D cartesian array, from a file contains the thetaMode representation of the fields.
More specifically, ts.get_field will return a numpy 3darray (and corresponding info object) if the user passes theta=None (note that the default value for theta is 0)

This feature can be useful for postprocessing operations that are easier on a 3D cartesian grid (e.g. computing the total energy). One of the motivations of this PR is also to allow VisualPIC to work with cylindrical data (including 3D visualization of the fields).

Regarding the implementation:

  • I updated the functions that read the field in quasi-3D, to support theta=None.
  • I added an example in the tutorial notebook.
  • Note that right now, the function construct_3d_from_circ typically dominates the time to get the field. I tried to speed up this function using Cython (see this commit), but this made it 10x slower. I obviously did something wrong but I am not sure what. So in the end, this function remained in Python/Numpy in this PR.

@RemiLehe RemiLehe changed the title [WIP] Reconstruct full 3D fields from cylindrical simulation Reconstruct full 3D fields from cylindrical simulation May 20, 2019
@RemiLehe RemiLehe requested a review from soerenjalas May 20, 2019 15:53
F = cos * F_cos + sin * F_sin
F_total[Nr:, :] = F[:, :]
F_total[:Nr, :] = (-1) ** m * F[::-1, :]

Copy link
Member Author

Choose a reason for hiding this comment

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

The code below is unchanged (just reindented)

Copy link
Member

@soerenjalas soerenjalas left a comment

Choose a reason for hiding this comment

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

Wow this is pretty cool. In terms of API, I don't have a strong opinion. I think the theta=None option works. Even though, this in a way then might seem that this is the default behaviour.

@RemiLehe
Copy link
Member Author

Thanks for the feedback.
In fact this is doing nearest-grid-point interpolation (so not really an interpolation, as you noted). But I'll maybe replace it by linear interpolation in a separate PR.

@RemiLehe RemiLehe merged commit eb977d3 into openPMD:dev May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants