#ifndef SIMULATION_H #define SIMULATION_H #include #include #include #include #include #include #include #include #include #include #if defined(FLUKA) #include "FlukaIO.h" #endif #include "lattice.h" using namespace std; /* ########################################################################################################## This class contains all the tools that are necessary to run a simulation. It is called in the main. It is also where the link is made with Fluka when the lattice contains a Fluka Collimator. ########################################################################################################## */ class Simulation { public: //========================Constructors, destructor===================== Simulation() {}; Simulation(int size_bunch, int nbre_elts, string genere = "standard"); virtual ~Simulation(); //=============================== Other methods =============================== //base method simulating a run, it is called in the main and it calls the other functions void run(string inputfile, string outputpath); //method used to read the parameters in the collimator file void readInputFile(string inputfile, double& Apr, double& Zpr, double& mass, double& energyPerIon, double& emix, double& emiy, long int& npart, int& kbunch, double& sigdpp, int& taubeam, long int& nparti, string& partdistr, double& r1r2skin, long int& nrev1, int& nrev2, double& blowup2, int& blowupperiod, string& stoplineartracking, int& scaleorbit, double& wecolli, double& nsigi, string& opticsFile, double& thicknessmagneticfield, double& Bmax, double& deltaGap, int& beamflag, int& RunWithFluka, int& RunWithCrystal, double& freqrf, double& rfvoltage, double& rfharmonic, int& RunningFlag, int& idpart, int& idelt, int& outcoord, double& momentum, string& plotflag, string& inputpath, int& RFflag); //method used to extract the parameters of the lattice in the optics file void extractOpticsParameters(string opticsFile, const int& beamflag); //method used to end a connection with an external server (e.g. Fluka) void die(const char* msg); //method used to initialize most of the parameters read in the input files void defineParameters(string opticsFile, const int& beamflag, int& JohnJaperFlag); //method to read the parameters of a particles from a file void readParticle(const double& Apr, const double& Zpr, string inputfile); //linear interpolation method double interp1(double x1, double y1, double x2, double y2, double x); //method generating an initial bunch of particles void 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); //method used to display the coordinates of all particles in a bunch at a precise time (mostly used for tests) void affichebunch(); //method used to write the file output_.txt void writeoutput(string outputfile, const double& emix, const double& emiy, const double& Apr, const double& Zpr, const double& nparti, const double& beamflag, const double& PlossPb, const int& i0, const int& im, const int& npart, const int& kbunch, const vector & asumrem, const vector & asumhitcolli, const vector & asumhits, const int& taubeam, vector & hitso, const vector & nhitcollio, vector & Aphito, vector & Zphito, const int& ibeg, const int& iend, vector >& xco, vector >& yco, const string& plotflag, string outputpath, string inputpath); //method making three plots illustrating the result of an ICOSIM run: // 1) the power load on each collimator (averagely during the beam lifetime) // 2) the power loss in the ring as a function of s // 3) how many particles there are left in the beam, how many particles that // have been lost on a collimator, and how many particles that have been // lost on the aperture, as a function of the number of revolutions. void PlotRunSummary(const vector & asumrem, const vector & asumhitcolli, const vector & asumhits, const vector & nhitcollio, vector & hitso, const double& PlossPb, string outputpath); //makes plots that shows particle trajectories, trajectory of the reference particle, the beam envelope, the aperture and the collimators. void PlotTrajectory(const double& emix, const double& emiy, const int& ibeg, const int& iend, vector >& xco, vector >& yco, string outputpath); //makes a histogram that shows the losses on the aperture along the ring void PlotLossSpectra(const double& beamflag, const double& nparti, const vector & asumrem, const double& Apr, const double& Zpr, vector & hitso, vector & Aphito, vector & Zphito, const double& PlossPb, const int& npart, const int& kbunch, const int& taubeam, const vector & nhitcollio, string outputpath, string inputpath); //====================================== Attributs ====================================================== private: int sizeBunch; // size of the bunch vector bunch; //bunch of particles vector bunchhit; //contains the particles that hit a primary collimator during the linear tracking; input bunch for the non-linear tracking int nbre_elts; //number of elements in the lattice Lattice lat; //lattice (see class lattice) }; #endif