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

#include <G4DNAIndependentReactionTimeStepper.hh>

Inheritance diagram for G4DNAIndependentReactionTimeStepper:

Public Member Functions

 G4DNAIndependentReactionTimeStepper ()
 ~G4DNAIndependentReactionTimeStepper () override=default
 G4DNAIndependentReactionTimeStepper (const G4DNAIndependentReactionTimeStepper &)=delete
G4DNAIndependentReactionTimeStepperoperator= (const G4DNAIndependentReactionTimeStepper &)=delete
void Prepare () override
G4double CalculateStep (const G4Track &, const G4double &) override
G4double CalculateMinTimeStep (G4double, G4double) override
void SetReactionModel (G4VDNAReactionModel *)
G4VDNAReactionModelGetReactionModel ()
std::unique_ptr< G4ITReactionChangeFindReaction (G4ITReactionSet *pReactionSet, G4double &currentStepTime, const G4double globalTime)
void SetReactionProcess (G4VITReactionProcess *pReactionProcess)
void SetVerbose (G4int)
Public Member Functions inherited from G4VITTimeStepComputer
 G4VITTimeStepComputer ()
virtual ~G4VITTimeStepComputer ()
 G4VITTimeStepComputer (const G4VITTimeStepComputer &)
G4VITTimeStepComputeroperator= (const G4VITTimeStepComputer &other)
virtual void Initialize ()
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

Definition at line 52 of file G4DNAIndependentReactionTimeStepper.hh.

Constructor & Destructor Documentation

◆ G4DNAIndependentReactionTimeStepper() [1/2]

G4DNAIndependentReactionTimeStepper::G4DNAIndependentReactionTimeStepper ( )

Definition at line 55 of file G4DNAIndependentReactionTimeStepper.cc.

56{
57 fReactionSet->SortByTime();
58}

Referenced by G4DNAIndependentReactionTimeStepper(), and operator=().

◆ ~G4DNAIndependentReactionTimeStepper()

G4DNAIndependentReactionTimeStepper::~G4DNAIndependentReactionTimeStepper ( )
overridedefault

◆ G4DNAIndependentReactionTimeStepper() [2/2]

G4DNAIndependentReactionTimeStepper::G4DNAIndependentReactionTimeStepper ( const G4DNAIndependentReactionTimeStepper & )
delete

Member Function Documentation

◆ CalculateMinTimeStep()

G4double G4DNAIndependentReactionTimeStepper::CalculateMinTimeStep ( G4double currentGlobalTime,
G4double  )
overridevirtual

Implements G4VITTimeStepComputer.

Definition at line 360 of file G4DNAIndependentReactionTimeStepper.cc.

362{
363 G4double fTSTimeStep = DBL_MAX;
364 // fUserMinTimeStep = definedMinTimeStep;
365 if (!fIsInitialized) {
366 InitializeReactions(currentGlobalTime);
367 }
368
369 G4int nbPreviousSecondaries = (G4int)fSecondaries.size();
370 if (nbPreviousSecondaries > 0) {
371 InitializeForNewTrack();
372 for (const auto& it : fSecondaries) {
374 }
375 fSecondaries.clear();
376 }
377 fTSTimeStep = GetNextReactionTime() - currentGlobalTime;
378 if (fTSTimeStep < 0) {
380 msg << "fTSTimeStep < 0" << ": fTSTimeStep : " << fTSTimeStep
381 << " GetNextReactionTime() : " << GetNextReactionTime()
382 << " currentGlobalTime : " << currentGlobalTime << G4endl;
383 G4Exception("G4DNAIndependentReactionTimeStepper::CalculateMinTimeStep",
384 "G4DNAIndependentReactionTimeStepper002", FatalErrorInArgument, msg);
385 }
386 return fTSTimeStep;
387}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4double CalculateStep(const G4Track &, const G4double &) override
static G4ThreadLocal G4double fUserMinTimeStep
#define DBL_MAX
Definition templates.hh:62

◆ CalculateStep()

G4double G4DNAIndependentReactionTimeStepper::CalculateStep ( const G4Track & trackA,
const G4double &  )
overridevirtual

Implements G4VITTimeStepComputer.

Definition at line 78 of file G4DNAIndependentReactionTimeStepper.cc.

80{
81 auto pMoleculeA = GetMolecule(trackA);
83 fCheckedTracks.insert(trackA.GetTrackID());
84
85#ifdef G4VERBOSE
86 if (fVerbose > 1) {
87 G4cout << "________________________________________________________________"
88 "_______"
89 << G4endl;
90 G4cout << "G4DNAIndependentReactionTimeStepper::CalculateStep" << G4endl;
91 G4cout << "Check done for molecule : " << pMoleculeA->GetName() << " (" << trackA.GetTrackID()
92 << ") " << G4endl;
93 }
94#endif
95
96 auto pMolConfA = pMoleculeA->GetMolecularConfiguration();
97
98 const auto pReactantList = fMolecularReactionTable->CanReactWith(pMolConfA);
99
100 if (pReactantList == nullptr) {
101 if (fVerbose > 1) {
103 msg << "G4DNAIndependentReactionTimeStepper::CalculateStep will return infinity "
104 "for the reaction because the molecule "
105 << pMoleculeA->GetName() << " does not have any reactants given in the reaction table."
106 << G4endl;
107 G4Exception("G4DNAIndependentReactionTimeStepper::CalculateStep",
108 "G4DNAIndependentReactionTimeStepper03", JustWarning, msg);
109 }
110 return DBL_MAX;
111 }
112
113 auto nbReactives = (G4int)pReactantList->size();
114
115 if (nbReactives == 0) {
116 if (fVerbose > 1) {
118 msg << "G4DNAIndependentReactionTimeStepper::CalculateStep will "
119 "return infinity "
120 "for the reaction because the molecule "
121 << pMoleculeA->GetName() << " does not have any reactants given in the reaction table."
122 << "This message can also result from a wrong implementation of "
123 "the reaction table."
124 << G4endl;
125 G4Exception("G4DNAIndependentReactionTimeStepper::CalculateStep",
126 "G4DNAIndependentReactionTimeStepper04", JustWarning, msg);
127 }
128 return DBL_MAX;
129 }
130 fReactionModel->Initialise(pMolConfA, trackA);
131 for (G4int i = 0; i < nbReactives; ++i) {
132 auto pMoleculeB = (*pReactantList)[i];
133 G4int key = pMoleculeB->GetMoleculeID();
134 fRCutOff = G4IRTUtils::GetRCutOff();
135 //______________________________________________________________
136 // Retrieve reaction range
137 const G4double Reff = fReactionModel->GetReactionRadius(i);
138 std::vector<std::pair<G4TrackList::iterator, G4double>> resultIndices;
139 resultIndices.clear();
140 G4ChemicalMoleculeFinder::Instance()->FindNearestInRange(trackA, key, fRCutOff, resultIndices);
141
142 if (resultIndices.empty()) {
143 continue;
144 }
145 for (auto& it : resultIndices) {
146 G4Track* pTrackB = *(std::get<0>(it));
147
148 if (pTrackB == &trackA) {
149 continue;
150 }
151 if (pTrackB == nullptr) {
152 G4ExceptionDescription exceptionDescription;
153 exceptionDescription << "No trackB no valid";
155 "G4DNAIndependentReactionTimeStepper"
156 "::CalculateStep()",
157 "G4DNAIndependentReactionTimeStepper007", FatalException, exceptionDescription);
158 }
159 if (fCheckedTracks.find(pTrackB->GetTrackID()) != fCheckedTracks.end()) {
160 continue;
161 }
162
163 Utils utils(trackA, *pTrackB);
164 auto pMolB = GetMolecule(pTrackB);
165 auto pMolConfB = pMolB->GetMolecularConfiguration();
166 G4double distance = (trackA.GetPosition() - pTrackB->GetPosition()).mag();
167 if (distance * distance < Reff * Reff) {
168 auto reactionData = fMolecularReactionTable->GetReactionData(pMolConfA, pMolConfB);
169 if (G4Scheduler::Instance()->GetGlobalTime() == G4Scheduler::Instance()->GetStartTime()) {
170 if (reactionData->GetProbability() > G4UniformRand()) {
172 }
173 }
174 }
175 else {
176 G4double tempMinET = GetTimeToEncounter(trackA, *pTrackB);
177 if (tempMinET < 0 || tempMinET > G4Scheduler::Instance()->GetEndTime()) {
178 continue;
179 }
180 fSampledMinTimeStep = tempMinET;
181 // Fixed the IRT_syn model (Stepper) to ensure it does not use minTimeStep (default = 1 ps)
182 // when DNA reactions do not yet share
183 // the same minTimeStep(The MinTimeStep is used to optimize the chemistry).
184 // TODO: full test
185
186 //if (tempMinET < fUserMinTimeStep) {
187 // fSampledMinTimeStep = fUserMinTimeStep;
188 //}
189 }
190 CheckAndRecordResults(fSampledMinTimeStep, utils);
191 }
192 }
193 return fSampledMinTimeStep;
194}
@ JustWarning
@ FatalException
G4Molecule * GetMolecule(const G4Track &track)
Definition G4Molecule.cc:75
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition Randomize.hh:52
static G4double GetRCutOff()
Definition G4IRTUtils.cc:39
static G4OctreeFinder * Instance()
void FindNearestInRange(const G4Track &track, const int &key, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSort=false) const
static G4Scheduler * Instance()
G4int GetTrackID() const
const G4ThreeVector & GetPosition() const

Referenced by CalculateMinTimeStep().

◆ FindReaction()

std::unique_ptr< G4ITReactionChange > G4DNAIndependentReactionTimeStepper::FindReaction ( G4ITReactionSet * pReactionSet,
G4double & currentStepTime,
const G4double globalTime )

Definition at line 263 of file G4DNAIndependentReactionTimeStepper.cc.

265{
266 if (pReactionSet == nullptr) {
267 return nullptr;
268 }
269
270 G4ITReactionPerTime& reactionPerTime = pReactionSet->GetReactionsPerTime();
271 if (reactionPerTime.empty()) {
272 return nullptr;
273 }
274 for (auto reaction_i = reactionPerTime.begin(); reaction_i != reactionPerTime.end();
275 reaction_i = reactionPerTime.begin())
276 {
277 G4Track* pTrackA = (*reaction_i)->GetReactants().first;
278 currentStepTime = DBL_MAX;
279 if (pTrackA->GetTrackStatus() == fStopAndKill) {
280 continue;
281 }
282 G4Track* pTrackB = (*reaction_i)->GetReactant(pTrackA);
283 currentStepTime = DBL_MAX;
284 if (pTrackB->GetTrackStatus() == fStopAndKill) {
285 continue;
286 }
287
288 if (pTrackB == pTrackA) {
290 msg << "The IT reaction process sent back a reaction "
291 "between trackA and trackB. ";
292 msg << "The problem is trackA == trackB";
293 G4Exception("G4DNAIndependentReactionTimeStepper::FindReaction",
294 "G4DNAIndependentReactionTimeStepper02", FatalErrorInArgument, msg);
295 }
296 G4double reactionTime = (*reaction_i)->GetTime();
297 currentStepTime = reactionTime - globalTime;
298 if(fVerbose > 1)
299 G4cout << " reaction Time : " << reactionTime << " currentStepTime : " << currentStepTime
300 << " globalTime : " << globalTime << " " << pTrackA->GetTrackID() << " + "
301 << pTrackB->GetTrackID() << G4endl;
302
303 pReactionSet->SelectThisReaction(*reaction_i);
304 if (fpReactionProcess != nullptr) {
305 if ((fSampledPositions.find(pTrackA->GetTrackID()) == fSampledPositions.end()
306 && (fSampledPositions.find(pTrackB->GetTrackID()) == fSampledPositions.end())))
307 {
309 msg << "The positions of trackA and trackB have no counted ";
310 G4Exception("G4DNAIndependentReactionTimeStepper::FindReaction",
311 "G4DNAIndependentReactionTimeStepper0001", FatalErrorInArgument, msg);
312 }
313
314 pTrackA->SetPosition(fSampledPositions[pTrackA->GetTrackID()]);
315 pTrackB->SetPosition(fSampledPositions[pTrackB->GetTrackID()]);
316 auto pReactionChange = fpReactionProcess->MakeReaction(*pTrackA, *pTrackB);
317 if (pReactionChange == nullptr) {
318 return nullptr;
319 }
320 G4int nbSecondaries = pReactionChange->GetNumberOfSecondaries();
321 if (nbSecondaries > 0) {
322 const std::vector<G4Track*>* productsVector = pReactionChange->GetfSecondary();
323 for (const auto& it : *productsVector) {
324 fSecondaries.push_back(it);
325 }
326 }
327 return pReactionChange;
328 }
329 }
330 return nullptr;
331}
std::multiset< G4ITReactionPtr, compReactionPerTime > G4ITReactionPerTime
@ fStopAndKill
void SelectThisReaction(G4ITReactionPtr reaction)
G4ITReactionPerTime & GetReactionsPerTime()
G4TrackStatus GetTrackStatus() const
void SetPosition(const G4ThreeVector &aValue)

◆ GetReactionModel()

G4VDNAReactionModel * G4DNAIndependentReactionTimeStepper::GetReactionModel ( )

Definition at line 338 of file G4DNAIndependentReactionTimeStepper.cc.

339{
340 return fReactionModel;
341}

◆ operator=()

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

◆ Prepare()

void G4DNAIndependentReactionTimeStepper::Prepare ( )
overridevirtual

Reimplemented from G4VITTimeStepComputer.

Definition at line 60 of file G4DNAIndependentReactionTimeStepper.cc.

61{
62 //fVerbose = G4Scheduler::Instance()->GetVerbose();
63 if (G4Scheduler::Instance()->IsInteractionStep()) {
64 fReactionSet->CleanAllReaction();
65 fIsInitialized = false;
66 fSampledPositions.clear();
67 fSecondaries.clear();
68 InitializeForNewTrack();
69 }
70}

◆ SetReactionModel()

void G4DNAIndependentReactionTimeStepper::SetReactionModel ( G4VDNAReactionModel * pReactionModel)

Definition at line 333 of file G4DNAIndependentReactionTimeStepper.cc.

334{
335 fReactionModel = pReactionModel;
336}

◆ SetReactionProcess()

void G4DNAIndependentReactionTimeStepper::SetReactionProcess ( G4VITReactionProcess * pReactionProcess)

Definition at line 356 of file G4DNAIndependentReactionTimeStepper.cc.

357{
358 fpReactionProcess = pReactionProcess;
359}

◆ SetVerbose()

void G4DNAIndependentReactionTimeStepper::SetVerbose ( G4int flag)

Definition at line 343 of file G4DNAIndependentReactionTimeStepper.cc.

344{
345 fVerbose = flag;
346}

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