Changeset 17 in ZHANGProjects for ICOSIM/CPP/trunk/source/simulation.cc


Ignore:
Timestamp:
Sep 30, 2014, 11:05:33 AM (10 years ago)
Author:
zhangj
Message:

Added comments...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ICOSIM/CPP/trunk/source/simulation.cc

    r15 r17  
    7878    particlefile = inputfile + "initial.dat";
    7979
     80    cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " << particlefile <<endl;
     81   
    8082    //if the name of the file is not 'initial.dat', uncomment the following two lines
    8183
     
    663665      cout <<"********************************"<<endl;
    664666        cout << "RunningFlag = " <<  RunningFlag << endl;
    665         cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " <<inputfile <<endl;
     667       
    666668        readParticle(Apr, Zpr, inputfile);
    667669
     
    676678      cout << "RunningFlag = " <<  RunningFlag << endl;
    677679      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);
    679681
    680682        //we set the id of the particles
     
    742744      cout <<"********************************"<<endl;
    743745        cout << "RunningFlag = " <<  RunningFlag << endl;
    744         cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " <<inputfile <<endl;
    745746        readParticle(Apr, Zpr, inputfile);
    746747    } else if (RunningFlag == 3) {
     
    749750      cout << "RunningFlag = " <<  RunningFlag << endl;
    750751      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);
    752753    }
    753754
     
    827828
    828829
    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 precise tracking
     830    //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
    830831    cout <<" "<<endl;
    831832      cout <<"********************************"<<endl;
     
    11011102
    11021103        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;
    11031105            nhitcollio[m] = nhitcollio[m] + lat.nhitcolli[m];
    11041106        }
     
    11061108        for (int m(0); m < lat.nhitspoiler.size(); ++m) {
    11071109            nhitspoilero[m] = nhitspoilero[m] + lat.nhitspoiler[m];
     1110           
    11081111        }
    11091112
     
    18711874
    18721875
    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)
     1876void 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)
    18741877{
    18751878
    18761879  //save bunch distribution
    18771880 
    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());
    18811884 
    18821885  if (sortie.fail()) {
     
    19992002        sortie << endl;
    20002003
    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):";
    20022005
    20032006        for (int i(0); i < asumhits.size(); ++i) {
     
    20072010        sortie << endl;
    20082011
    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):";
    20102013
    20112014        for (int i(0); i < nhitcollio.size(); ++i) {
     
    21022105
    21032106        for (int i(0); i < plosslocal.size(); ++i) {
    2104             outplot1 << setw(10) <<  plosslocal[i]*PlossPb / NLostTotal << setw(10) << zlosslocal[i] / 1000 << endl;
     2107            outplot1<< setw(10) <<  plosslocal[i]*PlossPb / NLostTotal << setw(10) << zlosslocal[i] / 1000 << endl;
    21052108        }
    21062109
     
    21902193    vector <int> newnhitcolli, ipsnew;
    21912194
     2195    cout << " size of nhitcollio.size():  "<<nhitcollio.size()<<endl;
    21922196    for (int i(0); i < nhitcollio.size(); ++i) {
    21932197        if (removedCollimators[i] == 0) {
     
    22092213
    22102214        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;
    22122217        }
    22132218        outplot3.close();
     
    22622267
    22632268        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;
    22652270        }
    22662271        outplot4.close();
     
    22732278    //Writing PlotRunSummary1.p
    22742279
     2280    //flag to switch to generate GUNPLOT script or not, default is false
     2281    bool gnuplotflag = true;
     2282    if(gnuplotflag)
     2283    {
    22752284    ofstream PlotRun1;
    22762285    string plotrunname1;
     
    22882297        PlotRun1 << "set key default" << endl;
    22892298        PlotRun1 << "set xrange [-1:]" << endl;
    2290         PlotRun1 << "set ylabel \"P\'(W/m)\"" << endl;
     2299        PlotRun1 << "set ylabel \"P\' (W/m)\"" << endl;
    22912300        PlotRun1 << "set xlabel \"Distance from starting point (km)\"" << endl;
    22922301        PlotRun1 << "set title \"Loss map\"" << endl << endl;
     
    23522361    }
    23532362
     2363    }
     2364   
    23542365}
    23552366
Note: See TracChangeset for help on using the changeset viewer.