diff --git a/src/TransferFunction.hh b/src/TransferFunction.hh
deleted file mode 100644
index 919ee86..0000000
--- a/src/TransferFunction.hh
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- This file is part of MUSIC -
- a tool to generate initial conditions for cosmological simulations
-
- Copyright (C) 2008-12 Oliver Hahn, ojha@gmx.de
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-
-#ifndef __TRANSFERFUNCTION_HH
-#define __TRANSFERFUNCTION_HH
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include "Numerics.hh"
-#include "general.hh"
-
-#include
-
-#define NZERO_Q
-
-typedef std::complex complex;
-
-//! Abstract base class for transfer functions
-/*!
- This class implements a purely virtual interface that can be
- used to derive instances implementing various transfer functions.
-*/
-class TransferFunction{
-public:
- Cosmology m_Cosmology;
-
-public:
-
- TransferFunction( Cosmology acosm ) : m_Cosmology( acosm ) { };
- virtual double compute( double k ) = 0;
- virtual ~TransferFunction(){ };
- virtual double get_kmax( void ) = 0;
- virtual double get_kmin( void ) = 0;
-};
-
-class TransferFunction_real
-{
-
-public:
- gsl_interp_accel *accp, *accn;
- gsl_spline *splinep, *splinen;
- double Tr0_, Tmin_, Tmax_, Tscale_;
- double rneg_, rneg2_;
- static TransferFunction *ptf_;
- static double nspec_;
-
-protected:
-
- double krgood( double mu, double q, double dlnr, double kr )
- {
- double krnew = kr;
- complex cdgamma, zm, zp;
- double arg, iarg, xm, xp, y;
- gsl_sf_result g_a, g_p;
-
- xp = 0.5*(mu+1.0+q);
- xm = 0.5*(mu+1.0-q);
- y = M_PI/(2.0*dlnr);
- zp=complex(xp,y);
- zm=complex(xm,y);
-
- gsl_sf_lngamma_complex_e (zp.real(), zp.imag(), &g_a, &g_p);
- zp=std::polar(exp(g_a.val),g_p.val);
- double zpa = g_p.val;
-
- gsl_sf_lngamma_complex_e (zm.real(), zm.imag(), &g_a, &g_p);
- zm=std::polar(exp(g_a.val),g_p.val);
- double zma = g_p.val;
-
- arg=log(2.0/kr)/dlnr+(zpa+zma)/M_PI;
- iarg=(double)((int)(arg + 0.5));
-
- if( arg!=iarg )
- krnew=kr*exp((arg-iarg)*dlnr);
-
- return krnew;
- }
-
- void transform( double pnorm, double dplus, unsigned N, double q, std::vector& rr, std::vector& TT )
- {
- const double mu = 0.5;
- double qmin = 1.0e-6, qmax = 1.0e+6;
-
- q = 0.0;
-
- N = 16384;
-
-#ifdef NZERO_Q
- //q = 0.4;
- q = 0.2;
-#endif
-
- double kmin = qmin, kmax=qmax;
- double rmin = qmin, rmax = qmax;
- double k0 = exp(0.5*(log(kmax)+log(kmin)));
- double r0 = exp(0.5*(log(rmax)+log(rmin)));
- double L = log(rmax)-log(rmin);
- double k0r0 = k0*r0;
- double dlnk = L/N, dlnr = L/N;
-
- double sqrtpnorm = sqrt(pnorm);
-
- double dir = 1.0;
-
- double fftnorm = 1.0/N;
-
- complex_t in[N], out[N];
- fftw_plan p,ip;
-
- //... perform anti-ringing correction from Hamilton (2000)
- k0r0 = krgood( mu, q, dlnr, k0r0 );
-
- std::ofstream ofsk("transfer_k.txt");
- double sum_in = 0.0;
- for( unsigned i=0; icompute( k )*pow(k,0.5*nspec_)*pow(k,1.5-q);
- in[i].im = 0.0;
-
- sum_in += in[i].re;
- ofsk << std::setw(16) << k < (int)N/2 )
- ii -= N;
-
-#ifndef NZERO_Q
- double y=ii*M_PI/L;
- complex zp((mu+1.0)*0.5,y);
- gsl_sf_result g_a, g_p;
- gsl_sf_lngamma_complex_e(zp.real(), zp.imag(), &g_a, &g_p);
-
- double arg = 2.0*(log(2.0/k0r0)*y+g_p.val);
- complex cu = complex(out[i].re,out[i].im)*std::polar(1.0,arg);
- out[i].re = cu.real()*fftnorm;
- out[i].im = cu.imag()*fftnorm;
-
-#else
- //complex x(dir*q, (double)ii*2.0*M_PI/L);
- complex x(dir*q, (double)ii*2.0*M_PI/L);
- gsl_sf_result g_a, g_p;
-
- complex g1, g2, garg, U, phase;
- complex twotox = pow(complex(2.0,0.0),x);
-
- /////////////////////////////////////////////////////////
- //.. evaluate complex Gamma functions
-
- garg = 0.5*(mu+1.0+x);
- gsl_sf_lngamma_complex_e (garg.real(), garg.imag(), &g_a, &g_p);
- g1 = std::polar(exp(g_a.val),g_p.val);
-
-
- garg = 0.5*(mu+1.0-x);
- gsl_sf_lngamma_complex_e (garg.real(), garg.imag(), &g_a, &g_p);
- g2 = std::polar(exp(g_a.val),g_p.val);
-
- /////////////////////////////////////////////////////////
- //.. compute U
-
- if( (fabs(g2.real()) < 1e-19 && fabs(g2.imag()) < 1e-19) )
- {
- //std::cerr << "Warning : encountered possible singularity in TransferFunction_real::transform!\n";
- g1 = 1.0; g2 = 1.0;
- }
-
-
- U = twotox * g1 / g2;
- phase = pow(complex(k0r0,0.0),complex(0.0,2.0*M_PI*(double)ii/L));
-
- complex cu = complex(out[i].re,out[i].im)*U*phase*fftnorm;
-
- out[i].re = cu.real();
- out[i].im = cu.imag();
-
- if( (out[i].re != out[i].re)||(out[i].im != out[i].im) )
- { std::cerr << "NaN @ i=" << i << ", U= " << U << ", phase = " << phase << ", g1 = " << g1 << ", g2 = " << g2 << std::endl;
- std::cerr << "mu+1+q = " << mu+1.0+q << std::endl;
- //break;
- }
-
-#endif
-
- }
-
- /*out[N/2].im = 0.0;
- out[N/2+1].im = 0.0;
- out[N/2+1].re = out[N/2].re;
- out[N/2].im = 0.0;*/
-
- fftw_one(ip, out, in);
-
- rr.assign(N,0.0);
- TT.assign(N,0.0);
-
- r0 = k0r0/k0;
-
- for( unsigned i=0; iN/2)
- // ii-=N;
-
-
-
- double r = r0*exp(-ii*dlnr);
- rr[N-i-1] = r;
- TT[N-i-1] = 4.0*M_PI* sqrt(M_PI/2.0) * in[i].re*pow(r,-(1.5+q));
-
- //TT[N-i-1] = 4.0*M_PI* sqrt(M_PI/2.0) * in[i].re*exp( -dir*(q+1.5)*ii*dlnr +q*log(k0r0))/r0;
-
- //rr[i] = r;
- //TT[i] = 4.0*M_PI* sqrt(M_PI/2.0) * in[i].re*pow(r,-(1.5+q));
-
- }
-
-
- {
- std::ofstream ofs("transfer_real_new.txt");
- for( unsigned i=0; i r,T,xp,yp,xn,yn;
-
- transform( pnorm, dplus, nr, q, r, T );
-
- //... determine r=0 zero component by integrating up to the Nyquist frequency
- gsl_integration_workspace * wp;
- gsl_function F;
- wp = gsl_integration_workspace_alloc(20000);
- F.function = &call_wrapper;
- double par[2]; par[0] = dplus*sqrt(pnorm); //par[1] = M_PI/kny;
- F.params = (void*)par;
- double error;
-
- //#warning factor of sqrt(1.5) needs to be adjusted for non-equilateral boxes
- //.. need a factor sqrt( 2*kny^2_x + 2*kny^2_y + 2*kny^2_z )/2 = sqrt(3/2)kny (in equilateral case)
- gsl_integration_qag (&F, 0.0, sqrt(1.5)*knymax, 0, 1e-8, 20000, GSL_INTEG_GAUSS21, wp, &Tr0_, &error);
- //Tr0_ = 0.0;
- gsl_integration_workspace_free(wp);
-
-
- for( unsigned i=0; i 0.0 )
- {
- xp.push_back( 2.0*log10(r[i]) );
- yp.push_back( log10(T[i]) );
- rneg_ = r[i];
- rneg2_ = rneg_*rneg_;
- }else {
- xn.push_back( 2.0*log10(r[i]) );
- yn.push_back( log10(-T[i]) );
- }*/
-
-
- if( r[i] > rmin && r[i] < rmax )
- {
- xp.push_back( 2.0*log10(r[i]) );
- yp.push_back( log10(fabs(T[i])) );
- xn.push_back( 2.0*log10(r[i]) );
- if( T[i] >= 0.0 )
- yn.push_back( 1.0 );
- else
- yn.push_back( -1.0 );
-
-
- //ofs << std::setw(16) << xp.back() << std::setw(16) << yp.back() << std::endl;
- }
-
- }
-
-
-
-
-
- accp = gsl_interp_accel_alloc ();
- accn = gsl_interp_accel_alloc ();
-
- //... spline interpolation is only marginally slower here
- splinep = gsl_spline_alloc (gsl_interp_cspline, xp.size() );
- splinen = gsl_spline_alloc (gsl_interp_cspline, xn.size() );
-
- //... set up everything for spline interpolation
- gsl_spline_init (splinep, &xp[0], &yp[0], xp.size() );
- gsl_spline_init (splinen, &xn[0], &yn[0], xn.size() );
-
-
-
-
- {
- double dlogr = (log10(rmax)-log10(rmin))/100;
- std::ofstream ofs("transfer_splinep.txt");
-
- for( int i=0; i< 100; ++i )
- {
- double r = rmin*pow(10.0,i*dlogr);
- ofs << std::setw(16) << r << std::setw(16) << compute_real(r*r) << std::endl;
- }
- }
-
- }
-
- static double call_wrapper( double k, void *arg )
- {
- double *a = (double*)arg;
- return 4.0*M_PI*a[0]*ptf_->compute( k )*pow(k,0.5*nspec_)*k*k;
- }
-
- ~TransferFunction_real()
- {
- gsl_spline_free (splinen);
- gsl_interp_accel_free (accn);
- gsl_spline_free (splinep);
- gsl_interp_accel_free (accp);
-
- }
-
- inline double compute_real( double r2 ) const
- {
- const double EPS = 1e-8;
- const double Reps2 = EPS*EPS;
-
- if( r2 compute(k,total);
+ double tfk = ptf->compute(k,delta_matter);
return k*k * w*w * pow(k,nspect) * tfk*tfk;
}
@@ -48,7 +48,7 @@ double dsigma2_gauss( double k, void *pparams )
double w = exp(-x*x*0.5);
- double tfk = ptf->compute(k,total);
+ double tfk = ptf->compute(k,delta_matter);
return k*k * w*w * pow(k,nspect) * tfk*tfk;
}
@@ -76,15 +76,15 @@ void compute_sigma_tophat( config_file& cf, transfer_function *ptf, double R, st
z.clear();
sigma.clear();
- cosmology cosm( cf );
- CosmoCalc ccalc( cosm, ptf );
+ cosmology::parameters cosm( cf );
+ cosmology::calculator ccalc( cf );
double zmin = 0.0, zmax = 200.0;
int nz = 100;
for( int i=0; i ("cosmology","sigma_8");
double nspec = cf.get_value("cosmology","nspec");
@@ -109,7 +109,7 @@ void compute_sigma_tophat( config_file& cf, transfer_function *ptf, double R, st
params[2] = reinterpret_cast (&nspec);
double sig = sqrt(4.0*M_PI*integrate( &dsigma2_tophat, 1e-4, 1e4, reinterpret_cast(params) ));
- double Dz = ccalc.CalcGrowthFactor(1./(1.+z[i]));
+ double Dz = ccalc.get_growth_factor(1./(1.+z[i]));
sigma.push_back( sig*sigma8/sigma0*Dz/D0 );
}
}
@@ -119,15 +119,15 @@ void compute_sigma_gauss( config_file& cf, transfer_function *ptf, double R, std
z.clear();
sigma.clear();
- cosmology cosm( cf );
- CosmoCalc ccalc( cosm, ptf );
+ cosmology::parameters cosm( cf );
+ cosmology::calculator ccalc( cf );
double zmin = 0.0, zmax = 200.0;
int nz = 100;
for( int i=0; i ("cosmology","sigma_8");
double nspec = cf.get_value("cosmology","nspec");
@@ -152,7 +152,7 @@ void compute_sigma_gauss( config_file& cf, transfer_function *ptf, double R, std
params[2] = reinterpret_cast (&nspec);
double sig = sqrt(4.0*M_PI*integrate( &dsigma2_gauss, 1e-4, 1e4, reinterpret_cast(params) ));
- double Dz = ccalc.CalcGrowthFactor(1./(1.+z[i]));
+ double Dz = ccalc.get_growth_factor(1./(1.+z[i]));
//std::cerr << z[i] << " " << sig << std::endl;
sigma.push_back( sig*sigma8/sigma0*Dz/D0 );
@@ -163,8 +163,8 @@ void compute_sigma_gauss( config_file& cf, transfer_function *ptf, double R, std
constraint_set::constraint_set( config_file& cf, transfer_function *ptf )
: pcf_( &cf ), ptf_( ptf )
{
- pcosmo_ = new Cosmology( cf );
- pccalc_ = new CosmoCalc( *pcosmo_, ptf_ );
+ pcosmo_ = new cosmology::parameters( cf );
+ pccalc_ = new cosmology::calculator( cf );
dplus0_ = 1.0;//pccalc_->CalcGrowthFactor( 1.0 );
@@ -218,9 +218,9 @@ constraint_set::constraint_set( config_file& cf, transfer_function *ptf )
double zcoll = cf.get_value( "constraints", temp1 );
new_c.Rg = pow((mass/pow(2.*M_PI,1.5)/rhom),1./3.);
- new_c.sigma = 1.686/(pccalc_->CalcGrowthFactor(1./(1.+zcoll))/pccalc_->CalcGrowthFactor(1.0));
+ new_c.sigma = 1.686/(pccalc_->get_growth_factor(1./(1.+zcoll))/pccalc_->get_growth_factor(1.0));
music::ilog.Print("sigma of constraint : %g", new_c.sigma );
- new_c.sigma *=pccalc_->CalcGrowthFactor(astart)/pccalc_->CalcGrowthFactor(1.0);
+ new_c.sigma *=pccalc_->get_growth_factor(astart)/pccalc_->get_growth_factor(1.0);
music::ilog.Print("Constraint %d : halo with %g h-1 M_o",i,pow(2.*M_PI,1.5)*rhom*pow(new_c.Rg,3));
}
else if( new_c.type == peak )
@@ -324,7 +324,7 @@ void constraint_set::wnoise_constr_corr( double dx, size_t nx, size_t ny, size_t
double k = sqrt(iix*iix+iiy*iiy+iiz*iiz)*(double)nx/lsub;
- double T = ptf_->compute(k,total);
+ double T = ptf_->compute(k,delta_matter);
double Pk = pnorm*T*T*pow(k,nspec)*d3k;
size_t q = ((size_t)ix*ny+(size_t)iy)*nzp+(size_t)iz;
@@ -407,7 +407,7 @@ void constraint_set::wnoise_constr_corr( double dx, complex_t* cw, size_t nx, si
iiz *= 2.0*M_PI/nx;
double k = sqrt(iix*iix+iiy*iiy+iiz*iiz)*(double)nx/lsub;
- double T = ptf_->compute(k,total);
+ double T = ptf_->compute(k,delta_matter);
std::complex v(std::conj(eval_constr(i,iix,iiy,iiz)));
@@ -472,7 +472,7 @@ void constraint_set::icov_constr( double dx, size_t nx, size_t ny, size_t nz, ma
iiz *= 2.0*M_PI/nx;
double k = sqrt(iix*iix+iiy*iiy+iiz*iiz)*(double)nx/lsub;
- double T = ptf_->compute(k,total);
+ double T = ptf_->compute(k,delta_matter);
std::complex v(std::conj(eval_constr(i,iix,iiy,iiz)));
v *= eval_constr(j,iix,iiy,iiz);
v *= pnorm * pow(k,nspec) * T * T * d3k;
diff --git a/src/constraints.hh b/src/constraints.hh
index 66f2871..450ae13 100644
--- a/src/constraints.hh
+++ b/src/constraints.hh
@@ -17,7 +17,7 @@
#include
#include
#include
-#include
+#include
//! matrix class serving as a gsl wrapper
class matrix
@@ -119,8 +119,8 @@ protected:
config_file *pcf_;
std::vector cset_;
transfer_function *ptf_;
- CosmoCalc *pccalc_;
- Cosmology *pcosmo_;
+ const cosmology::calculator *pccalc_;
+ const cosmology::parameters *pcosmo_;
double dplus0_;
unsigned constr_level_;
diff --git a/src/convolution_kernel.cc b/src/convolution_kernel.cc
index c9943e2..03a9c54 100644
--- a/src/convolution_kernel.cc
+++ b/src/convolution_kernel.cc
@@ -157,7 +157,7 @@ class kernel_k : public kernel
{
protected:
/**/
- double boxlength_, patchlength_, nspec_, pnorm_, volfac_, kfac_, kmax_;
+ double boxlength_, patchlength_, nspec_, pnorm_, kfac_, kmax_;
TransferFunction_k *tfk_;
public:
@@ -165,9 +165,8 @@ public:
: kernel(cf, ptf, refh, type)
{
boxlength_ = pcf_->get_value("setup", "boxlength");
- nspec_ = pcf_->get_value("cosmology", "nspec");
- pnorm_ = pcf_->get_value("cosmology", "pnorm");
- volfac_ = 1.0; //pow(boxlength,3)/pow(2.0*M_PI,3);
+ nspec_ = ptf->cosmo_params_["n_s"];
+ pnorm_ = ptf->cosmo_params_["pnorm"];
kfac_ = 2.0 * M_PI / boxlength_;
kmax_ = kfac_ / 2;
tfk_ = new TransferFunction_k(type_, ptf_, nspec_, pnorm_);
@@ -231,7 +230,7 @@ public:
for (size_t i = 0; i < len; ++i)
{
double kk = kfac_ * in_k[i];
- out_Tk[i] = volfac_ * tfk_->compute(kk);
+ out_Tk[i] = tfk_->compute(kk);
}
}
diff --git a/src/cosmology.hh b/src/cosmology.hh
deleted file mode 100644
index 3862d3b..0000000
--- a/src/cosmology.hh
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
-
- cosmology.hh - This file is part of MUSIC -
- a code to generate multi-scale initial conditions
- for cosmological simulations
-
- Copyright (C) 2010 Oliver Hahn
-
- */
-
-#ifndef _COSMOLOGY_HH
-#define _COSMOLOGY_HH
-
-
-#include "transfer_function.hh"
-#include "mesh.hh"
-#include "general.hh"
-
-/*!
- * @class CosmoCalc
- * @brief provides functions to compute cosmological quantities
- *
- * This class provides member functions to compute cosmological quantities
- * related to the Friedmann equations and linear perturbation theory
- */
-class CosmoCalc
-{
-public:
- //! data structure to store cosmological parameters
- Cosmology m_Cosmology;
-
- //! pointer to an instance of a transfer function plugin
- transfer_function_plugin *m_pTransferFunction;
-
-
- //! constructor for a cosmology calculator object
- /*!
- * @param acosmo a cosmological parameters structure
- * @param pTransferFunction pointer to an instance of a transfer function object
- */
-
- CosmoCalc( const Cosmology acosmo, transfer_function_plugin *pTransferFunction )
- {
- m_Cosmology = acosmo;
- m_pTransferFunction = pTransferFunction;
- }
-
- //! returns the amplitude of amplitude of the power spectrum
- /*!
- * @param k the wave number in h/Mpc
- * @param a the expansion factor of the universe
- * @returns power spectrum amplitude for wave number k at time a
- */
- inline real_t Power( real_t k, real_t a ){
- real_t m_Dplus = CalcGrowthFactor( a );
- real_t m_DplusOne = CalcGrowthFactor( 1.0 );
- real_t m_pNorm = ComputePNorm( 1e4 );
- m_Dplus /= m_DplusOne;
- m_DplusOne = 1.0;
- real_t scale = m_Dplus/m_DplusOne;
- return m_pNorm*scale*scale*TransferSq(k)*pow((double)k,(double)m_Cosmology.nspect);
- }
-
- inline static double H_of_a( double a, void *Params )
- {
- Cosmology *cosm = (Cosmology*)Params;
- double a2 = a*a;
- double Ha = sqrt(cosm->Omega_m/(a2*a) + cosm->Omega_k/a2
- + cosm->Omega_DE * pow(a,-3.*(1.+cosm->w_0+cosm->w_a)) * exp(-3.*(1.0-a)*cosm->w_a) );
- return Ha;
- }
-
- inline static double Hprime_of_a( double a, void *Params )
- {
- Cosmology *cosm = (Cosmology*)Params;
- double a2 = a*a;
- double H = H_of_a( a, Params );
- double Hprime = 1/(a*H) * ( -1.5 * cosm->Omega_m / (a2*a) - cosm->Omega_k / a2
- - 1.5 * cosm->Omega_DE * pow( a, -3.*(1.+cosm->w_0+cosm->w_a) ) * exp( -3.*(1.0-a)*cosm->w_a )
- * ( 1. + cosm->w_0 + (1.-a) * cosm->w_a ) );
- return Hprime;
- }
-
-
- //! Integrand used by function CalcGrowthFactor to determine the linear growth factor D+
- inline static double GrowthIntegrand( double a, void *Params )
- {
- double Ha = a * H_of_a( a, Params );
- return 2.5/( Ha * Ha * Ha );
- }
-
- //! Computes the linear theory growth factor D+
- /*! Function integrates over member function GrowthIntegrand and computes
- * /a
- * D+(a) = 5/2 H(a) * | [a'^3 * H(a')^3]^(-1) da'
- * /0
- */
- real_t CalcGrowthFactor( real_t a )
- {
- real_t integral = integrate( &GrowthIntegrand, 0.0, a, (void*)&m_Cosmology );
- return H_of_a( a, (void*)&m_Cosmology ) * integral;
- }
-
- //! Compute the factor relating particle displacement and velocity
- /*! Function computes
- *
- * vfac = a^2 * H(a) * dlogD+ / d log a = a^2 * H'(a) + 5/2 * [ a * D+(a) * H(a) ]^(-1)
- *
- */
- real_t CalcVFact( real_t a )
- {
- real_t Dp = CalcGrowthFactor( a );
- real_t H = H_of_a( a, (void*)&m_Cosmology );
- real_t Hp = Hprime_of_a( a, (void*)&m_Cosmology );
- real_t a2 = a*a;
-
- return ( a2 * Hp + 2.5 / ( a * Dp * H ) ) * 100.0;
- }
-
-
- //! Integrand for the sigma_8 normalization of the power spectrum
- /*! Returns the value of the primordial power spectrum multiplied with
- the transfer function and the window function of 8 Mpc/h at wave number k */
- static double dSigma8( double k, void *Params )
- {
- if( k<=0.0 )
- return 0.0f;
-
- transfer_function *ptf = (transfer_function *)Params;
-
- double x = k*8.0;
- double w = 3.0*(sin(x)-x*cos(x))/(x*x*x);
- static double nspect = (double)ptf->cosmo_.nspect;
-
- double tf = ptf->compute(k, total);
-
- //... no growth factor since we compute at z=0 and normalize so that D+(z=0)=1
- return k*k * w*w * pow((double)k,(double)nspect) * tf*tf;
-
- }
-
- //! Integrand for the sigma_8 normalization of the power spectrum
- /*! Returns the value of the primordial power spectrum multiplied with
- the transfer function and the window function of 8 Mpc/h at wave number k */
- static double dSigma8_0( double k, void *Params )
- {
- if( k<=0.0 )
- return 0.0f;
-
- transfer_function *ptf = (transfer_function *)Params;
-
- double x = k*8.0;
- double w = 3.0*(sin(x)-x*cos(x))/(x*x*x);
- static double nspect = (double)ptf->cosmo_.nspect;
-
- double tf = ptf->compute(k, total0);
-
- //... no growth factor since we compute at z=0 and normalize so that D+(z=0)=1
- return k*k * w*w * pow((double)k,(double)nspect) * tf*tf;
-
- }
-
-
- //! Computes the square of the transfer function
- /*! Function evaluates the supplied transfer function m_pTransferFunction
- * and returns the square of its value at wave number k
- * @param k wave number at which to evaluate the transfer function
- */
- inline real_t TransferSq( real_t k ){
- //.. parameter supplied transfer function
- real_t tf1 = m_pTransferFunction->compute(k, total);
- return tf1*tf1;
- }
-
-
- //! Computes the normalization for the power spectrum
- /*!
- * integrates the power spectrum to fix the normalization to that given
- * by the sigma_8 parameter
- */
- real_t ComputePNorm( real_t kmax )
- {
- real_t sigma0, kmin;
- kmax = m_pTransferFunction->get_kmax();//m_Cosmology.H0/8.0;
- kmin = m_pTransferFunction->get_kmin();//0.0;
-
- if( !m_pTransferFunction->tf_has_total0() )
- sigma0 = 4.0 * M_PI * integrate( &dSigma8, (double)kmin, (double)kmax, (void*)m_pTransferFunction );
- else
- sigma0 = 4.0 * M_PI * integrate( &dSigma8_0, (double)kmin, (double)kmax, (void*)m_pTransferFunction );
-
- return m_Cosmology.sigma8*m_Cosmology.sigma8/sigma0;
- }
-
-};
-
-
-//! compute the jeans sound speed
-/*! given a density in g/cm^-3 and a mass in g it gives back the sound
- * speed in cm/s for which the input mass is equal to the jeans mass
- * @param rho density
- * @param mass mass scale
- * @returns jeans sound speed
- */
-inline double jeans_sound_speed( double rho, double mass )
-{
- const double G = 6.67e-8;
- return pow( 6.0*mass/M_PI*sqrt(rho)*pow(G,1.5), 1.0/3.0 );
-}
-
-//! computes the density from the potential using the Laplacian
-void compute_Lu_density( const grid_hierarchy& u, grid_hierarchy& fnew, unsigned order=4 );
-
-//! computes the 2nd order density perturbations using also off-diagonal terms in the potential Hessian
-void compute_LLA_density( const grid_hierarchy& u, grid_hierarchy& fnew, unsigned order=4 );
-
-//! computes the source term for the 2nd order perturbations in the displacements
-void compute_2LPT_source( const grid_hierarchy& u, grid_hierarchy& fnew, unsigned order=4 );
-
-void compute_2LPT_source_FFT( config_file& cf_, const grid_hierarchy& u, grid_hierarchy& fnew );
-
-
-#endif // _COSMOLOGY_HH
-
diff --git a/src/cosmology_calculator.hh b/src/cosmology_calculator.hh
index fb48eab..f8d4241 100644
--- a/src/cosmology_calculator.hh
+++ b/src/cosmology_calculator.hh
@@ -17,11 +17,11 @@
#pragma once
#include
-#include
+#include "math/vec.hh"
#include
#include
-#include
+#include
#include