Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 77ad8bb5 authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

des trucs vachement cool

parent 2af0c210
......@@ -2,7 +2,7 @@
#cmt stuff
if [ -z "$CMTCLASS" ] ; then
echo "CMTCLASS is undefined"
exit 1
return
else
if [ -z "$CMTPATH" ] ; then
export CMTPATH=${CMTCLASS}
......@@ -20,18 +20,18 @@ fi
source ./setup.sh
if [ -z "$CAMELROOT" ] ; then
echo "CAMELROOT undefined ...something went wrong. do you have a requirements file?"
exit 1
return
fi
#creating link
if [ -z "${CAMEL_DATA}" ] ; then
echo "CAMEL_DATA undefined: review your installation (see http://camel.in2p3.fr/wiki/pmwiki.php?n=Main.Install)"
exit 1
return
fi
if [ ! -d "${CAMEL_DATA}" ] ; then
echo "empty CAMEL_DATA directory : please fix (see http://camel.in2p3.fr/wiki/pmwiki.php?n=Main.Install)"
exit 1
return
fi
echo CAMEL_DATA="${CAMEL_DATA}"
......
......@@ -85,7 +85,7 @@ void ClassParams::updateVal(const unsigned& i,const string& newval) {pars[i].sec
//---------------
// Constructors --
//----------------
ClassEngine::ClassEngine(const ClassParams& pars): cl(0),dofree(true){
ClassEngine::ClassEngine(const ClassParams& pars): cl(0),dofree(true),pvecback(0){
_lmax=-1; //default
......@@ -134,7 +134,7 @@ ClassEngine::ClassEngine(const ClassParams& pars): cl(0),dofree(true){
}
ClassEngine::ClassEngine(const ClassParams& pars,const string & precision_file): cl(0),dofree(true){
ClassEngine::ClassEngine(const ClassParams& pars,const string & precision_file): cl(0),dofree(true),pvecback(0){
cout << "Running CLASS version " << _VERSION_ << endl;
......@@ -271,11 +271,14 @@ int ClassEngine::class_main(
return _FAILURE_;
}
delete [] pvecback;
if (background_init(ppr,pba) == _FAILURE_) {
printf("\n\nError running background_init \n=>%s\n",pba->error_message);
dofree=false;
return _FAILURE_;
}
pvecback=new double[ba.bg_size];
if (thermodynamics_init(ppr,pba,pth) == _FAILURE_) {
printf("\n\nError in thermodynamics_init \n=>%s\n",pth->error_message);
......@@ -525,62 +528,56 @@ double ClassEngine::get_f(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double f_z=pvecback[ba.index_bg_f];
#ifdef DBUG
cout << "f_of_z= "<< f_z <<endl;
#endif
free (pvecback);
return f_z;
}
double ClassEngine::get_growthD(double z)
{
double tau;
int index;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double D=pvecback[ba.index_bg_D];
return D;
}
double ClassEngine::get_Pklin(double k, double z){
double tau;
int index;
double *pvecback;
double * pk_ic = NULL;
double mypk =0.;
//cout << " debut de getpk "<<endl;
background_tau_of_z(&ba,z,&tau);
//cout << " after bkg "<<tau<< endl;
///pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
// int ret = spectra_pk_at_k_and_z(&ba,&pm,&sp,k,z,&mypk,pk_ic);
int ret=spectra_pk_at_k_and_z(&ba,&pm,&sp,k,z,&mypk,pk_ic);
//cout << " z "<<z<< " k "<< k << " tau "<< tau<<" pk "<< mypk<<" return code " << ret<< endl;
free (pvecback);
return mypk;
}
double ClassEngine::get_PkNL(double k, double z){
double tau;
int index;
double *pvecback;
double mypk;
background_tau_of_z(&ba,z,&tau);
//cout << "pknl after bkg "<<tau<< endl;
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
//cout << "pknl after bkg @tau "<<tau<< " z "<<z<< " k "<< k << endl;
int ret = spectra_pk_nl_at_k_and_z(&ba,&pm,&sp,k,z,&mypk);
free (pvecback);
return mypk;
}
......@@ -589,15 +586,11 @@ double ClassEngine::get_sigma8(double z)
{
double tau;
int index;
double *pvecback;
double sigma8 = -99.;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
//background_at_tau(pba,tau,pba->long_info,pba->inter_normal,&last_index,pvecback);
......@@ -605,7 +598,6 @@ double ClassEngine::get_sigma8(double z)
#ifdef DBUG
cout << "sigma_8= " << sigma8 <<" at "<<z<<" tau "<<tau<<" bah "<<ba.h<< "size " << ba.bg_size << " index "<< index<<endl;
#endif
free (pvecback);
planck_assert( sigma8 != -99. , " sigma8 could not be computed at " +str(z) + " \n 1) check z_pk and z_max_pk parameters for class \n 2) that you have enabled the Pk computation with : do_mPk = true \n ");
return sigma8;
......@@ -615,12 +607,9 @@ double ClassEngine::get_Dv(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
// cout << " dv : tau= "<< tau <<endl;
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
......@@ -639,7 +628,6 @@ double ClassEngine::get_Dv(double z)
#ifdef DBUG
cout << D_v << endl;
#endif
free (pvecback);
return D_v;
}
......@@ -647,13 +635,9 @@ double ClassEngine::get_Fz(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
......@@ -665,7 +649,6 @@ double ClassEngine::get_Fz(double z)
cout << "D_ang= "<< D_ang <<endl;
#endif
double F_z = (1.+z) * D_ang * H_z /(3.e8) ; // is there speed of light somewhere ?
free (pvecback);
return F_z;
}
......@@ -673,19 +656,14 @@ double ClassEngine::get_H(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double H_z=pvecback[ba.index_bg_H]*_c_/1e3 ;
free (pvecback);
return(H_z);
}
......@@ -693,19 +671,13 @@ double ClassEngine::com_distance(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double r=pvecback[ba.index_bg_conf_distance];
free (pvecback);
return(r);
}
......@@ -715,13 +687,9 @@ double ClassEngine::get_Da(double z)
{
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
......@@ -732,7 +700,6 @@ double ClassEngine::get_Da(double z)
cout << "H_z= "<< H_z <<endl;
cout << "D_ang= "<< D_ang <<endl;
#endif
free (pvecback);
return D_ang;
}
......@@ -741,18 +708,13 @@ double ClassEngine::get_DMod(double z){
// returns distance modulus at redshift z
double tau;
int index;
double *pvecback;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
//pvecback must be allocated
pvecback=(double *)malloc(ba.bg_size*sizeof(double));
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
double mu = 5.*log10(pvecback[ba.index_bg_lum_distance]) + 25.;
free (pvecback);
return(mu);
}
......@@ -156,8 +156,12 @@ public:
double get_Pklin(double k, double z);
double get_PkNL(double k, double z);
//combile distance
double com_distance(double z);
//linear growth density term
double get_growthD(double z);
//expansion
inline double get_H0() const {return ba.H0*_c_/1e3;}
inline double theta() const {return th.rs_rec/th.ra_rec;}
......@@ -183,7 +187,6 @@ public:
//access to class content:dangerous to use (but sometimes mandatory...)
struct file_content fc;
private:
//structures class en commun
struct precision pr; /* for precision parameters */
struct background ba; /* for cosmological background */
......@@ -196,6 +199,8 @@ private:
struct lensing le; /* for lensed spectra */
struct output op; /* for output files */
private:
ErrorMsg _errmsg; /* for error messages */
double * cl;
......@@ -226,6 +231,8 @@ private:
protected:
std::string _output;
double* pvecback; // helper to avoid too much allocations
};
#endif
......
......@@ -118,6 +118,7 @@ Engine::get(const std::string& key)
else if (var=="z_reio") return get_z_reio();
else if (var=="H") return get_H(z);
else if (var=="com_distance") return com_distance(z);
else if (var=="growthD") return get_growthD(z);
else planck_assert(false,("key="+key+" not found in Engine::get()"));
}
......
......@@ -80,6 +80,8 @@ public:
//distance (comobile Mpc)
virtual double com_distance(double z) { return undef("com_distance");}
//linear growth density
virtual double get_growthD(double z) {return undef("get_growthD");}
//access to P(k,z)
//P(K): convention if NL is defined return it it, oterwise lin
......
......@@ -51,11 +51,9 @@ int main(int argc,char** argv){
pars.add("output","mPk"); //pol +clphi-> mPk added for sigma8
//need to compute P(k,z) for sigma8(z)
pars.add("z_pk","0,0.57");
//pars.add("z_pk","0,0.57");
pars.add("z_max_pk",1);
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)"};
const int Nder=sizeof(derived_par)/sizeof(char*);
try{
//the class calculator (engine)
......@@ -69,43 +67,40 @@ int main(int argc,char** argv){
engine=new ClassEngine(pars);
}
double H0=engine->get_H0();
double theta=engine->theta();
cout << " expansion: H0=" << H0 << " 100*theta_s=" << 100*theta << endl << endl;;
cout << " Omega_m=" << engine->Omega_m() << endl ;
//YHE
cout << " YHe=" << engine->YHe() << endl << endl;;
//reio
double tau=engine->get("tau_reio");
double zreio=engine->get("z_reio");
cout << " reionization : tau_reio=" << tau << " z_reio=" << zreio << endl << endl;;
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;
//background structure
//valeurs de z?
const double zi[]={0,0.5,1.};
const size_t Nz=sizeof(zi)/sizeof(double);
//write output
// engine->writeCls(std::cout);
// //derived parameters
// for (size_t i=0;i<Nder;i++) {
// cout << derived_par[i] << "\t" << engine->get(derived_par[i]) << endl;
// }
//test update: change H0
// int j=pars.findIndex("omega_b");
// pars.updateVal(j,"0.01");//here : use str() or a string
// engine->updateParValues(pars);
// //write output
// engine->writeCls(std::cout);
struct background& ba=engine->ba;
//print filled strcuture
/*
for (int index_tau=0; index_tau<ba.bt_size; index_tau++) {
fprintf(stdout,
"tau=%e z=%e a=%e H=%e\n",
ba.tau_table[index_tau],
ba.z_table[index_tau],
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;
// //derived parameters
// for (size_t i=0;i<Nder;i++) {
// cout << derived_par[i] << "\t" << engine->get(derived_par[i]) << endl;
// }
//interp
for (size_t i=0;i<Nz;i++){
cout << "z=" << zi[i] << " D=" << engine->get_growthD(zi[i]) <<endl;
}
//clean
delete engine;
}
......
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