ECP-WarpX / WarpX

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

How do we handle photons with zero momentum? #367

Open lucafedeli88 opened 5 years ago

lucafedeli88 commented 5 years ago

At present the code crashes if photons with zero initial momentum are initialized. I noticed this bug writing a unit test:

max_step = 50
amr.n_cell = 64 64 64
amr.max_level = 0
amr.blocking_factor = 8
amr.max_grid_size = 8
amr.plot_int = 1
geometry.coord_sys   = 0
geometry.is_periodic = 1 1 1
geometry.prob_lo = -0.5e-6 -0.5e-6 -0.5e-6
geometry.prob_hi = 0.5e-6 0.5e-6 0.5e-6
warpx.do_pml = 0
algo.charge_deposition = standard
algo.field_gathering = standard
warpx.cfl = 1.0

max_step = 50
amr.n_cell = 64 64 64
amr.max_level = 0
amr.blocking_factor = 8
amr.max_grid_size = 8
amr.plot_int = 1
geometry.coord_sys   = 0
geometry.is_periodic = 1 1 1
geometry.prob_lo     = -0.5e-6 -0.5e-6 -0.5e-6
geometry.prob_hi     = 0.5e-6 0.5e-6 0.5e-6
warpx.do_pml = 0
algo.charge_deposition = standard
algo.field_gathering = standard
warpx.cfl = 1.0

particles.nspecies = 1
particles.species_names = p_0
particles.photon_species = p_0

p_0.charge = -q_e
p_0.mass = m_e
p_0.injection_style = "SingleParticle"
p_0.single_particle_pos = 0.0 0.0 0.0
p_0.single_particle_vel = 0.0 0.0 0.0  # gamma*beta
p_0.single_particle_weight = 1.0

This is due to the fact that the photon pusher contains the following line:

const amrex::Real c_over_umod = PhysConst::c/std::sqrt(ux*ux + uy*uy + uz*uz);

which is infinity if normalized momenta are 0. This is not a big issue, since photons with zero momentum won't be generated by the QED modules. However, should we include a check in the pusher to return immediately if ux*ux + uy*uy + uz*uz ==0 ?

MaxThevenet commented 5 years ago

I think the issue here is that photons should be pushed with a velocity, not a momentum... We plan some refactoring on particle handling at some point, this could be included there. Yes I think we can implement the solution you propose. Otherwise we need something general enough to cover all injection types, and both at init and for continuous injection, which would require more changes.

ax3l commented 5 years ago

I think a photon momentum is physically also well defined.

We should just define a specific pusher for them, always moving them at c without respect for the momentum. And we might want to define their momentum properly?