Changeset 3313 in Sophya for trunk/Cosmo


Ignore:
Timestamp:
Aug 24, 2007, 4:59:12 PM (18 years ago)
Author:
cmv
Message:

nettoyage et mise en forme cmv 24/08/2007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/SimLSS/cmvtuniv.cc

    r3285 r3313  
    1313#include "geneutils.h"
    1414
    15 void usage(void);
    16 void usage(void) {cout<<"cmvtuniv z1,z2,dz [perc,dzinc,dzmax,glorder]"<<endl;}
    17 
    1815void tstprint(CosmoCalc& univ,double z1,double z2,double dz);
    1916void tstprint(CosmoCalc& univ1,CosmoCalc& univ2,double z1,double z2,double dz);
     
    2320
    2421const double deg2rad = M_PI/180.;
     22
     23void usage(void);
     24void usage(void) {
     25 cout
     26 <<"cmvtuniv [options] z1,z2"<<endl
     27 <<"  -D dz"<<endl
     28 <<"  -U h100,om0,or0,ol0,w0"<<endl
     29 <<"  -F flat(0,1,2)"<<endl
     30 <<"  -I perc,dzinc,dzmax,glorder"<<endl
     31 <<" --- What has to be done:"<<endl
     32 <<"  -W 1/2/3/4/5"<<endl
     33 <<"     1 : print info from z1 to z2 by step dz"<<endl
     34 <<"     2 : compare with/without spline from z1 to z2 by step dz"<<endl
     35 <<"     3 : test speed from z1 to z2 by step dz"<<endl
     36 <<"     4 : fill ntuple with infos from z1 to z2 by step dz"<<endl
     37 <<"     5 : test interpolation loscom from z1 to z2 by step dz"<<endl
     38 <<endl;
     39}
    2540
    2641int main(int narg,char *arg[])
     
    3651 //double h100=0.71, om0=0., or0=0., ol0=1.,w0=-1.; flat = 2;
    3752
     53 // -- parametre d'integration
     54 double perc=0.01,dzinc=-1.,dzmax=-1.;
     55 unsigned short glorder=4;
     56 // -- redshift
    3857 double z1=0., z2=-1., dz=-1.;
    39  if(narg>1) sscanf(arg[1],"%lf,%lf,%lf",&z1,&z2,&dz);
     58 // -- Work to be done
     59 int todo = 1;
     60
     61 InitTim();
     62
     63 // Read arguments
     64 char c;
     65 while ((c = getopt(narg, arg, "hD:U:F:I:W:")) != -1) {
     66  switch (c) {
     67  case 'D' :
     68    sscanf(optarg,"%lf",&dz);
     69    break;
     70  case 'U' :
     71    sscanf(optarg,"%lf,%lf,%lf,%lf,%lf",&h100,&om0,&or0,&ol0,&w0);
     72    break;
     73  case 'F' :
     74    sscanf(optarg,"%hu",&flat);
     75    break;
     76  case 'I' :
     77    sscanf(optarg,"%lf,%lf,%lf,%hu",&perc,&dzinc,&dzmax,&glorder);
     78    break;
     79  case 'W' :
     80    sscanf(optarg,"%d",&todo);
     81    break;
     82  case 'h' :
     83  default:
     84    usage();
     85    return -1;
     86  }
     87}
     88 if(optind<narg) sscanf(arg[optind],"%lf,%lf",&z1,&z2);
     89
     90 if(z1<0.) z1 = 0.;
    4091 if(z2<=z1) z2 = z1+1.;
    41  if(dz<0.) dz = 10.*(z2-z1);
     92 if(dz<=0.) dz = 10.*(z2-z1);
    4293 cout<<"z1="<<z1<<"  z2="<<z2<<"  dz="<<dz<<endl;
    43 
    44  double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
    45  if(narg>2) sscanf(arg[2],"%lf,%lf,%lf,%hu",&perc,&dzinc,&dzmax,&glorder);
    46  cout<<" perc="<<perc<<" dzinc="<<dzinc<<" dzmax="<<dzmax<<" glorder="<<glorder<<endl;
    47 
    48  CosmoCalc univ(flat,true,z2);
    49  univ.SetInteg(perc,dzinc,dzmax,glorder);
    50  univ.SetDynParam(h100,om0,or0,ol0,w0);
    51  univ.PrtInteg();
    52  univ.Print();
    53 
    54  CosmoCalc univ1(univ);
     94 cout<<"perc="<<perc<<" dzinc="<<dzinc<<" dzmax="<<dzmax<<" glorder="<<glorder<<endl;
     95 cout<<"h100="<<h100<<" om0="<<om0<<" or0="<<or0<<" ol0="<<ol0<<" w0="<<w0<<" flat="<<flat<<endl;
     96 cout<<"todo ="<<todo<<endl;
     97
     98 CosmoCalc univ1(flat,true,z2);
    5599 univ1.SetInteg(perc,dzinc,dzmax,glorder);
    56100 univ1.SetDynParam(h100,om0,or0,ol0,w0);
    57101 univ1.PrtInteg();
    58102 univ1.Print();
    59 
    60  tstprint(univ,z1,z2,dz);
    61  //tstprint(univ,univ1,z1,z2,dz);
    62  //tstspeed(univ,z1,z2,dz);
    63  //tstntuple(univ,z1,z2,dz);
    64  //tstinterp(univ,z1,z2,dz);
     103 cout<<endl;
     104
     105 if(todo==1)  tstprint(univ1,z1,z2,dz);
     106 else if(todo==2) {
     107   CosmoCalc univ2(flat,false,z2);
     108   univ2.SetInteg(perc,dzinc,dzmax,glorder);
     109   univ2.SetDynParam(h100,om0,or0,ol0,w0);
     110   univ2.PrtInteg();
     111   univ2.Print();
     112   tstprint(univ1,univ2,z1,z2,dz);
     113 }
     114 else if(todo==3) tstspeed(univ1,z1,z2,dz);
     115 else if(todo==4) tstntuple(univ1,z1,z2,dz);
     116 else if(todo==5)tstinterp(univ1,z1,z2,dz);
     117 else cout<<"Unknown job to be done !!!!!  todo="<<todo<<endl;
    65118
    66119 return 0;
     
    70123void tstprint(CosmoCalc& univ,double z1,double z2,double dz)
    71124{
    72  cout<<"\nTSTPRINT()"<<endl;
    73  double dzz = dz; if(dzz>z2-z1) dzz = 0.01;
    74  for(double z=z1;z<z2+dz/2.;z+=dz) {
    75    cout<<"--"<<endl;
     125 if(dz>z2-z1) dz = z2-z1;
     126 cout<<"\nTSTPRINT(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl;
     127 for(double z=z1;z<z2+dz/2.;z+=dz) {
     128   cout<<"-- z = "<<z<<endl;
    76129   univ.Print(z);
    77    cout<<"Volume comoving in [z,z+"<<dzz<<"] for 4Pi sr: "
    78        <<univ.Vol4Pi(z,z+dzz)<<" Mpc^3"<<endl;
     130   cout<<"Volume comoving in [z,z+"<<dz<<"] for 4Pi sr: "
     131       <<univ.Vol4Pi(z,z+dz)<<" Mpc^3"<<endl;
    79132   double dang = univ.Dang(z);
    80133   double a = deg2rad/3600.;
     
    86139   double dloscom = univ.Dhubble() / univ.E(z);
    87140   cout<<"dz=1 -> "<<dloscom<<" Mpc com"<<endl;
    88 
    89  }
     141 }
     142
    90143}
    91144
     
    93146void tstprint(CosmoCalc& univ1,CosmoCalc& univ2,double z1,double z2,double dz)
    94147{
    95  cout<<"\nTSTPRINT()"<<endl;
    96  for(double z=z1;z<z2+dz/2.;z+=dz) {
    97    cout<<endl<<"--spline:"<<endl;
     148 if(dz>z2-z1) dz = z2-z1;
     149 cout<<"\nTSTPRINT(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl;
     150 for(double z=z1;z<z2+dz/2.;z+=dz) {
     151   cout<<endl<<"--spline: z = "<<z<<endl;
    98152   univ1.Print(z);
    99153   cout<<"Volume comoving in [z,z+dz] for 4Pi sr: "
    100154       <<univ1.Vol4Pi(z,z+dz)<<" Mpc^3"<<endl;
    101    cout<<"--integ:"<<endl;
     155   cout<<"--integ: z = "<<z<<endl;
    102156   univ2.Print(z);
    103157   cout<<"Volume comoving in [z,z+dz] for 4Pi sr: "
     
    109163void tstspeed(CosmoCalc& univ,double z1,double z2,double dz)
    110164{
    111  cout<<"\nTSTSPEED()"<<endl;
     165 if(dz>z2-z1) dz = z2-z1;
     166 cout<<"\nTSTSPEED(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl;
    112167 double sum = 0.;
    113168 int_4 n=0;
     169 PrtTim("-- Beginning");
    114170 for(double z=z1;z<z2+dz/2.;z+=dz) {
    115171   sum += univ.Dang(z);
    116172   n++;
    117173 }
    118  if(n>0) cout<<"... "<<sum/n<<endl;
     174 if(n>0) cout<<"n="<<n<<" ...dum="<<sum/n<<endl;
     175 PrtTim("-- Ending");
    119176}
    120177
     
    122179void tstntuple(CosmoCalc& univ,double z1,double z2,double dz)
    123180{
    124  cout<<"\nTSTNTUPLE()"<<endl;
     181 if(dz>z2-z1) dz = z2-z1;
     182 cout<<"\nTSTNTUPLE(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl;
    125183 double norm =  univ.Dhubble();  // 1.
    126184 double norm3 = pow(norm,3.);
     
    152210 }
    153211 cout<<">>>> Ecriture"<<endl;
    154  string tag = "cmvtuniv.ppf";
     212 string tag = "cmvtuniv_nt.ppf";
    155213 POutPersist pos(tag);
    156214 tag = "nt"; pos.PutObject(nt,tag);
     
    159217
    160218/*
    161 openppf cmvtuniv.ppf
     219openppf cmvtuniv_nt.ppf
    162220
    163221set cut 1
     
    191249void tstinterp(CosmoCalc& univ,double z1,double z2,double dz)
    192250{
    193  cout<<"\nTSTINTERP()"<<endl;
    194 
    195  // On repmplit les donnes completes
     251 if(dz>z2-z1) dz = z2-z1;
     252 cout<<"\nTSTINTERP(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl;
     253 // On remplit les donnes completes
    196254 vector<double> Z,D;
    197255 for(double z=z1;z<z2+dz/2.;z+=dz) {
     
    226284 }
    227285 cout<<">>>> Ecriture"<<endl;
    228  string tag = "cmvtuniv.ppf";
     286 string tag = "cmvtuniv_int.ppf";
    229287 POutPersist pos(tag);
    230288 tag = "nt"; pos.PutObject(nt,tag);
     
    232290
    233291/*
    234 openppf cmvtuniv.ppf
     292openppf cmvtuniv_int.ppf
    235293
    236294n/plot nt.d%z ! ! "nsta connectpoints"
Note: See TracChangeset for help on using the changeset viewer.