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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/adjoint/include/G4AdjointCSManager.hh (Version 11.3.0) and /processes/electromagnetic/adjoint/include/G4AdjointCSManager.hh (Version 11.2.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //////////////////////////////////////////////     26 ////////////////////////////////////////////////////////////////////////////////
 27 //  Class:    G4AdjointCSManager                   27 //  Class:    G4AdjointCSManager
 28 //  Author:         L. Desorgher                   28 //  Author:         L. Desorgher
 29 //  Organisation:   SpaceIT GmbH                   29 //  Organisation:   SpaceIT GmbH
 30 //                                                 30 //
 31 // Class is responsible for the management of      31 // Class is responsible for the management of all adjoint cross section
 32 // matrices, and for the computation of the to     32 // matrices, and for the computation of the total forward and adjoint cross
 33 // sections. Total adjoint and forward cross s     33 // sections. Total adjoint and forward cross sections are needed to correct the
 34 // weight of a particle after a tracking step      34 // weight of a particle after a tracking step or after the occurrence of a
 35 // reverse reaction. It is also used to sample     35 // reverse reaction. It is also used to sample an adjoint secondary from a
 36 // given adjoint cross section matrix.             36 // given adjoint cross section matrix.
 37 //                                                 37 //
 38 //////////////////////////////////////////////     38 ////////////////////////////////////////////////////////////////////////////////
 39                                                    39 
 40 #ifndef G4AdjointCSManager_h                       40 #ifndef G4AdjointCSManager_h
 41 #define G4AdjointCSManager_h 1                     41 #define G4AdjointCSManager_h 1
 42                                                    42 
 43 #include "globals.hh"                              43 #include "globals.hh"
 44 #include "G4AdjointCSMatrix.hh"                    44 #include "G4AdjointCSMatrix.hh"
 45 #include "G4ThreadLocalSingleton.hh"               45 #include "G4ThreadLocalSingleton.hh"
 46                                                    46 
 47 #include <vector>                                  47 #include <vector>
 48                                                    48 
 49 class G4Element;                                   49 class G4Element;
 50 class G4Material;                                  50 class G4Material;
 51 class G4MaterialCutsCouple;                        51 class G4MaterialCutsCouple;
 52 class G4ParticleDefinition;                        52 class G4ParticleDefinition;
 53 class G4PhysicsTable;                              53 class G4PhysicsTable;
 54 class G4VEmProcess;                                54 class G4VEmProcess;
 55 class G4VEmAdjointModel;                           55 class G4VEmAdjointModel;
 56 class G4VEnergyLossProcess;                        56 class G4VEnergyLossProcess;
 57                                                    57 
 58 class G4AdjointCSManager                           58 class G4AdjointCSManager
 59 {                                                  59 {
 60   friend class G4ThreadLocalSingleton<G4Adjoin     60   friend class G4ThreadLocalSingleton<G4AdjointCSManager>;
 61                                                    61 
 62  public:                                           62  public:
 63   ~G4AdjointCSManager();                           63   ~G4AdjointCSManager();
 64   static G4AdjointCSManager* GetAdjointCSManag     64   static G4AdjointCSManager* GetAdjointCSManager();
 65                                                    65 
 66   G4int GetNbProcesses();                          66   G4int GetNbProcesses();
 67                                                    67 
 68   // Registration of the different models and      68   // Registration of the different models and processes
 69                                                    69 
 70   std::size_t RegisterEmAdjointModel(G4VEmAdjo     70   std::size_t RegisterEmAdjointModel(G4VEmAdjointModel*);
 71                                                    71 
 72   void RegisterEmProcess(G4VEmProcess* aProces     72   void RegisterEmProcess(G4VEmProcess* aProcess,
 73                          G4ParticleDefinition*     73                          G4ParticleDefinition* aPartDef);
 74                                                    74 
 75   void RegisterEnergyLossProcess(G4VEnergyLoss     75   void RegisterEnergyLossProcess(G4VEnergyLossProcess* aProcess,
 76                                  G4ParticleDef     76                                  G4ParticleDefinition* aPartDef);
 77                                                    77 
 78   void RegisterAdjointParticle(G4ParticleDefin     78   void RegisterAdjointParticle(G4ParticleDefinition* aPartDef);
 79                                                    79 
 80   // Building of the CS Matrices and Total For     80   // Building of the CS Matrices and Total Forward and Adjoint LambdaTables
 81   void BuildCrossSectionMatrices();                81   void BuildCrossSectionMatrices();
 82                                                    82 
 83   void BuildTotalSigmaTables();                    83   void BuildTotalSigmaTables();
 84                                                    84 
 85   // Get TotalCrossSections form Total Lambda      85   // Get TotalCrossSections form Total Lambda Tables, Needed for Weight
 86   // correction and scaling of the                 86   // correction and scaling of the
 87   G4double GetTotalAdjointCS(G4ParticleDefinit     87   G4double GetTotalAdjointCS(G4ParticleDefinition* aPartDef, G4double Ekin,
 88                              const G4MaterialC     88                              const G4MaterialCutsCouple* aCouple);
 89                                                    89 
 90   G4double GetTotalForwardCS(G4ParticleDefinit     90   G4double GetTotalForwardCS(G4ParticleDefinition* aPartDef, G4double Ekin,
 91                              const G4MaterialC     91                              const G4MaterialCutsCouple* aCouple);
 92                                                    92 
 93   G4double GetAdjointSigma(G4double Ekin_nuc,      93   G4double GetAdjointSigma(G4double Ekin_nuc, std::size_t index_model,
 94                            G4bool is_scat_proj     94                            G4bool is_scat_proj_to_proj,
 95                            const G4MaterialCut     95                            const G4MaterialCutsCouple* aCouple);
 96                                                    96 
 97   void GetEminForTotalCS(G4ParticleDefinition*     97   void GetEminForTotalCS(G4ParticleDefinition* aPartDef,
 98                          const G4MaterialCutsC     98                          const G4MaterialCutsCouple* aCouple,
 99                          G4double& emin_adj, G     99                          G4double& emin_adj, G4double& emin_fwd);
100                                                   100 
101   void GetMaxFwdTotalCS(G4ParticleDefinition*     101   void GetMaxFwdTotalCS(G4ParticleDefinition* aPartDef,
102                         const G4MaterialCutsCo    102                         const G4MaterialCutsCouple* aCouple,
103                         G4double& e_sigma_max,    103                         G4double& e_sigma_max, G4double& sigma_max);
104                                                   104 
105   void GetMaxAdjTotalCS(G4ParticleDefinition*     105   void GetMaxAdjTotalCS(G4ParticleDefinition* aPartDef,
106                         const G4MaterialCutsCo    106                         const G4MaterialCutsCouple* aCouple,
107                         G4double& e_sigma_max,    107                         G4double& e_sigma_max, G4double& sigma_max);
108                                                   108 
109   // CrossSection Correction 1 or FwdCS/AdjCS     109   // CrossSection Correction 1 or FwdCS/AdjCS following the G4boolean value of
110   // forward_CS_is_used and forward_CS_mode       110   // forward_CS_is_used and forward_CS_mode
111   G4double GetCrossSectionCorrection(G4Particl    111   G4double GetCrossSectionCorrection(G4ParticleDefinition* aPartDef,
112                                      G4double     112                                      G4double PreStepEkin,
113                                      const G4M    113                                      const G4MaterialCutsCouple* aCouple,
114                                      G4bool& f    114                                      G4bool& fwd_is_used);
115                                                   115 
116   // Cross section mode                           116   // Cross section mode
117   inline void SetFwdCrossSectionMode(G4bool aB    117   inline void SetFwdCrossSectionMode(G4bool aBool) { fForwardCSMode = aBool; }
118                                                   118 
119   // Weight correction                            119   // Weight correction
120   G4double GetContinuousWeightCorrection(G4Par    120   G4double GetContinuousWeightCorrection(G4ParticleDefinition* aPartDef,
121                                          G4dou    121                                          G4double PreStepEkin,
122                                          G4dou    122                                          G4double AfterStepEkin,
123                                          const    123                                          const G4MaterialCutsCouple* aCouple,
124                                          G4dou    124                                          G4double step_length);
125                                                   125 
126   G4double GetPostStepWeightCorrection();         126   G4double GetPostStepWeightCorrection();
127                                                   127 
128   // called by the adjoint model to get the CS    128   // called by the adjoint model to get the CS, if not otherwise specified
129   G4double ComputeAdjointCS(G4Material* aMater    129   G4double ComputeAdjointCS(G4Material* aMaterial, G4VEmAdjointModel* aModel,
130                             G4double PrimEnerg    130                             G4double PrimEnergy, G4double Tcut,
131                             G4bool isScatProjT    131                             G4bool isScatProjToProj,
132                             std::vector<G4doub    132                             std::vector<G4double>& AdjointCS_for_each_element);
133                                                   133 
134   // called by the adjoint model to sample sec    134   // called by the adjoint model to sample secondary energy from the CS matrix
135   G4Element* SampleElementFromCSMatrices(G4Mat    135   G4Element* SampleElementFromCSMatrices(G4Material* aMaterial,
136                                          G4VEm    136                                          G4VEmAdjointModel* aModel,
137                                          G4dou    137                                          G4double PrimEnergy, G4double Tcut,
138                                          G4boo    138                                          G4bool isScatProjToProj);
139                                                   139 
140   // Total Adjoint CS is computed at initialis    140   // Total Adjoint CS is computed at initialisation phase
141   G4double ComputeTotalAdjointCS(const G4Mater    141   G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,
142                                  G4ParticleDef    142                                  G4ParticleDefinition* aPart,
143                                  G4double Prim    143                                  G4double PrimEnergy);
144                                                   144 
145   G4ParticleDefinition* GetAdjointParticleEqui    145   G4ParticleDefinition* GetAdjointParticleEquivalent(
146     G4ParticleDefinition* theFwdPartDef);         146     G4ParticleDefinition* theFwdPartDef);
147                                                   147 
148   G4ParticleDefinition* GetForwardParticleEqui    148   G4ParticleDefinition* GetForwardParticleEquivalent(
149     G4ParticleDefinition* theAdjPartDef);         149     G4ParticleDefinition* theAdjPartDef);
150                                                   150 
151   // inline                                       151   // inline
152   inline void SetIon(G4ParticleDefinition* adj    152   inline void SetIon(G4ParticleDefinition* adjIon, G4ParticleDefinition* fwdIon)
153   {                                               153   {
154     fAdjIon = adjIon;                             154     fAdjIon = adjIon;
155     fFwdIon = fwdIon;                             155     fFwdIon = fwdIon;
156   }                                               156   }
157                                                   157 
158  private:                                         158  private:
159   G4AdjointCSManager();                           159   G4AdjointCSManager();
160                                                   160 
161   void DefineCurrentMaterial(const G4MaterialC    161   void DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
162                                                   162 
163   void DefineCurrentParticle(const G4ParticleD    163   void DefineCurrentParticle(const G4ParticleDefinition* aPartDef);
164                                                   164 
165   G4double ComputeAdjointCS(G4double aPrimEner    165   G4double ComputeAdjointCS(G4double aPrimEnergy,
166                             G4AdjointCSMatrix*    166                             G4AdjointCSMatrix* anAdjointCSMatrix,
167                             G4double Tcut);       167                             G4double Tcut);
168                                                   168 
169   std::vector<G4AdjointCSMatrix*> BuildCrossSe    169   std::vector<G4AdjointCSMatrix*> BuildCrossSectionsModelAndElement(
170     G4VEmAdjointModel* aModel, G4int Z, G4int     170     G4VEmAdjointModel* aModel, G4int Z, G4int A, G4int nbin_pro_decade);
171                                                   171 
172   std::vector<G4AdjointCSMatrix*> BuildCrossSe    172   std::vector<G4AdjointCSMatrix*> BuildCrossSectionsModelAndMaterial(
173     G4VEmAdjointModel* aModel, G4Material* aMa    173     G4VEmAdjointModel* aModel, G4Material* aMaterial, G4int nbin_pro_decade);
174                                                   174 
175   static constexpr G4double fTmin = 0.1 * CLHE    175   static constexpr G4double fTmin = 0.1 * CLHEP::keV;
176   static constexpr G4double fTmax = 100. * CLH    176   static constexpr G4double fTmax = 100. * CLHEP::TeV;
177   // fNbins chosen to avoid error                 177   // fNbins chosen to avoid error
178   // in the CS value close to CS jump. (For ex    178   // in the CS value close to CS jump. (For example at Tcut)
179   static constexpr G4int fNbins = 320;            179   static constexpr G4int fNbins = 320;
180                                                   180 
181   static G4ThreadLocal G4AdjointCSManager* fIn    181   static G4ThreadLocal G4AdjointCSManager* fInstance;
182                                                   182 
183   // only one ion can be considered by simulat    183   // only one ion can be considered by simulation
184   G4ParticleDefinition* fAdjIon = nullptr;        184   G4ParticleDefinition* fAdjIon = nullptr;
185   G4ParticleDefinition* fFwdIon = nullptr;        185   G4ParticleDefinition* fFwdIon = nullptr;
186                                                   186 
187   G4MaterialCutsCouple* fCurrentCouple = nullp    187   G4MaterialCutsCouple* fCurrentCouple = nullptr;
188   G4Material* fCurrentMaterial         = nullp    188   G4Material* fCurrentMaterial         = nullptr;
189                                                   189 
190   // x dim is for G4VAdjointEM*, y dim is for     190   // x dim is for G4VAdjointEM*, y dim is for elements
191   std::vector<std::vector<G4AdjointCSMatrix*>>    191   std::vector<std::vector<G4AdjointCSMatrix*>>
192     fAdjointCSMatricesForScatProjToProj;          192     fAdjointCSMatricesForScatProjToProj;
193                                                   193 
194   std::vector<std::vector<G4AdjointCSMatrix*>>    194   std::vector<std::vector<G4AdjointCSMatrix*>> fAdjointCSMatricesForProdToProj;
195                                                   195 
196   std::vector<G4VEmAdjointModel*> fAdjointMode    196   std::vector<G4VEmAdjointModel*> fAdjointModels;
197                                                   197 
198   std::vector<std::size_t> fIndexOfAdjointEMMo    198   std::vector<std::size_t> fIndexOfAdjointEMModelInAction;
199   std::vector<G4bool> fIsScatProjToProj;          199   std::vector<G4bool> fIsScatProjToProj;
200   std::vector<std::vector<G4double>> fLastAdjo    200   std::vector<std::vector<G4double>> fLastAdjointCSVsModelsAndElements;
201                                                   201 
202   // total adjoint and total forward cross sec    202   // total adjoint and total forward cross section table in function of material
203   // and in function of adjoint particle type     203   // and in function of adjoint particle type
204   std::vector<G4PhysicsTable*> fTotalFwdSigmaT    204   std::vector<G4PhysicsTable*> fTotalFwdSigmaTable;
205   std::vector<G4PhysicsTable*> fTotalAdjSigmaT    205   std::vector<G4PhysicsTable*> fTotalAdjSigmaTable;
206                                                   206 
207   // Sigma table for each G4VAdjointEMModel       207   // Sigma table for each G4VAdjointEMModel
208   std::vector<G4PhysicsTable*> fSigmaTableForA    208   std::vector<G4PhysicsTable*> fSigmaTableForAdjointModelScatProjToProj;
209   std::vector<G4PhysicsTable*> fSigmaTableForA    209   std::vector<G4PhysicsTable*> fSigmaTableForAdjointModelProdToProj;
210                                                   210 
211   std::vector<std::vector<G4double>> fEminForF    211   std::vector<std::vector<G4double>> fEminForFwdSigmaTables;
212   std::vector<std::vector<G4double>> fEminForA    212   std::vector<std::vector<G4double>> fEminForAdjSigmaTables;
213   std::vector<std::vector<G4double>> fEkinofFw    213   std::vector<std::vector<G4double>> fEkinofFwdSigmaMax;
214   std::vector<std::vector<G4double>> fEkinofAd    214   std::vector<std::vector<G4double>> fEkinofAdjSigmaMax;
215                                                   215 
216   // list of forward G4VEmProcess and of G4VEn    216   // list of forward G4VEmProcess and of G4VEnergyLossProcess for the different
217   // adjoint particle                             217   // adjoint particle
218   std::vector<std::vector<G4VEmProcess*>*> fFo    218   std::vector<std::vector<G4VEmProcess*>*> fForwardProcesses;
219   std::vector<std::vector<G4VEnergyLossProcess    219   std::vector<std::vector<G4VEnergyLossProcess*>*> fForwardLossProcesses;
220                                                   220 
221   // list of adjoint particles considered         221   // list of adjoint particles considered
222   std::vector<G4ParticleDefinition*> fAdjointP    222   std::vector<G4ParticleDefinition*> fAdjointParticlesInAction;
223                                                   223 
224   G4double fMassRatio              = 1.;  // i    224   G4double fMassRatio              = 1.;  // ion
225   G4double fLastCSCorrectionFactor = 1.;          225   G4double fLastCSCorrectionFactor = 1.;
226                                                   226 
227   G4ParticleDefinition* fCurrentParticleDef =  << 
228   std::size_t fCurrentParticleIndex = 0;          227   std::size_t fCurrentParticleIndex = 0;
229   std::size_t fCurrentMatIndex      = 0;          228   std::size_t fCurrentMatIndex      = 0;
230                                                   229 
231   G4bool fCSMatricesBuilt = false;                230   G4bool fCSMatricesBuilt = false;
232   G4bool fSigmaTableBuilt = false;                231   G4bool fSigmaTableBuilt = false;
233   G4bool fForwardCSUsed   = true;                 232   G4bool fForwardCSUsed   = true;
234   G4bool fForwardCSMode   = true;                 233   G4bool fForwardCSMode   = true;
235   // Two CS mode are possible:                    234   // Two CS mode are possible:
236   // 1) fForwardCSMode = false, the Adjoint CS    235   // 1) fForwardCSMode = false, the Adjoint CS are used as it is implying
237   //    an AlongStep Weight Correction.           236   //    an AlongStep Weight Correction.
238   // 2) fForwardCSMode = true, the Adjoint CS     237   // 2) fForwardCSMode = true, the Adjoint CS are scaled to have the total
239   //    adjoint CS equal to the fwd one implyi    238   //    adjoint CS equal to the fwd one implying a PostStep Weight Correction.
240   // For energies where the total Fwd CS or th    239   // For energies where the total Fwd CS or the total adjoint CS are zero,
241   // the scaling is not possible and fForwardC    240   // the scaling is not possible and fForwardCSUsed is set to false
242 };                                                241 };
243 #endif                                            242 #endif
244                                                   243