main() { page pg; FeynDiagram fd(pg); xy e1(-10,0), e2(10,0), arcpt(0,4); vertex_circlecross v1(fd,-4,0), v2(fd,4,0); line_plain f1(fd,e1,v1), f2(fd,v1,v2), f3(fd,v2,e2); line_wiggle photon1(fd,v1,v2), photon2(fd,v1,v2); photon1.arcthru(arcpt); photon1.dashon.settrue(); photon2.arcthru(0,-2); photon2.width.scale(0.7); pg.output(); return 0; }
int main(){ /////// Setting begins string AbsorptionModel="Fry"; //"Fry" for fry.dat or "SuperK" for superk.dat bool include_undiffract=true; //include un undiffracted photon as reference or not double photonStep=1.; //in meter double initialT=0.0; //in ns double initialX=0.0; //in meter double initialZ=0.0; //in meter double TankDiameter=50.; //in meter double TankHeight=60.; //in meter // For the test photon bool absorption=true; //apply absorption of photon or not bool rayleigh=true; //apply rayleigh scattering or not bool tempGradient=true; //apply temperature gradient or not, if not Temp=TempTop bool presGradient=true; //apply pressure gradient or not, if not Pressure=PressureTop double wavelength; //please define in the for-loop double TempTop=273.15+15.; //in Kelvin double TempBottom=273.15+5.; //in Kelvin double PressureTop=101325.; //in Pa // For the reference photon only bool ref_absorption=false; bool ref_rayleigh=false; bool ref_tempGradient=false; bool ref_presGradient=false; double ref_wavelength=380.; //fixed wavelength double ref_TempTop=273.15+10.; //in Kelvin double ref_TempBottom=275.15+10.; //in Kelvin double ref_PressureTop=101325.+1000.*9.8*30.; //in Pa, though named Top, the reference photon is living at this pressure /////// Setting Ends int number_absorbed=0; // Open output file FILE * outputfile; outputfile = fopen("output.dat","w"); if (include_undiffract) { fprintf(outputfile,"# theta wavelength deltaX deltaZ deltaT deltaD X1(no diffract) Z1 T1 X2(has diffract) Z2 T2 lambda scatter\n"); } else{ fprintf(outputfile,"# theta wavelength X2(has diffract) Z2 T2 lambda\n"); } // Do the iteration of theta, ranging from -pi/2 to pi/2 for (int i=500;i<=500;i++) //iteration of angle { for (int j=0;j<1000;j++) //iteration of photon { double initialTheta=-PI/2.+PI*i/1000.; ////////////////Select how wavelength is generated/////////////// wavelength=Spectrum(); // // wavelength=380.; // // wavelength=Gaussian(); // ///////////////////////////////////////////////////////////////// cout<<endl; cout<<"*******************************************"<<endl; cout<<"InitialTheta="<<initialTheta/PI<<" PI"<<endl; cout<<"InitialX="<<initialX<<"m"<<endl; cout<<"InitialZ="<<initialZ<<"m"<<endl; cout<<"Test Photon Wavelength="<<wavelength<<" nanometer"<<endl; cout<<"Step="<<photonStep<<"m"<<endl; cout<<"*******************************************"<<endl; // //Run the test photon // SingleRay photon2(photonStep,initialT,initialX,initialZ,wavelength,initialTheta,\ TempTop,TempBottom,PressureTop,TankDiameter,TankHeight,\ absorption,rayleigh,tempGradient,presGradient,AbsorptionModel); //photon2 stores the data of a diffracted ray photon2.WithDiffract(); if (photon2.absorbed) { //photon absorbed number_absorbed++; //record number of absorbed photons continue; //run the next photon } cout << "WithDiffract: x="<<photon2.x<<", z="<<photon2.z<<", t="<<photon2.t<<endl; if (!include_undiffract) { fprintf (outputfile, "%3.3f %3.3f %3.5f %3.5f %3.5f %3.5f \n",\ initialTheta/PI,wavelength,\ photon2.x,photon2.z,photon2.t,photon2.lambda); } // //Run an undiffracted photon for reference // double deltaX,deltaZ,deltaT,deltaD; if(include_undiffract){ SingleRay photon1(photonStep,initialT,initialX,initialZ,ref_wavelength,initialTheta, \ ref_TempTop,ref_TempBottom,ref_PressureTop,TankDiameter,TankHeight, \ ref_absorption,ref_rayleigh,ref_tempGradient,ref_presGradient,AbsorptionModel); // photon1 stores the data of an undiffracted ray photon1.WithoutDiffract(); cout << "WithoutDiffract: x="<<photon1.x<<", z="<<photon1.z<<", t="<<photon1.t<<endl; // Calculate the difference in x,z and t deltaX=photon2.x-photon1.x; deltaZ=photon2.z-photon1.z; deltaT=photon2.t-photon1.t; cout << "deltaX="<<deltaX<<"m, deltaZ="<<deltaZ<<"m, deltaT="<<deltaT<<"ns"<<endl; // Calculate sqrt(x^2+z^2) deltaD=sqrt(deltaX*deltaX+deltaZ*deltaZ); //Output to data to file fprintf (outputfile, "%3.3f %3.3f %3.5f %3.5f %3.5f %3.5f %3.5f %3.5f %3.5f %3.5f %3.5f %3.5f %3.3f %d\n",\ initialTheta/PI,wavelength,deltaX,deltaZ,\ deltaT,deltaD,photon1.x,photon1.z,\ photon1.t,photon2.x,photon2.z,photon2.t, photon2.lambda,photon2.scattered); } } } fclose(outputfile); cout << "Number of absorbed photons: "<< number_absorbed <<endl; }