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

#include <G4DNAIRTMoleculeEncounterStepper.hh>

+ Inheritance diagram for G4DNAIRTMoleculeEncounterStepper:

Public Member Functions

 G4DNAIRTMoleculeEncounterStepper ()
 
virtual ~G4DNAIRTMoleculeEncounterStepper ()
 
 G4DNAIRTMoleculeEncounterStepper (const G4DNAIRTMoleculeEncounterStepper &)=delete
 
G4DNAIRTMoleculeEncounterStepperoperator= (const G4DNAIRTMoleculeEncounterStepper &)=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 G4DNAIRTMoleculeEncounterStepper 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 59 of file G4DNAIRTMoleculeEncounterStepper.hh.

Constructor & Destructor Documentation

◆ G4DNAIRTMoleculeEncounterStepper() [1/2]

G4DNAIRTMoleculeEncounterStepper::G4DNAIRTMoleculeEncounterStepper ( )

Definition at line 67 of file G4DNAIRTMoleculeEncounterStepper.cc.

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

◆ ~G4DNAIRTMoleculeEncounterStepper()

G4DNAIRTMoleculeEncounterStepper::~G4DNAIRTMoleculeEncounterStepper ( )
virtualdefault

◆ G4DNAIRTMoleculeEncounterStepper() [2/2]

G4DNAIRTMoleculeEncounterStepper::G4DNAIRTMoleculeEncounterStepper ( const G4DNAIRTMoleculeEncounterStepper )
delete

Member Function Documentation

◆ CalculateMinTimeStep()

G4double G4DNAIRTMoleculeEncounterStepper::CalculateMinTimeStep ( G4double  currentGlobalTime,
G4double  definedMinTimeStep 
)
virtual

Implements G4VITTimeStepComputer.

Definition at line 431 of file G4DNAIRTMoleculeEncounterStepper.cc.

431 {
432
433 G4bool start = true;
434 G4bool active = false;
435
436 fUserMinTimeStep = definedMinTimeStep;
437
438 if(fReactionSet->Empty()){
439 if(currentGlobalTime == G4Scheduler::Instance()->GetStartTime()){
440
441 for (auto pTrack : *fpTrackContainer->GetMainList())
442 {
443 if (pTrack == nullptr)
444 {
445 G4ExceptionDescription exceptionDescription;
446 exceptionDescription << "No track found.";
447 G4Exception("G4Scheduler::CalculateMinStep", "ITScheduler006",
448 FatalErrorInArgument, exceptionDescription);
449 continue;
450 }
451
452 G4TrackStatus trackStatus = pTrack->GetTrackStatus();
453 if (trackStatus == fStopAndKill || trackStatus == fStopButAlive)
454 {
455 start = false;
456 continue;
457 }
458 active = true;
459 }
460
461 if(start == true){
462 return -1;
463 }else if(active == false){
465 return fSampledMinTimeStep;
466 }else{
467 return fSampledMinTimeStep;
468 }
469
470 }else{
471 for (auto pTrack : *fpTrackContainer->GetMainList())
472 {
473 pTrack->SetGlobalTime(G4Scheduler::Instance()->GetEndTime());
474 }
475 return fSampledMinTimeStep;
476 }
477 }
478
479 auto fReactionSetInTime = fReactionSet->GetReactionsPerTime();
480 fSampledMinTimeStep = fReactionSetInTime.begin()->get()->GetTime() - currentGlobalTime;
481
482 return fSampledMinTimeStep;
483}
@ 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
G4TrackStatus
@ fStopAndKill
@ fStopButAlive
bool G4bool
Definition: G4Types.hh:86
G4ITReactionPerTime & GetReactionsPerTime()
G4TrackList * GetMainList(Key)
static G4Scheduler * Instance()
Definition: G4Scheduler.cc:101
static G4ThreadLocal G4double fUserMinTimeStep

◆ CalculateStep()

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

Implements G4VITTimeStepComputer.

Definition at line 107 of file G4DNAIRTMoleculeEncounterStepper.cc.

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

◆ GetReactionModel()

G4VDNAReactionModel * G4DNAIRTMoleculeEncounterStepper::GetReactionModel ( )

Definition at line 421 of file G4DNAIRTMoleculeEncounterStepper.cc.

422{
423 return fReactionModel;
424}

◆ operator=()

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

◆ Prepare()

void G4DNAIRTMoleculeEncounterStepper::Prepare ( )
virtual

Reimplemented from G4VITTimeStepComputer.

Definition at line 80 of file G4DNAIRTMoleculeEncounterStepper.cc.

81{
83 if(G4Scheduler::Instance()->GetGlobalTime() == G4Scheduler::Instance()->GetStartTime()){
86 }
87}
virtual void UpdatePositionMap()

◆ SetReactionModel()

void G4DNAIRTMoleculeEncounterStepper::SetReactionModel ( G4VDNAReactionModel pReactionModel)

Definition at line 416 of file G4DNAIRTMoleculeEncounterStepper.cc.

417{
418 fReactionModel = pReactionModel;
419}

◆ SetVerbose()

void G4DNAIRTMoleculeEncounterStepper::SetVerbose ( int  flag)

Definition at line 426 of file G4DNAIRTMoleculeEncounterStepper.cc.

427{
428 fVerbose = flag;
429}

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