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

add method to radiation python module to load distributed amplitudes #4752

Conversation

PrometheusPi
Copy link
Member

This pull request adds a new method to the radiation plugin python module to load all distributed radiation amplitudes if available.

@PrometheusPi PrometheusPi added component: plugin in PIConGPU plugin component: tools scripts, python libs and CMake CI:no-compile CI is skipping compile/runtime tests but runs PICMI tests labels Nov 24, 2023
@PrometheusPi PrometheusPi added this to the 0.8.0 / Next stable milestone Nov 24, 2023
@PrometheusPi
Copy link
Member Author

Code has been tested.

for i, direction in enumerate(["x", "y", "z"]):
tmp = h_distAmp[direction][:, :, :]
self.rad_series.flush()
distAmp[:, :, :, i] = tmp
Copy link
Contributor

Choose a reason for hiding this comment

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

distAmp[:, :, :, i] is a non-contiguous memory slice, right? If not, you could load directly into that buffer, but otherwise the current implementation with an intermediate load buffer is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. As a physicist I would prefer keeping the polarization as my last component - but this is simply due to common convention. I agree with you that directly writing into a chunk of continuous memory would be more elegant and also easier to read.
I will change the memory layout according to your suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that it's okay to have a different memory layout than on the disk. I just wanted to confirm that I interpreted this correctly; probably a short comment is all that's needed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay - then I will just a comment. Thanks for the feeback @franzpoeschel.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could, of course, use fancy numpy methods to do so, e.g., create your array such that you can load contiguously and afterwards do a np.moveaxis() or .transpose() or the like.

@PrometheusPi PrometheusPi marked this pull request as draft November 27, 2023 10:17
@PrometheusPi PrometheusPi marked this pull request as ready for review November 27, 2023 10:47
@steindev steindev added the changelog PR's marked with this label will be added to the changelog label Jan 19, 2024
@steindev
Copy link
Member

steindev commented Feb 1, 2024

ping @PrometheusPi

@psychocoderHPC
Copy link
Member

@PrometheusPi please rebase against dev branch because pre commits has changed and check now python code too

@chillenzer
Copy link
Contributor

Steering things up...

@psychocoderHPC psychocoderHPC marked this pull request as draft June 27, 2024 13:23
@psychocoderHPC
Copy link
Member

@PrometheusPi is this PR still of interest?

@PrometheusPi
Copy link
Member Author

Yes, I will update it now

@PrometheusPi
Copy link
Member Author

I will not be able to work on this PR until #5105 is merged.

@PrometheusPi PrometheusPi force-pushed the add_distrRad_toPythonModule branch 2 times, most recently from e26dcc1 to 7dc8d12 Compare September 12, 2024 10:44
@PrometheusPi PrometheusPi marked this pull request as ready for review September 12, 2024 10:44
@PrometheusPi
Copy link
Member Author

@steindev @psychocoderHPC @ikbuibui ready for review

# get shape of distributed amplitude
shapeDistAmp = h_distAmp["x"].shape
# add 3 vector components
shapeDistAmp.append(3)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the magic number 3? Maybe a named constant would be nice.

Copy link
Member Author

Choose a reason for hiding this comment

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

3 is for the 3 spacial dimensions
Since there is no const uint in python, I personally favor using literals instead.
What would you prefer here to make clear that is a never changing value?

Copy link
Member Author

Choose a reason for hiding this comment

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

@chillenzer I used a class variable to make the global scope of that 3 clear. Is this in agreement with what you wanted?

@steindev
Copy link
Member

I am fine with the changes. Would you please squash (and rebase, if necessary)? I guess @chillenzer's comment is resolved as well. Then I will merge.

@PrometheusPi
Copy link
Member Author

@steindev squashed to 2 commites

@steindev steindev merged commit 5563163 into ComputationalRadiationPhysics:dev Sep 24, 2024
9 checks passed
@PrometheusPi PrometheusPi deleted the add_distrRad_toPythonModule branch September 24, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog PR's marked with this label will be added to the changelog CI:no-compile CI is skipping compile/runtime tests but runs PICMI tests component: plugin in PIConGPU plugin component: tools scripts, python libs and CMake
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants