Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codecompare #29

Merged
merged 7 commits into from
Sep 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LDFLAGS=-lgsl -lgslcblas -lm -Lclass -lclass


OBJECTS=src/ccl_core.o src/ccl_utils.o src/ccl_power.o src/ccl_placeholder.o src/ccl_background.o
TESTS=tests/ccl_test_utils tests/ccl_test_power tests/ccl_test_distances
TESTS=tests/ccl_test_utils tests/ccl_test_power tests/ccl_test_distances tests/ccl_test_bbks
LIB=lib/libccl.a
DYLIB=lib/libccl.so
INC_CCL=
Expand All @@ -29,6 +29,7 @@ test: $(TESTS)
LD_LIBRARY_PATH=lib:$(LD_LIBRARY_PATH) tests/ccl_test_utils > /dev/null
LD_LIBRARY_PATH=lib:$(LD_LIBRARY_PATH) tests/ccl_test_power > /dev/null
LD_LIBRARY_PATH=lib:$(LD_LIBRARY_PATH) tests/ccl_test_distances > /dev/null
LD_LIBRARY_PATH=lib:$(LD_LIBRARY_PATH) tests/ccl_test_bbks > /dev/null
@echo "---------------------"
@echo

Expand Down
Empty file added class/build/.base
Empty file.
4 changes: 2 additions & 2 deletions include/ccl_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#define K_PIVOT 0.05
#define K_MAX 1e3
#define K_MIN 1e-4
#define K_MAX_INT (1e3*1.1) //minimum integration range
#define K_MIN_INT (1e-4/1.1) //maximum integration range
#define K_MAX_INT (1e3/1.1) //minimum integration range
#define K_MIN_INT (1e-4*1.1) //maximum integration range
#define N_K 500

//Lightspeed / H0 in units of Mpc/h
Expand Down
10 changes: 6 additions & 4 deletions src/ccl_placeholder.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ struct sigma8_args {
int * status;
};

//TODO: Sorry, but shouldn't kR be k*8/h? It looks like you are multiplying by h.
//TODO: Sorry, but shouldn't kR be k*8/h? It looks like you are multiplying by h, so I changed that.
//TODO: Also, what units is k? If [k]=Mpc/h, then we should remove h from kR.
//TODO: It seems in the constants.h file thtat [k]=Mpc
//TODO: It seems in the constants.h file that [k]=Mpc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to revisit this when checking physical units

static
double sigma8_integrand(double k, void * args)
{
struct sigma8_args * s_args = (struct sigma8_args*) args;
gsl_spline * spline = s_args->P;
double kR = k*8.0*s_args->h; // r=8 Mpc/h
double kR = k*8.0/s_args->h; // r=8 Mpc/h
double x = 3.*(sin(kR) - kR*cos(kR))/pow(kR,3.0);
double p = exp(gsl_spline_eval(spline, log(k), NULL));
double res = p*x*x*k*k;
return res;
}

double ccl_sigma8(gsl_spline * P, double h, int * status){

struct sigma8_args s_args;
s_args.P = P;
s_args.status = status;
Expand All @@ -58,9 +59,10 @@ double ccl_sigma8(gsl_spline * P, double h, int * status){
double sigma_8;
//TODO: Why not integrating in ln space?
*status |= gsl_integration_cquad(&F, K_MIN_INT, K_MAX_INT, 0.0, 1e-5, workspace, &sigma_8, NULL, NULL);

gsl_integration_cquad_workspace_free(workspace);

//TODO: Check whether you are printing sigma_8 or sigma_8^2
//TODO: Printing sigma_8^2
return sigma_8/(2.*M_PI*M_PI);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ccl_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ void ccl_cosmology_compute_power_bbks(ccl_cosmology * cosmo, int *status){
}
gsl_spline * log_power_lin = gsl_spline_alloc(K_SPLINE_TYPE, nk);
*status = gsl_spline_init(log_power_lin, x, y, nk);
double sigma_8 = ccl_sigma8(log_power_lin, cosmo->params.h, status);
double log_sigma_8 = log(cosmo->params.sigma_8) - log(sigma_8);
double sigma_8 = ccl_sigma8(log_power_lin, cosmo->params.h, status); //this is sigma_8^2!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change ccl_sigma8 to return sigma_8, not sigma_8^2 to avoid confusion?

double log_sigma_8 = log(cosmo->params.sigma_8*cosmo->params.sigma_8) - log(sigma_8);
for (int i=0; i<nk; i++){
y[i] += log_sigma_8;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/benchmark/chi_model1-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#z chi(z,model1) chi(z,model2) chi(z,model3) chi(z,model4) chi(z,model5) [Mpc/h]
0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
1.000000e+00 2.312680e+03 2.265688e+03 2.256882e+03 2.229515e+03 2.285537e+03
2.000000e+00 3.625903e+03 3.552025e+03 3.533010e+03 3.479886e+03 3.589083e+03
3.000000e+00 4.448980e+03 4.365270e+03 4.341011e+03 4.273092e+03 4.412740e+03
4.000000e+00 5.019256e+03 4.931431e+03 4.904493e+03 4.827755e+03 4.985477e+03
5.000000e+00 5.442759e+03 5.352957e+03 5.324543e+03 5.242161e+03 5.411408e+03

8 changes: 8 additions & 0 deletions tests/benchmark/growth_model1-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#z G(z,model1) G(z,model2) G(z,model3) G(z,model4) G(z,model5)
0.000000e+00 7.789810e-01 7.567071e-01 7.479643e-01 7.157714e-01 7.831042e-01
1.000000e+00 4.765851e-01 4.687370e-01 4.645434e-01 4.480479e-01 4.823812e-01
2.000000e+00 3.282982e-01 3.256412e-01 3.238049e-01 3.149879e-01 3.331885e-01
3.000000e+00 2.483706e-01 2.472678e-01 2.463657e-01 2.410459e-01 2.519587e-01
4.000000e+00 1.993271e-01 1.987894e-01 1.982932e-01 1.947702e-01 2.019652e-01
5.000000e+00 1.663410e-01 1.660466e-01 1.657487e-01 1.632542e-01 1.683326e-01

7 changes: 7 additions & 0 deletions tests/benchmark/model1_chi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [1] z, [2] chi(z) (Mpc/h)
0.000000000000000000e+00 0.000000000000000000e+00
1.000000000000000000e+00 2.312680164121228700e+03
2.000000000000000000e+00 3.625903452087460209e+03
3.000000000000000000e+00 4.448979805408229367e+03
4.000000000000000000e+00 5.019256490124302218e+03
5.000000000000000000e+00 5.442759346824006570e+03
7 changes: 7 additions & 0 deletions tests/benchmark/model1_gf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [1] z, [2] D(z)
0.000000000000000000e+00 7.789810171220978852e-01
1.000000000000000000e+00 4.765850679945813351e-01
2.000000000000000000e+00 3.282981974613269904e-01
3.000000000000000000e+00 2.483706199262521175e-01
4.000000000000000000e+00 1.993271080152875518e-01
5.000000000000000000e+00 1.663409724161224179e-01
42 changes: 42 additions & 0 deletions tests/benchmark/model1_pk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# [0] k (Mpc/h)^-1, [2] P(k,z=0.0) (Mpc/h)^3, [3] P(k,z=1.0) (Mpc/h)^3, [4] P(k,z=2.0) (Mpc/h)^3, [5] P(k,z=3.0) (Mpc/h)^3, [6] P(k,z=4.0) (Mpc/h)^3, [7] P(k,z=5.0) (Mpc/h)^3
1.000000000000000021e-03 1.890711719536719102e+03 7.077052698823362107e+02 3.358215513377599564e+02 1.922082434013981356e+02 1.237953404645469391e+02 8.621246031916035690e+01
1.258925411794167490e-03 2.342301858687763797e+03 8.767382948547533488e+02 4.160314001113733298e+02 2.381165362874673121e+02 1.533634414336011105e+02 1.068040166890670548e+02
1.584893192461114082e-03 2.895181452646608705e+03 1.083684598837549174e+03 5.142319248279306976e+02 2.943218342550214288e+02 1.895635225262419397e+02 1.320141582262072291e+02
1.995262314968878920e-03 3.567429521857798136e+03 1.335311272715446648e+03 6.336342573747624556e+02 3.626620360837407588e+02 2.335793170784782262e+02 1.626672500712733154e+02
2.511886431509579437e-03 4.376865721868949549e+03 1.638288325463492129e+03 7.774034621604034783e+02 4.449486737250242641e+02 2.865775763737993884e+02 1.995758308735610171e+02
3.162277660168379394e-03 5.337948469712086990e+03 1.998027633372497348e+03 9.481075922557749891e+02 5.426515783072109116e+02 3.495049728427843547e+02 2.433991739066060518e+02
3.981071705534973415e-03 6.456404832034350875e+03 2.416672873453224383e+03 1.146763869052263090e+03 6.563529588517583306e+02 4.227364891748194395e+02 2.943984213112011616e+02
5.011872336272724625e-03 7.721052932704623345e+03 2.890038599250036896e+03 1.371386207124777457e+03 7.849160747615218270e+02 5.055399861715377483e+02 3.520637031572630917e+02
6.309573444801930275e-03 9.093378568852336684e+03 3.403708702767637533e+03 1.615133849512390043e+03 9.244256029318398760e+02 5.953937262206869718e+02 4.146388531543981344e+02
7.943282347242813790e-03 1.049799114984343032e+04 3.929464012495129282e+03 1.864616185239670585e+03 1.067217396129141662e+03 6.873614709000214589e+02 4.786862196308485409e+02
1.000000000000000021e-02 1.182053640158683447e+04 4.424501005520173749e+03 2.099522011212805410e+03 1.201666290177752899e+03 7.739558141981432300e+02 5.389914892592404385e+02
1.258925411794167490e-02 1.292057630279330624e+04 4.836252848553875992e+03 2.294907221099329490e+03 1.313495467993476041e+03 8.459815030894194479e+02 5.891509849413711208e+02
1.584893192461114125e-02 1.366045909531974212e+04 5.113195624100070745e+03 2.426322594805916651e+03 1.388711361778316586e+03 8.944257165875582132e+02 6.228880772925756446e+02
1.995262314968879874e-02 1.393878347887514064e+04 5.217374188681650594e+03 2.475757590789122787e+03 1.417005596328292313e+03 9.126491514273591292e+02 6.355790812278577278e+02
2.511886431509580825e-02 1.371131244639128272e+04 5.132230352754168052e+03 2.435354987777888255e+03 1.393881072834494944e+03 8.977553663932974359e+02 6.252068826747232606e+02
3.162277660168379134e-02 1.299231003429106386e+04 4.863103234725770562e+03 2.307648313644483096e+03 1.320787861847780732e+03 8.506783067437244199e+02 5.924218915615570040e+02
3.981071705534973415e-02 1.184453447320124178e+04 4.433483634428133882e+03 2.103784464105750430e+03 1.204105914972143182e+03 7.755271005107524616e+02 5.400857506293981487e+02
5.011872336272724798e-02 1.036937525194140835e+04 3.881322274230444236e+03 1.841771882793214672e+03 1.054142406666814622e+03 6.789402775973028383e+02 4.728216063850978230e+02
6.309573444801933051e-02 8.699029726647089774e+03 3.256101454704968546e+03 1.545090998141021146e+03 8.843364145778277816e+02 5.695735291604178201e+02 3.966573790040939684e+02
7.943282347242817953e-02 6.983222940396896774e+03 2.613864199716845633e+03 1.240335444557430037e+03 7.099088670074575020e+02 4.572301808432723078e+02 3.184202141595313265e+02
1.000000000000000056e-01 5.365070630179017826e+03 2.008179628356557942e+03 9.529249347990730712e+02 5.454087954793121753e+02 3.512808105098616238e+02 2.446358871288619241e+02
1.258925411794167559e-01 3.952925803802648261e+03 1.479604951880489125e+03 7.021047481957423315e+02 4.018512802317302999e+02 2.588198881174482153e+02 1.802450661745646698e+02
1.584893192461114264e-01 2.803046435120210845e+03 1.049197883189480763e+03 4.978672277678055025e+02 2.849554619564220275e+02 1.835309339800715236e+02 1.278129960604350686e+02
1.995262314968880846e-01 1.921221383986656065e+03 7.191252288800264978e+02 3.412405703984144338e+02 1.953098315229999287e+02 1.257929767297754040e+02 8.760363656700504009e+01
2.511886431509582351e-01 1.278316043721408505e+03 4.784817227125725481e+02 2.270499899411736351e+02 1.299525880845131098e+02 8.369841272923422082e+01 5.828851117593006137e+01
3.162277660168379412e-01 8.289227628011475417e+02 3.102709955717313051e+02 1.472303393831357710e+02 8.426762605167643017e+01 5.427415220387226924e+01 3.779712690052685531e+01
3.981071705534973137e-01 5.256082603434318798e+02 1.967384725524835005e+02 9.335668656442395275e+01 5.343291597231451107e+01 3.441447623550826052e+01 2.396662633443892076e+01
5.011872336272724660e-01 3.268153866409423927e+02 1.223290515494878719e+02 5.804779703259233514e+01 3.322379119657450275e+01 2.139840867341822062e+01 1.490209123968256222e+01
6.309573444801935826e-01 1.997347913300141329e+02 7.476198668601659847e+01 3.547618962080827032e+01 2.030487936949673511e+01 1.307774011226470989e+01 9.107484548788823631e+00
7.943282347242821562e-01 1.202191370455832526e+02 4.499877794628211802e+01 2.135289937961929496e+01 1.222138145968938971e+01 7.871410986207184379e+00 5.481738688691067729e+00
1.000000000000000000e+00 7.138269927636177670e+01 2.671899260701978207e+01 1.267874343928984970e+01 7.256708199027636752e+00 4.673819635687700647e+00 3.254900292438991816e+00
1.258925411794167504e+00 4.187371799173681097e+01 1.567359560217895798e+01 7.437462195299958445e+00 4.256848728821212902e+00 2.741703625010407208e+00 1.909353083008808794e+00
1.584893192461114042e+00 2.429779110773874606e+01 9.094815796487649706e+00 4.315688012914539406e+00 2.470094038713063433e+00 1.590910603471584528e+00 1.107927945902009714e+00
1.995262314968880846e+00 1.396200865813057668e+01 5.226067519126051941e+00 2.479882765265520650e+00 1.419366649502736166e+00 9.141698322078124495e-01 6.366381003391664573e-01
2.511886431509582351e+00 7.952542005274587211e+00 2.976686412814169902e+00 1.412502480253519765e+00 8.084490690014868308e-01 5.206968544854672087e-01 3.626191158502925505e-01
3.162277660168379523e+00 4.493784314928250367e+00 1.682051689069007816e+00 7.981701305507721278e-01 4.568345245190298387e-01 2.942328825132030645e-01 2.049070717288125343e-01
3.981071705534973137e+00 2.521126078237331924e+00 9.436733232094909329e-01 4.477935276770791395e-01 2.562956636298791557e-01 1.650720509025634386e-01 1.149580233378434818e-01
5.011872336272724660e+00 1.405216001748377908e+00 5.259811739062950631e-01 2.495895131952822199e-01 1.428531364695686257e-01 9.200725396957662450e-02 6.407488118826801249e-02
6.309573444801936049e+00 7.786006880451981083e-01 2.914351269788584831e-01 1.382923098377228655e-01 7.915192412143987055e-02 5.097928799325553845e-02 3.550254659605920488e-02
7.943282347242821118e+00 4.290793701381802605e-01 1.606071027681522378e-01 7.621156532638406755e-02 4.361986608632553025e-02 2.809419657354474131e-02 1.956511285648154103e-02
1.000000000000000000e+01 2.352958000243635939e-01 8.807269555573751796e-02 4.179241064142912021e-02 2.391998311275674027e-02 1.540611578851978740e-02 1.072899142331231424e-02
7 changes: 7 additions & 0 deletions tests/benchmark/model1_sm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [1] M (M_sun/h), [2] sigma(M)
1.000000000000000000e+06 8.105509216633080882e+00
1.000000000000000000e+08 5.848043348128250329e+00
1.000000000000000000e+10 3.831633778198952900e+00
1.000000000000000000e+12 2.147707459501027039e+00
1.000000000000000000e+14 9.168025874807437248e-01
1.000000000000000000e+16 2.384040593203513581e-01
7 changes: 7 additions & 0 deletions tests/benchmark/model2_chi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [1] z, [2] chi(z) (Mpc/h)
0.000000000000000000e+00 0.000000000000000000e+00
1.000000000000000000e+00 2.265688469419004832e+03
2.000000000000000000e+00 3.552025213618237103e+03
3.000000000000000000e+00 4.365269918649795727e+03
4.000000000000000000e+00 4.931431444916223882e+03
5.000000000000000000e+00 5.352957219062010154e+03
7 changes: 7 additions & 0 deletions tests/benchmark/model2_gf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [1] z, [2] D(z)
0.000000000000000000e+00 7.567071110262167943e-01
1.000000000000000000e+00 4.687370169138532217e-01
2.000000000000000000e+00 3.256412104875131552e-01
3.000000000000000000e+00 2.472678048453977873e-01
4.000000000000000000e+00 1.987893710005104453e-01
5.000000000000000000e+00 1.660465764960981083e-01
Loading