diff --git a/.gitignore b/.gitignore index 8550545ca5838ec841963a224dbcbcf26b0148bd..a9e20fb941e846fd27d29b53734498359dffa600 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,30 @@ DecayDataBank.log CLASS_Exec CLASS_OUTPUT.log CLASS_TimeStep + # Utils outputs +Utils/XSM/MLP/Generate/Generate_XSM +Utils/XSM/MLP/Generate/Train_XS +Utils/XSM/MLP/Generate/Data_Base_Info.nfo +Utils/XSM/MLP/Generate/_tmp +Utils/XSM/MLP/Generate/Trainining_output* +Utils/XSM/MLP/Generate/weights +Utils/XSM/MLP/Test/Mean_XS_accuracy.dat +Utils/XSM/MLP/Test/plots +Utils/EQM/MLP_Kinf/Generate_MLP_Kinf +Utils/EQM/MLP_Kinf/Train +Utils/EQM/MLP_Kinf/*.nfo +Utils/EQM/MLP_Kinf/_tmp +Utils/EQM/MLP_Kinf/Trainining_output* +Utils/EQM/MLP_Kinf/weights +Utils/EQM/MLP_Kinf/Train +Utils/EQM/FBR_MLP_Keff/Generate_FBR_Keff +Utils/EQM/FBR_MLP_Keff/Train +Utils/EQM/FBR_MLP_Keff/*.nfo +Utils/EQM/FBR_MLP_Keff/_tmp +Utils/EQM/FBR_MLP_Keff/weights +Utils/MURE2CLASS/MURE2CLASS + + # ---------------------------------------------------------------------------- # For Mac OS diff --git a/Utils/EQM/FBR_MLP_Keff/GenerateRootFile.cxx b/Utils/EQM/FBR_MLP_Keff/GenerateRootFile.cxx deleted file mode 100755 index 373bd7037cd6e32ecfbdeec5726ba4b16853c35b..0000000000000000000000000000000000000000 --- a/Utils/EQM/FBR_MLP_Keff/GenerateRootFile.cxx +++ /dev/null @@ -1,347 +0,0 @@ -/**********************************************************/ -// Make the input file for the MLPs training -// -// This programs reads a set of .dat files which are the -// results of a depletion calculation (see manual and -// looks for XS_CLOSEST). From the reading it fills a -// TTree (Data) and write it in a file named -// TrainingInput.root . -// The file TrainingInput.cxx is the list of MLP outputs -// (cross sections) -// -//@author BaM, BaL -/**********************************************************/ -#include "include/GenerateRootFile.hxx" -#include <TH1F.h> -#include <TH2D.h> -#include <TFile.h> -#include <TTree.h> -#include "include/StringLine.hxx" -#include <TString.h> -#include <string> -#include <cmath> -#include <iostream> -#include <fstream> -#include <algorithm> -#include <map> -#include <sstream> - -using namespace std; -//-------------------------------------------------------------------------------------------------- -/************************* - MAIN -*************************/ -int main(int argc, char ** argv){ - - if(argc!=2) - { - cout << "Usage : BuildInputTree Path" << endl; - cout << " Where Path is the path to the folder containing the Evolution Datas" << endl; - cout << " i.e the (.dat) files" << endl; - exit(0); - } - - fEvolutionDataFolder = argv[1]; - - InitMass(); //Load nuclei masses - CheckJob(); // looks fot the .dat files in the fEvolutionDataFolder - - FilePath = "DB_TMP/"; - DataPath = FilePath + "Data/"; - string Command = "mkdir -p " + DataPath; - system(Command.c_str()); - - cout << "Reading .dat files ..." << endl; - for(int i = 0; i < (int)JobName.size(); i++) - { - ReadAndFill(JobName[i]); - if (i%100 == 0) - cout << "\r" << i << " .dat files read" <<flush; - } - cout << "Filling the TTree ..." << endl; - DumpInputNeuron("TrainingInput.root"); - cout << "Training input generated in file : TrainingInput.root " << endl; - cout << "Names of MLP outputs in file : TrainingInput.cxx " << endl; - system("rm -r DB_TMP"); - -} -//-------------------------------------------------------------------------------------------------- -// Function definitions -//-------------------------------------------------------------------------------------------------- -//Convert int to string -string itoa(int num) -{ - ostringstream os(ostringstream::out); - os << num; - return os.str(); -} -//-------------------------------------------------------------------------------------------------- -void DumpInputNeuron(string filename) -{ - TFile* fOutFile = new TFile(filename.c_str(),"RECREATE"); - TTree* fOutT = new TTree("Data", "Data"); - -/**********************INITIALISATIONNN********************/ - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the input value according to your fresh fuel compo - //-> here MOX FUEL - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - double U5 = 0; - double U8 = 0; - double Pu8 = 0; - double Pu9 = 0; - double Pu10 = 0; - double Pu11 = 0; - double Pu12 = 0; - double Am1 = 0; - - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - double k_eff = 0; - - -/**********************BRANCHING**************************************************/ -/**********************Fresh fuel**************************************************/ - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the input value according to your fresh fuel compo - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - fOutT->Branch( "U5" ,&U5 ,"U5/D" ); - fOutT->Branch( "U8" ,&U8 ,"U8/D" ); - fOutT->Branch( "Pu8" ,&Pu8 ,"Pu8/D" ); - fOutT->Branch( "Pu9" ,&Pu9 ,"Pu9/D" ); - fOutT->Branch( "Pu10" ,&Pu10 ,"Pu10/D" ); - fOutT->Branch( "Pu11" ,&Pu11 ,"Pu11/D" ); - fOutT->Branch( "Pu12" ,&Pu12 ,"Pu12/D" ); - fOutT->Branch( "Am1" ,&Am1 ,"Am1/D" ); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - fOutT->Branch( "k_eff" ,&k_eff ,"k_eff/D" ); - -/**********************FILLING THE TTREE**************************************************/ - - //Fill containing all the output of the networks to train - - int NumOfBase=fActinideCompoInit.size(); - for(int b=0;b<NumOfBase;b++) - { - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the input value according to your fresh fuel compo - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - // (Z , A ,I) - U5 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(92,235,0)); - U8 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(92,238,0)); - Pu8 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,238,0)); - Pu9 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,239,0)); - Pu10 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,240,0)); - Pu11 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,241,0)); - Pu12 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,242,0)); - Am1 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(95,241,0)); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the TStep according the step you want - //@@@ I have assumed all your depletion calculations have - //@@@ the same time binning - //@@@ hoping is what you have done .... - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - int Tstep = 0; //at begining of cycle if 0 - - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - - k_eff=fkeff[b][Tstep]; - - fOutT->Fill(); - } - - fOutFile->Write(); - delete fOutT; - fOutFile-> Close(); - delete fOutFile; - -} -//-------------------------------------------------------------------------------------------------- -void InitMass() -{ -//Set tghe mass of the nuceli - -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// -//@@@Change : ADD THE MASS OF THE NUCLEI PRESENT IN YOUR FRESH FUEL -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - - ZAI U238 = ZAI(92,238,0); - ZAImass.insert(pair<ZAI,double>(U238, 238050788.247e-6)); - - ZAI U234 = ZAI(92,234,0); - ZAImass.insert(pair<ZAI,double>(U234, 234041000.000e-6)); - - ZAI U235 = ZAI(92,235,0); - ZAImass.insert(pair<ZAI,double>(U235, 235043929.918e-6)); - - ZAI Pu238 = ZAI(94,238,0); - ZAImass.insert(pair<ZAI,double>(Pu238,238049559.894e-6)); - - ZAI Pu239 = ZAI(94,239,0); - ZAImass.insert(pair<ZAI,double>(Pu239,239052163.381e-6)); - - ZAI Pu240 = ZAI(94,240,0); - ZAImass.insert(pair<ZAI,double>(Pu240,240053813.545e-6)); - - ZAI Pu241 = ZAI(94,241,0); - ZAImass.insert(pair<ZAI,double>(Pu241,241056851.456e-6)); - - ZAI Pu242 = ZAI(94,242,0); - ZAImass.insert(pair<ZAI,double>(Pu242,242058742.611e-6)); - - ZAI Am241 = ZAI(95,241,0); - ZAImass.insert(pair<ZAI,double>(Am241,241056829.144e-6)); - - ZAI O16 = ZAI(8,16,0); - ZAImass.insert(pair<ZAI,double>(O16, 0.)); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - -} -//-------------------------------------------------------------------------------------------------- -void CheckJob() -{ //LOAD THE LIST OF EvolutionData - cout << "Scanning " << fEvolutionDataFolder << " for .dat files ..." << endl; - cout << "Please wait ..."<< endl; - - string Command = "find "+ fEvolutionDataFolder + " -name \"*.dat\" > JOB.tmp"; - system(Command.c_str()); - - ifstream JOB("JOB.tmp"); - if (JOB.is_open()) - { - while (!JOB.eof()) - { - string tmp; - getline(JOB,tmp); - JobName.push_back(tmp); - } - } JOB.close(); JobName.pop_back(); - - // Remove temporary files... - Command = "\\rm -f JOB.tmp"; - system(Command.c_str()); - random_shuffle(JobName.begin(), JobName.end()); - cout << "Scan complete" <<endl; -} - -//-------------------------------------------------------------------------------------------------- -void ReadAndFill(string jobname) -{ //Read a .dat file and fill XS maps and the fuel initial composition -//Read a .dat file and fill XS maps and the fuel initial composition - - vector<double> vT; - vector<int> Z; - vector<int> A; - vector<int> I; - vector<double> Q; - - ifstream DecayDB(jobname.c_str()); // Open the File - if(!DecayDB) - { - cout << "!!Warning!! !!!EvolutiveProduct!!! \n Can't open \"" << jobname << "\"\n" << endl; - } - - string line; - int start = 0; - - getline(DecayDB, line); - - /******Getting Time vecotr ....******/ - if( StringLine::NextWord(line, start, ' ') != "time") - { - cout << "!!Bad Trouble!! !!!EvolutiveProduct!!! Bad Database file : " << jobname << endl; - exit (1); - } - - while(start < (int)line.size()) - vT.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); - - fNOfTimeStep=int(vT.size()); - - - start = 0; - getline(DecayDB, line); - string tmp = StringLine::NextWord(line, start, ' '); - vector<double> vKeff; - if ( tmp == "keff" || tmp == "Keff" ) - { - while(start < (int)line.size()) - vKeff.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); - } - fkeff.push_back(vKeff); - - - /****Getting Inventories***/ - getline(DecayDB, line); - do - { - start = 0; - int z; - string tmp2 = StringLine::NextWord(line, start, ' '); - if (tmp2 == "Inv") { - z = atoi(StringLine::NextWord(line, start, ' ').c_str()); - } - else z = atoi(tmp2.c_str()); - int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); - - if(a!=0 && z!=0) - { - - ZAI zaitmp(z, a, i); - Z.push_back(z); - A.push_back(a); - I.push_back(i); - if(!fIsAllNucleiAlreadyFill) - { - fAllNuclei.push_back(zaitmp); - fTime=vT; - } - - long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); - Q.push_back(q); - - } - - getline(DecayDB, line); - start = 0; - tmp2 = StringLine::NextWord(line, start, ' '); - - if(line == "" || line == "CrossSection" || tmp2 == "XSFis" || tmp2 == "XSCap" || tmp2 == "XSn2n") break; - }while (!DecayDB.eof() ); - - if(fAllNuclei.size()!=0) - fIsAllNucleiAlreadyFill=true; - - DecayDB.close(); - - double N = 0; - for(int i=0; i < (int)Z.size()-2; i++) - { - if( Z[i]>89 ) - N += Q[i]; - } - - - IsotopicVector CompoBasei; - - for(int i=0; i < (int)Z.size()-2; i++) - { - if(Z[i]>89) - { - ZAI zai = ZAI(Z[i], A[i], I[i]); - CompoBasei.IVquantity.insert(pair<ZAI,double>(zai,Q[i]/N)); - } - } - - fActinideCompoInit.push_back(CompoBasei); - -GoodJobName.push_back(jobname); - - -} -/*------------------------------------------------------------------------------------------------- -COMPILATION : - -g++ -o GenerateRootFile GenerateRootFile.cxx `root-config --cflags` `root-config --libs` - -*/ \ No newline at end of file diff --git a/Utils/EQM/FBR_MLP_Keff/Generate_FBR_Keff.cxx b/Utils/EQM/FBR_MLP_Keff/Generate_FBR_Keff.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a7d4fb6596828e44160c06ab7eee0684341305aa --- /dev/null +++ b/Utils/EQM/FBR_MLP_Keff/Generate_FBR_Keff.cxx @@ -0,0 +1,942 @@ +/**********************************************************/ +// Make the input file for the MLPs training +// +// This programs reads a set of .dat files which are the +// results of a depletion calculation (see manual and +// looks for XS_CLOSEST). From the reading it fills a +// TTree (Data) and write it in a file named +// TrainingInput.root . +// OUTPUTS : +// 1- File TrainingInput.cxx is the list of MLP outputs +// (cross sections) +// 2- File TrainingInput.root input datas (as a Root TTREE) for MLP training +// 3- File Data_Base_Info.nfo Information file to be red by XSM_MLP +// (to be place in the weight folder which is build by MLP training) +// +//@author BaM, BaL +/**********************************************************/ +#include "include/Generate_FBR_Keff.hxx" +#include <TH1F.h> +#include <TH2D.h> +#include <TFile.h> +#include <TTree.h> +#include "../../../source/external/StringLine.hxx" +#include <TString.h> +#include <string> +#include <cmath> +#include <math.h> +#include <iostream> +#include <fstream> +#include <algorithm> +#include <map> +#include <sstream> +#include <numeric> +#include <functional> +#include <algorithm> +#include <ctime> + +using namespace std; + +ZAIMass cZAIMass; //atomic masses + +string ElNames[110]={" ","H","He","Li","Be", + "B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar", + "K","Ca","Sc","Ti","V ","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge", + "As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd", + "Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd", + "Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W", + "Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra", + "Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No", + "Lr","Rf","Db","Sg","Bh","Hs","Mt"}; + +//-------------------------------------------------------------------------------------------------- +/************************* + MAIN +*************************/ +int main(int argc, char ** argv) +{ + + if(argc!=2) + { + cout << "Usage : Generate_MLP_Kinf Path" << endl; + cout << " Where Path is the path to the folder containing Evolution Datas" << endl; + cout << " i.e the (.dat) files" << endl; + exit(0); + } + + /*****************Preparation of working folders*************************/ + if(is_file_exist("Training_output_k_eff.root" )) + { + cout<< "\033[33m Trainining_output* detected. Delete these files and weights folder ? [y/n]\033[0m"<< endl; + if(UserSayYes()) + system( "rm -rf Training_output* weights" ); + else + { cout << "Move this files elsewhere and run this program again"<< endl; + exit(0); + } + } + + if(is_file_exist("_tmp/include_Train/TrainingInput.root" )) + system( "rm -rf _tmp" ); + + system("mkdir -p _tmp/include_Train"); + /**********************************************************************/ + + fEvolutionDataFolder = argv[1]; + CheckJob(); // looks fot the .dat files in the fEvolutionDataFolder + + cout << endl; + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ Load your EvolutionDatas to R.A.M │" << endl; + cout << "╰───────────────────────────────────────────────╯" << endl; + cout<< endl; + for(int i = 0; i < (int)JobName.size(); i++) + { + ReadAndFill(JobName[i]); + ProgressBar(i,JobName.size()); + } + ProgressBar(1,1); + + FillMapName(); + + cout << endl; + cout << "│ SELECT YOUR TIME STEP │" << endl; + cout << "This model aims to predict the fissile content needed to reach\nthe user define keff at a given time (often 0 or end of cycle)"<< endl; + cout << "Please select the time \033[36m Step \033[0m corresponding to this time" <<endl; + cout << "\tStep\ttime[year]" <<endl; + for(int i = 0 ; i < fTime[0].size() ; i++ ) + cout << "\t\033[36m" << i << "\033[0m\t" << fTime[0][i]/(3600.*24*365.25)<<endl; + cout << endl; + cout << "│↑↑↑↑↑↑↑↑↑↑↑↑ READ ABOVE ↑↑↑↑↑↑↑↑↑↑↑↑↑│" << endl; + cout << " Enter time step : " << endl; + GetUserValue(fKeffStep); + cout << "The keff at time step : " << fKeffStep << "("<<fTime[0][fKeffStep]<<"year) will be used to predict fissile content" << endl ; + cout << endl; + cout << "Proportion of data to be used for training ? ]0-100[" << endl; + double ProportionOfTraining = 0 ; + + GetUserValue( ProportionOfTraining); + DumpInputNeuron("_tmp/include_Train/TrainingInput.root"); + Generate_tmva_factory_input(ProportionOfTraining); + + string ModelName = CreateInfoFile(); + + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ GENERATED FILES: │" << endl; + cout << "├─────────────────────────────────────────────────────────────────────┤" << endl; + cout << "│#1 Input for TMVA training: \033[36m_tmp/include_Train/TrainingInput.root\033[0m │" << endl; + cout << "│#3 Model Information for CLASS: \033[36m"+ ModelName +".nfo\033[0m │" << endl; + cout << "╰─────────────────────────────────────────────────────────────────────╯" << endl; + cout << endl; + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ NEXT STEPS: │" << endl; + cout << "├────────────────────────────────────────────────┤" << endl; + cout << "│1. Train your MLPs with \033[36mTrain.cxx\033[0m │" << endl; + cout << "│2. Test MLPs performances using informations in:│" << endl; + cout << "│ \033[36mUtils/XSM/MLP/Test/EvaluateTrainingCommands.dat\033[0m│" << endl; + cout << "│3. Put the file #3 in \033[36mweights\033[0m folder then │" << endl; + cout << "│ move this folder to $CLASS_PATH/DATA_BASES/"<<fReactorType<<"/"<<fFuelType << "/EQModel/FBR_Keff/ChooseAName │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + cout << endl; + cout << "=> Doing the first step for you. Do you want to train the MLP on your local machine ? [y/n]" << endl; + + if(UserSayYes()) + { + CompileTraining(); + cout << "Let's train locally ? [y/n]" << endl; + if(UserSayYes()) + { + system("./train"); + if(TrainingHasSucceed()) + { + cout << "\t \033[32m CONGRATULATION TRAINING HAS SUCCEED \033[0m " << endl; + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ NEXT STEPS: │" << endl; + cout << "├────────────────────────────────────────────────┤" << endl; + cout << "│1.(optional) Test MLPs performances using │" << endl; + cout << "│ informations in: │" << endl; + cout << "│ \033[36mUtils/XSM/MLP/Test/EvaluateTrainingCommands.dat\033[0m│" << endl; + cout << "│2. Put the file .nfo in \033[36mweights\033[0m folder then │" << endl; + cout << "│ move this folder to $CLASS_PATH/DATA_BASES/"<<fReactorType<<"/"<<fFuelType << "/EQModel/FBR_Keff/ChooseAName │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + } + else + { + cout << "\t \031[32m TRAINING HAS FAILED \033[0m" << endl; + cout << "I supposed you did something nasty. " << endl; + cout << "Hints : "<<endl; + cout << "Does your training sample is big enough ?" << endl; + cout << "-> Look for \"ANN too complicated:\" in TMVA term output " <<endl, + cout << " If present maybe you can increase the proportion of events for training" << endl; + cout << " or change ANN archintecture in Train.cxx " <<endl; + } + + } + else + { + cout << "You can run it latter with ./Train" << endl; + exit(0); + } + } +} + +//-------------------------------------------------------------------------------------------------- +bool TrainingHasSucceed() +{ + if(is_file_exist("weights/TMVARegression_MLP_k_eff.weights.xml" )) + return true; + +return false; +} + +//-------------------------------------------------------------------------------------------------- +void GetUserValue(int &Value) +{ + string sValue ; + std::getline(std::cin, sValue); + + if(StringLine::IsDouble(sValue)) + { + double dValue = atof(sValue.c_str()); + double iValue = floor(dValue); + + if( dValue != iValue ) + { + cout << "It must be an INTEGER" << endl; + GetUserValue(Value); + + } + else + Value = iValue; + } + + else + { + cout << "It must be an INTEGER" << endl; + GetUserValue(Value); + } + +} +void GetUserValue(double &Value) +{ + string sValue ; + std::getline(std::cin, sValue); + + if(StringLine::IsDouble(sValue)) + Value = atof(sValue.c_str()); + else + { + cout << "It must be a DOUBLE" << endl; + GetUserValue(Value); + } +} +void GetUserValue(string &Value) +{ + std::getline(std::cin, Value); +} +//-------------------------------------------------------------------------------------------------- +bool is_file_exist(const char *fileName) +{ + std::ifstream infile(fileName); + return infile.good(); +} +//-------------------------------------------------------------------------------------------------- +void CompileTraining() +{ + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ COMPLILING TMVA TRAINING PROGRAM │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + if(is_file_exist("Train")) + system("rm Train"); + + string CMD = "g++ -o Train `root-config --cflags` Train.cxx `root-config --glibs` -lTMVA"; + cout << CMD << endl; + system(CMD.c_str()); + + if(!is_file_exist("Train")) + { + cout <<"\033[31m COMPILATION FAILED !!! May be not the good compilator name nor the good path of file to compile ? \033[0m " << endl; + exit(1); + } + else + cout <<"\t \033[32m Done \033[0m " << endl; + + +} + +//-------------------------------------------------------------------------------------------------- +//Convert int to string +string itoa(int num) +{ + ostringstream os(ostringstream::out); + os << num; + return os.str(); +} +//-------------------------------------------------------------------------------------------------- +//Give a name to a cross section +//!!!!!!!!!!!!!!!!!!!!!!!!!!// +// YOU MUST KEEP THE FORMAT : +// XS_Z_A_I_fis (fission cross section) +// XS_Z_A_I_cap (n,gamma cross section) +// XS_Z_A_I_n2n (n,2n cross section) +//!!!!!!!!!!!!!!!!!!!!!!!!!!// +string NameXS(ZAI act,string xs) +{ + stringstream Name; + Name<<"XS_"<<act.Z<<"_"<<act.A<<"_"<<act.I<<"_"<<xs; + + return Name.str(); +} + +//-------------------------------------------------------------------------------------------------- +void FillMapName() +{ + cout<< endl; + cout<< "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<< "│ SET UP MLPs INPUT │"<< endl; + cout<< "│default : composition @ t=0 + Irradiation time │"<< endl; + cout<< "╰───────────────────────────────────────────────╯"<< endl; + cout<< endl; + + vector<ZAI> ZAI_T0 = fActinideCompoInit[0].GetNonZeroZAIList(); + + for(int zai = 0 ; zai < ZAI_T0.size() ; zai++ ) + { stringstream ssname; + int Z = ZAI_T0[zai].Z; + int A = ZAI_T0[zai].A; + int I = ZAI_T0[zai].I; + string sI=""; + if(I == 1) + sI = "m"; + else if(I == 2) + sI = "2m"; + else if(I == 3) + sI = "3m"; + + ssname<<A<<ElNames[Z]<<sI; + if(zai == 0) + cout<< "Add this nuclei with this name [y/n] ? (if you don't know type yes to all) "<< endl; + else + cout<< "Add [y/n] ? "<< endl; + + cout<< "[Z\tA\tI\tName]"<< endl; + cout<<"\033[36m"<<Z<<"\t"<<A<<"\t"<<I<<"\t"<<ssname.str()<<"\033[0m"<< endl; + if (UserSayYes()) + { + fMapName.insert(pair<ZAI,string> ( ZAI(Z,A,I) , ssname.str()) ); + FissileOrFertileList(Z,A,I); + } + } + + bool UserWantToAdd = true; + while(UserWantToAdd) + { + cout<< "Do you want to add additional nuclei [y/n] ? (if you don't know type no) "<< endl; + if(UserSayYes()) + { + int Z = 0; + int A = 0; + int I = 0; + string Name; + cout << " Z -> "; + GetUserValue( Z); + cout <<" A -> "; + GetUserValue( A); + cout <<" I -> "; + GetUserValue( I); + cout <<" Name -> "; + GetUserValue( Name); + + fMapName.insert(pair<ZAI,string> ( ZAI(Z,A,I) ,Name) ); + + FissileOrFertileList(Z,A,I); + } + + else + UserWantToAdd = false; + } + + +} + +//-------------------------------------------------------------------------------------------------- +void FissileOrFertileList(int Z,int A,int I) +{ + + cout << "Is this nuclei is considered to be a part of a fissile element ? [y/n]" << endl; + + if (UserSayYes()) + fStreamList.push_back( ZAIStreamList(Z,A,I,"Fissile",1) ); + else + { + cout<<"So it is considered as fertile\n What is the default proportion of this nucleus in the fertile vector ? [0-1] " << endl; + double Default_Proportion = 0; + GetUserValue( Default_Proportion); + fStreamList.push_back( ZAIStreamList(Z,A,I,"Fertile",Default_Proportion) ); + } + cout<< endl; +} + +//-------------------------------------------------------------------------------------------------- +void Generate_tmva_factory_input(double ProportionOfTraining) +{ + + ofstream InputNetwork("_tmp/include_Train/InputVariables.cxx"); + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + InputNetwork <<"factory->AddVariable( \"" << it->second << "\" , \"" << it->second << "\", \"IsotopicFraction\", 'F' );"<< endl; + + ProportionOfTraining /=100; + InputNetwork <<"double PropTraining = "<< ProportionOfTraining <<";"<< endl; + + InputNetwork.close(); +} + +//-------------------------------------------------------------------------------------------------- +bool UserSayYes() +{ + bool AnswerIsNotGiven = true; + bool isYES = false; + while(AnswerIsNotGiven) + { + string answer; + GetUserValue( answer); + + + if(answer == "y" || answer == "yes" || answer == "Yes" || answer == "Y") + { + isYES = true; + AnswerIsNotGiven = false; + } + else if (answer == "n" || answer == "no" || answer == "No" || answer == "N") + { + isYES = false; + AnswerIsNotGiven = false; + } + + else{ + cout << "Yes OR No ? "<< endl; + } + } + return isYES; +} + +//-------------------------------------------------------------------------------------------------- +string CreateInfoFile() +{ + + /**************************************************/ + // GETTING USER INFO + /**************************************************/ + double sum = 0 ; + for (int i=0 ; i < fHMMass.size() ; i++) + sum+=fHMMass[i]; + + double MeanHMMass = sum / (double)fHMMass.size(); + string Author,Mail,XSBase,HLCut,EnergyDisc,FPYBase,SABase,Geom,AddInfo,DepCode ; + double Power = 0, FissileFirstGuess = 0 , MaxFisisle = 0; + + + int start=0; + string AnInfoFile = JobName[0]; + int pos=AnInfoFile.find(".dat",start); + AnInfoFile.replace(pos,4,".info"); + + ReadInfo(AnInfoFile,fReactorType,fFuelType,Power); + + cout<< endl; + cout<< endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<<"│ XSM_MLP .NFO FILE GENERATOR │"<< endl; + cout<<"╰───────────────────────────────────────────────╯"<< endl; + cout<<" Answer following questions "<< endl; + cout<<"-> Author(s) name(s) : "<< endl; + GetUserValue( Author); + cout<< endl; + + cout<<"-> email adress(es) : "<< endl; + GetUserValue( Mail); + cout<< endl; + + cout<<"-> Depletion code used : "<< endl; + GetUserValue( DepCode); + cout<< endl; + + cout<<"-> Cross section data base (e.g ENSDF7.1) : "<< endl; + GetUserValue( XSBase); + cout<< endl; + + cout<<"-> Fission yield data base (e.g ENSDF7.1) : "<< endl; + GetUserValue( FPYBase); + cout<< endl; + + cout<<"-> S(alpha,beta) data base (e.g ENSDF7.1) : "<< endl; + GetUserValue( SABase); + cout<< endl; + + cout<<"-> Geometry simulated (e.g Cubic Assembly with mirror boundary) : "<< endl; + GetUserValue( Geom); + cout<< endl; + + cout<<"-> Half life cut [s] (if any) : "<< endl; + GetUserValue( HLCut); + cout<< endl; + + cout<<"-> Multi group treatment (yes/no if yes give the number of groups) : "<< endl; + GetUserValue( EnergyDisc); + cout<< endl; + + cout<<"-> Additional informations : "<< endl; + GetUserValue( AddInfo); + cout<< endl; + + + cout<<"-> Reactor type (e.g PWR, FBR,...) : "<< endl; + cout<<"Found in a .info file :"<< endl; + cout<<"\033[36m"<<fReactorType<<"\033[0m"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( fReactorType); + } + cout<< endl; + + cout<<"-> Fuel type (e.g UOX, MOX,...) : "<< endl; + cout<<"Found in a .info file :"<< endl; + cout<<"\033[36m"<<fFuelType<<"\033[0m"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( fFuelType); + + } + cout<< endl; + + cout<<"-> Simulated heavy metal mass (tons) : "<< endl; + cout<< "\t According your evolution datas the AVERAGE heavy metal mass is : "<< endl; + cout<<"\033[36m"<<MeanHMMass<<"\033[0m"<<" tons"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( MeanHMMass); + } + cout<< endl; + + cout<<"-> Simulated thermal power (W) : "<< endl; + cout<<"Found in a .info file :"<< endl; + cout<<"\033[36m"<<Power<<"\033[0m"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( Power); + } + cout<< endl; + + cout<<"-> First guess of fissile content in fresh fuel (for algorithm initialization): ]0-1[ "<< endl; + GetUserValue( FissileFirstGuess); + + cout<<"-> Maximal fissile content in the fresh fuel (for algorithm max range): ]0-1[ "<< endl; + GetUserValue( MaxFisisle ); + + cout<< endl; + + + /**************************************************/ + // BUILDING FILE + /**************************************************/ + stringstream ssModelName; + ssModelName << fReactorType << "_" << fFuelType << "_" << Power/(MeanHMMass*1e6) << "Wg"; + + + ofstream InfoFile( (ssModelName.str() + ".nfo").c_str()); + + InfoFile << "To be used with : EQM_FBR_MLP_Keff.cxx " << endl; + InfoFile <<" THIS MODEL PREDICT FISSILE CONTENT THANKS TO Keff CALCULATES AT :"<<endl; + InfoFile <<" Time Step : # " << fKeffStep << " which correspond to" << fTime[0][fKeffStep]<< " year(s)" <<endl; + InfoFile <<"=================================================" << endl; + InfoFile <<" Informations needed by EQM_FBR_MLP_Keff model " << endl; + InfoFile <<"=================================================" << endl; + InfoFile << endl; + InfoFile << "Reactor Type :"<< endl; + InfoFile << "K_REACTOR "<< fReactorType << endl; + InfoFile << endl; + InfoFile << "Fuel Type :"<< endl; + InfoFile << "K_FUEL "<< fFuelType << endl; + InfoFile << endl; + InfoFile << "Specific Power (W/gHM) :"<< endl; + InfoFile << "K_SPECPOWER "<< Power/(MeanHMMass*1e6) << endl; + InfoFile << endl; + + double IrrTimeMax = 0; + for(int i = 0 ; i < fTime.size() ; i++ ) + { + if (IrrTimeMax < fTime[i].back()) + IrrTimeMax = fTime[i].back(); + } + + InfoFile << "Maximal fissile content (algo use) :" << endl; + InfoFile << "K_MAXFISCONTENT "<< MaxFisisle << endl; + InfoFile << endl; + + + InfoFile << "Z A I Name (input MLP) :"<< endl; + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + InfoFile <<"K_ZAINAME "<<it->first.Z <<" " <<it->first.A <<" " <<it->first.I<<" " << it->second << endl ; + InfoFile << endl; + + InfoFile << "Name of stream for fabrication (fissile or fertile):" << endl; + InfoFile << "Z A I Default_Proportion" << endl; + for( int l = 0 ; l < (int) fStreamList.size() ; l++ ) + InfoFile <<"K_LIST "<<fStreamList[l].fZAI.Z <<" " << fStreamList[l].fZAI.A <<" " <<fStreamList[l].fZAI.I<<" " << fStreamList[l].fListName <<" "<< fStreamList[l].fDefaultProportion<< endl ; + InfoFile << endl; + + InfoFile << "Starting fissile content in fuel for equivalence model calculation :"<< endl; + InfoFile << "k_firstguesscontent Fissile " << FissileFirstGuess << endl; + InfoFile << "k_firstguesscontent Fertile " << 1 - FissileFirstGuess << endl; + InfoFile << endl; + + InfoFile << "Fuel range (Z A I min max) :"<< endl; + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { vector <double> AllCompoOfZAI = GetAllCompoOf(it->first); + vector <double>::iterator Min = std::min_element(AllCompoOfZAI.begin(),AllCompoOfZAI.end()); + vector <double>::iterator Max = std::max_element(AllCompoOfZAI.begin(),AllCompoOfZAI.end()); + InfoFile <<"K_ZAIL "<<it->first.Z <<" " <<it->first.A <<" " <<it->first.I<<" " << *Min << " " << *Max << endl ; + } + InfoFile << endl; + InfoFile <<"============================================" << endl; + InfoFile <<" Data base generation informations " << endl; + InfoFile <<"============================================" << endl; + InfoFile << endl; + time_t t = time(0); // get time now + struct tm * now = localtime( & t ); + InfoFile <<" Date: "<< now->tm_mday<< '/'<< (now->tm_mon + 1) << '/' <<(now->tm_year + 1900)<< endl; + InfoFile <<" Author(s): "<< Author << endl; + InfoFile <<" Author(s) contact: "<< Mail << endl; + InfoFile <<" Depletion code: "<< DepCode << endl; + InfoFile <<" Simulated geometry: "<< Geom << endl; + InfoFile <<" Nuclear data used in "<< DepCode << endl; + InfoFile <<"\tCross section library: "<< XSBase << endl; + InfoFile <<"\tFission yield library: "<< FPYBase << endl; + InfoFile <<"\tS(alpha,beta) library: "<< SABase << endl; + InfoFile <<" Half life cut [s] : "<< HLCut << endl; + InfoFile <<" Multi-group treatment: "<< EnergyDisc << endl; + InfoFile <<" Additional informations: "<< endl << AddInfo << endl; + +return ssModelName.str(); + +} +//-------------------------------------------------------------------------------------------------- +vector<double> GetAllCompoOf(ZAI zai) +{ + vector<double> AllCompoOfZAI; + + for( int b = 0 ; b < fActinideCompoInit.size() ; b++ ) + AllCompoOfZAI.push_back(fActinideCompoInit[b].GetZAIIsotopicQuantity(zai)); + +return AllCompoOfZAI; +} +//-------------------------------------------------------------------------------------------------- +void ProgressBar(double loopindex, double totalindex) +{ + // Reset the line + //for(int i = 0; i < 22; i++) + // cout << " "; + cout << flush ; + + cout << "\033[42m"; + for(int i = 0; i < (int)(loopindex/totalindex*44.0); i++) + cout << " "; + cout<<" \033[41m"; + for(int i = 44; i >= (int)(loopindex/totalindex*44.0); i--) + cout << " "; + cout<<"\033[0m"; + cout << (int)(loopindex/totalindex*100) << "%\r"; + cout << flush; + //cout << endl; +} +//-------------------------------------------------------------------------------------------------- +void ReadInfo(string InfoDBFile,string &ReactorType,string &FuelType,double &Power) +{ + ifstream InfoDB(InfoDBFile.c_str()); // Open the File + if(!InfoDB) + { + cout << "\033[31m !!ERROR!! !!!EvolutionData!!! \n Can't open \"" << InfoDBFile << "\"\033[0m \n" << endl; + } + else + { + int start = 0; + string line; + getline(InfoDB, line); + string Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "reactor") + ReactorType = StringLine::NextWord(line, start, ' '); + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "fueltype") + FuelType = StringLine::NextWord(line, start, ' '); + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "cycletime") + double cycletime = atof(StringLine::NextWord(line, start, ' ').c_str()); + + getline(InfoDB, line); // Assembly HM Mass DONT TRUST THIS ONE CALCULATED WITH A instead of real atomic mass + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "constantpower") + Power = atof(StringLine::NextWord(line, start, ' ').c_str()); + InfoDB.close(); + } + +} + + +//-------------------------------------------------------------------------------------------------- +void DumpInputNeuron(string filename) +{ + TFile* fOutFile = new TFile(filename.c_str(),"RECREATE"); + TTree* fOutT = new TTree("Data", "Data"); + + +/**********************INITIALISATIONNN********************/ + + //////////////////////////////////////////////////////// + // INIT FRESH FUEL COMPOSITION and TIME + //////////////////////////////////////////////////////// + + double *FreshCompo = new double[fMapName.size()]; + + for(int i = 0 ; i < fMapName.size() ; i++ ) + FreshCompo[i] = 0; + + //////////////////////////////////////////////////////// + double k_eff = 0; + + +/**********************BRANCHING**************************************************/ +/**********************Fresh fuel**************************************************/ + + map<ZAI,string>::iterator it; + int index = 0; + for(it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { string Name = it->second + "/D"; + fOutT->Branch( it->second.c_str() , &FreshCompo[index] , Name.c_str()); + index++; + } + + //////////////////////////////////////////////////////// + fOutT->Branch( "k_eff" ,&k_eff ,"k_eff/D" ); + + +/**********************FILLING THE TTREE**************************************************/ + cout<< endl; + cout<< endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<<"│ FILLING TTREE │"<< endl; + cout<<"│ (building TrainingInput.root) │"<< endl; + cout<<"╰───────────────────────────────────────────────╯"<< endl; + cout<< endl; + + int NumOfBase=fActinideCompoInit.size(); + for(int b=0;b<NumOfBase;b++) + { + + ProgressBar(b,NumOfBase); + + /////////////////////////////////////////////////////// + int index =0; + for(it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { + int Z = it->first.Z; + int A = it->first.A; + int I = it->first.I; + FreshCompo[index] = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(Z,A,I)); + + index++; + } + + k_eff=fkeff[b][fKeffStep]; + + fOutT->Fill(); + } + ProgressBar(1,1); + + fOutFile->Write(); + delete fOutT; + fOutFile-> Close(); + delete fOutFile; + +} + +//-------------------------------------------------------------------------------------------------- +void CheckJob() +{ //LOAD THE LIST OF EvolutionData + + cout<< endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<<" Scanning : "<< endl; + cout<< fEvolutionDataFolder << endl; + cout<<" for EvolutionData (.dat files) "<< endl; + cout<<"╰───────────────────────────────────────────────╯"<< endl; + + string Command = "find "+ fEvolutionDataFolder + " -name \"*.dat\" > JOB.tmp"; + system(Command.c_str()); + + ifstream JOB("JOB.tmp"); + + if(JOB.peek() == std::ifstream::traits_type::eof()) // if file is empty + { cout << endl << "\033[31mERROR: No .dat found in folder : " << fEvolutionDataFolder << "\033[0m" << endl; + exit(1); + } + + if (JOB.is_open()) + { + while (!JOB.eof()) + { + string tmp; + getline(JOB,tmp); + JobName.push_back(tmp); + } + } JOB.close(); JobName.pop_back(); + + // Remove temporary files... + Command = "\\rm -f JOB.tmp"; + system(Command.c_str()); + random_shuffle(JobName.begin(), JobName.end()); + cout << "\033[32m Scan complete \033[0m" << endl; +} + +//-------------------------------------------------------------------------------------------------- +void ReadAndFill(string jobname) +{ //Read a .dat file and fill XS maps and the fuel initial composition + + vector<double> vT; + vector<int> Z; + vector<int> A; + vector<int> I; + vector<double> Q; + + ifstream DecayDB(jobname.c_str()); // Open the File + if(!DecayDB) + { + cout << "\033[33m !!Warning!! !!!EvolutiveProduct!!! \n Can't open \"" << jobname << "\"\033[0m\n" << endl; + } + + string line; + int start = 0; + + getline(DecayDB, line); + + /******Getting Time vecotr ....******/ + if( StringLine::NextWord(line, start, ' ') != "time") + { + cout << "\033[31m!!Bad Trouble!! !!!EvolutiveProduct!!! Bad Database file : " << jobname << "\033[0m" << endl; + exit (1); + } + + while(start < (int)line.size()) + vT.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); + + fTime.push_back(vT); + + fNOfTimeStep.push_back(int(vT.size())); + + /****Getting Keff***/ + start = 0; + getline(DecayDB, line); + string tmp = StringLine::NextWord(line, start, ' '); + vector<double> vKeff; + if ( tmp == "keff" || tmp == "Keff" ) + { + while(start < (int)line.size()) + vKeff.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); + } + fkeff.push_back(vKeff); + + /****Getting Inventories***/ + getline(DecayDB, line); + do + { + start = 0; + int z; + string tmp2 = StringLine::NextWord(line, start, ' '); + if (tmp2 == "Inv") { + z = atoi(StringLine::NextWord(line, start, ' ').c_str()); + } + else z = atoi(tmp2.c_str()); + int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); + + if(a!=0 && z!=0) + { + + ZAI zaitmp(z, a, i); + Z.push_back(z); + A.push_back(a); + I.push_back(i); + if(!fIsAllNucleiAlreadyFill) + { + fAllNuclei.push_back(zaitmp); + } + + long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); + Q.push_back(q); + + } + + getline(DecayDB, line); + start = 0; + tmp2 = StringLine::NextWord(line, start, ' '); + + if(line == "" || line == "CrossSection" || tmp2 == "XSFis" || tmp2 == "XSCap" || tmp2 == "XSn2n") break; + }while (!DecayDB.eof() ); + + if(fAllNuclei.size()!=0) + fIsAllNucleiAlreadyFill=true; + + DecayDB.close(); + + double N = 0; + for(int i=0; i < (int)Z.size()-2; i++) + { + if( Z[i]>89 ) + N += Q[i]; + } + + + IsotopicVector CompoBasei; + IsotopicVector CompoBaseiUnormalize; + + for(int i=0; i < (int)Z.size()-2; i++) + { + if(Z[i]>89) + { + ZAI zai = ZAI(Z[i], A[i], I[i]); + CompoBasei.IVquantity.insert(pair<ZAI,double>(zai,Q[i]/N)); + CompoBaseiUnormalize.IVquantity.insert(pair<ZAI,double>(zai,Q[i])); + } + } + + fActinideCompoInit.push_back(CompoBasei); + double MassOfThisFuel = cZAIMass.GetMass(CompoBaseiUnormalize); + //cout<<MassOfThisFuel<< endl; + fHMMass.push_back(MassOfThisFuel); + +GoodJobName.push_back(jobname); + +} +/*------------------------------------------------------------------------------------------------- +COMPILATION : + +g++ -o Generate_FBR_Keff Generate_FBR_Keff.cxx `root-config --cflags` `root-config --libs` + + +*/ diff --git a/Utils/EQM/FBR_MLP_Keff/Train_MLP.cxx b/Utils/EQM/FBR_MLP_Keff/Train.cxx old mode 100755 new mode 100644 similarity index 59% rename from Utils/EQM/FBR_MLP_Keff/Train_MLP.cxx rename to Utils/EQM/FBR_MLP_Keff/Train.cxx index 7ca138d39f54ab14ff0e426a0d7e61e1501e1e7b..06d14c44c89f040b482ff1e45268c393e7432a90 --- a/Utils/EQM/FBR_MLP_Keff/Train_MLP.cxx +++ b/Utils/EQM/FBR_MLP_Keff/Train.cxx @@ -14,7 +14,6 @@ #include "TSystem.h" #include "TROOT.h" -#include "TMVARegGui.C" #if not defined(__CINT__) || defined(__MAKECINT__) #include "TMVA/Tools.h" @@ -25,23 +24,13 @@ using namespace TMVA; int main(int argc, char const *argv[]) { - if(argc!=2) - { - std::cout << "TrainMLP Usage :" << std::endl; - std::cout << "\tTrainMLP YourTrainingData.root" << std::endl; - } + //--------------------------------------------------------------- // This loads the library TMVA::Tools::Instance(); // --------------------------------------------------------------- - // if(argc !=3) - // { - // cout<<"error : "<<endl; - // cout<<"Usage : Train_MLP rootfile.root targetname : "<<endl; - // cout<<"\t targetname : keff or k_0 or k_1 ..."<<endl; - // exit(1); - // } - std::string TargetName = "k_eff";//argv[2]; + + std::string TargetName = "k_eff"; std::cout << std::endl; @@ -49,7 +38,7 @@ int main(int argc, char const *argv[]) // Create a new root output file - TString outfileName( "TMVA_"+TargetName+".root" ); + TString outfileName( "Training_output_"+TargetName+".root" ); TFile* outputFile = TFile::Open( outfileName, "RECREATE" );//UPDATE @@ -63,37 +52,10 @@ int main(int argc, char const *argv[]) TMVA::Factory *factory = new TMVA::Factory( "TMVARegression", outputFile, "!V:!Silent:Color:DrawProgressBar" ); - // If you wish to modify default settings - // (please check "src/Config.h" to see all available global options) - // (TMVA::gConfig().GetVariablePlotting()).fTimesRMS = 8.0; - // (TMVA::gConfig().GetIONames()).fWeightFileDir = "myWeightDirectory"; - - // Define the input variables that shall be used for the TMVA training - // note that you may also use variable expressions, such as: "3*var1/var2*abs(var3)" - // [all types of expressions that can also be parsed by TTree::Draw( "expression" )] - - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change/add variables if needed - //@@@ the variable name are the one you use in GenerateRootFile.cxx - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - factory->AddVariable( "U8" , "U 238 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "U5" , "U 235 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu8" , "Pu 238 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu9" , "Pu 239 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu10" , "Pu 240 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu11" , "Pu 241 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu12" , "Pu 242 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Am1" , "Am 241 " , "FractionIsotopic", 'F' ); - - - // You can add so-called "Spectator variables", which are not used in the MVA training, - // but will appear in the final "TestTree" produced by TMVA. This TestTree will contain the - // input variables, the response values of all trained MVAs, and the spectator variables - //factory->AddSpectator( "spec1:=var1*2", "Spectator 1", "units", 'F' ); - //factory->AddSpectator( "spec2:=var1*3", "Spectator 2", "units", 'F' ); - // Add the variable carrying the regression target + #include "_tmp/include_Train/InputVariables.cxx" + // Add the variable carrying the regression target factory->AddTarget(TargetName); // It is also possible to declare additional targets for multi-dimensional regression, ie: @@ -103,7 +65,7 @@ int main(int argc, char const *argv[]) // Read training and test data (see TMVAClassification for reading ASCII files) // load the signal and background event samples from ROOT trees TFile *input(0); - TString fname = argv[1]; //Training Data input file + TString fname = "_tmp/include_Train/TrainingInput.root"; //Training Data input file if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists @@ -130,6 +92,14 @@ int main(int argc, char const *argv[]) // Apply additional cuts on the signal and background samples (can be different) TCut mycut = ""; // for example: TCut mycut = "abs(var1)<0.5 && abs(var2-0.5)<1"; + Long64_t NEvents = regTree->GetEntries(); + Long64_t NTraining = PropTraining * NEvents ; + Long64_t NTesting = NEvents - NTraining ; + + std::stringstream Samples_Parameters ; + Samples_Parameters << "nTrain_Regression=" << NTraining <<":"<< "nTest_Regression=" << NTesting <<":SplitMode=Random:NormMode=NumEvents:!V"; + + // tell the factory to use all remaining events in the trees after training for testing: factory->PrepareTrainingAndTestTree( mycut, "nTrain_Regression=0:nTest_Regression=0:SplitMode=Random:NormMode=NumEvents:!V" ); @@ -139,12 +109,17 @@ int main(int argc, char const *argv[]) // ---- Book MVA methods // + TString NType = "sigmoid"; + TString Arch = "18,21,9"; + TString Sampl = "0.5"; + TString LearRate = "0.1"; + + TString ParamNN = "!H:V:VarTransform=Norm:NeuronType=" + NType + ":NCycles=16000:HiddenLayers=" + Arch + ":TestRate=6:TrainingMethod=BFGS:LearningRate=" + LearRate + ":Sampling=" + Sampl + ":SamplingEpoch=0.8:ConvergenceImprove=1e-6:ConvergenceTests=15:!UseRegulator"; + std::stringstream Name; - Name<<"MLP_"<<TargetName; + Name<<"MLP_"<<TargetName; // Neural network (MLP) - factory->BookMethod( TMVA::Types::kMLP, Name.str().c_str(), "!H:V:VarTransform=Norm:NeuronType=tanh:NCycles=16000:HiddenLayers=8,:TestRate=6:TrainingMethod=BFGS:Sampling=0.3:SamplingEpoch=0.8:ConvergenceImprove=1e-6:ConvergenceTests=15:!UseRegulator" ); - - + factory->BookMethod( TMVA::Types::kMLP, Name.str().c_str(), ParamNN ); // -------------------------------------------------------------------------------------------------- // ---- Now you can tell the factory to train, test, and evaluate the MVAs @@ -168,10 +143,9 @@ int main(int argc, char const *argv[]) delete factory; - // Launch the GUI for the root macros -if (!gROOT->IsBatch()) TMVARegGui( outfileName ); + } /* -g++ -o Train_MLP `root-config --cflags` Train_MLP.cxx `root-config --glibs` -lTMVA -I$ROOTSYS/tmva/test/ +g++ -o Train `root-config --cflags` Train.cxx `root-config --glibs` -lTMVA -I$ROOTSYS/tmva/test/ */ \ No newline at end of file diff --git a/Utils/EQM/FBR_MLP_Keff/include/GenerateRootFile.hxx b/Utils/EQM/FBR_MLP_Keff/include/GenerateRootFile.hxx deleted file mode 100755 index ef7b9ff21a601531e0a8d45eb81c8e60aee3fd70..0000000000000000000000000000000000000000 --- a/Utils/EQM/FBR_MLP_Keff/include/GenerateRootFile.hxx +++ /dev/null @@ -1,51 +0,0 @@ -#include "ZAI.hxx" -#include <TGraph.h> -#include <TGraph.h> - -#include <vector> -#include <stdio.h> -#include <stdlib.h> -#include <iostream> -#include <fstream> -#include <sstream> -#include <string> -#include <vector> -#include <sstream> -#include <cmath> -#include <map> -#include <iostream> -#include <iomanip> -using namespace std; - -string dtoa(double num) -{ - ostringstream os(ostringstream::out); - os<<setprecision(3)<<num; - return os.str(); -} - -string FilePath; -string DataPath; - -map<ZAI, double> ZAImass; -vector<string> JobName; -vector<string> GoodJobName; - -vector<double> fTime; //Time vector of the depletion calculation (second) -vector< vector<double> > fkeff; - -vector<ZAI> fAllNuclei; //All the nuclei present in the fuel - - -vector<IsotopicVector> fActinideCompoInit; //Fresh fuel composition - -int fNOfTimeStep=0; //number of time step in the Evolution - -string fEvolutionDataFolder = ""; - -bool fIsAllNucleiAlreadyFill=false; - -void InitMass(); -void CheckJob(); -void ReadAndFill(string jobname); -void DumpInputNeuron(string filename); \ No newline at end of file diff --git a/Utils/EQM/FBR_MLP_Keff/include/Generate_FBR_Keff.hxx b/Utils/EQM/FBR_MLP_Keff/include/Generate_FBR_Keff.hxx new file mode 100644 index 0000000000000000000000000000000000000000..70bef22f8a6e2d3868a8b9622fe5fe65b38274b4 --- /dev/null +++ b/Utils/EQM/FBR_MLP_Keff/include/Generate_FBR_Keff.hxx @@ -0,0 +1,76 @@ +#include "ZAI.hxx" +#include <TGraph.h> +#include <TGraph.h> + +#include <vector> +#include <stdio.h> +#include <stdlib.h> +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +#include <sstream> +#include <cmath> +#include <map> +#include <iostream> +#include <iomanip> + +using namespace std; + +string dtoa(double num) +{ + ostringstream os(ostringstream::out); + os<<setprecision(3)<<num; + return os.str(); +} + +string FilePath; +string DataPath; + +vector<string> JobName; +vector<string> GoodJobName; + +vector< vector<double> > fTime; //Time vector of each depletion calculation (second) +vector<ZAI> fAllNuclei; //All the nuclei present in the fuel + +vector< vector<double> > fkeff; //Keff evolution of all Evolution Datas +int fKeffStep; // Time step to predict Keff + +vector<IsotopicVector> fActinideCompoInit; //Fresh fuel composition in atomic prop. + +vector<double> fHMMass; //Vector of initial Heavy metal mass (every element should be egual or very very close !!) + +vector<int> fNOfTimeStep; //number of time step in each Evolution data + +string fEvolutionDataFolder = ""; + +map<ZAI,string> fMapName; // List of ZAI and their name to consider for model parametrization (must of the time Fuel composition @ t=0) + +string fReactorType,fFuelType; + +vector <ZAIStreamList> fStreamList; // Fisisle or Fertile and default proportions for all nuclei in fresh fuel + +bool fIsAllNucleiAlreadyFill=false; + +void CheckJob(); +void ReadAndFill(string jobname); +void DumpForTestingNeuron(string filename); +void DumpInputNeuron(string filename); +void FillMapName(); +bool UserSayYes(); +string CreateInfoFile(); +void ReadInfo(string InfoDBFile,string &ReactorType,string &FuelType,double &Power); +void ProgressBar(double loopindex, double totalindex); +vector<double> GetAllCompoOf(ZAI zai); + +bool is_file_exist(const char *fileName); +void CompileTraining(); +void FissileOrFertileList(int Z,int A,int I); +/* PRINT INFO */ +void Generate_tmva_factory_input(double ProportionOfTraining); +bool TrainingHasSucceed(); +void GetUserValue(int &Value); +void GetUserValue(double &Value); +void GetUserValue(string &Value); + + diff --git a/Utils/EQM/FBR_MLP_Keff/include/StringLine.hxx b/Utils/EQM/FBR_MLP_Keff/include/StringLine.hxx deleted file mode 100755 index da8500370b840d6abebf1360b3593151b6dab9d7..0000000000000000000000000000000000000000 --- a/Utils/EQM/FBR_MLP_Keff/include/StringLine.hxx +++ /dev/null @@ -1,275 +0,0 @@ -#ifndef _STRINGLINE_ -#define _STRINGLINE_ - -#include <string> -#include <sstream> -#include <iostream> -#include <algorithm> -#include <cctype> -using namespace std; -/*! - \file - \brief Header file for StingLine class. -*/ - -// Class extracting fields from a string / line. -/*! - The aim of this class is to provide tools to extract fields ("word") from - a string and convert a string in Upper/Lower case. - All methods are static so that it is not necessary to create object to use them - - example: - \code - string line="The temperature is : 300.6 K"; - int start; - - 1st method: creation of StringLine - - start=0; - StringLine SL; - string the=SL.NextWord(line,start); - string temperature_is=SL.NextWord(line,start,':'); - string colon=SL.NextWord(line,start); - double T=atof(SL.NextWord(line,start).c_str()); - cout<<the<<endl<<temperature_is<<endl<<T<<endl; - - 2nd method: "using" the static methods - - start=0; - the=StringLine::NextWord(line,start); - temperature_is=StringLine::NextWord(line,start,':'); - colon=StringLine::NextWord(line,start); - T=atof(StringLine::NextWord(line,start).c_str()); - cout<<the<<endl<<temperature_is<<endl<<T<<endl; - \endcode - @author PTO - @version 0.1 -*/ - -class StringLine -{ - public: - // Find the next word in a line. - /*! - Find Next word in a line starting from position "start" in the line. If an alternative - separator is given, the word length is defined by the first position of sep or alt_sep found. - The first value of start is in general 0 (i.e. the beginning of the Line) - \param Line : a line containing words - \param start : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static string NextWord(string Line,int &start,char sep=' ', char alt_sep='\0'); - // Find the previous word in a line. - /*! - Find Previous word in a line starting from position "start" in the line. If an alternative - separator is given, the word length is defined by the first position of sep or alt_sep found. - The first value of start is in general the end of the Line. - \param Line : a line containing words - \param start : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static string PreviousWord(string Line,int &start,char sep=' ', char alt_sep='\0'); - static void ToLower(string &Line); // convert a string to Lower case - static void ToUpper(string &Line); // convert a string to Upper case - - // Find \p search in \p Line from the begining. - /*! - returns the position, starting from the begenning of the first occurence - of \p search in \p Line if it is found, else returns -1 - \param search : a string to find - \param Line : where to search - */ - static int Find(const char *search,string Line); - // Find \p search in \p Line from the end. - /*! - returns the position, starting from the end of the first occurence - of \p search in \p Line if it is found, else returns -1 - \param search : a string to find - \param Line : where to search - */ - static int rFind(const char *search,string Line); - // convert a input type (\p in_T) to another (\p out_T). - /*! - Example: - \code - string s="32.12"; - double t=StringLine::convert<double>(s); - string temperature=StringLine::convert<string>(300.); - \endcode - \param t : the input value - */ - template <class out_T, class in_T> static out_T convert(const in_T & t); - // Find the start of a word in a line. - /*! - \param Line : a line containing words - \param CurrentPosition : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static int GetStartWord(string Line,int CurrentPosition,char sep=' ', char alt_sep='\0'); - // Find the end of a word in a line. - /*! - \param Line : a line containing words - \param CurrentPosition : from where to start to find the end of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static int GetEndWord(string Line,int CurrentPosition,char sep=' ', char alt_sep='\0'); - // Replace a sub-string by an other in a string. - /*! - \param InLine : the string which contains the sub-string to replace - \param ToReplace : the sub-string to replace - \param By : the sub-string ToReplace is replaced by the sub-string By in Inline - */ - string ReplaceAll(string InLine, string ToReplace, string By); -}; - - -//_________________________________________________________________________________ -inline string StringLine::NextWord(string Line,int &start,char sep, char alt_sep) -{ - string Word=""; - if(start>=int(Line.size())) - { - return Word; - } - start=GetStartWord(Line,start,sep,alt_sep); - int wordlength=GetEndWord(Line,start,sep,alt_sep)-start; - - Word=Line.substr(start,wordlength); - - start+=wordlength; - return Word; -} -//_________________________________________________________________________________ -inline string StringLine::PreviousWord(string Line,int &start,char sep, char alt_sep) -{ - string Word=""; - if(start<=0) - { - return Word; - } - int pos=Line.rfind(sep,start); - int alt_pos=-1; - int real_pos=pos; - char real_sep=sep; - if(alt_sep!='\0') - { - alt_pos=Line.rfind(alt_sep,start); - real_pos=max(pos,alt_pos); - if(real_pos!=pos) - real_sep=alt_sep; - } - int wordlength=start-Line.rfind(real_sep,real_pos); - if(real_pos<=0) - { - Word=Line.substr(0,start+1); - start=0; - return Word; - } - Word=Line.substr(real_pos+1,wordlength); - - start-=wordlength+1; - return Word; -} - -//_________________________________________________________________________________ -inline void StringLine::ToLower(string &Line) -{ - transform (Line.begin(), Line.end(), // source - Line.begin(), // destination - (int(*)(int))tolower); // operation -} - -//_________________________________________________________________________________ -inline void StringLine::ToUpper(string &Line) -{ - transform (Line.begin(), Line.end(), // source - Line.begin(), // destination - (int(*)(int))toupper); // operation -} - -//_________________________________________________________________________________ -inline int StringLine::GetStartWord(string Line,int CurrentPosition,char sep, char alt_sep) -{ - int pos=Line.find(sep,CurrentPosition); - int alt_pos=-1; - if(alt_sep!='\0') - alt_pos=Line.find(alt_sep,CurrentPosition); - int real_pos=pos; - char real_sep=sep; - if(alt_pos>=0) - { - real_pos=min(pos,alt_pos); - if(pos==int(string::npos))real_pos=alt_pos; - if(real_pos!=pos) - real_sep=alt_sep; - } - if(real_pos==int(string::npos)) return CurrentPosition; - while(CurrentPosition<int(Line.size()) && Line[CurrentPosition]==real_sep) - CurrentPosition++; - return CurrentPosition; -} - -//_________________________________________________________________________________ -inline int StringLine::GetEndWord(string Line,int CurrentPosition,char sep, char alt_sep) -{ - int pos=Line.find(sep,CurrentPosition); - int alt_pos=-1; - if(alt_sep!='\0') - alt_pos=Line.find(alt_sep,CurrentPosition); - int real_pos=pos; - if(alt_pos>=0) - { - real_pos=min(pos,alt_pos); - if(pos==int(string::npos))real_pos=alt_pos; - } - if(real_pos==int(string::npos)) - return Line.size(); - return real_pos; -} - -//_________________________________________________________________________________ -inline int StringLine::Find(const char *search,string Line) -{ - size_t Pos=Line.find(search); - if(Pos != string::npos ) return Pos; - return -1; -} - -//_________________________________________________________________________________ -inline int StringLine::rFind(const char *search,string Line) -{ - size_t Pos=Line.rfind(search); - if(Pos != string::npos) return Pos; - return -1; -} - -//_________________________________________________________________________________ -template <class out_T, class in_T> -inline out_T StringLine::convert(const in_T & t) -{ - stringstream stream; - stream << t; // insert value to stream - out_T result; // store conversion's result here - stream >> result; // write value to result - return result; -} - -//_________________________________________________________________________________ -inline string StringLine::ReplaceAll(string InLine, string ToReplace, string By) -{ - int start=0; - int pos=InLine.find(ToReplace,start); - while(pos!=int(string::npos)) - { - InLine.replace(pos,ToReplace.size(),By); - start=0; - pos=InLine.find(ToReplace,start); - } - return InLine; - -} -#endif diff --git a/Utils/EQM/FBR_MLP_Keff/include/ZAI.hxx b/Utils/EQM/FBR_MLP_Keff/include/ZAI.hxx old mode 100755 new mode 100644 index 1ee9136f9231fdadd328a009579e46ea9d6d6c6b..68f0f25d7210d1e92286c596cfed31f8df01c7dd --- a/Utils/EQM/FBR_MLP_Keff/include/ZAI.hxx +++ b/Utils/EQM/FBR_MLP_Keff/include/ZAI.hxx @@ -2,6 +2,10 @@ #define MN_ZAI_H_ #include <map> +#include <vector> +#include <fstream> +#include <iostream> + using namespace std; class ZAI { @@ -12,6 +16,7 @@ class ZAI { ZAI(int z, int a, int i=0) { Z=z;A=a; I=i;} + ZAI(){;} bool operator <(const ZAI& zai) const {return (Z != zai.Z)? (Z < zai.Z) : ( (A != zai.A)? @@ -35,8 +40,103 @@ class IsotopicVector { else return 0; } + vector<ZAI> GetNonZeroZAIList() + { + vector<ZAI> vZAI; + map<ZAI,double>::iterator it; + for(it = IVquantity.begin(); it != IVquantity.end(); ++it) + { if(it->second != 0 ) + vZAI.push_back(it->first); + } + return vZAI; + } + map<ZAI,double> IVquantity; - double MASS; + }; + +class ZAIMass +{ + public: + ZAIMass() + { + string CLASSPATH = getenv("CLASS_PATH"); + string MassDataFile = CLASSPATH + "/data/Mass.dat"; + + ifstream infile(MassDataFile.c_str()); + + if(!infile.good()) + { + std::cout << " ZAIMass Error.\n can't find/open file " << MassDataFile << std::endl; + exit(1); + } + + int Z,A; + string Name; + double MassUnity,MassDec,error; + while (infile>>Z>>A>>Name>>MassUnity>>MassDec>>error) + { + double Masse = MassUnity + MassDec * 1e-6; + fZAIMass.insert( pair< ZAI,double >( ZAI(Z,A,0), Masse ) ); + } + + infile.close(); + } + ~ZAIMass() + { + fZAIMass.clear(); + } + + double GetMass(ZAI zai ) //!< get with ZAI + { + map<ZAI,double>::iterator MassIT = fZAIMass.find( ZAI(zai.Z, zai.A, 0) ); + + if(MassIT == fZAIMass.end()) + return zai.A; + else + return MassIT->second; + + } + + double GetMass(IsotopicVector & IV) //return Mass of IV [t] + { + double AVOGADRO = 6.02214129e23; + double TotalMass = 0; + + for( map<ZAI,double>::iterator it = IV.IVquantity.begin(); it != IV.IVquantity.end(); it++) + { + TotalMass += it->second/AVOGADRO * GetMass( it->first ) ; + } + + return TotalMass*1e-6; + } + + + private: + map<ZAI, double> fZAIMass; //! ZAI mass list + +}; + +class ZAIStreamList { + public : + + ZAI fZAI; + string fListName; + double fDefaultProportion; + + ZAIStreamList(int Z, int A, int I, string ListName, double DefaultProportion ) + { + fZAI = ZAI(Z,A,I); + fListName = ListName; + fDefaultProportion = DefaultProportion; + } ///< Normal Constructor. + ~ZAIStreamList() {}; ///< Normal Destructor. + + +}; + + + + #endif //MN_ZAI_H_ diff --git a/Utils/EQM/MLP_Kinf/GenerateRootFile.cxx b/Utils/EQM/MLP_Kinf/GenerateRootFile.cxx deleted file mode 100755 index 8bd2d961c870be380bb5717a97051a0eb497f01f..0000000000000000000000000000000000000000 --- a/Utils/EQM/MLP_Kinf/GenerateRootFile.cxx +++ /dev/null @@ -1,343 +0,0 @@ -/**********************************************************/ -// Make the input file for the MLPs training -// -// This programs reads a set of .dat files which are the -// results of a depletion calculation (see manual and -// looks for XS_CLOSEST). From the reading it fills a -// TTree (Data) and write it in a file named -// TrainingInput.root . -// The file TrainingInput.cxx is the list of MLP outputs -// (cross sections) -// -//@author BaM, BaL -/**********************************************************/ -#include "include/GenerateRootFile.hxx" -#include <TH1F.h> -#include <TH2D.h> -#include <TFile.h> -#include <TTree.h> -#include "include/StringLine.hxx" -#include <TString.h> -#include <string> -#include <cmath> -#include <iostream> -#include <fstream> -#include <algorithm> -#include <map> -#include <sstream> - -using namespace std; -//-------------------------------------------------------------------------------------------------- -/************************* - MAIN -*************************/ -int main(int argc, char ** argv){ - - if(argc!=2) - { - cout << "Usage : BuildInputTree Path" << endl; - cout << " Where Path is the path to the folder containing the Evolution Datas" << endl; - cout << " i.e the (.dat) files" << endl; - exit(0); - } - - fEvolutionDataFolder = argv[1]; - - InitMass(); //Load nuclei masses - CheckJob(); // looks fot the .dat files in the fEvolutionDataFolder - - FilePath = "DB_TMP/"; - DataPath = FilePath + "Data/"; - string Command = "mkdir -p " + DataPath; - system(Command.c_str()); - - cout << "Reading .dat files ..." << endl; - for(int i = 0; i < (int)JobName.size(); i++) - { - ReadAndFill(JobName[i]); - if (i%100 == 0) - cout << "\r" << i << " .dat files read" <<flush; - } - cout << "Filling the TTree ..." << endl; - DumpInputNeuron("TrainingInput.root"); - cout << "Training input generated in file : TrainingInput.root " << endl; - cout << "Names of MLP outputs in file : TrainingInput.cxx " << endl; - system("rm -r DB_TMP"); - -} -//-------------------------------------------------------------------------------------------------- -// Function definitions -//-------------------------------------------------------------------------------------------------- -//Convert int to string -string itoa(int num) -{ - ostringstream os(ostringstream::out); - os << num; - return os.str(); -} -//-------------------------------------------------------------------------------------------------- -void DumpInputNeuron(string filename) -{ - TFile* fOutFile = new TFile(filename.c_str(),"RECREATE"); - TTree* fOutT = new TTree("Data", "Data"); - -/**********************INITIALISATIONNN********************/ - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the input value according to your fresh fuel compo - //-> here MOX FUEL - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - double U5 = 0; - double U8 = 0; - double Pu8 = 0; - double Pu9 = 0; - double Pu10 = 0; - double Pu11 = 0; - double Pu12 = 0; - double Am1 = 0; - - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - double Time = 0; - double k_inf = 0; - - -/**********************BRANCHING**************************************************/ -/**********************Fresh fuel**************************************************/ - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the input value according to your fresh fuel compo - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - fOutT->Branch( "U5" ,&U5 ,"U5/D" ); - fOutT->Branch( "U8" ,&U8 ,"U8/D" ); - fOutT->Branch( "Pu8" ,&Pu8 ,"Pu8/D" ); - fOutT->Branch( "Pu9" ,&Pu9 ,"Pu9/D" ); - fOutT->Branch( "Pu10" ,&Pu10 ,"Pu10/D" ); - fOutT->Branch( "Pu11" ,&Pu11 ,"Pu11/D" ); - fOutT->Branch( "Pu12" ,&Pu12 ,"Pu12/D" ); - fOutT->Branch( "Am1" ,&Am1 ,"Am1/D" ); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - fOutT->Branch( "Time" ,&Time ,"Time/D" ); - fOutT->Branch( "k_inf" ,&k_inf ,"k_inf/D" ); - -/**********************FILLING THE TTREE**************************************************/ - - //Fill containing all the output of the networks to train - - int NumOfBase=fActinideCompoInit.size(); - for(int b=0;b<NumOfBase;b++) - { - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the input value according to your fresh fuel compo - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - // (Z , A ,I) - U5 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(92,235,0)); - U8 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(92,238,0)); - Pu8 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,238,0)); - Pu9 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,239,0)); - Pu10 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,240,0)); - Pu11 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,241,0)); - Pu12 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,242,0)); - Am1 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(95,241,0)); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - for(int Tstep=0 ;Tstep<fNOfTimeStep;Tstep++ ) - { - Time=fTime[Tstep]; - k_inf=fkeff[b][Tstep]; - fOutT->Fill(); - } - } - - fOutFile->Write(); - delete fOutT; - fOutFile-> Close(); - delete fOutFile; - -} -//-------------------------------------------------------------------------------------------------- -void InitMass() -{ -//Set tghe mass of the nuceli - -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// -//@@@Change : ADD THE MASS OF THE NUCLEI PRESENT IN YOUR FRESH FUEL -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - - ZAI U238 = ZAI(92,238,0); - ZAImass.insert(pair<ZAI,double>(U238, 238050788.247e-6)); - - ZAI U234 = ZAI(92,234,0); - ZAImass.insert(pair<ZAI,double>(U234, 234041000.000e-6)); - - ZAI U235 = ZAI(92,235,0); - ZAImass.insert(pair<ZAI,double>(U235, 235043929.918e-6)); - - ZAI Pu238 = ZAI(94,238,0); - ZAImass.insert(pair<ZAI,double>(Pu238,238049559.894e-6)); - - ZAI Pu239 = ZAI(94,239,0); - ZAImass.insert(pair<ZAI,double>(Pu239,239052163.381e-6)); - - ZAI Pu240 = ZAI(94,240,0); - ZAImass.insert(pair<ZAI,double>(Pu240,240053813.545e-6)); - - ZAI Pu241 = ZAI(94,241,0); - ZAImass.insert(pair<ZAI,double>(Pu241,241056851.456e-6)); - - ZAI Pu242 = ZAI(94,242,0); - ZAImass.insert(pair<ZAI,double>(Pu242,242058742.611e-6)); - - ZAI Am241 = ZAI(95,241,0); - ZAImass.insert(pair<ZAI,double>(Am241,241056829.144e-6)); - - ZAI O16 = ZAI(8,16,0); - ZAImass.insert(pair<ZAI,double>(O16, 0.)); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - -} -//-------------------------------------------------------------------------------------------------- -void CheckJob() -{ //LOAD THE LIST OF EvolutionData - cout << "Scanning " << fEvolutionDataFolder << " for .dat files ..." << endl; - cout << "Please wait ..."<< endl; - - string Command = "find "+ fEvolutionDataFolder + " -name \"*.dat\" > JOB.tmp"; - system(Command.c_str()); - - ifstream JOB("JOB.tmp"); - if (JOB.is_open()) - { - while (!JOB.eof()) - { - string tmp; - getline(JOB,tmp); - JobName.push_back(tmp); - } - } JOB.close(); JobName.pop_back(); - - // Remove temporary files... - Command = "\\rm -f JOB.tmp"; - system(Command.c_str()); - random_shuffle(JobName.begin(), JobName.end()); - cout << "Scan complete" <<endl; -} - -//-------------------------------------------------------------------------------------------------- -void ReadAndFill(string jobname) -{ //Read a .dat file and fill XS maps and the fuel initial composition -//Read a .dat file and fill XS maps and the fuel initial composition - - vector<double> vT; - vector<int> Z; - vector<int> A; - vector<int> I; - vector<double> Q; - - ifstream DecayDB(jobname.c_str()); // Open the File - if(!DecayDB) - { - cout << "!!Warning!! !!!EvolutiveProduct!!! \n Can't open \"" << jobname << "\"\n" << endl; - } - - string line; - int start = 0; - - getline(DecayDB, line); - - /******Getting Time vecotr ....******/ - if( StringLine::NextWord(line, start, ' ') != "time") - { - cout << "!!Bad Trouble!! !!!EvolutiveProduct!!! Bad Database file : " << jobname << endl; - exit (1); - } - - while(start < (int)line.size()) - vT.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); - - fNOfTimeStep=int(vT.size()); - - - start = 0; - getline(DecayDB, line); - string tmp = StringLine::NextWord(line, start, ' '); - vector<double> vKeff; - if ( tmp == "keff" || tmp == "Keff" ) - { - while(start < (int)line.size()) - vKeff.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); - } - fkeff.push_back(vKeff); - - - /****Getting Inventories***/ - getline(DecayDB, line); - do - { - start = 0; - int z; - string tmp2 = StringLine::NextWord(line, start, ' '); - if (tmp2 == "Inv") { - z = atoi(StringLine::NextWord(line, start, ' ').c_str()); - } - else z = atoi(tmp2.c_str()); - int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); - - if(a!=0 && z!=0) - { - - ZAI zaitmp(z, a, i); - Z.push_back(z); - A.push_back(a); - I.push_back(i); - if(!fIsAllNucleiAlreadyFill) - { - fAllNuclei.push_back(zaitmp); - fTime=vT; - } - - long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); - Q.push_back(q); - - } - - getline(DecayDB, line); - start = 0; - tmp2 = StringLine::NextWord(line, start, ' '); - - if(line == "" || line == "CrossSection" || tmp2 == "XSFis" || tmp2 == "XSCap" || tmp2 == "XSn2n") break; - }while (!DecayDB.eof() ); - - if(fAllNuclei.size()!=0) - fIsAllNucleiAlreadyFill=true; - - DecayDB.close(); - - double N = 0; - for(int i=0; i < (int)Z.size()-2; i++) - { - if( Z[i]>89 ) - N += Q[i]; - } - - - IsotopicVector CompoBasei; - - for(int i=0; i < (int)Z.size()-2; i++) - { - if(Z[i]>89) - { - ZAI zai = ZAI(Z[i], A[i], I[i]); - CompoBasei.IVquantity.insert(pair<ZAI,double>(zai,Q[i]/N)); - } - } - - fActinideCompoInit.push_back(CompoBasei); - -GoodJobName.push_back(jobname); - - -} -/*------------------------------------------------------------------------------------------------- -COMPILATION : - -g++ -o GenerateRootFile GenerateRootFile.cxx `root-config --cflags` `root-config --libs` - -*/ \ No newline at end of file diff --git a/Utils/EQM/MLP_Kinf/Generate_MLP_Kinf.cxx b/Utils/EQM/MLP_Kinf/Generate_MLP_Kinf.cxx new file mode 100644 index 0000000000000000000000000000000000000000..07fd9b4cda7fc386019546f47045196e0045ded2 --- /dev/null +++ b/Utils/EQM/MLP_Kinf/Generate_MLP_Kinf.cxx @@ -0,0 +1,908 @@ +/**********************************************************/ +// Make the input file for the MLPs training +// +// This programs reads a set of .dat files which are the +// results of a depletion calculation (see manual and +// looks for XS_CLOSEST). From the reading it fills a +// TTree (Data) and write it in a file named +// TrainingInput.root . +// OUTPUTS : +// 1- File TrainingInput.cxx is the list of MLP outputs +// (cross sections) +// 2- File TrainingInput.root input datas (as a Root TTREE) for MLP training +// 3- File Data_Base_Info.nfo Information file to be red by XSM_MLP +// (to be place in the weight folder which is build by MLP training) +// +//@author BaM, BaL +/**********************************************************/ +#include "include/Generate_MLP_Kinf.hxx" +#include <TH1F.h> +#include <TH2D.h> +#include <TFile.h> +#include <TTree.h> +#include "../../../source/external/StringLine.hxx" +#include <TString.h> +#include <string> +#include <cmath> +#include <math.h> +#include <iostream> +#include <fstream> +#include <algorithm> +#include <map> +#include <sstream> +#include <numeric> +#include <functional> +#include <algorithm> +#include <ctime> + +using namespace std; + +ZAIMass cZAIMass; //atomic masses + +string ElNames[110]={" ","H","He","Li","Be", + "B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar", + "K","Ca","Sc","Ti","V ","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge", + "As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd", + "Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd", + "Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W", + "Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra", + "Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No", + "Lr","Rf","Db","Sg","Bh","Hs","Mt"}; + +//-------------------------------------------------------------------------------------------------- +/************************* + MAIN +*************************/ +int main(int argc, char ** argv) +{ + + if(argc!=2) + { + cout << "Usage : Generate_MLP_Kinf Path" << endl; + cout << " Where Path is the path to the folder containing Evolution Datas" << endl; + cout << " i.e the (.dat) files" << endl; + exit(0); + } + + /*****************Preparation of working folders*************************/ + if(is_file_exist("Training_output_k_inf.root" )) + { + cout<< "\033[33m Trainining_output* detected. Delete these files and weights folder ? [y/n]\033[0m"<< endl; + if(UserSayYes()) + system( "rm -rf Training_output* weights" ); + else + { cout << "Move this files elsewhere and run this program again"<< endl; + exit(0); + } + } + + if(is_file_exist("_tmp/include_Train/TrainingInput.root" )) + system( "rm -rf _tmp" ); + + system("mkdir -p _tmp/include_Train"); + /**********************************************************************/ + + fEvolutionDataFolder = argv[1]; + CheckJob(); // looks fot the .dat files in the fEvolutionDataFolder + + cout << endl; + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ Load your EvolutionDatas to R.A.M │" << endl; + cout << "╰───────────────────────────────────────────────╯" << endl; + cout<< endl; + for(int i = 0; i < (int)JobName.size(); i++) + { + ReadAndFill(JobName[i]); + ProgressBar(i,JobName.size()); + } + ProgressBar(1,1); + + FillMapName(); + + cout << "Proportion of data to be used for training ? ]0-100[" << endl; + double ProportionOfTraining = 0 ; + + GetUserValue( ProportionOfTraining); + DumpInputNeuron("_tmp/include_Train/TrainingInput.root"); + Generate_tmva_factory_input(ProportionOfTraining); + + string ModelName = CreateInfoFile(); + + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ GENERATED FILES: │" << endl; + cout << "├─────────────────────────────────────────────────────────────────────┤" << endl; + cout << "│#1 Input for TMVA training: \033[36m_tmp/include_Train/TrainingInput.root\033[0m │" << endl; + cout << "│#3 Model Information for CLASS: \033[36m"+ ModelName +".nfo\033[0m │" << endl; + cout << "╰─────────────────────────────────────────────────────────────────────╯" << endl; + cout << endl; + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ NEXT STEPS: │" << endl; + cout << "├────────────────────────────────────────────────┤" << endl; + cout << "│1. Train your MLPs with \033[36mTrain.cxx\033[0m │" << endl; + cout << "│2. Test MLPs performances using informations in:│" << endl; + cout << "│ \033[36mUtils/XSM/MLP/Test/EvaluateTrainingCommands.dat\033[0m│" << endl; + cout << "│3. Put the file #3 in \033[36mweights\033[0m folder then │" << endl; + cout << "│ move this folder to $CLASS_PATH/DATA_BASES"<<fReactorType<<"/"<<fFuelType << "/EQModel/ChooseAName │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + cout << endl; + cout << "=> Doing the first step for you. Do you want to train the MLP on your local machine ? [y/n]" << endl; + + if(UserSayYes()) + { + CompileTraining(); + cout << "Let's train locally ? [y/n]" << endl; + if(UserSayYes()) + system("./train"); + else + { + cout << "You can run it latter with ./Train" << endl; + exit(0); + } + } + + + + +} + +//-------------------------------------------------------------------------------------------------- +void GetUserValue(int &Value) +{ + string sValue ; + std::getline(std::cin, sValue); + + if(StringLine::IsDouble(sValue)) + { + double dValue = atof(sValue.c_str()); + double iValue = floor(dValue); + + if( dValue != iValue ) + { + cout << "It must be an INTEGER" << endl; + GetUserValue(Value); + + } + else + Value = iValue; + } + + else + { + cout << "It must be an INTEGER" << endl; + GetUserValue(Value); + } + +} +void GetUserValue(double &Value) +{ + string sValue ; + std::getline(std::cin, sValue); + + if(StringLine::IsDouble(sValue)) + Value = atof(sValue.c_str()); + else + { + cout << "It must be a DOUBLE" << endl; + GetUserValue(Value); + } +} +void GetUserValue(string &Value) +{ + std::getline(std::cin, Value); +} +//-------------------------------------------------------------------------------------------------- +bool is_file_exist(const char *fileName) +{ + std::ifstream infile(fileName); + return infile.good(); +} +//-------------------------------------------------------------------------------------------------- +void CompileTraining() +{ + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ COMPLILING TMVA TRAINING PROGRAM │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + if(is_file_exist("Train")) + system("rm Train"); + + string CMD = "g++ -o Train `root-config --cflags` Train.cxx `root-config --glibs` -lTMVA"; + cout << CMD << endl; + system(CMD.c_str()); + + if(!is_file_exist("Train")) + { + cout <<"\033[31m COMPILATION FAILED !!! May be not the good compilator name nor the good path of file to compile ? \033[0m " << endl; + exit(1); + } + else + cout <<"\t \033[32m Done \033[0m " << endl; + + +} + +//-------------------------------------------------------------------------------------------------- +//Convert int to string +string itoa(int num) +{ + ostringstream os(ostringstream::out); + os << num; + return os.str(); +} +//-------------------------------------------------------------------------------------------------- +//Give a name to a cross section +//!!!!!!!!!!!!!!!!!!!!!!!!!!// +// YOU MUST KEEP THE FORMAT : +// XS_Z_A_I_fis (fission cross section) +// XS_Z_A_I_cap (n,gamma cross section) +// XS_Z_A_I_n2n (n,2n cross section) +//!!!!!!!!!!!!!!!!!!!!!!!!!!// +string NameXS(ZAI act,string xs) +{ + stringstream Name; + Name<<"XS_"<<act.Z<<"_"<<act.A<<"_"<<act.I<<"_"<<xs; + + return Name.str(); +} + +//-------------------------------------------------------------------------------------------------- +void FillMapName() +{ + cout<< endl; + cout<< "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<< "│ SET UP MLPs INPUT │"<< endl; + cout<< "│default : composition @ t=0 + Irradiation time │"<< endl; + cout<< "╰───────────────────────────────────────────────╯"<< endl; + cout<< endl; + + vector<ZAI> ZAI_T0 = fActinideCompoInit[0].GetNonZeroZAIList(); + + for(int zai = 0 ; zai < ZAI_T0.size() ; zai++ ) + { stringstream ssname; + int Z = ZAI_T0[zai].Z; + int A = ZAI_T0[zai].A; + int I = ZAI_T0[zai].I; + string sI=""; + if(I == 1) + sI = "m"; + else if(I == 2) + sI = "2m"; + else if(I == 3) + sI = "3m"; + + ssname<<A<<ElNames[Z]<<sI; + if(zai == 0) + cout<< "Add this nuclei with this name [y/n] ? (if you don't know type yes to all) "<< endl; + else + cout<< "Add [y/n] ? "<< endl; + + cout<< "[Z\tA\tI\tName]"<< endl; + cout<<"\033[36m"<<Z<<"\t"<<A<<"\t"<<I<<"\t"<<ssname.str()<<"\033[0m"<< endl; + if (UserSayYes()) + { + fMapName.insert(pair<ZAI,string> ( ZAI(Z,A,I) , ssname.str()) ); + FissileOrFertileList(Z,A,I); + } + } + + bool UserWantToAdd = true; + while(UserWantToAdd) + { + cout<< "Do you want to add additional nuclei [y/n] ? (if you don't know type no) "<< endl; + if(UserSayYes()) + { + int Z = 0; + int A = 0; + int I = 0; + string Name; + cout << " Z -> "; + GetUserValue( Z); + cout <<" A -> "; + GetUserValue( A); + cout <<" I -> "; + GetUserValue( I); + cout <<" Name -> "; + GetUserValue( Name); + + fMapName.insert(pair<ZAI,string> ( ZAI(Z,A,I) ,Name) ); + + FissileOrFertileList(Z,A,I); + } + + else + UserWantToAdd = false; + } + + +} + +//-------------------------------------------------------------------------------------------------- +void FissileOrFertileList(int Z,int A,int I) +{ + + cout << "Is this nuclei is considered to be a part of a fissile element ? [y/n]" << endl; + + if (UserSayYes()) + fStreamList.push_back( ZAIStreamList(Z,A,I,"Fissile",1) ); + else + { + cout<<"So it is considered as fertile\n What is the default proportion of this nucleus in the fertile vector ? [0-1] " << endl; + double Default_Proportion = 0; + GetUserValue( Default_Proportion); + fStreamList.push_back( ZAIStreamList(Z,A,I,"Fertile",Default_Proportion) ); + } + cout<< endl; +} + +//-------------------------------------------------------------------------------------------------- +void Generate_tmva_factory_input(double ProportionOfTraining) +{ + + ofstream InputNetwork("_tmp/include_Train/InputVariables.cxx"); + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + InputNetwork <<"factory->AddVariable( \"" << it->second << "\" , \"" << it->second << "\", \"IsotopicFraction\", 'F' );"<< endl; + InputNetwork <<"factory->AddVariable( \"Time\" , \"Time\" , \"seconds\", 'F' );"<< endl<< endl; + + ProportionOfTraining /=100; + InputNetwork <<"double PropTraining = "<< ProportionOfTraining <<";"<< endl; + + InputNetwork.close(); +} + +//-------------------------------------------------------------------------------------------------- +bool UserSayYes() +{ + bool AnswerIsNotGiven = true; + bool isYES = false; + while(AnswerIsNotGiven) + { + string answer; + GetUserValue( answer); + + + if(answer == "y" || answer == "yes" || answer == "Yes" || answer == "Y") + { + isYES = true; + AnswerIsNotGiven = false; + } + else if (answer == "n" || answer == "no" || answer == "No" || answer == "N") + { + isYES = false; + AnswerIsNotGiven = false; + } + + else{ + cout << "Yes OR No ? "<< endl; + } + } + return isYES; +} + +//-------------------------------------------------------------------------------------------------- +string CreateInfoFile() +{ + + /**************************************************/ + // GETTING USER INFO + /**************************************************/ + double sum = 0 ; + for (int i=0 ; i < fHMMass.size() ; i++) + sum+=fHMMass[i]; + + double MeanHMMass = sum / (double)fHMMass.size(); + string Author,Mail,XSBase,HLCut,EnergyDisc,FPYBase,SABase,Geom,AddInfo,DepCode ; + double Power = 0, FissileFirstGuess = 0 , MaxFisisle = 0; + + + int start=0; + string AnInfoFile = JobName[0]; + int pos=AnInfoFile.find(".dat",start); + AnInfoFile.replace(pos,4,".info"); + + ReadInfo(AnInfoFile,fReactorType,fFuelType,Power); + + cout<< endl; + cout<< endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<<"│ XSM_MLP .NFO FILE GENERATOR │"<< endl; + cout<<"╰───────────────────────────────────────────────╯"<< endl; + cout<<" Answer following questions "<< endl; + cout<<"-> Author(s) name(s) : "<< endl; + GetUserValue( Author); + cout<< endl; + + cout<<"-> email adress(es) : "<< endl; + GetUserValue( Mail); + cout<< endl; + + cout<<"-> Depletion code used : "<< endl; + GetUserValue( DepCode); + cout<< endl; + + cout<<"-> Cross section data base (e.g ENSDF7.1) : "<< endl; + GetUserValue( XSBase); + cout<< endl; + + cout<<"-> Fission yield data base (e.g ENSDF7.1) : "<< endl; + GetUserValue( FPYBase); + cout<< endl; + + cout<<"-> S(alpha,beta) data base (e.g ENSDF7.1) : "<< endl; + GetUserValue( SABase); + cout<< endl; + + cout<<"-> Geometry simulated (e.g Cubic Assembly with mirror boundary) : "<< endl; + GetUserValue( Geom); + cout<< endl; + + cout<<"-> Half life cut [s] (if any) : "<< endl; + GetUserValue( HLCut); + cout<< endl; + + cout<<"-> Multi group treatment (yes/no if yes give the number of groups) : "<< endl; + GetUserValue( EnergyDisc); + cout<< endl; + + cout<<"-> Additional informations : "<< endl; + GetUserValue( AddInfo); + cout<< endl; + + + cout<<"-> Reactor type (e.g PWR, FBR,...) : "<< endl; + cout<<"Found in a .info file :"<< endl; + cout<<"\033[36m"<<fReactorType<<"\033[0m"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( fReactorType); + } + cout<< endl; + + cout<<"-> Fuel type (e.g UOX, MOX,...) : "<< endl; + cout<<"Found in a .info file :"<< endl; + cout<<"\033[36m"<<fFuelType<<"\033[0m"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( fFuelType); + + } + cout<< endl; + + cout<<"-> Simulated heavy metal mass (tons) : "<< endl; + cout<< "\t According your evolution datas the AVERAGE heavy metal mass is : "<< endl; + cout<<"\033[36m"<<MeanHMMass<<"\033[0m"<<" tons"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( MeanHMMass); + } + cout<< endl; + + cout<<"-> Simulated thermal power (W) : "<< endl; + cout<<"Found in a .info file :"<< endl; + cout<<"\033[36m"<<Power<<"\033[0m"<< endl; + cout<< "Is that corect ? [y/n] "<< endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<< endl; + GetUserValue( Power); + } + cout<< endl; + + cout<<"-> First guess of fissile content in fresh fuel (for algorithm initialization): ]0-1[ "<< endl; + GetUserValue( FissileFirstGuess); + + cout<<"-> Maximal fissile content in the fresh fuel (for algorithm max range): ]0-1[ "<< endl; + GetUserValue( MaxFisisle ); + + cout<< endl; + + + /**************************************************/ + // BUILDING FILE + /**************************************************/ + stringstream ssModelName; + ssModelName << fReactorType << "_" << fFuelType << "_" << Power/(MeanHMMass*1e6) << "Wg"; + + + ofstream InfoFile( (ssModelName.str() + ".nfo").c_str()); + + InfoFile << "To be used with : EQM_PWR_MLP_Kinf.cxx " << endl; + InfoFile << "with constructor : EQM_PWR_MLP_Kinf(string TMVAWeightPath, int NumOfBatch, string InformationFile, double CriticalityThreshold)" << endl; + InfoFile <<"============================================" << endl; + InfoFile <<" Informations needed by EQM_MLP_Kinf model " << endl; + InfoFile <<"============================================" << endl; + InfoFile << endl; + InfoFile << "Reactor Type :"<< endl; + InfoFile << "K_REACTOR "<< fReactorType << endl; + InfoFile << endl; + InfoFile << "Fuel Type :"<< endl; + InfoFile << "K_FUEL "<< fFuelType << endl; + InfoFile << endl; + InfoFile << "Specific Power (W/gHM) :"<< endl; + InfoFile << "K_SPECPOWER "<< Power/(MeanHMMass*1e6) << endl; + InfoFile << endl; + + double IrrTimeMax = 0; + for(int i = 0 ; i < fTime.size() ; i++ ) + { + if (IrrTimeMax < fTime[i].back()) + IrrTimeMax = fTime[i].back(); + } + double Bu_Max = Power*1e-9 * (IrrTimeMax/3600./24.) / MeanHMMass; + InfoFile << "Maximal Burnup:"<< endl; + InfoFile << "K_MAXBURNUP "<< Bu_Max * 1.3 << endl; + cout << endl; + + InfoFile << "Maximal fissile content (algo use) :" << endl; + InfoFile << "K_MAXFISCONTENT "<< MaxFisisle << endl; + InfoFile << endl; + + + InfoFile << "Z A I Name (input MLP) :"<< endl; + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + InfoFile <<"K_ZAINAME "<<it->first.Z <<" " <<it->first.A <<" " <<it->first.I<<" " << it->second << endl ; + InfoFile << endl; + + InfoFile << "Name of stream for fabrication (fissile or fertile):" << endl; + InfoFile << "Z A I Default_Proportion" << endl; + for( int l = 0 ; l < (int) fStreamList.size() ; l++ ) + InfoFile <<"K_LIST "<<fStreamList[l].fZAI.Z <<" " << fStreamList[l].fZAI.A <<" " <<fStreamList[l].fZAI.I<<" " << fStreamList[l].fListName <<" "<< fStreamList[l].fDefaultProportion<< endl ; + InfoFile << endl; + + InfoFile << "Starting fissile content in fuel for equivalence model calculation :"<< endl; + InfoFile << "k_firstguesscontent Fissile " << FissileFirstGuess << endl; + InfoFile << "k_firstguesscontent Fertile " << 1 - FissileFirstGuess << endl; + InfoFile << endl; + + InfoFile << "Fuel range (Z A I min max) :"<< endl; + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { vector <double> AllCompoOfZAI = GetAllCompoOf(it->first); + vector <double>::iterator Min = std::min_element(AllCompoOfZAI.begin(),AllCompoOfZAI.end()); + vector <double>::iterator Max = std::max_element(AllCompoOfZAI.begin(),AllCompoOfZAI.end()); + InfoFile <<"K_ZAIL "<<it->first.Z <<" " <<it->first.A <<" " <<it->first.I<<" " << *Min << " " << *Max << endl ; + } + InfoFile << endl; + InfoFile <<"============================================" << endl; + InfoFile <<" Data base generation informations " << endl; + InfoFile <<"============================================" << endl; + InfoFile << endl; + time_t t = time(0); // get time now + struct tm * now = localtime( & t ); + InfoFile <<" Date: "<< now->tm_mday<< '/'<< (now->tm_mon + 1) << '/' <<(now->tm_year + 1900)<< endl; + InfoFile <<" Author(s): "<< Author << endl; + InfoFile <<" Author(s) contact: "<< Mail << endl; + InfoFile <<" Depletion code: "<< DepCode << endl; + InfoFile <<" Simulated geometry: "<< Geom << endl; + InfoFile <<" Nuclear data used in "<< DepCode << endl; + InfoFile <<"\tCross section library: "<< XSBase << endl; + InfoFile <<"\tFission yield library: "<< FPYBase << endl; + InfoFile <<"\tS(alpha,beta) library: "<< SABase << endl; + InfoFile <<" Half life cut [s] : "<< HLCut << endl; + InfoFile <<" Multi-group treatment: "<< EnergyDisc << endl; + InfoFile <<" Additional informations: "<< endl << AddInfo << endl; + +return ssModelName.str(); + +} +//-------------------------------------------------------------------------------------------------- +vector<double> GetAllCompoOf(ZAI zai) +{ + vector<double> AllCompoOfZAI; + + for( int b = 0 ; b < fActinideCompoInit.size() ; b++ ) + AllCompoOfZAI.push_back(fActinideCompoInit[b].GetZAIIsotopicQuantity(zai)); + +return AllCompoOfZAI; +} +//-------------------------------------------------------------------------------------------------- +void ProgressBar(double loopindex, double totalindex) +{ + // Reset the line + //for(int i = 0; i < 22; i++) + // cout << " "; + cout << flush ; + + cout << "\033[42m"; + for(int i = 0; i < (int)(loopindex/totalindex*44.0); i++) + cout << " "; + cout<<" \033[41m"; + for(int i = 44; i >= (int)(loopindex/totalindex*44.0); i--) + cout << " "; + cout<<"\033[0m"; + cout << (int)(loopindex/totalindex*100) << "%\r"; + cout << flush; + //cout << endl; +} +//-------------------------------------------------------------------------------------------------- +void ReadInfo(string InfoDBFile,string &ReactorType,string &FuelType,double &Power) +{ + ifstream InfoDB(InfoDBFile.c_str()); // Open the File + if(!InfoDB) + { + cout << "\033[31m !!ERROR!! !!!EvolutionData!!! \n Can't open \"" << InfoDBFile << "\"\033[0m \n" << endl; + } + else + { + int start = 0; + string line; + getline(InfoDB, line); + string Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "reactor") + ReactorType = StringLine::NextWord(line, start, ' '); + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "fueltype") + FuelType = StringLine::NextWord(line, start, ' '); + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "cycletime") + double cycletime = atof(StringLine::NextWord(line, start, ' ').c_str()); + + getline(InfoDB, line); // Assembly HM Mass DONT TRUST THIS ONE CALCULATED WITH A instead of real atomic mass + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "constantpower") + Power = atof(StringLine::NextWord(line, start, ' ').c_str()); + InfoDB.close(); + } + +} + + +//-------------------------------------------------------------------------------------------------- +void DumpInputNeuron(string filename) +{ + TFile* fOutFile = new TFile(filename.c_str(),"RECREATE"); + TTree* fOutT = new TTree("Data", "Data"); + + +/**********************INITIALISATIONNN********************/ + + //////////////////////////////////////////////////////// + // INIT FRESH FUEL COMPOSITION and TIME + //////////////////////////////////////////////////////// + + double *FreshCompo = new double[fMapName.size()]; + + for(int i = 0 ; i < fMapName.size() ; i++ ) + FreshCompo[i] = 0; + + //////////////////////////////////////////////////////// + double Time = 0; + double k_inf = 0; + + +/**********************BRANCHING**************************************************/ +/**********************Fresh fuel**************************************************/ + + map<ZAI,string>::iterator it; + int index = 0; + for(it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { string Name = it->second + "/D"; + fOutT->Branch( it->second.c_str() , &FreshCompo[index] , Name.c_str()); + index++; + } + + //////////////////////////////////////////////////////// + fOutT->Branch( "Time" ,&Time ,"Time/D" ); + fOutT->Branch( "k_inf" ,&k_inf ,"k_inf/D" ); + + +/**********************FILLING THE TTREE**************************************************/ + cout<< endl; + cout<< endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<<"│ FILLING TTREE │"<< endl; + cout<<"│ (building TrainingInput.root) │"<< endl; + cout<<"╰───────────────────────────────────────────────╯"<< endl; + cout<< endl; + + int NumOfBase=fActinideCompoInit.size(); + for(int b=0;b<NumOfBase;b++) + { + + ProgressBar(b,NumOfBase); + + /////////////////////////////////////////////////////// + int index =0; + for(it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { + int Z = it->first.Z; + int A = it->first.A; + int I = it->first.I; + FreshCompo[index] = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(Z,A,I)); + + index++; + } + /////////////////////////////////////////////////////// + + for(int Tstep=0 ;Tstep<fNOfTimeStep[b];Tstep++ ) + { + Time=fTime[b][Tstep]; + k_inf=fkeff[b][Tstep]; + fOutT->Fill(); + } + } + ProgressBar(1,1); + + fOutFile->Write(); + delete fOutT; + fOutFile-> Close(); + delete fOutFile; + +} + +//-------------------------------------------------------------------------------------------------- +void CheckJob() +{ //LOAD THE LIST OF EvolutionData + + cout<< endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<< endl; + cout<<" Scanning : "<< endl; + cout<< fEvolutionDataFolder << endl; + cout<<" for EvolutionData (.dat files) "<< endl; + cout<<"╰───────────────────────────────────────────────╯"<< endl; + + string Command = "find "+ fEvolutionDataFolder + " -name \"*.dat\" > JOB.tmp"; + system(Command.c_str()); + + ifstream JOB("JOB.tmp"); + + if(JOB.peek() == std::ifstream::traits_type::eof()) // if file is empty + { cout << endl << "\033[31mERROR: No .dat found in folder : " << fEvolutionDataFolder << "\033[0m" << endl; + exit(1); + } + + if (JOB.is_open()) + { + while (!JOB.eof()) + { + string tmp; + getline(JOB,tmp); + JobName.push_back(tmp); + } + } JOB.close(); JobName.pop_back(); + + // Remove temporary files... + Command = "\\rm -f JOB.tmp"; + system(Command.c_str()); + random_shuffle(JobName.begin(), JobName.end()); + cout << "\033[32m Scan complete \033[0m" << endl; +} + +//-------------------------------------------------------------------------------------------------- +void ReadAndFill(string jobname) +{ //Read a .dat file and fill XS maps and the fuel initial composition + + vector<double> vT; + vector<int> Z; + vector<int> A; + vector<int> I; + vector<double> Q; + + ifstream DecayDB(jobname.c_str()); // Open the File + if(!DecayDB) + { + cout << "\033[33m !!Warning!! !!!EvolutiveProduct!!! \n Can't open \"" << jobname << "\"\033[0m\n" << endl; + } + + string line; + int start = 0; + + getline(DecayDB, line); + + /******Getting Time vecotr ....******/ + if( StringLine::NextWord(line, start, ' ') != "time") + { + cout << "\033[31m!!Bad Trouble!! !!!EvolutiveProduct!!! Bad Database file : " << jobname << "\033[0m" << endl; + exit (1); + } + + while(start < (int)line.size()) + vT.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); + + fTime.push_back(vT); + + fNOfTimeStep.push_back(int(vT.size())); + + /****Getting Keff***/ + start = 0; + getline(DecayDB, line); + string tmp = StringLine::NextWord(line, start, ' '); + vector<double> vKeff; + if ( tmp == "keff" || tmp == "Keff" ) + { + while(start < (int)line.size()) + vKeff.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); + } + fkeff.push_back(vKeff); + + /****Getting Inventories***/ + getline(DecayDB, line); + do + { + start = 0; + int z; + string tmp2 = StringLine::NextWord(line, start, ' '); + if (tmp2 == "Inv") { + z = atoi(StringLine::NextWord(line, start, ' ').c_str()); + } + else z = atoi(tmp2.c_str()); + int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); + + if(a!=0 && z!=0) + { + + ZAI zaitmp(z, a, i); + Z.push_back(z); + A.push_back(a); + I.push_back(i); + if(!fIsAllNucleiAlreadyFill) + { + fAllNuclei.push_back(zaitmp); + } + + long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); + Q.push_back(q); + + } + + getline(DecayDB, line); + start = 0; + tmp2 = StringLine::NextWord(line, start, ' '); + + if(line == "" || line == "CrossSection" || tmp2 == "XSFis" || tmp2 == "XSCap" || tmp2 == "XSn2n") break; + }while (!DecayDB.eof() ); + + if(fAllNuclei.size()!=0) + fIsAllNucleiAlreadyFill=true; + + DecayDB.close(); + + double N = 0; + for(int i=0; i < (int)Z.size()-2; i++) + { + if( Z[i]>89 ) + N += Q[i]; + } + + + IsotopicVector CompoBasei; + IsotopicVector CompoBaseiUnormalize; + + for(int i=0; i < (int)Z.size()-2; i++) + { + if(Z[i]>89) + { + ZAI zai = ZAI(Z[i], A[i], I[i]); + CompoBasei.IVquantity.insert(pair<ZAI,double>(zai,Q[i]/N)); + CompoBaseiUnormalize.IVquantity.insert(pair<ZAI,double>(zai,Q[i])); + } + } + + fActinideCompoInit.push_back(CompoBasei); + double MassOfThisFuel = cZAIMass.GetMass(CompoBaseiUnormalize); + //cout<<MassOfThisFuel<< endl; + fHMMass.push_back(MassOfThisFuel); + +GoodJobName.push_back(jobname); + +} +/*------------------------------------------------------------------------------------------------- +COMPILATION : + +g++ -o Generate_MLP_Kinf Generate_MLP_Kinf.cxx `root-config --cflags` `root-config --libs` + + +*/ diff --git a/Utils/EQM/MLP_Kinf/Train_MLP.cxx b/Utils/EQM/MLP_Kinf/Train.cxx old mode 100755 new mode 100644 similarity index 58% rename from Utils/EQM/MLP_Kinf/Train_MLP.cxx rename to Utils/EQM/MLP_Kinf/Train.cxx index 8f8aa47e89c41e7537a55b31205f1e1794cd64ba..870f31787d920efe5c688ddd3488ceda47084f31 --- a/Utils/EQM/MLP_Kinf/Train_MLP.cxx +++ b/Utils/EQM/MLP_Kinf/Train.cxx @@ -14,7 +14,6 @@ #include "TSystem.h" #include "TROOT.h" -#include "TMVARegGui.C" #if not defined(__CINT__) || defined(__MAKECINT__) #include "TMVA/Tools.h" @@ -25,23 +24,13 @@ using namespace TMVA; int main(int argc, char const *argv[]) { - if(argc!=2) - { - std::cout << "TrainMLP Usage :" << std::endl; - std::cout << "\tTrainMLP YourTrainingData.root" << std::endl; - } + //--------------------------------------------------------------- // This loads the library TMVA::Tools::Instance(); // --------------------------------------------------------------- - // if(argc !=3) - // { - // cout<<"error : "<<endl; - // cout<<"Usage : Train_MLP rootfile.root targetname : "<<endl; - // cout<<"\t targetname : keff or k_0 or k_1 ..."<<endl; - // exit(1); - // } - std::string TargetName = "k_inf";//argv[2]; + + std::string TargetName = "k_inf"; std::cout << std::endl; @@ -49,7 +38,7 @@ int main(int argc, char const *argv[]) // Create a new root output file - TString outfileName( "TMVA_"+TargetName+".root" ); + TString outfileName( "Training_output_"+TargetName+".root" ); TFile* outputFile = TFile::Open( outfileName, "RECREATE" );//UPDATE @@ -63,38 +52,10 @@ int main(int argc, char const *argv[]) TMVA::Factory *factory = new TMVA::Factory( "TMVARegression", outputFile, "!V:!Silent:Color:DrawProgressBar" ); - // If you wish to modify default settings - // (please check "src/Config.h" to see all available global options) - // (TMVA::gConfig().GetVariablePlotting()).fTimesRMS = 8.0; - // (TMVA::gConfig().GetIONames()).fWeightFileDir = "myWeightDirectory"; - - // Define the input variables that shall be used for the TMVA training - // note that you may also use variable expressions, such as: "3*var1/var2*abs(var3)" - // [all types of expressions that can also be parsed by TTree::Draw( "expression" )] - - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change/add variables if needed - //@@@ the variable name are the one you use in GenerateRootFile.cxx - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - factory->AddVariable( "U8" , "U 238 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "U5" , "U 235 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu8" , "Pu 238 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu9" , "Pu 239 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu10" , "Pu 240 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu11" , "Pu 241 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu12" , "Pu 242 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Am1" , "Am 241 " , "FractionIsotopic", 'F' ); - factory->AddVariable( "Time" , "Time" , "temps(s)", 'F' ); - - - // You can add so-called "Spectator variables", which are not used in the MVA training, - // but will appear in the final "TestTree" produced by TMVA. This TestTree will contain the - // input variables, the response values of all trained MVAs, and the spectator variables - //factory->AddSpectator( "spec1:=var1*2", "Spectator 1", "units", 'F' ); - //factory->AddSpectator( "spec2:=var1*3", "Spectator 2", "units", 'F' ); - // Add the variable carrying the regression target + #include "_tmp/include_Train/InputVariables.cxx" + // Add the variable carrying the regression target factory->AddTarget(TargetName); // It is also possible to declare additional targets for multi-dimensional regression, ie: @@ -104,7 +65,7 @@ int main(int argc, char const *argv[]) // Read training and test data (see TMVAClassification for reading ASCII files) // load the signal and background event samples from ROOT trees TFile *input(0); - TString fname = argv[1]; //Training Data input file + TString fname = "_tmp/include_Train/TrainingInput.root"; //Training Data input file if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists @@ -131,6 +92,14 @@ int main(int argc, char const *argv[]) // Apply additional cuts on the signal and background samples (can be different) TCut mycut = ""; // for example: TCut mycut = "abs(var1)<0.5 && abs(var2-0.5)<1"; + Long64_t NEvents = regTree->GetEntries(); + Long64_t NTraining = PropTraining * NEvents ; + Long64_t NTesting = NEvents - NTraining ; + + std::stringstream Samples_Parameters ; + Samples_Parameters << "nTrain_Regression=" << NTraining <<":"<< "nTest_Regression=" << NTesting <<":SplitMode=Random:NormMode=NumEvents:!V"; + + // tell the factory to use all remaining events in the trees after training for testing: factory->PrepareTrainingAndTestTree( mycut, "nTrain_Regression=0:nTest_Regression=0:SplitMode=Random:NormMode=NumEvents:!V" ); @@ -140,12 +109,17 @@ int main(int argc, char const *argv[]) // ---- Book MVA methods // + TString NType = "sigmoid"; + TString Arch = "18,21,9"; + TString Sampl = "0.5"; + TString LearRate = "0.1"; + + TString ParamNN = "!H:V:VarTransform=Norm:NeuronType=" + NType + ":NCycles=16000:HiddenLayers=" + Arch + ":TestRate=6:TrainingMethod=BFGS:LearningRate=" + LearRate + ":Sampling=" + Sampl + ":SamplingEpoch=0.8:ConvergenceImprove=1e-6:ConvergenceTests=15:!UseRegulator"; + std::stringstream Name; - Name<<"MLP_"<<TargetName; + Name<<"MLP_"<<TargetName; // Neural network (MLP) - factory->BookMethod( TMVA::Types::kMLP, Name.str().c_str(), "!H:V:VarTransform=Norm:NeuronType=tanh:NCycles=16000:HiddenLayers=8,:TestRate=6:TrainingMethod=BFGS:Sampling=0.3:SamplingEpoch=0.8:ConvergenceImprove=1e-6:ConvergenceTests=15:!UseRegulator" ); - - + factory->BookMethod( TMVA::Types::kMLP, Name.str().c_str(), ParamNN ); // -------------------------------------------------------------------------------------------------- // ---- Now you can tell the factory to train, test, and evaluate the MVAs @@ -169,10 +143,9 @@ int main(int argc, char const *argv[]) delete factory; - // Launch the GUI for the root macros -if (!gROOT->IsBatch()) TMVARegGui( outfileName ); + } /* -g++ -o Train_MLP `root-config --cflags` Train_MLP.cxx `root-config --glibs` -lTMVA -I$ROOTSYS/tmva/test/ +g++ -o Train `root-config --cflags` Train.cxx `root-config --glibs` -lTMVA -I$ROOTSYS/tmva/test/ */ \ No newline at end of file diff --git a/Utils/EQM/MLP_Kinf/include/GenerateRootFile.hxx b/Utils/EQM/MLP_Kinf/include/GenerateRootFile.hxx deleted file mode 100755 index ef7b9ff21a601531e0a8d45eb81c8e60aee3fd70..0000000000000000000000000000000000000000 --- a/Utils/EQM/MLP_Kinf/include/GenerateRootFile.hxx +++ /dev/null @@ -1,51 +0,0 @@ -#include "ZAI.hxx" -#include <TGraph.h> -#include <TGraph.h> - -#include <vector> -#include <stdio.h> -#include <stdlib.h> -#include <iostream> -#include <fstream> -#include <sstream> -#include <string> -#include <vector> -#include <sstream> -#include <cmath> -#include <map> -#include <iostream> -#include <iomanip> -using namespace std; - -string dtoa(double num) -{ - ostringstream os(ostringstream::out); - os<<setprecision(3)<<num; - return os.str(); -} - -string FilePath; -string DataPath; - -map<ZAI, double> ZAImass; -vector<string> JobName; -vector<string> GoodJobName; - -vector<double> fTime; //Time vector of the depletion calculation (second) -vector< vector<double> > fkeff; - -vector<ZAI> fAllNuclei; //All the nuclei present in the fuel - - -vector<IsotopicVector> fActinideCompoInit; //Fresh fuel composition - -int fNOfTimeStep=0; //number of time step in the Evolution - -string fEvolutionDataFolder = ""; - -bool fIsAllNucleiAlreadyFill=false; - -void InitMass(); -void CheckJob(); -void ReadAndFill(string jobname); -void DumpInputNeuron(string filename); \ No newline at end of file diff --git a/Utils/EQM/MLP_Kinf/include/Generate_MLP_Kinf.hxx b/Utils/EQM/MLP_Kinf/include/Generate_MLP_Kinf.hxx new file mode 100644 index 0000000000000000000000000000000000000000..72b250482f0bdeee95816477a450a767125fe45b --- /dev/null +++ b/Utils/EQM/MLP_Kinf/include/Generate_MLP_Kinf.hxx @@ -0,0 +1,76 @@ +#include "ZAI.hxx" +#include <TGraph.h> +#include <TGraph.h> + +#include <vector> +#include <stdio.h> +#include <stdlib.h> +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +#include <sstream> +#include <cmath> +#include <map> +#include <iostream> +#include <iomanip> + +using namespace std; + +string dtoa(double num) +{ + ostringstream os(ostringstream::out); + os<<setprecision(3)<<num; + return os.str(); +} + +string FilePath; +string DataPath; + +vector<string> JobName; +vector<string> GoodJobName; + +vector< vector<double> > fTime; //Time vector of each depletion calculation (second) +vector<ZAI> fAllNuclei; //All the nuclei present in the fuel + +vector< vector<double> > fkeff; //Keff evolution of all Evolution Datas + + +vector<IsotopicVector> fActinideCompoInit; //Fresh fuel composition in atomic prop. + +vector<double> fHMMass; //Vector of initial Heavy metal mass (every element should be egual or very very close !!) + +vector<int> fNOfTimeStep; //number of time step in each Evolution data + +string fEvolutionDataFolder = ""; + +map<ZAI,string> fMapName; // List of ZAI and their name to consider for model parametrization (must of the time Fuel composition @ t=0) + +string fReactorType,fFuelType; + +vector <ZAIStreamList> fStreamList; // Fisisle or Fertile and default proportions for all nuclei in fresh fuel + +bool fIsAllNucleiAlreadyFill=false; + +void CheckJob(); +void ReadAndFill(string jobname); +void DumpForTestingNeuron(string filename); +void DumpInputNeuron(string filename); +void FillMapName(); +bool UserSayYes(); +string CreateInfoFile(); +void ReadInfo(string InfoDBFile,string &ReactorType,string &FuelType,double &Power); +void ProgressBar(double loopindex, double totalindex); +vector<double> GetAllCompoOf(ZAI zai); + +bool is_file_exist(const char *fileName); +void CompileTraining(); +void FissileOrFertileList(int Z,int A,int I); +/* PRINT INFO */ +void Generate_tmva_factory_input(double ProportionOfTraining); + +void GetUserValue(int &Value); +void GetUserValue(double &Value); +void GetUserValue(string &Value); + + diff --git a/Utils/EQM/MLP_Kinf/include/StringLine.hxx b/Utils/EQM/MLP_Kinf/include/StringLine.hxx deleted file mode 100755 index da8500370b840d6abebf1360b3593151b6dab9d7..0000000000000000000000000000000000000000 --- a/Utils/EQM/MLP_Kinf/include/StringLine.hxx +++ /dev/null @@ -1,275 +0,0 @@ -#ifndef _STRINGLINE_ -#define _STRINGLINE_ - -#include <string> -#include <sstream> -#include <iostream> -#include <algorithm> -#include <cctype> -using namespace std; -/*! - \file - \brief Header file for StingLine class. -*/ - -// Class extracting fields from a string / line. -/*! - The aim of this class is to provide tools to extract fields ("word") from - a string and convert a string in Upper/Lower case. - All methods are static so that it is not necessary to create object to use them - - example: - \code - string line="The temperature is : 300.6 K"; - int start; - - 1st method: creation of StringLine - - start=0; - StringLine SL; - string the=SL.NextWord(line,start); - string temperature_is=SL.NextWord(line,start,':'); - string colon=SL.NextWord(line,start); - double T=atof(SL.NextWord(line,start).c_str()); - cout<<the<<endl<<temperature_is<<endl<<T<<endl; - - 2nd method: "using" the static methods - - start=0; - the=StringLine::NextWord(line,start); - temperature_is=StringLine::NextWord(line,start,':'); - colon=StringLine::NextWord(line,start); - T=atof(StringLine::NextWord(line,start).c_str()); - cout<<the<<endl<<temperature_is<<endl<<T<<endl; - \endcode - @author PTO - @version 0.1 -*/ - -class StringLine -{ - public: - // Find the next word in a line. - /*! - Find Next word in a line starting from position "start" in the line. If an alternative - separator is given, the word length is defined by the first position of sep or alt_sep found. - The first value of start is in general 0 (i.e. the beginning of the Line) - \param Line : a line containing words - \param start : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static string NextWord(string Line,int &start,char sep=' ', char alt_sep='\0'); - // Find the previous word in a line. - /*! - Find Previous word in a line starting from position "start" in the line. If an alternative - separator is given, the word length is defined by the first position of sep or alt_sep found. - The first value of start is in general the end of the Line. - \param Line : a line containing words - \param start : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static string PreviousWord(string Line,int &start,char sep=' ', char alt_sep='\0'); - static void ToLower(string &Line); // convert a string to Lower case - static void ToUpper(string &Line); // convert a string to Upper case - - // Find \p search in \p Line from the begining. - /*! - returns the position, starting from the begenning of the first occurence - of \p search in \p Line if it is found, else returns -1 - \param search : a string to find - \param Line : where to search - */ - static int Find(const char *search,string Line); - // Find \p search in \p Line from the end. - /*! - returns the position, starting from the end of the first occurence - of \p search in \p Line if it is found, else returns -1 - \param search : a string to find - \param Line : where to search - */ - static int rFind(const char *search,string Line); - // convert a input type (\p in_T) to another (\p out_T). - /*! - Example: - \code - string s="32.12"; - double t=StringLine::convert<double>(s); - string temperature=StringLine::convert<string>(300.); - \endcode - \param t : the input value - */ - template <class out_T, class in_T> static out_T convert(const in_T & t); - // Find the start of a word in a line. - /*! - \param Line : a line containing words - \param CurrentPosition : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static int GetStartWord(string Line,int CurrentPosition,char sep=' ', char alt_sep='\0'); - // Find the end of a word in a line. - /*! - \param Line : a line containing words - \param CurrentPosition : from where to start to find the end of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static int GetEndWord(string Line,int CurrentPosition,char sep=' ', char alt_sep='\0'); - // Replace a sub-string by an other in a string. - /*! - \param InLine : the string which contains the sub-string to replace - \param ToReplace : the sub-string to replace - \param By : the sub-string ToReplace is replaced by the sub-string By in Inline - */ - string ReplaceAll(string InLine, string ToReplace, string By); -}; - - -//_________________________________________________________________________________ -inline string StringLine::NextWord(string Line,int &start,char sep, char alt_sep) -{ - string Word=""; - if(start>=int(Line.size())) - { - return Word; - } - start=GetStartWord(Line,start,sep,alt_sep); - int wordlength=GetEndWord(Line,start,sep,alt_sep)-start; - - Word=Line.substr(start,wordlength); - - start+=wordlength; - return Word; -} -//_________________________________________________________________________________ -inline string StringLine::PreviousWord(string Line,int &start,char sep, char alt_sep) -{ - string Word=""; - if(start<=0) - { - return Word; - } - int pos=Line.rfind(sep,start); - int alt_pos=-1; - int real_pos=pos; - char real_sep=sep; - if(alt_sep!='\0') - { - alt_pos=Line.rfind(alt_sep,start); - real_pos=max(pos,alt_pos); - if(real_pos!=pos) - real_sep=alt_sep; - } - int wordlength=start-Line.rfind(real_sep,real_pos); - if(real_pos<=0) - { - Word=Line.substr(0,start+1); - start=0; - return Word; - } - Word=Line.substr(real_pos+1,wordlength); - - start-=wordlength+1; - return Word; -} - -//_________________________________________________________________________________ -inline void StringLine::ToLower(string &Line) -{ - transform (Line.begin(), Line.end(), // source - Line.begin(), // destination - (int(*)(int))tolower); // operation -} - -//_________________________________________________________________________________ -inline void StringLine::ToUpper(string &Line) -{ - transform (Line.begin(), Line.end(), // source - Line.begin(), // destination - (int(*)(int))toupper); // operation -} - -//_________________________________________________________________________________ -inline int StringLine::GetStartWord(string Line,int CurrentPosition,char sep, char alt_sep) -{ - int pos=Line.find(sep,CurrentPosition); - int alt_pos=-1; - if(alt_sep!='\0') - alt_pos=Line.find(alt_sep,CurrentPosition); - int real_pos=pos; - char real_sep=sep; - if(alt_pos>=0) - { - real_pos=min(pos,alt_pos); - if(pos==int(string::npos))real_pos=alt_pos; - if(real_pos!=pos) - real_sep=alt_sep; - } - if(real_pos==int(string::npos)) return CurrentPosition; - while(CurrentPosition<int(Line.size()) && Line[CurrentPosition]==real_sep) - CurrentPosition++; - return CurrentPosition; -} - -//_________________________________________________________________________________ -inline int StringLine::GetEndWord(string Line,int CurrentPosition,char sep, char alt_sep) -{ - int pos=Line.find(sep,CurrentPosition); - int alt_pos=-1; - if(alt_sep!='\0') - alt_pos=Line.find(alt_sep,CurrentPosition); - int real_pos=pos; - if(alt_pos>=0) - { - real_pos=min(pos,alt_pos); - if(pos==int(string::npos))real_pos=alt_pos; - } - if(real_pos==int(string::npos)) - return Line.size(); - return real_pos; -} - -//_________________________________________________________________________________ -inline int StringLine::Find(const char *search,string Line) -{ - size_t Pos=Line.find(search); - if(Pos != string::npos ) return Pos; - return -1; -} - -//_________________________________________________________________________________ -inline int StringLine::rFind(const char *search,string Line) -{ - size_t Pos=Line.rfind(search); - if(Pos != string::npos) return Pos; - return -1; -} - -//_________________________________________________________________________________ -template <class out_T, class in_T> -inline out_T StringLine::convert(const in_T & t) -{ - stringstream stream; - stream << t; // insert value to stream - out_T result; // store conversion's result here - stream >> result; // write value to result - return result; -} - -//_________________________________________________________________________________ -inline string StringLine::ReplaceAll(string InLine, string ToReplace, string By) -{ - int start=0; - int pos=InLine.find(ToReplace,start); - while(pos!=int(string::npos)) - { - InLine.replace(pos,ToReplace.size(),By); - start=0; - pos=InLine.find(ToReplace,start); - } - return InLine; - -} -#endif diff --git a/Utils/EQM/MLP_Kinf/include/ZAI.hxx b/Utils/EQM/MLP_Kinf/include/ZAI.hxx index 1ee9136f9231fdadd328a009579e46ea9d6d6c6b..68f0f25d7210d1e92286c596cfed31f8df01c7dd 100755 --- a/Utils/EQM/MLP_Kinf/include/ZAI.hxx +++ b/Utils/EQM/MLP_Kinf/include/ZAI.hxx @@ -2,6 +2,10 @@ #define MN_ZAI_H_ #include <map> +#include <vector> +#include <fstream> +#include <iostream> + using namespace std; class ZAI { @@ -12,6 +16,7 @@ class ZAI { ZAI(int z, int a, int i=0) { Z=z;A=a; I=i;} + ZAI(){;} bool operator <(const ZAI& zai) const {return (Z != zai.Z)? (Z < zai.Z) : ( (A != zai.A)? @@ -35,8 +40,103 @@ class IsotopicVector { else return 0; } + vector<ZAI> GetNonZeroZAIList() + { + vector<ZAI> vZAI; + map<ZAI,double>::iterator it; + for(it = IVquantity.begin(); it != IVquantity.end(); ++it) + { if(it->second != 0 ) + vZAI.push_back(it->first); + } + return vZAI; + } + map<ZAI,double> IVquantity; - double MASS; + }; + +class ZAIMass +{ + public: + ZAIMass() + { + string CLASSPATH = getenv("CLASS_PATH"); + string MassDataFile = CLASSPATH + "/data/Mass.dat"; + + ifstream infile(MassDataFile.c_str()); + + if(!infile.good()) + { + std::cout << " ZAIMass Error.\n can't find/open file " << MassDataFile << std::endl; + exit(1); + } + + int Z,A; + string Name; + double MassUnity,MassDec,error; + while (infile>>Z>>A>>Name>>MassUnity>>MassDec>>error) + { + double Masse = MassUnity + MassDec * 1e-6; + fZAIMass.insert( pair< ZAI,double >( ZAI(Z,A,0), Masse ) ); + } + + infile.close(); + } + ~ZAIMass() + { + fZAIMass.clear(); + } + + double GetMass(ZAI zai ) //!< get with ZAI + { + map<ZAI,double>::iterator MassIT = fZAIMass.find( ZAI(zai.Z, zai.A, 0) ); + + if(MassIT == fZAIMass.end()) + return zai.A; + else + return MassIT->second; + + } + + double GetMass(IsotopicVector & IV) //return Mass of IV [t] + { + double AVOGADRO = 6.02214129e23; + double TotalMass = 0; + + for( map<ZAI,double>::iterator it = IV.IVquantity.begin(); it != IV.IVquantity.end(); it++) + { + TotalMass += it->second/AVOGADRO * GetMass( it->first ) ; + } + + return TotalMass*1e-6; + } + + + private: + map<ZAI, double> fZAIMass; //! ZAI mass list + +}; + +class ZAIStreamList { + public : + + ZAI fZAI; + string fListName; + double fDefaultProportion; + + ZAIStreamList(int Z, int A, int I, string ListName, double DefaultProportion ) + { + fZAI = ZAI(Z,A,I); + fListName = ListName; + fDefaultProportion = DefaultProportion; + } ///< Normal Constructor. + ~ZAIStreamList() {}; ///< Normal Destructor. + + +}; + + + + #endif //MN_ZAI_H_ diff --git a/Utils/MURE2CLASS/MURE2CLASS.cxx b/Utils/MURE2CLASS/MURE2CLASS.cxx old mode 100755 new mode 100644 index ff93a76154e1487f38d1714215c1628e49dbfc22..66fb54703c8cccd0da5af8f21867d40edd7df5cc --- a/Utils/MURE2CLASS/MURE2CLASS.cxx +++ b/Utils/MURE2CLASS/MURE2CLASS.cxx @@ -66,12 +66,26 @@ int ReadCommentVersion(ifstream& in, string filename) return MureDataVersion; } +double GetPropOf( vector <ZAI> vZAI , ZAI zai) +{ + + for(int nuc = 0 ; nuc < vZAI.size() ; nuc++ ) + { + if( vZAI[nuc].Z() == zai.Z() && vZAI[nuc].A() == zai.A() && vZAI[nuc].I() == zai.I() ) + return vZAI[nuc].Prop(); + } + +return 0.0; +} + //---------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------- //------------------------------------- MAIN --------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------- + + int main(int argc, char** argv) { @@ -129,25 +143,37 @@ int main(int argc, char** argv) // ========================================================================================= // MURE output path - if(argc != 9) + if(argc < 4) { - cout << "Argument problem for MURE2CLASS... EXIT!" << endl; - cout << "Arg should be :" << endl << "\t1 Path," << endl << "\t2 OutName," << endl << "\t3 ReactorType," << endl << "\t4 FuelType," << endl; - cout << "\t5 Power," << endl << endl << "\t6 NormalizationFactor(Before Normalization)," << endl << "\t7 WantedCell (by default should be 0)" << endl << "\t8 Step to Skip," << endl; - exit(1);} + cout << "MURE2CLASS usage: " << endl; + cout << "Arguments should be :" << endl; + cout << "\t1 Path," << endl; + cout << "\t2 ReactorType," << endl; + cout << "\t3 FuelType," << endl; + cout << "Optional : "<<endl ; + cout << "\t4 WantedCell [Default :0]" << endl; + cout << "\t5 Step to Skip [Default :0]" << endl; + exit(1); + } string DBPath = argv[1]; - string OutName = argv[2]; - string ReactorType = argv[3]; - string FuelType = argv[4]; - - string Power = argv[5]; - double NormalizationFactor = atof(argv[6]); - int WantedCell = atoi(argv[7]); - int StepToSkip = atoi(argv[8]); + string ReactorType = argv[2]; + string FuelType = argv[3]; + int WantedCell = 0; + int StepToSkip = 0; + if(argc == 5) + WantedCell = atoi(argv[4]); + if(argc == 6) + StepToSkip = atoi(argv[5]); + // Name of the output file - OutDataFile = "./" + OutName + ".dat"; + if (DBPath.back() == '/') + DBPath.pop_back(); + + size_t found = DBPath.find_last_of("/"); + string OutName = DBPath.substr(found+1); + OutDataFile = "./" + OutName + ".dat"; OutDataFileInfo = "./" + OutName + ".info"; - OutLOG = "./" + OutName + ".log"; + OutLOG = "./" + OutName + ".log"; ofstream OutputLog(OutLOG.c_str()); @@ -482,7 +508,8 @@ int main(int argc, char** argv) if (vCellNumber.size()>=2) { - OutputLog << endl << "===================================================" << endl; + OutputLog << endl; + OutputLog << "===================================================" << endl; OutputLog << "-------------- WARNING ----------------------------" << endl; OutputLog << "===================================================" << endl << endl; OutputLog << "THERE IS MORE THAN ONE CELL... Cells are : " << endl << endl; /*sleep(1)*/; @@ -546,7 +573,8 @@ int main(int argc, char** argv) zai_SN_1.clear(); } - OutputLog << endl << "---------------------------------------------------" << endl; + OutputLog << endl; + OutputLog << "---------------------------------------------------" << endl; OutputLog << "-------------- Sum of cells done ------------------" << endl; OutputLog << "---------------------------------------------------" << endl << endl; } @@ -612,7 +640,7 @@ int main(int argc, char** argv) Output << "Inv " << zai2[0][i].Z() << " " << zai2[0][i].A() << " " << zai2[0][i].I() << " "; for (int t=StepToSkip; t<vTime.size(); t++) { - double Val = zai2[t][i].Prop() * NormalizationFactor; + double Val = zai2[t][i].Prop() ; Output << Val << " "; if (t==StepToSkip) NPrinted++; @@ -627,7 +655,7 @@ int main(int argc, char** argv) Output << "Inv " << zai3[0][0][i].Z() << " " << zai3[0][0][i].A() << " " << zai3[0][0][i].I() << " "; for (int t=StepToSkip; t<vTime.size(); t++) { - double Val = zai3[t][WantedCell][i].Prop() * NormalizationFactor; + double Val = zai3[t][WantedCell][i].Prop() ; Output << Val << " "; if (t==StepToSkip) NPrinted++; } @@ -638,6 +666,7 @@ int main(int argc, char** argv) if (SumOfCell) { + for(int i=0; i< (int)zai_FS_2[0].size(); i++) { @@ -723,6 +752,22 @@ int main(int argc, char** argv) } Output.close(); + + double Power = 0 ;//Calculated Power @ t = 0 (as we supposed it is constant) + for(int c = 0 ; c < NumberOfCells ; c++) + { + for(int nuc = 0 ; nuc < zai_FS_3[0][c].size() ; nuc++) //ef * Nf * sigma_f *phi + { + + double EnergyPerFisison_f = 1.9679e6*zai_FS_3[0][c][nuc].A()-2.601e8; //eV + double XS_f = zai_FS_3[0][c][nuc].Prop() * 1e-24; + double N_f = GetPropOf( zai3[0][c], zai_FS_3[0][c][nuc] ); + + Power += EnergyPerFisison_f * N_f * XS_f * vFlux1[0][c]; //eV.s-1 + } + } + Power *= 1.60218e-19 ; //W + ofstream OutputInfo(OutDataFileInfo.c_str()); OutputInfo << "Reactor " << ReactorType << endl; OutputInfo << "Fueltype " << FuelType << endl; @@ -731,8 +776,6 @@ int main(int argc, char** argv) OutputInfo << "ConstantPower " << Power << " W" << endl; OutputInfo << "Nnuclei " << NPrinted << endl; - OutputInfo << "NormalizationFactor " << NormalizationFactor << endl; - OutputInfo << "FinalHeavyMetalMass " << MTotalFissile*NormalizationFactor << " g" << endl; OutputInfo.close(); @@ -754,5 +797,5 @@ int main(int argc, char** argv) /* - g++ -o MURE2CLASS MURE2CLASS.cxx + g++ -std=c++11 -o MURE2CLASS MURE2CLASS.cxx */ diff --git a/Utils/README.md b/Utils/README.md new file mode 100644 index 0000000000000000000000000000000000000000..77739dec9d77d94211e81ba67e41dec96065355e --- /dev/null +++ b/Utils/README.md @@ -0,0 +1,101 @@ +# Utils folder +## EQM +This folder contains programs to help you with the generation of equivalence models (EQM). An EQM describes how the FabricationPlant build a fuel. + +### FBR\_MLP\_Keff +#### Generate +The programs in this folder generate weigths files to be used with : +**\$CLASS_PATH/Model/Equivalence/EQM\_FBR\_MLP\_Keff.cxx** +This model is related to Fast Breeder Reactor. The idea is that the fissile content is such as the keff of the reactor is equal to a user defined value at time T (often Begining of Cycle, Middle or End Of Cycle). Where T depends on the weigths models. For instance, the weights in \$CLASS\_PATH/DATA\_BASES/FBR\_Na/MOX/EQModel/MLP\_K\_EFF\_BOC aims to predict the keff at begining of cycle for a FBR-Na loaded with MOX fuel. Thus, programs in this folder build Artificial Neural Network (ANN) weights files to estimate keff at time T according your depletion (or just neutron transport if T=BOC) calculations results. + +##### Usage: +* Generate a folder containing results of many depletions calculations of FBR reactor (each calculation should defer in terms of fresh fuel composition). It has to be formated as **EvolutionData**s (see USEGUIDE.pdf in ../documentation for format). If you are using MURE or SMURE depletion code you can use the [MURE2CLASS](#mure2class) utility to convert MURE outputs in EvolutionData (.dat files) +* Compile the file .cxx with : + +```bash +g++ -o Generate_FBR_Keff Generate_FBR_Keff.cxx `root-config --cflags` `root-config --libs` +``` +* Execute with + +```bash +./Generate_FBR_Keff PATH_TO_YOUR_EVOLUTION_DATAS +``` +* Follow program instructions + +#### Test +The programs in this folder test the regression performances of the model you created thanks to \$CLASS_PATH/Utils/EQM/FBR\_MLP\_Keff/Generate/Generate\_FBR.cxx. +##### Usage: + + +### MLP\_Kinf +#### Generate +The programs in this folder generate weigths files to be used with : +**\$CLASS\_PATH/source/Model/Equivalence/EQM\_MLP\_Kinf.cxx** +This model is related to non breeder reactor. See USEGUIDE.pdf in ../documentation for additional informations. + +##### Usage: +* Generate a folder containing results of many depletions calculations of a non-breeder reactor (each calculation should defer in terms of fresh fuel composition). It has to be formated as **EvolutionData**s (see \$CLASS\_PATH/documentation/Manuel/USEGUIDE.pdf for format). If you are using MURE or SMURE depletion code you can use the [MURE2CLASS](#mure2class) utility to convert MURE outputs in EvolutionData (.dat files) +* Compile the file .cxx with +``` +g++ -o Generate_MLP_Kinf Generate_MLP_Kinf.cxx `root-config --cflags` `root-config --libs` +``` +* Execute with +``` +./Generate_MLP_Kinf PATH_TO_YOUR_EVOLUTION_DATAS +``` +* Follow program instructions + + +#### Test +The programs in this folder test the regression performances of the model you created thanks to \$CLASS\_PATH/Utils/EQM/MLP\_Kinf/Generate/Generate\_MLP\_Kinf.cxx. +##### Usage: + + +### PWR\_MOX\_MLP +#### Generate +The programs in this folder generate weigths files to be used with : +**\$CLASS\_PATH/source/Model/Equivalence/EQM\_PWR\_MLP\_MOX.cxx** +This model is made for PWR loaded with MOX (U,Pu)O2 fuel. See USEGUIDE.pdf in ../documentation for additional informations. +#####Usage: + +* Generate a folder containing results of many depletions calculations of a non-breeder reactor (each calculation should defer in terms of fresh fuel composition). It has to be formated as **EvolutionData**s (see USEGUIDE.pdf for format). If you are using MURE or SMURE depletion code you can use the [MURE2CLASS](#mure2class) utility to convert MURE outputs in EvolutionData (.dat files) + +#### Test +The programs in this folder test the regression performances of the model you created thanks to \$CLASS\_PATH/Utils/EQM/PWR\_MOX\_MLP/Generate/Generate_PWR.cxx. +#####Usage: + + +## MURE2CLASS +Convert a (S)MURE evolution result to CLASS format EvolutionData (.dat file) +##### Usage: +* Compile the file .cxx with +``` g++ -std=c++11 -o MURE2CLASS MURE2CLASS.cxx``` + +* Execute with +``` +./MURE2CLASS PATH_TO_YOUR_MURE_RESULT ReactorType FuelType +``` +with ReactorType and FuelType is any strings you want. + +## XSM / MLP +These utils allow you to build mean cross section predictors based on artificial neural networks (MLP). The weights and .nfo file produced by this utils are planned to be used with $CLASS\_PATH/source/Model/XSM/XSM\_MLP.cxx +### Generate +#####Usage: + +* Generate a folder containing results of many depletions calculations (each calculation should defer in terms of fresh fuel composition). It has to be formated as **EvolutionData**s (see USEGUIDE.pdf for format). If you are using MURE or SMURE depletion code you can use the [MURE2CLASS](#mure2class) utility to convert MURE outputs in EvolutionData (.dat files) + +* Compile file Generate_XSM.cxx with : +``` g++ -o Generate_XSM Generate_XSM.cxx `root-config --cflags` `root-config --libs` ``` + +* Execute with +``` ./Generate_MLP_Kinf PATH_TO_YOUR_EVOLUTION_DATAS ``` + +* Follow instructions. + + +### Test +The program in this folder aims to test regression performance of your mean cross section predictors. +Once you have trained your ANN with Generate_MLP_Kinf, you can test their performances using indications in file EvaluateTrainingCommands.dat. + +## cgui +Graphical user interface (web) to define a CLASS input. Usefull if you have poor knowledge in C++. Note that this user friendly interface does not have all the possibilities given by the C++ one. More informations can be found [here](cgui/README.md) (in french). diff --git a/Utils/XSM/MLP/BuildInput/Gene.cxx b/Utils/XSM/MLP/BuildInput/Gene.cxx deleted file mode 100755 index 1bf019439efa62b5cba26bd45a44131ff5124dc3..0000000000000000000000000000000000000000 --- a/Utils/XSM/MLP/BuildInput/Gene.cxx +++ /dev/null @@ -1,497 +0,0 @@ -/**********************************************************/ -// Make the input file for the MLPs training -// -// This programs reads a set of .dat files which are the -// results of a depletion calculation (see manual and -// looks for XS_CLOSEST). From the reading it fills a -// TTree (Data) and write it in a file named -// TrainingInput.root . -// The file TrainingInput.cxx is the list of MLP outputs -// (cross sections) -// -//@author BaM, BaL -/**********************************************************/ -#include "Gene.hxx" -#include <TH1F.h> -#include <TH2D.h> -#include <TFile.h> -#include <TTree.h> -#include "StringLine.hxx" -#include <TString.h> -#include <string> -#include <cmath> -#include <iostream> -#include <fstream> -#include <algorithm> -#include <map> -#include <sstream> - -using namespace std; -//-------------------------------------------------------------------------------------------------- -/************************* - MAIN -*************************/ -int main(int argc, char ** argv){ - - if(argc!=2) - { - cout << "Usage : BuildInputTree Path" << endl; - cout << " Where Path is the path to the folder containing the Evolution Datas" << endl; - cout << " i.e the (.dat) files" << endl; - exit(0); - } - - fEvolutionDataFolder = argv[1]; - - InitMass(); //Load nuclei masses - CheckJob(); // looks fot the .dat files in the fEvolutionDataFolder - - FilePath = "DB_TMP/"; - DataPath = FilePath + "Data/"; - string Command = "mkdir -p " + DataPath; - system(Command.c_str()); - - cout << "Reading .dat files ..." << endl; - for(int i = 0; i < (int)JobName.size(); i++) - { - ReadAndFill(JobName[i]); - if (i%100 == 0) - cout << "\r" << i << " .dat files read" <<flush; - } - cout << "Filling the TTree ..." << endl; - DumpInputNeuron("TrainingInput.root"); - cout << "Training input generated in file : TrainingInput.root " << endl; - cout << "Names of MLP outputs in file : TrainingInput.cxx " << endl; - system("rm -r DB_TMP"); - -} -//-------------------------------------------------------------------------------------------------- -// Function definitions -//-------------------------------------------------------------------------------------------------- -//Convert int to string -string itoa(int num) -{ - ostringstream os(ostringstream::out); - os << num; - return os.str(); -} -//-------------------------------------------------------------------------------------------------- -//Give a name to a cross section -//!!!!!!!!!!!!!!!!!!!!!!!!!!// -// YOU MUST KEEP THE FORMAT : -// XS_Z_A_I_fis (fission cross section) -// XS_Z_A_I_cap (n,gamma cross section) -// XS_Z_A_I_n2n (n,2n cross section) -//!!!!!!!!!!!!!!!!!!!!!!!!!!// -string NameXS(ZAI act,string xs) -{ - stringstream Name; - Name<<"XS_"<<act.Z<<"_"<<act.A<<"_"<<act.I<<"_"<<xs; - - return Name.str(); -} -//-------------------------------------------------------------------------------------------------- -void DumpInputNeuron(string filename) -{ - TFile* fOutFile = new TFile(filename.c_str(),"RECREATE"); - TTree* fOutT = new TTree("Data", "Data"); - -/**********************INITIALISATIONNN********************/ - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@Change the input value according to your fresh fuel compo - //-> here MOX FUEL - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - double U5 = 0; - double U8 = 0; - double Pu8 = 0; - double Pu9 = 0; - double Pu10 = 0; - double Pu11 = 0; - double Pu12 = 0; - double Am1 = 0; - - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - double Time = 0; -/**********************init map********************/ - map < ZAI,vector<double> > mAllXS; - map < ZAI, vector<double> > mAllInventories; - for(int act=0;act<int(fAllNuclei.size());act++ ) - { - vector<double> InitVect; - for(int Tstep=0 ;Tstep<fNOfTimeStep;Tstep++) - { - InitVect.push_back(0); - } - mAllInventories.insert( pair<ZAI,vector<double> >(fAllNuclei[act],InitVect) ); - } - - for(int act=0;act<int(fAllNuclei.size());act++ ) - { - vector< double> InitVect; - for(int xs=0;xs<3;xs++) - { - - InitVect.push_back(0); - - } - - mAllXS.insert(pair<ZAI,vector< double> >(fAllNuclei[act], InitVect) ); - } - -/**********************BRANCHING**************************************************/ -/**********************Fresh fuel**************************************************/ - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@Change the input value according to your fresh fuel compo - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - fOutT->Branch( "U5" ,&U5 ,"U5/D" ); - fOutT->Branch( "U8" ,&U8 ,"U8/D" ); - fOutT->Branch( "Pu8" ,&Pu8 ,"Pu8/D" ); - fOutT->Branch( "Pu9" ,&Pu9 ,"Pu9/D" ); - fOutT->Branch( "Pu10" ,&Pu10 ,"Pu10/D" ); - fOutT->Branch( "Pu11" ,&Pu11 ,"Pu11/D" ); - fOutT->Branch( "Pu12" ,&Pu12 ,"Pu12/D" ); - fOutT->Branch( "Am1" ,&Am1 ,"Am1/D" ); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - fOutT->Branch( "Time" ,&Time ,"Time/D" ); - - -/**********************cross section**************************************************/ - - string XSType[3]={"fis","cap","n2n"}; //!!!!!!DO NOT TOUCH THIS - - for(int act=0;act<int(fAllNuclei.size());act++ ) - { - for(int xs=0;xs<3;xs++) - { - string NamedXS= NameXS(fAllNuclei[act],XSType[xs]); - string NameXSBis=NamedXS+"/D"; - - if( xs==0 && fXSFis[0][fAllNuclei[act]].size()!=0) //Check if the reaction we want to branch exists - if(fXSFis[0][fAllNuclei[act]][0]!=0) - fOutT->Branch( NamedXS.c_str() , &mAllXS[fAllNuclei[act]][xs], NameXSBis.c_str() ); - - if(xs==1 && fXSCap[0][fAllNuclei[act]].size()!=0) - if(fXSCap[0][fAllNuclei[act]][0]!=0) - fOutT->Branch( NamedXS.c_str() , &mAllXS[fAllNuclei[act]][xs], NameXSBis.c_str() ); - - if(xs==2 && fXSN2N[0][fAllNuclei[act]].size()!=0) - if(fXSN2N[0][fAllNuclei[act]][0]!=0) - fOutT->Branch( NamedXS.c_str() , &mAllXS[fAllNuclei[act]][xs], NameXSBis.c_str() ); - - - } - } -/**********************FILLING THE TTREE**************************************************/ - - //Fill containing all the output of the networks to train - ofstream InputNetwork("TrainingInput.cxx"); - - int NumOfBase=fActinideCompoInit.size(); - for(int b=0;b<NumOfBase;b++) - { - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - //@@@Change the input value according to your fresh fuel compo - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - // (Z , A ,I) - U5 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(92,235,0)); - U8 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(92,238,0)); - Pu8 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,238,0)); - Pu9 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,239,0)); - Pu10 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,240,0)); - Pu11 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,241,0)); - Pu12 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(94,242,0)); - Am1 = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(95,241,0)); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - for(int Tstep=0 ;Tstep<fNOfTimeStep;Tstep++ ) - { - Time=fTime[Tstep]; - for(int act=0;act<int(fAllNuclei.size());act++) - { - - if(fXSFis[b][fAllNuclei[act]].size()!=0) // reaction may not be present - { - if(fXSFis[b][fAllNuclei[act]][Tstep] !=0 ) - { mAllXS[fAllNuclei[act]][0] = fXSFis[b][fAllNuclei[act]][Tstep]; - if(b==0 && Tstep==0) - InputNetwork<<"OUTPUT.push_back(\""<<NameXS(fAllNuclei[act],XSType[0])<<"\");"<<endl; - } - } - if(fXSCap[b][fAllNuclei[act]].size()!=0) - { - if(fXSCap[b][fAllNuclei[act]][Tstep] !=0) - { mAllXS[fAllNuclei[act]][1] = fXSCap[b][fAllNuclei[act]][Tstep]; - if(b==0 && Tstep==0) - InputNetwork<<"OUTPUT.push_back(\""<<NameXS(fAllNuclei[act],XSType[1])<<"\");"<<endl; - } - } - if( fXSN2N[b][fAllNuclei[act]].size()!=0) - { - if(fXSN2N[b][fAllNuclei[act]][Tstep] !=0) - { mAllXS[fAllNuclei[act]][2] = fXSN2N[b][fAllNuclei[act]][Tstep]; - if(b==0 && Tstep==0) - InputNetwork<<"OUTPUT.push_back(\""<<NameXS(fAllNuclei[act],XSType[2])<<"\");"<<endl; - } - } - - } - fOutT->Fill(); - } - } - - fOutFile->Write(); - delete fOutT; - fOutFile-> Close(); - delete fOutFile; - -} -//-------------------------------------------------------------------------------------------------- -void InitMass() -{ -//Set tghe mass of the nuceli - -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// -//@@Change : ADD THE MASS OF THE NUCLEI PRESENT IN YOUR FRESH FUEL -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - - ZAI U238 = ZAI(92,238,0); - ZAImass.insert(pair<ZAI,double>(U238, 238050788.247e-6)); - - ZAI U234 = ZAI(92,234,0); - ZAImass.insert(pair<ZAI,double>(U234, 234041000.000e-6)); - - ZAI U235 = ZAI(92,235,0); - ZAImass.insert(pair<ZAI,double>(U235, 235043929.918e-6)); - - ZAI Pu238 = ZAI(94,238,0); - ZAImass.insert(pair<ZAI,double>(Pu238,238049559.894e-6)); - - ZAI Pu239 = ZAI(94,239,0); - ZAImass.insert(pair<ZAI,double>(Pu239,239052163.381e-6)); - - ZAI Pu240 = ZAI(94,240,0); - ZAImass.insert(pair<ZAI,double>(Pu240,240053813.545e-6)); - - ZAI Pu241 = ZAI(94,241,0); - ZAImass.insert(pair<ZAI,double>(Pu241,241056851.456e-6)); - - ZAI Pu242 = ZAI(94,242,0); - ZAImass.insert(pair<ZAI,double>(Pu242,242058742.611e-6)); - - ZAI Am241 = ZAI(95,241,0); - ZAImass.insert(pair<ZAI,double>(Am241,241056829.144e-6)); - - ZAI O16 = ZAI(8,16,0); - ZAImass.insert(pair<ZAI,double>(O16, 0.)); - //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// - -} -//-------------------------------------------------------------------------------------------------- -void CheckJob() -{ //LOAD THE LIST OF EvolutionData - cout << "Scanning " << fEvolutionDataFolder << " for .dat files ..." << endl; - cout << "Please wait ..."<< endl; - - string Command = "find "+ fEvolutionDataFolder + " -name \"*.dat\" > JOB.tmp"; - system(Command.c_str()); - - ifstream JOB("JOB.tmp"); - if (JOB.is_open()) - { - while (!JOB.eof()) - { - string tmp; - getline(JOB,tmp); - JobName.push_back(tmp); - } - } JOB.close(); JobName.pop_back(); - - // Remove temporary files... - Command = "\\rm -f JOB.tmp"; - system(Command.c_str()); - random_shuffle(JobName.begin(), JobName.end()); - cout << "Scan complete" <<endl; -} - -//-------------------------------------------------------------------------------------------------- -void ReadAndFill(string jobname) -{ //Read a .dat file and fill XS maps and the fuel initial composition - - vector<double> vT; - vector<int> Z; - vector<int> A; - vector<int> I; - vector<double> Q; - - ifstream DecayDB(jobname.c_str()); // Open the File - if(!DecayDB) - { - cout << "!!Warning!! !!!EvolutiveProduct!!! \n Can't open \"" << jobname << "\"\n" << endl; - } - - string line; - int start = 0; - - getline(DecayDB, line); - - /******Getting Time vecotr ....******/ - if( StringLine::NextWord(line, start, ' ') != "time") - { - cout << "!!Bad Trouble!! !!!EvolutiveProduct!!! Bad Database file : " << jobname << endl; - exit (1); - } - - while(start < (int)line.size()) - vT.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); - - fNOfTimeStep=int(vT.size()); - - /****Getting Inventories***/ - getline(DecayDB, line); - do - { - start = 0; - int z; - string tmp2 = StringLine::NextWord(line, start, ' '); - if (tmp2 == "Inv") { - z = atoi(StringLine::NextWord(line, start, ' ').c_str()); - } - else z = atoi(tmp2.c_str()); - int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); - - if(a!=0 && z!=0) - { - - ZAI zaitmp(z, a, i); - Z.push_back(z); - A.push_back(a); - I.push_back(i); - if(!fIsAllNucleiAlreadyFill) - { - fAllNuclei.push_back(zaitmp); - fTime=vT; - } - - long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); - Q.push_back(q); - - } - - getline(DecayDB, line); - start = 0; - tmp2 = StringLine::NextWord(line, start, ' '); - - if(line == "" || line == "CrossSection" || tmp2 == "XSFis" || tmp2 == "XSCap" || tmp2 == "XSn2n") break; - }while (!DecayDB.eof() ); - - if(fAllNuclei.size()!=0) - fIsAllNucleiAlreadyFill=true; - - //XS - map<ZAI, vector <double> > mapFistmp; - map<ZAI, vector <double> > mapCaptmp; - map<ZAI, vector <double> > mapN2Ntmp; - do - { - - start = 0; - int z; - string tmp2 = StringLine::NextWord(line, start, ' '); - if (tmp2 == "XSFis") - { - z = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); - - if(a!=0 && z!=0) - { - - ZAI zaitmp(z, a, i); - - vector<double> XSTime; - for(int i = 0; i < (int)vT.size(); i++) - { long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); - XSTime.push_back(q); - } - mapFistmp.insert( pair<ZAI,vector<double> >(zaitmp,XSTime)); - } - } - else if (tmp2 == "XSCap") - { - z = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); - - if(a!=0 && z!=0) - { - - ZAI zaitmp(z, a, i); - vector<double> XSTime; - for(int i = 0; i < (int)vT.size(); i++) - { long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); - XSTime.push_back(q); - } - mapCaptmp.insert( pair<ZAI,vector<double> >(zaitmp,XSTime)); - - } - } - else if (tmp2 == "XSn2n") - { - z = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); - int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); - - if(a!=0 && z!=0) - { - ZAI zaitmp(z, a, i); - vector<double> XSTime; - for(int i = 0; i < (int)vT.size(); i++) - { long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); - XSTime.push_back(q); - } - mapN2Ntmp.insert( pair<ZAI,vector<double> >(zaitmp,XSTime)); - } - } - getline(DecayDB, line); - start = 0; - tmp2 = StringLine::NextWord(line, start, ' '); - - if(line == "") break; - }while (!DecayDB.eof() ); - - fXSFis.push_back(mapFistmp); - fXSCap.push_back(mapCaptmp); - fXSN2N.push_back(mapN2Ntmp); - - DecayDB.close(); - - double N = 0; - for(int i=0; i < (int)Z.size()-2; i++) - { - if( Z[i]>89 ) - N += Q[i]; - } - - - IsotopicVector CompoBasei; - - for(int i=0; i < (int)Z.size()-2; i++) - { - if(Z[i]>89) - { - ZAI zai = ZAI(Z[i], A[i], I[i]); - CompoBasei.IVquantity.insert(pair<ZAI,double>(zai,Q[i]/N)); - } - } - - fActinideCompoInit.push_back(CompoBasei); - -GoodJobName.push_back(jobname); - -} -/*------------------------------------------------------------------------------------------------- -COMPILATION : - -g++ -o Gene Gene.cxx `root-config --cflags` `root-config --libs` - -*/ \ No newline at end of file diff --git a/Utils/XSM/MLP/BuildInput/Gene.hxx b/Utils/XSM/MLP/BuildInput/Gene.hxx deleted file mode 100755 index 11d75520f759ced76e8497ee4273b5aceed79291..0000000000000000000000000000000000000000 --- a/Utils/XSM/MLP/BuildInput/Gene.hxx +++ /dev/null @@ -1,53 +0,0 @@ -#include "ZAI.hxx" -#include <TGraph.h> -#include <TGraph.h> - -#include <vector> -#include <stdio.h> -#include <stdlib.h> -#include <iostream> -#include <fstream> -#include <sstream> -#include <string> -#include <vector> -#include <sstream> -#include <cmath> -#include <map> -#include <iostream> -#include <iomanip> -using namespace std; - -string dtoa(double num) -{ - ostringstream os(ostringstream::out); - os<<setprecision(3)<<num; - return os.str(); -} - -string FilePath; -string DataPath; - -map<ZAI, double> ZAImass; -vector<string> JobName; -vector<string> GoodJobName; - -vector<double> fTime; //Time vector of the depletion calculation (second) -vector<ZAI> fAllNuclei; //All the nuclei present in the fuel - -vector< map < ZAI, vector<double> > > fXSFis; // map of fission cross section fXSFis[NumberOfTheEvolution][ZAI][TimeStep] -vector< map < ZAI, vector<double> > > fXSCap; -vector< map < ZAI, vector<double> > > fXSN2N; - -vector<IsotopicVector> fActinideCompoInit; //Fresh fuel composition - -int fNOfTimeStep=0; //number of time step in the Evolution - -string fEvolutionDataFolder = ""; - -bool fIsAllNucleiAlreadyFill=false; - -void InitMass(); -void CheckJob(); -void ReadAndFill(string jobname); -void DumpForTestingNeuron(string filename); -void DumpInputNeuron(string filename); \ No newline at end of file diff --git a/Utils/XSM/MLP/BuildInput/StringLine.hxx b/Utils/XSM/MLP/BuildInput/StringLine.hxx deleted file mode 100755 index da8500370b840d6abebf1360b3593151b6dab9d7..0000000000000000000000000000000000000000 --- a/Utils/XSM/MLP/BuildInput/StringLine.hxx +++ /dev/null @@ -1,275 +0,0 @@ -#ifndef _STRINGLINE_ -#define _STRINGLINE_ - -#include <string> -#include <sstream> -#include <iostream> -#include <algorithm> -#include <cctype> -using namespace std; -/*! - \file - \brief Header file for StingLine class. -*/ - -// Class extracting fields from a string / line. -/*! - The aim of this class is to provide tools to extract fields ("word") from - a string and convert a string in Upper/Lower case. - All methods are static so that it is not necessary to create object to use them - - example: - \code - string line="The temperature is : 300.6 K"; - int start; - - 1st method: creation of StringLine - - start=0; - StringLine SL; - string the=SL.NextWord(line,start); - string temperature_is=SL.NextWord(line,start,':'); - string colon=SL.NextWord(line,start); - double T=atof(SL.NextWord(line,start).c_str()); - cout<<the<<endl<<temperature_is<<endl<<T<<endl; - - 2nd method: "using" the static methods - - start=0; - the=StringLine::NextWord(line,start); - temperature_is=StringLine::NextWord(line,start,':'); - colon=StringLine::NextWord(line,start); - T=atof(StringLine::NextWord(line,start).c_str()); - cout<<the<<endl<<temperature_is<<endl<<T<<endl; - \endcode - @author PTO - @version 0.1 -*/ - -class StringLine -{ - public: - // Find the next word in a line. - /*! - Find Next word in a line starting from position "start" in the line. If an alternative - separator is given, the word length is defined by the first position of sep or alt_sep found. - The first value of start is in general 0 (i.e. the beginning of the Line) - \param Line : a line containing words - \param start : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static string NextWord(string Line,int &start,char sep=' ', char alt_sep='\0'); - // Find the previous word in a line. - /*! - Find Previous word in a line starting from position "start" in the line. If an alternative - separator is given, the word length is defined by the first position of sep or alt_sep found. - The first value of start is in general the end of the Line. - \param Line : a line containing words - \param start : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static string PreviousWord(string Line,int &start,char sep=' ', char alt_sep='\0'); - static void ToLower(string &Line); // convert a string to Lower case - static void ToUpper(string &Line); // convert a string to Upper case - - // Find \p search in \p Line from the begining. - /*! - returns the position, starting from the begenning of the first occurence - of \p search in \p Line if it is found, else returns -1 - \param search : a string to find - \param Line : where to search - */ - static int Find(const char *search,string Line); - // Find \p search in \p Line from the end. - /*! - returns the position, starting from the end of the first occurence - of \p search in \p Line if it is found, else returns -1 - \param search : a string to find - \param Line : where to search - */ - static int rFind(const char *search,string Line); - // convert a input type (\p in_T) to another (\p out_T). - /*! - Example: - \code - string s="32.12"; - double t=StringLine::convert<double>(s); - string temperature=StringLine::convert<string>(300.); - \endcode - \param t : the input value - */ - template <class out_T, class in_T> static out_T convert(const in_T & t); - // Find the start of a word in a line. - /*! - \param Line : a line containing words - \param CurrentPosition : from where to start to find the begining of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static int GetStartWord(string Line,int CurrentPosition,char sep=' ', char alt_sep='\0'); - // Find the end of a word in a line. - /*! - \param Line : a line containing words - \param CurrentPosition : from where to start to find the end of a word - \param sep : the separator between 2 words (default=space) - \param alt_sep : the alternative separator between 2 words (default='') - */ - static int GetEndWord(string Line,int CurrentPosition,char sep=' ', char alt_sep='\0'); - // Replace a sub-string by an other in a string. - /*! - \param InLine : the string which contains the sub-string to replace - \param ToReplace : the sub-string to replace - \param By : the sub-string ToReplace is replaced by the sub-string By in Inline - */ - string ReplaceAll(string InLine, string ToReplace, string By); -}; - - -//_________________________________________________________________________________ -inline string StringLine::NextWord(string Line,int &start,char sep, char alt_sep) -{ - string Word=""; - if(start>=int(Line.size())) - { - return Word; - } - start=GetStartWord(Line,start,sep,alt_sep); - int wordlength=GetEndWord(Line,start,sep,alt_sep)-start; - - Word=Line.substr(start,wordlength); - - start+=wordlength; - return Word; -} -//_________________________________________________________________________________ -inline string StringLine::PreviousWord(string Line,int &start,char sep, char alt_sep) -{ - string Word=""; - if(start<=0) - { - return Word; - } - int pos=Line.rfind(sep,start); - int alt_pos=-1; - int real_pos=pos; - char real_sep=sep; - if(alt_sep!='\0') - { - alt_pos=Line.rfind(alt_sep,start); - real_pos=max(pos,alt_pos); - if(real_pos!=pos) - real_sep=alt_sep; - } - int wordlength=start-Line.rfind(real_sep,real_pos); - if(real_pos<=0) - { - Word=Line.substr(0,start+1); - start=0; - return Word; - } - Word=Line.substr(real_pos+1,wordlength); - - start-=wordlength+1; - return Word; -} - -//_________________________________________________________________________________ -inline void StringLine::ToLower(string &Line) -{ - transform (Line.begin(), Line.end(), // source - Line.begin(), // destination - (int(*)(int))tolower); // operation -} - -//_________________________________________________________________________________ -inline void StringLine::ToUpper(string &Line) -{ - transform (Line.begin(), Line.end(), // source - Line.begin(), // destination - (int(*)(int))toupper); // operation -} - -//_________________________________________________________________________________ -inline int StringLine::GetStartWord(string Line,int CurrentPosition,char sep, char alt_sep) -{ - int pos=Line.find(sep,CurrentPosition); - int alt_pos=-1; - if(alt_sep!='\0') - alt_pos=Line.find(alt_sep,CurrentPosition); - int real_pos=pos; - char real_sep=sep; - if(alt_pos>=0) - { - real_pos=min(pos,alt_pos); - if(pos==int(string::npos))real_pos=alt_pos; - if(real_pos!=pos) - real_sep=alt_sep; - } - if(real_pos==int(string::npos)) return CurrentPosition; - while(CurrentPosition<int(Line.size()) && Line[CurrentPosition]==real_sep) - CurrentPosition++; - return CurrentPosition; -} - -//_________________________________________________________________________________ -inline int StringLine::GetEndWord(string Line,int CurrentPosition,char sep, char alt_sep) -{ - int pos=Line.find(sep,CurrentPosition); - int alt_pos=-1; - if(alt_sep!='\0') - alt_pos=Line.find(alt_sep,CurrentPosition); - int real_pos=pos; - if(alt_pos>=0) - { - real_pos=min(pos,alt_pos); - if(pos==int(string::npos))real_pos=alt_pos; - } - if(real_pos==int(string::npos)) - return Line.size(); - return real_pos; -} - -//_________________________________________________________________________________ -inline int StringLine::Find(const char *search,string Line) -{ - size_t Pos=Line.find(search); - if(Pos != string::npos ) return Pos; - return -1; -} - -//_________________________________________________________________________________ -inline int StringLine::rFind(const char *search,string Line) -{ - size_t Pos=Line.rfind(search); - if(Pos != string::npos) return Pos; - return -1; -} - -//_________________________________________________________________________________ -template <class out_T, class in_T> -inline out_T StringLine::convert(const in_T & t) -{ - stringstream stream; - stream << t; // insert value to stream - out_T result; // store conversion's result here - stream >> result; // write value to result - return result; -} - -//_________________________________________________________________________________ -inline string StringLine::ReplaceAll(string InLine, string ToReplace, string By) -{ - int start=0; - int pos=InLine.find(ToReplace,start); - while(pos!=int(string::npos)) - { - InLine.replace(pos,ToReplace.size(),By); - start=0; - pos=InLine.find(ToReplace,start); - } - return InLine; - -} -#endif diff --git a/Utils/XSM/MLP/BuildInput/ZAI.hxx b/Utils/XSM/MLP/BuildInput/ZAI.hxx deleted file mode 100755 index 1ee9136f9231fdadd328a009579e46ea9d6d6c6b..0000000000000000000000000000000000000000 --- a/Utils/XSM/MLP/BuildInput/ZAI.hxx +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef MN_ZAI_H_ -#define MN_ZAI_H_ - -#include <map> -using namespace std; - -class ZAI { - public : - int Z; - int A; - int I; - - - ZAI(int z, int a, int i=0) { Z=z;A=a; I=i;} - - bool operator <(const ZAI& zai) const {return (Z != zai.Z)? - (Z < zai.Z) : ( (A != zai.A)? - (A < zai.A) : (I < zai.I) );} -}; - -class IsotopicVector { - public : - - IsotopicVector() {} ///< Normal Constructor. - ~IsotopicVector() {}; ///< Normal Destructor. - double GetZAIIsotopicQuantity(const ZAI& zai) const - { - map<ZAI ,double> IsotopicQuantity = IVquantity; - - map<ZAI ,double>::iterator it; - it = IsotopicQuantity.find(zai); - - if ( it != IsotopicQuantity.end() ) - return it->second; - else - return 0; - } - map<ZAI,double> IVquantity; - double MASS; -}; - -#endif //MN_ZAI_H_ diff --git a/Utils/XSM/MLP/Generate/Generate_XSM.cxx b/Utils/XSM/MLP/Generate/Generate_XSM.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f241ca401c0780dbd29a2ae037330cdc5b0b678f --- /dev/null +++ b/Utils/XSM/MLP/Generate/Generate_XSM.cxx @@ -0,0 +1,1135 @@ +/**********************************************************/ +// Make the input file for the MLPs training +// +// This programs reads a set of .dat files which are the +// results of a depletion calculation (see manual and +// looks for XS_CLOSEST). From the reading it fills a +// TTree (Data) and write it in a file named +// TrainingInput.root . +// OUTPUTS : +// 1- File TrainingInput.cxx is the list of MLP outputs +// (cross sections) +// 2- File TrainingInput.root input datas (as a Root TTREE) for MLP training +// 3- File Data_Base_Info.nfo Information file to be red by XSM_MLP +// (to be place in the weight folder which is build by MLP training) +// +//@author BaM, BaL +/**********************************************************/ +#include "include/Generate_XSM.hxx" +#include <TH1F.h> +#include <TH2D.h> +#include <TFile.h> +#include <TTree.h> +#include "../../../../source/external/StringLine.hxx" +#include <TString.h> +#include <string> +#include <cmath> +#include <math.h> +#include <iostream> +#include <fstream> +#include <algorithm> +#include <map> +#include <sstream> +#include <numeric> +#include <functional> +#include <algorithm> +#include <ctime> + +using namespace std; + +ZAIMass cZAIMass; //atomic masses + +string ElNames[110]={" ","H","He","Li","Be", + "B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar", + "K","Ca","Sc","Ti","V ","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge", + "As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd", + "Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd", + "Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W", + "Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra", + "Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No", + "Lr","Rf","Db","Sg","Bh","Hs","Mt"}; + +//-------------------------------------------------------------------------------------------------- +/************************* + MAIN +*************************/ +int main(int argc, char ** argv){ + + if(argc!=2) + { + cout << "Usage : Generate_XSM Path" << endl; + cout << " Where Path is the path to the folder containing Evolution Datas" << endl; + cout << " i.e the (.dat) files" << endl; + exit(0); + } + + /*****************Preparation of working folders*************************/ + if(is_file_exist("Training_output_0.root" )) + { + cout<< "Trainining_output* detected. Delete these files and weights folder ? [y/n]"<<endl; + if(UserSayYes()) + system( "rm -rf Training_output* weights" ); + else + { cout << "Move this files elsewhere and run this program again"<<endl; + exit(0); + } + } + + if(is_file_exist("_tmp/include_Train_XS/TrainingInput.cxx" )) + system( "rm -rf _tmp" ); + + system("mkdir -p _tmp/scripts/subatech"); + system("mkdir -p _tmp/include_Train_XS"); + /**********************************************************************/ + + fEvolutionDataFolder = argv[1]; + CheckJob(); // looks fot the .dat files in the fEvolutionDataFolder + + cout << endl; + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ Load your EvolutionDatas to R.A.M │" << endl; + cout << "╰───────────────────────────────────────────────╯" << endl; + cout<<endl; + for(int i = 0; i < (int)JobName.size(); i++) + { + ReadAndFill(JobName[i]); + ProgressBar(i,JobName.size()); + } + ProgressBar(1,1); + + FillMapName(); + + cout << "Proportion of data to be used for training ? [0-100]" <<endl; + double ProportionOfTraining = 0 ; + cin >> ProportionOfTraining ; + DumpInputNeuron("_tmp/include_Train_XS/TrainingInput.root"); + Generate_tmva_factory_input(ProportionOfTraining); + + CreateInfoFile(); + + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ GENERATED FILES: │" << endl; + cout << "├─────────────────────────────────────────────────────────────────────┤" << endl; + cout << "│#1 Input for TMVA training: \033[36m_tmp/include_Train_XS/TrainingInput.root\033[0m │" << endl; + cout << "│#2 Target names for TMVA: \033[36m_tmp/include_Train_XS/TrainingInput.cxx\033[0m │" << endl; + cout << "│#3 Model Information for CLASS: \033[36mData_Base_Info.nfo\033[0m │" << endl; + cout << "╰─────────────────────────────────────────────────────────────────────╯" << endl; + cout << endl; + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ NEXT STEPS: │" << endl; + cout << "├────────────────────────────────────────────────┤" << endl; + cout << "│1. Train your MLPs with \033[36mTrain_XS.cxx\033[0m │" << endl; + cout << "│2. Test MLPs performances using informations in:│" << endl; + cout << "│ \033[36m../Test/EvaluateTrainingCommands.dat\033[0m│" << endl; + cout << "│3. Put the file #3 in \033[36mweights\033[0m folder then │" << endl; + cout << "│ move this folder to $CLASS_PATH/DATA_BASES │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + cout << endl; + cout << "=> Doing this steps for you. Do you want to train the MLPs on your local machine on one cpu ? It can take a while. [y/n]" << endl; + + if(UserSayYes()) + { + GenerateScript_Sequential(0,fReactionCounter,"_tmp/scripts/Run_Sequential.sh"); + CompileTraining(); + cout << "Let's train locally ? [y/n]" <<endl; + if(UserSayYes()) + Run_Sequential(); + else + { + cout << "You can run _tmp/scripts/Run_Sequential.sh later. Then read the following : "<<endl; + PrintFinalSteps(); + exit(0); + } + } + else + { + cout << "Ok so you want to run on a grid ? [y/n]" << endl; + if(UserSayYes()) + { + + int Threads = 4; + cout << "On how many threads you want to run training ?" <<endl; + cin >> Threads; + GenerateScript_Parallel(Threads); + cout << "Are you a Researcher from Subatech ? [y/n] " << endl; + if(UserSayYes()) + { + GenrateZubaScript(Threads); + PrintFinalSteps(); + } + else + { + cout << "Nobody is perfect ... RUN THE SCRIPTS located in folder \"_tmp/scripts\" using your job submission program (e.g qsub)" << endl; + cout << "Once training are finished follow the following steps :" << endl; + PrintFinalSteps(); + } + + + } + else + cout <<" Ok , so follow advices in \"NEXT STEPS:\" " <<endl; + + } + + + +} +//-------------------------------------------------------------------------------------------------- +void GenrateZubaScript(int threads) +{ + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ GENERATE QSUB SCRIPT FOR SUBATECH NANSL │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + + string filepath = "_tmp/scripts/subatech/RunOnSubaGrid.sh"; + + if(is_file_exist(filepath.c_str())) + system( ("rm " + filepath).c_str() ); + + ofstream Script(filepath.c_str()); + Script << "#!/bin/bash" << endl; + Script << "cd .." << endl; + Script << "max_job=$((40))" << endl; + Script << "user=$(whoami)" << endl; + Script << "job=$((0))" << endl; + Script << "launchedjob=$((0))" << endl; + Script << "currentJob=$((0))" << endl; + Script << " for ((file=$((0)); file<$(("<< threads <<")); file=file+1 )) ;" << endl; + Script << " do " << endl; + Script << " Job_Launched=$((0))" << endl; + Script << " while [ $Job_Launched -lt 1 ]" << endl; + Script << " do" << endl; + Script << " launchedjob=$(( `qstat -u ${user} | grep \" R \" |grep \"XSM_MLP_Training_\" | wc -l `))" << endl; + Script << " jobinactive=$(( `qstat | grep ${user} | grep \" Q \" | wc -l `))" << endl; + Script << " if [ $jobinactive -lt 5 ] ; then" << endl; + Script << " ../../include/QSUB -n \"XSM_MLP_Training_${currentJob}\" -c \"./Run_Parallel_${currentJob}.sh\"" << endl; + Script << " Job_Launched=$(( $Job_Launched +1 ))" << endl; + Script << " currentJob=$(( $currentJob + 1 ))" << endl; + Script << " sleep 5s" << endl; + Script << " else" << endl; + Script << " if [ $launchedjob -lt $max_job ]; then" << endl; + Script << " sleep 1m" << endl; + Script << " else" << endl; + Script << " sleep 5m" << endl; + Script << " fi" << endl; + Script << " fi" << endl; + Script << " done" << endl; + Script << "done" << endl; + Script << "cd -" << endl; + Script.close(); + + string CMD = "chmod u+x " + filepath ; + cout << CMD <<endl; + system(CMD.c_str()); + + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ RUN ON NANSL GRID │" << endl; + cout << "│1.Syncrhonise your Utils folder and ssh to nansl3 │" << endl; + cout << "│2. type : cd _tmp/scripts/subatech/ │" << endl; + cout << "│3. then nohup ./RunOnSubaGrid.sh > LogFile.log & │" << endl; + cout << "│3. wait │" << endl; + cout << "╰──────────────────────────────────────────────────────────────────╯" << endl; + + + +} + +//-------------------------------------------------------------------------------------------------- +void PrintFinalSteps() +{ + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ NEXT STEPS: │" << endl; + cout << "├───────────────────────────────────────────────────────┤" << endl; + cout << "│1.(optional) Test MLPs performances using │" << endl; + cout << "│ informations in: │" << endl; + cout << "│ \033[36m../Test/EvaluateTrainingCommands.dat\033[0m │" << endl; + cout << "│2. Put the file \033[36mData_Base_Info.nfo\033[0m in \033[36mweights\033[0m then │" << endl; + cout << "│ mkdir -p $CLASS_PATH/DATA_BASES/"<<fReactorType<<"/"<<fFuelType << "/XSModel/ChooseAName │" << endl; + cout << "│ mv weights $CLASS_PATH/DATA_BASES/"<<fReactorType<<"/"<<fFuelType << "/XSModel/ChooseAName│" << endl; + cout << "╰───────────────────────────────────────────────────────╯" << endl; +} + +//-------------------------------------------------------------------------------------------------- +void Run_Sequential() +{ + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ RUNNING TRAINING ON ONE CPU (Please wait) │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + + system("cd _tmp/scripts/ ; ./Run_Sequential.sh ; cd -"); + + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ TRAINING FINISHED │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + + +} +//-------------------------------------------------------------------------------------------------- +bool is_file_exist(const char *fileName) +{ + std::ifstream infile(fileName); + return infile.good(); +} +//-------------------------------------------------------------------------------------------------- +void CompileTraining() +{ + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ COMPLILING TMVA TRAINING PROGRAM │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + if(is_file_exist("Train_XS")) + system("rm Train_XS "); + + string CMD = "g++ -o Train_XS `root-config --cflags` Train_XS.cxx `root-config --glibs` -lTMVA"; + cout << CMD <<endl; + system(CMD.c_str()); + + if(!is_file_exist("Train_XS")) + { + cout <<"\033[31m COMPILATION FAILED !!! May be not the good compilator name nor the good path of file to compile ? \033[0m " << endl; + exit(1); + } + else + cout <<"\t \033[32m Done \033[0m " << endl; + + +} + +//-------------------------------------------------------------------------------------------------- +void GenerateScript_Parallel(int threads) +{ + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ GENERATE BASH SCRIPTS FOR PARALLEL TRAINING │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + + double JobPerProcessor = double (fReactionCounter) / double (threads); + int JobPerProcessor_IntegerPart = floor(JobPerProcessor); + double Rest = (JobPerProcessor - JobPerProcessor_IntegerPart) * threads; + + for (int proc = 0 ; proc < threads -1 ; proc++) + { + stringstream ssScriptName ; + ssScriptName<< "_tmp/scripts/Run_Parallel_" <<proc <<".sh"; + GenerateScript_Sequential( proc * JobPerProcessor_IntegerPart , (proc + 1) * JobPerProcessor_IntegerPart - 1 ,ssScriptName.str().c_str(),false); + } + + stringstream ssScriptName ; + ssScriptName<< "_tmp/scripts/Run_Parallel_" << threads-1 <<".sh"; + if (Rest > 0) + GenerateScript_Sequential( (threads-1) * JobPerProcessor_IntegerPart , threads * JobPerProcessor_IntegerPart + Rest , ssScriptName.str().c_str(),false); + + else + GenerateScript_Sequential( (threads-1) * JobPerProcessor_IntegerPart , threads * JobPerProcessor_IntegerPart + Rest , ssScriptName.str().c_str(),false); + + cout << "\t \033[32m => Scripts buit in _tmp/scripts \033[0m " << endl; + +} + +//-------------------------------------------------------------------------------------------------- +void GenerateScript_Sequential(int begin, int end, string filepath ,bool print) +{ + + if(print) + { + cout << "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®" << endl; + cout << "│ GENERATE BASH SCRIPT FOR SEQUENTIAL TRAINING │" << endl; + cout << "╰────────────────────────────────────────────────╯" << endl; + } + + ofstream Script(filepath.c_str()); + Script << "#!/bin/bash" << endl; + Script <<endl; + Script << "# Script to train MLPs" << endl; + Script << "#@author BaL" << endl; + Script << "#" << endl; + Script << endl; + Script << "cd ../.."<<endl; + Script << "echo \"----------------------------------\"" << endl; + Script << "echo \"--- Run Training from MLP " << begin<< " to " << end << "---\"" << endl; + Script << "echo \"----------------------------------\"" << endl; + Script << endl; + Script << "Start=$(("<< begin << "))" << endl; + Script << "End=$((" << end+1 << "))" << endl; + Script << endl; + Script << "for ((reaction=$Start; reaction<$End; reaction=reaction+1 )) ;"<< endl; + Script << "do"<<endl; + Script << " ./Train_XS $reaction"<< endl; + Script << "done" << endl; + Script << "cd -"<<endl; + + Script.close(); + + stringstream ssCMD ; + ssCMD << "chmod u+x "<< filepath <<endl; + cout << ssCMD.str() << endl; + + system(ssCMD.str().c_str()); + +} + +//-------------------------------------------------------------------------------------------------- +//Convert int to string +string itoa(int num) +{ + ostringstream os(ostringstream::out); + os << num; + return os.str(); +} +//-------------------------------------------------------------------------------------------------- +//Give a name to a cross section +//!!!!!!!!!!!!!!!!!!!!!!!!!!// +// YOU MUST KEEP THE FORMAT : +// XS_Z_A_I_fis (fission cross section) +// XS_Z_A_I_cap (n,gamma cross section) +// XS_Z_A_I_n2n (n,2n cross section) +//!!!!!!!!!!!!!!!!!!!!!!!!!!// +string NameXS(ZAI act,string xs) +{ + stringstream Name; + Name<<"XS_"<<act.Z<<"_"<<act.A<<"_"<<act.I<<"_"<<xs; + + return Name.str(); +} + +//-------------------------------------------------------------------------------------------------- +void FillMapName() +{ + cout<<endl; + cout<< "â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<<endl; + cout<< "│ SET UP MLPs INPUT │"<<endl; + cout<< "│default : composition @ t=0 + Irradiation time │"<<endl; + cout<< "╰───────────────────────────────────────────────╯"<<endl; + cout<<endl; + + vector<ZAI> ZAI_T0 = fActinideCompoInit[0].GetNonZeroZAIList(); + + for(int zai = 0 ; zai < ZAI_T0.size() ; zai++ ) + { stringstream ssname; + int Z = ZAI_T0[zai].Z; + int A = ZAI_T0[zai].A; + int I = ZAI_T0[zai].I; + string sI=""; + if(I == 1) + sI = "m"; + else if(I == 2) + sI = "2m"; + else if(I == 3) + sI = "3m"; + + ssname<<A<<ElNames[Z]<<sI; + if(zai == 0) + cout<< "Add this nuclei with this name [y/n] ? (if you don't know type yes to all) "<<endl; + else + cout<< "Add [y/n] ? "<<endl; + + cout<< "[Z\tA\tI\tName]"<<endl; + cout<<"\033[36m"<<Z<<"\t"<<A<<"\t"<<I<<"\t"<<ssname.str()<<"\033[0m"<<endl; + + if (UserSayYes()) + fMapName.insert(pair<ZAI,string> ( ZAI(Z,A,I) , ssname.str()) ); + + } + + bool UserWantToAdd = true; + while(UserWantToAdd) + { + cout<< "Do you want to add additional nuclei [y/n] ? (if you don't know type no) "<<endl; + if(UserSayYes()) + { + int Z = 0; + int A = 0; + int I = 0; + string Name; + cout << " Z -> "; cin >> Z ; cout <<" A -> "; cin >> A ; cout <<" I -> "; cin >> I ;cout <<" Name -> "; cin >> Name; + fMapName.insert(pair<ZAI,string> ( ZAI(Z,A,I) ,Name) ); + } + + else + UserWantToAdd = false; + } + + +} +//-------------------------------------------------------------------------------------------------- +void Generate_tmva_factory_input(double ProportionOfTraining) +{ + + ofstream InputNetwork("_tmp/include_Train_XS/InputVariables.cxx"); + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + InputNetwork <<"factory->AddVariable( \"" << it->second << "\" , \"" << it->second << "\", \"IsotopicFraction\", 'F' );"<<endl; + InputNetwork <<"factory->AddVariable( \"Time\" , \"Time\" , \"seconds\", 'F' );"<<endl<<endl; + + ProportionOfTraining /=100; + InputNetwork <<"double PropTraining = "<< ProportionOfTraining << endl; + + InputNetwork.close(); +} + +//-------------------------------------------------------------------------------------------------- +bool UserSayYes() +{ + bool AnswerIsNotGiven = true; + bool isYES = false; + while(AnswerIsNotGiven) + { + string answer; + std::getline(std::cin, answer); + + + if(answer == "y" || answer == "yes" || answer == "Yes" || answer == "Y") + { + isYES = true; + AnswerIsNotGiven = false; + } + else if (answer == "n" || answer == "no" || answer == "No" || answer == "N") + { + isYES = false; + AnswerIsNotGiven = false; + } + + else{ + cout << "Yes OR No ? "<<endl; + } + } + return isYES; +} + +//-------------------------------------------------------------------------------------------------- +void CreateInfoFile() +{ + + /**************************************************/ + // GETTING USER INFO + /**************************************************/ + double sum = 0 ; + for (int i=0 ; i < fHMMass.size() ; i++) + sum+=fHMMass[i]; + + double MeanHMMass = sum / (double)fHMMass.size(); + string Author,Mail,XSBase,HLCut,EnergyDisc,FPYBase,SABase,Geom,AddInfo,DepCode ; + double Power = 0; + + + int start=0; + string AnInfoFile = JobName[0]; + int pos=AnInfoFile.find(".dat",start); + AnInfoFile.replace(pos,4,".info"); + + ReadInfo(AnInfoFile,fReactorType,fFuelType,Power); + + cout<<endl; + cout<<endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<<endl; + cout<<"│ XSM_MLP .NFO FILE GENERATOR │"<<endl; + cout<<"╰───────────────────────────────────────────────╯"<<endl; + cout<<" Answer following questions "<<endl; + cout<<"-> Author(s) name(s) : "<<endl; + std::getline(std::cin, Author); + cout<<endl; + + cout<<"-> email adress(es) : "<<endl; + std::getline(std::cin, Mail); + cout<<endl; + + cout<<"-> Depletion code used : "<<endl; + std::getline(std::cin, DepCode); + cout<<endl; + + cout<<"-> Cross section data base (e.g ENSDF7.1) : "<<endl; + std::getline(std::cin, XSBase); + cout<<endl; + + cout<<"-> Fission yield data base (e.g ENSDF7.1) : "<<endl; + std::getline(std::cin, FPYBase); + cout<<endl; + + cout<<"-> S(alpha,beta) data base (e.g ENSDF7.1) : "<<endl; + std::getline(std::cin, SABase); + cout<<endl; + + cout<<"-> Geometry simulated (e.g Cubic Assembly with mirror boundary) : "<<endl; + std::getline(std::cin, Geom); + cout<<endl; + + cout<<"-> Half life cut [s] (if any) : "<<endl; + std::getline(std::cin, HLCut); + cout<<endl; + + cout<<"-> Multi group treatment (yes/no if yes give the number of groups) : "<<endl; + std::getline(std::cin, EnergyDisc); + cout<<endl; + + cout<<"-> Additional informations : "<<endl; + std::getline(std::cin, AddInfo); + cout<<endl; + + + cout<<"-> Reactor type (e.g PWR, FBR,...) : "<<endl; + cout<<"Found in a .info file :"<<endl; + cout<<"\033[36m"<<fReactorType<<"\033[0m"<<endl; + cout<< "Is that corect ? [y/n] "<<endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<<endl; + cin>> fReactorType; + } + cout<<endl; + + cout<<"-> Fuel type (e.g UOX, MOX,...) : "<<endl; + cout<<"Found in a .info file :"<<endl; + cout<<"\033[36m"<<fFuelType<<"\033[0m"<<endl; + cout<< "Is that corect ? [y/n] "<<endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<<endl; + cin>> fFuelType; + } + cout<<endl; + + cout<<"-> Simulated heavy metal mass (tons) : "<<endl; + cout<< "\t According your evolution datas the AVERAGE heavy metal mass is : "<<endl; + cout<<"\033[36m"<<MeanHMMass<<"\033[0m"<<" tons"<<endl; + cout<< "Is that corect ? [y/n] "<<endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<<endl; + cin>> MeanHMMass; + } + cout<<endl; + + cout<<"-> Simulated thermal power (W) : "<<endl; + cout<<"Found in a .info file :"<<endl; + cout<<"\033[36m"<<Power<<"\033[0m"<<endl; + cout<< "Is that corect ? [y/n] "<<endl; + if(!UserSayYes()) + { cout<<"\t So what it is ?"<<endl; + cin>> Power; + } + cout<<endl; + + /**************************************************/ + // BUILDING FILE + /**************************************************/ + ofstream InfoFile("Data_Base_Info.nfo"); + + InfoFile <<"============================================" << endl; + InfoFile <<" Informations needed by XSM_MLP model " <<endl; + InfoFile <<"============================================" << endl; + InfoFile << endl; + InfoFile << "Reactor Type :"<<endl; + InfoFile << "K_REACTOR "<< fReactorType <<endl; + InfoFile << endl; + InfoFile << "Fuel Type :"<<endl; + InfoFile << "K_FUEL "<< fFuelType <<endl; + InfoFile << endl; + InfoFile << "Heavy Metal [t] :"<<endl; + InfoFile << "K_MASS "<< MeanHMMass <<endl; + InfoFile << endl; + InfoFile << "Thermal Power [W] :"<<endl; + InfoFile << "K_POWER "<< Power <<endl; + InfoFile << endl; + InfoFile << "Irradiation time steps [s] :"<<endl; + InfoFile << "K_TIMESTEP"; + for( int t = 0 ; t < fNOfTimeStep[0] ; t++ ) /// DANGER IF NOT THE SAME TIME BINNING FOR EACH EVOLUTION DATA => Futher work : get the vector with the shortest irrariaiton time to avoid extrapolation in CLASS + InfoFile <<" "<<fTime[0][t]; + InfoFile << endl<<endl; + InfoFile << "Z A I Name (input MLP) :"<<endl; + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + InfoFile <<"K_ZAINAME "<<it->first.Z <<" " <<it->first.A <<" " <<it->first.I<<" " << it->second <<endl ; + InfoFile <<endl; + InfoFile << "Fuel range (Z A I min max) :"<<endl; + for(map<ZAI,string>::iterator it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { vector <double> AllCompoOfZAI = GetAllCompoOf(it->first); + vector <double>::iterator Min = std::min_element(AllCompoOfZAI.begin(),AllCompoOfZAI.end()); + vector <double>::iterator Max = std::max_element(AllCompoOfZAI.begin(),AllCompoOfZAI.end()); + InfoFile <<"K_ZAIL "<<it->first.Z <<" " <<it->first.A <<" " <<it->first.I<<" " << *Min << " " << *Max <<endl ; + } + InfoFile << endl; + InfoFile <<"============================================" << endl; + InfoFile <<" Data base generation informations " <<endl; + InfoFile <<"============================================" << endl; + InfoFile << endl; + time_t t = time(0); // get time now + struct tm * now = localtime( & t ); + InfoFile <<" Date: "<< now->tm_mday<< '/'<< (now->tm_mon + 1) << '/' <<(now->tm_year + 1900)<< endl; + InfoFile <<" Author(s): "<< Author <<endl; + InfoFile <<" Author(s) contact: "<< Mail <<endl; + InfoFile <<" Depletion code: "<< DepCode <<endl; + InfoFile <<" Simulated geometry: "<< Geom <<endl; + InfoFile <<" Nuclear data used in "<< DepCode <<endl; + InfoFile <<"\tCross section library: "<< XSBase <<endl; + InfoFile <<"\tFission yield library: "<< FPYBase <<endl; + InfoFile <<"\tS(alpha,beta) library: "<< SABase <<endl; + InfoFile <<" Half life cut [s] : "<< HLCut <<endl; + InfoFile <<" Multi-group treatment: "<< EnergyDisc <<endl; + InfoFile <<" Additional informations: "<< endl << AddInfo <<endl; + + +} +//-------------------------------------------------------------------------------------------------- +vector<double> GetAllCompoOf(ZAI zai) +{ + vector<double> AllCompoOfZAI; + + for( int b = 0 ; b < fActinideCompoInit.size() ; b++ ) + AllCompoOfZAI.push_back(fActinideCompoInit[b].GetZAIIsotopicQuantity(zai)); + +return AllCompoOfZAI; +} +//-------------------------------------------------------------------------------------------------- +void ProgressBar(double loopindex, double totalindex) +{ + // Reset the line + //for(int i = 0; i < 22; i++) + // cout << " "; + cout << flush ; + + cout << "\033[42m"; + for(int i = 0; i < (int)(loopindex/totalindex*44.0); i++) + cout << " "; + cout<<" \033[41m"; + for(int i = 44; i >= (int)(loopindex/totalindex*44.0); i--) + cout << " "; + cout<<"\033[0m"; + cout << (int)(loopindex/totalindex*100) << "%\r"; + cout << flush; + //cout << endl; +} +//-------------------------------------------------------------------------------------------------- +void ReadInfo(string InfoDBFile,string &ReactorType,string &FuelType,double &Power) +{ + ifstream InfoDB(InfoDBFile.c_str()); // Open the File + if(!InfoDB) + { + cout << "\033[31m !!ERROR!! !!!EvolutionData!!! \n Can't open \"" << InfoDBFile << "\"\033[0m \n" << endl; + } + else + { + int start = 0; + string line; + getline(InfoDB, line); + string Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "reactor") + ReactorType = StringLine::NextWord(line, start, ' '); + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "fueltype") + FuelType = StringLine::NextWord(line, start, ' '); + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "cycletime") + double cycletime = atof(StringLine::NextWord(line, start, ' ').c_str()); + + getline(InfoDB, line); // Assembly HM Mass DONT TRUST THIS ONE CALCULATED WITH A instead of real atomic mass + + start = 0; + getline(InfoDB, line); + Next = StringLine::NextWord(line, start, ' '); + StringLine::ToLower(Next) ; + if ( Next == "constantpower") + Power = atof(StringLine::NextWord(line, start, ' ').c_str()); + InfoDB.close(); + } + +} + + +//-------------------------------------------------------------------------------------------------- +void DumpInputNeuron(string filename) +{ + TFile* fOutFile = new TFile(filename.c_str(),"RECREATE"); + TTree* fOutT = new TTree("Data", "Data"); + + +/**********************INITIALISATIONNN********************/ + + //////////////////////////////////////////////////////// + // INIT FRESH FUEL COMPOSITION and TIME + //////////////////////////////////////////////////////// + + double *FreshCompo = new double[fMapName.size()]; + + for(int i = 0 ; i < fMapName.size() ; i++ ) + FreshCompo[i] = 0; + + //////////////////////////////////////////////////////// + double Time = 0; + +/**********************init map********************/ + map < ZAI,vector<double> > mAllXS; + //map < ZAI, vector<double> > mAllInventories; + //for(int act=0;act<int(fAllNuclei.size());act++ ) + //{ + // vector<double> InitVect; + // for(int Tstep=0 ;Tstep<fNOfTimeStep;Tstep++) + // { + // InitVect.push_back(0); + // } + // mAllInventories.insert( pair<ZAI,vector<double> >(fAllNuclei[act],InitVect) ); + //} + + for(int act=0;act<int(fAllNuclei.size());act++ ) + { + vector< double> InitVect; + for(int xs=0;xs<3;xs++) + { + + InitVect.push_back(0); + + } + + mAllXS.insert(pair<ZAI,vector< double> >(fAllNuclei[act], InitVect) ); + } + + +/**********************BRANCHING**************************************************/ +/**********************Fresh fuel**************************************************/ + + map<ZAI,string>::iterator it; + int index = 0; + for(it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { string Name = it->second + "/D"; + fOutT->Branch( it->second.c_str() , &FreshCompo[index] , Name.c_str()); + index++; + } + + //////////////////////////////////////////////////////// + fOutT->Branch( "Time" ,&Time ,"Time/D" ); + + +/**********************cross section**************************************************/ + + string XSType[3]={"fis","cap","n2n"}; //!!!!!!DO NOT TOUCH THIS + + for(int act=0;act<int(fAllNuclei.size());act++ ) + { + for(int xs=0;xs<3;xs++) + { + string NamedXS= NameXS(fAllNuclei[act],XSType[xs]); + string NameXSBis=NamedXS+"/D"; + + if( xs==0 && fXSFis[0][fAllNuclei[act]].size()!=0) //Check if the reaction we want to branch exists + if(fXSFis[0][fAllNuclei[act]][0]!=0) + fOutT->Branch( NamedXS.c_str() , &mAllXS[fAllNuclei[act]][xs], NameXSBis.c_str() ); + + if(xs==1 && fXSCap[0][fAllNuclei[act]].size()!=0) + if(fXSCap[0][fAllNuclei[act]][0]!=0) + fOutT->Branch( NamedXS.c_str() , &mAllXS[fAllNuclei[act]][xs], NameXSBis.c_str() ); + + if(xs==2 && fXSN2N[0][fAllNuclei[act]].size()!=0) + if(fXSN2N[0][fAllNuclei[act]][0]!=0) + fOutT->Branch( NamedXS.c_str() , &mAllXS[fAllNuclei[act]][xs], NameXSBis.c_str() ); + + + } + } +/**********************FILLING THE TTREE**************************************************/ + cout<<endl; + cout<<endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<<endl; + cout<<"│ FILLING TTREE │"<<endl; + cout<<"│ (building TrainingInput.root) │"<<endl; + cout<<"╰───────────────────────────────────────────────╯"<<endl; + cout<<endl; + //File containing all the output of the networks to train + ofstream InputNetwork("_tmp/include_Train_XS/TrainingInput.cxx"); + + int NumOfBase=fActinideCompoInit.size(); + for(int b=0;b<NumOfBase;b++) + { + + ProgressBar(b,NumOfBase); + + /////////////////////////////////////////////////////// + int index =0; + for(it = fMapName.begin() ; it != fMapName.end() ; it++ ) + { + int Z = it->first.Z; + int A = it->first.A; + int I = it->first.I; + FreshCompo[index] = fActinideCompoInit[b].GetZAIIsotopicQuantity(ZAI(Z,A,I)); + + index++; + } + /////////////////////////////////////////////////////// + + for(int Tstep=0 ;Tstep<fNOfTimeStep[b];Tstep++ ) + { + Time=fTime[b][Tstep]; + for(int act=0;act<int(fAllNuclei.size());act++) + { + + if(fXSFis[b][fAllNuclei[act]].size()!=0) // reaction may not be present + { + if(fXSFis[b][fAllNuclei[act]][Tstep] !=0 ) + { mAllXS[fAllNuclei[act]][0] = fXSFis[b][fAllNuclei[act]][Tstep]; + if(b==0 && Tstep==0){ + InputNetwork<<"OUTPUT.push_back(\""<<NameXS(fAllNuclei[act],XSType[0])<<"\");"<<endl; + fReactionCounter++; + } + } + } + if(fXSCap[b][fAllNuclei[act]].size()!=0) + { + if(fXSCap[b][fAllNuclei[act]][Tstep] !=0) + { mAllXS[fAllNuclei[act]][1] = fXSCap[b][fAllNuclei[act]][Tstep]; + if(b==0 && Tstep==0){ + InputNetwork<<"OUTPUT.push_back(\""<<NameXS(fAllNuclei[act],XSType[1])<<"\");"<<endl; + fReactionCounter++; + } + } + } + if( fXSN2N[b][fAllNuclei[act]].size()!=0) + { + if(fXSN2N[b][fAllNuclei[act]][Tstep] !=0) + { mAllXS[fAllNuclei[act]][2] = fXSN2N[b][fAllNuclei[act]][Tstep]; + if(b==0 && Tstep==0){ + InputNetwork<<"OUTPUT.push_back(\""<<NameXS(fAllNuclei[act],XSType[2])<<"\");"<<endl; + fReactionCounter++; + } + } + } + + } + fOutT->Fill(); + } + } + ProgressBar(1,1); + + fOutFile->Write(); + delete fOutT; + fOutFile-> Close(); + delete fOutFile; + +} + +//-------------------------------------------------------------------------------------------------- +void CheckJob() +{ //LOAD THE LIST OF EvolutionData + + cout<<endl; + cout<<"â•â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â•®"<<endl; + cout<<" Scanning : "<<endl; + cout<< fEvolutionDataFolder <<endl; + cout<<" for EvolutionData (.dat files) "<<endl; + cout<<"╰───────────────────────────────────────────────╯"<<endl; + + string Command = "find "+ fEvolutionDataFolder + " -name \"*.dat\" > JOB.tmp"; + system(Command.c_str()); + + ifstream JOB("JOB.tmp"); + + if(JOB.peek() == std::ifstream::traits_type::eof()) // if file is empty + { cout << endl << "\033[31mERROR: No .dat found in folder : " << fEvolutionDataFolder << "\033[0m" << endl; + exit(1); + } + + if (JOB.is_open()) + { + while (!JOB.eof()) + { + string tmp; + getline(JOB,tmp); + JobName.push_back(tmp); + } + } JOB.close(); JobName.pop_back(); + + // Remove temporary files... + Command = "\\rm -f JOB.tmp"; + system(Command.c_str()); + random_shuffle(JobName.begin(), JobName.end()); + cout << "\033[32m Scan complete \033[0m" <<endl; +} + +//-------------------------------------------------------------------------------------------------- +void ReadAndFill(string jobname) +{ //Read a .dat file and fill XS maps and the fuel initial composition + + vector<double> vT; + vector<int> Z; + vector<int> A; + vector<int> I; + vector<double> Q; + + ifstream DecayDB(jobname.c_str()); // Open the File + if(!DecayDB) + { + cout << "\033[33m !!Warning!! !!!EvolutiveProduct!!! \n Can't open \"" << jobname << "\"\033[0m\n" << endl; + } + + string line; + int start = 0; + + getline(DecayDB, line); + + /******Getting Time vecotr ....******/ + if( StringLine::NextWord(line, start, ' ') != "time") + { + cout << "\033[31m!!Bad Trouble!! !!!EvolutiveProduct!!! Bad Database file : " << jobname << "\033[0m" << endl; + exit (1); + } + + while(start < (int)line.size()) + vT.push_back(atof(StringLine::NextWord(line, start, ' ').c_str())); + + fTime.push_back(vT); + + fNOfTimeStep.push_back(int(vT.size())); + /****Getting Inventories***/ + getline(DecayDB, line); + do + { + start = 0; + int z; + string tmp2 = StringLine::NextWord(line, start, ' '); + if (tmp2 == "Inv") { + z = atoi(StringLine::NextWord(line, start, ' ').c_str()); + } + else z = atoi(tmp2.c_str()); + int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); + + if(a!=0 && z!=0) + { + + ZAI zaitmp(z, a, i); + Z.push_back(z); + A.push_back(a); + I.push_back(i); + if(!fIsAllNucleiAlreadyFill) + { + fAllNuclei.push_back(zaitmp); + } + + long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); + Q.push_back(q); + + } + + getline(DecayDB, line); + start = 0; + tmp2 = StringLine::NextWord(line, start, ' '); + + if(line == "" || line == "CrossSection" || tmp2 == "XSFis" || tmp2 == "XSCap" || tmp2 == "XSn2n") break; + }while (!DecayDB.eof() ); + + if(fAllNuclei.size()!=0) + fIsAllNucleiAlreadyFill=true; + + //XS + map<ZAI, vector <double> > mapFistmp; + map<ZAI, vector <double> > mapCaptmp; + map<ZAI, vector <double> > mapN2Ntmp; + do + { + + start = 0; + int z; + string tmp2 = StringLine::NextWord(line, start, ' '); + if (tmp2 == "XSFis") + { + z = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); + + if(a!=0 && z!=0) + { + + ZAI zaitmp(z, a, i); + + vector<double> XSTime; + for(int i = 0; i < (int)vT.size(); i++) + { long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); + XSTime.push_back(q); + } + mapFistmp.insert( pair<ZAI,vector<double> >(zaitmp,XSTime)); + } + } + else if (tmp2 == "XSCap") + { + z = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); + + if(a!=0 && z!=0) + { + + ZAI zaitmp(z, a, i); + vector<double> XSTime; + for(int i = 0; i < (int)vT.size(); i++) + { long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); + XSTime.push_back(q); + } + mapCaptmp.insert( pair<ZAI,vector<double> >(zaitmp,XSTime)); + + } + } + else if (tmp2 == "XSn2n") + { + z = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int a = atoi(StringLine::NextWord(line, start, ' ').c_str()); + int i = atoi(StringLine::NextWord(line, start, ' ').c_str()); + + if(a!=0 && z!=0) + { + ZAI zaitmp(z, a, i); + vector<double> XSTime; + for(int i = 0; i < (int)vT.size(); i++) + { long double q = atof(StringLine::NextWord(line, start, ' ').c_str()); + XSTime.push_back(q); + } + mapN2Ntmp.insert( pair<ZAI,vector<double> >(zaitmp,XSTime)); + } + } + getline(DecayDB, line); + start = 0; + tmp2 = StringLine::NextWord(line, start, ' '); + + if(line == "") break; + }while (!DecayDB.eof() ); + + fXSFis.push_back(mapFistmp); + fXSCap.push_back(mapCaptmp); + fXSN2N.push_back(mapN2Ntmp); + + DecayDB.close(); + + double N = 0; + for(int i=0; i < (int)Z.size()-2; i++) + { + if( Z[i]>89 ) + N += Q[i]; + } + + + IsotopicVector CompoBasei; + IsotopicVector CompoBaseiUnormalize; + + for(int i=0; i < (int)Z.size()-2; i++) + { + if(Z[i]>89) + { + ZAI zai = ZAI(Z[i], A[i], I[i]); + CompoBasei.IVquantity.insert(pair<ZAI,double>(zai,Q[i]/N)); + CompoBaseiUnormalize.IVquantity.insert(pair<ZAI,double>(zai,Q[i])); + } + } + + fActinideCompoInit.push_back(CompoBasei); + double MassOfThisFuel = cZAIMass.GetMass(CompoBaseiUnormalize); + //cout<<MassOfThisFuel<<endl; + fHMMass.push_back(MassOfThisFuel); + +GoodJobName.push_back(jobname); + +} +/*------------------------------------------------------------------------------------------------- +COMPILATION : + +g++ -o Generate_XSM Generate_XSM.cxx `root-config --cflags` `root-config --libs` + + +*/ diff --git a/Utils/XSM/MLP/Train/Train_XS.cxx b/Utils/XSM/MLP/Generate/Train_XS.cxx old mode 100755 new mode 100644 similarity index 78% rename from Utils/XSM/MLP/Train/Train_XS.cxx rename to Utils/XSM/MLP/Generate/Train_XS.cxx index 2d79051d7ddae5e4d84c10e21400442774d5c343..f54c9d10718d347a5f19b20a57dc11b3e4151071 --- a/Utils/XSM/MLP/Train/Train_XS.cxx +++ b/Utils/XSM/MLP/Generate/Train_XS.cxx @@ -31,7 +31,7 @@ std::vector<std::string>OUTPUT; void LOAD_OUTPUT() { - #include "../BuildInput/TrainingInput.cxx" + #include "_tmp/include_Train_XS/TrainingInput.cxx" } void Train_XS_Time(int INDICE) @@ -70,20 +70,8 @@ void Train_XS_Time(int INDICE) TMVA::Factory *factory = new TMVA::Factory( "TMVARegression", OUTPUTFile, "!V:!Silent:Color:DrawProgressBar" ); -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -//@@Change : change the each first arguments with the name used in your training sample - // factory->AddVariable( "TheNameOfYourNucleusInTheTrainingFile" , "whatever" , "whatever", 'F' ); - factory->AddVariable( "U5" , "U 235" , "FractionIsotopic", 'F' ); - factory->AddVariable( "U8" , "U 238" , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu8" , "Pu 238" , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu9" , "Pu 239" , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu10" , "Pu 240" , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu11" , "Pu 241" , "FractionIsotopic", 'F' ); - factory->AddVariable( "Pu12" , "Pu 242" , "FractionIsotopic", 'F' ); - factory->AddVariable( "Am1" , "Am 241" , "FractionIsotopic", 'F' ); -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - factory->AddVariable( "Time" , "Time" , "seconds" , 'F' ); + #include "_tmp/include_Train_XS/InputVariables.cxx" // Add the variable carrying the regression target factory->AddTarget( OUTPUT[INDICE].c_str() ); //The name of the MLP output @@ -95,7 +83,7 @@ void Train_XS_Time(int INDICE) // load the signal and background event samples from ROOT trees TFile *input(0); - TString fname = "../BuildInput/TrainingInput.root"; + TString fname = "_tmp/include_Train_XS/TrainingInput.root"; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists @@ -118,9 +106,15 @@ void Train_XS_Time(int INDICE) // Apply additional cuts on the signal and background samples (can be different) TCut mycut = ""; // for example: TCut mycut = "abs(var1)<0.5 && abs(var2-0.5)<1"; + Long64_t NEvents = regTree->GetEntries(); + Long64_t NTraining = PropTraining * NEvents ; + Long64_t NTesting = NEvents - NTraining ; + + std::stringstream Samples_Parameters ; + Samples_Parameters << "nTrain_Regression=" << NTraining <<":"<< "nTest_Regression=" << NTesting <<":SplitMode=Random:NormMode=NumEvents:!V"; + // tell the factory to use all remaining events in the trees after training for testing: - factory->PrepareTrainingAndTestTree( mycut, - "nTrain_Regression=0:nTest_Regression=0:SplitMode=Random:NormMode=NumEvents:!V" ); + factory->PrepareTrainingAndTestTree( mycut, Samples_Parameter.str() ); // If no numbers of events are given, half of the events in the tree are used // for training, and the other half for testing: @@ -134,7 +128,7 @@ void Train_XS_Time(int INDICE) // "...:CutRangeMin[2]=-1:CutRangeMax[2]=1"...", where [2] is the third input variable std::stringstream Name; - Name<< OUTPUT[INDICE]; + Name << OUTPUT[INDICE]; // Neural network (MLP) factory->BookMethod( TMVA::Types::kMLP, Name.str().c_str(), "!H:!V:VarTransform=Norm:NeuronType=tanh:NCycles=20000:HiddenLayers=N,N:TestRate=6:TrainingMethod=BFGS:Sampling=0.3:SamplingEpoch=0.8:ConvergenceImprove=1e-6:ConvergenceTests=15:!UseRegulator" ); @@ -169,7 +163,7 @@ int main(int argc, char const *argv[]) { std::cout << "Usage : TrainXS i"<< std::endl; std::cout << "With i the cross section index " << std::endl; - std::cout << "File ../BuildInput/TrainingInput.cxx indicates\n indice ranging from 0 to "<< OUTPUT.size()-1 << std::endl; + std::cout << "File _tmp/include_Train_XS/TrainingInput.cxx indicates\n indice ranging from 0 to "<< OUTPUT.size()-1 << std::endl; exit(0); } diff --git a/Utils/XSM/MLP/Generate/include/Generate_XSM.hxx b/Utils/XSM/MLP/Generate/include/Generate_XSM.hxx new file mode 100644 index 0000000000000000000000000000000000000000..200b25cf91f85b580d886d3449c61386ea6c8b40 --- /dev/null +++ b/Utils/XSM/MLP/Generate/include/Generate_XSM.hxx @@ -0,0 +1,76 @@ +#include "ZAI.hxx" +#include <TGraph.h> +#include <TGraph.h> + +#include <vector> +#include <stdio.h> +#include <stdlib.h> +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +#include <sstream> +#include <cmath> +#include <map> +#include <iostream> +#include <iomanip> + +using namespace std; + +string dtoa(double num) +{ + ostringstream os(ostringstream::out); + os<<setprecision(3)<<num; + return os.str(); +} + +string FilePath; +string DataPath; + +vector<string> JobName; +vector<string> GoodJobName; + +vector< vector<double> > fTime; //Time vector of each depletion calculation (second) +vector<ZAI> fAllNuclei; //All the nuclei present in the fuel + +vector< map < ZAI, vector<double> > > fXSFis; // map of fission cross section fXSFis[NumberOfTheEvolution][ZAI][TimeStep] +vector< map < ZAI, vector<double> > > fXSCap; +vector< map < ZAI, vector<double> > > fXSN2N; + +vector<IsotopicVector> fActinideCompoInit; //Fresh fuel composition in atomic prop. + +vector<double> fHMMass; //Vector of initial Heavy metal mass (every element should be egual or very very close !!) + +vector<int> fNOfTimeStep; //number of time step in each Evolution data +int fReactionCounter=0;//number of nuclear reactions to train +string fEvolutionDataFolder = ""; + +map<ZAI,string> fMapName; // List of ZAI and their name to consider for model parametrization (must of the time Fuel composition @ t=0) + +string fReactorType,fFuelType; + +bool fIsAllNucleiAlreadyFill=false; + +void CheckJob(); +void ReadAndFill(string jobname); +void DumpForTestingNeuron(string filename); +void DumpInputNeuron(string filename); +void FillMapName(); +bool UserSayYes(); +void CreateInfoFile(); +void ReadInfo(string InfoDBFile,string &ReactorType,string &FuelType,double &Power); +void ProgressBar(double loopindex, double totalindex); +vector<double> GetAllCompoOf(ZAI zai); + +bool is_file_exist(const char *fileName); +void CompileTraining(); +void Run_Sequential(); + +/* PRINT INFO */ +void PrintFinalSteps(); +void Generate_tmva_factory_input(double ProportionOfTraining); + +/* SCRIPT GENERATION */ +void GenerateScript_Parallel(int threads); +void GenerateScript_Sequential(int begin, int end, string filepath, bool print=true ); +void GenrateZubaScript(int threads); diff --git a/Utils/XSM/MLP/Generate/include/QSUB b/Utils/XSM/MLP/Generate/include/QSUB new file mode 100755 index 0000000000000000000000000000000000000000..5793a016dd812a2e51403180b3c005d42fab922f --- /dev/null +++ b/Utils/XSM/MLP/Generate/include/QSUB @@ -0,0 +1,116 @@ +#!/bin/sh + +####################################### +############ DEFAULT IMPUT ############ +####################################### +# Job Name +JARG='AutoSub' + +####################################### +############ CODE ############ +####################################### + + +if [ "$1" = "" ] +then + echo '---------------------------------------------' + echo + echo "Pas de commande en argument de Qsub : EXIT..." + echo + echo "USE :" + echo + echo "Qsub commande_1 \; commande_2 \; ..." + echo "Qsub -n Job_Name -c \"Cmd1 ; cmd2;....\" -p proc_numb" + echo + echo '---------------------------------------------' + exit +fi + +NARG=$* +JFLG=0 +CFLG=0 +PFLG=0 + +while getopts ":n:c:p:" flag; do + case $flag in + n) + JFLG=1 + JARG=$OPTARG + + ;; + c) + CFLG=1 + CARG=$OPTARG + + ;; + p) + PFLG=1 + PARG=$((OPTARG)) + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + ;; + esac + +done + + +BATCH_FILE='/scratch/spallati/'${USER}'/.batch-pbs/QSUB/batch.txt' + +echo +echo '--------------------------' +echo 'qsub job..................' +echo '--------------------------' +echo + +if [ $JFLG -eq 1 ] +then + if [ $PFLG -ne 1 ] + then + PARG=1 + fi + if [ $CFLG -ne 1 ] + then + echo '---------------------------------------------' + echo + echo "Pas de commande en argument de Qsub : EXIT..." + echo + echo "USE :" + echo + echo "Qsub commande_1 \; commande_2 \; ..." + echo "Qsub -n Job_Name -c \"Cmd1 ; cmd2;....\"" + echo + echo '---------------------------------------------' + exit + else + echo 'commande : ' ${CARG} + echo '#PBS -N '${JARG} > ${BATCH_FILE} + echo '#PBS -S /bin/tcsh' >> ${BATCH_FILE} + echo '#PBS -l nodes=1:ppn='${PARG} >> ${BATCH_FILE} + echo '#PBS -l cput=240:00:00' >> ${BATCH_FILE} + echo '#PBS -S /bin/csh' >> ${BATCH_FILE} + echo '#PBS -j oe' >> ${BATCH_FILE} + echo 'cd ' `pwd` >> ${BATCH_FILE} + if [ $PARG -gt 1 ] + then + echo 'set OMP_NUM_THREADS = '$PARG >> ${BATCH_FILE} + fi + echo ${CARG} >> ${BATCH_FILE} + fi +else + echo 'commande : '${NARG} + echo '#PBS -N '${JARG} > ${BATCH_FILE} + echo '#PBS -S /bin/tcsh' >> ${BATCH_FILE} + echo '#PBS -l nodes=1:ppn=1' >> ${BATCH_FILE} + echo '#PBS -l cput=240:00:00' >> ${BATCH_FILE} + echo '#PBS -j oe' >> ${BATCH_FILE} + echo 'cd ' `pwd` >> ${BATCH_FILE} + echo ${NARG} >> ${BATCH_FILE} + +fi +echo +qsub ${BATCH_FILE} +echo +echo '---------------' +echo 'qsub job : DONE' +echo '---------------' diff --git a/Utils/XSM/MLP/Generate/include/ZAI.hxx b/Utils/XSM/MLP/Generate/include/ZAI.hxx new file mode 100644 index 0000000000000000000000000000000000000000..1643a5414f573a8ee439c7356a0a2c73a432da96 --- /dev/null +++ b/Utils/XSM/MLP/Generate/include/ZAI.hxx @@ -0,0 +1,123 @@ +#ifndef MN_ZAI_H_ +#define MN_ZAI_H_ + +#include <map> +#include <vector> +#include <fstream> +#include <iostream> + +using namespace std; + +class ZAI { + public : + int Z; + int A; + int I; + + + ZAI(int z, int a, int i=0) { Z=z;A=a; I=i;} + + bool operator <(const ZAI& zai) const {return (Z != zai.Z)? + (Z < zai.Z) : ( (A != zai.A)? + (A < zai.A) : (I < zai.I) );} +}; + +class IsotopicVector { + public : + + IsotopicVector() {} ///< Normal Constructor. + ~IsotopicVector() {}; ///< Normal Destructor. + double GetZAIIsotopicQuantity(const ZAI& zai) const + { + map<ZAI ,double> IsotopicQuantity = IVquantity; + + map<ZAI ,double>::iterator it; + it = IsotopicQuantity.find(zai); + + if ( it != IsotopicQuantity.end() ) + return it->second; + else + return 0; + } + vector<ZAI> GetNonZeroZAIList() + { + vector<ZAI> vZAI; + map<ZAI,double>::iterator it; + for(it = IVquantity.begin(); it != IVquantity.end(); ++it) + { if(it->second != 0 ) + vZAI.push_back(it->first); + } + return vZAI; + } + + map<ZAI,double> IVquantity; + +}; + + +class ZAIMass +{ + public: + ZAIMass() + { + string CLASSPATH = getenv("CLASS_PATH"); + string MassDataFile = CLASSPATH + "/data/Mass.dat"; + + ifstream infile(MassDataFile.c_str()); + + if(!infile.good()) + { + std::cout << " ZAIMass Error.\n can't find/open file " << MassDataFile << std::endl; + exit(1); + } + + int Z,A; + string Name; + double MassUnity,MassDec,error; + while (infile>>Z>>A>>Name>>MassUnity>>MassDec>>error) + { + double Masse = MassUnity + MassDec * 1e-6; + fZAIMass.insert( pair< ZAI,double >( ZAI(Z,A,0), Masse ) ); + } + + infile.close(); + } + ~ZAIMass() + { + fZAIMass.clear(); + } + + double GetMass(ZAI zai ) //!< get with ZAI + { + map<ZAI,double>::iterator MassIT = fZAIMass.find( ZAI(zai.Z, zai.A, 0) ); + + if(MassIT == fZAIMass.end()) + return zai.A; + else + return MassIT->second; + + } + + double GetMass(IsotopicVector & IV) //return Mass of IV [t] + { + double AVOGADRO = 6.02214129e23; + double TotalMass = 0; + + for( map<ZAI,double>::iterator it = IV.IVquantity.begin(); it != IV.IVquantity.end(); it++) + { + TotalMass += it->second/AVOGADRO * GetMass( it->first ) ; + } + + return TotalMass*1e-6; + } + + + private: + map<ZAI, double> fZAIMass; //! ZAI mass list + +}; + + + + +#endif //MN_ZAI_H_ diff --git a/Utils/XSM/MLP/Test/EvaluateTrainingCommands.dat b/Utils/XSM/MLP/Test/EvaluateTrainingCommands.dat new file mode 100644 index 0000000000000000000000000000000000000000..48985a2ecb96f848fca15713911609a54b0f39e9 --- /dev/null +++ b/Utils/XSM/MLP/Test/EvaluateTrainingCommands.dat @@ -0,0 +1,6 @@ +in terminal type : + +root +int N = ; // with N the number of cross section trained (get it with wc -l ../Generate/_tmp/include_Train_XS/TrainingInput.cxx ) +.L deviations.C +for(int i=0;i<N;i++) {stringstream ss;ss<<"../Generate/Training_output_"<<i<<".root";deviations(ss.str().c_str(),0,kTRUE,kFALSE,kFALSE); } \ No newline at end of file diff --git a/Utils/XSM/MLP/Train/deviations.C b/Utils/XSM/MLP/Test/deviations.C old mode 100755 new mode 100644 similarity index 100% rename from Utils/XSM/MLP/Train/deviations.C rename to Utils/XSM/MLP/Test/deviations.C diff --git a/Utils/XSM/MLP/Train/tmvaglob.C b/Utils/XSM/MLP/Test/tmvaglob.C old mode 100755 new mode 100644 similarity index 100% rename from Utils/XSM/MLP/Train/tmvaglob.C rename to Utils/XSM/MLP/Test/tmvaglob.C diff --git a/Utils/XSM/MLP/Train/EvaluateTrainingCommands.dat b/Utils/XSM/MLP/Train/EvaluateTrainingCommands.dat deleted file mode 100644 index 7f5793c64f44e4531be1867a4a669e0cab035a2b..0000000000000000000000000000000000000000 --- a/Utils/XSM/MLP/Train/EvaluateTrainingCommands.dat +++ /dev/null @@ -1,5 +0,0 @@ -in terminal type (with N the number of cross section trained: - -root -.L deviations.C -for(int i=0;i<N;i++) {stringstream ss;ss<<"Training_output_"<<i<<".root";deviations(ss.str().c_str(),0,kTRUE,kFALSE,kFALSE); } \ No newline at end of file diff --git a/Utils/XSM/MLP/Train/LaunchTraining.sh b/Utils/XSM/MLP/Train/LaunchTraining.sh deleted file mode 100755 index b41b382885247d0a88b1aafcacb7bffa2835551b..0000000000000000000000000000000000000000 --- a/Utils/XSM/MLP/Train/LaunchTraining.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Script to train MLPs -#@author BaL -# - -echo "--------------------------" -echo "--- Run Training from MLP $1 to $2 ---" -echo "--------------------------" - -#LigneDeDepart=$((0)) -#NbreSimu=$((700)) -LigneDeDepart=$1 -LigneFinal=$2 - -echo LigneDeDepart $LigneDeDepart LigneFinal $LigneFinal exclu - -for ((ligne=$LigneDeDepart; ligne<$LigneFinal; ligne=ligne+1 )) ; -do - Train_XS $ligne -done diff --git a/Utils/cgui/html/__init__.pyc b/Utils/cgui/html/__init__.pyc index 21f5311380d76192cd164204a4940c1be178f634..8159a1886485e300be9e536568a2eb68fc16252f 100644 Binary files a/Utils/cgui/html/__init__.pyc and b/Utils/cgui/html/__init__.pyc differ diff --git a/Utils/cgui/html/backend.pyc b/Utils/cgui/html/backend.pyc index fc3f0a6847ee4f86cddf8c19843ba954d21b93c5..0e6798a87b752db8e18843a730a73842305229db 100644 Binary files a/Utils/cgui/html/backend.pyc and b/Utils/cgui/html/backend.pyc differ diff --git a/Utils/cgui/html/htmlHelper.pyc b/Utils/cgui/html/htmlHelper.pyc index b5e515edb14b87b70e5f90f020ce9ed8d7b275ec..2510b5a4e48791376c96bd1d9146d525373eba5b 100644 Binary files a/Utils/cgui/html/htmlHelper.pyc and b/Utils/cgui/html/htmlHelper.pyc differ diff --git a/Utils/cgui/html/model.pyc b/Utils/cgui/html/model.pyc index 88f5e87b3412035d3f5fa06275934bd57de88310..a60ed5e549f50a46c2a4ff8312be46450f579b37 100644 Binary files a/Utils/cgui/html/model.pyc and b/Utils/cgui/html/model.pyc differ diff --git a/Utils/install.sh b/Utils/install.sh deleted file mode 100755 index 650e0f41c70f007d8a63c667daaeaaa4d7aeba46..0000000000000000000000000000000000000000 --- a/Utils/install.sh +++ /dev/null @@ -1,367 +0,0 @@ -#!/bin/bash - -option=$1 -case "$option" in - "-h" | "--help") - -cat <<\_ACEOF -############################################################### -############## configures and compiles CLASS V4.1 ############# -############################################################### - -Usage: install.sh [VAR=VALUE] [OPTION] -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit -Optional Features: - --disable-OMP do not compile with OpenMP support for evolution - [default: enable for gcc version >= 4.1] - --InstallLib-path=path Install location of CLASS's libraries [default= $PWD/lib] - --InstallGui-path=path Install location of the GUI binary [default= $PWD/gui/bin] - -Some influential environment variables: - CXX C++ compiler command [default=g++] - CXXFLAGS C++ compiler flags, e.g. -I<include dir> if - you have headers in a nonstandard directory <include dir> - CPPFLAGS C++ preprocessor flags, e.g. -D<special flag> - - -Report bugs to <leniau@subatech.in2p3.fr>. -(special thanks to PTO) -_ACEOF - -exit ;; -esac - -####### set default - -IsGCCSupportOMP="no" -IsOMPEnable="yes" -OMPFLAGS= - -ROOTCFLAGS= -ROOTGLIBS= -ROOTLIBS= - -LIBDIR=${PWD}/lib -Gui_bin_PATH=${PWD}/gui/bin - -CXX="" -CXXFLAGS="" -CPPFLAGS="" - -####### evaluate options -for option -do - case $option in - *=?*) ac_optarg=`expr "X$option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac -# echo $ac_optarg - case $option in - --InstallLib-path=*) - LIBDIR="$ac_optarg" ;; - --InstallGui-path=*) - Gui_bin_PATH="$ac_optarg" ;; - --disable-OMP) - IsOMPEnable="disable" ;; - *) - echo "Unrecognized option $option" - exit ;; - esac -done - -####### ROOT Support -if [ -f $ROOTSYS/bin/root-config ] -then - echo "Checking for ROOT cern lib... yes" - ROOTCFLAGS='$(shell ${ROOTSYS}/bin/root-config --cflags)' - ROOTGLIBS='$(shell ${ROOTSYS}/bin/root-config --glibs)' - ROOTLIBS='$(shell ${ROOTSYS}/bin/root-config --libs)' - - if [ "$ROOTSYS/bin/root-config --features-tmva" = "no" ] - then - echo "TMVA is not activated : consider rebuild ROOT activating this feature" - exit 0 - fi - -else - echo "Checking for ROOT cern lib... no" - echo "********************* ERROR *********************" - echo "** CLASS need ROOT (cern) to work" - echo "** Either set the ROOTSYS env variable or intall" - echo "** the ROOT library FROM SOURCES with the same C++" - echo "** compiler you will use for comipling CLASS" - echo "***************************************************" - exit 0 -fi - -####### OMP support -### write a testconf prog -echo "#include <omp.h>" > testconf.cxx -echo "int main(){ return 0;}" >> testconf.cxx - -if [ "$IsOMPEnable" = "yes" ] -then - - g++ -o testconf -fopenmp testconf.cxx -lgomp > script.errors 2>&1 - - ok=`cat script.errors|wc -l` - if [ $ok = 0 ] - then - IsGCCSupportOMP="yes" - else - IsOMPEnable="no" - IsGCCSupportOMP="no" - fi - rm -f script.errors -fi - -if [ "$IsOMPEnable" = "yes" ] -then - echo "Checking for omp.h... yes" - echo " You can disable the use of this library with \"--disable-OMP\" option" - OMPFLAGS="-fopenmp -DOpenMP" - OMPLIB=-lgomp -else - if [ "$IsOMPEnable" = "no" ] - then - echo "Checking for omp.h... no" - echo " OpenMP support not found." - echo " Either gcc is to old either install libgomp.so" - else - if [ "$IsOMPEnable" = "disable" ] - then - echo "Checking for omp.h... disable" - fi - fi -fi - -rm -f script.errors testconf testconf.cxx - - -####################################################### -### Preprocessor flags & Makefile variables -####################################################### -mkdir -p config -MAKEFILE_INC="config/Makefile.config" -rm config/Makefile.config -echo "#####################">> $MAKEFILE_INC -echo "###### OPEN MP ######">> $MAKEFILE_INC -echo "#####################">> $MAKEFILE_INC -echo "OMPFLAGS=$OMPFLAGS" >> $MAKEFILE_INC -echo "OMPLIB=$OMPLIB" >> $MAKEFILE_INC -echo >> $MAKEFILE_INC -echo "#####################">> $MAKEFILE_INC -echo "####### ROOT ########">> $MAKEFILE_INC -echo "#####################">> $MAKEFILE_INC -echo "ROOTCFLAGS:=$ROOTCFLAGS" >> $MAKEFILE_INC -echo "ROOTGLIBS:=$ROOTGLIBS" >> $MAKEFILE_INC -echo "ROOTLIBS:=$ROOTLIBS" >> $MAKEFILE_INC -echo >> $MAKEFILE_INC -echo "#####################">> $MAKEFILE_INC -echo "##### COMPILER ######">> $MAKEFILE_INC -echo "#####################">> $MAKEFILE_INC - -if [ "$CXX" = "" ] -then - echo "CXX= g++" >> $MAKEFILE_INC -else - echo "CXX=$CXX" >> $MAKEFILE_INC -fi - -if [ "$CXXFLAGS" = "" ] -then - echo "CXXFLAGS=-O2 -g -fPIC -Wall -Wno-unused">> $MAKEFILE_INC -else - echo "CXXFLAGS=$CXXFLAGS" >> $MAKEFILE_INC -fi -if [ "$CPPFLAGS" = "" ] -then - echo "CPPFLAGS= \$(OMPFLAGS) " >> $MAKEFILE_INC -else - echo "CPPFLAGS=$CPPFLAGS" >> $MAKEFILE_INC -fi - -echo "####Installation folder of librairies##" >>$MAKEFILE_INC -echo "LIBDIR=$LIBDIR" >> $MAKEFILE_INC -echo "Building Librairies Folder @ $LIBDIR" -mkdir -p $LIBDIR - - -echo "####Installation folder of Gui##" >>$MAKEFILE_INC -echo "Gui_bin_PATH=$Gui_bin_PATH" >> $MAKEFILE_INC -echo "Building Gui Folder @ $Gui_bin_PATH" -mkdir -p $Gui_bin_PATH - -####################################################### -### Include flags -####################################################### -INCLUDE_INC="config/config.hxx" -if [ "$IsOMPEnable" = "yes" ] -then - echo "#include <omp.h>" > $INCLUDE_INC -else - echo "#define omp_get_thread_num() 0" > $INCLUDE_INC -fi - -####################################################### -### compile libraries -####################################################### -echo "####################################################" -echo "######### Compilation of CLASS libraries ###########" -echo "####################################################" -cd source/src ; make clean ; make -j 4 ; make install ; cd ../.. -echo "####################################################" -echo "########## Compilation Done #######################" -echo "####################################################" -echo "MURE libraries installed in" -echo "----> $LIBDIR" -echo "####################################################" -echo "######### Compilation of CLASSGUI binary ###########" -echo "####################################################" -cd gui ; make clean ; make -j 4 ; cd ../ -echo "####################################################" -echo "########## Compilation Done #######################" -echo "####################################################" -echo -####################################################### -### set the pathes of DECAY data base -####################################################### -echo -echo -echo "####################################################" -echo "########## SET DECAY DATA BASES PATHES #############" -echo "####################################################" -cd DATA_BASES/DECAY/ALL/ -sed -e "s%PATHTOBASE%`pwd`%" .Decay.tmp > Decay.idx -echo "-> Done" -cd - - -####################################################### -### set the environement variables -####################################################### -echo -echo -echo "####################################################" -echo "########## ENVIRONEMENT VARIABLES ##################" -echo "####################################################" - -MYDefaultSHELL=$(env | grep SHELL | awk -F "=" '{ print $2 }') -SHELLPreference=".$(echo "$MYDefaultSHELL" | awk -F "/bin/" '{print $2}')rc" -echo "-> Your default shell is : $MYDefaultSHELL" -echo "-> Your $SHELLPreference will be edited if CLASS_PATH CLASS_include" -echo " and CLASS_lib aren't defined yet " -echo -echo "CHECKING LOADED ENVIRONEMENT VARIABLES " -echo - -CLASS_PATH_To_Set="" -CLASS_include_To_Set="" -CLASS_lib_To_Set="" -SetEnvSucceed=false - -if [ -z "$CLASS_PATH" ]; then - echo "Not found in your loaded $SHELLPreference." - echo "Setting variables ..." - echo "PRESS ENTER IF DEFAULT IS CORRECT" - read -p "====>ENTER THE PATH TO THE CLASS root folder (defalut ${PWD}) " CLASS_PATH_To_Set - [ -z "${CLASS_PATH_To_Set}" ] && CLASS_PATH_To_Set="${PWD}" - echo "Path of the CLASS include folder is $CLASS_PATH_To_Set" - echo - read -p "====>ENTER THE PATH TO THE CLASS INCLUDE (default: $CLASS_PATH_To_Set/source/include/): " CLASS_include_To_Set - [ -z "${CLASS_include_To_Set}" ] && CLASS_include_To_Set="${CLASS_PATH_To_Set}/source/include/" - echo "Path of the CLASS include folder is $CLASS_include_To_Set" - echo - read -p "====>ENTER THE PATH WHERE CLASS LIB ARE INSTALLED (default: $LIBDIR): " CLASS_lib_To_Set - [ -z "${CLASS_lib_To_Set}" ] && CLASS_lib_To_Set="$LIBDIR" - echo "Path of the CLASS lib folder is $CLASS_lib_To_Set" - echo - read -p "====>ENTER THE PATH WHERE CLASSGui is INSTALLED (default: $Gui_bin_PATH): " CLASS_Gui_path_to_set - [ -z "${CLASS_Gui_path_to_set}" ] && CLASS_Gui_path_to_set="$Gui_bin_PATH" - echo "Path of the CLASS lib folder is $CLASS_Gui_path_to_set" - echo - - EXPORT= - EQUAL= - if [ "$MYDefaultSHELL" = "/bin/tcsh" ] || [ "$MYDefaultSHELL" = "/bin/csh" ] ; then - EXPORT="setenv " - EQUAL=" " - - else - EXPORT="export " - EQUAL="=" - fi - - - if [ -f $HOME/$SHELLPreference ] ; then - SetEnvSucceed=true - echo "" >>$HOME/$SHELLPreference - echo "##################" >> $HOME/$SHELLPreference - echo "####CLASSV4.1#####" >> $HOME/$SHELLPreference - echo "##################" >> $HOME/$SHELLPreference - - echo "$EXPORT CLASS_PATH$EQUAL$CLASS_PATH_To_Set" >> $HOME/$SHELLPreference - echo "$EXPORT CLASS_include$EQUAL$CLASS_include_To_Set" >> $HOME/$SHELLPreference - echo "$EXPORT CLASS_lib$EQUAL$CLASS_lib_To_Set" >> $HOME/$SHELLPreference - echo "#### CLASS Gui ####" >> $HOME/$SHELLPreference - echo "$EXPORT PATH$EQUAL\${PATH}:$CLASS_Gui_path_to_set" >> $HOME/$SHELLPreference - - echo "Environnment variables added in $HOME/$SHELLPreference" - else - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "!!!!!! WARNING $HOME/$SHELLPreference NOT FOUND !!!!!!!!!!" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - - fi -else - SetEnvSucceed=true - echo "A CLASS_PATH is already defined in your $SHELLPreference: $CLASS_PATH" - - if [ -z "$CLASS_lib" ]; then - echo "Path to CLASS libraries is not set " - echo "delete the CLASS_PATH set in your $SHELLPreference, source $SHELLPreference, and rerun this script" - SetEnvSucceed=false - - else - echo "CLASS_lib is: $CLASS_lib" - - fi - - if [ -z "$CLASS_include" ]; then - echo "Path to CLASS includes is not set " - echo "delete the CLASS_PATH set in your $SHELLPreference, source $SHELLPreference, and rerun this script" - SetEnvSucceed=false - else - echo "CLASS_include is : $CLASS_include" - fi - -fi - -if [ "$SetEnvSucceed" = true ] ; then - echo "LOADING $HOME/$SHELLPreference ... done" - echo - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " Congratulations you are now able to compile your first " - echo " CLASS .cxx input. " - echo " Please read $CLASS_PATH_To_Set/documentation/Manual/USEGUIDE.pdf" - echo " (Check if echo \$CLASS_PATH gives you the correct path) " - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - $MYDefaultSHELL #LOAD THE DEFAULT SHELL WITH THE NEW ENV VAR -else - echo " I CAN'T MANAGE TO SET THE CLASS ENVIRONEMENT VARIABLE " - echo " ADD THE FOLLOWING IN YOUR SHELL PREFERENCE FILE (RC FILE) :" - echo - echo "$EXPORT CLASS_PATH$EQUAL$CLASS_PATH_To_Set " - echo "$EXPORT CLASS_include$EQUAL$CLASS_include_To_Set" - echo "$EXPORT CLASS_lib$EQUAL$CLASS_lib_To_Set " - echo "$EXPORT PATH$EQUAL\${PATH}:$CLASS_Gui_path_to_set" - - echo -fi - - - -