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

Error while calculating d(S3/T)/dT at T_nucleation #29

Open abhijitsaha118 opened 3 years ago

abhijitsaha118 commented 3 years ago

Hi CL Wainwright,

I am using CosmoTransitions for the first time. The original code as framed by you is working well. However, I faced a particular issue which is defined below:

While I try to calculate the d(S3/T)/dT at T_nucleation, I add the following line in the testModel1.py file.

p = pd.fullTunneling([[286.39824899, 382.19727026], [231.1029627, -136.8226031]], m.Vtot([231.1029627, -136.8226031], 84.23+1e-03), m.gradV([231.1029627, -136.8226031], 84.23+1e-03))

in the following format:

pathDeformation.fullTunneling([ findMinimum( [(Low VeV), T=Tn+1e-03), findMinimum( (High VeV), T=Tn+1e-03)], Vtot(X,T=Tn+1e-03), gradV(X,T=Tn+1e-03))

The low VeV and high VeV array that I have considered here is taken from the output generated using your code for "#Low-T transition (first-order)" corresponding to "Tnuc: 84.2382008774623" (i.e low_vev : [286.39824899 382.19727026]; high_vev : [ 231.1029627 -136.8226031]).

I was considering to calculate dS3/dT in the following way:

dS3/dT ~ (S3(Tn+1e-3) - S3(Tn)) / 1e-3

While running I get the following error.

Traceback (most recent call last): File "testModel1_pb1.py", line 201, in p = pd.fullTunneling([[286.39824899, 382.19727026], [231.1029627, -136.8226031]], m.Vtot([231.1029627, -136.8226031], 84.23+1e-03), m.gradV([231.1029627, -136.8226031], 84.23+1e-03))

File "/home/aks/.local/lib/python2.7/site-packages/cosmoTransitions/pathDeformation.py", line 950, in fullTunneling extend_to_minima=True) File "/home/aks/.local/lib/python2.7/site-packages/cosmoTransitions/pathDeformation.py", line 759, in init xtol=1e-6, disp=0)[0] File "/home/aks/.local/lib/python2.7/site-packages/scipy/optimize/optimize.py", line 416, in fmin res = _minimize_neldermead(func, x0, args, callback=callback, *opts) File "/home/aks/.local/lib/python2.7/site-packages/scipy/optimize/optimize.py", line 559, in _minimize_neldermead fsim[k] = func(sim[k]) File "/home/aks/.local/lib/python2.7/site-packages/scipy/optimize/optimize.py", line 300, in function_wrapper return function((wrapper_args + args)) File "/home/aks/.local/lib/python2.7/site-packages/cosmoTransitions/pathDeformation.py", line 756, in V_lin def V_lin(x, p0, dp0, V): return V(p0+x*dp0) TypeError: 'numpy.float64' object is not callable

Separetely, I can obtain the Vtot(X,T=Tn+1e-03) and gradV(X,T=Tn+1e-03) succesfully for any X.

Could you give some direction on the above-mentioned error message, or is there any basic issue while I am trying to calculate the same using "pathDeformation.fullTunneling()". It'd also be helpful if you provide some insights on which output value (or, from where) we have to consider the "X".

gifstr commented 1 year ago

Hello,

Did you ever end up solving this issue?

I am trying to extend the code to get d(S3/T)/dT at Tnuc as well, but I keep getting the exact same error.

Thanks for the help

clwainwright commented 1 year ago

Hello! And sorry for being so negligent on replies to github issues in this repo.

In any case, from looking at the error message and @abhijitsaha118's code, it appears the error is due to the way the fullTunneling() function is called. It expects callables to be passed in as the second and third functions, whereas the above code executes the function before passing it to fullTunneling() so fullTunneling() just sees the resulting floating pointing return value. So instead of doing

x1 = findMinimum(low_vev, T=Tn+1e-03)
x2 = findMinimum(high_vev, T=Tn+1e-03)
pathDeformation.fullTunneling(
    [x1, x2],
    Vtot(x2, T=Tn+1e-03),
    gradV(x2, T=Tn+1e-03),
)

you should be doing

pathDeformation.fullTunneling(
    [x1, x2],
    lambda x: Vtot(x, T=Tn+1e-03),
    lambda x: gradV(x, T=Tn+1e-03),
)

or equivalently

from functools import partial

pathDeformation.fullTunneling(
    [x1, x2],
    partial(Vtot, T=Tn+1e-03),
    partial(gradV, T=Tn+1e-03),
)

The partial here just makes it so that the potential function, which is generally a function of temperature, gets turned into a function of the vev only with temperature fixed.

Hope that helps! Let me know if it fixes your problem.

doxtor6 commented 10 months ago

Hello! And sorry for being so negligent on replies to github issues in this repo.

In any case, from looking at the error message and @abhijitsaha118's code, it appears the error is due to the way the fullTunneling() function is called. It expects callables to be passed in as the second and third functions, whereas the above code executes the function before passing it to fullTunneling() so fullTunneling() just sees the resulting floating pointing return value. So instead of doing

x1 = findMinimum(low_vev, T=Tn+1e-03)
x2 = findMinimum(high_vev, T=Tn+1e-03)
pathDeformation.fullTunneling(
    [x1, x2],
    Vtot(x2, T=Tn+1e-03),
    gradV(x2, T=Tn+1e-03),
)

you should be doing

pathDeformation.fullTunneling(
    [x1, x2],
    lambda x: Vtot(x, T=Tn+1e-03),
    lambda x: gradV(x, T=Tn+1e-03),
)

or equivalently

from functools import partial

pathDeformation.fullTunneling(
    [x1, x2],
    partial(Vtot, T=Tn+1e-03),
    partial(gradV, T=Tn+1e-03),
)

The partial here just makes it so that the potential function, which is generally a function of temperature, gets turned into a function of the vev only with temperature fixed.

Hope that helps! Let me know if it fixes your problem.

It works. Very helpful! It would be great if you could update the dS_dT in repo.