Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: G4DNASmoluchowskiReactionModel.cc 94218 2015-11-09 08:24:48Z gcosmo $ 26 // 27 // 27 #include "G4DNASmoluchowskiReactionModel.hh" 28 #include "G4DNASmoluchowskiReactionModel.hh" 28 #include "Randomize.hh" 29 #include "Randomize.hh" 29 #include "G4Track.hh" 30 #include "G4Track.hh" 30 #include "G4DNAMolecularReactionTable.hh" 31 #include "G4DNAMolecularReactionTable.hh" 31 #include "G4UnitsTable.hh" 32 #include "G4UnitsTable.hh" 32 #include "G4Molecule.hh" 33 #include "G4Molecule.hh" 33 #include "G4Exp.hh" << 34 //#include "G4Scheduler.hh" 34 35 35 G4DNASmoluchowskiReactionModel::G4DNASmoluchow << 36 G4DNASmoluchowskiReactionModel::G4DNASmoluchowskiReactionModel() : >> 37 G4VDNAReactionModel() >> 38 { >> 39 fReactionData = 0; >> 40 } 36 41 37 G4DNASmoluchowskiReactionModel::~G4DNASmolucho << 42 G4DNASmoluchowskiReactionModel::G4DNASmoluchowskiReactionModel(const G4DNASmoluchowskiReactionModel& __right) : >> 43 G4VDNAReactionModel(__right) >> 44 { >> 45 fReactionData = 0; >> 46 } 38 47 39 void G4DNASmoluchowskiReactionModel::Initialis << 48 G4DNASmoluchowskiReactionModel& G4DNASmoluchowskiReactionModel::operator=(const G4DNASmoluchowskiReactionModel& right) >> 49 { >> 50 if (this == &right) return *this; >> 51 fReactionData = 0; >> 52 return *this; >> 53 } >> 54 >> 55 G4DNASmoluchowskiReactionModel::~G4DNASmoluchowskiReactionModel() >> 56 { >> 57 fReactionData = 0; >> 58 } >> 59 >> 60 void G4DNASmoluchowskiReactionModel::Initialise(G4MolecularConfiguration* __molecule, 40 61 const G4Track&) 41 { 62 { 42 fpReactionData = fpReactionTable->GetReact << 63 fReactionData = fReactionTable->GetReactionData(__molecule); 43 } 64 } 44 65 45 void G4DNASmoluchowskiReactionModel::Initialis << 66 void >> 67 G4DNASmoluchowskiReactionModel:: >> 68 InitialiseToPrint(G4MolecularConfiguration* __molecule) 46 { 69 { 47 fpReactionData = fpReactionTable->GetReact << 70 fReactionData = fReactionTable->GetReactionData(__molecule); 48 } 71 } 49 72 50 G4double G4DNASmoluchowskiReactionModel::GetRe << 73 G4double 51 << 74 G4DNASmoluchowskiReactionModel::GetReactionRadius(G4MolecularConfiguration* __mol1, >> 75 G4MolecularConfiguration* __mol2) 52 { 76 { 53 G4double __output = fpReactionTable->GetRe << 77 G4double __output = fReactionTable->GetReactionData(__mol1, __mol2) 54 return __output; << 78 ->GetEffectiveReactionRadius(); >> 79 return __output; 55 } 80 } 56 81 57 G4double G4DNASmoluchowskiReactionModel::GetRe << 82 G4double G4DNASmoluchowskiReactionModel::GetReactionRadius(const G4int __i) 58 { 83 { 59 G4double __output = (*fpReactionData)[__i] << 84 G4double __output = (*fReactionData)[__i]->GetEffectiveReactionRadius(); 60 return __output; << 85 return __output; 61 } 86 } 62 87 63 G4bool G4DNASmoluchowskiReactionModel::FindRea 88 G4bool G4DNASmoluchowskiReactionModel::FindReaction(const G4Track& __trackA, 64 89 const G4Track& __trackB, 65 << 90 const G4double __R, 66 << 91 G4double& __r, 67 92 const G4bool __alongStepReaction) 68 { 93 { 69 const G4double R2 = __reactionRadius * __r << 94 G4double postStepSeparation = 0; 70 G4double postStepSeparation = 0.; << 95 bool do_break = false; 71 bool do_break = false; << 96 G4double R2 = __R * __R; 72 int k = 0; << 97 int k = 0; >> 98 >> 99 for (; k < 3; k++) >> 100 { >> 101 postStepSeparation += std::pow( >> 102 __trackA.GetPosition()[k] - __trackB.GetPosition()[k], 2); 73 103 74 for (; k < 3; ++k) << 104 if (postStepSeparation > R2) 75 { 105 { 76 postStepSeparation += std::pow( << 106 do_break = true; 77 __trackA.GetPosition()[k] - __trac << 107 break; 78 << 79 if (postStepSeparation > R2) << 80 { << 81 do_break = true; << 82 break; << 83 } << 84 } 108 } >> 109 } 85 110 86 if (!do_break) << 111 if (do_break == false) >> 112 { >> 113 // The loop was not break >> 114 // => __r^2 < __R^2 >> 115 __r = std::sqrt(postStepSeparation); >> 116 return true; >> 117 } >> 118 else if (__alongStepReaction == true) >> 119 { >> 120 //G4cout << "alongStepReaction==true" << G4endl; >> 121 //Along step cheack and >> 122 // the loop has break >> 123 >> 124 // Continue loop >> 125 for (; k < 3; k++) 87 { 126 { 88 // The loop was not break << 127 postStepSeparation += std::pow( 89 // => r^2 < R^2 << 128 __trackA.GetPosition()[k] - __trackB.GetPosition()[k], 2); 90 __separationDistance = std::sqrt(postS << 91 return true; << 92 } 129 } 93 if (__alongStepReaction) << 130 // Use Green approach : the Brownian bridge 94 { << 131 __r = (postStepSeparation = std::sqrt(postStepSeparation)); 95 //Along step check and the loop has br << 132 >> 133 G4Molecule* __moleculeA = GetMolecule(__trackA); >> 134 G4Molecule* __moleculeB = GetMolecule(__trackB); >> 135 >> 136 G4double __D = __moleculeA->GetDiffusionCoefficient() >> 137 + __moleculeB->GetDiffusionCoefficient(); >> 138 >> 139 G4ThreeVector __preStepPositionA = __trackA.GetStep()->GetPreStepPoint() >> 140 ->GetPosition(); >> 141 G4ThreeVector __preStepPositionB = __trackB.GetStep()->GetPreStepPoint() >> 142 ->GetPosition(); 96 143 97 // Continue loop << 144 if (__preStepPositionA == __trackA.GetPosition()) 98 for (; k < 3; ++k) << 145 { 99 { << 146 G4ExceptionDescription exceptionDescription; 100 postStepSeparation += std::pow( << 147 exceptionDescription << "The molecule : " << __moleculeA->GetName(); 101 __trackA.GetPosition()[k] - __ << 148 exceptionDescription << " with track ID :" << __trackA.GetTrackID(); 102 } << 149 exceptionDescription << " did not move since the previous step." << G4endl; 103 // Use Green approach : the Brownian b << 150 exceptionDescription << "Current position : " 104 __separationDistance = (postStepSepara << 151 << G4BestUnit(__trackA.GetPosition(), "Length") 105 << 152 << G4endl; 106 auto pMoleculeA = GetMolecule(__trackA << 153 exceptionDescription << "Previous position : " 107 auto pMoleculeB = GetMolecule(__trackB << 154 << G4BestUnit(__preStepPositionA, "Length") << G4endl; 108 << 155 G4Exception("G4DNASmoluchowskiReactionModel::FindReaction", 109 G4double D = pMoleculeA->GetDiffusionC << 156 "G4DNASmoluchowskiReactionModel", FatalErrorInArgument, 110 + pMoleculeB->GetDiffusio << 157 exceptionDescription); 111 << 112 const auto& preStepPositionA = __track << 113 const auto& preStepPositionB = __track << 114 << 115 G4double preStepSeparation = (preStepP << 116 << 117 //=================================== << 118 // Brownian bridge << 119 G4double __probabiltyOfEncounter = G4E << 120 << 121 << 122 ); << 123 G4double __selectedPOE = G4UniformRand << 124 << 125 if (__selectedPOE <= __probabiltyOfEnc << 126 { << 127 return true; << 128 } << 129 //=================================== << 130 } 158 } 131 159 132 return false; << 160 G4double __preStepSeparation = >> 161 (__preStepPositionA - __preStepPositionB).mag(); >> 162 >> 163 //=================================== >> 164 // Brownian bridge >> 165 >> 166 >> 167 // if(G4Scheduler::Instance()->GetTimeStep() != __trackB.GetStep()->GetDeltaTime()) >> 168 // { >> 169 // G4cout << G4Scheduler::Instance()->GetTimeStep() << G4endl; >> 170 // G4cout << __trackB.GetStep()->GetDeltaTime() << G4endl; >> 171 // assert(G4Scheduler::Instance()->GetTimeStep() == __trackB.GetStep()->GetDeltaTime()); >> 172 // } >> 173 >> 174 G4double __probabiltyOfEncounter = std::exp( >> 175 -(__preStepSeparation - __R) * (postStepSeparation - __R) / (__D >> 176 * (__trackB.GetStep()->GetDeltaTime()))); >> 177 G4double __selectedPOE = G4UniformRand(); >> 178 >> 179 if (__selectedPOE <= __probabiltyOfEncounter) return true; >> 180 //=================================== >> 181 } >> 182 >> 183 return false; 133 } 184 } 134 185