Changeset 17 in ZHANGProjects for ICOSIM/CPP/trunk/source/simulation.cc
- Timestamp:
- Sep 30, 2014, 11:05:33 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ICOSIM/CPP/trunk/source/simulation.cc
r15 r17 78 78 particlefile = inputfile + "initial.dat"; 79 79 80 cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " << particlefile <<endl; 81 80 82 //if the name of the file is not 'initial.dat', uncomment the following two lines 81 83 … … 663 665 cout <<"********************************"<<endl; 664 666 cout << "RunningFlag = " << RunningFlag << endl; 665 cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " <<inputfile <<endl;667 666 668 readParticle(Apr, Zpr, inputfile); 667 669 … … 676 678 cout << "RunningFlag = " << RunningFlag << endl; 677 679 cout << "GENERATION OF THE BUNCH OF PARTICLES." << endl; 678 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi );680 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi, inputfile); 679 681 680 682 //we set the id of the particles … … 742 744 cout <<"********************************"<<endl; 743 745 cout << "RunningFlag = " << RunningFlag << endl; 744 cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " <<inputfile <<endl;745 746 readParticle(Apr, Zpr, inputfile); 746 747 } else if (RunningFlag == 3) { … … 749 750 cout << "RunningFlag = " << RunningFlag << endl; 750 751 cout << "GENERATION OF THE BUNCH OF PARTICLES." << endl; 751 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi );752 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi, inputfile); 752 753 } 753 754 … … 827 828 828 829 829 //We take the particles hitting collimators during the previous tracking (we take their coordinates at the beginning of the last turn before the hit), and do a more precisetracking830 //We take the particles hitting collimators during the previous tracking (we take their coordinates at the beginning of the last turn before the hit), and do a preciser tracking 830 831 cout <<" "<<endl; 831 832 cout <<"********************************"<<endl; … … 1101 1102 1102 1103 for (int m(0); m < lat.nhitcolli.size(); ++m) { 1104 cout << "m = " << m << "nhitcollio[m] is: " << nhitcollio[m] << " lat.nhitcolli[m] is: " << lat.nhitcolli[m] << endl; 1103 1105 nhitcollio[m] = nhitcollio[m] + lat.nhitcolli[m]; 1104 1106 } … … 1106 1108 for (int m(0); m < lat.nhitspoiler.size(); ++m) { 1107 1109 nhitspoilero[m] = nhitspoilero[m] + lat.nhitspoiler[m]; 1110 1108 1111 } 1109 1112 … … 1871 1874 1872 1875 1873 void Simulation::genbunch(const int& i0, const int& npart, const string& partdistr, const double& r1r2skin, const double& emx, const double& emy, const double& sigdpp, const double& bx, const double& ax, const double& dx, const double& dpx, const double& by, const double& ay, const double& dy, const double& dpy, const double& nsigi )1876 void Simulation::genbunch(const int& i0, const int& npart, const string& partdistr, const double& r1r2skin, const double& emx, const double& emy, const double& sigdpp, const double& bx, const double& ax, const double& dx, const double& dpx, const double& by, const double& ay, const double& dy, const double& dpy, const double& nsigi, const string& inputfile) 1874 1877 { 1875 1878 1876 1879 //save bunch distribution 1877 1880 1878 //string path1;1879 //path1 = outputpath+ "initial.dat";1880 ofstream sortie( "initial.dat");1881 string outfile; 1882 outfile = inputfile + "initial.dat"; 1883 ofstream sortie(outfile.c_str()); 1881 1884 1882 1885 if (sortie.fail()) { … … 1999 2002 sortie << endl; 2000 2003 2001 sortie << " Number of particles that have hit another element during a preceding turn(asumhits):";2004 sortie << "(Total) Number of particles that have hit another element during the preceding turns (asumhits):"; 2002 2005 2003 2006 for (int i(0); i < asumhits.size(); ++i) { … … 2007 2010 sortie << endl; 2008 2011 2009 sortie << " Number of particles that have hit the collimators, for each collimator (nhitcolli):";2012 sortie << "(Total) Number of particles that have hit the collimators, for each collimator (nhitcolli):"; 2010 2013 2011 2014 for (int i(0); i < nhitcollio.size(); ++i) { … … 2102 2105 2103 2106 for (int i(0); i < plosslocal.size(); ++i) { 2104 outplot1 2107 outplot1<< setw(10) << plosslocal[i]*PlossPb / NLostTotal << setw(10) << zlosslocal[i] / 1000 << endl; 2105 2108 } 2106 2109 … … 2190 2193 vector <int> newnhitcolli, ipsnew; 2191 2194 2195 cout << " size of nhitcollio.size(): "<<nhitcollio.size()<<endl; 2192 2196 for (int i(0); i < nhitcollio.size(); ++i) { 2193 2197 if (removedCollimators[i] == 0) { … … 2209 2213 2210 2214 for (int i(0); i < newnhitcolli.size(); ++i) { 2211 outplot3 << setw(10) << i + 1 << setw(10) << newnhitcolli[i]*PlossPb / NLostTotal << setw(10) << ipsnew[i] << setw(20) << lat.reseau[ipsnew[i]]->NAME << endl; 2215 cout << newnhitcolli[i]*PlossPb / NLostTotal << endl; 2216 outplot3 << setw(10) << i + 1 << setw(20) << newnhitcolli[i]*PlossPb / NLostTotal << setw(10) << ipsnew[i] << setw(20) << lat.reseau[ipsnew[i]]->NAME << endl; 2212 2217 } 2213 2218 outplot3.close(); … … 2262 2267 2263 2268 for (int i(0); i < asumrem.size(); ++i) { 2264 outplot4 << setw(10) << i << setw(10) << asumrem[i] << setw(10) << asumhitcolli[i] << setw(10) << asumhits[i] << endl;2269 outplot4 << setw(10) << i << setw(10) << asumrem[i] << setw(10) << asumhitcolli[i] << setw(10) << asumhits[i] << setw(10) << (asumrem[i]+asumhitcolli[i]+asumhits[i])<<endl; 2265 2270 } 2266 2271 outplot4.close(); … … 2273 2278 //Writing PlotRunSummary1.p 2274 2279 2280 //flag to switch to generate GUNPLOT script or not, default is false 2281 bool gnuplotflag = true; 2282 if(gnuplotflag) 2283 { 2275 2284 ofstream PlotRun1; 2276 2285 string plotrunname1; … … 2288 2297 PlotRun1 << "set key default" << endl; 2289 2298 PlotRun1 << "set xrange [-1:]" << endl; 2290 PlotRun1 << "set ylabel \"P\' (W/m)\"" << endl;2299 PlotRun1 << "set ylabel \"P\' (W/m)\"" << endl; 2291 2300 PlotRun1 << "set xlabel \"Distance from starting point (km)\"" << endl; 2292 2301 PlotRun1 << "set title \"Loss map\"" << endl << endl; … … 2352 2361 } 2353 2362 2363 } 2364 2354 2365 } 2355 2366
Note: See TracChangeset
for help on using the changeset viewer.