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

coherent synchrotron radiation #23

Open
berceanu opened this issue May 2, 2023 · 9 comments
Open

coherent synchrotron radiation #23

berceanu opened this issue May 2, 2023 · 9 comments

Comments

@berceanu
Copy link
Contributor

berceanu commented May 2, 2023

Hi,
We're looking to check the code corectness for the coherent part of the synchrotron emission spectrum by comparing with the PIConGPU radiation plugin output for a simple LWFA setup.

Coh

While we get relatively good agreement for the incoherent part of the spectrum, the coherent part seems to be a global upward shift of the whole spectrum in the case of synchrad, while for PIConGPU, the coherent low-energy part actually has a different shape, as can be seen in the attached figure.

We used this code in the case of synchrad:

def main():
    """Main entry point."""
    args = cmdline_args()

    calc_input = {
        "grid": [
            (args.params["omega_min"], args.params["omega_max"]),
            (args.params["theta_min"], args.params["theta_max"]),
            (PHI_MIN, PHI_MAX),
            (N_OMEGA, N_THETA, N_PHI),
        ],
        "dtype": "double",
        "native": False,
        "ctx": "mpi",  # set your context to avoid being asked
    }

    calc = SynchRad(calc_input)
    calc.calculate_spectrum(
        file_tracks=args.infile,
        comp='cartesian_complex',
        file_spectrum=args.outfile,
    )


if __name__ == "__main__":
    main()

adapted from the Betatron_Example.ipynb.

@hightower8083
Copy link
Owner

hightower8083 commented May 9, 2023

Thanx for these interesting tests @berceanu -- we should definitely look into this, PoG is doing things a bit differently and handles particles shapes (you can fix macroparticle size with sigma_particle argument in synchrad)
Could you post details (inputs) of how exactly the particle tracks are obtained?

@berceanu
Copy link
Contributor Author

berceanu commented May 9, 2023

Hi @hightower8083 indeed, the radiation plugin implementation from PoG is described in some detail here.

Would you also require the PoG input files, or just the synchrad input and trajectory data?

@hightower8083
Copy link
Owner

inputs would already be helpful, and I suspect tracks data should be rather large. right now I'd like to understand why all spectrum in synchrad case is coherent -- in general that shouldn't be the case for a finite-size beam.

@berceanu
Copy link
Contributor Author

berceanu commented May 9, 2023

Hi @hightower8083 , in the interest of completeness and reproducibility, I am going to link here to the complete data set, including the PIConGPU input files and trajectories.

The total archive size is ~60 GB, so it should be download-able over a standard connection in about 20 minutes (tested on Chrome).

To extract, simply run:

tar -xf betatron.tar

PIConGPU particle data is under /simOutput/h5.

@berceanu
Copy link
Contributor Author

This might also be of interest for @PrometheusPi by the way, as he is the main person behind PIConGPU's radiation plugin.

@hightower8083
Copy link
Owner

hightower8083 commented May 11, 2023

Hi @hightower8083 , in the interest of completeness and reproducibility, I am going to link here to the complete data set, including the PoG input files and trajectories.

The total archive size is ~60 GB, so it should be download-able over a standard connection in about 20 minutes (tested on Chrome).

To extract, simply run:

tar -xf betatron.tar

Than you for the data @berceanu , though its a bit fat for a quick check. As I do not have much doubt on the PIC simulation itself, and I suspect something is happening as the data is passed to synchrad. Do you by chance have the tracks data extracted for the openpmd dataset which was used for synchrad ?

@berceanu
Copy link
Contributor Author

Of course @hightower8083 , here is a link to the extracted tracks. The y and z axes are already switched in this file, compared to the PoG convention.

Thanks again for taking the time to look at this!

@hightower8083
Copy link
Owner

hightower8083 commented May 17, 2023

hi @berceanu

I did some tests and found a couple problems:

  1. originally each track in the integral had its own time axis, that completely spoiled the coherency of particles contributions for the cases when tracks have difference starting time. This was indeed a bug which practically only appears for coherent calculation with PIC input, which is your case and its great that we have found it. Its fixed now
  2. strictly speaking, coherent summation of LW potentials is valid only for the physical particles, i.e. single electrons, and is much less for the case of macro-particles that present point-like ensembles of many particles. In PoG field sums are calculated over samples for each time-step and as far as i understand apply some particle shaping. In synchrad we treat track by track and I guess this makes on-flight smoothing of particles phase shapes more difficult.

While first issue is fixed, I'm still not sure which would be the best solution for the second problem. For an ideal case of all macro-particles emitting coherently the same field $A$ and each presenting some $N_{e/mp}$ electrons we obtain a correct scaling for the full energy $W\propto (N_{mp} N_{e/mp})^2 = N_e^2$, while for a fully incoherent situation we have $W\propto N_{mp} N_{e/mp}^2 = N_e N_{e/mp}\ggg N_e$, which is definitely incorrect (see left central panels in fig below).

  • one more or less "physical" way is to consider each macro-particle being an electron, i.e. all weights to be $N_{e/mp}=1$. This can be applied when dispersion of weight statistics is small.
  • another more artificial way is to replace $N_{e/mp}$ with $\sqrt{N_{e/mp}}$, which corresponds to the more or less correct incoherent sum of contributions and allows to keep some variability of the weights for the coherent sum.
  • alternative is to renormalized the weights to a "mean" or "max" value of the weights to imitate physical particles with some variability of contributions depending on their charges, but i'm not sure if it makes much physical sense

I've tried several cases and these solutions seems to give cleaner results though do not show much difference between them (see right panel in fig below).
syncrad_coh

I'm still puzzled why in the case of unity weights there is still an important difference in the incoherent region between coherent and incoherent mappers. In the simple betatron example case below (with unity weights) I see that mappers converge well in the incoherent region and the coherent peak corresponds to the one expected.
image

To conclude, for now I've implemented the correction $N_{e/mp}$ with $\sqrt{N_{e/mp}}$ in the mappers for complex fields, and also added in the calculate_spectrum method an option weights_normalize which can be ones to set all weights to 1, and either mean or max for corresponding re-normalizations. This is done in #25 which I'm going to merge soon, so let me know if you have any thoughts or comments.

@PrometheusPi
Copy link

The time issue that @hightower8083 found would definitely cause a significant issue.

I would not trust the coherent to incoherent transition from the ensemble average PIConGPU simulation, since this depends heavily on the assumed macro particle shape. (See https://doi.org/10.1016/j.nima.2018.02.020 for details.) But this does not explain why PIConGPU predicts such a high intensity at 1e-3 keV.

Without knowing many details of syncrad, I agree with @hightower8083 that the higher result of the coherent calculation compared to the incoherent calculation in the high frequency/incoherent region of the spectrum is strange.
@hightower8083 Do you apply some filters on the coherently calculated spectra to avoid coherent cancelation? I would have expected very strong oscillation between values above the incoherent spectrum and zero in the incoherent region. But the overall spectrum looks smooth.

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

No branches or pull requests

3 participants