-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add synchrotron emission in turbulent magnetic field #135
Comments
@tibaldo - that would be quite useful! I already have working code that implements Kelner et al. 2013, but its is quite slow at the moment. If you want to give it a go you could use it as a starting point: This could also be a good opportunity to see how we can refactor the |
@zblz the code was very useful! I managed to reduce the time for the calculation of the spectrum by ~40% by invoking cbrt only once in Gtilda cb = cbrt(x)
gt1 = 1.808 * cb / np.sqrt(1 + 3.4 * cb ** 2.)
gt2 = 1 + 2.210 * cb ** 2. + 0.347 * cb ** 4.
gt3 = 1 + 1.353 * cb ** 2. + 0.217 * cb ** 4.
return gt1 * (gt2 / gt3) * np.exp(-x) Original code (based on your snippet)
modified code with the tweak described above
Do you feel like this makes it fast enough? I did not find any other places where the calculation can be made faster. |
That's brilliant, should probably add that modification to the regular It will probably never be a super fast calculation, as it has to do quite a lot of work anyway, but I was thinking being a bit more clever about the integration over the magnetic field spectrum could reduce the number of single-B synchrotron computations needed. |
@zblz Okay, I'll look more into the integration scheme, so far I have found that a large-number of single B computations (> 100) is needed for a power-law B distribution in order to get accurate results. |
Yes, doing a first PR with the With the code from the snippet my experience was similar, at least a 100 points in the B spectrum need to be evaluated to avoid the final spectrum being too different from an analytical calculation. However, each of these 100 spectra is very similar to the adjacent ones, so it feels like some interpolation should be possible before the integration if a lower number of single-B spectra are computed. I have not actually tested any of this so it might be completely wrong. |
See example Kelner, Aharonian, Khangulyan 2013 ApJ 774:61 Sec 4.
Options could be power-law turbulence spectrum or tabulated values for the magnetic field PDF.
I will branch and give it a go.
The text was updated successfully, but these errors were encountered: