diff --git a/source/branches/CLASSV3/include/XSM_CLOSEST.hxx b/source/branches/CLASSV3/include/XSM_CLOSEST.hxx index 2f861248d83532cc0d9bc212a5042093fcf0291e..a4381a9f789130275e4f776a9a7613f3febae601 100644 --- a/source/branches/CLASSV3/include/XSM_CLOSEST.hxx +++ b/source/branches/CLASSV3/include/XSM_CLOSEST.hxx @@ -54,14 +54,14 @@ public : */ //@{ EvolutionData GetCrossSections(IsotopicVector isotopicvector,double t=0) ; //!< Reason to live of this CLASS Return the closest Evolutiondata - map<IsotopicVector ,EvolutionData > GetFuelDataBank() const { return fFuelDataBank; } //!< Return the FuelDataBank - string GetDataBaseIndex() const { return fDataBaseIndex; } //!< Return the index Name - string GetFuelType() const { return fFuelType; } //!< Return the fuel type of the DB - vector<double> GetFuelParameter() const { return fFuelParameter; } //!< Return the Fuel parameter of the DB - pair<double,double> GetBurnUpRange() const { return fBurnUpRange;} //!< Return the BurnUp range of the DB - bool IsDefine(IsotopicVector IV) const; //!< True the key is define, false unstead - - map<double, EvolutionData> GetDistancesTo(IsotopicVector isotopicvector, double t = 0) const; //! Return a map containing the distance of each EvolutionData in the DataBase to the set IV at the t time + vector< EvolutionData > GetFuelDataBank() const { return fFuelDataBank; } //!< Return the FuelDataBank + string GetDataBaseIndex() const { return fDataBaseIndex; } //!< Return the index Name + string GetFuelType() const { return fFuelType; } //!< Return the fuel type of the DB + vector<double> GetFuelParameter() const { return fFuelParameter; } //!< Return the Fuel parameter of the DB + pair<double,double> GetBurnUpRange() const { return fBurnUpRange;} //!< Return the BurnUp range of the DB + bool IsDefine(IsotopicVector IV) const; //!< True the key is define, false unstead + + map<double, int> GetDistancesTo(IsotopicVector isotopicvector, double t = 0); //! Return a map containing the distance of each EvolutionData in the DataBase to the set IV at the t time //@} //********* Set Method *********// @@ -71,11 +71,10 @@ public : */ //@{ - void SetFuelDataBank(map< IsotopicVector ,EvolutionData > mymap) { fFuelDataBank = mymap; } //!< Set the FuelDataBank map + void SetFuelDataBank(vector< EvolutionData > mymap) { fFuelDataBank = mymap; } //!< Set the FuelDataBank map - void SetDataBaseIndex(string database) { fDataBaseIndex = database;; ReadDataBase(); } //!< Set the Name of the database index - - void SetOldReadMethod(bool val) { fOldReadMethod = val; ReadDataBase();} ///< use the old reading method + void SetDataBaseIndex(string database) { fDataBaseIndex = database;; ReadDataBase(); } //!< Set the Name of the database index + void SetOldReadMethod(bool val) { fOldReadMethod = val; ReadDataBase();} ///< use the old reading method @@ -107,8 +106,7 @@ public : private : - map<IsotopicVector, EvolutionData> fFuelDataBank; ///< DataBanck map - map<IsotopicVector, EvolutionData> fFuelDataBankCalculated; ///< Map of the already calculated EvolutionData (to avoid recalculation...) + vector< EvolutionData > fFuelDataBank; ///< DataBanck map string fDataBaseIndex; ///< Name of the index diff --git a/source/branches/CLASSV3/include/XSModel.hxx b/source/branches/CLASSV3/include/XSModel.hxx index 08c0ce669b9db2621e036e791f0696a96bd8082f..607a19c8bb247f163a16d58a04582ef7e6cd3520 100644 --- a/source/branches/CLASSV3/include/XSModel.hxx +++ b/source/branches/CLASSV3/include/XSModel.hxx @@ -43,6 +43,7 @@ class XSModel : public CLASSObject public : XSModel(); + XSModel(LogFile* log); virtual EvolutionData GetCrossSections(IsotopicVector IV,double t=0) {return 0;} diff --git a/source/branches/CLASSV3/src/XSM_CLOSEST.cxx b/source/branches/CLASSV3/src/XSM_CLOSEST.cxx index 756c448cae9881e9b2d25e70648e0a9db9b8ae4b..dd5a79b8095599dd16833730cbcf55749e8b61ce 100644 --- a/source/branches/CLASSV3/src/XSM_CLOSEST.cxx +++ b/source/branches/CLASSV3/src/XSM_CLOSEST.cxx @@ -27,15 +27,15 @@ // // //________________________________________________________________________ -XSM_CLOSEST::XSM_CLOSEST(LogFile* Log,string DB_index_file, bool oldreadmethod ) +XSM_CLOSEST::XSM_CLOSEST(LogFile* Log,string DB_index_file, bool oldreadmethod ): XSModel(Log) { - SetLog(Log); fOldReadMethod = oldreadmethod; fDataBaseIndex = DB_index_file; fDistanceType = 0; fWeightedDistance = false; fEvolutionDataInterpolation = false; ReadDataBase(); + if(IsLog()) { // Warning @@ -49,40 +49,27 @@ XSM_CLOSEST::XSM_CLOSEST(LogFile* Log,string DB_index_file, bool oldreadmethod ) } } + //________________________________________________________________________ XSM_CLOSEST::~XSM_CLOSEST() { - map<IsotopicVector ,EvolutionData >::iterator it_del; - for( it_del = fFuelDataBank.begin(); it_del != fFuelDataBank.end(); it_del++) - (*it_del).second.DeleteEvolutionData(); + for( int i = 0; i < (int)fFuelDataBank.size(); i++) + fFuelDataBank[i].DeleteEvolutionData(); fFuelDataBank.clear(); - - - for( it_del = fFuelDataBankCalculated.begin(); it_del != fFuelDataBankCalculated.end(); it_del++) - (*it_del).second.DeleteEvolutionData(); - fFuelDataBankCalculated.clear(); } + //________________________________________________________________________ void XSM_CLOSEST::ReadDataBase() { if(fFuelDataBank.size() != 0) { - map<IsotopicVector ,EvolutionData >::iterator it_del; - for( it_del = fFuelDataBank.begin(); it_del != fFuelDataBank.end(); it_del++) - (*it_del).second.DeleteEvolutionData(); + for( int i = 0; i < (int)fFuelDataBank.size(); i++) + fFuelDataBank[i].DeleteEvolutionData(); fFuelDataBank.clear(); } - if(fFuelDataBankCalculated.size() != 0) - { - map<IsotopicVector ,EvolutionData >::iterator it_del; - for( it_del = fFuelDataBankCalculated.begin(); it_del != fFuelDataBankCalculated.end(); it_del++) - (*it_del).second.DeleteEvolutionData(); - fFuelDataBankCalculated.clear(); - } - - + ifstream DataDB(fDataBaseIndex.c_str()); // Open the File if(!DataDB) { @@ -113,9 +100,8 @@ void XSM_CLOSEST::ReadDataBase() getline(DataDB, line); if(line != "") { - EvolutionData* evolutionproduct = new EvolutionData(GetLog(), line, fOldReadMethod); - IsotopicVector ivtmp = evolutionproduct->GetIsotopicVectorAt(0.).GetActinidesComposition(); - fFuelDataBank.insert( pair<IsotopicVector, EvolutionData >(ivtmp , (*evolutionproduct) )); + EvolutionData evolutionproduct(GetLog(), line, fOldReadMethod); + fFuelDataBank.push_back(evolutionproduct); } } @@ -127,22 +113,27 @@ void XSM_CLOSEST::ReadDataBase() //________________________________________________________________________ //________________________________________________________________________ //________________________________________________________________________ -map<double, EvolutionData> XSM_CLOSEST::GetDistancesTo(IsotopicVector isotopicvector, double t) const +map<double, int> XSM_CLOSEST::GetDistancesTo(IsotopicVector isotopicvector, double t) { - map<double, EvolutionData> distances; - - map<IsotopicVector, EvolutionData > evolutiondb = fFuelDataBank; + map<double, int> distances; - map<IsotopicVector, EvolutionData >::iterator it; - for( it = evolutiondb.begin(); it != evolutiondb.end(); it++ ) + for( int i = 0; i < (int)fFuelDataBank.size(); i++) { - pair<map<double, EvolutionData>::iterator, bool> IResult; - - double D = Distance(isotopicvector.GetActinidesComposition(), (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition()/ Norme( (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition() )*Norme(isotopicvector.GetActinidesComposition()) - ,fDistanceType, fDistanceParameter); + pair<map<double, int>::iterator, bool> IResult; + + IsotopicVector ActinidesCompositionAtT = fFuelDataBank[i].GetIsotopicVectorAt(t).GetActinidesComposition(); + IsotopicVector IV_ActinidesComposition = isotopicvector.GetActinidesComposition(); + + double NormalisationFactor = Norme(IV_ActinidesComposition) / Norme( ActinidesCompositionAtT ); + + + double distance = Distance( IV_ActinidesComposition, + ActinidesCompositionAtT / NormalisationFactor, + fDistanceType, + fDistanceParameter); - IResult = distances.insert( pair<double, EvolutionData>( D , (*it).second ) ); + IResult = distances.insert( pair< double, int >(distance, i) ); } return distances; @@ -152,64 +143,70 @@ map<double, EvolutionData> XSM_CLOSEST::GetDistancesTo(IsotopicVector isotopicve EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, double t) { - map<IsotopicVector, EvolutionData > evolutiondb = fFuelDataBank; double distance = 0; - - map<IsotopicVector, EvolutionData >::iterator it_close = evolutiondb.begin(); - - - map<IsotopicVector, EvolutionData >::iterator it; - + int N_BestEvolutionData = 0; + if(fWeightedDistance) { - distance = Distance(isotopicvector.GetActinidesComposition() - * evolutiondb.begin()->second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll() - / isotopicvector.GetActinidesComposition().GetSumOfAll(), - evolutiondb.begin()->second); - - - for( it = evolutiondb.begin(); it != evolutiondb.end(); it++ ) + + IsotopicVector ActinidesCompositionAtT = fFuelDataBank[0].GetIsotopicVectorAt(t).GetActinidesComposition(); + IsotopicVector IV_ActinidesComposition = isotopicvector.GetActinidesComposition(); + + double NormalisationFactor = Norme( ActinidesCompositionAtT ) / Norme(IV_ActinidesComposition); + + + distance = Distance( IV_ActinidesComposition / NormalisationFactor, + fFuelDataBank[0]); + + + for( int i = 1; i < (int)fFuelDataBank.size(); i++) { double D = 0; - D = Distance(isotopicvector.GetActinidesComposition() - * (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll() - / isotopicvector.GetActinidesComposition().GetSumOfAll(), - (*it).second); + ActinidesCompositionAtT = fFuelDataBank[i].GetIsotopicVectorAt(t).GetActinidesComposition(); + IV_ActinidesComposition = isotopicvector.GetActinidesComposition(); + + D = Distance( IV_ActinidesComposition / NormalisationFactor, + fFuelDataBank[i]); + if (D< distance) { distance = D; - it_close = it; + N_BestEvolutionData = i; } } - return (*it_close).second; + return fFuelDataBank[N_BestEvolutionData]; } else if (fEvolutionDataInterpolation) { - map<double, EvolutionData> distance_map = GetDistancesTo(isotopicvector, t); - map<double, EvolutionData>::iterator it_distance; + map<double, int> distance_map = GetDistancesTo(isotopicvector, t); + map<double, int>::iterator it_distance; int NClose = 64; int Nstep = 0; EvolutionData EvolInterpolate; double SumOfDistance = 0; for( it_distance = distance_map.begin(); it_distance != distance_map.end(); it_distance++) { + + double distance = (*it_distance).first; + int ED_Indice = (*it_distance).second; - if((*it_distance).first == 0 ) + if(distance == 0 ) { - EvolInterpolate = Multiply(1,(*it_distance).second); + EvolInterpolate = Multiply(1,fFuelDataBank[ED_Indice]); return EvolInterpolate; } + if(Nstep == 0) - EvolInterpolate = Multiply(1./(*it_distance).first, (*it_distance).second); + EvolInterpolate = Multiply(1./distance, fFuelDataBank[ED_Indice]); else { EvolutionData Evoltmp = EvolInterpolate; - EvolutionData Evoltmp2 = Multiply(1./(*it_distance).first, (*it_distance).second); + EvolutionData Evoltmp2 = Multiply(1./distance, fFuelDataBank[ED_Indice]); EvolInterpolate = Sum(Evoltmp, Evoltmp2); Evoltmp.DeleteEvolutionData(); @@ -218,7 +215,7 @@ EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, doubl } - SumOfDistance += 1./(*it_distance).first; + SumOfDistance += 1./distance; Nstep++; if(Nstep == NClose) break; @@ -235,31 +232,37 @@ EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, doubl } else { - distance = Distance(isotopicvector.GetActinidesComposition(), - evolutiondb.begin()->second.GetIsotopicVectorAt(t).GetActinidesComposition() - / evolutiondb.begin()->second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll() - * isotopicvector.GetActinidesComposition().GetSumOfAll(), - fDistanceType, fDistanceParameter); - for( it = evolutiondb.begin(); it != evolutiondb.end(); it++ ) + IsotopicVector ActinidesCompositionAtT = fFuelDataBank[0].GetIsotopicVectorAt(t).GetActinidesComposition(); + IsotopicVector IV_ActinidesComposition = isotopicvector.GetActinidesComposition(); + + double NormalisationFactor = Norme(IV_ActinidesComposition) / Norme( ActinidesCompositionAtT ); + + + distance = Distance( IV_ActinidesComposition, + ActinidesCompositionAtT / NormalisationFactor, + fDistanceType, + fDistanceParameter); + + for( int i = 1; i < (int)fFuelDataBank.size(); i++) { - double D = 0; - - - D = Distance(isotopicvector.GetActinidesComposition(), - (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition() - / (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll() - * isotopicvector.GetActinidesComposition().GetSumOfAll(), - fDistanceType, fDistanceParameter); - + ActinidesCompositionAtT = fFuelDataBank[i].GetIsotopicVectorAt(t).GetActinidesComposition(); + IV_ActinidesComposition = isotopicvector.GetActinidesComposition(); + + D = Distance( IV_ActinidesComposition, + ActinidesCompositionAtT / NormalisationFactor, + fDistanceType, + fDistanceParameter); + if (D< distance) { distance = D; - it_close = it; + N_BestEvolutionData = i; } } - return (*it_close).second; - + + return fFuelDataBank[N_BestEvolutionData]; + } } @@ -278,21 +281,19 @@ void XSM_CLOSEST::CalculateDistanceParameter() fDistanceParameter.Clear(); //We calculate the weight for the distance calculation. - map<IsotopicVector ,EvolutionData >::iterator it; - map<IsotopicVector ,EvolutionData > FuelDataBank = (*this).GetFuelDataBank(); int NevolutionDatainFuelDataBank = 0; - for( it = FuelDataBank.begin(); it != FuelDataBank.end(); it++ ) + for( int i = 0; i < (int)fFuelDataBank.size(); i++) { NevolutionDatainFuelDataBank++; map<ZAI ,double>::iterator itit; - map<ZAI ,double> isovector=(*it).first.GetIsotopicQuantity(); + map<ZAI ,double> isovector = fFuelDataBank[i].GetIsotopicVectorAt(0).GetIsotopicQuantity(); for(itit=isovector.begin(); itit != isovector.end(); itit++) //Boucle sur ZAI { double TmpXS=0; for( int i=1; i<4; i++ ) //Loop on Reactions 1==fission, 2==capture, 3==n2n - TmpXS+= (*it).second.GetXSForAt(0, (*itit).first, i); + TmpXS+= fFuelDataBank[i].GetXSForAt(0, (*itit).first, i); fDistanceParameter.Add((*itit).first,TmpXS); } @@ -301,7 +302,8 @@ void XSM_CLOSEST::CalculateDistanceParameter() } fDistanceParameter.Multiply( (double)1.0/NevolutionDatainFuelDataBank ); - if(GetLog()){ + if(GetLog()) + { GetLog()->fLog <<"!!INFO!! Distance Parameters "<<endl; map<ZAI ,double >::iterator it2; for(it2 = fDistanceParameter.GetIsotopicQuantity().begin();it2 != fDistanceParameter.GetIsotopicQuantity().end(); it2++) diff --git a/source/branches/CLASSV3/src/XSModel.cxx b/source/branches/CLASSV3/src/XSModel.cxx index c04cbaf27ad10021d54c0ab0c3ec314c06f72c0c..700c79b5229168649ef94f8cc9b7b871d0d7a8bb 100644 --- a/source/branches/CLASSV3/src/XSModel.cxx +++ b/source/branches/CLASSV3/src/XSModel.cxx @@ -14,3 +14,10 @@ XSModel::XSModel(): CLASSObject() { } + + + +XSModel::XSModel(LogFile* log): CLASSObject(log) +{ + +} \ No newline at end of file