ECP-WarpX / WarpX

WarpX is an advanced electromagnetic & electrostatic Particle-In-Cell code.
https://ecp-warpx.github.io
Other
309 stars 195 forks source link

Field initialization not converging and beam transport noise in RZ PSATD #2938

Open nckwcq opened 2 years ago

nckwcq commented 2 years ago

Attached is the input script for a Gaussian beam transport in free space using RZ PSATD. The code cannot run with accuracy better than the following.

driver.initialize_self_fields = 1 driver.self_fields_required_precision = 5.e-2

With this setting, noises build up at later time steps.

beam-spectral-rz.txt

RemiLehe commented 2 years ago

Thanks for reporting this.

My guess is that the noise issue is probably unrelated to the self-field initialization, and is instead a problem of PSATD. Could you try to confirm (or infirm) this, by running the same simulation with driver.initialize_self_fields = 0 and checking whether you see the same type of noise?

nckwcq commented 2 years ago

Setting driver.initialize_self_fields = 0, noise remains if the same z BC (none) is used and disappears if z BC set to damped. The field initialization allows "none" BC in RZ PSATD, not other BC. See figures. none damped

nckwcq commented 2 years ago

Add link for field initialization noise. mar07.pptx

dpgrote commented 2 years ago

I ran the simulation (with the initialization turned off) and I do see the significant noise in the simulation. What I see is ripples flowing in from the upper end of the simulation. This is almost certainly due to leakage from the lower end of the simulation (since the PSATD solver is using periodic transforms). This is the purpose of the damped boundary conditions, to eliminate this leakage. So it seems that WarpX is working as expected and the correct thing to do is to use the damped boundary conditions.

RemiLehe commented 2 years ago

Thanks for checking this @dpgrote. I am guessing that the issue for @nckwcq is that the field initialization will abort when the boundary is damped (or pml by the way).

In general, this is because the amrex solver only supports Dirichlet, Neumann or periodic boundary conditions. However, instead of aborting for damped or pml, we could simply raise a warning and pass e.g. Neumann boundary conditions to the amrex solver in this case. @dpgrote Would this make sense?

RemiLehe commented 2 years ago

Btw, here is PR that is tangentially relevant https://github.com/ECP-WarpX/WarpX/pull/2514 It would probably need to be updated.

dpgrote commented 2 years ago

I found this same issue, that the initial Poisson solve does not work when damped boundary is set. I agree, in this case Neumann or Dirichlet should be used, though I don't think a warning is needed (since this behavior would be documented). This could be another configurable user option, adding a new input parameter specifying the BC to use for the initial Poisson solve.