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

Alternative method of particle initialisation from a file #3948

Open
PhysicsDan opened this issue May 29, 2023 · 4 comments · May be fixed by #4754
Open

Alternative method of particle initialisation from a file #3948

PhysicsDan opened this issue May 29, 2023 · 4 comments · May be fixed by #4754
Labels
component: core Core WarpX functionality component: openPMD openPMD I/O good first issue Good for newcomers

Comments

@PhysicsDan
Copy link
Contributor

PhysicsDan commented May 29, 2023

Hello,
I have a feature suggestion. I have initialised macro particles from an external openPMD file so that I can use the output of a hydrodynamic input as my starting conditions. This method has worked well however requires conversion of particle number density mesh into macroparticles.

An alternative to this could be supplying the number density as an openPMD mesh and then specifying a variable such as total_macro_particle_number to initialise the particles or a second mesh containing the particle per cell number.

This may be a simpler method for users to create custom targets that can't be easily created using an analytical function.

Thanks,
Daniel

@ax3l ax3l added component: openPMD openPMD I/O component: core Core WarpX functionality labels May 30, 2023
@ax3l
Copy link
Member

ax3l commented May 30, 2023

Hi Daniel,

Thanks for the suggestion, that would be super useful!

CCing @aeriforme, she suggested this recently, too. X-ref #618 Using openPMD files for the density profile (and maybe also temperature maps) would be ideal.

@ax3l ax3l added the good first issue Good for newcomers label May 30, 2023
@RemiLehe
Copy link
Member

RemiLehe commented Dec 20, 2023

This would great!

To guide the implementation:

Some features that we would like to have:

  • The dimensionality of the openPMD file does not need to match the dimensionality for which WarpX was compiled. For instance, WarpX 3D Cartesian should be able to read a density profile saved in thetaMode format and vice-versa. (We already have this feature when reading the lasy files.)

Steps:

  • Produce an openPMD file that represents density and temperature on a grid, for testing
  • Implementing reading from that file: we would create a new density injector. The file would be read at initialization + copied into device memory, and then the getDensity function would interpolate from this file.
  • This could maybe be abstracted with a new class that has method for reading the file, updating the cached chunk, a then interpolate from the data.
  • Implement caching/chunking: every time we move the window (or run in the boosted-frame): refresh the chunk of the file that gets loaded from the file. We should call a function update at every time step, with the current extent of the simulation box. We would load the density for each box, so that this works for load-balancing.
  • As a second pass: Reduce code duplication between reading external fields, lasy, density

@PhysicsDan
Copy link
Contributor Author

Hi Reme,

What would be really nice is if the particle per cell could also be read from an openPMD file.

I would expect that people using this feature would be either for a) preplasma formation or b) some nanostructured foams, where it would be advantageous not to have lots of low weight macroparticles due to a constant 'ppc' setting.

Cheers,
Daniel

@ax3l
Copy link
Member

ax3l commented May 24, 2024

Implementation started in #4754.
I'll try to spend some time on it next week to push it along for review.

@ax3l ax3l linked a pull request Jun 5, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core Core WarpX functionality component: openPMD openPMD I/O good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants