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 "cosmocalc.h"
|
---|
13 | #include "geneutils.h"
|
---|
14 |
|
---|
15 | int main(int narg,char *arg[])
|
---|
16 | {
|
---|
17 | double zmax = 2.5;
|
---|
18 | unsigned short flat = 0;
|
---|
19 | // -- WMAP
|
---|
20 | double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
|
---|
21 | // -- ouvert matter only
|
---|
22 | //double h100=0.71, om0=0.3, or0=0., ol0=0.,w0=-1.;
|
---|
23 | // -- plat matter only
|
---|
24 | //double h100=0.71, om0=1., or0=0., ol0=0.,w0=-1.; flat = 1;
|
---|
25 | // -- plat lambda only
|
---|
26 | //double h100=0.71, om0=0., or0=0., ol0=1.,w0=-1.; flat = 2;
|
---|
27 |
|
---|
28 | // --- la cosmologie
|
---|
29 | double perc=0.01,dzinc=-1.,dzmax=5.; unsigned short glorder=4;
|
---|
30 | cout<<" perc="<<perc<<" dzinc="<<dzinc<<" dzmax="<<dzmax<<" glorder="<<glorder<<endl;
|
---|
31 | CosmoCalc univ(flat,true,zmax);
|
---|
32 | univ.SetInteg(perc,dzinc,dzmax,glorder);
|
---|
33 | univ.SetDynParam(h100,om0,or0,ol0,w0);
|
---|
34 | univ.Print();
|
---|
35 |
|
---|
36 | // --- Remplissage de Dloscom en fct de z
|
---|
37 | int_4 lmod=10 , nzfin = lmod*100;
|
---|
38 | cout<<"Remplissage de loscom vs z: nzfin="<<nzfin<<" , lmod="<<lmod<<endl;
|
---|
39 | vector<double> zfin, dlcfin;
|
---|
40 | vector<double> zgros, dlcgros;
|
---|
41 | for(int_4 i=0;i<=nzfin;i++) {
|
---|
42 | double z = i*zmax/(nzfin-1.);
|
---|
43 | double loscom = univ.Dloscom(z); // pour test: loscom = z*(z+4);
|
---|
44 | zfin.push_back(z); dlcfin.push_back(loscom);
|
---|
45 | if(i%lmod==0) { // ATTENTION il faut etre equidistant en z !
|
---|
46 | zgros.push_back(z);
|
---|
47 | dlcgros.push_back(loscom);
|
---|
48 | }
|
---|
49 | }
|
---|
50 | nzfin = zfin.size();
|
---|
51 | printf("Fin: z(%d) : [%f,%f] -> loscom : [%f,%f]\n"
|
---|
52 | ,nzfin,zfin[0],zfin[nzfin-1],dlcfin[0],dlcfin[nzfin-1]);
|
---|
53 | int_4 nzgros = zgros.size();
|
---|
54 | printf("Gros: z(%d) : [%f,%f] -> loscom : [%f,%f]\n"
|
---|
55 | ,nzgros,zgros[0],zgros[nzgros-1],dlcgros[0],dlcgros[nzgros-1]);
|
---|
56 |
|
---|
57 | // --- Check interpolation en z
|
---|
58 | cout<<"Check interpolation en z"<<endl;
|
---|
59 | InterpFunc interpgros(zgros[0],zgros[nzgros-1],dlcgros);
|
---|
60 | double xnt[10];
|
---|
61 | vector<string> noms;
|
---|
62 | noms.push_back("z"); noms.push_back("d");
|
---|
63 | noms.push_back("d0"); noms.push_back("d1"); noms.push_back("d2");
|
---|
64 | NTuple ntg(noms);
|
---|
65 | for(int_4 i=0;i<nzfin;i++) {
|
---|
66 | unsigned short ok;
|
---|
67 | double z = zfin[i];
|
---|
68 | xnt[0] = z;
|
---|
69 | xnt[1] = dlcfin[i];
|
---|
70 | xnt[2] = interpgros(z);
|
---|
71 | xnt[3] = interpgros.Linear(z,ok);
|
---|
72 | xnt[4] = interpgros.Parab(z,ok);
|
---|
73 | ntg.Fill(xnt);
|
---|
74 | }
|
---|
75 |
|
---|
76 | // --- Check interpolation en los avec inversion
|
---|
77 | cout<<"Check interpolation en los avec inversion"<<endl;
|
---|
78 | InverseFunc invfun(zgros,dlcgros);
|
---|
79 | vector<double> zbackl;
|
---|
80 | invfun.ComputeLinear(nzfin,zbackl);
|
---|
81 | vector<double> zbackp;
|
---|
82 | invfun.ComputeParab(nzfin,zbackp);
|
---|
83 | printf("YMin=%f , YMax=%f\n",invfun.YMin(),invfun.YMax());
|
---|
84 | printf("Linear ZBack: z(%d) : [%f,%f]\n"
|
---|
85 | ,zbackl.size(),zbackl[0],zbackl[zbackl.size()-1]);
|
---|
86 | printf("Parab ZBack: z(%d) : [%f,%f]\n"
|
---|
87 | ,zbackp.size(),zbackp[0],zbackp[zbackp.size()-1]);
|
---|
88 |
|
---|
89 | InterpFunc interpinvl(invfun.YMin(),invfun.YMax(),zbackl);
|
---|
90 | InterpFunc interpinvp(invfun.YMin(),invfun.YMax(),zbackp);
|
---|
91 |
|
---|
92 | noms.resize(0);
|
---|
93 | noms.push_back("z"); noms.push_back("d");
|
---|
94 | noms.push_back("zl"); noms.push_back("zp");
|
---|
95 | NTuple ntinv(noms);
|
---|
96 | for(int_4 i=0;i<nzfin;i++) {
|
---|
97 | double z = zfin[i];
|
---|
98 | double d = dlcfin[i];
|
---|
99 | unsigned short ok;
|
---|
100 | xnt[0] = z;
|
---|
101 | xnt[1] = d;
|
---|
102 | xnt[2] = interpinvl.Parab(d,ok);
|
---|
103 | xnt[3] = interpinvp.Parab(d,ok);
|
---|
104 | ntinv.Fill(xnt);
|
---|
105 | }
|
---|
106 |
|
---|
107 | // --- Write PPF
|
---|
108 | string tag = "cmvtinterp.ppf";
|
---|
109 | cout<<"Write PPF : "<<tag<<endl;
|
---|
110 | POutPersist pos(tag);
|
---|
111 | tag = "ntg"; pos.PutObject(ntg,tag);
|
---|
112 | tag = "ntinv"; pos.PutObject(ntinv,tag);
|
---|
113 |
|
---|
114 | return 0;
|
---|
115 | }
|
---|
116 |
|
---|
117 | /*
|
---|
118 | openppf cmvtinterp.ppf
|
---|
119 |
|
---|
120 | #### Check interpolation
|
---|
121 | n/plot ntg.d%z ! ! "nsta connectpoints"
|
---|
122 | n/plot ntg.d0%z ! ! "nsta connectpoints same green"
|
---|
123 | n/plot ntg.d1%z ! ! "nsta connectpoints same blue"
|
---|
124 | n/plot ntg.d2%z ! ! "nsta connectpoints same red"
|
---|
125 |
|
---|
126 | n/plot ntg.d0-d%z ! ! "nsta connectpoints green"
|
---|
127 | n/plot ntg.d1-d%z ! ! "nsta connectpoints same blue"
|
---|
128 | n/plot ntg.d2-d%z ! ! "nsta connectpoints same red"
|
---|
129 | addline 0 0 1000 0
|
---|
130 |
|
---|
131 | n/plot ntg.d0-d%d ! ! "nsta connectpoints green"
|
---|
132 | n/plot ntg.d1-d%d ! ! "nsta connectpoints same blue"
|
---|
133 | n/plot ntg.d2-d%d ! ! "nsta connectpoints same red"
|
---|
134 | addline 0 0 1000 0
|
---|
135 |
|
---|
136 | n/plot ntg.(d0-d)/d%d fabs(d)>1e-13 ! "nsta connectpoints green"
|
---|
137 | n/plot ntg.(d1-d)/d%d fabs(d)>1e-13 ! "nsta connectpoints same blue"
|
---|
138 | n/plot ntg.(d2-d)/d%d fabs(d)>1e-13 ! "nsta connectpoints same red"
|
---|
139 | addline 0 0 1000 0
|
---|
140 |
|
---|
141 | #### Check inversion
|
---|
142 | n/plot ntinv.d%_nl ! ! "connectpoints"
|
---|
143 |
|
---|
144 | n/plot ntinv.z%d ! ! "nsta connectpoints"
|
---|
145 | n/plot ntg.z%d ! ! "nsta connectpoints same red"
|
---|
146 |
|
---|
147 | n/plot ntinv.z%d ! ! "nsta connectpoints"
|
---|
148 | n/plot ntinv.zl%d ! ! "nsta connectpoints same blue"
|
---|
149 | n/plot ntinv.zp%d ! ! "nsta connectpoints same red"
|
---|
150 |
|
---|
151 | n/plot ntinv.zl-z%d ! ! "nsta connectpoints blue"
|
---|
152 | n/plot ntinv.zp-z%d ! ! "nsta connectpoints same red"
|
---|
153 | addline 0 0 10000 0
|
---|
154 |
|
---|
155 | n/plot ntinv.zl-z%z ! ! "nsta connectpoints blue"
|
---|
156 | n/plot ntinv.zp-z%z ! ! "nsta connectpoints same red"
|
---|
157 | addline 0 0 10000 0
|
---|
158 |
|
---|
159 | n/plot ntinv.(zl-z)/z%z z>0 ! "nsta connectpoints blue"
|
---|
160 | n/plot ntinv.(zp-z)/z%z z>0 ! "nsta connectpoints same red"
|
---|
161 | addline 0 0 10000 0
|
---|
162 |
|
---|
163 | */
|
---|