Skip to content
Snippets Groups Projects
Commit ab3c1aed authored by BaM's avatar BaM
Browse files

improve constructor;

remove map from XSM_CLOSEST replacing it by a vector :)

git-svn-id: svn+ssh://svn.in2p3.fr/class@299 0e7d625b-0364-4367-a6be-d5be4a48d228
parent d0733df5
No related branches found
No related tags found
No related merge requests found
...@@ -54,14 +54,14 @@ public : ...@@ -54,14 +54,14 @@ public :
*/ */
//@{ //@{
EvolutionData GetCrossSections(IsotopicVector isotopicvector,double t=0) ; //!< Reason to live of this CLASS Return the closest Evolutiondata 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 vector< EvolutionData > GetFuelDataBank() const { return fFuelDataBank; } //!< Return the FuelDataBank
string GetDataBaseIndex() const { return fDataBaseIndex; } //!< Return the index Name string GetDataBaseIndex() const { return fDataBaseIndex; } //!< Return the index Name
string GetFuelType() const { return fFuelType; } //!< Return the fuel type of the DB 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 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 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 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 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 *********// //********* Set Method *********//
...@@ -71,11 +71,10 @@ public : ...@@ -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 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 SetOldReadMethod(bool val) { fOldReadMethod = val; ReadDataBase();} ///< use the old reading method
...@@ -107,8 +106,7 @@ public : ...@@ -107,8 +106,7 @@ public :
private : private :
map<IsotopicVector, EvolutionData> fFuelDataBank; ///< DataBanck map vector< EvolutionData > fFuelDataBank; ///< DataBanck map
map<IsotopicVector, EvolutionData> fFuelDataBankCalculated; ///< Map of the already calculated EvolutionData (to avoid recalculation...)
string fDataBaseIndex; ///< Name of the index string fDataBaseIndex; ///< Name of the index
......
...@@ -43,6 +43,7 @@ class XSModel : public CLASSObject ...@@ -43,6 +43,7 @@ class XSModel : public CLASSObject
public : public :
XSModel(); XSModel();
XSModel(LogFile* log);
virtual EvolutionData GetCrossSections(IsotopicVector IV,double t=0) {return 0;} virtual EvolutionData GetCrossSections(IsotopicVector IV,double t=0) {return 0;}
......
...@@ -27,15 +27,15 @@ ...@@ -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; fOldReadMethod = oldreadmethod;
fDataBaseIndex = DB_index_file; fDataBaseIndex = DB_index_file;
fDistanceType = 0; fDistanceType = 0;
fWeightedDistance = false; fWeightedDistance = false;
fEvolutionDataInterpolation = false; fEvolutionDataInterpolation = false;
ReadDataBase(); ReadDataBase();
if(IsLog()) if(IsLog())
{ {
// Warning // Warning
...@@ -49,40 +49,27 @@ XSM_CLOSEST::XSM_CLOSEST(LogFile* Log,string DB_index_file, bool oldreadmethod ) ...@@ -49,40 +49,27 @@ XSM_CLOSEST::XSM_CLOSEST(LogFile* Log,string DB_index_file, bool oldreadmethod )
} }
} }
//________________________________________________________________________ //________________________________________________________________________
XSM_CLOSEST::~XSM_CLOSEST() XSM_CLOSEST::~XSM_CLOSEST()
{ {
map<IsotopicVector ,EvolutionData >::iterator it_del; for( int i = 0; i < (int)fFuelDataBank.size(); i++)
for( it_del = fFuelDataBank.begin(); it_del != fFuelDataBank.end(); it_del++) fFuelDataBank[i].DeleteEvolutionData();
(*it_del).second.DeleteEvolutionData();
fFuelDataBank.clear(); fFuelDataBank.clear();
for( it_del = fFuelDataBankCalculated.begin(); it_del != fFuelDataBankCalculated.end(); it_del++)
(*it_del).second.DeleteEvolutionData();
fFuelDataBankCalculated.clear();
} }
//________________________________________________________________________ //________________________________________________________________________
void XSM_CLOSEST::ReadDataBase() void XSM_CLOSEST::ReadDataBase()
{ {
if(fFuelDataBank.size() != 0) if(fFuelDataBank.size() != 0)
{ {
map<IsotopicVector ,EvolutionData >::iterator it_del; for( int i = 0; i < (int)fFuelDataBank.size(); i++)
for( it_del = fFuelDataBank.begin(); it_del != fFuelDataBank.end(); it_del++) fFuelDataBank[i].DeleteEvolutionData();
(*it_del).second.DeleteEvolutionData();
fFuelDataBank.clear(); 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 ifstream DataDB(fDataBaseIndex.c_str()); // Open the File
if(!DataDB) if(!DataDB)
{ {
...@@ -113,9 +100,8 @@ void XSM_CLOSEST::ReadDataBase() ...@@ -113,9 +100,8 @@ void XSM_CLOSEST::ReadDataBase()
getline(DataDB, line); getline(DataDB, line);
if(line != "") if(line != "")
{ {
EvolutionData* evolutionproduct = new EvolutionData(GetLog(), line, fOldReadMethod); EvolutionData evolutionproduct(GetLog(), line, fOldReadMethod);
IsotopicVector ivtmp = evolutionproduct->GetIsotopicVectorAt(0.).GetActinidesComposition(); fFuelDataBank.push_back(evolutionproduct);
fFuelDataBank.insert( pair<IsotopicVector, EvolutionData >(ivtmp , (*evolutionproduct) ));
} }
} }
...@@ -127,22 +113,27 @@ void XSM_CLOSEST::ReadDataBase() ...@@ -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<double, int> distances;
map<IsotopicVector, EvolutionData > evolutiondb = fFuelDataBank;
map<IsotopicVector, EvolutionData >::iterator it; for( int i = 0; i < (int)fFuelDataBank.size(); i++)
for( it = evolutiondb.begin(); it != evolutiondb.end(); it++ )
{ {
pair<map<double, EvolutionData>::iterator, bool> IResult; pair<map<double, int>::iterator, bool> IResult;
double D = Distance(isotopicvector.GetActinidesComposition(), (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition()/ Norme( (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition() )*Norme(isotopicvector.GetActinidesComposition()) IsotopicVector ActinidesCompositionAtT = fFuelDataBank[i].GetIsotopicVectorAt(t).GetActinidesComposition();
,fDistanceType, fDistanceParameter); 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; return distances;
...@@ -152,64 +143,70 @@ map<double, EvolutionData> XSM_CLOSEST::GetDistancesTo(IsotopicVector isotopicve ...@@ -152,64 +143,70 @@ map<double, EvolutionData> XSM_CLOSEST::GetDistancesTo(IsotopicVector isotopicve
EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, double t) EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, double t)
{ {
map<IsotopicVector, EvolutionData > evolutiondb = fFuelDataBank;
double distance = 0; double distance = 0;
int N_BestEvolutionData = 0;
map<IsotopicVector, EvolutionData >::iterator it_close = evolutiondb.begin();
map<IsotopicVector, EvolutionData >::iterator it;
if(fWeightedDistance) if(fWeightedDistance)
{ {
distance = Distance(isotopicvector.GetActinidesComposition()
* evolutiondb.begin()->second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll() IsotopicVector ActinidesCompositionAtT = fFuelDataBank[0].GetIsotopicVectorAt(t).GetActinidesComposition();
/ isotopicvector.GetActinidesComposition().GetSumOfAll(), IsotopicVector IV_ActinidesComposition = isotopicvector.GetActinidesComposition();
evolutiondb.begin()->second);
double NormalisationFactor = Norme( ActinidesCompositionAtT ) / Norme(IV_ActinidesComposition);
for( it = evolutiondb.begin(); it != evolutiondb.end(); it++ )
distance = Distance( IV_ActinidesComposition / NormalisationFactor,
fFuelDataBank[0]);
for( int i = 1; i < (int)fFuelDataBank.size(); i++)
{ {
double D = 0; double D = 0;
D = Distance(isotopicvector.GetActinidesComposition() ActinidesCompositionAtT = fFuelDataBank[i].GetIsotopicVectorAt(t).GetActinidesComposition();
* (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll() IV_ActinidesComposition = isotopicvector.GetActinidesComposition();
/ isotopicvector.GetActinidesComposition().GetSumOfAll(),
(*it).second); D = Distance( IV_ActinidesComposition / NormalisationFactor,
fFuelDataBank[i]);
if (D< distance) if (D< distance)
{ {
distance = D; distance = D;
it_close = it; N_BestEvolutionData = i;
} }
} }
return (*it_close).second; return fFuelDataBank[N_BestEvolutionData];
} }
else if (fEvolutionDataInterpolation) else if (fEvolutionDataInterpolation)
{ {
map<double, EvolutionData> distance_map = GetDistancesTo(isotopicvector, t); map<double, int> distance_map = GetDistancesTo(isotopicvector, t);
map<double, EvolutionData>::iterator it_distance; map<double, int>::iterator it_distance;
int NClose = 64; int NClose = 64;
int Nstep = 0; int Nstep = 0;
EvolutionData EvolInterpolate; EvolutionData EvolInterpolate;
double SumOfDistance = 0; double SumOfDistance = 0;
for( it_distance = distance_map.begin(); it_distance != distance_map.end(); it_distance++) 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; return EvolInterpolate;
} }
if(Nstep == 0) if(Nstep == 0)
EvolInterpolate = Multiply(1./(*it_distance).first, (*it_distance).second); EvolInterpolate = Multiply(1./distance, fFuelDataBank[ED_Indice]);
else else
{ {
EvolutionData Evoltmp = EvolInterpolate; 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); EvolInterpolate = Sum(Evoltmp, Evoltmp2);
Evoltmp.DeleteEvolutionData(); Evoltmp.DeleteEvolutionData();
...@@ -218,7 +215,7 @@ EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, doubl ...@@ -218,7 +215,7 @@ EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, doubl
} }
SumOfDistance += 1./(*it_distance).first; SumOfDistance += 1./distance;
Nstep++; Nstep++;
if(Nstep == NClose) break; if(Nstep == NClose) break;
...@@ -235,31 +232,37 @@ EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, doubl ...@@ -235,31 +232,37 @@ EvolutionData XSM_CLOSEST::GetCrossSections(IsotopicVector isotopicvector, doubl
} }
else else
{ {
distance = Distance(isotopicvector.GetActinidesComposition(), IsotopicVector ActinidesCompositionAtT = fFuelDataBank[0].GetIsotopicVectorAt(t).GetActinidesComposition();
evolutiondb.begin()->second.GetIsotopicVectorAt(t).GetActinidesComposition() IsotopicVector IV_ActinidesComposition = isotopicvector.GetActinidesComposition();
/ evolutiondb.begin()->second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll()
* isotopicvector.GetActinidesComposition().GetSumOfAll(), double NormalisationFactor = Norme(IV_ActinidesComposition) / Norme( ActinidesCompositionAtT );
fDistanceType, fDistanceParameter);
for( it = evolutiondb.begin(); it != evolutiondb.end(); it++ )
distance = Distance( IV_ActinidesComposition,
ActinidesCompositionAtT / NormalisationFactor,
fDistanceType,
fDistanceParameter);
for( int i = 1; i < (int)fFuelDataBank.size(); i++)
{ {
double D = 0; double D = 0;
ActinidesCompositionAtT = fFuelDataBank[i].GetIsotopicVectorAt(t).GetActinidesComposition();
IV_ActinidesComposition = isotopicvector.GetActinidesComposition();
D = Distance(isotopicvector.GetActinidesComposition(),
(*it).second.GetIsotopicVectorAt(t).GetActinidesComposition() D = Distance( IV_ActinidesComposition,
/ (*it).second.GetIsotopicVectorAt(t).GetActinidesComposition().GetSumOfAll() ActinidesCompositionAtT / NormalisationFactor,
* isotopicvector.GetActinidesComposition().GetSumOfAll(), fDistanceType,
fDistanceType, fDistanceParameter); fDistanceParameter);
if (D< distance) if (D< distance)
{ {
distance = D; distance = D;
it_close = it; N_BestEvolutionData = i;
} }
} }
return (*it_close).second;
return fFuelDataBank[N_BestEvolutionData];
} }
} }
...@@ -278,21 +281,19 @@ void XSM_CLOSEST::CalculateDistanceParameter() ...@@ -278,21 +281,19 @@ void XSM_CLOSEST::CalculateDistanceParameter()
fDistanceParameter.Clear(); fDistanceParameter.Clear();
//We calculate the weight for the distance calculation. //We calculate the weight for the distance calculation.
map<IsotopicVector ,EvolutionData >::iterator it;
map<IsotopicVector ,EvolutionData > FuelDataBank = (*this).GetFuelDataBank();
int NevolutionDatainFuelDataBank = 0; int NevolutionDatainFuelDataBank = 0;
for( it = FuelDataBank.begin(); it != FuelDataBank.end(); it++ ) for( int i = 0; i < (int)fFuelDataBank.size(); i++)
{ {
NevolutionDatainFuelDataBank++; NevolutionDatainFuelDataBank++;
map<ZAI ,double>::iterator itit; 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 for(itit=isovector.begin(); itit != isovector.end(); itit++) //Boucle sur ZAI
{ {
double TmpXS=0; double TmpXS=0;
for( int i=1; i<4; i++ ) //Loop on Reactions 1==fission, 2==capture, 3==n2n 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); fDistanceParameter.Add((*itit).first,TmpXS);
} }
...@@ -301,7 +302,8 @@ void XSM_CLOSEST::CalculateDistanceParameter() ...@@ -301,7 +302,8 @@ void XSM_CLOSEST::CalculateDistanceParameter()
} }
fDistanceParameter.Multiply( (double)1.0/NevolutionDatainFuelDataBank ); fDistanceParameter.Multiply( (double)1.0/NevolutionDatainFuelDataBank );
if(GetLog()){ if(GetLog())
{
GetLog()->fLog <<"!!INFO!! Distance Parameters "<<endl; GetLog()->fLog <<"!!INFO!! Distance Parameters "<<endl;
map<ZAI ,double >::iterator it2; map<ZAI ,double >::iterator it2;
for(it2 = fDistanceParameter.GetIsotopicQuantity().begin();it2 != fDistanceParameter.GetIsotopicQuantity().end(); it2++) for(it2 = fDistanceParameter.GetIsotopicQuantity().begin();it2 != fDistanceParameter.GetIsotopicQuantity().end(); it2++)
......
...@@ -14,3 +14,10 @@ XSModel::XSModel(): CLASSObject() ...@@ -14,3 +14,10 @@ XSModel::XSModel(): CLASSObject()
{ {
} }
XSModel::XSModel(LogFile* log): CLASSObject(log)
{
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment