Geant4-11
Public Member Functions | Protected Attributes | Private Attributes
G4DNAIRT_geometries Class Reference

#include <G4DNAIRT_geometries.hh>

Inheritance diagram for G4DNAIRT_geometries:
G4VITReactionProcess

Public Member Functions

G4int FindBin (G4int, G4double, G4double, G4double)
 
std::vector< std::unique_ptr< G4ITReactionChange > > FindReaction (G4ITReactionSet *, const G4double, const G4double, const G4bool) override
 
 G4DNAIRT_geometries ()
 
 G4DNAIRT_geometries (const G4DNAIRT_geometries &other)=delete
 
 G4DNAIRT_geometries (G4VDNAReactionModel *)
 
G4double GetIndependentReactionTime (const G4MolecularConfiguration *, const G4MolecularConfiguration *, G4double)
 
void Initialize () override
 
void IRTSampling ()
 
virtual G4bool IsApplicable (const G4ITType &, const G4ITType &) const
 
std::unique_ptr< G4ITReactionChangeMakeReaction (const G4Track &, const G4Track &) override
 
G4DNAIRT_geometriesoperator= (const G4DNAIRT_geometries &other)=delete
 
G4double SamplePDC (G4double, G4double)
 
void Sampling (G4Track *)
 
void SetReactionModel (G4VDNAReactionModel *)
 
virtual void SetReactionTable (const G4ITReactionTable *)
 
void SpaceBinning ()
 
G4bool TestReactibility (const G4Track &, const G4Track &, G4double, G4bool) override
 
 ~G4DNAIRT_geometries () override
 

Protected Attributes

const G4DNAMolecularReactionTable *& fMolReactionTable
 
G4String fName
 
G4VDNAReactionModelfpReactionModel
 
const G4ITReactionTablefpReactionTable = nullptr
 

Private Attributes

G4ErrorFunctionerfc
 
G4VDNAMolecularGeometryfGeometry
 
G4int fNx
 
G4int fNy
 
G4int fNz
 
G4double fRCutOff
 
G4ITReactionSetfReactionSet
 
G4ITTrackHolderfTrackHolder
 
G4double fXMax
 
G4double fXMin
 
G4double fYMax
 
G4double fYMin
 
G4double fZMax
 
G4double fZMin
 
std::vector< std::pair< G4ThreeVector, G4Track * > > positionMap
 
std::map< G4int, std::map< G4int, std::map< G4int, std::vector< G4Track * > > > > spaceBinned
 
G4double timeMax
 
G4double timeMin
 
G4int xendIndex
 
G4int xiniIndex
 
G4int yendIndex
 
G4int yiniIndex
 
G4int zendIndex
 
G4int ziniIndex
 

Detailed Description

Definition at line 65 of file G4DNAIRT_geometries.hh.

Constructor & Destructor Documentation

◆ G4DNAIRT_geometries() [1/3]

G4DNAIRT_geometries::G4DNAIRT_geometries ( )

Definition at line 54 of file G4DNAIRT_geometries.cc.

54 :
56fMolReactionTable(reference_cast<const G4DNAMolecularReactionTable*>(fpReactionTable)),
57fpReactionModel(nullptr),
59fReactionSet(nullptr),
60fGeometry(nullptr)
61{
64
65 fXMin = 1e9*nm;
66 fYMin = 1e9*nm;
67 fZMin = 1e9*nm;
68
69 fXMax = 0e0*nm;
70 fYMax = 0e0*nm;
71 fZMax = 0e0*nm;
72
73 fNx = 0;
74 fNy = 0;
75 fNz = 0;
76
77 xiniIndex = 0, yiniIndex = 0, ziniIndex = 0;
78 xendIndex = 0, yendIndex = 0, zendIndex = 0;
79
80 fRCutOff =
81 1.45 * nm + 2 * std::sqrt(8*9.46e9*nm*nm/s * timeMax); // 95% confidence level
82
83 erfc = new G4ErrorFunction();
84}
static constexpr double nm
Definition: G4SIunits.hh:92
static constexpr double s
Definition: G4SIunits.hh:154
G4ErrorFunction * erfc
G4ITTrackHolder * fTrackHolder
G4VDNAMolecularGeometry * fGeometry
G4VDNAReactionModel * fpReactionModel
const G4DNAMolecularReactionTable *& fMolReactionTable
G4ITReactionSet * fReactionSet
static G4ITTrackHolder * Instance()
static G4Scheduler * Instance()
Definition: G4Scheduler.cc:101
G4double GetEndTime() const
Definition: G4Scheduler.hh:349
G4double GetStartTime() const
Definition: G4Scheduler.hh:344
const G4ITReactionTable * fpReactionTable
G4VITReactionProcess()=default

References erfc, fNx, fNy, fNz, fRCutOff, fXMax, fXMin, fYMax, fYMin, fZMax, fZMin, G4Scheduler::GetEndTime(), G4Scheduler::GetStartTime(), G4Scheduler::Instance(), nm, s, timeMax, timeMin, xendIndex, xiniIndex, yendIndex, yiniIndex, zendIndex, and ziniIndex.

◆ G4DNAIRT_geometries() [2/3]

G4DNAIRT_geometries::G4DNAIRT_geometries ( G4VDNAReactionModel pReactionModel)
explicit

Definition at line 87 of file G4DNAIRT_geometries.cc.

89{
90 fpReactionModel = pReactionModel;
91}

References fpReactionModel.

◆ ~G4DNAIRT_geometries()

G4DNAIRT_geometries::~G4DNAIRT_geometries ( )
override

Definition at line 93 of file G4DNAIRT_geometries.cc.

94{
95 delete erfc;
96}

References erfc.

◆ G4DNAIRT_geometries() [3/3]

G4DNAIRT_geometries::G4DNAIRT_geometries ( const G4DNAIRT_geometries other)
delete

Member Function Documentation

◆ FindBin()

G4int G4DNAIRT_geometries::FindBin ( G4int  n,
G4double  xmin,
G4double  xmax,
G4double  value 
)

(xmax < value) ) //value >= xmax )

Definition at line 430 of file G4DNAIRT_geometries.cc.

430 {
431
432 G4int bin = -1;
433 if ( value <= xmin )
434 bin = 0; //1;
435 else if ( value >= xmax)
436 bin = n-1; //n;
437 else
438 bin = G4int( n * ( value - xmin )/( xmax - xmin ) ); //bin = 1 + G4int( n * ( value - xmin )/( xmax - xmin ) );
439
440 if ( bin < 0 ) bin = 0;
441 if ( bin >= n ) bin = n-1;
442
443 return bin;
444}
int G4int
Definition: G4Types.hh:85

References CLHEP::detail::n.

Referenced by IRTSampling(), MakeReaction(), and Sampling().

◆ FindReaction()

std::vector< std::unique_ptr< G4ITReactionChange > > G4DNAIRT_geometries::FindReaction ( G4ITReactionSet pReactionSet,
const  G4double,
const G4double  fGlobalTime,
const  G4bool 
)
overridevirtual

Implements G4VITReactionProcess.

Definition at line 590 of file G4DNAIRT_geometries.cc.

595{
596 std::vector<std::unique_ptr<G4ITReactionChange>> fReactionInfo;
597 fReactionInfo.clear();
598
599 if (pReactionSet == nullptr)
600 {
601 return fReactionInfo;
602 }
603
604 auto fReactionsetInTime = pReactionSet->GetReactionsPerTime();
605 assert(fReactionsetInTime.begin() != fReactionsetInTime.end());
606
607 auto it_begin = fReactionsetInTime.begin();
608 while(it_begin != fReactionsetInTime.end())
609 {
610 G4double irt = it_begin->get()->GetTime();
611
612 if(fGlobalTime < irt) break;
613
614 pReactionSet->SelectThisReaction(*it_begin);
615
616 G4Track* pTrackA = it_begin->get()->GetReactants().first;
617 G4Track* pTrackB = it_begin->get()->GetReactants().second;
618 auto pReactionChange = MakeReaction(*pTrackA, *pTrackB);
619
620 if(pReactionChange){
621 fReactionInfo.push_back(std::move(pReactionChange));
622 }
623
624 fReactionsetInTime = pReactionSet->GetReactionsPerTime();
625 it_begin = fReactionsetInTime.begin();
626 }
627
628 return fReactionInfo;
629}
double G4double
Definition: G4Types.hh:83
std::unique_ptr< G4ITReactionChange > MakeReaction(const G4Track &, const G4Track &) override
void SelectThisReaction(G4ITReactionPtr reaction)
G4ITReactionPerTime & GetReactionsPerTime()

References G4ITReactionSet::GetReactionsPerTime(), MakeReaction(), and G4ITReactionSet::SelectThisReaction().

◆ GetIndependentReactionTime()

G4double G4DNAIRT_geometries::GetIndependentReactionTime ( const G4MolecularConfiguration molA,
const G4MolecularConfiguration molB,
G4double  distance 
)

Definition at line 371 of file G4DNAIRT_geometries.cc.

371 {
372 const auto pMoleculeA = molA;
373 const auto pMoleculeB = molB;
374 auto fReactionData = fMolReactionTable->GetReactionData(pMoleculeA, pMoleculeB);
375 G4int reactionType = fReactionData->GetReactionType();
376 G4double r0 = distance;
377 if(r0 == 0) r0 += 1e-3*nm;
378 G4double irt = -1 * ps;
381 if(D == 0) D += 1e-20*(m2/s);
382 G4double rc = fReactionData->GetOnsagerRadius();
383
384 if ( reactionType == 0){
385 G4double sigma = fReactionData->GetEffectiveReactionRadius();
386
387 if(sigma > r0) return 0; // contact reaction
388 if( rc != 0) r0 = -rc / (1-std::exp(rc/r0));
389
390 G4double Winf = sigma/r0;
392
393 if ( W > 0 && W < Winf ) irt = (0.25/D) * std::pow( (r0-sigma)/erfc->erfcInv(r0*W/sigma), 2 );
394
395 return irt;
396 }
397 else if ( reactionType == 1 ){
398 G4double sigma = fReactionData->GetReactionRadius();
399 G4double kact = fReactionData->GetActivationRateConstant();
400 G4double kdif = fReactionData->GetDiffusionRateConstant();
401 G4double kobs = fReactionData->GetObservedReactionRateConstant();
402
403 G4double a, b, Winf;
404
405 if ( rc == 0 ) {
406 a = 1/sigma * kact / kobs;
407 b = (r0 - sigma) / 2;
408 } else {
409 G4double v = kact/Avogadro/(4*CLHEP::pi*pow(sigma,2) * exp(-rc / sigma));
410 G4double alpha = v+rc*D/(pow(sigma,2)*(1-exp(-rc/sigma)));
411 a = 4*pow(sigma,2)*alpha/(D*pow(rc,2))*pow(sinh(rc/(2*sigma)),2);
412 b = rc/4*(cosh(rc/(2*r0))/sinh(rc/(2*r0))-cosh(rc/(2*sigma))/sinh(rc/(2*sigma)));
413 r0 = -rc/(1-std::exp(rc/r0));
414 sigma = fReactionData->GetEffectiveReactionRadius();
415 }
416
417 if(sigma > r0){
418 if(fReactionData->GetProbability() > G4UniformRand()) return 0;
419 else return irt;
420 }
421 Winf = sigma / r0 * kobs / kdif;
422
423 if(Winf > G4UniformRand()) irt = SamplePDC(a,b)/D;
424 return irt;
425 }
426
427 return -1 * ps;
428}
G4double D(G4double temp)
static const G4double alpha
static constexpr double ps
Definition: G4SIunits.hh:157
static constexpr double m2
Definition: G4SIunits.hh:110
#define G4UniformRand()
Definition: Randomize.hh:52
G4double SamplePDC(G4double, G4double)
Data * GetReactionData(Reactant *, Reactant *) const
static G4double erfcInv(G4double x)
static constexpr double pi
Definition: SystemOfUnits.h:55
float Avogadro
Definition: hepunit.py:252

References alpha, source.hepunit::Avogadro, D(), erfc, G4ErrorFunction::erfcInv(), fMolReactionTable, G4UniformRand, G4MolecularConfiguration::GetDiffusionCoefficient(), G4DNAMolecularReactionTable::GetReactionData(), G4DNAMolecularReactionData::GetReactionType(), m2, nm, CLHEP::pi, ps, s, and SamplePDC().

Referenced by Sampling().

◆ Initialize()

void G4DNAIRT_geometries::Initialize ( )
overridevirtual

First initialization (done once for all at the begin of the run) eg. check if the reaction table is given ...

Reimplemented from G4VITReactionProcess.

Definition at line 98 of file G4DNAIRT_geometries.cc.

98 {
99
101 timeMax = std::min(timeMin + G4Scheduler::Instance()->GetLimitingTimeStep(),
102 G4Scheduler::Instance()->GetEndTime());
103 if(timeMin == 0) return;
104
106 if(fTrackHolder->GetMainList()->size() == 0) return;
107
111
112 spaceBinned.clear();
113 positionMap.clear();
114
115 fRCutOff =
116 1.45 * nm + 2 * std::sqrt(8*9.46e9*nm*nm/s * (timeMax - timeMin));
117
118 xiniIndex = 0;
119 yiniIndex = 0;
120 ziniIndex = 0;
121 xendIndex = 0;
122 yendIndex = 0;
123 zendIndex = 0;
124
125 fXMin = 1e9*nm;
126 fYMin = 1e9*nm;
127 fZMin = 1e9*nm;
128
129 fXMax = 0e0*nm;
130 fYMax = 0e0*nm;
131 fZMax = 0e0*nm;
132
133 fNx = 0;
134 fNy = 0;
135 fNz = 0;
136
138
139 SpaceBinning(); // 1. binning the space
140 IRTSampling(); // 2. Sampling of the IRT
141
142}
std::vector< std::pair< G4ThreeVector, G4Track * > > positionMap
std::map< G4int, std::map< G4int, std::map< G4int, std::vector< G4Track * > > > > spaceBinned
G4VDNAMolecularGeometry * GetGeometry() const
G4int size() const
Definition: G4FastList.hh:357
static G4ITReactionSet * Instance()
void CleanAllReaction()
G4TrackList * GetMainList(Key)
G4double GetGlobalTime() const
Definition: G4Scheduler.hh:364
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References G4ITReactionSet::CleanAllReaction(), fGeometry, fMolReactionTable, fNx, fNy, fNz, fRCutOff, fReactionSet, fTrackHolder, fXMax, fXMin, fYMax, fYMin, fZMax, fZMin, G4DNAMolecularReactionTable::GetGeometry(), G4Scheduler::GetGlobalTime(), G4ITTrackHolder::GetMainList(), G4ITReactionSet::Instance(), G4ITTrackHolder::Instance(), G4Scheduler::Instance(), IRTSampling(), G4INCL::Math::min(), nm, positionMap, s, G4FastList< OBJECT >::size(), G4ITReactionSet::SortByTime(), spaceBinned, SpaceBinning(), timeMax, timeMin, xendIndex, xiniIndex, yendIndex, yiniIndex, zendIndex, and ziniIndex.

◆ IRTSampling()

void G4DNAIRT_geometries::IRTSampling ( )

Definition at line 180 of file G4DNAIRT_geometries.cc.

180 {
181
182 auto it_begin = fTrackHolder->GetMainList()->begin();
183 while(it_begin != fTrackHolder->GetMainList()->end()){
184 G4int I = FindBin(fNx, fXMin, fXMax, it_begin->GetPosition().x());
185 G4int J = FindBin(fNy, fYMin, fYMax, it_begin->GetPosition().y());
186 G4int K = FindBin(fNz, fZMin, fZMax, it_begin->GetPosition().z());
187
188 spaceBinned[I][J][K].push_back(*it_begin);
189
190 Sampling(*it_begin);
191 ++it_begin;
192 }
193}
G4int FindBin(G4int, G4double, G4double, G4double)
iterator begin()
iterator end()

References G4FastList< OBJECT >::begin(), G4FastList< OBJECT >::end(), FindBin(), fNx, fNy, fNz, fTrackHolder, fXMax, fXMin, fYMax, fYMin, fZMax, fZMin, G4ITTrackHolder::GetMainList(), Sampling(), and spaceBinned.

Referenced by Initialize().

◆ IsApplicable()

G4bool G4VITReactionProcess::IsApplicable ( const G4ITType ,
const G4ITType  
) const
virtualinherited

Definition at line 43 of file G4VITReactionProcess.cc.

44{
45 return true;
46}

◆ MakeReaction()

std::unique_ptr< G4ITReactionChange > G4DNAIRT_geometries::MakeReaction ( const G4Track trackA,
const G4Track trackB 
)
overridevirtual

Implements G4VITReactionProcess.

Definition at line 479 of file G4DNAIRT_geometries.cc.

481{
482
483 std::unique_ptr<G4ITReactionChange> pChanges(new G4ITReactionChange());
484 pChanges->Initialize(trackA, trackB);
485
486 const auto pMoleculeA = GetMolecule(trackA)->GetMolecularConfiguration();
487 const auto pMoleculeB = GetMolecule(trackB)->GetMolecularConfiguration();
488 const auto pReactionData = fMolReactionTable->GetReactionData(pMoleculeA, pMoleculeB);
489
491 G4double effectiveReactionRadius = pReactionData->GetEffectiveReactionRadius();
492
493 const G4double D1 = pMoleculeA->GetDiffusionCoefficient();
494 const G4double D2 = pMoleculeB->GetDiffusionCoefficient();
495
496 G4ThreeVector r1 = trackA.GetPosition();
497 G4ThreeVector r2 = trackB.GetPosition();
498
499 if(r1 == r2) r2 += G4ThreeVector(0,0,1e-3*nm);
500
501 G4ThreeVector S1 = r1 - r2;
502
503 G4double r0 = S1.mag();
504
505 S1.setMag(effectiveReactionRadius);
506
507 G4double dt = globalTime - trackA.GetGlobalTime();
508
509 if(dt != 0 && (D1 + D2) != 0 && r0 != 0){
510 G4double s12 = 2.0 * D1 * dt;
511 G4double s22 = 2.0 * D2 * dt;
512 if(s12 == 0) r2 = r1;
513 else if(s22 == 0) r1 = r2;
514 else{
515 G4double alpha = effectiveReactionRadius * r0 / (2*(D1 + D2)*dt);
516 G4ThreeVector S2 = (r1 + (s12 / s22)*r2) + G4ThreeVector(G4RandGauss::shoot(0, s12 + s22 * s22 / s12),
517 G4RandGauss::shoot(0, s12 + s22 * s22 / s12),
518 G4RandGauss::shoot(0, s12 + s22 * s22 / s12));
519
520 S1.setPhi(rad * G4UniformRand() * 2.0 * CLHEP::pi);
521 S1.setTheta(rad * std::acos(1.0 + 1./alpha * std::log(1.0 - G4UniformRand() * (1 - std::exp(-2.0 * alpha)))));
522
523 r1 = (D1 * S1 + D2 * S2) / (D1 + D2);
524 r2 = D2 * (S2 - S1) / (D1 + D2);
525 }
526 }
527
528 auto pTrackA = const_cast<G4Track*>(pChanges->GetTrackA());
529 auto pTrackB = const_cast<G4Track*>(pChanges->GetTrackB());
530
531 pTrackA->SetPosition(r1);
532 pTrackB->SetPosition(r2);
533
534 pTrackA->SetGlobalTime(globalTime);
535 pTrackB->SetGlobalTime(globalTime);
536
537 pTrackA->SetTrackStatus(fStopButAlive);
538 pTrackB->SetTrackStatus(fStopButAlive);
539
540 const G4int nbProducts = pReactionData->GetNbProducts();
541
542 if(nbProducts){
543
544 const G4double sqrD1 = D1 == 0. ? 0. : std::sqrt(D1);
545 const G4double sqrD2 = D2 == 0. ? 0. : std::sqrt(D2);
546 const G4double inv_numerator = 1./(sqrD1 + sqrD2);
547 const G4ThreeVector reactionSite = sqrD2 * inv_numerator * trackA.GetPosition()
548 + sqrD1 * inv_numerator * trackB.GetPosition();
549
550 std::vector<G4ThreeVector> position;
551
552 if(nbProducts == 1){
553 position.push_back(reactionSite);
554 }else if(nbProducts == 2){
555 position.push_back(trackA.GetPosition());
556 position.push_back(trackB.GetPosition());
557 }else if (nbProducts == 3){
558 position.push_back(reactionSite);
559 position.push_back(trackA.GetPosition());
560 position.push_back(trackB.GetPosition());
561 }
562
563 for(G4int u = 0; u < nbProducts; ++u){
564
565 auto product = new G4Molecule(pReactionData->GetProduct(u));
566 auto productTrack = product->BuildTrack(globalTime,
567 position[u]);
568
569 productTrack->SetTrackStatus(fAlive);
570 fTrackHolder->Push(productTrack);
571
572 pChanges->AddSecondary(productTrack);
573
574 G4int I = FindBin(fNx, fXMin, fXMax, position[u].x());
575 G4int J = FindBin(fNy, fYMin, fYMax, position[u].y());
576 G4int K = FindBin(fNz, fZMin, fZMax, position[u].z());
577
578 spaceBinned[I][J][K].push_back(productTrack);
579
580 Sampling(productTrack);
581 }
582 }
583
585 pChanges->KillParents(true);
586 return pChanges;
587}
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:76
static constexpr double rad
Definition: G4SIunits.hh:129
CLHEP::Hep3Vector G4ThreeVector
@ fAlive
@ fStopButAlive
void setTheta(double)
double mag() const
void setMag(double)
Definition: ThreeVector.cc:20
void setPhi(double)
virtual void Push(G4Track *)
void MergeSecondariesWithMainList()
const G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:532
void SetPosition(const G4ThreeVector &aValue)
const G4ThreeVector & GetPosition() const
G4double GetGlobalTime() const
ThreeVector shoot(const G4int Ap, const G4int Af)
#define position
Definition: xmlparse.cc:622

References alpha, fAlive, FindBin(), fMolReactionTable, fNx, fNy, fNz, fStopButAlive, fTrackHolder, fXMax, fXMin, fYMax, fYMin, fZMax, fZMin, G4UniformRand, G4Scheduler::GetGlobalTime(), G4Track::GetGlobalTime(), G4Molecule::GetMolecularConfiguration(), GetMolecule(), G4Track::GetPosition(), G4DNAMolecularReactionTable::GetReactionData(), G4Scheduler::Instance(), CLHEP::Hep3Vector::mag(), G4ITTrackHolder::MergeSecondariesWithMainList(), nm, CLHEP::pi, position, G4ITTrackHolder::Push(), rad, Sampling(), CLHEP::Hep3Vector::setMag(), CLHEP::Hep3Vector::setPhi(), G4Track::SetPosition(), CLHEP::Hep3Vector::setTheta(), G4INCL::DeJongSpin::shoot(), and spaceBinned.

Referenced by FindReaction().

◆ operator=()

G4DNAIRT_geometries & G4DNAIRT_geometries::operator= ( const G4DNAIRT_geometries other)
delete

◆ SamplePDC()

G4double G4DNAIRT_geometries::SamplePDC ( G4double  a,
G4double  b 
)

Definition at line 446 of file G4DNAIRT_geometries.cc.

446 {
447
448 G4double p = 2.0 * std::sqrt(2.0*b/a);
449 G4double q = 2.0 / std::sqrt(2.0*b/a);
450 G4double M = max(1.0/(a*a),3.0*b/a);
451
452 G4double X, U, lambdax;
453
454 G4int ntrials = 0;
455 while(1) {
456
457 // Generate X
458 U = G4UniformRand();
459 if ( U < p/(p + q * M) ) X = pow(U * (p + q * M) / 2, 2);
460 else X = pow(2/((1-U)*(p+q*M)/M),2);
461
462 U = G4UniformRand();
463
464 lambdax = std::exp(-b*b/X) * ( 1.0 - a * std::sqrt(CLHEP::pi * X) * erfc->erfcx(b/std::sqrt(X) + a*std::sqrt(X)));
465
466 if ((X <= 2.0*b/a && U <= lambdax) ||
467 (X >= 2.0*b/a && U*M/X <= lambdax)) break;
468
469 ntrials++;
470
471 if ( ntrials > 10000 ){
472 G4cout<<"Totally rejected"<<'\n';
473 return -1.0;
474 }
475 }
476 return X;
477}
#define M(row, col)
G4GLOB_DLL std::ostream G4cout
static G4double erfcx(G4double x)
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References erfc, G4ErrorFunction::erfcx(), G4cout, G4UniformRand, M, G4INCL::Math::max(), and CLHEP::pi.

Referenced by GetIndependentReactionTime().

◆ Sampling()

void G4DNAIRT_geometries::Sampling ( G4Track track)

Definition at line 195 of file G4DNAIRT_geometries.cc.

195 {
196 G4Molecule* molA = G4Molecule::GetMolecule(track);
197 const G4MolecularConfiguration* molConfA = molA->GetMolecularConfiguration();
198 if(molConfA->GetDiffusionCoefficient() == 0) return;
199
200 const vector<const G4MolecularConfiguration*>* reactivesVector =
202
203 if(reactivesVector == nullptr) return;
204
206 G4double minTime = timeMax;
207
214
215 for ( G4int ii = xiniIndex; ii <= xendIndex; ++ii ) {
216 for ( G4int jj = yiniIndex; jj <= yendIndex; ++jj ) {
217 for ( G4int kk = ziniIndex; kk <= zendIndex; ++kk ) {
218
219 std::vector<G4Track*> spaceBin = spaceBinned[ii][jj][kk];
220 for ( G4int n = 0; n < (G4int)spaceBinned[ii][jj][kk].size(); ++n ) {
221 if(!spaceBin[n] || track == spaceBin[n]) continue;
222 if(spaceBin[n]->GetTrackStatus() == fStopButAlive) continue;
223
224 G4Molecule* molB = G4Molecule::GetMolecule(spaceBin[n]);
225 if(!molB) continue;
226
227 const G4MolecularConfiguration* molConfB = molB->GetMolecularConfiguration();
228 if(molConfB->GetDiffusionCoefficient() == 0) continue;
229
230 auto it = std::find(reactivesVector->begin(), reactivesVector->end(), molConfB);
231 if(it == reactivesVector->end()) continue;
232
233 G4ThreeVector orgPosB = spaceBin[n]->GetPosition();
234 G4double dt = track->GetGlobalTime() - spaceBin[n]->GetGlobalTime();
235 G4ThreeVector newPosB = orgPosB;
236
237 if(dt > 0){
238 G4double sigma, x, y, z;
239 G4double diffusionCoefficient = G4Molecule::GetMolecule(spaceBin[n])->GetDiffusionCoefficient();
240
241 sigma = std::sqrt(2.0 * diffusionCoefficient * dt);
242
243 x = G4RandGauss::shoot(0., 1.0)*sigma;
244 y = G4RandGauss::shoot(0., 1.0)*sigma;
245 z = G4RandGauss::shoot(0., 1.0)*sigma;
246
247 newPosB = orgPosB + G4ThreeVector(x,y,z);
248 }else if(dt < 0) continue;
249
250 G4double r0 = (newPosB - track->GetPosition()).mag();
252 molConfB,
253 r0);
254 if(irt>=0 && irt<timeMax - globalTime)
255 {
256 irt += globalTime;
257 if(irt < minTime) minTime = irt;
258#ifdef DEBUG
259 G4cout<<irt<<'\t'<<molConfA->GetName()<<" "<<track->GetTrackID()<<'\t'<<molConfB->GetName()<<" "<<spaceBin[n]->GetTrackID()<<'\n';
260#endif
261 fReactionSet->AddReaction(irt,track,spaceBin[n]);
262 }
263 }
264 spaceBin.clear();
265 }
266 }
267 }
268
269// Scavenging & first order reactions
270
271 auto fReactionDatas = fMolReactionTable->GetReactionData(molConfA);
272 G4int index = -1;
273
274 for(size_t u=0; u<fReactionDatas->size();++u){
275 auto molB = (*fReactionDatas)[u]->GetReactant2();
276 if(molB == G4MoleculeTable::Instance()->GetConfiguration("H2O(B)") ||
277 molB == G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)") ||
278 molB == G4MoleculeTable::Instance()->GetConfiguration("OHm(B)")){
279 G4double kObs = (*fReactionDatas)[u]->GetObservedReactionRateConstant();
280 if(kObs == 0) continue;
281 G4double time = -(std::log(1.0 - G4UniformRand())/kObs) + globalTime;
282 if( time < minTime && time >= globalTime && time < timeMax){
283 minTime = time;
284 index = (G4int)u;
285 }
286 }
287 }
288
289 if(index != -1){
290#ifdef DEBUG
291 G4cout<<"scavenged: "<<minTime<<'\t'<<molConfA->GetName()<<it_begin->GetTrackID()<<'\n';
292#endif
293 G4Molecule* fakeMol = new G4Molecule((*fReactionDatas)[index]->GetReactant2());
294 G4Track* fakeTrack = fakeMol->BuildTrack(globalTime,track->GetPosition());
295 fTrackHolder->Push(fakeTrack);
296 fReactionSet->AddReaction(minTime, track, fakeTrack);
297 }
298
299
300 // DNA reactions
301 if(fGeometry == nullptr) return;
302
303 const G4VTouchable* touchable = track->GetTouchable();
304 if(touchable == nullptr) return;
305
306 const G4LogicalVolume* logicalVolume = touchable->GetVolume()->GetLogicalVolume();
307
308 const G4ThreeVector& globalPos = track->GetPosition();
309 const G4ThreeVector& localPos = touchable->GetHistory()->GetTopTransform().TransformPoint(globalPos);
310
312 G4double time_step = abs(timeMax - timeMin);
313 G4double search_range = 2*sqrt(2*D*time_step);
314
315 std::vector<G4VPhysicalVolume*> result_pv;
316 result_pv.clear();
317 fGeometry->FindNearbyMolecules(logicalVolume,
318 localPos,
319 result_pv,
320 search_range);
321
322 if(result_pv.empty()) return;
323
324 for(auto physicalVolume : result_pv){
325 const G4Material* material = physicalVolume->GetLogicalVolume()->GetMaterial();
326 G4MolecularConfiguration* dna_molConf =
328
329 auto it = std::find(reactivesVector->begin(), reactivesVector->end(), dna_molConf);
330 if(it == reactivesVector->end()) continue;
331 G4ThreeVector pos = physicalVolume->GetTranslation();
332
333 G4ThreeVector globalPos_DNA = touchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(pos);
334
335 G4double r0 = (pos - localPos).mag();
336 G4double irt = GetIndependentReactionTime(molConfA,dna_molConf,r0);
337
338 if(irt>=0 && irt<timeMax - globalTime)
339 {
340
341 index = -1;
342 for(size_t i=0;i<positionMap.size();++i){
343 if(globalPos_DNA == positionMap[i].first){
344 index = (G4int)i;
345 break;
346 }
347 }
348
349 G4Track* DNATrack;
350 if(index == -1){
351 auto DNAMol = new G4Molecule(dna_molConf);
352 DNATrack = DNAMol->BuildTrack(globalTime,globalPos_DNA);
353 DNATrack->SetTrackStatus(fAlive);
354 fTrackHolder->Push(DNATrack);
355 positionMap.push_back(std::make_pair(globalPos_DNA,DNATrack));
356 }else{
357 DNATrack = positionMap[index].second;
358 }
359
360 irt += globalTime;
361 if(irt < minTime) minTime = irt;
362#ifdef DEBUG
363 G4cout<<irt<<'\t'<<globalPos_DNA<<'\t'<<molConfA->GetName()<<" "<<track->GetTrackID()<<'\t'<<dna_molConf->GetName()<<" "<<DNATrack->GetTrackID()<<'\n';
364#endif
365 fReactionSet->AddReaction(irt,track,DNATrack);
366 }
367 }
368}
static const G4double pos
double z() const
double x() const
double y() const
G4AffineTransform Inverse() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4double GetIndependentReactionTime(const G4MolecularConfiguration *, const G4MolecularConfiguration *, G4double)
G4MolecularConfiguration * GetMolecularConfiguration(const G4Material *) const
static G4DNAMolecularMaterial * Instance()
const ReactantList * CanReactWith(Reactant *) const
void AddReaction(G4double time, G4Track *trackA, G4Track *trackB)
const G4String & GetName() const
static G4MoleculeTable * Instance()
static G4Molecule * GetMolecule(const G4Track *)
Definition: G4Molecule.cc:90
G4Track * BuildTrack(G4double globalTime, const G4ThreeVector &Position)
Definition: G4Molecule.cc:373
G4double GetDiffusionCoefficient() const
Definition: G4Molecule.cc:516
const G4AffineTransform & GetTopTransform() const
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4int GetTrackID() const
const G4VTouchable * GetTouchable() const
virtual void FindNearbyMolecules(const G4LogicalVolume *, const G4ThreeVector &, std::vector< G4VPhysicalVolume * > &, G4double)
G4LogicalVolume * GetLogicalVolume() const
virtual const G4NavigationHistory * GetHistory() const
Definition: G4VTouchable.cc:82
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:34
string material
Definition: eplot.py:19

References G4ITReactionSet::AddReaction(), G4Molecule::BuildTrack(), G4DNAMolecularReactionTable::CanReactWith(), D(), fAlive, fGeometry, FindBin(), G4VDNAMolecularGeometry::FindNearbyMolecules(), fMolReactionTable, fNx, fNy, fNz, fRCutOff, fReactionSet, fStopButAlive, fTrackHolder, fXMax, fXMin, fYMax, fYMin, fZMax, fZMin, G4cout, G4UniformRand, G4MolecularConfiguration::GetDiffusionCoefficient(), G4Molecule::GetDiffusionCoefficient(), G4Scheduler::GetGlobalTime(), G4Track::GetGlobalTime(), G4VTouchable::GetHistory(), GetIndependentReactionTime(), G4VPhysicalVolume::GetLogicalVolume(), G4Molecule::GetMolecularConfiguration(), G4DNAMolecularMaterial::GetMolecularConfiguration(), GetMolecule(), G4Molecule::GetMolecule(), G4MolecularConfiguration::GetName(), G4Track::GetPosition(), G4DNAMolecularReactionData::GetReactant2(), G4DNAMolecularReactionTable::GetReactionData(), G4NavigationHistory::GetTopTransform(), G4Track::GetTouchable(), G4Track::GetTrackID(), G4VTouchable::GetVolume(), G4Scheduler::Instance(), G4MoleculeTable::Instance(), G4DNAMolecularMaterial::Instance(), G4AffineTransform::Inverse(), eplot::material, CLHEP::detail::n, pos, positionMap, G4ITTrackHolder::Push(), G4Track::SetTrackStatus(), G4INCL::DeJongSpin::shoot(), spaceBinned, timeMax, timeMin, G4AffineTransform::TransformPoint(), CLHEP::Hep3Vector::x(), xendIndex, xiniIndex, CLHEP::Hep3Vector::y(), yendIndex, yiniIndex, CLHEP::Hep3Vector::z(), zendIndex, and ziniIndex.

Referenced by IRTSampling(), and MakeReaction().

◆ SetReactionModel()

void G4DNAIRT_geometries::SetReactionModel ( G4VDNAReactionModel model)

Definition at line 639 of file G4DNAIRT_geometries.cc.

640{
641 fpReactionModel = model;
642}

References fpReactionModel.

◆ SetReactionTable()

void G4VITReactionProcess::SetReactionTable ( const G4ITReactionTable pReactionTable)
virtualinherited

Definition at line 38 of file G4VITReactionProcess.cc.

39{
40 fpReactionTable = pReactionTable;
41}

References G4VITReactionProcess::fpReactionTable.

◆ SpaceBinning()

void G4DNAIRT_geometries::SpaceBinning ( )

Definition at line 144 of file G4DNAIRT_geometries.cc.

144 {
146
147 auto it_begin = fTrackHolder->GetMainList()->begin();
148 while(it_begin != fTrackHolder->GetMainList()->end()){
149
150 // for diffusion
152 G4double sqrt_2Dt = sqrt(2 * D * time_step);
153
154 G4double x = G4RandGauss::shoot(0,sqrt_2Dt);
155 G4double y = G4RandGauss::shoot(0,sqrt_2Dt);
156 G4double z = G4RandGauss::shoot(0,sqrt_2Dt);
157
158 G4ThreeVector position_ori = it_begin->GetPosition();
159 G4ThreeVector position = position_ori + G4ThreeVector(x,y,z);
160 it_begin->SetPosition(position);
161 it_begin->SetGlobalTime(timeMax);
162
163 if ( fXMin > position.x() ) fXMin = position.x();
164 if ( fYMin > position.y() ) fYMin = position.y();
165 if ( fZMin > position.z() ) fZMin = position.z();
166
167 if ( fXMax < position.x() ) fXMax = position.x();
168 if ( fYMax < position.y() ) fYMax = position.y();
169 if ( fZMax < position.z() ) fZMax = position.z();
170
171 ++it_begin;
172 }
173
174 fNx = G4int((fXMax-fXMin)/fRCutOff) == 0 ? 1 : G4int((fXMax-fXMin)/fRCutOff);
175 fNy = G4int((fYMax-fYMin)/fRCutOff) == 0 ? 1 : G4int((fYMax-fYMin)/fRCutOff);
176 fNz = G4int((fZMax-fZMin)/fRCutOff) == 0 ? 1 : G4int((fZMax-fZMin)/fRCutOff);
177
178}
G4double GetPreviousTimeStep() const
Definition: G4Scheduler.hh:411

References G4FastList< OBJECT >::begin(), D(), G4FastList< OBJECT >::end(), fNx, fNy, fNz, fRCutOff, fTrackHolder, fXMax, fXMin, fYMax, fYMin, fZMax, fZMin, G4Molecule::GetDiffusionCoefficient(), G4ITTrackHolder::GetMainList(), GetMolecule(), G4Scheduler::GetPreviousTimeStep(), G4Scheduler::Instance(), ps, G4INCL::DeJongSpin::shoot(), and timeMax.

Referenced by Initialize().

◆ TestReactibility()

G4bool G4DNAIRT_geometries::TestReactibility ( const G4Track ,
const G4Track ,
G4double  ,
G4bool   
)
overridevirtual

Implements G4VITReactionProcess.

Definition at line 631 of file G4DNAIRT_geometries.cc.

635{
636 return true;
637}

Field Documentation

◆ erfc

G4ErrorFunction* G4DNAIRT_geometries::erfc
private

◆ fGeometry

G4VDNAMolecularGeometry* G4DNAIRT_geometries::fGeometry
private

Definition at line 115 of file G4DNAIRT_geometries.hh.

Referenced by Initialize(), and Sampling().

◆ fMolReactionTable

const G4DNAMolecularReactionTable*& G4DNAIRT_geometries::fMolReactionTable
protected

◆ fName

G4String G4VITReactionProcess::fName
protectedinherited

Definition at line 91 of file G4VITReactionProcess.hh.

◆ fNx

G4int G4DNAIRT_geometries::fNx
private

◆ fNy

G4int G4DNAIRT_geometries::fNy
private

◆ fNz

G4int G4DNAIRT_geometries::fNz
private

◆ fpReactionModel

G4VDNAReactionModel* G4DNAIRT_geometries::fpReactionModel
protected

Definition at line 95 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), and SetReactionModel().

◆ fpReactionTable

const G4ITReactionTable* G4VITReactionProcess::fpReactionTable = nullptr
protectedinherited

Definition at line 90 of file G4VITReactionProcess.hh.

Referenced by G4VITReactionProcess::SetReactionTable().

◆ fRCutOff

G4double G4DNAIRT_geometries::fRCutOff
private

Definition at line 105 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), Sampling(), and SpaceBinning().

◆ fReactionSet

G4ITReactionSet* G4DNAIRT_geometries::fReactionSet
private

Definition at line 99 of file G4DNAIRT_geometries.hh.

Referenced by Initialize(), and Sampling().

◆ fTrackHolder

G4ITTrackHolder* G4DNAIRT_geometries::fTrackHolder
private

Definition at line 98 of file G4DNAIRT_geometries.hh.

Referenced by Initialize(), IRTSampling(), MakeReaction(), Sampling(), and SpaceBinning().

◆ fXMax

G4double G4DNAIRT_geometries::fXMax
private

◆ fXMin

G4double G4DNAIRT_geometries::fXMin
private

◆ fYMax

G4double G4DNAIRT_geometries::fYMax
private

◆ fYMin

G4double G4DNAIRT_geometries::fYMin
private

◆ fZMax

G4double G4DNAIRT_geometries::fZMax
private

◆ fZMin

G4double G4DNAIRT_geometries::fZMin
private

◆ positionMap

std::vector<std::pair<G4ThreeVector,G4Track*> > G4DNAIRT_geometries::positionMap
private

Definition at line 103 of file G4DNAIRT_geometries.hh.

Referenced by Initialize(), and Sampling().

◆ spaceBinned

std::map<G4int,std::map<G4int,std::map<G4int,std::vector<G4Track*> > > > G4DNAIRT_geometries::spaceBinned
private

Definition at line 102 of file G4DNAIRT_geometries.hh.

Referenced by Initialize(), IRTSampling(), MakeReaction(), and Sampling().

◆ timeMax

G4double G4DNAIRT_geometries::timeMax
private

Definition at line 107 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), Sampling(), and SpaceBinning().

◆ timeMin

G4double G4DNAIRT_geometries::timeMin
private

Definition at line 106 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), and Sampling().

◆ xendIndex

G4int G4DNAIRT_geometries::xendIndex
private

Definition at line 113 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), and Sampling().

◆ xiniIndex

G4int G4DNAIRT_geometries::xiniIndex
private

Definition at line 112 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), and Sampling().

◆ yendIndex

G4int G4DNAIRT_geometries::yendIndex
private

Definition at line 113 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), and Sampling().

◆ yiniIndex

G4int G4DNAIRT_geometries::yiniIndex
private

Definition at line 112 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), and Sampling().

◆ zendIndex

G4int G4DNAIRT_geometries::zendIndex
private

Definition at line 113 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), and Sampling().

◆ ziniIndex

G4int G4DNAIRT_geometries::ziniIndex
private

Definition at line 112 of file G4DNAIRT_geometries.hh.

Referenced by G4DNAIRT_geometries(), Initialize(), and Sampling().


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