sourceterm Package

sourceterm Package

sourceterm package - Provides modules to calculate the source term for a second order perturbation Klein-Gordon equation.

sosource Module

sosource.py Second order source term calculation module.

Provides the method getsourceandintegrate which uses an instance of a first order class from cosmomodels to calculate the source term required for second order models.

pyflation.sourceterm.sosource.calculatesource(m, nix, integrand_elements, srceqns)[source]

Return the integrated source term at this timestep.

Given the first order model and the timestep calculate the integrated source term at this time step.

Parameters :

m: Cosmomodels.FOCanonicalTwoStage instance :

First order model to be used.

nix: int :

Index of current timestep in m.tresult

integrand_elements: tuple :

Contains integrand arrays in order integrand_elements = (k, q, theta)

srceqns: Instance of a subclass of srcequations.SourceEquations :

This class should implement the sourceterm function which constructs the integrated source term.

Returns :

s: array_like :

Integrated source term calculated using srcfunc.

pyflation.sourceterm.sosource.getsourceandintegrate(m, savefile=None, srcclass=None, ninit=0, nfinal=-1, ntheta=513, numks=1025, overwrite=False)[source]

Calculate and save integrated source term.

Using first order results in the specified model, the source term for second order perturbations is obtained from the given source function. The convolution integral is performed and the results are saved in a file with the specified filename.

Parameters :

m: compatible cosmomodels model instance :

The model class should contain first order results as in cosmomodels.FOCanonicalTwoStage

savefile: String, optional :

Filename where results should be saved.

srcclass: class, optional :

Class which contains functions for constructing source term. Defaults to srcequations.SlowRollSource. Class should be a subclass of srcequations.SourceEquations and should implement the sourceterm function

ninit: int, optional :

Start time index for source calculation. Default is 0 (start at beginning).

nfinal: int, optional :

End time index for source calculation. -1 signifies end of run (and is the default).

ntheta: int, optional :

Number of theta points to integrate. Should be a power of two + 1 for Romberg integration. Default is 129.

numks: int, optional :

Number of k modes required for second order calculation. Must be small enough that largest first order k mode is at least 2*(numks*deltak + kmin). Default is this limiting value.

Returns :

savefile: String :

Filename where results have been saved.

pyflation.sourceterm.sosource.opensourcefile(k, filename=None, sourcetype=None, overwrite=False)[source]

Open the source term hdf5 file with filename.

pyflation.sourceterm.sosource.profile(f)[source]
pyflation.sourceterm.sosource.set_log_name()[source]

srcequations Module

srcequations.py - Contains classes which implement source term calculation and are used by sosource.py.

Select the class to be used in a run by changing the settings in run_config.py.

class pyflation.sourceterm.srcequations.ConvolutionOnlyFullSource(*args, **kwargs)[source]

Bases: pyflation.sourceterm.srcequations.SelectedkOnlyFullSource

Convenience class to calculate the convolution for selected k values.

sourceterm(bgvars, a, potentials, dp1, dp1dot)[source]

Return unintegrated slow roll source term.

The source term before integration is calculated here using the slow roll approximation. This function follows the revised version of Eq (5.8) in Malik 06 (astro-ph/0610864v5).

Parameters :

bgvars : tuple

Tuple of background field values in the form (phi, phidot, H)

a : float

Scale factor at the current timestep, a = ainit*exp(n)

potentials : tuple

Tuple of potential values in the form (U, dU, dU2, dU3)

dp1 : array_like

Array of known dp1 values

dp1dot : array_like

Array of dpdot1 values

Returns :

src_integrand : array_like

Array containing the unintegrated source terms for all k and q modes.

References

Malik, K. 2006, JCAP03(2007)004, astro-ph/0610864v5

class pyflation.sourceterm.srcequations.FullSingleFieldSource(*args, **kwargs)[source]

Bases: pyflation.sourceterm.srcequations.SourceEquations

Full single field (non slow-roll) source term equations

J_factory(Jkey)[source]
J_func(preterms, dp1, dp1dot, Cterms, Jkey)[source]

Generic solution for J_func integral.

calculate_Cterms(bgvars, a, potentials)[source]

Calculate the value of the constants needed for source term integration.

getthetaterms(dp1, dp1dot)[source]

Return array of integrated values for specified theta function and dphi function.

Parameters :

dp1 : array_like

Array of values for dphi1

dp1dot : array_like

Array of values for dphi1dot

Returns :

theta_terms : tuple

Tuple of len(k)xlen(q) shaped arrays of integration results

Notes

The returned expression is of the form

\bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)

sourceterm(bgvars, a, potentials, dp1, dp1dot)[source]

Return unintegrated slow roll source term.

The source term before integration is calculated here using the slow roll approximation. This function follows the revised version of Eq (5.8) in Malik 06 (astro-ph/0610864v5).

Parameters :

bgvars : tuple

Tuple of background field values in the form (phi, phidot, H)

a : float

Scale factor at the current timestep, a = ainit*exp(n)

potentials : tuple

Tuple of potential values in the form (U, dU, dU2, dU3)

dp1 : array_like

Array of known dp1 values

dp1dot : array_like

Array of dpdot1 values

Returns :

src_integrand : array_like

Array containing the unintegrated source terms for all k and q modes.

References

Malik, K. 2006, JCAP03(2007)004, astro-ph/0610864v5

class pyflation.sourceterm.srcequations.SelectedkOnlyFullSource(*args, **kwargs)[source]

Bases: pyflation.sourceterm.srcequations.FullSingleFieldSource

Convenience class to the source term for selected k values.

getthetaterms(dp1, dp1dot)[source]

Return array of integrated values for specified theta function and dphi function. This modified version only returns the result for one k value.

Parameters :

dp1 : array_like

Array of values for dphi1

dp1dot : array_like

Array of values for dphi1dot

Returns :

theta_terms : tuple

Tuple of len(k)xlen(q) shaped arrays of integration results in form

Notes

The returned expression is of the form

\bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)

class pyflation.sourceterm.srcequations.SelectedkOnlySlowRollSource(*args, **kwargs)[source]

Bases: pyflation.sourceterm.srcequations.SlowRollSource

Convenience class to do slow roll calculation of source term for only selected k modes.

getthetaterms(dp1, dp1dot)[source]

Return array of integrated values for specified theta function and dphi function.

Parameters :

dp1 : array_like

Array of values for dphi1

dp1dot : array_like

Array of values for dphi1dot

Returns :

theta_terms : tuple

Tuple of len(k)xlen(q) shaped arrays of integration results in form

Notes

The returned expression is of the form

\bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)

class pyflation.sourceterm.srcequations.SlowRollSource(*args, **kwargs)[source]

Bases: pyflation.sourceterm.srcequations.SourceEquations

Slow roll source term equations

J_A(preterms, dp1, dp1dot, Cterms)[source]

Solution for J_A which is the integral for A in terms of constants C1 and C2.

J_B(preterms, dp1, dp1dot, Cterms)[source]

Solution for J_B which is the integral for B in terms of constants C3 and C4.

J_C(preterms, dp1, dp1dot, Cterms)[source]

Solution for J_C which is the integral for C in terms of constants C5.

J_D(preterms, dp1, dp1dot, Cterms)[source]

Solution for J_D which is the integral for D in terms of constants C6 and C7.

calculate_Cterms(bgvars, a, potentials)[source]

Calculate the C terms needed for source term integration.

getthetaterms(dp1, dp1dot)[source]

Return array of integrated values for specified theta function and dphi function.

Parameters :

dp1 : array_like

Array of values for dphi1

dp1dot : array_like

Array of values for dphi1dot

Returns :

theta_terms : tuple

Tuple of len(k)xlen(q) shaped arrays of integration results

Notes

The returned expression is of the form

\bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,

 \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,

 \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)

sourceterm(bgvars, a, potentials, dp1, dp1dot)[source]

Return integrated slow roll source term.

The source term before integration is calculated here using the slow roll approximation. This function follows the revised version of Eq (5.8) in Malik 06 (astro-ph/0610864v5).

Parameters :

bgvars : tuple

Tuple of background field values in the form (phi, phidot, H)

a : float

Scale factor at the current timestep, a = ainit*exp(n)

potentials : tuple

Tuple of potential values in the form (U, dU, dU2, dU3)

dp1 : array_like

Array of known dp1 values

dp1dot : array_like

Array of dpdot1 values

Returns :

src_integrand : array_like

Array containing the unintegrated source terms for all k and q modes.

References

Malik, K. 2006, JCAP03(2007)004, astro-ph/0610864v5

class pyflation.sourceterm.srcequations.SourceEquations(fixture)[source]

Bases: object

Class for source term equations

getthetaterms(dp1, dp1dot)[source]

Calculate the theta terms needed for source integrations.

sourceterm(bgvars, a, potentials, dp1, dp1dot, theta_terms)[source]

Calculate the source term for this timestep

pyflation.sourceterm.srcequations.klessq(k, q, theta)[source]

Return the scalar magnitude of k^i - q^i squared, where theta is angle between vectors.

Parameters :

k : float

Single k value to compute array for.

q : array_like

1-d array of q values to use

theta : array_like

1-d array of theta values to use

Returns :

klessq : array_like

len(q)*len(theta) array of values

Notes

The expression evaluated is

|k^i - q^i|^2 = (k^2 + q^2 - 2kq \cos(\theta))

pyflation.sourceterm.srcequations.klessqksq(k, q, theta)[source]

Return the scalar magnitude of (k^i - q^i) squared times 1/k^2, where theta is angle between vectors.

Parameters :

k : float

Single k value to compute array for.

q : array_like

1-d array of q values to use

theta : array_like

1-d array of theta values to use

Returns :

klessq : array_like

len(q)*len(theta) array of values

Notes

The expression calculated is

|k^i - q^i|^2/k^2 = (1 + (q/k)^2 - 2(q/k) \cos(\theta))

Table Of Contents

Previous topic

analysis Package

This Page