CLASS
1.1
|
00001 #include "TreatmentFactory.hxx" 00002 #include "EvolutionDataBase.hxx" 00003 #include "LogFile.hxx" 00004 #include "Defines.hxx" 00005 00006 00007 #include <sstream> 00008 #include <string> 00009 #include <iostream> 00010 #include <cmath> 00011 #include <algorithm> 00012 00013 //________________________________________________________________________ 00014 // 00015 // TreatmentFactory 00016 // 00017 // 00018 // 00019 // 00020 //________________________________________________________________________ 00021 ClassImp(TreatmentFactory) 00022 00023 TreatmentFactory::TreatmentFactory() 00024 { 00025 DBGL; 00026 DBGL; 00027 } 00028 00029 //________________________________________________________________________ 00030 TreatmentFactory::TreatmentFactory(long int abstime, 00031 long int coolingtime , 00032 long int separationtime, 00033 EvolutionDataBase* evolutivedb) 00034 { 00035 DBGL; 00036 fStockManagement = true; 00037 00038 fCoolingTime = coolingtime; 00039 fInternalTime = 0; 00040 fDecayDataBase = evolutivedb; 00041 fSeparationTime = separationtime; 00042 fCreationTime = abstime; 00043 IsStarted = false; 00044 fCoolingLastIndex = 0; 00045 fSeparatingLastIndex = 0; 00046 DBGL; 00047 } 00048 00049 //________________________________________________________________________ 00050 TreatmentFactory::~TreatmentFactory() 00051 { 00052 DBGL; 00053 DBGL; 00054 } 00055 00056 00057 00058 //________________________________________________________________________ 00059 void TreatmentFactory::AddValorisableIV(ZAI zai, double factor) 00060 { 00061 DBGL; 00062 pair<map<ZAI, double>::iterator, bool> IResult; 00063 if(factor > 1) factor = 1; 00064 00065 if(factor > 0) 00066 { 00067 IResult = fValorisableIV.insert( pair<ZAI ,double>(zai, factor)); 00068 if(IResult.second == false) 00069 IResult.first->second = factor; 00070 } 00071 DBGL; 00072 } 00073 00074 00075 //________________________________________________________________________ 00076 // Get Decay 00077 //________________________________________________________________________ 00078 IsotopicVector TreatmentFactory::GetDecayProduct(IsotopicVector isotopicvector, long int t) 00079 { 00080 DBGL; 00081 IsotopicVector IV; 00082 map<ZAI ,double> isotopicquantity = isotopicvector.GetIsotopicQuantity(); 00083 for(map<ZAI ,double >::iterator it = isotopicquantity.begin(); 00084 it != isotopicquantity.end(); it++) 00085 { 00086 if((*it).second > 0) 00087 { 00088 IsotopicVector ivtmp = fDecayDataBase->DecayProduction(it->first, t) * (*it).second ; 00089 IV += ivtmp; 00090 } 00091 } 00092 DBGL; 00093 return IV; 00094 DBGL; 00095 } 00096 00097 00098 //________________________________________________________________________ 00099 // Add Temporary IV : 00100 // Cooling 00101 // Separation 00102 //________________________________________________________________________ 00103 void TreatmentFactory::AddIVCooling(IsotopicVector IV) 00104 { 00105 DBGL; 00106 fIVCooling.push_back(IV); 00107 fCoolingStartingTime.push_back(fInternalTime); 00108 fCoolingLastIndex++; 00109 fCoolingIndex.push_back(fCoolingLastIndex); 00110 fParc->AddTotalCooling(IV); 00111 DBGL; 00112 } 00113 00114 //________________________________________________________________________ 00115 void TreatmentFactory::AddIVSeparating(IsotopicVector IV) 00116 { 00117 DBGL; 00118 fIVSeparating.push_back(IV); 00119 fSeparatingStartingTime.push_back(fInternalTime); 00120 fSeparatingLastIndex++; 00121 fSeparatingIndex.push_back(fSeparatingLastIndex); 00122 fParc->AddTotalSeparating(IV); 00123 DBGL; 00124 } 00125 00126 //________________________________________________________________________ 00127 void TreatmentFactory::AddIVSeparating(IsotopicVector IV, long int absolutadditiontime) 00128 { 00129 DBGL; 00130 fIVSeparating.push_back(IV); 00131 fSeparatingStartingTime.push_back(absolutadditiontime); 00132 fSeparatingLastIndex++; 00133 fSeparatingIndex.push_back(fSeparatingLastIndex); 00134 fParc->AddTotalSeparating(IV); 00135 DBGL; 00136 } 00137 00138 00139 //________________________________________________________________________ 00140 void TreatmentFactory::RemoveIVSeparation(int i) //remove a Treated IsotopicVector 00141 { 00142 DBGL; 00143 fIVSeparating.erase(fIVSeparating.begin()+i); 00144 fSeparatingStartingTime.erase(fSeparatingStartingTime.begin()+i); 00145 fSeparatingIndex.erase(fSeparatingIndex.begin()+i); 00146 DBGL; 00147 } 00148 00149 00150 //________________________________________________________________________ 00151 void TreatmentFactory::RemoveIVCooling(int i) 00152 { 00153 DBGL; 00154 fIVCooling.erase(fIVCooling.begin()+i); 00155 fCoolingStartingTime.erase(fCoolingStartingTime.begin()+i); 00156 fCoolingIndex.erase(fCoolingIndex.begin()+i); 00157 DBGL; 00158 } 00159 00160 void TreatmentFactory::ClearIVStock() 00161 { 00162 DBGL; 00163 fParc->RemoveTotalStock(fIVFullStock); 00164 IsotopicVector EmptyIV; 00165 fIVFullStock = EmptyIV; 00166 fIVStock.clear(); 00167 DBGL; 00168 } 00169 00170 00171 void TreatmentFactory::AddIVStock(IsotopicVector isotopicvector) 00172 { 00173 DBGL; 00174 00175 if(fParc->GetStockManagement() == true) fIVStock.push_back(isotopicvector); 00176 AddIVFullStock(isotopicvector); 00177 fParc->AddTotalStock(isotopicvector); 00178 DBGL; 00179 } 00180 00181 00182 //________________________________________________________________________ 00183 // Time Action with the reste of the Universe : 00184 // In/Out stock 00185 // Evolution : 00186 // Waste, Stock, Separating, Cooling 00187 // Separation 00188 //________________________________________________________________________ 00189 void TreatmentFactory::TakeFromStock(IsotopicVector isotopicvector, int index) 00190 { 00191 DBGL; 00192 if(fStockManagement == true ) 00193 fIVStock[index] -= isotopicvector; 00194 00195 fIVFullStock -= isotopicvector; 00196 fParc->RemoveTotalStock(isotopicvector); 00197 DBGL; 00198 } 00199 00200 //________________________________________________________________________ 00201 pair<IsotopicVector, IsotopicVector> TreatmentFactory::Separation(IsotopicVector isotopicvector) 00202 { 00203 DBGL; 00204 //[0] = stock ; [1] = waste 00205 pair<IsotopicVector, IsotopicVector> IVTmp; 00206 00207 map<ZAI ,double> isotopicquantity = isotopicvector.GetIsotopicQuantity(); 00208 for(map<ZAI ,double >::iterator it = isotopicquantity.begin(); it != isotopicquantity.end(); it++) 00209 { 00210 map<ZAI ,double>::iterator it2; 00211 it2 = fValorisableIV.find((*it).first); 00212 if ( it2 != fValorisableIV.end() ) 00213 { 00214 IVTmp.first.Add( (*it).first, (*it).second * (*it2).second ); //stock 00215 IVTmp.second.Add( (*it).first, (*it).second * (1-(*it2).second) ); //waste 00216 } 00217 else IVTmp.second.Add( (*it).first, (*it).second ); //waste 00218 } 00219 DBGL; 00220 return IVTmp; 00221 } 00222 00223 00224 //________________________________________________________________________ 00225 void TreatmentFactory::WasteEvolution(long int t) 00226 { 00227 DBGL; 00228 // Check if the TF has been created ... 00229 if(t<fCreationTime) return; 00230 00231 long int EvolutionTime = t - fInternalTime; 00232 fIVWaste = GetDecayProduct(fIVWaste , EvolutionTime); 00233 #pragma omp critical(UpdateTotalWasta) 00234 {fParc->AddTotalWaste(fIVWaste);} 00235 DBGL; 00236 } 00237 00238 //________________________________________________________________________ 00239 void TreatmentFactory::StockEvolution(long int t) 00240 { 00241 DBGL; 00242 if(t == fInternalTime) return; 00243 int EvolutionTime = t - fInternalTime; 00244 fIVFullStock = GetDecayProduct(fIVFullStock , EvolutionTime); 00245 #pragma omp critical(UpdateTotalStock) 00246 {fParc->AddTotalStock(fIVFullStock);} 00247 00248 #pragma omp parallel for 00249 for (int i=0; i <(int) fIVStock.size() ; i++) 00250 { 00251 fIVStock[i] = GetDecayProduct(fIVStock[i] , EvolutionTime); 00252 } 00253 00254 00255 DBGL; 00256 } 00257 00258 00259 //________________________________________________________________________ 00260 void TreatmentFactory::SeparatingEvolution(long int t) 00261 { 00262 DBGL; 00263 if(t == fInternalTime) return; 00264 long int EvolutionTime = t - fInternalTime; 00265 #pragma omp parallel for 00266 for (int i = 0 ; i < (int)fIVSeparating.size() ; i++) 00267 { 00268 if (fInternalTime - fSeparatingStartingTime[i] + EvolutionTime >= fSeparationTime) // ">" should not append, only "=" is normal... 00269 { 00270 if (t - fSeparatingStartingTime[i] > fSeparationTime) // Warning & Quit 00271 { 00272 cout << "!!Warning!! !!!TreamtmentFactory!!! Separation Step : "<< t/365.4/3600/24 << " :" 00273 << " An evolution Step is probably missing ! " << endl; 00274 cout << t - fSeparatingStartingTime[i] << " " << fSeparationTime << endl; 00275 fLog->fLog << "!!Warning!! !!!TreamtmentFactory!!! Separation Step : "<< t/365.4/3600/24 << " :" 00276 << " An evolution Step is probably missing ! " << endl; 00277 exit (1); 00278 } 00279 fIVSeparating[i] = GetDecayProduct( fIVSeparating[i] , EvolutionTime); 00280 #pragma omp critical(DeleteSeprationIVPB) 00281 {fSeparationEndOfCycle.push_back(i);} 00282 } 00283 else 00284 { 00285 fIVSeparating[i] = GetDecayProduct( fIVSeparating[i] , EvolutionTime); 00286 #pragma omp critical(UpdateSeparatingStock) 00287 {fParc->AddTotalSeparating(fIVSeparating[i]);} 00288 } 00289 } 00290 sort (fSeparationEndOfCycle.begin(), fSeparationEndOfCycle.end()); 00291 DBGL; 00292 } 00293 00294 //________________________________________________________________________ 00295 void TreatmentFactory::CoolingEvolution(long int t) 00296 { 00297 DBGL; 00298 if(t == fInternalTime) return; 00299 int i; 00300 int RemainingCoolingTime; 00301 long int EvolutionTime = t - fInternalTime; 00302 #pragma omp parallel for 00303 for ( i = 0 ; i < (int)fIVCooling.size() ; i++) 00304 { 00305 if (t - fCoolingStartingTime[i] >= fCoolingTime) // ">" should not append, only "=" is normal... 00306 { 00307 if (t - fCoolingStartingTime[i] > fCoolingTime) // Warning & Quit 00308 { 00309 cout << "!!Warning!! !!!TreamtmentFactory!!! Cooling Step : " << t/365.4/3600/24 << " :" 00310 << " An evolution Step is probably missing ! " << " " << endl; 00311 fLog->fLog << "!!Warning!! !!!TreamtmentFactory!!! Cooling Step : "<< t/365.4/3600/24 << " :" 00312 << " An evolution Step is probably missing ! " << endl; 00313 exit (1); 00314 } 00315 00316 RemainingCoolingTime = fCoolingTime - (fInternalTime - fCoolingStartingTime[i]); 00317 //Cooling Decay 00318 fIVCooling[i] = GetDecayProduct( fIVCooling[i], RemainingCoolingTime); 00319 #pragma omp critical(DeleteCoolingIVPB) 00320 {fCoolingEndOfCycle.push_back(i);} 00321 00322 } 00323 else 00324 { 00325 fIVCooling[i] = GetDecayProduct( fIVCooling[i] , EvolutionTime); 00326 #pragma omp critical(UpdateCoolingStock) 00327 {fParc->AddTotalCooling(fIVCooling[i]);} 00328 } 00329 } 00330 00331 sort (fCoolingEndOfCycle.begin(), fCoolingEndOfCycle.end()); 00332 DBGL; 00333 } 00334 00335 00336 //________________________________________________________________________ 00337 void TreatmentFactory::Evolution(long int t) 00338 { 00339 DBGL; 00340 // Check if the TF has been created ... 00341 if(t<fCreationTime) return; 00342 if(t == fInternalTime) return; 00343 00344 if(fInternalTime ==0 && IsStarted == false) 00345 { 00346 fInternalTime = fCreationTime; 00347 IsStarted = true; 00348 } 00349 // Make the evolution for the Waste ... 00350 WasteEvolution(t); 00351 00352 // ... the Stock ... 00353 StockEvolution(t); 00354 00355 00356 // ... the SeparatingIV ... 00357 SeparatingEvolution(t); 00358 00359 // ... Then Deal the Cooling IV ... 00360 CoolingEvolution(t); 00361 00362 // ... And Finaly update the AbsoluteInternalTime 00363 fInternalTime = t; 00364 00365 00366 DBGL; 00367 } 00368 00369 00370 //________________________________________________________________________ 00371 void TreatmentFactory::Dump() 00372 { 00373 //------ Cooling ------// 00374 for(int i = (int)fCoolingEndOfCycle.size()-1; i >=0 ; i--) // IV End Of Cooling 00375 { 00376 00377 int idx = fCoolingEndOfCycle[i]; // Get Index number 00378 // pair<IsotopicVector, IsotopicVector> SeparatedIV = Separation(fIVCooling[idx]); 00379 // Separation 00380 // fIVWaste += SeparatedIV.second; // Add to waste 00381 // AddIVSeparating(SeparatedIV.first, fInternalTime ); // Add to speration 00382 AddIVStock(fIVCooling[idx]); 00383 00384 fCoolingEndOfCycle.erase(fCoolingEndOfCycle.begin()+i); // Remove index entry 00385 RemoveIVCooling(idx); // Remove IVcooling 00386 } 00387 if((int)fCoolingEndOfCycle.size() != 0 )// Control 00388 { 00389 cout << "Problem while Dumping Cooling"<< endl; 00390 fLog->fLog << "Problem while Dumping Cooling"<< endl; 00391 exit (1); 00392 } 00393 00394 if( (int)fSeparationEndOfCycle.size() == 0 ) return; 00395 00396 //------ Separation ------// 00397 for(int i = (int)fSeparationEndOfCycle.size()-1; i >=0 ; i--) // IV End Of Cooling 00398 { 00399 int idx = fSeparationEndOfCycle[i]; // Get Index number 00400 AddIVStock(fIVSeparating[idx]); 00401 00402 RemoveIVSeparation(idx); // Remove Separated IV 00403 fSeparationEndOfCycle.erase(fSeparationEndOfCycle.begin()+i); // Remove index entry 00404 00405 } 00406 00407 if((int)fSeparationEndOfCycle.size() != 0 ) // Control 00408 { 00409 cout << "Problem while Dumping Separtion"<< endl; 00410 fLog->fLog << "Problem while Dumping Separtion"<< endl; 00411 exit (1); 00412 } 00413 00414 } 00415 00416