Exemplo n.º 1
0
import math
import sys
############################################################################################################################################

############################################################################################################################################

# if using an integrated environment we recommend restarting the python console after running this script to make sure updates are found 

location = "/Users/david/Dropbox/PyTransportDist/PyTransport/" # this should be the location of the PyTransport folder

sys.path.append(location)  # we add this location to the python path

import PyTransSetup  # the above commands allows python to find the PyTransSetup module and import it

############################################################################################################################################

### Sets potential and compiles PyTransport, users may prefer to do this only once in a separate file (or comment after running below once) ###
### Restart the python kernel after running this file

nF=2
nP=5
f=sym.symarray('f',nF)
p=sym.symarray('p',nP)
V= 1./2. * p[0]**2 * f[0]**2 + 1/2.*p[1]**2 * sym.cos(p[2]/2.)**2*(f[1] - (f[0]-p[3])*sym.tan(p[2]/math.pi*sym.atan(p[4]*(f[0]-p[3]))))**2

PyTransSetup.potential(V,nF,nP) # writes this potential into c file when run

PyTransSetup.compileName("LH") # this compiles the module with the new potential and places it in the location folder, and adds this folder to the path ready for use
############################################################################################################################################

Exemplo n.º 2
0
from pylab import *  # contains some useful stuff for plotting
import time  # imports a package that allows us to see how long processes take
import math  # imports math package
import numpy as np # imports numpu package as np for short
import sys  # imports sys package for sue below
############################################################################################################################################

#This file contains simple examples of using the PyTransCurve
#It assumes the CurveSetup file has been run to install a double quadratic version of PyTransport
#It is recommended you restart the kernel before running this file to insure any updates to PyTransCurve are imported

location = "/Users/david/Dropbox/PyTransportDist/PyTransport/" # this should be the location of the PyTransport folder folder
sys.path.append(location) # sets up python path to give access to PyTransSetup

import PyTransSetup
PyTransSetup.pathSet()  # this adds the other paths that PyTransport uses to the python path

import PyTransCurve as PyT  # import module as PyT 
                             # using a generic name PyT means the file can be more easily reused for a different example (once field values 
                             # etc are altered)
import PyTransScripts as PyS  # import the scripts module as PyS for convenience

###########################################################################################################################################
# Example 
########################### set some field values and field derivatives in cosmic time ####################################################
omega = pi/30.0
R0 = np.sqrt(10.0**(-10)/3.0) / (omega *np.sqrt(10.0**(-9)))

fields = np.array([-R0, (1e-2)*R0]) # we set up a numpy array which contains the values of the fields

nP=PyT.nP()   # the .np function gets the number of parameters needed for the potential -- this can be used as a useful crosscheck
Exemplo n.º 3
0
import math  # imports math package
import numpy as np # imports numpu package as np for short
import sys  # imports sys package for sue below
############################################################################################################################################


############################################################################################################################################
#This file contains simple examples of using the PyTransDQuad 
#It assumes the DQuadSetup file has been run to install a double quadratic version of PyTransport
#It is recommended you restart the kernel before running this file to insure any updates to PyTransDQuad are imported

location = "/home/jwr/Code/PyTransport/" # this should be the location of the PyTransport folder 
sys.path.append(location) # sets up python path to give access to PyTransSetup

import PyTransSetup
PyTransSetup.pathSet()  # this sets the other paths that PyTransport uses

import PyTransDQuad as PyT  # import module as PyT (PyTransDQuad is quite long to type each time and it saves time to use a shorter name
                             # using a generic name PyT means the file can be more easily reused for a different example (once field values 
                             # etc are altered)
import PyTransScripts as PyS  # import the scripts module as PyS for convenience
###########################################################################################################################################


########################### set up initial conditions for background run ##################################################################
fields = np.array([12.0, 12.0]) # we set up a numpy array which contains the values of the fields

nP=PyT.nP()   # the .nP() function gets the number of parameters needed for the potential -- this can be used as a useful crosscheck
pvalue = np.zeros(nP) 
pvalue[0]=10.0**(-5.0); pvalue[1]=9.0*10.0**(-5) # we set up numpy array which contains values of the parameters
Exemplo n.º 4
0
####################################### Setup file for the Quartic Axion non-canonical Model ######################################################

import sympy as sym    # we import the sympy package
import math            # we import the math package (not used here, but has useful constants such math.pi which might be needed in other cases)    
import sys             # import the sys module used below
from pylab import *
from gravipy import *

############################################################################################################################################

# if using an integrated environment we recommend restarting the python console after running this script to make sure updates are found 

location = "/home/jwr/Code/nosetest/PyTransport-master/PyTransport/" # this should be the location of the PyTransport folder 
sys.path.append(location)  # we add this location to the python path

import PyTransSetup  # the above commands allows python to find the PyTransSetup module and import it

############################################################################################################################################

nF=2
nP=4

f=sym.symarray('f',nF)
p=sym.symarray('p',nP)
G=Matrix( [[p[3]**2.0, 0], [0, p[3]**2.0*sym.sin(f[0])**2.0] ] )
V= 1./4. * p[0] * f[0]**4 + p[2] * (1-sym.cos(2*math.pi * f[1] / p[1]))
PyTransSetup.potential(V,nF,nP,False,G) # writes this potential into c file when run

PyTransSetup.compileName("QuartAxNC",True) 
import sys 




############################################################################################################################################

#This file contains simple examples of using the PyTransport package for the single field Step example of Chen et al.
#It assumes the StepPotSetup file has been run to install a Step version of PyTransport
#It is recommended you restart the kernel before running this file to insure any updates to PyTransPyStep are imported

location = "/Users/David/Dropbox/MTeasyDist/MTeasy/" # this should be the location of the PyTransport folder 
sys.path.append(location) # sets up python path to give access to PyTransSetup

import PyTransSetup
PyTransSetup.pathSet()  # his add sets the other paths that PyTransport uses

import PyTransPyStep as MTSE  # import module
import PyTransScripts as MTS
###########################################################################################################################################

# Example 

########################### set initial field values and parameters for a simple example run ###############################################
tols = np.array([10**-8,10**-8])

nF=MTSE.nF() # gets number of fields (useful check)
nP=MTSE.nP() # gets number of parameters needed (useful check)


params = np.zeros(nP)
from pylab import *  # contains some useful stuff for plotting
import time  # imports a package that allows us to see how long processes take
import math  # imports math package
import numpy as np # imports numpu package as np for short
import sys  # imports sys package for sue below
############################################################################################################################################

#This file contains simple examples of using the PyTransDQuad 
#It assumes the DQuadSetup file has been run to install a double quadratic version of PyTransport
#It is recommended you restart the kernel before running this file to insure any updates to PyTransDQuad are imported

location = "/home/jwr/Code/PyTransport/" # this should be the location of the PyTransport folder folder
sys.path.append(location) # sets up python path to give access to PyTransSetup

import PyTransSetup
PyTransSetup.pathSet()  # this adds the other paths that PyTrans uses to the python path

import PyTransDQuad as PyT  # import module as PyT (PyTransDQuad is quite long to type each time and it saves time to use a shorter name
                             # using a generic name PyT means the file can be more easily reused for a different example (once field values 
                             # etc are altered)
import PyTransScripts as PyS  # import the scripts module as PyS for convenience

###########################################################################################################################################



# Example 

########################### set some field values and field derivatives in cosmic time ####################################################

fields = np.array([12.0, 12.0]) # we set up a numpy array which contains the values of the fields
Exemplo n.º 7
0
############################################################################################################################################

# if using an integrated environment we recommend restarting the python console after running this script to make sure updates are found

location = "/Users/david/Dropbox/PyTransportDist/PyTransport/"  # this should be the location of the PyTransport folder

sys.path.append(location)  # we add this location to the python path

import PyTransSetup  # the above commands allows python to find the PyTransSetup module and import it

############################################################################################################################################

### Sets potential and compiles PyTransport, users may prefer to do this only once in a separate file (or comment after running below once) ###
### Restart the python kernel after running this file

nF = 2
nP = 5
f = sym.symarray('f', nF)
p = sym.symarray('p', nP)
V = 1. / 2. * p[0]**2 * f[0]**2 + 1 / 2. * p[1]**2 * sym.cos(p[2] / 2.)**2 * (
    f[1] -
    (f[0] - p[3]) * sym.tan(p[2] / math.pi * sym.atan(p[4] *
                                                      (f[0] - p[3]))))**2

PyTransSetup.potential(V, nF, nP)  # writes this potential into c file when run

PyTransSetup.compileName(
    "LH"
)  # this compiles the module with the new potential and places it in the location folder, and adds this folder to the path ready for use
############################################################################################################################################
Exemplo n.º 8
0
sys.path.append(location)  # we add this location to the python path

import PyTransSetup  # the above commands allows python to find the PyTransSetup module and import it

############################################################################################################################################

nF = 2  # number of fields needed to define the double quadratic potential
nP = 2  # number of parameters needed to define the double quadtartic potential
f = sym.symarray(
    'f', nF)  # an array representing the nF fields present for this model
p = sym.symarray(
    'p', nP
)  # an array representing the nP parameters needed to define this model (that we might wish to change) if we don't
# wish to change them they could be typed explicitly in the potential below

V = 1. / 2. * p[0]**2.0 * f[0]**2.0 + 1. / 2. * p[1]**2.0 * f[
    1]**2.0  # this is the potential written in sympy notation

#The last argument is for whether the sympy's simplify is used to on derivatives of the potential and field geometric quantites.
#Caution is recomended as sympy's simplify is known to have bugs. Simplification can increase the speed of numerically evolutions, but at the cost of compling more slowly.
PyTransSetup.potential(
    V, nF, nP, True
)  # writes this potential and its derivatives into C++ file potential.h when run

PyTransSetup.compileName(
    "DQuad"
)  # this compiles a python module using the C++ code, including the edited potential.h file, called PyTransDQuad
# and places it in the location folder, ready for use

############################################################################################################################################
####################################### Setup file for the Quartic Axion non-canonical Model ######################################################

import sympy as sym    # we import the sympy package
import math            # we import the math package (not used here, but has useful constants such math.pi which might be needed in other cases)    
import sys             # import the sys module used below
from pylab import *
from gravipy import *

############################################################################################################################################

# if using an integrated environment we recommend restarting the python console after running this script to make sure updates are found 

location = "/home/jwr/Code/PyTransport/" # this should be the location of the PyTransport folder 
sys.path.append(location)  # we add this location to the python path

import PyTransSetup  # the above commands allows python to find the PyTransSetup module and import it

############################################################################################################################################

nF=2
nP=4

f=sym.symarray('f',nF)
p=sym.symarray('p',nP)
G=Matrix( [[p[3]**2.0, 0], [0, p[3]**2.0*sym.sin(f[0])**2.0] ] )
V= 1./4. * p[0] * f[0]**4 + p[2] * (1-sym.cos(2*math.pi * f[1] / p[1]))

PyTransSetup.potential(V,nF,nP,False,G) # writes this potential into c file when run

PyTransSetup.compileName("QuartAxNC",True) 
Exemplo n.º 10
0
import sympy as sym    # we import the sympy package
import math            # we import the math package (not used here, but has useful constants such math.pi which might be needed in other cases)    
import sys             # import the sys module used below
from pylab import *
from gravipy import *

############################################################################################################################################

# if using an integrated environment we recommend restarting the python console after running this script to make sure updates are found 

location = "/home/jwr/Code/PyTransport/" # this should be the location of the PyTransport folder 
sys.path.append(location)  # we add this location to the python path

import PyTransSetup  # the above commands allows python to find the PyTransSetup module and import it

############################################################################################################################################

nF=3  # number of fields needed to define the PseudoScalar potential
nP=3  # number of parameters needed to define the PseudoScalar potential
f=sym.symarray('f',nF)   # an array representing the nF fields present for this model
p=sym.symarray('p',nP)   # an array representing the nP parameters needed to define this model (that we might wish to change) if we don't 
V= p[0] * f[0]**2 + p[1] * f[1]**2 + p[2] * f[2]**2 # this is the potential written in sympy notation
R=(0.9)/((sym.cosh(2.0*((1.0*f[0])-7.0)/0.12))**(2.0))
G=Matrix([[1,R,0],[R,1,0],[0,0,1]]) # selecting the field space metric in this instance.

PyTransSetup.potential(V,nF,nP,False,G) # writes this potential and its derivatives into C++ file potential.h when run

PyTransSetup.compileName("Pseudo",True) # this compiles a python module using the C++ code, including the edited potential.h file, called PyTransPseudo
                                 # and places it in the location folder, ready for use

############################################################################################################################################
Exemplo n.º 11
0
import sympy as sym
import numpy as np
import math
import sys
############################################################################################################################################

location = "/Users/mulryne/Dropbox/PyTransportDist/PyTransport/"  # this should be the location of the PyTransport folder
sys.path.append(location)  # we add this location to the python path

import PyTransSetup

### Sets potential and compiles PyTransport, users may prefer to do this only once in a separate file (or comment after running below once) ###
nF = 1
nP = 4
f = sym.symarray('f', nF)
p = sym.symarray('p', nP)

## example step
V = 1.0 / 2.0 * p[0]**2 * f[0]**2 * (1.0 + p[1] * (sym.tanh(
    (f[0] - p[2]) / p[3])))

PyTransSetup.potential(
    V, nF, nP
)  # differentiates this potential and writes this potential and derivatives into c file when run (can be a
# little slow, and so one may not wish to run if recompiling to alater other properties such as tols)

PyTransSetup.compileName(
    "Step"
)  # this compiles the module with the new potential and places it in the location folder, and adds this folder to the path ready for use
############################################################################################################################################
Exemplo n.º 12
0
import sys
from pylab import *

from gravipy import *

############################################################################################################################################

location = "/home/jwr/Code/PyTransport/" # this should be the location of the PyTransport folder
sys.path.append(location)  # we add this location to the python path

import PyTransSetup as PySet

### Sets potential and compiles PyTransport, users may prefer to do this only once in a separate file (or comment after running below once) ###
### Restart the python kernel after running this file
nF=2
nP=4

f=sym.symarray('f',nF)
p=sym.symarray('p',nP)
G=Matrix( [[ 1.0,0], [0,f[0]**2.0] ] )

V = 10.0**(-10.0) * (1.0 + 29.0/120. *math.pi * f[1] +  1./2. * p[1] * (f[0] - p[0])**2 +  1./3./2. * p[2] * (f[0] - p[0])**3 +  1./4./3./2. * p[3] * (f[0] - p[0])**4)
                  
#The last argument is for whether the sympy's simplify is used to on derivatives of the potential and field geometric quantites.
#Caution is recomended as sympy's simplify is known to have bugs. Simplification can increase the speed of numerically evolutions, but at the cost of compling more slowly.
PySet.potential(V,nF,nP,False,G) # writes this potential into c file when run
##Set second argument to True to use the non-canonical set-up
PySet.compileName("CurveNC",True) # this compiles the module with the new potential and places it in the location folder, and adds this folder to the path ready for use
############################################################################################################################################

Exemplo n.º 13
0
############################################################################################################################################

location = "/home/jwr/Code/PyTransport/"  # this should be the location of the PyTransport folder
sys.path.append(location)  # we add this location to the python path

import PyTransSetup as PySet

### Sets potential and compiles PyTransport, users may prefer to do this only once in a separate file (or comment after running below once) ###
### Restart the python kernel after running this file
nF = 2
nP = 4

f = sym.symarray('f', nF)
p = sym.symarray('p', nP)
G = Matrix([[1.0, 0], [0, f[0]**2.0]])

V = 10.0**(-10.0) * (1.0 + 29.0 / 120. * math.pi * f[1] + 1. / 2. * p[1] *
                     (f[0] - p[0])**2 + 1. / 3. / 2. * p[2] *
                     (f[0] - p[0])**3 + 1. / 4. / 3. / 2. * p[3] *
                     (f[0] - p[0])**4)

#The last argument is for whether the sympy's simplify is used to on derivatives of the potential and field geometric quantites.
#Caution is recomended as sympy's simplify is known to have bugs. Simplification can increase the speed of numerically evolutions, but at the cost of compling more slowly.
PySet.potential(V, nF, nP, False,
                G)  # writes this potential into c file when run
##Set second argument to True to use the non-canonical set-up
PySet.compileName(
    "CurveNC", True
)  # this compiles the module with the new potential and places it in the location folder, and adds this folder to the path ready for use
############################################################################################################################################
Exemplo n.º 14
0
####################################### Setup file for the Step Potential example of Chen et al. ###########################################
import sympy as sym
import numpy as np
import math
import sys
############################################################################################################################################

location = "/Users/mulryne/Dropbox/PyTransportDist/PyTransport/" # this should be the location of the PyTransport folder
sys.path.append(location)  # we add this location to the python path

import PyTransSetup

### Sets potential and compiles PyTransport, users may prefer to do this only once in a separate file (or comment after running below once) ###
nF=1
nP=4
f=sym.symarray('f',nF)
p=sym.symarray('p',nP)

## example step
V = 1.0/2.0 *p[0]**2*f[0]**2*(1.0 + p[1]*(sym.tanh((f[0]-p[2])/p[3])))

PyTransSetup.potential(V,nF,nP) # differentiates this potential and writes this potential and derivatives into c file when run (can be a 
                               # little slow, and so one may not wish to run if recompiling to alater other properties such as tols) 

PyTransSetup.compileName("Step") # this compiles the module with the new potential and places it in the location folder, and adds this folder to the path ready for use
############################################################################################################################################