Commit 07468a61 authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

better class tests

parent 4b2c3500
...@@ -11,12 +11,14 @@ ...@@ -11,12 +11,14 @@
using namespace std; using namespace std;
#define PLANCK_CHECKS
// example run: one can specify as a second argument a preicison file // example run: one can specify as a second argument a preicison file
int main(int argc,char** argv){ int main(int argc,char** argv){
//jusqu'a ou en l announce(argv[0]);
const int l_max_scalars=2500;
//macro to add try-catch blocks if macro (PLANCK_CHECKS) defined
PLANCK_DIAGNOSIS_BEGIN
//CLASS config //CLASS config
ClassParams pars; ClassParams pars;
...@@ -44,10 +46,12 @@ int main(int argc,char** argv){ ...@@ -44,10 +46,12 @@ int main(int argc,char** argv){
pars.add("k_pivot",0.05); pars.add("k_pivot",0.05);
pars.add("sBBN file",Parser::CheckPath("bbn/sBBN.dat")); pars.add("sBBN file",Parser::CheckPath("bbn/sBBN.dat"));
//pars.add("l_max_scalars",l_max_scalars); //for cmb:
//pars.add("l_max_scalars",100);
//pars.add("lensing",true); //note boolean //pars.add("lensing",true); //note boolean
//pars.add("output","tCl,pCl,lCl,mPk"); //pol +clphi-> mPk added for sigma8 //pars.add("output","tCl,pCl,lCl,mPk"); //pol +clphi-> mPk added for sigma8
//for structures
pars.add("output","mPk"); //pol +clphi-> mPk added for sigma8 pars.add("output","mPk"); //pol +clphi-> mPk added for sigma8
//need to compute P(k,z) for sigma8(z) //need to compute P(k,z) for sigma8(z)
...@@ -55,71 +59,62 @@ int main(int argc,char** argv){ ...@@ -55,71 +59,62 @@ int main(int argc,char** argv){
pars.add("z_max_pk",1); pars.add("z_max_pk",1);
try{ //the class calculator (engine)
//the class calculator (engine) ClassEngine* engine(0);
ClassEngine* engine(0); //if a precision file is given use it (otherwise use CLASS default)
//if a precision file is given use it (otherwise use CLASS default) if (argc==2){
if (argc==2){ string pre=string(argv[1]);
string pre=string(argv[1]); engine=new ClassEngine(pars,pre);
engine=new ClassEngine(pars,pre); }
} else{
else{ engine=new ClassEngine(pars);
engine=new ClassEngine(pars); }
} cout << "----Engine creating with parameters: " << endl;
cout << "*****************************************" << endl; //engine->printFC();
//test keyword access
const char* derived_par[]={ "H0","H(0)","z_reio","tau_reio","z_drag","rs_drag","sigma8","Dv(0.57)","Da(0.57)","H(0.57)","sigma8(0.57)", "f(0.57)","growthD(0.57)"}; cout << "----Printing some keyword values: " << endl;
const int Nder=sizeof(derived_par)/sizeof(char*);
for (size_t i=0;i<Nder;i++) cout << derived_par[i] << "\t" << engine->get(derived_par[i]) << endl;
//background structure
//valeurs de z?
const double zi[]={0,0.5,1.};
const size_t Nz=sizeof(zi)/sizeof(double);
struct background& ba=engine->ba;
//test keyword access
const char* derived_par[]={ "H0","H(0)","z_reio","tau_reio","z_drag","rs_drag","sigma8","Dv(0.57)","Da(0.57)","H(0.57)","sigma8(0.57)", "f(0.57)","growthD(0.57)"};
const int Nder=sizeof(derived_par)/sizeof(char*);
for (size_t i=0;i<Nder;i++)
cout << derived_par[i] << "\t" << engine->get(derived_par[i]) << endl;
//print filled strcuture //background structure
/* //valeurs de z?
for (int index_tau=0; index_tau<ba.bt_size; index_tau++) { const double zi[]={0,0.5,1.};
const size_t Nz=sizeof(zi)/sizeof(double);
fprintf(stdout,
"tau=%e z=%e a=%e H=%e\n", //interp
ba.tau_table[index_tau], for (size_t i=0;i<Nz;i++){
ba.z_table[index_tau], cout << "z=" << zi[i] << " growthD=" << engine->get_growthD(zi[i]) <<endl;
ba.background_table[index_tau*ba.bg_size+ba.index_bg_a], }
ba.background_table[index_tau*ba.bg_size+ba.index_bg_H]);
}
*/
cout << "size bt=" << ba.bt_size << endl;
//interp
for (size_t i=0;i<Nz;i++){
cout << "z=" << zi[i] << " D=" << engine->get_growthD(zi[i]) <<endl;
}
//test pk cout << "----Testing Pk output: " << endl;
struct spectra& sp=engine->sp; //test pk
cout << "ln_tau_size=" << sp.ln_tau_size << endl; double kval[]={1e-4,3e-4,1e-3,2e-3,1e-2,3e-2,0.1};
const vector<double> kvec(kval,kval+sizeof(kval)/sizeof(double));
vector<double> pkvec(kvec.size());
double kval[]={1e-4,3e-4,1e-3,2e-3,1e-2,3e-2,0.1}; engine->get_Pkvec(kvec,0.,pkvec);
const vector<double> kvec(kval,kval+sizeof(kval)/sizeof(double)); for (size_t i=0;i<kvec.size();i++)
vector<double> pkvec(kvec.size()); cout << "k=" << kvec[i] << "\t p(k)=" << pkvec[i] << endl;
//clean
//spectra_fast_pk_at_kvec(&ba,&sp,const_cast<double*>(&kvec[0]),kvec.size(),&pkvec[0]); cout << "----Testing update: " << endl;
const int i_ns=pars.findIndex("n_s");
cout <<" n_s index=" << i_ns <<endl;
pars.updateVal(i_ns,"1");
engine->updateParValues(pars);
engine->get_Pkvec(kvec,0.,pkvec); for (size_t i=0;i<Nder;i++)
for (size_t i=0;i<kvec.size();i++) cout << "k=" << kvec[i] << "\t p(k)=" << pkvec[i] << endl; cout << derived_par[i] << "\t" << engine->get(derived_par[i]) << endl;
//clean
delete engine;
} delete engine;
//class engine throws std:exceptions
catch(exception& e){ PLANCK_DIAGNOSIS_END
cerr << e.what() << endl;
}
} }
...@@ -238,7 +238,7 @@ void announce (const string &name) ...@@ -238,7 +238,7 @@ void announce (const string &name)
cout << endl; cout << endl;
IO_backend_status(); IO_backend_status();
cout << endl; cout << endl;
CVS_status(); //CVS_status();
cout << endl; cout << endl;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment