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

#include <G4DNAGillespieDirectMethod.hh>

Public Types

using MolType = const G4MolecularConfiguration *
 
using Index = G4VDNAMesh::Index
 
using Voxel = G4DNAMesh::Voxel
 
using JumpingData = std::pair< MolType, Index >
 
using ReactionData = const G4DNAMolecularReactionData
 
using EventIt = G4DNAEventSet::EventSet::iterator
 

Public Member Functions

 G4DNAGillespieDirectMethod ()
 
 ~G4DNAGillespieDirectMethod ()
 
G4double PropensityFunction (const Voxel &voxel, ReactionData *data)
 
G4double PropensityFunction (const Voxel &voxel, MolType moleType)
 
void SetVoxelMesh (G4DNAMesh &mesh)
 
void SetTimeStep (const G4double &stepTime)
 
void Initialize ()
 
void CreateEvent (const Index &index)
 
void SetEventSet (G4DNAEventSet *)
 

Detailed Description

Definition at line 40 of file G4DNAGillespieDirectMethod.hh.

Member Typedef Documentation

◆ EventIt

using G4DNAGillespieDirectMethod::EventIt = G4DNAEventSet::EventSet::iterator

Definition at line 50 of file G4DNAGillespieDirectMethod.hh.

◆ Index

◆ JumpingData

◆ MolType

◆ ReactionData

◆ Voxel

Constructor & Destructor Documentation

◆ G4DNAGillespieDirectMethod()

G4DNAGillespieDirectMethod::G4DNAGillespieDirectMethod ( )

Definition at line 37 of file G4DNAGillespieDirectMethod.cc.

38 : fMolecularReactions(G4DNAMolecularReactionTable::Instance())
39{}
static G4DNAMolecularReactionTable * Instance()

◆ ~G4DNAGillespieDirectMethod()

G4DNAGillespieDirectMethod::~G4DNAGillespieDirectMethod ( )
default

Member Function Documentation

◆ CreateEvent()

void G4DNAGillespieDirectMethod::CreateEvent ( const Index index)

Definition at line 178 of file G4DNAGillespieDirectMethod.cc.

179{
180 const auto& voxel = fpMesh->GetVoxel(index);
181 if(std::get<2>(voxel).empty())
182 {
183 G4ExceptionDescription exceptionDescription;
184 exceptionDescription << "This voxel : " << index
185 << " is not ready to make event" << G4endl;
186 G4Exception("G4DNAGillespieDirectMethod::CreateEvent",
187 "G4DNAGillespieDirectMethod05", FatalErrorInArgument,
188 exceptionDescription);
189 }
190 G4double r1 = G4UniformRand();
191 G4double r2 = G4UniformRand();
192 G4double dAlpha0 = DiffusiveJumping(voxel);
193 G4double rAlpha0 = Reaction(voxel);
194 G4double alphaTotal = dAlpha0 + rAlpha0;
195
196 if(alphaTotal == 0)
197 {
198 return;
199 }
200 auto timeStep = ((1.0 / (alphaTotal)) * std::log(1.0 / r1)) + fTimeStep;
201
202#ifdef DEBUG
203 G4cout << "r2 : " << r2 << " rAlpha0 : " << rAlpha0
204 << " dAlpha0 : " << dAlpha0 << " rAlpha0 / (dAlpha0 + rAlpha0) : "
205 << rAlpha0 / (dAlpha0 + rAlpha0) << G4endl;
206#endif
207 if(r2 < rAlpha0 / alphaTotal)
208 {
209 if(fVerbose > 1)
210 {
211 G4cout << "=>>>>reaction at : " << timeStep << " timeStep : "
212 << G4BestUnit(((1.0 / alphaTotal) * std::log(1.0 / r1)), "Time")
213 << G4endl;
214 }
215 auto rSelectedIter = fReactionDataMap.upper_bound(r2 * alphaTotal);
216 fpEventSet->CreateEvent(timeStep, index, rSelectedIter->second);
217 }
218 else if(dAlpha0 > 0)
219 {
220 if(fVerbose > 1)
221 {
222 G4cout << "=>>>>jumping at : " << timeStep << " timeStep : "
223 << G4BestUnit(((1.0 / alphaTotal) * std::log(1.0 / r1)), "Time")
224 << G4endl;
225 }
226
227 auto dSelectedIter = fJumpingDataMap.upper_bound(r2 * alphaTotal - rAlpha0);
228 auto pDSelected =
229 std::make_unique<std::pair<MolType, Index>>(dSelectedIter->second);
230 fpEventSet->CreateEvent(timeStep, index, std::move(pDSelected));
231 }
232#ifdef DEBUG
233 G4cout << G4endl;
234#endif
235}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4BestUnit(a, b)
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
void CreateEvent(const G4double &time, const Index &index, Event::ReactionData *pReactionData)
Voxel & GetVoxel(const Index &index)
Definition: G4DNAMesh.cc:36

Referenced by Initialize().

◆ Initialize()

void G4DNAGillespieDirectMethod::Initialize ( )

Definition at line 156 of file G4DNAGillespieDirectMethod.cc.

157{
158 // for Scavenger
159 fpScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
161
162 auto begin = fpMesh->begin();
163 auto end = fpMesh->end();
164 for(; begin != end; begin++)
165 {
166 auto index = std::get<0>(*begin);
167#ifdef DEBUG
168 fpMesh->PrintVoxel(index);
169#endif
170 CreateEvent(index);
171 }
172}
void CreateEvent(const Index &index)
void PrintVoxel(const Index &index)
Definition: G4DNAMesh.cc:102
auto begin()
Definition: G4DNAMesh.hh:60
auto end()
Definition: G4DNAMesh.hh:59
static G4Scheduler * Instance()
Definition: G4Scheduler.cc:101
G4VScavengerMaterial * GetScavengerMaterial() const
Definition: G4Scheduler.hh:194

◆ PropensityFunction() [1/2]

G4double G4DNAGillespieDirectMethod::PropensityFunction ( const Voxel voxel,
MolType  moleType 
)

Definition at line 67 of file G4DNAGillespieDirectMethod.cc.

69{
70 if(moleType->GetDiffusionCoefficient() == 0)
71 {
72 return 0.;
73 }
74 const auto& node = std::get<2>(voxel);
75 const auto& box = std::get<1>(voxel);
76
77 G4double alpha = 0;
78 auto it = node.find(moleType);
79 if(it != node.end())
80 {
81 auto LengthY = box.Getyhi() - box.Getylo();
82 G4double d = it->first->GetDiffusionCoefficient() / std::pow(LengthY, 2);
83 alpha = d * it->second;
84
85#ifdef DEBUG
86 G4cout << it->first->GetName() << " " << it->second
87 << " D : " << it->first->GetDiffusionCoefficient()
88 << " LengthY : " << LengthY << " PropensityFunction : " << alpha
89 << G4endl;
90#endif
91 }
92 return alpha;
93}

◆ PropensityFunction() [2/2]

G4double G4DNAGillespieDirectMethod::PropensityFunction ( const Voxel voxel,
ReactionData data 
)

Definition at line 95 of file G4DNAGillespieDirectMethod.cc.

97{
98 G4double value;
99 auto ConfA = data->GetReactant1();
100 auto ConfB = data->GetReactant2();
101 G4double scavengerNumber = 0;
102 auto typeANumber = FindScavenging(voxel, ConfA, scavengerNumber)
103 ? scavengerNumber
104 : ComputeNumberInNode(voxel, ConfA);
105
106 auto typeBNumber = FindScavenging(voxel, ConfB, scavengerNumber)
107 ? scavengerNumber
108 : ComputeNumberInNode(voxel, ConfB);
109
110 if(typeANumber == 0 || typeBNumber == 0)
111 {
112 return 0;
113 }
114
115 auto k =
116 data->GetObservedReactionRateConstant() / (Avogadro * VolumeOfNode(voxel));
117 if(ConfA == ConfB)
118 {
119 value = typeANumber * (typeBNumber - 1) * k;
120 }
121 else
122 {
123 value = typeANumber * typeBNumber * k;
124 }
125
126 if(value < 0)
127 {
128 G4ExceptionDescription exceptionDescription;
129 exceptionDescription
130 << "G4DNAGillespieDirectMethod::PropensityFunction for : "
131 << ConfA->GetName() << "(" << typeANumber << ") + " << ConfB->GetName()
132 << "(" << typeBNumber << ") : propensity : " << value
133 << " GetObservedReactionRateConstant : "
134 << data->GetObservedReactionRateConstant()
135 << " GetEffectiveReactionRadius : "
136 << G4BestUnit(data->GetEffectiveReactionRadius(), "Length")
137 << " k : " << k << " volume : " << VolumeOfNode(voxel) << G4endl;
138 G4Exception("G4DNAGillespieDirectMethod::PropensityFunction",
139 "G4DNAGillespieDirectMethod013", FatalErrorInArgument,
140 exceptionDescription);
141 }
142
143#ifdef DEBUG
144 if(value > 0)
145 G4cout << "G4DNAGillespieDirectMethod::PropensityFunction for : "
146 << ConfA->GetName() << "(" << typeANumber << ") + "
147 << ConfB->GetName() << "(" << typeBNumber
148 << ") : propensity : " << value
149 << " Time to Reaction : " << G4BestUnit(timeToReaction, "Time")
150 << " k : " << k << " Index : " << index << G4endl;
151#endif
152
153 return value;
154}

◆ SetEventSet()

void G4DNAGillespieDirectMethod::SetEventSet ( G4DNAEventSet pEventSet)

Definition at line 43 of file G4DNAGillespieDirectMethod.cc.

44{
45 fpEventSet = pEventSet;
46}

◆ SetTimeStep()

void G4DNAGillespieDirectMethod::SetTimeStep ( const G4double stepTime)

Definition at line 174 of file G4DNAGillespieDirectMethod.cc.

175{
176 fTimeStep = stepTime;
177}

◆ SetVoxelMesh()

void G4DNAGillespieDirectMethod::SetVoxelMesh ( G4DNAMesh mesh)
inline

Definition at line 54 of file G4DNAGillespieDirectMethod.hh.

54{ fpMesh = &mesh; }

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