ComputationalRadiationPhysics / clara2

Clara2 - a parallel classical radiation calculator based on Liénard-Wiechert potentials
GNU General Public License v3.0
13 stars 9 forks source link

Radiation bandwidth #106

Closed ad210 closed 5 years ago

ad210 commented 5 years ago

I am attempting to simulate undulator radiation using Clara but instead of getting a continuous spectrum, I am seeing sharp peaks. I've simulated a few undulators and have found that the peaks occur at the expected frequency but the bandwidth isn't matching the expected behavior. I tried to reproduce Fig. 5.7 in the thesis with the undulator parameters gamma = 100, λ = 800 nm, K = 3.7E-5. I produced these plots using the plotRadiation tool included for 10 and 50 periods.

n10 n50

Would you know what may be causing the issue with the spread?

Thank you

PrometheusPi commented 5 years ago

Hi @ad210 welcome to Clara2,

Could it be that you have a well resolved time step but only trajectories containing the 10 or 50 oscillation periods and nothing else (before and/or after) and additionally a large number of frequencies that resolve the spectra insetting.hpp very fine? https://github.com/ComputationalRadiationPhysics/clara2/blob/fa2f51fc89dc7af446cab63084c94e8070ee7b3a/src/settings.hpp#L26-L28

This would cause a high Nyquist frequency while having only a few sample points in the above frequency range.

omega_Nyquist [omega_undulator] = (pi / delta_t) / (2 * pi / undulator_period) 
                                = number_of_sample_points_per_period / 2 

# in case only oscillation periods are covered by the trajectory:
frequency_resolution [omega_undulator] = 2 * Omega_Nyquist / number_of_total_sample_points 
                                       = 1 / number_of_periods 

This is a simplification of the limiting signal theory governing the radiation calculation. It becomes more complex with retarded time but is a good estimate for the undulator case.

As you can see the frequency resolution is fixed and can not be improved if only the 10 or 50 oscillation periods are considered. A common method to avoid this is to apply a so called zero padding to the trajectory by adding regions without radiation (constant velocity and thus zero acceleration and radiation) to the beginning or end of the trajectory.

Clara2 assumes by default that your spectral resolution from the FFT algorithm is better than what you request in settings.param and thus used an integrating method to compute the spectra for the requested frequency range: https://github.com/ComputationalRadiationPhysics/clara2/blob/fa2f51fc89dc7af446cab63084c94e8070ee7b3a/src/single_direction.cpp#L132-L134

If the trajectory contains only the 10 or 50 oscillation periods, but omega_max / N_spectrum is smaller than 1/10 or 1/50 of the undulator frequency, the frequency values in between are set to zero.

This can be avoided by either

Did this answer help you? Did zero padding provided better results?

ad210 commented 5 years ago

Thank you for your response. I added more padding before and after the undulator and I am getting a much better spectrum.

PrometheusPi commented 5 years ago

Great to hear that zero passing helped. I will close the issue. Feel free to open another issue if you encounter other questions, problems, or concerns. I will try to answer as soon as possible. However, this is an old project of mine which I am not working a lot on anymore, thus answering and fixing issues might take some days. (it s even worse with implementing new features).

Your problem brought me to the idea that zero padding could be handled by Clara2 directly. I added an issue (#107) for this.

Feel free to let me know if you are interested in not only using the Clara2 code but also develop it further. Developers (and users) are always welcome!