static double vSigmaI(double X, double Beps, int fast) { double XX; int i; if(vSigmaGrid.pow==0) { checkSgridUpdate(); vSigmaGrid.pow=1; vSigmaGrid.xtop=X; MassCut=Mcdm*(2-log(Beps)/X); vSigmaGrid.data[0]= aRate(X,0,fast,NULL,NULL); return vSigmaGrid.data[0]; } while(X<= vSigmaGrid.xtop) { XX=vSigmaGrid.xtop/XSTEP; checkSgridUpdate(); for(i=vSigmaGrid.pow;i;i--) vSigmaGrid.data[i]=vSigmaGrid.data[i-1]; vSigmaGrid.xtop=XX; MassCut=Mcdm*(2-log(Beps)/XX); vSigmaGrid.data[0]=aRate(XX,0,fast,NULL,NULL); vSigmaGrid.pow++; } for(XX=vSigmaGrid.xtop*pow(XSTEP,vSigmaGrid.pow-1);X>= XX;) { XX*=XSTEP; checkSgridUpdate(); MassCut=Mcdm*(2-log(Beps)/XX); vSigmaGrid.data[vSigmaGrid.pow]=aRate(XX,0,fast,NULL,NULL); vSigmaGrid.pow++; } { double X0,X1,X2,sigmav0,sigmav1,sigmav2; i=log(X/vSigmaGrid.xtop)/log(XSTEP); if(i<0)i=0; if(i>vSigmaGrid.pow-2) i=vSigmaGrid.pow-2; X1=vSigmaGrid.xtop*pow(XSTEP,i); X2=X1*XSTEP; sigmav1=log(vSigmaGrid.data[i]); sigmav2=log(vSigmaGrid.data[i+1]); if(vSigmaGrid.pow==2) { return exp((sigmav1*(X-X2)-sigmav2*(X-X1))/(X1-X2)); } if(i>0) { X0=X1/XSTEP; sigmav0=log(vSigmaGrid.data[i-1]); } else { X0=X2*XSTEP; sigmav0=log(vSigmaGrid.data[i+2]); } return exp( sigmav0*(X-X1)*(X-X2)/(X0-X1)/(X0-X2) +sigmav1*(X-X0)*(X-X2)/(X1-X0)/(X1-X2) +sigmav2*(X-X0)*(X-X1)/(X2-X0)/(X2-X1) ); } }
double darkOmega(double * Xf, int Fast, double Beps) { double Yt,Yi,Xt=25; double Z1=1.1; double Z2=10; int i; double Xf1; if(Xf)*Xf=Xt; assignVal("Q",2*M); if(Beps>=1) Beps=0.999; if(Z1<=1) Z1=1.1; fast_=Fast; Yt= darkOmega1(&Xt, Z1, (Z1-1)/5,Fast, Beps); if(Yt<0||FError) return -1; Xf1=Xt; for(i=0; ;i++) { double X2=vSigmaGrid.xtop*pow(XSTEP,i+1); double y; if(Yt>=Z2*Yeq(Xt)) break; if(Xt>X2*0.999999) continue; while(vSigmaGrid.pow<=i+1) { double X; if(vSigmaGrid.pow==vSigmaGrid.size) { vSigmaGrid.size+=10; vSigmaGrid.data=(double*)realloc(vSigmaGrid.data,sizeof(double)*vSigmaGrid.size); } X=vSigmaGrid.xtop*pow(XSTEP,vSigmaGrid.pow); MassCut=M*(2-log(Beps)/X); vSigmaGrid.data[vSigmaGrid.pow++]=aRate(X,0,Fast,NULL); if(FError) return -1; } y=log(Yt); odeint(&y,1 , Xt , X2 , 1.E-3, (X2-Xt)/2, &XderivLn); Yt=exp(y); Xt=X2; } if(Xf) *Xf=0.5*(Xf1+Xt); Yi=1/( (M/Xt)*sqrt(M_PI/45)*MPlank*aRate(Xt,1,Fast,NULL) ); if(!finite(Yi)||FError) return -1; return 2.742E8*M/(1/Yt + 1/Yi); /* 2.828-old 2.755-new,2.742 -newnew */ }
double vSigma(double T,double Beps ,int Fast) { double X=Mcdm/T; assignVal("Q",2*Mcdm); MassCut=Mcdm*(2-log(Beps)/X); return 3.8937966E8*aRate(X, 0 ,Fast,&vSigmaTCh,NULL); }
double darkOmega(double * Xf, int Fast, double Beps) { double Yt,Yi,Xt=25; double Z1=1.1; double Z2=10; int i; double Xf1; if(Xf)*Xf=Xt; assignVal("Q",2*Mcdm); if(Beps>=1) Beps=0.999; Beps_=Beps; Fast_=Fast; if(Z1<=1) Z1=1.1; Yt= darkOmega1(&Xt, Z1, (Z1-1)/5,Fast, Beps); if(Yt<0||FError) {return -1;} Xf1=Xt; for(i=0; ;i++) { double X2=vSigmaGrid.xtop*pow(XSTEP,i+1); double y; if(Yt>=Z2*Yeq(Xt)) break; if(Xt>X2*0.999999) continue; y=Yt; if(odeint(&y,1 , Xt , X2 , 1.E-3, (X2-Xt)/2, &XderivLn)){return -1;} Yt=y; Xt=X2; } if(Xf) *Xf=0.5*(Xf1+Xt); Yi=1/( (Mcdm/Xt)*sqrt(M_PI/45)*MPlank*aRate(Xt,1,Fast,NULL,NULL)); if(!finite(Yi)||FError) return -1; if(deltaY==0.) { dmAsymm=0; return 2.742E8*Mcdm/(1/Yt + 1/Yi); /* 2.828-old 2.755-new,2.742 -newnew */ } else { double a,f,z0,Y0; a=fabs(deltaY); f= (sqrt(Yt*Yt+a*a)-a)/ (sqrt(Yt*Yt+a*a)+a)*exp(-2*a/Yi); z0=sqrt(f)*2*a/(1-f); Y0=sqrt(z0*z0+a*a); dmAsymm=log((Y0+deltaY)/(Y0-deltaY)); return 2.742E8*Mcdm*Y0; } }
const char *MSLabelOut::formatOutput(MSString &buffer_,double data_) { if (data_<UINT_MAX) { unsigned index=unsigned(data_); if (index<labels().length()) { buffer_=labels()(index); return buffer_.string(); } } switch (format().formatType()) { case MSFormat::Date: { MSDate aDate((MSJulian)data_); return aDate.format(buffer_,format()); } case MSFormat::Money: { MSMoney aMoney(data_); return aMoney.format(buffer_,format()); } case MSFormat::Rate: { MSRate aRate(data_); return aRate.format(buffer_,format()); } case MSFormat::Time: { MSTime aTime((time_t)data_); return aTime.format(buffer_,format()); } case MSFormat::Float: default: { MSFloat aFloat(data_); return aFloat.format(buffer_,format()); } } /* return buffer_.string(); */ }
double darkOmegaFO(double * Xf_, int Fast, double Beps) { double Yf,Yi; double Z1=2.5; double dZ1=0.05; double x; double Xf=25; if(Xf_) *Xf_=Xf; assignVal("Q",2*M); if(Beps>=1) Beps=0.999; Yf= darkOmega1(&Xf, Z1, dZ1,Fast, Beps); if(Yf<0||FError) return -1; x=Xf; Yi=1/( (M/x)*sqrt(M_PI/45)*MPlank*aRate(x, 1,Fast, NULL) ); if(!finite(Yi)||FError) return -1; if(Xf_) *Xf_=Xf; return 2.742E8*M/(1/Yf + 1/Yi); /* 2.828-old 2.755-new 2.742 next-new */ }
double printChannels(double Xf ,double cut, double Beps, int prcn, FILE * f) { int i, nsub, l1,l2; int nPrc,nform=log10(1/cut)-2; float *wPrc; double Sum; MassCut=M*(2-log(Beps)/Xf); Sum=aRate(Xf, 1,1,&wPrc)*(M/Xf)*sqrt(M_PI/45)*MPlank/(2.742E8*M); if(FError) return -1; if(wPrc==NULL) return 0; if(nform<0)nform=0; fprintf(f,"\nChannels which contribute to 1/(omega) more than %G%%.\n",100*cut ); if(prcn) fprintf(f,"Relative contrubutions in %% are displyed\n"); else fprintf(f,"Absolut contrubutions are displyed\n"); for(l1=0,nPrc=0;l1<NC;l1++) { int k1=sort[l1]; if(M+inMass[k1]>MassCut) break; for(l2=0;l2<NC;l2++) { int k2=sort[l2]; if( inMass[k1]+inMass[k2]>MassCut) break; if( inC[k1*NC+k2]<=0) continue; for(nsub=1; nsub<=code22[k1*NC+k2]->interface->nprc; nsub++,nPrc++) if(fabs(wPrc[nPrc])>=cut) { char *pname[4]; for(i=0;i<4;i++) pname[i]=code22[k1*NC+k2]->interface->pinf(nsub,i+1,NULL,NULL); if(prcn) { if(cut <0.000001) fprintf(f,"%.1E%% %s %s -> %s %s \n", 100*wPrc[nPrc],pname[0],pname[1],pname[2],pname[3]); else fprintf(f,"%*.*f%% %s %s -> %s %s \n",nform+3,nform, 100*wPrc[nPrc],pname[0],pname[1],pname[2],pname[3]); } else fprintf(f,"%.1E %s %s -> %s %s \n",Sum*wPrc[nPrc],pname[0],pname[1],pname[2],pname[3]); } } } return 1/Sum; }
double oneChannel(double Xf,double Beps,char*n1,char*n2,char*n3,char*n4) { int j,nPrc; aChannel *wPrc; double Sum,res; MassCut=Mcdm*(2-log(Beps)/Xf); Sum=aRate(Xf, 1,1,&wPrc,&nPrc)*(Mcdm/Xf)*sqrt(M_PI/45)*MPlank/(2.742E8*Mcdm); if(FError) { return -1;} if(wPrc==NULL) { return 0;} for(res=0,j=0;j<nPrc;j++) if( ( (strcmp_(n1,wPrc[j].prtcl[0])==0 && strcmp_(n2,wPrc[j].prtcl[1])==0) || (strcmp_(n2,wPrc[j].prtcl[0])==0 && strcmp_(n1,wPrc[j].prtcl[1])==0) ) && ( (strcmp_(n3,wPrc[j].prtcl[2])==0 && strcmp_(n4,wPrc[j].prtcl[3])==0) || (strcmp_(n4,wPrc[j].prtcl[2])==0 && strcmp_(n3,wPrc[j].prtcl[3])==0) ) ) {res+=wPrc[j].weight;} free(wPrc); return res; }
double printChannels(double Xf ,double cut, double Beps, int prcn, FILE * f) { int i,nPrc,nform=log10(1/cut)-2; aChannel *wPrc; double Sum,s; if(omegaCh) {free(omegaCh); omegaCh=NULL;} MassCut=Mcdm*(2-log(Beps)/Xf); Sum=aRate(Xf, 1,1,&omegaCh,&nPrc)*(Mcdm/Xf)*sqrt(M_PI/45)*MPlank/(2.742E8*Mcdm); if(FError) { return -1;} if(wPrc==NULL) { return 0;} if(nform<0)nform=0; if(f) { int j; fprintf(f,"\nChannels which contribute to 1/(omega) more than %G%%.\n",100*cut ); if(prcn) fprintf(f,"Relative contrubutions in %% are displyed\n"); else fprintf(f,"Absolut contrubutions are displyed\n"); for(i=0,s=0;i<nPrc;i++) if(fabs(omegaCh[i].weight)>=cut) { s+=omegaCh[i].weight; if(prcn) { if(cut <0.000001) fprintf(f,"%.1E%% ",100*omegaCh[i].weight); else fprintf(f,"%*.*f%% ",nform+3,nform, 100*omegaCh[i].weight); } else fprintf(f,"%.1E ",Sum*omegaCh[i].weight); for(j=0;j<4;j++) { fprintf(f,"%s ",omegaCh[i].prtcl[j]); if(j==1) fprintf(f,"->"); if(j==3) fprintf(f,"\n"); } } } return 1/Sum; }
static double darkOmega1(double * Xf,double Z1,double dZ1,int Fast,double Beps) { double X = *Xf; double sqrt_gStar; double CCX=(Z1-1)*(Z1+1); double dCCX=(Z1-1+dZ1)*(Z1+1+dZ1)-CCX; double d, dYdX,Yeq0X; double dCC,dCC1,dCC2,X1,X2,vSigma,vSigma1,vSigma2; double cFactor=sqrt(M_PI/45)*MPlank*M; int i; if(vSigmaGrid.data==NULL) { vSigmaGrid.data=(double*)malloc(20*sizeof(double)); vSigmaGrid.size=20; } sigma= (Fast)?sigma_gauss:sigma_simpson; if(Beps>=1) Beps=0.999; MassCut=M*(2-log(Beps)/X); d=X*0.01; dYdX=(Yeq(X+d)-Yeq(X-d))/(2*d); Yeq0X=Yeq(X)/X; termod(M/X,&sqrt_gStar,NULL); vSigma=aRate(X,0,Fast,NULL); if(FError) return -1; if(vSigma ==0) { printf("ERROR:Zero annihilation rate,\n"); return -1; } dCC=-CCX-dYdX/(vSigma*cFactor*sqrt_gStar*Yeq0X*Yeq0X); vSigmaGrid.data[0]=vSigma; vSigmaGrid.xtop=X; vSigmaGrid.pow=1; if(fabs(dCC)<dCCX) { *Xf=X; return Yeq(X)*sqrt(1+dCC+CCX);} dCC1=dCC;dCC2=dCC;X1=X;X2=X; vSigma1=vSigma;vSigma2=vSigma; while(dCC2>0) { X1=X2; dCC1=dCC2; vSigma1=vSigma2; X2=X2/XSTEP; X=X2; MassCut=M*(2-log(Beps)/X); termod(M/X,&sqrt_gStar,NULL); d=0.01*X; dYdX= (Yeq(X+d)-Yeq(X-d))/(2*d); Yeq0X=Yeq(X)/X; vSigma2=aRate(X,0,Fast,NULL); if(FError) return -1; dCC2=-CCX-dYdX/(vSigma2*cFactor*sqrt_gStar*Yeq0X*Yeq0X); if(vSigmaGrid.pow==vSigmaGrid.size) { vSigmaGrid.size+=10; vSigmaGrid.data=(double*)realloc(vSigmaGrid.data,sizeof(double)*vSigmaGrid.size); } for(i=vSigmaGrid.pow;i;i--) vSigmaGrid.data[i]=vSigmaGrid.data[i-1]; vSigmaGrid.xtop=X; vSigmaGrid.data[0]=vSigma2; vSigmaGrid.pow++; } while (dCC1<0) { X2=X1; dCC2=dCC1; vSigma2=vSigma1; X1=X1*XSTEP; X=X1; MassCut=M*(2-log(Beps)/X); termod(M/X,&sqrt_gStar,NULL); d=0.01*X; dYdX=(Yeq(X+d)-Yeq(X-d))/(2*d); Yeq0X=Yeq(X)/X; vSigma1=aRate(X,0,Fast,NULL); if(FError) return -1; dCC1=-CCX-dYdX/(vSigma1*cFactor*sqrt_gStar*Yeq0X*Yeq0X); if(vSigmaGrid.pow==vSigmaGrid.size) { vSigmaGrid.size+=10; vSigmaGrid.data=(double*)realloc(vSigmaGrid.data,sizeof(double)*vSigmaGrid.size); } vSigmaGrid.data[vSigmaGrid.pow++]=vSigma1; } for(;;) { if(fabs(dCC1)<dCCX) { *Xf=X1; return Yeq(X1)*sqrt(1+dCC1+CCX);} if(fabs(dCC2)<dCCX) { *Xf=X2; return Yeq(X2)*sqrt(1+dCC2+CCX);} X=(X1*dCC2 - X2*dCC1)/(dCC2-dCC1); MassCut=M*(2-log(Beps)/X); termod(M/X,&sqrt_gStar,NULL); d=0.01*X; dYdX= (Yeq(X+d)-Yeq(X-d))/(2*d); Yeq0X=Yeq(X)/X; vSigma= (vSigma1*(X2-X) - vSigma2*(X1-X))/(X2-X1); dCC=-CCX-dYdX/(vSigma*cFactor*sqrt_gStar*Yeq0X*Yeq0X); if(dCC*dCC1>0) {dCC1=dCC;X1=X;vSigma1=vSigma;} else {dCC2=dCC;X2=X;vSigma2=vSigma;} } }