Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DNAMoleculeEncounterStepper Class Reference

#include <G4DNAMoleculeEncounterStepper.hh>

+ Inheritance diagram for G4DNAMoleculeEncounterStepper:

Public Member Functions

 G4DNAMoleculeEncounterStepper ()
 
virtual ~G4DNAMoleculeEncounterStepper ()
 
 G4DNAMoleculeEncounterStepper (const G4DNAMoleculeEncounterStepper &)=delete
 
G4DNAMoleculeEncounterStepperoperator= (const G4DNAMoleculeEncounterStepper &)=delete
 
virtual void Prepare ()
 
virtual G4double CalculateStep (const G4Track &, const G4double &)
 
virtual G4double CalculateMinTimeStep (G4double, G4double)
 
void SetReactionModel (G4VDNAReactionModel *)
 
G4VDNAReactionModelGetReactionModel ()
 
void SetVerbose (int)
 
- Public Member Functions inherited from G4VITTimeStepComputer
 G4VITTimeStepComputer ()
 
virtual ~G4VITTimeStepComputer ()
 
 G4VITTimeStepComputer (const G4VITTimeStepComputer &)
 
G4VITTimeStepComputeroperator= (const G4VITTimeStepComputer &other)
 
virtual void Initialize ()
 
virtual void Prepare ()
 
virtual G4double CalculateStep (const G4Track &, const G4double &)=0
 
virtual G4double CalculateMinTimeStep (G4double, G4double)=0
 
G4TrackVectorHandle GetReactants ()
 
virtual void ResetReactants ()
 
G4double GetSampledMinTimeStep ()
 
void SetReactionTable (const G4ITReactionTable *)
 
const G4ITReactionTableGetReactionTable ()
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VITTimeStepComputer
static void SetTimes (const G4double &, const G4double &)
 
- Protected Attributes inherited from G4VITTimeStepComputer
G4double fSampledMinTimeStep
 
G4TrackVectorHandle fReactants
 
const G4ITReactionTablefpReactionTable
 
- Static Protected Attributes inherited from G4VITTimeStepComputer
static G4ThreadLocal G4double fCurrentGlobalTime = -1
 
static G4ThreadLocal G4double fUserMinTimeStep = -1
 

Detailed Description

Given a molecule G4DNAMoleculeEncounterStepper will calculate for its possible reactants what will be the minimum encounter time and the associated molecules.*

This model includes dynamical time steps as explained in "Computer-Aided Stochastic Modeling of the Radiolysis of Liquid Water", V. Michalik, M. Begusová, E. A. Bigildeev, Radiation Research, Vol. 149, No. 3 (Mar., 1998), pp. 224-236

Definition at line 70 of file G4DNAMoleculeEncounterStepper.hh.

Constructor & Destructor Documentation

◆ G4DNAMoleculeEncounterStepper() [1/2]

G4DNAMoleculeEncounterStepper::G4DNAMoleculeEncounterStepper ( )

Definition at line 68 of file G4DNAMoleculeEncounterStepper.cc.

70 , fHasAlreadyReachedNullTime(false)
71 , fMolecularReactionTable(reference_cast<const G4DNAMolecularReactionTable*>(fpReactionTable))
72 , fReactionModel(nullptr)
73 , fVerbose(0)
74{
75 fpTrackContainer = G4ITTrackHolder::Instance();
76 fReactionSet = G4ITReactionSet::Instance();
77}
static G4ITReactionSet * Instance()
static G4ITTrackHolder * Instance()
const G4ITReactionTable * fpReactionTable

◆ ~G4DNAMoleculeEncounterStepper()

G4DNAMoleculeEncounterStepper::~G4DNAMoleculeEncounterStepper ( )
virtualdefault

◆ G4DNAMoleculeEncounterStepper() [2/2]

G4DNAMoleculeEncounterStepper::G4DNAMoleculeEncounterStepper ( const G4DNAMoleculeEncounterStepper )
delete

Member Function Documentation

◆ CalculateMinTimeStep()

G4double G4DNAMoleculeEncounterStepper::CalculateMinTimeStep ( G4double  ,
G4double  definedMinTimeStep 
)
virtual

Implements G4VITTimeStepComputer.

Definition at line 441 of file G4DNAMoleculeEncounterStepper.cc.

441 {
442
443 G4double fTSTimeStep = DBL_MAX;
444
445 for (auto pTrack : *fpTrackContainer->GetMainList())
446 {
447 if (pTrack == nullptr)
448 {
449 G4ExceptionDescription exceptionDescription;
450 exceptionDescription << "No track found.";
451 G4Exception("G4Scheduler::CalculateMinStep", "ITScheduler006",
452 FatalErrorInArgument, exceptionDescription);
453 continue;
454 }
455
456 G4TrackStatus trackStatus = pTrack->GetTrackStatus();
457 if (trackStatus == fStopAndKill || trackStatus == fStopButAlive)
458 {
459 continue;
460 }
461
462 G4double sampledMinTimeStep = CalculateStep(*pTrack, definedMinTimeStep);
463 G4TrackVectorHandle reactants = GetReactants();
464
465 if (sampledMinTimeStep < fTSTimeStep)
466 {
467 fTSTimeStep = sampledMinTimeStep;
468 fReactionSet->CleanAllReaction();
469 if (reactants)
470 {
471 fReactionSet->AddReactions(fTSTimeStep,
472 const_cast<G4Track*>(pTrack),
473 reactants);
475 }
476 }
477 else if (fTSTimeStep == sampledMinTimeStep && bool(reactants))
478 {
479 fReactionSet->AddReactions(fTSTimeStep,
480 const_cast<G4Track*>(pTrack),
481 reactants);
483 }
484 else if (reactants)
485 {
487 }
488 }
489
490 return fTSTimeStep;
491}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4shared_ptr< std::vector< G4Track * > > G4TrackVectorHandle
Definition: G4ITReaction.hh:43
G4TrackStatus
@ fStopAndKill
@ fStopButAlive
double G4double
Definition: G4Types.hh:83
virtual G4double CalculateStep(const G4Track &, const G4double &)
void AddReactions(double time, G4Track *trackA, G4TrackVectorHandle reactants)
void CleanAllReaction()
G4TrackList * GetMainList(Key)
G4TrackVectorHandle GetReactants()
#define DBL_MAX
Definition: templates.hh:62

◆ CalculateStep()

G4double G4DNAMoleculeEncounterStepper::CalculateStep ( const G4Track trackA,
const G4double userMinTimeStep 
)
virtual

Implements G4VITTimeStepComputer.

Definition at line 121 of file G4DNAMoleculeEncounterStepper.cc.

123{
124 auto pMoleculeA = GetMolecule(trackA);
125 InitializeForNewTrack();
126 fUserMinTimeStep = userMinTimeStep;
127
128#ifdef G4VERBOSE
129 if (fVerbose)
130 {
131 G4cout
132 << "_______________________________________________________________________"
133 << G4endl;
134 G4cout << "G4DNAMoleculeEncounterStepper::CalculateStep" << G4endl;
135 G4cout << "Check done for molecule : " << pMoleculeA->GetName()
136 << " (" << trackA.GetTrackID() << ") "
137 << G4endl;
138 }
139#endif
140
141 //__________________________________________________________________
142 // Retrieve general informations for making reactions
143 auto pMolConfA = pMoleculeA->GetMolecularConfiguration();
144
145 const auto pReactantList = fMolecularReactionTable->CanReactWith(pMolConfA);
146
147 if (!pReactantList)
148 {
149#ifdef G4VERBOSE
150 // DEBUG
151 if (fVerbose > 1)
152 {
153 G4cout << "!!!!!!!!!!!!!!!!!!!!" << G4endl;
154 G4cout << "!!! WARNING" << G4endl;
155 G4cout << "G4MoleculeEncounterStepper::CalculateStep will return infinity "
156 "for the reaction because the molecule "
157 << pMoleculeA->GetName()
158 << " does not have any reactants given in the reaction table."
159 << G4endl;
160 G4cout << "!!!!!!!!!!!!!!!!!!!!" << G4endl;
161 }
162#endif
163 return DBL_MAX;
164 }
165
166 G4int nbReactives = pReactantList->size();
167
168 if (nbReactives == 0)
169 {
170#ifdef G4VERBOSE
171 // DEBUG
172 if (fVerbose)
173 {
174 // TODO replace with the warning mode of G4Exception
175 G4cout << "!!!!!!!!!!!!!!!!!!!!" << G4endl;
176 G4cout << "!!! WARNING" << G4endl;
177 G4cout << "G4MoleculeEncounterStepper::CalculateStep will return infinity "
178 "for the reaction because the molecule "
179 << pMoleculeA->GetName()
180 << " does not have any reactants given in the reaction table."
181 << "This message can also result from a wrong implementation of the reaction table."
182 << G4endl;
183 G4cout << "!!!!!!!!!!!!!!!!!!!!" << G4endl;
184 }
185#endif
186 return DBL_MAX;
187 }
188
189 fReactants.reset(new vector<G4Track*>());
190 fReactionModel->Initialise(pMolConfA, trackA);
191
192 //__________________________________________________________________
193 // Start looping on possible reactants
194 for (G4int i = 0; i < nbReactives; i++)
195 {
196 auto pMoleculeB = (*pReactantList)[i];
197
198 //______________________________________________________________
199 // Retrieve reaction range
200 const G4double R = fReactionModel->GetReactionRadius(i);
201
202 //______________________________________________________________
203 // Use KdTree algorithm to find closest reactants
204 G4KDTreeResultHandle resultsNearest(
205 G4MoleculeFinder::Instance()->FindNearest(pMoleculeA,
206 pMoleculeB->GetMoleculeID()));
207
208 if (resultsNearest == 0) continue;
209
210 G4double r2 = resultsNearest->GetDistanceSqr();
211 Utils utils(trackA, pMoleculeB);
212
213 if (r2 <= R * R) // ==> Record in range
214 {
215 // Entering in this condition may due to the fact that molecules are very close
216 // to each other
217 // Therefore, if we only take the nearby reactant into account, it might have already
218 // reacted. Instead, we will take all possible reactants that satisfy the condition r<R
219
220 if (fHasAlreadyReachedNullTime == false)
221 {
222 fReactants->clear();
223 fHasAlreadyReachedNullTime = true;
224 }
225
227 G4KDTreeResultHandle resultsInRange(
228 G4MoleculeFinder::Instance()->FindNearestInRange(pMoleculeA,
229 pMoleculeB->GetMoleculeID(),
230 R));
231 CheckAndRecordResults(utils,
232#ifdef G4VERBOSE
233 R,
234#endif
235 resultsInRange);
236 }
237 else
238 {
239 G4double r = sqrt(r2);
240 G4double tempMinET = pow(r - R, 2) / utils.fConstant;
241 // constant = 16 * (fDA + fDB + 2*sqrt(fDA*fDB))
242
243 if (tempMinET <= fSampledMinTimeStep)
244 {
245 if (fUserMinTimeStep < DBL_MAX/*IsInf(fUserMinTimeStep) == false*/
246 && tempMinET <= fUserMinTimeStep) // ==> Record in range
247 {
249 {
250 fReactants->clear();
251 }
252
254
255 G4double range = R + sqrt(fUserMinTimeStep*utils.fConstant);
256
257 G4KDTreeResultHandle resultsInRange(
259 FindNearestInRange(pMoleculeA,
260 pMoleculeB->GetMoleculeID(),
261 range));
262
263 CheckAndRecordResults(utils,
264#ifdef G4VERBOSE
265 range,
266#endif
267 resultsInRange);
268 }
269 else // ==> Record nearest
270 {
271 if (tempMinET < fSampledMinTimeStep)
272 // to avoid cases where fSampledMinTimeStep == tempMinET
273 {
274 fSampledMinTimeStep = tempMinET;
275 fReactants->clear();
276 }
277
278 CheckAndRecordResults(utils,
279#ifdef G4VERBOSE
280 R,
281#endif
282 resultsNearest);
283 }
284 }
285 }
286 }
287
288#ifdef G4VERBOSE
289 if (fVerbose)
290 {
291 G4cout << "G4MoleculeEncounterStepper::CalculateStep will finally return :"
293
294 if (fVerbose > 1)
295 {
296 G4cout << "Selected reactants for trackA: " << pMoleculeA->GetName()
297 << " (" << trackA.GetTrackID() << ") are: ";
298
299 vector<G4Track*>::iterator it;
300 for (it = fReactants->begin(); it != fReactants->end(); it++)
301 {
302 G4Track* trackB = *it;
303 G4cout << GetMolecule(trackB)->GetName() << " ("
304 << trackB->GetTrackID() << ") \t ";
305 }
306 G4cout << G4endl;
307 }
308 }
309#endif
310 return fSampledMinTimeStep;
311}
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:76
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const ReactantList * CanReactWith(Reactant *) const
static G4ITFinder * Instance()
const G4String & GetName() const
Definition: G4Molecule.cc:338
G4int GetTrackID() const
virtual void Initialise(const G4MolecularConfiguration *, const G4Track &)
virtual G4double GetReactionRadius(const G4MolecularConfiguration *, const G4MolecularConfiguration *)=0
G4TrackVectorHandle fReactants
static G4ThreadLocal G4double fUserMinTimeStep

Referenced by CalculateMinTimeStep().

◆ GetReactionModel()

G4VDNAReactionModel * G4DNAMoleculeEncounterStepper::GetReactionModel ( )

Definition at line 431 of file G4DNAMoleculeEncounterStepper.cc.

432{
433 return fReactionModel;
434}

◆ operator=()

G4DNAMoleculeEncounterStepper & G4DNAMoleculeEncounterStepper::operator= ( const G4DNAMoleculeEncounterStepper )
delete

◆ Prepare()

void G4DNAMoleculeEncounterStepper::Prepare ( )
virtual

Reimplemented from G4VITTimeStepComputer.

Definition at line 81 of file G4DNAMoleculeEncounterStepper.cc.

82{
84
85#if defined (DEBUG_MEM)
86 MemStat mem_first, mem_second, mem_diff;
87#endif
88
89#if defined (DEBUG_MEM)
90 mem_first = MemoryUsage();
91#endif
93
94#if defined (DEBUG_MEM)
95 mem_second = MemoryUsage();
96 mem_diff = mem_second - mem_first;
97 G4cout << "\t || MEM || G4DNAMoleculeEncounterStepper::Prepare || "
98 "After computing G4ITManager<G4Molecule>::Instance()->"
99 "UpdatePositionMap, diff is : " << mem_diff << G4endl;
100#endif
101}
virtual void UpdatePositionMap()
MemStat MemoryUsage()
Definition: G4MemStat.cc:55

◆ SetReactionModel()

void G4DNAMoleculeEncounterStepper::SetReactionModel ( G4VDNAReactionModel pReactionModel)

Definition at line 426 of file G4DNAMoleculeEncounterStepper.cc.

427{
428 fReactionModel = pReactionModel;
429}

◆ SetVerbose()

void G4DNAMoleculeEncounterStepper::SetVerbose ( int  flag)

Definition at line 436 of file G4DNAMoleculeEncounterStepper.cc.

437{
438 fVerbose = flag;
439}

The documentation for this class was generated from the following files: