56G4DNAIRTMoleculeEncounterStepper::Utils::Utils(
const G4Track& tA,
59 , fpMoleculeB(pMoleculeB)
62 fDA = fpMoleculeA->GetDiffusionCoefficient();
63 fDB = fpMoleculeB->GetDiffusionCoefficient();
64 fConstant = 8 * (fDA + fDB + 2 * sqrt(fDA * fDB));
69 , fHasAlreadyReachedNullTime(false)
71 , fReactionModel(nullptr)
89void G4DNAIRTMoleculeEncounterStepper::InitializeForNewTrack()
96 fHasAlreadyReachedNullTime =
false;
102 return std::numeric_limits<T>::has_infinity
103 && value == std::numeric_limits<T>::infinity();
112 InitializeForNewTrack();
119 <<
"_______________________________________________________________________"
121 G4cout <<
"G4DNAMoleculeEncounterStepper::CalculateStep" <<
G4endl;
122 G4cout <<
"Check done for molecule : " << pMoleculeA->GetName()
130 auto pMolConfA = pMoleculeA->GetMolecularConfiguration();
132 const auto pReactantList = fMolecularReactionTable->
CanReactWith(pMolConfA);
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."
153 G4int nbReactives = pReactantList->size();
155 if (nbReactives == 0)
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."
177 fReactionModel->
Initialise(pMolConfA, trackA);
181 for (
G4int i = 0; i < nbReactives; i++)
183 auto pMoleculeB = (*pReactantList)[i];
195 if (resultsNearest == 0)
continue;
197 G4double r2 = resultsNearest->GetDistanceSqr();
198 Utils utils(trackA, pMoleculeB);
207 if (fHasAlreadyReachedNullTime ==
false)
210 fHasAlreadyReachedNullTime =
true;
218 CheckAndRecordResults(utils,
227 G4double tempMinET = pow(r - R, 2) / utils.fConstant;
246 FindNearestInRange(pMoleculeA,
250 CheckAndRecordResults(utils,
265 CheckAndRecordResults(utils,
278 G4cout <<
"G4MoleculeEncounterStepper::CalculateStep will finally return :"
283 G4cout <<
"Selected reactants for trackA: " << pMoleculeA->GetName()
286 vector<G4Track*>::iterator it;
303void G4DNAIRTMoleculeEncounterStepper::CheckAndRecordResults(
const Utils& utils,
314 G4cout <<
"No molecule " << utils.fpMoleculeB->GetName()
315 <<
" found to react with " << utils.fpMoleculeA->GetName()
322 for (results->Rewind(); !results->End(); results->Next())
324 G4IT* reactiveB = results->GetItem<
G4IT>();
337 <<
"The reactant B found using the MoleculeFinder does not have a valid "
338 "track attached to it. If this is done on purpose, please do "
339 "not record this molecule in the MoleculeFinder."
341 G4Exception(
"G4DNAMoleculeEncounterStepper::RetrieveResults",
343 exceptionDescription);
352 if (trackB == &utils.fpTrackA)
356 <<
"A track is reacting with itself (which is impossible) ie fpTrackA == trackB"
358 exceptionDescription <<
"Molecule A (and B) is of type : "
359 << utils.fpMoleculeA->GetName() <<
" with trackID : "
360 << utils.fpTrackA.GetTrackID() <<
G4endl;
362 G4Exception(
"G4DNAMoleculeEncounterStepper::RetrieveResults",
364 exceptionDescription);
368 if (fabs(trackB->
GetGlobalTime() - utils.fpTrackA.GetGlobalTime())
369 > utils.fpTrackA.GetGlobalTime() * (1 - 1 / 100))
374 <<
"The interacting tracks are not synchronized in time" <<
G4endl;
376 <<
"trackB->GetGlobalTime() != fpTrackA.GetGlobalTime()" <<
G4endl;
378 exceptionDescription <<
"fpTrackA : trackID : " << utils.fpTrackA.GetTrackID()
379 <<
"\t Name :" << utils.fpMoleculeA->GetName()
380 <<
"\t fpTrackA->GetGlobalTime() = "
383 exceptionDescription <<
"trackB : trackID : " << trackB->
GetTrackID()
384 <<
"\t Name :" << utils.fpMoleculeB->GetName()
385 <<
"\t trackB->GetGlobalTime() = "
388 G4Exception(
"G4DNAMoleculeEncounterStepper::RetrieveResults",
390 exceptionDescription);
397 G4double r2 = results->GetDistanceSqr();
398 G4cout <<
"\t ************************************************** " <<
G4endl;
399 G4cout <<
"\t Reaction between "
400 << utils.fpMoleculeA->GetName() <<
" (" << utils.fpTrackA.GetTrackID() <<
") "
401 <<
" & " << utils.fpMoleculeB->GetName() <<
" (" << trackB->
GetTrackID() <<
"), "
402 <<
"Interaction Range = "
404 G4cout <<
"\t Real distance between reactants = "
406 G4cout <<
"\t Distance between reactants calculated by nearest neighbor algorithm = "
418 fReactionModel = pReactionModel;
423 return fReactionModel;
438 if(fReactionSet->
Empty()){
441 for (
auto pTrack : *fpTrackContainer->
GetMainList())
443 if (pTrack ==
nullptr)
446 exceptionDescription <<
"No track found.";
447 G4Exception(
"G4Scheduler::CalculateMinStep",
"ITScheduler006",
463 }
else if(active ==
false){
471 for (
auto pTrack : *fpTrackContainer->
GetMainList())
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4Molecule * GetMolecule(const G4Track &track)
ReturnType & reference_cast(OriginalType &source)
G4GLOB_DLL std::ostream G4cout
void SetReactionModel(G4VDNAReactionModel *)
virtual G4double CalculateMinTimeStep(G4double, G4double)
G4DNAIRTMoleculeEncounterStepper()
virtual G4double CalculateStep(const G4Track &, const G4double &)
G4VDNAReactionModel * GetReactionModel()
virtual ~G4DNAIRTMoleculeEncounterStepper()
const ReactantList * CanReactWith(Reactant *) const
virtual void UpdatePositionMap()
static G4ITFinder * Instance()
static G4ITReactionSet * Instance()
G4ITReactionPerTime & GetReactionsPerTime()
G4TrackList * GetMainList(Key)
static G4ITTrackHolder * Instance()
G4int GetMoleculeID() const
const G4String & GetName() const
static G4Scheduler * Instance()
G4TrackStatus GetTrackStatus() const
const G4ThreeVector & GetPosition() const
G4double GetGlobalTime() const
virtual void Initialise(const G4MolecularConfiguration *, const G4Track &)
virtual G4double GetReactionRadius(const G4MolecularConfiguration *, const G4MolecularConfiguration *)=0
G4TrackVectorHandle fReactants
static G4ThreadLocal G4double fUserMinTimeStep
G4double fSampledMinTimeStep