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

Sensitivity to number of points in straight line guess between vacua #6

Closed andrewfowlie closed 6 years ago

andrewfowlie commented 7 years ago

Hi,

I was testing the path deformation algorithm for various 1d potentials. I am parametrising my potentials such that the true and false vacua are always at 1 and 0. I noticed that in rare cases whether it succeeds is sensitive to the number of points I use in my guess of the solution (n_points below). If this is too small, I see

cosmoTransitions.tunneling1D.PotentialError: ('Minimization is placing the top of the potential barrier outside of the interval defined by phi_bar and phi_metaMin. Assume that the barrier does not exist.', 'no barrier')

Of course, increasing n_points is rather easy, but maybe something is wrong with the code here, I'm not sure.

"""
Path deformation from CT
========================
"""

from cosmoTransitions.pathDeformation import fullTunneling as path_deform
import numpy as np

# Make potential

alpha = 0.719387755102
E = -1.

def V(f):
    """
    :returns: 1d potential
    """
    return E * ((4. * alpha - 3.) / 2. * f**2 + f**3 - alpha * f**4)

def dV(f):
    """
    :returns: Derivative of 1d potential
    """
    return E *((4. * alpha - 3.) * f + 3. * f**2 - 4. * alpha * f**3)

# This number fails

# cosmoTransitions.tunneling1D.PotentialError: 
# ('Minimization is placing the top of the potential barrier outside of the interval 
# defined by phi_bar and phi_metaMin. Assume that the barrier does not exist.', 'no barrier')

n_points = 100 

# This one works

# n_points = 1000

guess_phi = np.linspace(1., 0., n_points)
guess_phi = np.reshape(guess_phi, (len(guess_phi), 1))

profile_1d, phi, action = path_deform(guess_phi, V, dV)[:3]

print "action = {}".format(action)
print "phi(r=0) = {}".format(phi[0])
print "r0 = {}".format(profile_1d.R[0])
clwainwright commented 7 years ago

It looks like there was a problem with the optimization function in SingleFieldInstanton.findRScale(). Replacing the optimize.fmin with optimize.fminbound seems to have fixed it, although I'm not sure why exactly changing the number of points in the fitted potential should have made a difference. In any case, the change is pushed to the develop branch. Try it out and let me know if you have any problems before I merge it into master.

andrewfowlie commented 7 years ago

Thanks, that's fixed it for me. I've added a PR with tests of path deformation for the 1d and 2d potentials - https://github.com/clwainwright/CosmoTransitions/pull/7 - should add the above problematic case to it as well.

andrewfowlie commented 6 years ago

Hi Clarence, I never found any problems with this fix (https://github.com/clwainwright/CosmoTransitions/commit/222bb9faeef534323bcf8ca280fe024c8a121837). Can it be merged to master?

clwainwright commented 6 years ago

Merged, and did a bump up to v2.0.3. I'll update the version on PyPI in minute.

(Who's Clarence?)

andrewfowlie commented 6 years ago

Thanks for this, and I'm very sorry for calling you Clarence.