From e4f4c88b1e75c4e5995f54890e5ebccccb7351a7 Mon Sep 17 00:00:00 2001 From: Baptiste LENIAU <baptiste.leniau@subatech.in2p3.fr> Date: Tue, 19 Apr 2016 18:05:13 +0000 Subject: [PATCH] putain de merge git-svn-id: svn+ssh://svn.in2p3.fr/class@816 0e7d625b-0364-4367-a6be-d5be4a48d228 --- .../To_Merge/src/FabricationPlant.cxx | 600 +++++++++--------- 1 file changed, 289 insertions(+), 311 deletions(-) diff --git a/source/branches/To_Merge/src/FabricationPlant.cxx b/source/branches/To_Merge/src/FabricationPlant.cxx index 3e3c0573b..12bb8eaa9 100644 --- a/source/branches/To_Merge/src/FabricationPlant.cxx +++ b/source/branches/To_Merge/src/FabricationPlant.cxx @@ -3,15 +3,13 @@ #include "Storage.hxx" #include "Reactor.hxx" #include "EvolutionData.hxx" +#include "DecayDataBank.hxx" #include "PhysicsModels.hxx" #include "IsotopicVector.hxx" #include "Scenario.hxx" #include "CLASSLogger.hxx" #include "CLASSConstante.hxx" - - - #include "TMatrixT.h" #include <sstream> @@ -19,24 +17,21 @@ #include <iostream> #include <cmath> #include <algorithm> -#include <ctime> -#include <cstdlib> +#include <stdarg.h> + +#include <ctime> +#include <cstdlib> ClassImp(FabricationPlant) - //________________________________________________________________________ //________________________________________________________________________ //________________________________________________________________________ // // FabricationPlant - // - // - // - // //________________________________________________________________________ //________________________________________________________________________ -//________________________________________________________________________ + FabricationPlant::FabricationPlant():CLASSFacility(16) { SetName("F_FabricationPLant."); @@ -54,15 +49,13 @@ DBGL fStorageManagement = kpLiFo; fIsSeparationManagement = true; fSubstitutionFuel = false; - fSubstitutionFissile = false; - fIsReplaceFissileStock = false; fReUsable = 0; fIsReusable = false; - - INFO << " A FabricationPlant has been define :" << endl; - INFO << "\t Chronological Stock Priority has been set! " << endl; - INFO << "\t Fabrication time set to \t " << (double)(GetCycleTime()/cYear) << " year" << endl << endl; + + INFO << " A FabricationPlant has been define :" << endl; + INFO << "\t Chronological Stock Priority has been set! "<< endl; + INFO << "\t Fabrication time set to \t " << (double)(GetCycleTime()/cYear) << " year" << endl << endl; DBGL } @@ -73,7 +66,6 @@ FabricationPlant::~FabricationPlant() } - //________________________________________________________________________ void FabricationPlant::SetSeparartionEfficiencyIV(ZAI zai, double factor) { @@ -83,7 +75,7 @@ void FabricationPlant::SetSeparartionEfficiencyIV(ZAI zai, double factor) if(factor > 0) { - IResult = fSeparationLostFraction.GetIsotopicQuantity().insert( pair<ZAI ,double>(zai, 1 - factor)); + IResult = fSeparationLostFraction.GetIsotopicQuantity().insert( pair<ZAI ,double>(zai, 1 - factor)); if(!IResult.second) IResult.first->second = 1 - factor; } @@ -99,7 +91,7 @@ void FabricationPlant::Evolution(cSecond t) { // Check if the FabricationPlant has been created ... - if(t == fInternalTime && t != 0) return; + if(t == fInternalTime && t != 0) return; // Make the evolution for the FabricationPlant ... FabricationPlantEvolution(t); //Update Inside IsotopicVector @@ -113,36 +105,35 @@ void FabricationPlant::Evolution(cSecond t) void FabricationPlant::FabricationPlantEvolution(cSecond t) { DBGL + map<int ,cSecond >::iterator it; - for( it = fReactorNextStep.begin(); it != fReactorNextStep.end(); it++ ) + for( it = fReactorNextStep.begin(); it!= fReactorNextStep.end(); it++ ) { double R_CreactionTime = GetParc()->GetReactor()[ (*it).first ]->GetCreationTime(); - double R_LifeTime = GetParc()->GetReactor()[ (*it).first ]->GetLifeTime(); + double R_LifeTime = GetParc()->GetReactor()[ (*it).first ]->GetLifeTime(); int ReactorId = (*it).first; pair<CLASSFuel, double> R_Fuel = GetParc()->GetReactor()[ReactorId]->GetFuelPlan()->GetFuelAt( t + GetCycleTime() ); - double R_BU = R_Fuel.second; - double R_Power = GetParc()->GetReactor()[ReactorId]->GetPower(); - double R_HMMass = GetParc()->GetReactor()[ReactorId]->GetHeavyMetalMass(); - cSecond R_CycleTime = (cSecond) (R_BU*1e9 / (R_Power) * R_HMMass * 3600 * 24); - - + double R_BU = R_Fuel.second; + double R_Power = GetParc()->GetReactor()[ReactorId]->GetPower(); + double R_HMMass = GetParc()->GetReactor()[ReactorId]->GetHeavyMetalMass(); + cSecond R_CycleTime = (cSecond) (R_BU*1e9 / (R_Power) * R_HMMass * 3600 * 24); if( R_CycleTime < GetCycleTime()) { - ERROR << "Reactor Cycle Time is shorter than Fabrication Time of the fuel, we cannot deal it upto now!!!" << endl; + ERROR << "Reactor Cycle Time is shorter than Fabrication Time of the fuel, we cannot deal it upto now!!!"<< endl; exit(1); } if( t + GetCycleTime() >= R_CreactionTime && t + GetCycleTime() < R_CreactionTime + R_LifeTime) { - if( (*it).second == t ) + if( (*it).second == t ) { #pragma omp critical(FuelBuild) { if( R_Fuel.first.GetPhysicsModels() ) { - BuildFuelForReactor( (*it).first, t ); + BuildFuelForReactor( (*it).first, t ); } (*it).second += R_CycleTime; } @@ -178,70 +169,70 @@ void FabricationPlant::UpdateInsideIV() void FabricationPlant::BuildFuelForReactor(int ReactorId, cSecond t) { DBGL - if(fFissileStorage.size() == 0) - { - ERROR << " One need at least one Fissile storage to build fuel " << endl; - ERROR << " Use AddFissileStorage to add a stock to provide fissil material... " << endl; - ERROR << " One need at least one Fissile storage to build fuel " << endl; - exit(1); - } - + double R_HM_Mass = GetParc()->GetReactor()[ ReactorId ]->GetHeavyMetalMass(); + double R_CycleTime = GetParc()->GetReactor()[ ReactorId ]->GetCycleTime(); + double R_Power = GetParc()->GetReactor()[ ReactorId ]->GetPower(); + + pair<CLASSFuel, double > FuelBU = GetParc()->GetReactor()[ReactorId]->GetFuelPlan()->GetFuelAt(t+GetCycleTime()) ; + PhysicsModels FuelType = *FuelBU.first.GetPhysicsModels(); + double R_BU = FuelBU.second; + + map < string , vector <IsotopicVector> >::iterator it_s_vIV; + map < string , vector <double> >::iterator it_s_vD; + map < string , bool >::iterator it_s_B; - double R_HM_Mass = GetParc()->GetReactor()[ ReactorId ]->GetHeavyMetalMass(); - double R_CycleTime = GetParc()->GetReactor()[ ReactorId ]->GetCycleTime(); - double R_Power = GetParc()->GetReactor()[ ReactorId ]->GetPower(); + fStreamList = FuelType.GetEquivalenceModel()->GetAllStreamList(); + + BuildArray(ReactorId); // Checker chez les stocks si les StreamList sont présentes + // Grosse map qui contient tous les IV + // séparation + refroidissement virtuel + // Construit les stocks de matière infini (=taille du réacteur) - pair<CLASSFuel, double > FuelBU = GetParc()->GetReactor()[ReactorId]->GetFuelPlan()->GetFuelAt(t+GetCycleTime()) ; - PhysicsModels FuelType = *FuelBU.first.GetPhysicsModels(); - double R_BU = FuelBU.second; + // string="MA, .." LambdaArray = tableau sur les IV + map < string , vector <double> > LambdaArray = FuelType.GetEquivalenceModel()->BuildFuel(R_BU, R_HM_Mass, fStreamArray); + + bool FuelCanBeBuilt = true; + double LambdaSum = 0; - fFissileList = FuelType.GetEquivalenceModel()->GetFissileList(); - BuildFissileArray(); - - // If there is not enough Fissile its possible to take from an infinite fissile stock - if( !fIsReplaceFissileStock && fSubstitutionFissile )//if it is defined and wanted - { IsotopicVector CooledSeparatedIV = GetDecay( fSubstitutionFissileIV , GetCycleTime()); - fFissileArray.push_back( CooledSeparatedIV/ CooledSeparatedIV.GetTotalMass() * R_HM_Mass ); + for( it_s_vD = LambdaArray.begin(); it_s_vD != LambdaArray.end(); it_s_vD++) + { + for(int i = 0; i < (int)LambdaArray[(*it_s_vD).first].size();i++) {fErrorOnLambda[(*it_s_vD).first] = false;} } - - fFertileList = FuelType.GetEquivalenceModel()->GetFertileList(); - - - if(fFertileStorage.size() != 0) // If the fertile need to be taken in stock - BuildFertileArray(); - else // if their is not stock and the fertile come from outside of the park - { - fFertileArray.push_back( fFertileList / fFertileList.GetTotalMass() * R_HM_Mass ); - DBGV("Fertile Array size : " << fFertileArray.size()) + for( it_s_vD = LambdaArray.begin(); it_s_vD != LambdaArray.end(); it_s_vD++) + { + for(int i = 0; i < (int)LambdaArray[(*it_s_vD).first].size();i++) + { + if(LambdaArray[(*it_s_vD).first][i] == -1){fErrorOnLambda[(*it_s_vD).first] = true;} + LambdaSum += LambdaArray[(*it_s_vD).first][i]; + } } - - vector<double> LambdaArray = FuelType.GetEquivalenceModel()->BuildFuel(R_BU, R_HM_Mass, fFissileArray, fFertileArray); - - double LambdaSum = 0; - for(int i = 0; i < (int)fFissileArray.size();i++) - LambdaSum += LambdaArray[i]; + for( it_s_B = fErrorOnLambda.begin(); it_s_B != fErrorOnLambda.end(); it_s_B++) + { + if(fErrorOnLambda[(*it_s_B).first]){FuelCanBeBuilt = false;} + } - if(LambdaArray[0] != -1 && LambdaSum > 0 ) - { - DBGV("Building process suceed: ") + if(FuelCanBeBuilt && LambdaSum > 0 ) + { + DBGV("Building process from initial stocks has succeeded : ") + IsotopicVector IV = BuildFuelFromEqModel(LambdaArray); + IsotopicVector LoadedIV = GetDecay(IV,fCycleTime); - IsotopicVector IV = BuildFuelFromEqModel(LambdaArray); - EvolutionData EvolDB = FuelType.GenerateEvolutionData( GetDecay(IV,fCycleTime), R_CycleTime, R_Power); + EvolutionData EvolDB = FuelType.GenerateEvolutionData(GetDecay(IV,fCycleTime), R_CycleTime, R_Power); { pair<map<int, IsotopicVector>::iterator, bool> IResult; IResult = fReactorFuturIV.insert( pair<int, IsotopicVector>(ReactorId, IV) ); if(!IResult.second) - IResult.first->second = IV; + IResult.first->second = IV; } { pair<map<int, EvolutionData>::iterator, bool> IResult; IResult = fReactorFuturDB.insert( pair<int, EvolutionData>(ReactorId,EvolDB) ); if(!IResult.second) - IResult.first->second = EvolDB; + IResult.first->second = EvolDB; } fInsideIV += IV; AddCumulativeIVIn(IV); @@ -250,10 +241,90 @@ void FabricationPlant::BuildFuelForReactor(int ReactorId, cSecond t) } else { - DBGV("Building process failed: ") - if (!fSubstitutionFuel) + DBGV("Building process from initial stocks failed: ") + //If the building fails : possibility to take a materials from an infinite stock composed of a substitution IV defined by user + bool IsSubstitutionMaterials = false; + + for( it_s_B = fErrorOnLambda.begin(); it_s_B != fErrorOnLambda.end(); it_s_B++) + { + if(fErrorOnLambda[(*it_s_B).first] && fSubstitutionMaterialFromIV[(*it_s_B).first]) + IsSubstitutionMaterials = true; + else if(fErrorOnLambda[(*it_s_B).first] && !fSubstitutionMaterialFromIV[(*it_s_B).first]) + IsSubstitutionMaterials = false; + } + + if(IsSubstitutionMaterials) + { + DBGV("Using substitute : -> From infinite substitutions IV ") + + //Make the user specified composition to decay the fabrication time + + map < string , IsotopicVector> CooledSeparatedIV; + + for( it_s_B = fSubstitutionMaterialFromIV.begin(); it_s_B != fSubstitutionMaterialFromIV.end(); it_s_B++) + CooledSeparatedIV[(*it_s_B).first] = GetDecay(fSubstitutionIV[(*it_s_B).first], GetCycleTime()); + + for( it_s_vIV = fStreamArray.begin(); it_s_vIV != fStreamArray.end(); it_s_vIV++) + { + if(fErrorOnLambda[(*it_s_vIV).first]) + { + fStreamArray[(*it_s_vIV).first].clear(); + fStreamArray[(*it_s_vIV).first].push_back(CooledSeparatedIV[(*it_s_vIV).first]); + } + } + + //Building the fuel : + for( it_s_vD = LambdaArray.begin(); it_s_vD != LambdaArray.end(); it_s_vD++) + LambdaArray[(*it_s_vD).first].clear(); + + LambdaArray = FuelType.GetEquivalenceModel()->BuildFuel(R_BU, R_HM_Mass, fStreamArray); + IsotopicVector IV = BuildFuelFromEqModel(LambdaArray); + + //Generating the EvolutionData + EvolutionData EvolDB = FuelType.GenerateEvolutionData(GetDecay(IV,fCycleTime), R_CycleTime, R_Power); + { + pair<map<int, IsotopicVector>::iterator, bool> IResult; + IResult = fReactorFuturIV.insert( pair<int, IsotopicVector>(ReactorId, IV) ); + if(!IResult.second) + IResult.first->second = IV; + } + { + pair<map<int, EvolutionData>::iterator, bool> IResult; + IResult = fReactorFuturDB.insert( pair<int, EvolutionData>(ReactorId,EvolDB) ); + if(!IResult.second) + IResult.first->second = EvolDB; + } + GetParc()->AddOutIncome(IV); + fInsideIV += IV; + AddCumulativeIVIn(IV); + DBGL + } + else if(fSubstitutionFuel) { - DBGV("Reactor not loaded ") + DBGV("Using substitute : -> From a fixed data base") + IsotopicVector IV = fSubstitutionEvolutionData.GetIsotopicVectorAt(0); + EvolutionData evolutiondb = fSubstitutionEvolutionData * R_HM_Mass / IV.GetTotalMass(); + + IV = IV* R_HM_Mass / IV.GetTotalMass(); + { + pair<map<int, IsotopicVector>::iterator, bool> IResult; + IResult = fReactorFuturIV.insert( pair<int, IsotopicVector>(ReactorId, IV) ); + if(!IResult.second) + IResult.first->second = IV; + } + { + pair<map<int, EvolutionData>::iterator, bool> IResult; + IResult = fReactorFuturDB.insert( pair<int, EvolutionData>(ReactorId,evolutiondb) ); + if(!IResult.second) + IResult.first->second = evolutiondb; + } + GetParc()->AddOutIncome( IV ); + fInsideIV += IV; + AddCumulativeIVIn(IV); + } + else + { + DBGV("No Alternative Solution. Reactor not loaded. ") { EvolutionData EmptyDB; pair<map<int, EvolutionData>::iterator, bool> IResult; @@ -269,122 +340,62 @@ void FabricationPlant::BuildFuelForReactor(int ReactorId, cSecond t) IResult.first->second = EmptyIV; } } - else - { - DBGV("Using substitute : ") - if(fSubstitutionFissile)//if the build fail possibility to take a fissile material from an infinite fissile stock (if infinite stock defined) - { - DBGV("->From an infinite stock") - //make the user specified fissil composition to decay the fabrication time - IsotopicVector CooledSeparatedIV = GetDecay(fSubstitutionFissileIV, GetCycleTime()); - //Building the fuel : - double MolarFissileContent = FuelType.GetEquivalenceModel()->GetFissileMolarFraction(CooledSeparatedIV,fFertileList, R_BU); - IsotopicVector BuiltFuel = MolarFissileContent*fSubstitutionFissileIV/fSubstitutionFissileIV.GetSumOfAll() + (1-MolarFissileContent)*fFertileList/fFertileList.GetSumOfAll(); - IsotopicVector IV = BuiltFuel/ BuiltFuel.GetTotalMass() * R_HM_Mass; - - //Generating the EvolutionData - EvolutionData EvolDB = FuelType.GenerateEvolutionData( GetDecay(IV,fCycleTime), R_CycleTime, R_Power); - - { - pair<map<int, IsotopicVector>::iterator, bool> IResult; - IResult = fReactorFuturIV.insert( pair<int, IsotopicVector>(ReactorId, IV) ); - if(!IResult.second) - IResult.first->second = IV; - } - { - pair<map<int, EvolutionData>::iterator, bool> IResult; - IResult = fReactorFuturDB.insert( pair<int, EvolutionData>(ReactorId,EvolDB) ); - if(!IResult.second) - IResult.first->second = EvolDB; - } - - GetParc()->AddOutIncome(IV); - fInsideIV += IV; - AddCumulativeIVIn(IV); - - DBGL - } - else - { - DBGV("->From a fixed data base") - IsotopicVector IV = fSubstitutionEvolutionData.GetIsotopicVectorAt(0); - EvolutionData evolutiondb = fSubstitutionEvolutionData * R_HM_Mass / IV.GetTotalMass(); - - IV = IV* R_HM_Mass / IV.GetTotalMass(); - { - pair<map<int, IsotopicVector>::iterator, bool> IResult; - IResult = fReactorFuturIV.insert( pair<int, IsotopicVector>(ReactorId, IV) ); - if(!IResult.second) - IResult.first->second = IV; - } - { - pair<map<int, EvolutionData>::iterator, bool> IResult; - IResult = fReactorFuturDB.insert( pair<int, EvolutionData>(ReactorId,evolutiondb) ); - if(!IResult.second) - IResult.first->second = evolutiondb; - } - GetParc()->AddOutIncome( IV ); - fInsideIV += IV; - AddCumulativeIVIn(IV); - } - } DBGL ResetArrays(); return; } - DBGL +DBGL } //________________________________________________________________________ void FabricationPlant::BuildArray(int ReactorId) { DBGL - double R_HM_Mass = GetParc()->GetReactor()[ ReactorId ]->GetHeavyMetalMass(); + double R_HM_Mass = GetParc()->GetReactor()[ ReactorId ]->GetHeavyMetalMass(); - vector <IsotopicVector> StreamArray; - vector <cSecond> StreamArrayTime; - vector < pair<int,int> > StreamArrayAdress; - - map < string , IsotopicVector>::iterator it; - - for( it = fStreamList.begin(); it != fStreamList.end(); it++) - { - if(fInfiniteMaterialFromList[(*it).first]) - { - IsotopicVector IV = (*it).second / (*it).second.GetTotalMass() * R_HM_Mass; - StreamArray.push_back(IV); - StreamArrayAdress.push_back(pair<int,int>(0,0)); - StreamArrayTime.push_back(0); - } - else - { - for(int j = 0; j < (int)fStorage[(*it).first].size(); j++) - { - vector<IsotopicVector> IVArray = fStorage[(*it).first][j]->GetIVArray(); - for(int k = 0; k < (int)IVArray.size(); k++) - { - IsotopicVector SeparatedIV = Separation(IVArray[k], (*it).second).first; - if(Norme(SeparatedIV) != 0) - { - IsotopicVector CooledSeparatedIV = GetDecay( SeparatedIV , GetCycleTime()); - StreamArray.push_back( CooledSeparatedIV ); - StreamArrayAdress.push_back( pair<int,int>(j,k) ); - StreamArrayTime.push_back(fStorage[(*it).first][j]->GetIVArrayArrivalTime()[k]); - } - } - } - } - - fStreamArray[(*it).first] = StreamArray; StreamArray.clear(); - fStreamArrayAdress[(*it).first] = StreamArrayAdress; StreamArrayAdress.clear(); - fStreamArrayTime[(*it).first] = StreamArrayTime; StreamArrayTime.clear(); - } + vector <IsotopicVector> StreamArray; + vector <cSecond> StreamArrayTime; + vector < pair<int,int> > StreamArrayAdress; + + map < string , IsotopicVector>::iterator it; + + for( it = fStreamList.begin(); it != fStreamList.end(); it++) + { + if(fInfiniteMaterialFromList[(*it).first]) + { + IsotopicVector IV = (*it).second / (*it).second.GetTotalMass() * R_HM_Mass; + StreamArray.push_back(IV); + StreamArrayAdress.push_back(pair<int,int>(0,0)); + StreamArrayTime.push_back(0); + } + else + { + for(int j = 0; j < (int)fStorage[(*it).first].size(); j++) + { + vector<IsotopicVector> IVArray = fStorage[(*it).first][j]->GetIVArray(); + for(int k = 0; k < (int)IVArray.size(); k++) + { + IsotopicVector SeparatedIV = Separation(IVArray[k], (*it).second).first; + if(Norme(SeparatedIV) != 0) + { + IsotopicVector CooledSeparatedIV = GetDecay( SeparatedIV , GetCycleTime()); + StreamArray.push_back( CooledSeparatedIV ); + StreamArrayAdress.push_back( pair<int,int>(j,k) ); + StreamArrayTime.push_back(fStorage[(*it).first][j]->GetIVArrayArrivalTime()[k]); + } + } + } + } + + fStreamArray[(*it).first] = StreamArray; StreamArray.clear(); + fStreamArrayAdress[(*it).first] = StreamArrayAdress; StreamArrayAdress.clear(); + fStreamArrayTime[(*it).first] = StreamArrayTime; StreamArrayTime.clear(); + } - SortArray(); + SortArray(); DBGL } - //________________________________________________________________________ void FabricationPlant::SortArray() { @@ -401,75 +412,38 @@ void FabricationPlant::SortArray() TimeArray = fStreamArrayTime[(*it_s_vIV).first] ; AdressArray = fStreamArrayAdress[(*it_s_vIV).first] ; - if(fFiFo) - { - for(int j = 0; j < (int)TimeArray.size(); j++) - { - for (int k = j+1; k < (int)TimeArray.size(); k++) - { - cSecond time_tmp = TimeArray[j]; - pair<int,int> Adress_tmp = AdressArray[j]; - IsotopicVector IV_tmp = IVArray[j]; - - if(time_tmp > TimeArray[k]) - { - TimeArray[j] = TimeArray[k]; - TimeArray[k] = time_tmp; - - AdressArray[j] = AdressArray[k]; - AdressArray[k] = Adress_tmp; - - IVArray[j] = IVArray[k]; - IVArray[k] = IV_tmp; - } - } - } - } - else + + switch(fStorageManagement) { - for(int j = 0; j < (int)TimeArray.size(); j++) - { + case kpFiFo: SortFiFo(IVArray, TimeArray, AdressArray); + break; - for (int k = j+1; k < (int)TimeArray.size(); k++) - { - cSecond time_tmp = TimeArray[j]; - pair<int,int> Adress_tmp = AdressArray[j]; - IsotopicVector IV_tmp = IVArray[j]; - - if(time_tmp < TimeArray[k]) - { - TimeArray[j] = TimeArray[k]; - TimeArray[k] = time_tmp; - - AdressArray[j] = AdressArray[k]; - AdressArray[k] = Adress_tmp; - - IVArray[j] = IVArray[k]; - IVArray[k] = IV_tmp; - } - } - } + case kpLiFo: SortLiFo(IVArray, TimeArray, AdressArray); + break; + + case kpMix: SortMix(IVArray, TimeArray, AdressArray); + break; + + case kpRand: SortRandom(IVArray, TimeArray, AdressArray); + break; + + default: + ERROR<<" Posibble Storage Management are"<<endl; + ERROR<<" YourFabPlant->SetStorageManagement(key); //with key can be either"<<endl; + ERROR<<"\tkFiFo : First In First Out (i.e the older storage first)"<<endl; + ERROR<<"\tkLiFo : Last In First Out (i.e the youger storage first)"<<endl; + ERROR<<"\tkMix : IVs are sorted that way : "<<"\n"<<"First: The younger , Second: The older, Third: The second younger ,4th : the second older ...."<<endl; + ERROR<<"\tkRand : IVs order in storage is random"<<endl; + + exit(1); } + fStreamArray[(*it_s_vIV).first] = IVArray; fStreamArrayTime[(*it_s_vIV).first] = TimeArray; fStreamArrayAdress[(*it_s_vIV).first] = AdressArray; } + } - -//________________________________________________________________________ -// Substitution Fuel -//________________________________________________________________________ - -void FabricationPlant::SetSubstitutionFuel(EvolutionData fuel) -{ - - fSubstitutionFuel = true; - - double M0 = cZAIMass.GetMass( fuel.GetIsotopicVectorAt(0.).GetActinidesComposition() ); - fSubstitutionEvolutionData = fuel / M0; - -} - //________________________________________________________________________ void FabricationPlant::SortFiFo(vector<IsotopicVector> &IVArray, vector<cSecond> &TimeArray, vector< pair<int,int> > &AdressArray) { @@ -623,12 +597,22 @@ void FabricationPlant::SortRandom(vector<IsotopicVector> &IVArray, vector<cSecon } - //________________________________________________________________________ -//_____________________________ Reactor & DB _____________________________ +// Substitution Fuel //________________________________________________________________________ +void FabricationPlant::SetSubstitutionFuel(EvolutionData fuel) +{ + + fSubstitutionFuel = true; + + double M0 = cZAIMass.GetMass( fuel.GetIsotopicVectorAt(0.).GetActinidesComposition() ); + fSubstitutionEvolutionData = fuel / M0; + +} + //________________________________________________________________________ +//_____________________________ Reactor & DB _____________________________ void FabricationPlant::TakeReactorFuel(int Id) { DBGL @@ -641,7 +625,7 @@ DBGL (*it2).second = IV; map< int,EvolutionData >::iterator it = fReactorFuturDB.find(Id); - (*it).second.DeleteEvolutionDataCopy(); + (*it).second = EvolutionData(); UpdateInsideIV(); DBGL @@ -658,52 +642,41 @@ EvolutionData FabricationPlant::GetReactorEvolutionDB(int ReactorId) //________________________________________________________________________ //_______________________________ Storage ________________________________ //________________________________________________________________________ -IsotopicVector FabricationPlant::BuildFuelFromEqModel(vector<double> LambdaArray) + +//________________________________________________________________________ +IsotopicVector FabricationPlant::BuildFuelFromEqModel(map <string , vector<double> > LambdaArray) { DBGL IsotopicVector BuildedFuel; IsotopicVector Lost; + + map < string , IsotopicVector>::iterator it; - int StockCorrection = 0; - if( !fIsReplaceFissileStock && fSubstitutionFissile) + for( it = fStreamList.begin(); it != fStreamList.end(); it++) { - StockCorrection = 1; - BuildedFuel += fFissileArray.back()*LambdaArray[fFissileArray.size()-1]; - } - - for(int i = 0; i < (int)fFissileArray.size() - StockCorrection ; i++) - { - if(LambdaArray[i] != 0) + for(int i = 0; i < (int)fStreamArray[(*it).first].size(); i++) { - int Stor_N = fFissileArrayAdress[i].first; - int IV_N = fFissileArrayAdress[i].second; + if(fInfiniteMaterialFromList[(*it).first]) + BuildedFuel += fStreamArray[(*it).first][i]*LambdaArray[(*it).first][i]; - pair<IsotopicVector, IsotopicVector> Separated_Lost; - Separated_Lost = Separation( fFissileStorage[Stor_N]->GetIVArray()[IV_N]*LambdaArray[i], fFissileList ); - BuildedFuel += Separated_Lost.first; - Lost += Separated_Lost.second; - - } - } - - if(fFertileStorage.size() != 0) - { - for(int i = fFissileArray.size(); i < (int)(fFertileArray.size()+fFissileArray.size()); i++) - { - if(LambdaArray[i] != 0) + else if (fSubstitutionMaterialFromIV[(*it).first] && fErrorOnLambda[(*it).first]) + BuildedFuel += fStreamArray[(*it).first][i]*LambdaArray[(*it).first][i]; + else { - int Stor_N = fFertileArrayAdress[i].first; - int IV_N = fFertileArrayAdress[i].second; - - pair<IsotopicVector, IsotopicVector> Separated_Lost; - Separated_Lost = Separation( fFertileStorage[Stor_N]->GetIVArray()[IV_N]*LambdaArray[i], fFertileList); - BuildedFuel += Separated_Lost.first; - Lost += Separated_Lost.second; + if(LambdaArray[(*it).first][i] != 0) + { + int Stor_N = fStreamArrayAdress[(*it).first][i].first; + int IV_N = fStreamArrayAdress[(*it).first][i].second; + + pair<IsotopicVector, IsotopicVector> Separated_Lost; + Separated_Lost = Separation( fStorage[(*it).first][Stor_N]->GetIVArray()[IV_N]*LambdaArray[(*it).first][i], (*it).second ); + BuildedFuel += Separated_Lost.first; + Lost += Separated_Lost.second; + + } } } } - else - BuildedFuel += fFertileArray[0]*LambdaArray.back(); if(fIsReusable) fReUsable->AddIV(Lost); @@ -717,38 +690,32 @@ DBGL } //________________________________________________________________________ -void FabricationPlant::DumpStock(vector<double> LambdaArray) +void FabricationPlant::DumpStock(map <string , vector<double> > LambdaArray) { DBGL - int StockCorrection = 0; - if( !fIsReplaceFissileStock && fSubstitutionFissile) - { StockCorrection = 1; - GetParc()->AddOutIncome( fFissileArray.back()*LambdaArray[fFissileArray.size()-1] ); - } - for(int i = 0; i < (int)fFissileArray.size() - StockCorrection; i++) - { - if(LambdaArray[i] != 0) - { - int Stor_N = fFissileArrayAdress[i].first; - int IV_N = fFissileArrayAdress[i].second; - fFissileStorage[Stor_N]->TakeFractionFromStock( IV_N, LambdaArray[i] ); - } - } - if(fFertileStorage.size() != 0) - { - for(int i = fFissileArray.size(); i < (int)(fFertileArray.size()+fFissileArray.size()); i++) + + map < string , IsotopicVector>::iterator it; + + for( it = fStreamList.begin(); it != fStreamList.end(); it++) + { + for(int i = 0; i < (int)fStreamArray[(*it).first].size(); i++) { - if(LambdaArray[i] != 0) + if(fInfiniteMaterialFromList[(*it).first]) { - int Stor_N = fFertileArrayAdress[i].first; - int IV_N = fFertileArrayAdress[i].second; - - fFertileStorage[Stor_N]->TakeFractionFromStock( IV_N, LambdaArray[i] ); + GetParc()->AddOutIncome( fStreamArray[(*it).first][0]*LambdaArray[(*it).first][i] ); + } + + else + { + if(LambdaArray[(*it).first][i] != 0) + { + int Stor_N = fStreamArrayAdress[(*it).first][i].first; + int IV_N = fStreamArrayAdress[(*it).first][i].second; + fStorage[(*it).first][Stor_N]->TakeFractionFromStock( IV_N, LambdaArray[(*it).first][i] ); + } } } } - else - GetParc()->AddOutIncome( fFertileArray[0]*LambdaArray.back() ); ResetArrays(); @@ -759,15 +726,19 @@ DBGL //________________________________________________________________________ void FabricationPlant::ResetArrays() { - //Clear the Building Array (Fissile and Fertile) - fFissileArray.clear(); - fFissileArrayTime.clear(); - fFissileArrayAdress.clear(); - fFertileArray.clear(); - fFertileArrayTime.clear(); - fFertileArrayAdress.clear(); - - fFertileList = fFissileList = IsotopicVector(); + //Clear the Building Array + map < string , IsotopicVector>::iterator it; + + for( it = fStreamList.begin(); it != fStreamList.end(); it++) + { + fStreamList[(*it).first]= IsotopicVector(); + fStreamArray[(*it).first].clear(); + fStreamArrayTime[(*it).first].clear(); + fStreamArrayAdress[(*it).first].clear(); + + } + + } //________________________________________________________________________ @@ -818,3 +789,10 @@ IsotopicVector FabricationPlant::GetDecay(IsotopicVector isotopicvector, cSecond } +//________________________________________________________________________ +void FabricationPlant::AddInfiniteStorage(string keyword) +{ + Storage* Stock; + fStorage[keyword].push_back(Stock); + fInfiniteMaterialFromList[keyword] = true; +} -- GitLab