clwainwright / CosmoTransitions

A package for analyzing finite or zero-temperature cosmological phase transitions driven by single or multiple scalar fields.
MIT License
25 stars 19 forks source link

Replacing scipy.optimize.fmin with scipy.optimize.fminbound in pathDeformation.fullTunneling #5

Closed andrewfowlie closed 7 years ago

andrewfowlie commented 7 years ago

The papers

https://arxiv.org/pdf/1310.4174.pdf https://arxiv.org/pdf/1208.1765.pdf

both suggest replacing scipy.optimize.fmin with scipy.optimize.fminbound in pathDeformation.fullTunneling. It is argued that this helps with shallow minima. I can't find the relevant calls in pathDeformation.fullTunneling. Perhaps the papers refer to an older version of the code?

clwainwright commented 7 years ago

It does indeed look like that was referring to the old version of CosmoTransitions (which you can download at Comput. Phys. Commun. 183 (2012)) before I migrated the code to github. In that code there was a fullTunneling class rather than a fullTunneling function, and the optimize.fmin calls were to find the minima of the 1-dimensional potential along the path. The corresponding code in the current version is in the class pathDeformation.SplinePath, which as part of its initialization finds the minima.

You could pretty easily replace the optimize.fmin calls in that class with optimize.fminbound, but you'd need to set some reasonable bounds first. The x that's being optimized is measured in the number of extra discrete points that need to be appended to the path to reach the minimum, so a reasonable bound would be, say, zero and the number of points already in the path.

There's a good chance that the newer code avoids the issue with optimize.fmin that was present in the original. My suggestion is to use the current version as is, but look out for situations where shallow minima are being skipped. If you run into a problem, then try tweaking the optimization. Also, if you do make changes, let me know what they are and what your test cases are and I'll try to get them incorporated into the package.

andrewfowlie commented 7 years ago

Thanks for your quick response.

andrewfowlie commented 7 years ago

BTW, I just pushed a C++ implementation of the thermal functions that might interest you

https://github.com/andrewfowlie/thermal_funcs

My tests suggest they are slightly faster than the Python ones inside CosmoTransitions, which are already pretty quick, depending on which technique you use to calculate them.

The C++ ones are also appear to be more reliable in the (somewhat physically uninteresting) region of y^2 << 0 for J_F(y^2) and J_B(y^2)