Changeset 3285 in Sophya for trunk/Cosmo/SimLSS


Ignore:
Timestamp:
Jul 29, 2007, 9:01:31 PM (18 years ago)
Author:
cmv
Message:

update logique Init_Spline de CosmoCalc cmv 29/07/07

Location:
trunk/Cosmo/SimLSS
Files:
4 edited

Legend:

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

    r3283 r3285  
    6060 double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
    6161 double zref = 0.5;
    62  double perc=0.01,dzinc=-1.,dzmax=5.; unsigned short glorder=4;
     62 double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
    6363
    6464 // *** Spectrum and variance definition
     
    193193 univ.SetInteg(perc,dzinc,dzmax,glorder);
    194194 univ.SetDynParam(h100,om0,or0,ol0,w0);
     195 univ.PrtInteg();
    195196 univ.Print();
    196197 double loscomref = univ.Dloscom(zref);
  • trunk/Cosmo/SimLSS/cmvtuniv.cc

    r3248 r3285  
    4242 cout<<"z1="<<z1<<"  z2="<<z2<<"  dz="<<dz<<endl;
    4343
    44  double perc=0.01,dzinc=-1.,dzmax=5.; unsigned short glorder=4;
     44 double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
    4545 if(narg>2) sscanf(arg[2],"%lf,%lf,%lf,%hu",&perc,&dzinc,&dzmax,&glorder);
    46  if(dzinc<=0.) dzinc = dz/2.;
    4746 cout<<" perc="<<perc<<" dzinc="<<dzinc<<" dzmax="<<dzmax<<" glorder="<<glorder<<endl;
    4847
     
    5049 univ.SetInteg(perc,dzinc,dzmax,glorder);
    5150 univ.SetDynParam(h100,om0,or0,ol0,w0);
     51 univ.PrtInteg();
    5252 univ.Print();
    5353
     
    5555 univ1.SetInteg(perc,dzinc,dzmax,glorder);
    5656 univ1.SetDynParam(h100,om0,or0,ol0,w0);
     57 univ1.PrtInteg();
    5758 univ1.Print();
    5859
     
    202203 vector<double> Dinterp;
    203204 double zmin = Z[0], zmax = Z[0];
    204  for(int i=0;i<Z.size();i+=ninc) {
     205 for(unsigned int i=0;i<Z.size();i+=ninc) {
    205206   Dinterp.push_back(D[i]);
    206207   zmax = Z[i];
     
    214215 double xnt[n];
    215216   
    216  for(int i=0;i<Z.size();i++) {
     217 for(unsigned int i=0;i<Z.size();i++) {
    217218   if(Z[i]>zmax) break;
    218219   xnt[0] = Z[i];
  • trunk/Cosmo/SimLSS/cosmocalc.cc

    r3267 r3285  
    106106void CosmoCalc::SetInteg(double dperc,double dzinc,double dzmax,unsigned short order)
    107107{
    108   _dperc = fabs(dperc);
    109 
    110   _dzinc = fabs(dzinc);
    111   if(_dzinc>_zmax/5.) _dzinc = _zmax/5.; // Protection against big dzinc
    112 
    113   _dzmax = fabs(dzmax);
     108  _dperc = dperc; _dzinc = dzinc; _dzmax = dzmax;
     109
     110  if(_dperc<=0.) _dperc = 0.01;
     111
     112  if(_dzinc<=0.) _dzinc = _zmax/100.;
     113  if(_dzinc>=_zmax/2.) _dzinc = _zmax/2.; // Protection against big dzinc
     114
     115  if(_dzmax<=0.) _dzmax = _zmax;
    114116  if(_dzmax<_dzinc) _dzmax = _dzinc;
    115117
     
    119121
    120122  _computespl=true;
     123}
     124
     125
     126void CosmoCalc::PrtInteg(void)
     127{
     128 printf("CosmoCalc::PrtInteg: dperc=%g dzinc=%g dzmax=%g glorder=%hu\n",_dperc,_dzinc,_dzmax,_glorder);
    121129}
    122130
     
    369377  if(_usespline) {
    370378    if( (!_computespl) && (z==_zold) ) return _integval;
    371     if(z>_zmax) {_zmax = z; _computespl = true;}
     379    if(z>_zmax) {_zmax = z+_dzmax; _computespl = true;}
    372380    if(_computespl) Init_Spline();
    373381    _integval = _spline->CSplineInt(z);
     
    392400  //-- Look for intervalles and integrate
    393401  vector<double> x,y;
     402  x.push_back(0.); y.push_back(0.);
    394403  double zbas=0., fbas = Integrand(zbas);
    395   x.push_back(zbas); y.push_back(0.);
    396   for(double z=_dzinc;z<_zmax+_dzinc && zbas<_zmax;z+=_dzinc) {
     404  for(double z=_dzinc;;z+=_dzinc) {
    397405    double f = Integrand(z);
    398     bool doit = false;
    399406    //cout<<fbas<<","<<f<<"  :  "<<fabs(f-fbas)<<" >? "<<_dperc*fabs(fbas)<<endl;
    400     if( fabs(f-fbas)>_dperc*fabs(fbas) ) doit = true;
    401     if( z-zbas>_dzmax ) doit = true;
    402     if( z>_zmax ) {doit = true; z=_zmax;}
    403     if( ! doit ) continue;
    404     x.push_back(z);
    405     double sum = 0., dz = z-zbas;
    406     for(unsigned short i=0;i<_glorder;i++) sum += _wgausl[i]*Integrand(zbas+_xgausl[i]*dz);
    407     y.push_back(sum*dz);
    408     //cout<<"...set... "<<zbas<<","<<z<<"  ,  "<<fbas<<","<<f<<endl;
    409     zbas = z;
    410     fbas = f;
     407    if( z>_zmax || z-zbas>_dzmax || fabs(f-fbas)>_dperc*fabs(fbas) ) {
     408      double sum=0.,  dz=z-zbas;
     409      for(unsigned short i=0;i<_glorder;i++) sum += _wgausl[i]*Integrand(zbas+_xgausl[i]*dz);
     410      x.push_back(z); y.push_back(sum*dz);
     411      //cout<<"...set... "<<zbas<<","<<z<<"  ,  "<<fbas<<","<<f<<endl;
     412      zbas = z;  fbas = f;
     413      if( z>_zmax ) break;
     414    }
     415  }
     416
     417  //-- Protection car il faut au moins 4 points pour un spline cubique
     418  if(x.size()<4) {
     419    x.resize(0); y.resize(0);
     420    x.push_back(0.); y.push_back(0.);
     421    for(int i=1;i<4;i++) {
     422      x.push_back(i*_zmax/3.);
     423      double sum=0., dz=x[i]-x[i-1];
     424      for(unsigned short i=0;i<_glorder;i++) sum += _wgausl[i]*Integrand(x[i-1]+_xgausl[i]*dz);
     425      y.push_back(sum*dz);
     426    }
    411427  }
    412428
     
    420436    if(i!=0) _yspl[i] += _yspl[i-1];
    421437  }
     438
     439#if 1
     440  cout<<"CosmoCalc::Init_Spline called: (zmax="<<_zmax<<") _nspl="<<_nspl<<endl;
     441  int n = (_nspl>5)? 5: _nspl;
     442  cout<<_nspl<<"...";
     443  for(int i=0;i<n;i++) cout<<_xspl[i]<<" ("<<_yspl[i]<<") ";
     444  cout<<"\n... ";
     445  n = (_nspl<5)? 0: _nspl-5;
     446  for(int i=n;i<_nspl;i++) cout<<_xspl[i]<<" ("<<_yspl[i]<<") ";
     447  cout<<endl;
     448#endif
     449
    422450  double yp1 = Integrand(_xspl[0]);
    423451  double ypn = Integrand(_xspl[_nspl-1]);
     
    426454  _computespl = false;
    427455
    428   cout<<"CosmoCalc::Init_Spline called: (zmax="<<_zmax<<") _nspl="<<_nspl<<endl;
    429   for(int i=0;i<(10<_nspl?10:_nspl);i++) cout<<_xspl[i]<<" ";
    430   cout<<" ... "<<_xspl[_nspl-1]<<endl;
    431 
    432456  return _nspl;
    433457}
  • trunk/Cosmo/SimLSS/cosmocalc.h

    r3115 r3285  
    2121
    2222  double ZMax(void) { return _zmax;}
    23   void SetInteg(double dperc=0.01,double dzinc=0.05,double dzmax=5.,unsigned short order=4);
     23  void SetInteg(double dperc=-1.,double dzinc=-1.,double dzmax=-1.,unsigned short order=4);
     24  void PrtInteg(void);
    2425
    2526  void SetDynParam(double h100,double om0,double or0,double ol0,double w0=-1.);
Note: See TracChangeset for help on using the changeset viewer.