WarpX
WarpX copied to clipboard
Alternative method of particle initialisation from a file
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
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.
This would great!
To guide the implementation:
- Here is how we read external fields from an openPMD file, and interpolate them to the grid: https://github.com/ECP-WarpX/WarpX/blob/e460e608a303b642023b2c8418bf5ae2ec64a5f5/Source/Initialization/WarpXInitData.cpp#L1329
- Here is how we read lasy profiles from an openPMD file, and interpolate them to the position of the laser antenna: https://github.com/ECP-WarpX/WarpX/blob/development/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp
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 thelasy
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
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
Implementation started in #4754. I'll try to spend some time on it next week to push it along for review.