CLASS  1.1
src/Reactor.cxx
Aller à la documentation de ce fichier.
00001 #include "Reactor.hxx"
00002 #include "IsotopicVector.hxx"
00003 #include "EvolutiveProduct.hxx"
00004 #include "CLASS.hxx"
00005 #include "LogFile.hxx"
00006 #include "TreatmentFactory.hxx"
00007 #include "Defines.hxx"
00008 
00009 #include <iostream>
00010 #include <algorithm>
00011 #include <omp.h>
00012 
00013 //________________________________________________________________________
00014 //
00015 //              Reactor
00016 //
00017 //
00018 //
00019 //
00020 //________________________________________________________________________
00021 ClassImp(Reactor)
00022 
00023 Reactor::Reactor()
00024 {
00025         DBGL;
00026         DBGL;
00027 }
00028 
00029 Reactor::Reactor(EvolutiveProduct* evolutivedb, 
00030                  TreatmentFactory* TreatmentFactory,
00031                  long int creationtime,
00032                  long int lifetime )
00033 {
00034         DBGL;
00035         fCycleTime = (long int)(3600*24*365.4)*5;
00036         fIsStarted = false;
00037         fShutDown = false;
00038         fEndOfCycle = false;
00039         fEvolutionDB = evolutivedb; 
00040         fAssociedTreatmentFactory = TreatmentFactory;
00041 
00042         fInternalTime = 0;
00043         fInCycleTime = 0;
00044         fCreationTime = creationtime;
00045         fLifeTime = lifetime;
00046 
00047         fIVBeginCycle = fEvolutionDB->GetIsotopicVectorAt(0);
00048         fIVInCycle = fEvolutionDB->GetIsotopicVectorAt(0);
00049         fIVOutCycle = fEvolutionDB->GetIsotopicVectorAt(fCycleTime);
00050         DBGL;
00051 }
00052 
00053 //________________________________________________________________________
00054 Reactor::~Reactor()
00055 {
00056         DBGL;
00057         DBGL;
00058 }
00059 
00060 
00061 //________________________________________________________________________
00062 void Reactor::Evolution(long int t)
00063 {
00064         DBGL;
00065         if(fShutDown == true) return; // Reactor stop...
00066         
00067         // Check if the Reactor has been created ...
00068         if(t<fCreationTime) return;
00069         DBGL;
00070         
00071         
00072         if(fInternalTime == 0 && fIsStarted == false) // Start of the Reactor
00073         {
00074                 fEndOfCycle = true;
00075                 fIVReactor  = fIVBeginCycle;
00076                 fInternalTime = t;
00077         }
00078 
00079         // Check if the Reactor if started ...
00080         if(fIsStarted == false) return; 
00081 
00082         long int EvolutionTime = t - fInternalTime; // Calculation of the evolution time (relativ)
00083 
00084         if(EvolutionTime + fInCycleTime < fCycleTime )                  //During Cycle
00085         {
00086                 fIVReactor = fEvolutionDB->GetIsotopicVectorAt(EvolutionTime + fInCycleTime);   // update the fuel composition
00087 #pragma omp critical(UpdateInReactor)
00088                         {fParc->AddTotalInReactor(fIVReactor);}
00089                 fInternalTime += EvolutionTime;                                                 // Update Internal Time
00090                 fInCycleTime += EvolutionTime;                                                  // Update InCycleTime
00091         }
00092         else if(EvolutionTime + fInCycleTime == fCycleTime )            //End of Cycle
00093         {
00094                 fEndOfCycle = true;
00095                 fInternalTime += EvolutionTime;                                                 // Update Internal Time
00096                 
00097                 if(t < fCreationTime + fLifeTime)                       //if the Next Cycle Exist...
00098                 {
00099                         fIVReactor  = fIVBeginCycle;
00100                         fInCycleTime = 0;
00101                 }
00102                 else                                                    //if Not....
00103                 {
00104                         IsotopicVector IV;
00105                         fIVReactor = IV;
00106                         fShutDown = true;
00107                 }
00108 
00109         }
00110         else
00111         {
00112                 // This is so bad!! You will probably unsynchronize all the reactor....
00113                 cout << "!!Warning!! !!!Reactor!!!"
00114                      << " Evolution is too long! This is a Bad way to deal the evolution of the reactor..."
00115                      << t/365.4/3600/24 << " :" << endl;
00116                                 
00117                 fLog->fLog << "!!Warning!! !!!Reactor!!!"
00118                            << " Evolution is too long! This is a Bad way to deal the evolution of the reactor..."
00119                            << t/365.4/3600/24 << " :" << endl;
00120                 exit(1);
00121         }
00122         DBGL;
00123 }
00124 
00125 //________________________________________________________________________
00126 void Reactor::Dump()
00127 {
00128         DBGL;
00129         if(fEndOfCycle == true  )
00130         {
00131                 if(fShutDown == false)  fParc->AddTotalInReactor(fIVReactor);
00132                 
00133                 fEndOfCycle = false;
00134                 if(fParc->GetStockManagement() == true)
00135                 {
00136                         IsotopicVector BuildIVtmp  = fParc->BuildIsotopicVector(fIVInCycle);
00137 //                      BuildIVtmp.Print();
00138                         fAssociedTreatmentFactory->AddIVGodIncome(fIVInCycle - BuildIVtmp);
00139                 }
00140                 else
00141                 {
00142                         IsotopicVector BuildIVtmp ;
00143                         IsotopicVector GodPart;
00144                         
00145                         BuildIVtmp.Add(fAssociedTreatmentFactory->GetIVFullStock().GetIsotopicQuantity());
00146                         BuildIVtmp -= fIVInCycle;                       
00147                         GodPart.Add(BuildIVtmp.GetIsotopicQuantityNeeded()) ;
00148                         fAssociedTreatmentFactory->TakeFromStock( fIVInCycle - GodPart, -1);
00149                         fAssociedTreatmentFactory->AddIVGodIncome(GodPart);
00150                 }
00151                 
00152                 if(fIsStarted == true )                                 // A Cycle has already been done
00153                 {
00154                         if(fShutDown == false)  fAssociedTreatmentFactory->AddIVCooling(fIVOutCycle);
00155                         else                    fAssociedTreatmentFactory->AddIVCooling(fEvolutionDB->GetIsotopicVectorAt(fCycleTime));
00156 
00157                 }
00158                 else fIsStarted = true;                                 // Just start the first cycle
00159                 
00160                 if(fShutDown == true) fIsStarted = false;               // shut down the Reactor
00161         }
00162         DBGL;
00163 }
00164 
00165 
00166 
00167 
 Tout Classes Fichiers Fonctions Variables Macros