00001 #include <sstream>
00002 #include <iomanip>
00003 #include "message.h"
00004 #include "utilities.h"
00005 #include "constants.h"
00006 #include "cheezyparser.h"
00007 #include "kernel.h"
00008
00009 using namespace std;
00010
00011 string getKernelFilename( string datadir, int ell, double q )
00012 {
00013 stringstream filename;
00014 filename << datadir
00015 << "/ell" << ell
00016 << "_q" << setfill('0') << fixed << setw(7) << setprecision(2) << q << ".tmp";
00017 return filename.str();
00018 }
00019
00024 CKernel::CKernel(string kparsfilename){
00025 int iq,ir,ell,dell;
00026 ParsInit(kparsfilename);
00027
00028 dell=1;
00029 if(IDENTICAL) dell=2;
00030
00031 kernel=new double **[ellmax+1];
00032 P=new double [ellmax+1];
00033 for(ell=0;ell<=ellmax;ell+=1){
00034 kernel[ell]=NULL;
00035 if(ell%dell==0){
00036 kernel[ell]=new double *[nqmax];
00037 for(iq=0;iq<nqmax;iq++){
00038 kernel[ell][iq]=new double[nrmax];
00039 for(ir=0;ir<nrmax;ir++) kernel[ell][iq][ir]=0.0;
00040 }
00041 }
00042 }
00043 }
00044
00048 CKernel::~CKernel(){
00049 int ell,iq,dell=1;
00050 if(IDENTICAL) dell=2;
00051 delete [] P;
00052 for(ell=0;ell<=ellmax;ell+=dell){
00053 for(iq=0;iq<nqmax;iq++) delete [] kernel[ell][iq];
00054 if(kernel[ell]!=NULL) delete [] kernel[ell];
00055 }
00056 delete [] kernel;
00057 printf("kernel object deleted\n");
00058
00059 }
00060
00063 int CKernel::GetLMAX(){
00064 return ellmax;
00065 }
00066
00069 double CKernel::GetDELR(){
00070 return delr;
00071 }
00072 double CKernel::GetQ(int iq){
00073 return (iq+0.5)*delq;
00074 }
00075
00078 double CKernel::GetDELQ(){
00079 return delq;
00080 }
00081
00084 int CKernel::GetNRMAX(){
00085 return nrmax;
00086 }
00087
00090 int CKernel::GetNQMAX(){
00091 return nqmax;
00092 }
00093
00096 bool CKernel::GetIDENTICAL(){
00097 return IDENTICAL;
00098 }
00099
00107 double CKernel::GetValue(int ell,double q,double r) const{
00108 int iqlow,iqhigh,irlow,irhigh,iq,ir;
00109 double wrlow,wrhigh,wqlow,wqhigh,answer;
00110 double qlow,qhigh,rlow,rhigh,qi,ri;
00111
00112
00113 if((IDENTICAL && pow(-1.0,ell)<0) || q>delq*nqmax || r>delr*nrmax) answer=0.0;
00114 else{
00115 iq=lrint(floor(q/delq));
00116 qi=(0.5+iq)*delq;
00117 if(q<qi){
00118 iqlow=iq-1;
00119 if(iqlow<0) iqlow=0;
00120 iqhigh=iq;
00121 qhigh=(0.5+iq)*delq;
00122 wqhigh=fabs(delq-fabs(qhigh-q))/delq;
00123 if(wqhigh>1.0) wqhigh=1.0;
00124 wqlow=1.0-wqhigh;
00125 }
00126 else{
00127 iqlow=iq;
00128 iqhigh=iq+1;
00129 if(iqhigh>=nqmax) iqhigh=iqlow;
00130 qlow=(iq+0.5)*delq;
00131 wqlow=fabs(delq-fabs(q-qlow))/delq;
00132 if(wqlow>1.0) wqlow=1.0;
00133 wqhigh=1.0-wqlow;
00134 }
00135
00136 ir=int(floor(r/delr));
00137 ri=(0.5+ir)*delr;
00138 if(r<ri){
00139 irlow=ir-1;
00140 if(irlow<0) irlow=0;
00141 irhigh=ir;
00142 rhigh=(0.5+ir)*delr;
00143 wrhigh=fabs(delr-fabs(rhigh-r))/delr;
00144
00145 if(wrhigh>1.0) wrhigh=1.0;
00146 wrlow=1.0-wrhigh;
00147 }
00148 else{
00149 irlow=ir;
00150 irhigh=ir+1;
00151 if(irhigh>=nrmax) irhigh=irlow;
00152 rlow=(ir+0.5)*delr;
00153 wrlow=fabs(delr-fabs(r-rlow))/delr;
00154 if(wrlow>1.0) wrlow=1.0;
00155 wrhigh=1.0-wrlow;
00156 }
00157
00158 if(fabs(wrlow+wrhigh-1.0)>1.0E-8 || fabs(wqlow+wqhigh-1.0)>1.0E-6){
00159 printf("weights do not add up in GetValue(ell,q,r)\n");
00160 exit(1);
00161 }
00162
00163 answer=wqlow*wrlow*GetValue(ell,iqlow,irlow)
00164 +wqlow*wrhigh*GetValue(ell,iqlow,irhigh)
00165 +wqhigh*wrlow*GetValue(ell,iqhigh,irlow)
00166 +wqhigh*wrhigh*GetValue(ell,iqhigh,irhigh);
00167
00168 if(ell==0 && r>1.0 && answer<-1.0){
00169 printf("__________________________________________________\n");
00170 printf("answer below -1, =%g, q=%g, r=%g, iq=%d, ir=%d, nrmax=%d\n",
00171 answer,q,r,iq,ir,nrmax);
00172 printf("wqlow=%g, wqhigh=%g, wrlow=%g, wrhigh=%g\n",wqlow,wqhigh,wrlow,wrhigh);
00173
00174 printf("__________________________________________________\n");
00175 }
00176 }
00177 return answer;
00178 }
00179
00187 double CKernel::GetValue(int ell,int iq,int ir) const{
00188 if(iq>=nqmax||ir>=nrmax || iq<0 || ir<0) return 0.0;
00189 else{
00190
00191
00192
00193
00194
00195
00196 return kernel[ell][iq][ir];
00197 }
00198 }
00199
00213 bool CKernel::Read(const parameterMap& parameters){
00214 nqmax=parameter::getI(parameters,"NQMAX",200);
00215 nrmax=parameter::getI(parameters,"NRMAX",500);
00216 ellmax=parameter::getI(parameters,"KLMAX",4);
00217 delq=parameter::getD(parameters,"DELQ",0.5);
00218 delr=parameter::getD(parameters,"DELR",0.1);
00219 IDENTICAL=parameter::getB(parameters,"IDENTICAL",true);
00220 return true;
00221 }
00222
00223
00237 bool CKernel::Write( parameterMap& parameters){
00238 parameter::set(parameters,"NQMAX",nqmax);
00239 parameter::set(parameters,"NRMAX",nrmax);
00240 parameter::set(parameters,"KLMAX",ellmax);
00241 parameter::set(parameters,"DELQ",delq);
00242 parameter::set(parameters,"DELR",delr);
00243 parameter::set(parameters,"IDENTICAL",IDENTICAL);
00244 return true;
00245 }
00246
00247
00248 void CKernel::ParsInit(string kparsfilename){
00249 parameterMap parameters;
00250 if ( kparsfilename!=string("") ) {
00251 try {
00252 parameter::ReadParsFromFile(parameters,kparsfilename);
00253 } catch ( const CMessage& ) {}
00254 }
00255 Read(parameters);
00256
00257 printf(" Parameters for kernel: \n");
00258 printf(" delq set to %g\n",delq);
00259 printf(" nqmax set to %d\n",nqmax);
00260 printf(" delr set to %g\n",delr);
00261 printf(" nrmax set to %d\n",nrmax);
00262 printf(" KLMAX=%d\n",ellmax);
00263 printf(" IDENTICAL set to %d\n",IDENTICAL);
00264
00265 }
00266
00274 void CKernel::ReadData(string datadir){
00275 double q,delr0;
00276 int iq,ir,ell,nrmax0,dell;
00277 FILE *infile;
00278 dell=1;
00279 string filename;
00280 if(IDENTICAL) dell=2;
00281
00282 for(ell=0;ell<=ellmax;ell+=dell){
00283 bool this_l_OK = true;
00284 for(iq=0;iq<nqmax;iq++){
00285 q=(0.5+iq)*delq;
00286 filename = getKernelFilename( datadir, ell, q );
00287 if (! file_exists( filename ) ) this_l_OK = false;
00288 }
00289 if ( !this_l_OK )
00290 {
00291 MESSAGE << "Missing files for l = "<< ell<<", truncating kernel at lmax = "<<ell-dell<< ENDM_WARN;
00292 ellmax = ell-dell;
00293 break;
00294 }
00295 }
00296
00297 for(ell=0;ell<=ellmax;ell+=dell){
00298 for(iq=0;iq<nqmax;iq++){
00299 q=(0.5+iq)*delq;
00300 filename = getKernelFilename( datadir, ell, q );
00301 infile=fopen(filename.c_str(),"r");
00302 if (infile==NULL) throw MESSAGE<<"Opening kernel data file "<<filename<<" failed!"<<ENDM_SEVERE;
00303 fscanf(infile,"%d %lf",&nrmax0,&delr0);
00304 if(nrmax0<nrmax || fabs(delr-delr0)>1.0E-8){
00305 printf("Inconsistent values for nrmax or delr in data files!\n");
00306 exit(1);
00307 }
00308 for(ir=0;ir<nrmax;ir++){
00309 fscanf(infile,"%lf",&kernel[ell][iq][ir]);
00310 }
00311 fclose(infile);
00312 }
00313 }
00314 }
00315
00323 void CKernel::WriteData(string datadir){
00324 double q,r;
00325 int ell,iq,ir,dell;
00326 char filename[100];
00327 FILE *outfile;
00328 char shellcommand[120];
00329
00330
00331 sprintf(shellcommand,"mkdir -p %s",datadir.c_str());
00332
00333 system(shellcommand);
00334
00335 dell=1;
00336 if(IDENTICAL) dell=2;
00337 for(ell=0;ell<=ellmax;ell+=dell){
00338 for(iq=0;iq<nqmax;iq++){
00339 q=(0.5+iq)*delq;
00340 sprintf(filename,"%s/ell%d_q%07.2f.tmp",datadir.c_str(),ell,q);
00341 printf("For q=%g, Will write to %s\n",q,filename);
00342 outfile=fopen(filename,"w");
00343 fprintf(outfile,"%d %g\n",nrmax,delr);
00344 for(ir=0;ir<nrmax;ir++){
00345 r=(0.5+ir)*delr;
00346 fprintf(outfile,"%17.10e\n",kernel[ell][iq][ir]);
00347 }
00348 fclose(outfile);
00349 }
00350 }
00351 }
00352
00356 void CKernel::Print(){
00357 double q,r;
00358 int ell,iq,ir,dell;
00359
00360 dell=1;
00361 if(IDENTICAL) dell=2;
00362 printf("ellmax=%d, nqmax=%d, nrmax=%d\n",ellmax,nqmax,nrmax);
00363 for(iq=0;iq<nqmax;iq++){
00364 q=(0.5+iq)*delq;
00365 printf("______________ q=%g MeV/c____________________\n",q);
00366 for(ir=0;ir<nrmax;ir++){
00367 r=(0.5+ir)*delr;
00368 printf("%6.2f ",r);
00369 for(ell=0;ell<=ellmax;ell+=dell){
00370 printf("%10.3e ",kernel[ell][iq][ir]);
00371 }
00372 printf("\n");
00373 }
00374 }
00375 }
00376
00385 void CKernel::Calc_ClassCoul(double ma,double mb,int zazb){
00386 double q,r,ctheta;
00387 int ell,iq,ir,nu=512;
00388 double x,ea,eb,u,umax,delu;
00389
00390 for(ell=0;ell<=ellmax;ell++){
00391 for(iq=0;iq<nqmax;iq++){
00392 for(ir=0;ir<nrmax;ir++) kernel[ell][iq][ir]=0.0;
00393 }
00394 }
00395
00396 for(iq=0;iq<nqmax;iq++){
00397 q=(0.5+iq)*delq;
00398 for(ir=0;ir<nrmax;ir++){
00399 r=(0.5+ir)*delr;
00400 ea=sqrt(q*q+ma*ma);
00401 eb=sqrt(q*q+mb*mb);
00402 x=2.0*ea*eb*zazb*197.327/(q*q*r*137.036*(ea+eb));
00403
00404 if(x<1.0){
00405 umax=2.0*sqrt(1.0-x);
00406 delu=umax/double(nu);
00407 for(u=0.5*delu;u<umax;u+=delu){
00408 ctheta=-1.0+x+sqrt(u*u+x*x);
00409 for(ell=0;ell<=ellmax;ell++)
00410 kernel[ell][iq][ir]+=0.5*delu*SpherHarmonics::legendre(ell,ctheta);
00411 }
00412 printf("q=%g, r=%g, kernel0=%g =? %g\n",
00413 q,r,kernel[0][iq][ir],sqrt(1.0-x));
00414 }
00415 kernel[0][iq][ir]-=1.0;
00416 }
00417 }
00418 }
00419
00435 void CKernel::Calc_PureHBT(){
00436 int ir,iq,ell,sign;
00437 double qr,r,q;
00438
00439 for(iq=0;iq<nqmax;iq++){
00440 q=(0.5+iq)*delq;
00441 for(ir=0;ir<nrmax;ir++){
00442 r=(0.5+ir)*delr;
00443 qr=q*r/197.3269602;
00444 sign=-1;
00445 for(ell=0;ell<=ellmax;ell+=2){
00446 sign=-sign;
00447 kernel[ell][iq][ir]=2.0*sign*Bessel::jn(ell,qr);
00448
00449
00450 }
00451 kernel[0][iq][ir]-=1.0;
00452 }
00453 }
00454 }
00455
00468 void CKernel::Calc(CWaveFunction *wf){
00469 double q,r,ctheta,wf2;
00470 int ell,dell,iq,ir,ictheta,nctheta=720;
00471 if(IDENTICAL!=wf->GetIDENTICAL()){
00472 printf("Creating Kernel with different symmetry (value of IDENTICAL) than wave function\n");
00473 printf("You probably need to edit parameters file\n");
00474 exit(1);
00475 }
00476
00477 dell=1;
00478 if(IDENTICAL) dell=2;
00479 for(iq=0;iq<nqmax;iq++){
00480 q=(0.5+iq)*delq;
00481 for(ir=0;ir<nrmax;ir++){
00482 r=(0.5+ir)*delr;
00483 for(ell=0;ell<=ellmax;ell+=dell)
00484 kernel[ell][iq][ir]=0.0;
00485 for(ictheta=0;ictheta<nctheta;ictheta++){
00486 ctheta=-1.0+2.0*(0.5+ictheta)/double(nctheta);
00487 wf2=wf->GetPsiSquared(q,r,ctheta);
00488 for(ell=0;ell<=ellmax;ell+=dell){
00489 kernel[ell][iq][ir]+=(wf2-1.0)*SpherHarmonics::legendre(ell,ctheta);
00490 }
00491 }
00492 for(ell=0;ell<=ellmax;ell+=dell)
00493 kernel[ell][iq][ir]=kernel[ell][iq][ir]/double(nctheta);
00494 }
00495 }
00496 }
00497
00498 double CKernel::CalcPsiSquared(int iq,int ir,double ctheta){
00499 int ell,dell=1,nsmall=0;
00500 double answer=1.0,dela;
00501 if(IDENTICAL) dell=2;
00502 ell=0;
00503 if(ir<nrmax && iq<nqmax){
00504 while(ell<=ellmax && nsmall<5){
00505 dela=kernel[ell][iq][ir]*(2.0*ell+1)*P[ell];
00506
00507 answer+=dela;
00508 if(fabs(dela)<1.0E-4) nsmall+=1;
00509 else(nsmall=0);
00510 ell+=dell;
00511 }
00512 }
00513 return answer;
00514 }
00515
00516 double CKernel::GetPsiSquared(int iq,int ir,double ctheta){
00517 double answer=1.0;
00518 if(ir<nrmax && iq<nqmax){
00519 CalcP(ctheta);
00520 answer=CalcPsiSquared(iq,ir,ctheta);
00521 }
00522 return answer;
00523 }
00524
00525 double CKernel::CalcPsiSquared(int iq,double r,double ctheta){
00526 double wa,wb;
00527 int ira,irb;
00528 ira=lrint(floor((r/delr)-0.5));
00529 if(ira<0) ira=0;
00530 irb=ira+1;
00531 wb=(r-(ira+0.5)*delr)/delr;
00532 wa=((irb+0.5)*delr-r)/delr;
00533 return wa*CalcPsiSquared(iq,ira,ctheta)+wb*CalcPsiSquared(iq,irb,ctheta);
00534 }
00535
00536
00537 double CKernel::GetPsiSquared(int iq,double r,double ctheta){
00538 double answer=1.0;
00539 if(iq<nqmax){
00540 CalcP(ctheta);
00541 answer=CalcPsiSquared(iq,r,ctheta);
00542 }
00543 return answer;
00544 }
00545
00546
00547
00548 double CKernel::GetPsiSquared(double q,double r,double ctheta){
00549 double wa,wb,answer=1.0;
00550 int iqa,iqb;
00551 iqa=lrint(floor((q/delq)-0.5));
00552 if(iqa<0) iqa=0;
00553 iqb=iqa+1;
00554 if(iqb>=nqmax){
00555 iqb=nqmax-1;
00556 iqa=iqb-1;
00557 }
00558 CalcP(ctheta);
00559 wb=(q-(iqa+0.5)*delq)/delq;
00560 wa=((iqb+0.5)*delq-q)/delq;
00561 answer=wa*CalcPsiSquared(iqa,r,ctheta)+wb*CalcPsiSquared(iqb,r,ctheta);
00562
00563 return answer;
00564 }
00565
00566 void CKernel::CalcP(double ctheta){
00567 int ell;
00568 P[0]=1.0;
00569 P[1]=ctheta;
00570 for(ell=1;ell<ellmax;ell++){
00571 P[ell+1]=((2*ell+1)*ctheta*P[ell]-ell*P[ell-1])/double(ell+1);
00572 }
00573 }
00574
00575
00576
00577 CKernelWF::CKernelWF(string kparsfilename){
00578 int iq,ir,ictheta;
00579 ParsInit(kparsfilename);
00580
00581 delctheta=2.0/double(nctheta);
00582 if(IDENTICAL) delctheta=delctheta*0.5;
00583
00584 wfarray=new double **[nqmax];
00585 for(iq=0;iq<nqmax;iq+=1){
00586 wfarray[iq]=new double *[nrmax];
00587 for(ir=0;ir<nrmax;ir++){
00588 wfarray[iq][ir]=new double[nctheta+1];
00589 for(ictheta=0;ictheta<=nctheta;ictheta++) wfarray[iq][ir][ictheta]=0.0;
00590 }
00591 }
00592 }
00593
00594 void CKernelWF::ParsInit(string kparsfilename){
00595 parameterMap parameters;
00596 parameter::ReadParsFromFile(parameters,kparsfilename);
00597 if ( kparsfilename!="" ) {
00598 try {
00599 parameter::ReadParsFromFile(parameters,kparsfilename);
00600 printf("Read from %s:\n",kparsfilename.c_str());
00601 } catch ( const CMessage& ) {}
00602 }
00603
00604 nqmax=parameter::getI(parameters,"NQMAX",25);
00605 nrmax=parameter::getI(parameters,"NRMAX",120);
00606 nctheta=parameter::getI(parameters,"NCTHETA",120);
00607 delq=parameter::getD(parameters,"DELQ",4.0);
00608 delr=parameter::getD(parameters,"DELR",0.5);
00609 IDENTICAL=parameter::getB(parameters,"IDENTICAL",0);
00610
00611 printf("reading from %s\n",kparsfilename.c_str());
00612 printf(" _________ PARAMETERS FOR KERNELWF ________\n");
00613 printf("delq set to %g\n",delq);
00614 printf("nqmax set to %d\n",nqmax);
00615 printf("delr set to %g\n",delr);
00616 printf("nrmax set to %d\n",nrmax);
00617 printf("nctheta set to %d\n",nctheta);
00618 printf("IDENTICAL set to %d\n",IDENTICAL);
00619 printf("__________________________________________\n");
00620 }
00621
00622
00623 CKernelWF::~CKernelWF(){
00624 int iq,ir;
00625 for(iq=0;iq<nqmax;iq++){
00626 for(ir=0;ir<nrmax;ir++) delete [] wfarray[iq][ir];
00627 delete [] wfarray[iq];
00628 }
00629 delete [] wfarray;
00630 printf("KernelWF object deleted\n");
00631
00632 }
00633
00634 void CKernelWF::Calc(CWaveFunction *wf){
00635 int iq,ir,ictheta;
00636 double q,r,ctheta,ps2;
00637 for(iq=0;iq<nqmax;iq++){
00638 q=(iq+0.5)*delq;
00639 for(ir=0;ir<nrmax;ir++){
00640 r=(ir+0.5)*delr;
00641 for(ictheta=0;ictheta<=nctheta;ictheta++){
00642 ctheta=1.0-ictheta*delctheta;
00643 if(ctheta>1.0) ctheta=1.0;
00644 ps2=wf->GetPsiSquared(q,r,ctheta);
00645 if(ps2<0.0 && r>1.0){
00646 printf("screwy, psi^2=%g, r=%g, q=%g, ctheta=%g\n",ps2,r,q,ctheta);
00647 exit(1);
00648 }
00649 wfarray[iq][ir][ictheta]=ps2-1.0;
00650 }
00651 }
00652 }
00653 }
00654
00655 double CKernelWF::GetPsiSquared(int iq,int ir,int ictheta){
00656 if(iq<nqmax && ir<nrmax && ictheta<=nctheta)
00657 return 1.0+wfarray[iq][ir][ictheta];
00658 else return 1.0;
00659 }
00660
00661 double CKernelWF::GetPsiSquared(int iq,int ir,double ctheta){
00662 double wa,wb;
00663 int ictheta;
00664 if(iq<nqmax && ir<nrmax){
00665 if(IDENTICAL) ctheta=fabs(ctheta);
00666 ictheta=lrint(floor((1.0-ctheta)/delctheta));
00667 wb=((1.0-ctheta)-ictheta*delctheta)/delctheta;
00668 wa=1.0-wb;
00669 return 1.0+wa*wfarray[iq][ir][ictheta]+wb*wfarray[iq][ir][ictheta+1];
00670 }
00671 else return 1.0;
00672 }
00673
00674 double CKernelWF::GetPsiSquared(int iq,double r,double ctheta){
00675 int ir;
00676 double wa,wb;
00677 if(iq<nqmax){
00678 ir=lrint(floor((r-0.5*delr)/delr));
00679 if(ir<0) ir=0;
00680 wb=(r-(ir+0.5)*delr)/delr;
00681 wa=1.0-wb;
00682 return wa*GetPsiSquared(iq,ir,ctheta)+wb*GetPsiSquared(iq,ir+1,ctheta);
00683 }
00684 else return 1.0;
00685 }
00686
00687 double CKernelWF::GetPsiSquared(double q,double r,double ctheta){
00688 int iq;
00689 double wa,wb;
00690 iq=lrint(floor((q-0.5*delq)/delq));
00691 if(iq<0) iq=0;
00692 wb=(q-(iq+0.5)*delq)/delq;
00693 wa=1.0-wb;
00694 return wa*GetPsiSquared(iq,r,ctheta)+wb*GetPsiSquared(iq+1,r,ctheta);
00695 }
00696
00697 double CKernelWF::GetDELR(){
00698 return delr;
00699 }
00700
00701 double CKernelWF::GetDELQ(){
00702 return delq;
00703 }
00704
00705 double CKernelWF::GetDELCTHETA(){
00706 return delctheta;
00707 }
00708
00709 int CKernelWF::GetNRMAX(){
00710 return nrmax;
00711 }
00712
00713 int CKernelWF::GetNQMAX(){
00714 return nqmax;
00715 }
00716
00717 int CKernelWF::GetNCTHETA(){
00718 return nctheta;
00719 }
00720
00721 bool CKernelWF::GetIDENTICAL(){
00722 return IDENTICAL;
00723 }
00724
00725 void CKernelWF::WriteData(string datadir){
00726 double q;
00727 int iq,ir,ictheta;
00728 double meanwf2;
00729 char filename[80];
00730 FILE *outfile;
00731 char shellcommand[120];
00732
00733
00734 sprintf(shellcommand,"mkdir -p %s",datadir.c_str());
00735 system(shellcommand);
00736 for(iq=0;iq<nqmax;iq++){
00737 meanwf2=0.0;
00738 q=(0.5+iq)*delq;
00739 sprintf(filename,"%s/q%07.2f.tmp",datadir.c_str(),q);
00740 outfile=fopen(filename,"w");
00741 fprintf(outfile,"%d %d\n",nrmax,nctheta);
00742 for(ir=0;ir<nrmax;ir++){
00743 for(ictheta=0;ictheta<=nctheta;ictheta++){
00744 meanwf2+=wfarray[iq][ir][ictheta];
00745 fprintf(outfile,"%17.10e ",wfarray[iq][ir][ictheta]);
00746 }
00747 fprintf(outfile,"\n");
00748 }
00749 meanwf2=meanwf2/double(nctheta*nrmax);
00750
00751 fclose(outfile);
00752 }
00753 }
00754
00755 void CKernelWF::ReadData(string datadir){
00756 double q;
00757 double meanwf2;
00758 int iq,ir,ictheta,nrmaxread,ncthetaread;
00759 char filename[80];
00760 FILE *infile;
00761
00762 for(iq=0;iq<nqmax;iq++){
00763 meanwf2=0.0;
00764 q=(0.5+iq)*delq;
00765 sprintf(filename,"%s/q%07.2f.tmp",datadir.c_str(),q);
00766 infile=fopen(filename,"r");
00767 fscanf(infile,"%d %d\n",&nrmaxread,&ncthetaread);
00768 if(nrmaxread!=nrmax || ncthetaread!=nctheta){
00769 printf("CKernelWF : trying to read file with wrong dimensions\n");
00770 printf("nrmaxread=%d, nrmax=%d, ncthetaread=%d, nctheta=%d\n",
00771 nrmaxread,nrmax,ncthetaread,nctheta);
00772 exit(1);
00773 }
00774 for(ir=0;ir<nrmax;ir++){
00775 for(ictheta=0;ictheta<=nctheta;ictheta++){
00776 fscanf(infile,"%lf ",&wfarray[iq][ir][ictheta]);
00777 meanwf2+=wfarray[iq][ir][ictheta];
00778 }
00779 }
00780 fclose(infile);
00781 meanwf2=meanwf2/double(nctheta*nrmax);
00782
00783 }
00784 }
00785
00786
00787