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

Magnetic field in TrackParticle and ParticleBinning diagnostics #717

Closed
egelfer opened this issue May 14, 2024 · 21 comments
Closed

Magnetic field in TrackParticle and ParticleBinning diagnostics #717

egelfer opened this issue May 14, 2024 · 21 comments
Labels
documentation related to the included doc

Comments

@egelfer
Copy link

egelfer commented May 14, 2024

Hi! It seems that TrackParticle and ParticleBinning diagnostics output the magnetic field, which is half step shifted (both in space and time) from the particle. Is it possible to shift it back? Or maybe at least it would make sense to point it out in the documentation?

@egelfer egelfer added the bug label May 14, 2024
@egelfer egelfer changed the title Magnetic field in TracParticle and ParticleBinning diagnostics Magnetic field in TrackParticle and ParticleBinning diagnostics May 14, 2024
@Z10Frank Z10Frank added documentation related to the included doc and removed bug labels May 14, 2024
@mccoys
Copy link
Contributor

mccoys commented May 25, 2024

Just a precision: the magnetic field is shifted by half a timestep compared to its value from Field diagnostics. Right? Is this what you meant?

@egelfer
Copy link
Author

egelfer commented May 28, 2024

Not exactly. It is shifted by half a timestep and half a spatial step. In particular, if particle moves along x direction inside the plane wave, which is propagating in -x direction, then the vector of the transverse magnetic field (B_y,B_z) in TrackParticles/ParticleBinning diagnotics is rotated by the angle phi=timestep*(1+v_x)/2

@mccoys
Copy link
Contributor

mccoys commented May 28, 2024

I don't understand how there could be a spatial shift. Is it due because of the wave displacement during that half timestep?

@egelfer
Copy link
Author

egelfer commented May 28, 2024

I think it is due to the particle displacement during the half timestep, since there is the term timestep*v_x/2

@mccoys
Copy link
Contributor

mccoys commented May 28, 2024

But what do you compare it with? The field diagnostic? If yes, i believe those are not properly aligned (by half a cell) in happi

@egelfer
Copy link
Author

egelfer commented May 28, 2024

No, actually I calculate the longitudinal component of the Lorentz force ([v x B]_x, for circular polarization it is also the ponderomotive force), and I know that (at least for rare plasma) the integral over time of it should be equal to zero. It is zero ideed after the rotation I described above.

@mccoys
Copy link
Contributor

mccoys commented May 29, 2024

@egelfer Could you try your test using the option keep_interpolated_fields? It probably changes the results as the interpolated fields are calculated at the correct time with this option.

@egelfer
Copy link
Author

egelfer commented May 29, 2024

Actually I used the option keep_interpolated_fields=["Ex","Ey","Ez","Bx","By","Bz"]. Do you want me to run the test without it?

@mccoys
Copy link
Contributor

mccoys commented May 29, 2024

yes that would be good.

Now your result is puzzling. Those fields are supposed to be exactly those calculated for pushing particles

@egelfer
Copy link
Author

egelfer commented May 29, 2024

Yes, I also assumed it and was very much surprized :)

@mccoys
Copy link
Contributor

mccoys commented May 29, 2024

Ah well in fact I forgot that the magnetic field is interpolated at integer timesteps while the velocity is known at half-integer timesteps

image

Thus the shift?

@egelfer
Copy link
Author

egelfer commented May 29, 2024

Yes, I suppose that might be the source of the shift

@mccoys
Copy link
Contributor

mccoys commented May 30, 2024

Did you manage to test without keep_interpolated_fields?

@mccoys
Copy link
Contributor

mccoys commented May 31, 2024

Did you test without keep_interpolated_fields?

@mccoys
Copy link
Contributor

mccoys commented Jun 3, 2024

I made some changes in the documentation in branch develop. Please reopen if necessary

@mccoys mccoys closed this as completed Jun 3, 2024
@egelfer
Copy link
Author

egelfer commented Jun 5, 2024

Did you test without keep_interpolated_fields?

Sorry, I forgot to answer. In this case the simulation crushes.

I also wanted to ask, is it possible to output the magnetic field in a way similar to when the force acting on a field is calculated (https://smileipic.github.io/Smilei/Understand/algorithms.html#the-pic-loop), i.e. (B_p^{(n+1/2)}+B_p^{(n-1/2)})/2 ? Unfortunately my method to recover the correct field is valid only for a plane wave, and it is not always the case.

@mccoys
Copy link
Contributor

mccoys commented Jun 5, 2024

keep_interpolated_fields exactly retain the value of the fields that were obtained during interpolation. So you should have the force exactly.

@egelfer
Copy link
Author

egelfer commented Jun 6, 2024

That's what I assumed! :) But it is not, what I've got. Here is the plot of average longitudinal momentum (darkred, obtained from the ParticleBinning diag) in the collision of electron-positron bunch with a pulse plane wave. Magenta curve corresponds to the integral of the (averaged over the particles) force F_x= [v x B]_x+E_x with the E and B fields obtained from TrackParticles diag. Orange curve corresponds to the integral of F_x'= [v x B']_x+E_x, where B' is B shifted by a half step. However, as I wrote above, it works only for a plane wave field.

image

@mccoys
Copy link
Contributor

mccoys commented Jun 6, 2024

Are you using the velocity from tracked particles as well? As the fields and velocities differ by half a timestep that might be the problem

@egelfer
Copy link
Author

egelfer commented Jun 6, 2024

Yes, the velocities are taken from TrackParticles diag as well

@mccoys
Copy link
Contributor

mccoys commented Jun 6, 2024

Well then there you have it. It is not the fields that are out of phase. It's the velocities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation related to the included doc
Projects
None yet
Development

No branches or pull requests

3 participants