Project

General

Profile

Creation of a Physics Model » EQM_CANDU2.cxx

The equivalence model we made - Alderete Tommasi Francisco Martin, 01/22/2016 11:21 AM

 
1
#include "EquivalenceModel.hxx"
2
#include "EQM_CANDU2.hxx"
3
#include "CLASSLogger.hxx"
4
#include "StringLine.hxx"
5

    
6
#include <string>
7
#include <iostream>
8
#include <fstream>
9
#include <algorithm>
10
#include <cmath>
11
#include <cassert>
12

    
13
#include "TSystem.h"
14
#include "TMVA/Reader.h"
15
#include "TMVA/Tools.h"
16
#include "TMVA/MethodCuts.h"
17

    
18

    
19
//________________________________________________________________________
20
//
21
//		EQM_CANDU2
22
//
23
//	Equivalenve Model based on multi layer perceptron from TMVA (root cern)
24
//	For REP MOX use
25
//
26
//________________________________________________________________________
27

    
28
EQM_CANDU2::EQM_CANDU2(string TMVAWeightPath):EquivalenceModel(new CLASSLogger("EQM_CANDU2.log"))
29
{
30

    
31
WARNING << "yes you are a CANDU2 first constructor"<<endl;
32
	fTMVAWeightPath = TMVAWeightPath;
33

    
34
	ZAI U8(92,238,0);
35
	ZAI U5(92,235,0);
36
	ZAI U6(92,236,0);
37
	double U5_enrich = 0.0025;
38

    
39
	ZAI Pu8(94,238,0);
40
	ZAI Pu9(94,239,0);
41
	ZAI Pu0(94,240,0);
42
	ZAI Pu1(94,241,0);
43
	ZAI Pu2(94,242,0);
44

    
45
	fFissileList = U5*1+U6*1+U8*1;
46
	fFertileList = U5*U5_enrich + U8*(1-U5_enrich);
47

    
48
	SetBuildFuelFirstGuess(0.04);
49

    
50
	INFO << "__An equivalence model of PWR MOX has been define__" << endl;
51
	INFO << "\tThis model is based on a multi layer perceptron" << endl;
52
	INFO << "\t\tThe TMVA weight file is :" << endl;
53
	INFO << "\t\t\t" << fTMVAWeightPath << endl;
54
	EquivalenceModel::PrintInfo();
55

    
56
}
57

    
58
//________________________________________________________________________
59
EQM_CANDU2::EQM_CANDU2(CLASSLogger* log, string TMVAWeightPath):EquivalenceModel(log)
60
{
61
WARNING << "yes you are a CANDU2 second constructor"<<endl;
62
	fTMVAWeightPath = TMVAWeightPath;
63

    
64
	ZAI U8(92,238,0);
65
	ZAI U2(92,232,0);
66
	ZAI U3(92,233,0);
67
	ZAI U4(92,234,0);
68
	ZAI U5(92,235,0);
69
	ZAI U6(92,236,0);
70
	double U5_enrich = 0.0025;
71

    
72
	ZAI Pu8(94,238,0);
73
	ZAI Pu9(94,239,0);
74
	ZAI Pu0(94,240,0);
75
	ZAI Pu1(94,241,0);
76
	ZAI Pu2(94,242,0);
77

    
78
//	fFissileList = Pu8*1+Pu9*1+Pu0*1+Pu1*1+Pu2*1;
79

    
80
	fFissileList = U2*1+U3*1+U4*1+U5*1+U6*1+U8*1;
81
	fFertileList = U5*U5_enrich + U8*(1-U5_enrich);
82

    
83
	SetBuildFuelFirstGuess(0.04);
84

    
85
	INFO << "__An equivalence model of PWR MOX has been defined__" << endl;
86
	INFO << "\tThis model is based on a multi layer perceptron" << endl;
87
	INFO << "\t\tThe TMVA weight file is :" << endl;
88
	INFO << "\t\t\t" << fTMVAWeightPath << endl;
89
	EquivalenceModel::PrintInfo();
90

    
91
}
92

    
93
//________________________________________________________________________
94
TTree* EQM_CANDU2::CreateTMVAInputTree(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp)
95
{
96
	TTree*   InputTree = new TTree("EQTMP", "EQTMP");
97
	float Pu8   		 = 0;
98
	float Pu9   		 = 0;
99
	float Pu10  		 = 0;
100
	float Pu11  		 = 0;
101
	float Pu12  		 = 0;
102
	float Am1   		 = 0;
103
	float U5_enrichment  = 0;
104
	float BU  			  = 0;
105

    
106
	InputTree->Branch(	"Pu8"	,&Pu8	,"Pu8/F"	);
107
	InputTree->Branch(	"Pu9"	,&Pu9	,"Pu9/F"	);
108
	InputTree->Branch(	"Pu10"	,&Pu10	,"Pu10/F"	);
109
	InputTree->Branch(	"Pu11"	,&Pu11	,"Pu11/F"	);
110
	InputTree->Branch(	"Pu12"	,&Pu12	,"Pu12/F"	);
111
	InputTree->Branch(	"Am1"	,&Am1	,"Am1/F"	);
112
	InputTree->Branch(	"U5_enrichment"	,&U5_enrichment	,"U5_enrichment/F"	);
113
	InputTree->Branch(	"BU"	,&BU	,"BU/F"	);
114

    
115

    
116
	float U8     = Fertil.GetZAIIsotopicQuantity(92,238,0);
117
	float U5     = Fertil.GetZAIIsotopicQuantity(92,235,0);
118
	float U4     = Fertil.GetZAIIsotopicQuantity(92,234,0);
119

    
120
	float UTOT = U8 + U5 + U4;
121

    
122
	Pu8    	   = Fissil.GetZAIIsotopicQuantity(94,238,0);
123
	Pu9    	   = Fissil.GetZAIIsotopicQuantity(94,239,0);
124
	Pu10   	   = Fissil.GetZAIIsotopicQuantity(94,240,0);
125
	Pu11   	   = Fissil.GetZAIIsotopicQuantity(94,241,0);
126
	Pu12   	   = Fissil.GetZAIIsotopicQuantity(94,242,0);
127
	Am1        = Fissil.GetZAIIsotopicQuantity(95,241,0);
128

    
129
	double TOTPU = (Pu8+Pu9+Pu10+Pu11+Pu12+Am1);
130

    
131
	Pu8 = Pu8  / TOTPU;
132
	Pu9 = Pu9  / TOTPU;
133
	Pu10 = Pu10 / TOTPU;
134
	Pu11 = Pu11 / TOTPU;
135
	Pu12 = Pu12 / TOTPU;
136
	Am1 = Am1  / TOTPU;
137

    
138
	U5_enrichment = U5 / UTOT;
139

    
140
	BU = BurnUp;
141
	if(Pu8 + Pu9 + Pu10 + Pu11 + Pu12 + Am1 > 1.00001 )//?????1.00001??? I don't know it! goes in condition if  = 1 !! may be float/double issue ...
142
	{
143
		ERROR << Pu8 << " " << Pu9 << " " << Pu10 << " " << Pu11 << " " << Pu12 << " " << Am1 << endl;
144
		exit(0);
145
	}
146
	// All value are molar (!weight)
147

    
148
	InputTree->Fill();
149
	return InputTree;
150
}
151
//________________________________________________________________________
152
double EQM_CANDU2::ExecuteTMVA(TTree* theTree)
153
{
154
	// --- Create the Reader object
155
	TMVA::Reader *reader = new TMVA::Reader( "Silent" );
156
	// Create a set of variables and declare them to the reader
157
	// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
158
	Float_t Pu8,Pu9,Pu10,Pu11,Pu12,Am1,BU,U5_enrichment;
159

    
160
	reader->AddVariable( "BU"   		,&BU );
161
	reader->AddVariable( "U5_enrichment",&U5_enrichment );
162
	reader->AddVariable( "Pu8"  		,&Pu8 );
163
	reader->AddVariable( "Pu9"  		,&Pu9 );
164
	reader->AddVariable( "Pu10" 		,&Pu10);
165
	reader->AddVariable( "Pu11" 		,&Pu11);
166
	reader->AddVariable( "Pu12" 		,&Pu12);
167
	reader->AddVariable( "Am1"  		,&Am1 );
168

    
169
	// --- Book the MVA methods
170

    
171
	// Book method MLP
172
	TString methodName = "MLP method";
173
	reader->BookMVA( methodName, fTMVAWeightPath );
174
	theTree->SetBranchAddress( "BU"   			,&BU 	);
175
	theTree->SetBranchAddress( "U5_enrichment"  ,&U5_enrichment  )	;
176
	theTree->SetBranchAddress( "Pu8"  			,&Pu8  );
177
	theTree->SetBranchAddress( "Pu9"  			,&Pu9  );
178
	theTree->SetBranchAddress( "Pu10" 			,&Pu10 );
179
	theTree->SetBranchAddress( "Pu11" 			,&Pu11 );
180
	theTree->SetBranchAddress( "Pu12" 			,&Pu12 );
181
	theTree->SetBranchAddress( "Am1"  			,&Am1  );
182
	theTree->GetEntry(0);
183

    
184
	Float_t val = (reader->EvaluateRegression( methodName ))[0];
185

    
186
	delete reader;
187
	delete theTree;
188

    
189
	return (double)val; //retourne teneur
190
}
191
//________________________________________________________________________
192
double EQM_CANDU2::GetFissileMolarFraction(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp)
193
{DBGL
194
//double retourTMVA=ExecuteTMVA(CreateTMVAInputTree(Fissil,Fertil,BurnUp));
195
//INFO<<"FissileMolarFraction ="<<retourTMVA<<endl;
196
	return	1.0;
197
}
(3-3/6)