source: Sophya/trunk/Cosmo/SimLSS/cmvtransf.cc@ 4047

Last change on this file since 4047 was 3805, checked in by cmv, 15 years ago

Refonte totale de la structure des classes InitialSpectrum, TransfertFunction, GrowthFactor, PkSpectrum et classes tabulate pour lecture des fichiers CAMB, cmv 24/07/2010

File size: 3.6 KB
RevLine 
[3115]1#include "sopnamsp.h"
2#include "machdefs.h"
3#include <iostream>
4#include <stdlib.h>
5#include <stdio.h>
6#include <string.h>
7#include <math.h>
8#include <unistd.h>
9#include "timing.h"
10#include "ntuple.h"
11
12#include "constcosmo.h"
13#include "pkspectrum.h"
14
15void usage(void);
[3318]16void usage(void) {
17cout
18<<"cmvtransf [options]"<<endl
[3805]19<<" -k npt,k1,k2 : k range in Mpc^-1"<<endl
[3318]20<<" -U h100,Om0,Ob0,tcmb : cosmology"<<endl
[3805]21<<" -F filename : read also CAMB file"<<endl
[3318]22<<endl;
23}
[3115]24
25int main(int narg,char *arg[])
26{
27 double k1 = 1e-6, k2 = 10.; int_4 npt = 100;
28 double h100 = 0.71, Om0 = 0.267804, Ob0 = 0.0444356, tcmb = T_CMB_Par;
[3805]29 string fcmbfile = "";
[3115]30
[3318]31 char c;
32 while((c = getopt(narg,arg,"hk:U:F:")) != -1) {
33 switch (c) {
34 case 'k' :
35 sscanf(optarg,"%d,%lf,%lf",&npt,&k1,&k2);
36 break;
37 case 'U' :
38 sscanf(optarg,"%lf,%lf,%lf,%lf",&h100,&Om0,&Ob0,&tcmb);
39 break;
40 case 'F' :
[3805]41 fcmbfile = optarg;
[3318]42 break;
43 case 'h' :
44 default :
45 usage(); return -1;
46 }
47 }
48
[3115]49 if(k1<=0.) {cout<<"k1 must be >0"<<endl; return -1;}
[3318]50 if(npt<=0) npt = 1000;
51 if(k2<=k1) {k1=1.e-4; k2=1.e+2;}
[3115]52 cout<<"k1="<<k1<<" k2="<<k2<<" npt="<<npt<<endl;
53 cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Tcmb="<<tcmb<<endl;
[3805]54 cout<<"fcmbfile="<<fcmbfile<<endl;
[3115]55
56 cout<<"TransfertEisenstein with baryon"<<endl;
57 TransfertEisenstein tf(h100,Om0-Ob0,Ob0,tcmb);
58 cout<<"KPeak = "<<tf.KPeak()<<" 1/Mpc"<<endl;
59
60 cout<<endl<<"TransfertEisenstein with baryon without oscillation approx.1"<<endl;
61 TransfertEisenstein tfnosc1(h100,Om0-Ob0,Ob0,tcmb); // No oscillation approx.1
62 tfnosc1.SetNoOscEnv(1);
63
64 cout<<endl<<"TransfertEisenstein with baryon without oscillation approx.2"<<endl;
65 TransfertEisenstein tfnosc2(h100,Om0-Ob0,Ob0,tcmb); // No oscillation approx.2
66 tfnosc2.SetNoOscEnv(2);
67
68 cout<<endl<<"TransfertEisenstein without baryon"<<endl;
69 TransfertEisenstein tfnob(h100,Om0-Ob0,Ob0,tcmb,true); // No baryons
70
[3805]71 TransfertTabulate tf_cmbfile;
72 bool cmbfileOK = false;
73 if(fcmbfile.size()>0) {
74 cout<<endl<<"TransfertTabulate for CAMB"<<endl;
75 tf_cmbfile.ReadCAMB(fcmbfile,h100);
76 tf_cmbfile.SetInterpTyp(1);
77 if(tf_cmbfile.NPoints()>0) cmbfileOK = true;
[3318]78 }
79
80 const int n = 6;
[3572]81 const char *vname[n] = {"k","t","tnosc1","tnosc2","tnob","tcmbf"};
[3115]82 NTuple nt(n,vname);
83 double xnt[n];
[3318]84 for(int i=0;i<n;i++) xnt[i]=0.;
[3115]85
86 double lnk1 = log10(k1), lnk2=log10(k2), dlnk=(lnk2-lnk1)/npt;
87 for(double lnk=lnk1;lnk<lnk2+dlnk/2.;lnk+=dlnk) {
88 double k = pow(10.,lnk);
89 xnt[0] = k;
90 xnt[1] = tf(k);
91 xnt[2] = tfnosc1(k);
92 xnt[3] = tfnosc2(k);
93 xnt[4] = tfnob(k);
[3805]94 if(cmbfileOK) xnt[5] = tf_cmbfile(k);
[3115]95 nt.Fill(xnt);
96 }
97
98 cout<<">>>> Ecriture"<<endl;
99 string tag = "cmvtransf.ppf";
100 POutPersist pos(tag);
101 tag = "nt"; pos.PutObject(nt,tag);
102
103 return 0;
104}
105
106/*
107openppf cmvtransf.ppf
108
[3318]109# Eisenstein
[3805]110n/plot nt.t%k t>0&&k>0 ! "nsta connectpoints logx logy"
111n/plot nt.tnob%k tnob>0&&k>0 ! "nsta red same connectpoints logx logy"
112n/plot nt.tnosc2%k tnosc2>0&&k>0 ! "nsta blue same connectpoints logx logy"
113n/plot nt.tnosc1%k tnosc1>0&&k>0 ! "nsta green same connectpoints logx logy"
[3115]114
[3805]115n/plot nt.t/tnob%k tnob>0 ! "nsta red connectpoints"
116n/plot nt.t/tnosc2%k tnosc2>0 ! "nsta blue same connectpoints"
117n/plot nt.t/tnosc1%k tnosc1>0 ! "nsta green same connectpoints"
[3318]118
[3805]119# CAMB
120n/plot nt.t%k t>0&&k>0 ! "nsta connectpoints logx logy"
121n/plot nt.tcmbf%k tcmbf>0&&k>0 ! "nsta red same connectpoints logx logy"
[3318]122
[3805]123n/plot nt.(tcmbf-t)%k tcmbf>0. ! "nsta connectpoints"
124n/plot nt.(tcmbf-t)/tcmbf%k tcmbf>0. ! "nsta connectpoints"
125
126n/plot nt.t/tnosc2%k tnosc2>0&&t>0&&k>0 ! "nsta connectpoints logx logy"
127n/plot nt.tcmbf/tnosc2%k tnosc2>0&&tcmbf>0&&k>0 ! "nsta connectpoints same red logx logy"
[3115]128*/
Note: See TracBrowser for help on using the repository browser.