samoylv / WPG

WPG: WavePropaGator, Interactive framework for X-ray FEL optics design and simulations.
Other
26 stars 20 forks source link

wpg.generators.build_gauss_wavefront yields wrong radius of curvature #133

Open CFGrote opened 3 years ago

CFGrote commented 3 years ago

I use wpg.generators.build_gauss_wavefront() to setup a Gaussian wavefront 100 m from the source position. E.g.:

>>> srwl_wf = build_gauss_wavefront(400, 400, 12,
                                        8.0,
                                        -30e-6, 30e-6,
                                        -30e-6, 30e-6,
                                        1.4e-15,
                                        5e-6, 5e-6,
                                        100,
                                        pulseEn=2e-15,
                                        pulseRange=8.)

Then I query for the radius of curvatures:

>>> srwl_wf.Rx
100

>>> srwl_wf.Ry
100

To my knowledge, it should be Rx = z * sqrt( 1 + ( z_Rx / z )^2 ) and likewise for Ry (z_R being the Rayleigh length). Cf here: https://www.rp-photonics.com/gaussian_beams.html.

I guess the current implementation is valid for the limit z >> z_R but z/z_R would have to be of the 10 to make this approximation accurate on the 1% level. Not sure this would be true in all applications.

rafaelcelestre commented 3 years ago

Hello @CFGrote,

in the SRW, from the available propagators:

[ 3]: Type of Free-Space Propagator:

    0- Standard Fresnel
    1- Fresnel with the analytical treatment of the quadratic (leading) phase terms
    2- Similar to 1, yet with different processing near a waist
    3- For propagation from a waist over a ~large distance
    4- For propagation over some distance to a waist

only propagators 1 and 2 make use of the radius of curvature on its calculations, as described in Memory and CPU efficient computation of the Fresnel free-space propagator in Fourier optics simulations.

In this paper, we show that removing the curvature of the wavefront eases the sampling requirements for wavefront propagation. Removing a R very near to the exact one also does the job. In fact, there are some conditions (when propagating to the focal plane were L=-R in Eq. 11) where intentionally the removed curvature is near, but not exactly the same.

I agree with you on your point about Gaussian beams and the radii of curvature, however, on the standard SRW, this value being exat or just near it will not affect the simulation results. However, if srwl_wf.Rx and srwl_wf.Ry are used somewhere else 9user input), this may be problematic, indeed.

Having said that, I would propose you add an ideal lens at the position you are calculating the wavefront with f=-srwl_wf.Rx and check the resulting wavefront phase radius of curvature. You should have something converging to a plane wave, where srwl_wf.Rx and srwl_wf.Ry go to 1e23.

Maybe Oleg could say more about how Rx and Ry are calculated, but I think the calculation is done for an unwrapped phase-cut along x=0 and y=0 and a subsequent fit to it.

Cheers, Rafael