Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
+11
-11
@@ -100,19 +100,19 @@ private:
|
||||
const G4double ExcitationEnergyAu[4]={ 2.66 , 1.14 , 4.63 , 5.11};
|
||||
// [eV] 5dto6s1,6sto6p1,6sto6p2
|
||||
|
||||
G4double fLowEnergyLimit;
|
||||
G4double fExperimentalEnergyLimit;
|
||||
G4double fHighEnergyLimit;
|
||||
G4double fLowEnergyLimit=0.;
|
||||
G4double fExperimentalEnergyLimit=0.;
|
||||
G4double fHighEnergyLimit=0.;
|
||||
|
||||
G4bool isInitialised;
|
||||
G4bool statCode;
|
||||
G4int verboseLevel;
|
||||
G4bool isInitialised=false;
|
||||
G4bool statCode=false;
|
||||
G4int verboseLevel=0;
|
||||
|
||||
G4String fTableFile;
|
||||
G4DNACrossSectionDataSet* fTableData;
|
||||
const std::vector<G4double>* fpMaterialDensity;
|
||||
const G4ParticleDefinition* fParticleDefinition;
|
||||
G4VAtomDeexcitation* fAtomDeexcitation;
|
||||
G4String fTableFile="";
|
||||
G4DNACrossSectionDataSet* fTableData=nullptr;
|
||||
const std::vector<G4double>* fpMaterialDensity=nullptr;
|
||||
const G4ParticleDefinition* fParticleDefinition=nullptr;
|
||||
G4VAtomDeexcitation* fAtomDeexcitation=nullptr;
|
||||
|
||||
G4int RandomSelect(const G4Material* material,
|
||||
const G4ParticleDefinition*,
|
||||
|
||||
@@ -72,11 +72,11 @@ public:
|
||||
G4double maxEnergy);
|
||||
|
||||
void SetMaximumEnergy (G4double input)
|
||||
{highEnergyLimit = input; SetHighEnergyLimit(input);};
|
||||
{fhighEnergyLimit = input; SetHighEnergyLimit(input);};
|
||||
|
||||
void SetKillBelowThreshold (G4double threshold);
|
||||
|
||||
G4double GetKillBelowThreshold() {return killBelowEnergy;}
|
||||
G4double GetKillBelowThreshold() {return fkillBelowEnergy_Au;}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -84,21 +84,18 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
G4int kScreeningFactor;
|
||||
|
||||
const std::vector<G4double>* fpMolDensity;
|
||||
const std::vector<G4double>* fpMolDensity=nullptr;
|
||||
std::vector <G4double> kIntersectionEnergySR;
|
||||
|
||||
G4double killBelowEnergy;
|
||||
G4double lowEnergyLimit;
|
||||
G4double highEnergyLimit;
|
||||
G4double fkillBelowEnergy_Au=0.;
|
||||
G4double flowEnergyLimit=0.;
|
||||
G4double fhighEnergyLimit=0.;
|
||||
|
||||
G4bool isInitialised;
|
||||
G4int verboseLevel;
|
||||
G4bool isInitialised=false;
|
||||
G4int verboseLevel=0;
|
||||
|
||||
typedef std::map<G4int,G4String, std::less<G4String> >MapZFile;
|
||||
typedef std::map<G4int,G4DNACrossSectionDataSet*,std::less<G4String>>MapZData;
|
||||
MapZData tableZData;
|
||||
G4DNACrossSectionDataSet* fpData_Au=nullptr;
|
||||
G4DNACrossSectionDataSet* fpData_H2O=nullptr;
|
||||
|
||||
G4double Theta(G4int Z, G4ParticleDefinition * aParticleDefinition,
|
||||
G4double k,
|
||||
@@ -149,8 +146,16 @@ private:
|
||||
|
||||
std::map <G4int, std::vector<G4double> > eEdummyVecZ;
|
||||
|
||||
typedef std::map <G4int, std::map<G4double, std::vector<G4double>>> VecMapZ;
|
||||
VecMapZ eCumZ;
|
||||
typedef std::map<G4double, std::vector<G4double> > VecMap;
|
||||
VecMap eCum_Au;
|
||||
VecMap eCum_H2O;
|
||||
|
||||
typedef std::map<G4double, std::map<G4double, G4double> > TriDimensionMap;
|
||||
TriDimensionMap fAngleData_Au;
|
||||
TriDimensionMap fAngleData_H2O;
|
||||
|
||||
std::vector<G4double> eEdummyVec_Au;
|
||||
std::vector<G4double> eEdummyVec_H2O;
|
||||
|
||||
G4DNAELSEPAElasticModel & operator=(const G4DNAELSEPAElasticModel &right);
|
||||
G4DNAELSEPAElasticModel(const G4DNAELSEPAElasticModel&);
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
#ifndef G4DNAEventScheduler_hh
|
||||
#define G4DNAEventScheduler_hh 1
|
||||
|
||||
#include <G4VScheduler.hh>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "globals.hh"
|
||||
#include "G4ITModelHandler.hh"
|
||||
#include "G4ITStepStatus.hh"
|
||||
#include "G4ITTrackHolder.hh"
|
||||
#include "G4VStateDependent.hh"
|
||||
#include "G4ITReaction.hh"
|
||||
#include "G4DNAEventSet.hh"
|
||||
#include "G4DNAUpdateSystemModel.hh"
|
||||
class G4VITStepModel;
|
||||
class G4DNAGillespieDirectMethod;
|
||||
class G4UserMeshAction;
|
||||
class IEventScheduler
|
||||
{
|
||||
public:
|
||||
IEventScheduler() = default;
|
||||
virtual ~IEventScheduler() = default;
|
||||
};
|
||||
|
||||
class G4DNAEventScheduler : public IEventScheduler
|
||||
{
|
||||
public:
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
using MapList = std::map<MolType, size_t>;
|
||||
using MapCounter = std::map<MolType, G4int>;
|
||||
G4DNAEventScheduler(const G4DNABoundingBox& boundingBox, G4int pixel);
|
||||
~G4DNAEventScheduler() override;
|
||||
G4DNAEventScheduler(const G4DNAEventScheduler&) = delete;
|
||||
G4DNAEventScheduler& operator=(const G4DNAEventScheduler& right) = delete;
|
||||
void Initialize();
|
||||
void InitializeInMesh();
|
||||
void Voxelizing();
|
||||
void ReVoxelizing(G4int);
|
||||
void SetEndTime(const G4double&);
|
||||
G4double GetStartTime() const;
|
||||
G4double GetEndTime() const;
|
||||
[[maybe_unused]] G4double GetTimeStep() const;
|
||||
[[maybe_unused]] void SetStartTime(G4double time);
|
||||
|
||||
inline void SetVerbose(G4int verbose) { fVerbose = verbose; }
|
||||
inline G4int GetVerbose() const;
|
||||
void Stepping();
|
||||
void SetChangeMesh(G4bool change) { fSetChangeMesh = change; }
|
||||
|
||||
void Reset();
|
||||
void ResetInMesh();
|
||||
void RunInMesh();
|
||||
void Run();
|
||||
|
||||
[[maybe_unused]] void AddTimeToRecord(const G4double& time);
|
||||
|
||||
void RecordTime();
|
||||
void ClearAndReChargeCounter();
|
||||
void PrintRecordTime();
|
||||
void Stop();
|
||||
[[maybe_unused]] void SetMaxNbSteps(G4int);
|
||||
std::map<G4double /*time*/, MapCounter> GetCounterMap() const;
|
||||
G4DNAMesh* GetMesh() const;
|
||||
G4int GetPixels() const;
|
||||
void SetUserMeshAction(std::unique_ptr<G4UserMeshAction>);
|
||||
static G4bool CheckingReactionRadius(G4double resolution);
|
||||
|
||||
private:
|
||||
G4int fVerbose;
|
||||
G4bool fInitialized;
|
||||
G4double fStartTime;
|
||||
G4double fEndTime;
|
||||
G4int fStepNumber;
|
||||
G4int fMaxStep;
|
||||
G4bool fRunning;
|
||||
G4double fTimeStep;
|
||||
G4double fGlobalTime;
|
||||
G4double fJumpingNumber;
|
||||
G4double fReactionNumber;
|
||||
G4int fPixel;
|
||||
G4bool fIsChangeMesh;
|
||||
G4bool fSetChangeMesh;
|
||||
G4int fStepNumberInMesh;
|
||||
G4double fInitialPixels;
|
||||
|
||||
std::unique_ptr<G4DNAMesh> fpMesh;
|
||||
std::unique_ptr<G4DNAGillespieDirectMethod> fpGillespieReaction;
|
||||
std::unique_ptr<G4DNAEventSet> fpEventSet;
|
||||
std::unique_ptr<G4DNAUpdateSystemModel> fpUpdateSystem;
|
||||
std::unique_ptr<G4UserMeshAction> fpUserMeshAction;
|
||||
// an aternative Counter
|
||||
|
||||
std::map<G4double /*time*/, MapCounter> fCounterMap;
|
||||
std::set<G4double> fTimeToRecord;
|
||||
std::set<G4double>::iterator fLastRecoredTime;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
#ifndef G4DNAGillespieDirectMethod_hh
|
||||
#define G4DNAGillespieDirectMethod_hh 1
|
||||
#include "globals.hh"
|
||||
#include "G4DNAMesh.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Molecule.hh"
|
||||
#include "G4MolecularConfiguration.hh"
|
||||
#include "G4MoleculeTable.hh"
|
||||
#include "G4ITTrackHolder.hh"
|
||||
#include "G4DNAEventSet.hh"
|
||||
|
||||
class G4DNAMolecularReactionTable;
|
||||
class G4DNAMolecularReactionData;
|
||||
class G4DNAScavengerMaterial;
|
||||
class G4DNAGillespieDirectMethod
|
||||
{
|
||||
public:
|
||||
G4DNAGillespieDirectMethod();
|
||||
~G4DNAGillespieDirectMethod();
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
using Key = unsigned int;
|
||||
using Index = G4Voxel::Index;
|
||||
using JumpingData = std::pair<MolType, Index>;
|
||||
using ReactionData = const G4DNAMolecularReactionData;
|
||||
using EventIt = G4DNAEventSet::EventSet::iterator;
|
||||
|
||||
G4double PropensityFunction(const Index& index, ReactionData* data);
|
||||
G4double PropensityFunction(const Index& index, MolType moleType);
|
||||
inline void SetVoxelMesh(G4DNAMesh& mesh) { fpMesh = &mesh; }
|
||||
void SetTimeStep(const G4double& stepTime);
|
||||
G4double Reaction(const Index& index);
|
||||
G4double DiffusiveJumping(const Index& index);
|
||||
G4double ComputeNumberInNode(const Index& index, MolType type);
|
||||
G4double VolumeOfNode(const Index& index);
|
||||
void Initialize();
|
||||
void CreateEvent(unsigned int key);
|
||||
void SetEventSet(G4DNAEventSet*);
|
||||
|
||||
private:
|
||||
G4DNAMolecularReactionTable* fMolecularReactions;
|
||||
G4DNAMesh* fpMesh;
|
||||
G4double fTimeStep;
|
||||
G4DNAEventSet* fpEventSet;
|
||||
G4double fVerbose;
|
||||
std::map<G4double /*Propensity*/, ReactionData*> fReactionDataMap;
|
||||
std::map<G4double /*Propensity*/, JumpingData> fJumpingDataMap;
|
||||
G4bool FindScavenging(const Index& index, MolType, G4double&);
|
||||
G4DNAScavengerMaterial* fpScavengerMaterial;
|
||||
};
|
||||
#endif
|
||||
@@ -73,9 +73,9 @@ public:
|
||||
|
||||
G4bool TestReactibility(const G4Track&,
|
||||
const G4Track&,
|
||||
double ,
|
||||
bool ) override;
|
||||
std::vector<std::unique_ptr<G4ITReactionChange>> FindReaction(G4ITReactionSet*, const double, const double, const bool) override;
|
||||
G4double ,
|
||||
G4bool ) override;
|
||||
std::vector<std::unique_ptr<G4ITReactionChange>> FindReaction(G4ITReactionSet*, const G4double, const G4double, const G4bool) override;
|
||||
std::unique_ptr<G4ITReactionChange> MakeReaction(const G4Track&, const G4Track&) override;
|
||||
|
||||
void SetReactionModel(G4VDNAReactionModel*);
|
||||
@@ -109,7 +109,6 @@ private:
|
||||
G4int fNx, fNy, fNz;
|
||||
G4int xiniIndex, yiniIndex, ziniIndex;
|
||||
G4int xendIndex, yendIndex, zendIndex;
|
||||
|
||||
};
|
||||
|
||||
#endif /* G4DNAIRT_HH_ */
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/*
|
||||
* G4DNAIRT_geometries.hh
|
||||
*
|
||||
* Created on: Jul 23, 2019
|
||||
* Author: W. G. Shin
|
||||
* J. Ramos-Mendez and B. Faddegon
|
||||
*/
|
||||
|
||||
#ifndef G4DNAIRT_geometries_HH_
|
||||
#define G4DNAIRT_geometries_HH_
|
||||
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
#include "G4DNAMolecularReaction.hh"
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
#include "G4MoleculeTable.hh"
|
||||
|
||||
#include "G4VDNAReactionModel.hh"
|
||||
#include "G4VITReactionProcess.hh"
|
||||
|
||||
#include "G4ITReactionTable.hh"
|
||||
#include "G4ITTrackHolder.hh"
|
||||
#include "G4ITReaction.hh"
|
||||
|
||||
#include "G4Molecule.hh"
|
||||
#include "G4VITReactionProcess.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4VDNAMolecularGeometry.hh"
|
||||
|
||||
#include "AddClone_def.hh"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class G4DNAMolecularReactionTable;
|
||||
class G4VDNAReactionModel;
|
||||
class G4ErrorFunction;
|
||||
|
||||
class G4DNAIRT_geometries : public G4VITReactionProcess
|
||||
{
|
||||
public:
|
||||
|
||||
G4DNAIRT_geometries();
|
||||
explicit G4DNAIRT_geometries(G4VDNAReactionModel*);
|
||||
~G4DNAIRT_geometries() override;
|
||||
G4DNAIRT_geometries(const G4DNAIRT_geometries& other) = delete;
|
||||
G4DNAIRT_geometries& operator=(const G4DNAIRT_geometries& other) = delete;
|
||||
|
||||
G4bool TestReactibility(const G4Track&,
|
||||
const G4Track&,
|
||||
G4double ,
|
||||
G4bool ) override;
|
||||
std::vector<std::unique_ptr<G4ITReactionChange>> FindReaction(G4ITReactionSet*, const G4double, const G4double, const G4bool) override;
|
||||
std::unique_ptr<G4ITReactionChange> MakeReaction(const G4Track&, const G4Track&) override;
|
||||
|
||||
void SetReactionModel(G4VDNAReactionModel*);
|
||||
|
||||
void Initialize() override;
|
||||
void SpaceBinning();
|
||||
void IRTSampling();
|
||||
void Sampling(G4Track*);
|
||||
|
||||
G4double GetIndependentReactionTime(const G4MolecularConfiguration*, const G4MolecularConfiguration*, G4double);
|
||||
G4int FindBin(G4int, G4double, G4double, G4double);
|
||||
G4double SamplePDC(G4double , G4double );
|
||||
|
||||
protected:
|
||||
const G4DNAMolecularReactionTable*& fMolReactionTable;
|
||||
G4VDNAReactionModel* fpReactionModel;
|
||||
|
||||
private:
|
||||
G4ITTrackHolder* fTrackHolder;
|
||||
G4ITReactionSet* fReactionSet;
|
||||
G4ErrorFunction* erfc;
|
||||
|
||||
std::map<G4int,std::map<G4int,std::map<G4int,std::vector<G4Track*>>>> spaceBinned;
|
||||
std::vector<std::pair<G4ThreeVector,G4Track*>> positionMap;
|
||||
|
||||
G4double fRCutOff;
|
||||
G4double timeMin;
|
||||
G4double timeMax;
|
||||
|
||||
G4double fXMin, fYMin, fZMin;
|
||||
G4double fXMax, fYMax, fZMax;
|
||||
G4int fNx, fNy, fNz;
|
||||
G4int xiniIndex, yiniIndex, ziniIndex;
|
||||
G4int xendIndex, yendIndex, zendIndex;
|
||||
|
||||
G4VDNAMolecularGeometry* fGeometry;
|
||||
};
|
||||
|
||||
#endif /* G4DNAIRT_geometries_HH_ */
|
||||
-2
@@ -34,8 +34,6 @@
|
||||
#include "G4KDTreeResult.hh"
|
||||
#include "G4IRTUtils.hh"
|
||||
#include "G4VReactionType.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
|
||||
+6
-7
@@ -75,16 +75,15 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
G4bool statCode;
|
||||
G4double fLowEnergyLimit=0.;
|
||||
G4double fHighEnergyLimit=0.;
|
||||
|
||||
G4double fLowEnergyLimit;
|
||||
G4double fHighEnergyLimit;
|
||||
|
||||
G4bool isInitialised;
|
||||
G4int verboseLevel;
|
||||
G4bool isInitialised=false;
|
||||
G4bool statCode=false;
|
||||
G4int verboseLevel=0;
|
||||
G4int nValenceElectron[100];
|
||||
|
||||
const std::vector<G4double>* fpMaterialDensity;
|
||||
const std::vector<G4double>* fpMaterialDensity=nullptr;
|
||||
|
||||
G4int GetNValenceElectron(G4int z);
|
||||
|
||||
|
||||
+9
-9
@@ -116,17 +116,17 @@ private:
|
||||
=(const G4DNARelativisticIonisationModel &right);
|
||||
G4DNARelativisticIonisationModel(const G4DNARelativisticIonisationModel&);
|
||||
|
||||
G4double fLowEnergyLimit;
|
||||
G4double fHighEnergyLimit;
|
||||
G4double fLowEnergyLimit=0.;
|
||||
G4double fHighEnergyLimit=0.;
|
||||
|
||||
G4bool isInitialised;
|
||||
G4bool statCode;
|
||||
G4bool fasterCode;
|
||||
G4int verboseLevel;
|
||||
G4bool isInitialised=false;
|
||||
G4bool statCode=false;
|
||||
G4bool fasterCode=false;
|
||||
G4int verboseLevel=0;
|
||||
|
||||
const std::vector<G4double>* fMaterialDensity;
|
||||
const G4ParticleDefinition* fParticleDefinition;
|
||||
G4VAtomDeexcitation* fAtomDeexcitation;
|
||||
const std::vector<G4double>* fMaterialDensity=nullptr;
|
||||
const G4ParticleDefinition* fParticleDefinition=nullptr;
|
||||
G4VAtomDeexcitation* fAtomDeexcitation=nullptr;
|
||||
|
||||
G4int RandomSelect(const G4Material* material,
|
||||
const G4ParticleDefinition*,
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
#ifndef G4DNAUPDATESYSTEMMODEL_HH
|
||||
#define G4DNAUPDATESYSTEMMODEL_HH
|
||||
#include "G4DNAMesh.hh"
|
||||
#include "G4VUpdateSystemModel.hh"
|
||||
|
||||
class G4MolecularConfiguration;
|
||||
class G4DNAMolecularReactionTable;
|
||||
class G4DNAMolecularReactionData;
|
||||
|
||||
class G4DNAUpdateSystemModel : public G4VUpdateSystemModel
|
||||
{
|
||||
public:
|
||||
using Index = G4Voxel::Index;
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
using JumpingData = std::pair<MolType, Index>;
|
||||
using ReactionData = const G4DNAMolecularReactionData;
|
||||
|
||||
G4DNAUpdateSystemModel();
|
||||
~G4DNAUpdateSystemModel() override = default;
|
||||
void UpdateSystem(const Index& index, const ReactionData& data);
|
||||
void UpdateSystem(const Index& index, const JumpingData& data);
|
||||
|
||||
void KillMolecule(const Index& index, MolType type);
|
||||
void CreateMolecule(const Index& index, MolType);
|
||||
|
||||
void JumpTo(const Index& index, MolType type);
|
||||
void JumpIn(const Index& index, MolType);
|
||||
|
||||
void SetMesh(G4DNAMesh*);
|
||||
void SetGlobalTime(const G4double& globalTime) { fGlobalTime = globalTime; }
|
||||
void SetVerbose(G4int verbose) { fVerbose = verbose; }
|
||||
|
||||
private:
|
||||
G4DNAMesh* fpMesh;
|
||||
G4int fVerbose;
|
||||
G4double fGlobalTime;
|
||||
};
|
||||
|
||||
#endif // G4DNAUPDATESYSTEMMODEL_HH
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#ifndef G4VUPDATESYSTEMMODEL_HH
|
||||
#define G4VUPDATESYSTEMMODEL_HH
|
||||
class G4VUpdateSystemModel
|
||||
{
|
||||
public:
|
||||
G4VUpdateSystemModel() = default;
|
||||
virtual ~G4VUpdateSystemModel() = default;
|
||||
// virtual UpdateSystem() = 0;
|
||||
};
|
||||
#endif // G4VUPDATESYSTEMMODEL_HH
|
||||
@@ -23,6 +23,7 @@ geant4_add_module(G4emdna-models
|
||||
G4DNAELSEPAElasticModel.hh
|
||||
G4DNAIonElasticModel.hh
|
||||
G4DNAIRT.hh
|
||||
G4DNAIRT_geometries.hh
|
||||
G4DNAIRTMoleculeEncounterStepper.hh
|
||||
G4DNAMeltonAttachmentModel.hh
|
||||
G4DNAMillerGreenExcitationModel.hh
|
||||
@@ -68,6 +69,11 @@ geant4_add_module(G4emdna-models
|
||||
G4DNAMakeReaction.hh
|
||||
G4DNAPartiallyDiffusionControlled.hh
|
||||
G4DNATotallyDiffusionControlled.hh
|
||||
G4DNAUpdateSystemModel.hh
|
||||
G4DNAGillespieDirectMethod.hh
|
||||
G4VUpdateSystemModel.hh
|
||||
G4DNAUpdateSystemModel.hh
|
||||
G4DNAEventScheduler.hh
|
||||
SOURCES
|
||||
G4DNABornAngle.cc
|
||||
G4DNABornExcitationModel1.cc
|
||||
@@ -87,6 +93,7 @@ geant4_add_module(G4emdna-models
|
||||
G4DNAEmfietzoglouIonisationModel.cc
|
||||
G4DNAIonElasticModel.cc
|
||||
G4DNAIRT.cc
|
||||
G4DNAIRT_geometries.cc
|
||||
G4DNAIRTMoleculeEncounterStepper.cc
|
||||
G4DNAMeltonAttachmentModel.cc
|
||||
G4DNAMillerGreenExcitationModel.cc
|
||||
@@ -130,7 +137,11 @@ geant4_add_module(G4emdna-models
|
||||
G4DNAIndependentReactionTimeStepper.cc
|
||||
G4DNAMakeReaction.cc
|
||||
G4DNAPartiallyDiffusionControlled.cc
|
||||
G4DNATotallyDiffusionControlled.cc)
|
||||
G4DNATotallyDiffusionControlled.cc
|
||||
G4DNAUpdateSystemModel.cc
|
||||
G4DNAGillespieDirectMethod.cc
|
||||
G4DNAUpdateSystemModel.cc
|
||||
G4DNAEventScheduler.cc)
|
||||
|
||||
geant4_module_link_libraries(G4emdna-models
|
||||
PUBLIC
|
||||
|
||||
@@ -100,7 +100,7 @@ void G4DNABornExcitationModel2::Initialise(const G4ParticleDefinition* particle,
|
||||
fParticleDefinition = particle;
|
||||
|
||||
std::ostringstream fullFileName;
|
||||
char *path = getenv("G4LEDATA");
|
||||
char *path = std::getenv("G4LEDATA");
|
||||
|
||||
if(G4String(path) == "")
|
||||
{
|
||||
@@ -130,17 +130,16 @@ void G4DNABornExcitationModel2::Initialise(const G4ParticleDefinition* particle,
|
||||
|
||||
fTableData = new G4PhysicsTable();
|
||||
fTableData->RetrievePhysicsTable(fullFileName.str().c_str(), true);
|
||||
/*
|
||||
for(size_t level = 0; level<fTableData->size(); ++level)
|
||||
{
|
||||
//(*fTableData)(level)->ScaleVector(1,scaleFactor);
|
||||
(*fTableData)(level)->SetSpline(true);
|
||||
}
|
||||
|
||||
*/
|
||||
size_t finalBin_i = 2000;
|
||||
G4double E_min = fLowEnergy;
|
||||
G4double E_max = fHighEnergy;
|
||||
fTotalXS = new G4PhysicsLogVector(E_min, E_max, finalBin_i);
|
||||
fTotalXS->SetSpline(true);
|
||||
fTotalXS = new G4PhysicsLogVector(E_min, E_max, finalBin_i, true);
|
||||
G4double energy;
|
||||
G4double finalXS;
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void G4DNABornIonisationModel2::Initialise(const G4ParticleDefinition* particle,
|
||||
fParticleDef = particle;
|
||||
|
||||
// Energy limits
|
||||
char *path = getenv("G4LEDATA");
|
||||
char *path = std::getenv("G4LEDATA");
|
||||
|
||||
// ***
|
||||
|
||||
|
||||
@@ -69,20 +69,20 @@ G4VEmModel(nam), isInitialised(false)
|
||||
Z = G4lrint((*theElementVector)[0]->GetZ());
|
||||
// Protection: only for GOLD
|
||||
if (Z==79){
|
||||
killBelowEnergy = 10. * eV; // Kills e- tracking
|
||||
lowEnergyLimit = 0 * eV; // Must stay at zero for killing
|
||||
highEnergyLimit = 1 * GeV; // Default
|
||||
SetLowEnergyLimit (lowEnergyLimit);
|
||||
SetHighEnergyLimit(highEnergyLimit);
|
||||
fkillBelowEnergy_Au = 10. * eV; // Kills e- tracking
|
||||
flowEnergyLimit = 0 * eV; // Must stay at zero for killing
|
||||
fhighEnergyLimit = 1 * GeV; // Default
|
||||
SetLowEnergyLimit (flowEnergyLimit);
|
||||
SetHighEnergyLimit(fhighEnergyLimit);
|
||||
}else{
|
||||
//continue;
|
||||
}
|
||||
}else{// Protection: H2O only is available
|
||||
if(material->GetName()=="G4_WATER"){
|
||||
lowEnergyLimit = 10. * eV;
|
||||
highEnergyLimit = 1 * MeV;
|
||||
SetLowEnergyLimit (lowEnergyLimit);
|
||||
SetHighEnergyLimit(highEnergyLimit);
|
||||
flowEnergyLimit = 10. * eV;
|
||||
fhighEnergyLimit = 1 * MeV;
|
||||
SetLowEnergyLimit (flowEnergyLimit);
|
||||
SetHighEnergyLimit(fhighEnergyLimit);
|
||||
}else{
|
||||
//continue;
|
||||
}
|
||||
@@ -93,8 +93,8 @@ G4VEmModel(nam), isInitialised(false)
|
||||
G4cout << "ELSEPA Elastic model is constructed for "
|
||||
<< material->GetName() << G4endl
|
||||
<< "Energy range: "
|
||||
<< lowEnergyLimit / eV << " eV - "
|
||||
<< highEnergyLimit / MeV << " MeV"
|
||||
<< flowEnergyLimit / eV << " eV - "
|
||||
<< fhighEnergyLimit / MeV << " MeV"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
@@ -102,23 +102,46 @@ G4VEmModel(nam), isInitialised(false)
|
||||
|
||||
fParticleChangeForGamma = 0;
|
||||
fpMolDensity = 0;
|
||||
|
||||
fpData_Au=nullptr;
|
||||
fpData_H2O=nullptr;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
G4DNAELSEPAElasticModel::~G4DNAELSEPAElasticModel()
|
||||
{
|
||||
std::map<G4int,G4DNACrossSectionDataSet*,
|
||||
std::less<G4String>>::iterator posZ;
|
||||
for (posZ = tableZData.begin(); posZ != tableZData.end(); ++posZ)
|
||||
{
|
||||
G4DNACrossSectionDataSet* table = posZ->second;
|
||||
delete table;
|
||||
}
|
||||
//std::map<G4int,G4DNACrossSectionDataSet*,
|
||||
// std::less<G4String>>::iterator posZ;
|
||||
//for (posZ = tableZData.begin(); posZ != tableZData.end(); ++posZ)
|
||||
//{
|
||||
// G4DNACrossSectionDataSet* table = posZ->second;
|
||||
// delete table;
|
||||
//}
|
||||
//for (posZ = tableZData_Au.begin(); posZ != tableZData_Au.end(); ++posZ)
|
||||
//{
|
||||
// G4DNACrossSectionDataSet* table = posZ->second;
|
||||
// delete table;
|
||||
//}
|
||||
//for (posZ = tableZData_H2O.begin(); posZ != tableZData_H2O.end(); ++posZ)
|
||||
//{
|
||||
// G4DNACrossSectionDataSet* table = posZ->second;
|
||||
// delete table;
|
||||
//}
|
||||
|
||||
eEdummyVecZ.clear();
|
||||
eCumZ.clear();
|
||||
fAngleDataZ.clear();
|
||||
if(fpData_Au) delete fpData_Au;
|
||||
if(fpData_H2O) delete fpData_H2O;
|
||||
|
||||
//eEdummyVecZ.clear();
|
||||
//eCumZ.clear();
|
||||
//fAngleDataZ.clear();
|
||||
|
||||
eEdummyVec_Au.clear();
|
||||
eEdummyVec_H2O.clear();
|
||||
eCum_Au.clear();
|
||||
eCum_H2O.clear();
|
||||
fAngleData_Au.clear();
|
||||
fAngleData_H2O.clear();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -145,6 +168,13 @@ const G4DataVector& )
|
||||
// UNIT OF TCS
|
||||
G4double scaleFactor = 1.*cm*cm;
|
||||
|
||||
//tableZData.clear();
|
||||
//tableZData_Au.clear();
|
||||
//tableZData_H2O.clear();
|
||||
|
||||
fpData_Au=nullptr;
|
||||
fpData_H2O=nullptr;
|
||||
|
||||
for(G4int i=0; i<numOfCouples; ++i)
|
||||
{
|
||||
const G4MaterialCutsCouple* couple =
|
||||
@@ -169,11 +199,17 @@ const G4DataVector& )
|
||||
oss << Z;
|
||||
fileZElectron += oss.str()+"_muffintin";
|
||||
|
||||
G4DNACrossSectionDataSet* tableZE =
|
||||
new G4DNACrossSectionDataSet
|
||||
(new G4LogLogInterpolation, eV,scaleFactor );
|
||||
tableZE->LoadData(fileZElectron);
|
||||
tableZData[Z] = tableZE;
|
||||
//G4DNACrossSectionDataSet* tableZE =
|
||||
// new G4DNACrossSectionDataSet
|
||||
// (new G4LogLogInterpolation, eV,scaleFactor );
|
||||
//tableZE->LoadData(fileZElectron);
|
||||
////tableZData_Au[0] = tableZE;
|
||||
//tableZData[Z] = tableZE;
|
||||
|
||||
fpData_Au = new G4DNACrossSectionDataSet(new G4LogLogInterpolation,
|
||||
eV,
|
||||
scaleFactor );
|
||||
fpData_Au->LoadData(fileZElectron);
|
||||
|
||||
std::ostringstream eFullFileNameZ;
|
||||
char *path = getenv("G4LEDATA");
|
||||
@@ -200,26 +236,38 @@ const G4DataVector& )
|
||||
FatalException,"Missing data file for cumulated DCS");
|
||||
return;
|
||||
}
|
||||
|
||||
//eEdummyVecZ.clear();
|
||||
//eCumZ.clear();
|
||||
//fAngleDataZ.clear();
|
||||
|
||||
eEdummyVecZ.clear();
|
||||
eCumZ.clear();
|
||||
fAngleDataZ.clear();
|
||||
eEdummyVec_Au.clear();
|
||||
eCum_Au.clear();
|
||||
fAngleData_Au.clear();
|
||||
|
||||
eEdummyVecZ[Z].push_back(0.);
|
||||
//eEdummyVecZ[Z].push_back(0.);
|
||||
eEdummyVec_Au.push_back(0.);
|
||||
do
|
||||
{
|
||||
G4double eDummy;
|
||||
G4double cumDummy;
|
||||
eDiffCrossSectionZ>>eDummy>>cumDummy;
|
||||
if (eDummy != eEdummyVecZ[Z].back())
|
||||
//if (eDummy != eEdummyVecZ[Z].back())
|
||||
if (eDummy != eEdummyVec_Au.back())
|
||||
{
|
||||
eEdummyVecZ[Z].push_back(eDummy);
|
||||
eCumZ[Z][eDummy].push_back(0.);
|
||||
|
||||
//eEdummyVecZ[Z].push_back(eDummy);
|
||||
eEdummyVec_Au.push_back(eDummy);
|
||||
//eCumZ[Z][eDummy].push_back(0.);
|
||||
eCum_Au[eDummy].push_back(0.);
|
||||
}
|
||||
eDiffCrossSectionZ>>fAngleDataZ[Z][eDummy][cumDummy];
|
||||
if (cumDummy != eCumZ[Z][eDummy].back())
|
||||
//eDiffCrossSectionZ>>fAngleDataZ[Z][eDummy][cumDummy];
|
||||
eDiffCrossSectionZ>>fAngleData_Au[eDummy][cumDummy];
|
||||
//if (cumDummy != eCumZ[Z][eDummy].back())
|
||||
if (cumDummy != eCum_Au[eDummy].back())
|
||||
{
|
||||
eCumZ[Z][eDummy].push_back(cumDummy);
|
||||
//eCumZ[Z][eDummy].push_back(cumDummy);
|
||||
eCum_Au[eDummy].push_back(cumDummy);
|
||||
}
|
||||
}while(!eDiffCrossSectionZ.eof());
|
||||
}
|
||||
@@ -244,11 +292,17 @@ const G4DataVector& )
|
||||
|
||||
G4String fileZElectron("dna/sigma_elastic_e_elsepa_muffin");
|
||||
|
||||
G4DNACrossSectionDataSet* tableZE =
|
||||
new G4DNACrossSectionDataSet(
|
||||
new G4LogLogInterpolation, eV,scaleFactor );
|
||||
tableZE->LoadData(fileZElectron);
|
||||
tableZData[0] = tableZE;
|
||||
//G4DNACrossSectionDataSet* tableZE =
|
||||
// new G4DNACrossSectionDataSet(
|
||||
// new G4LogLogInterpolation, eV,scaleFactor );
|
||||
//tableZE->LoadData(fileZElectron);
|
||||
////tableZData_H2O[0] = tableZE;
|
||||
//tableZData[0] = tableZE;
|
||||
|
||||
fpData_H2O = new G4DNACrossSectionDataSet(new G4LogLogInterpolation,
|
||||
eV,
|
||||
scaleFactor );
|
||||
fpData_H2O->LoadData(fileZElectron);
|
||||
|
||||
std::ostringstream eFullFileNameZ;
|
||||
|
||||
@@ -274,25 +328,37 @@ const G4DataVector& )
|
||||
FatalException,
|
||||
"Missing data file for cumulated DCS");
|
||||
|
||||
eEdummyVecZ.clear();
|
||||
eCumZ.clear();
|
||||
fAngleDataZ.clear();
|
||||
//eEdummyVecZ.clear();
|
||||
//eCumZ.clear();
|
||||
//fAngleDataZ.clear();
|
||||
|
||||
eEdummyVecZ[0].push_back(0.);
|
||||
eEdummyVec_H2O.clear();
|
||||
eCum_H2O.clear();
|
||||
fAngleData_H2O.clear();
|
||||
|
||||
//eEdummyVecZ[0].push_back(0.);
|
||||
eEdummyVec_H2O.push_back(0.);
|
||||
|
||||
do
|
||||
{
|
||||
G4double eDummy;
|
||||
G4double cumDummy;
|
||||
eDiffCrossSectionZ>>eDummy>>cumDummy;
|
||||
if (eDummy != eEdummyVecZ[0].back())
|
||||
//if (eDummy != eEdummyVecZ[0].back())
|
||||
if (eDummy != eEdummyVec_H2O.back())
|
||||
{
|
||||
eEdummyVecZ[0].push_back(eDummy);
|
||||
eCumZ[0][eDummy].push_back(0.);
|
||||
//eEdummyVecZ[0].push_back(eDummy);
|
||||
eEdummyVec_H2O.push_back(eDummy);
|
||||
//eCumZ[0][eDummy].push_back(0.);
|
||||
eCum_H2O[eDummy].push_back(0.);
|
||||
}
|
||||
//eDiffCrossSectionZ>>fAngleDataZ[0][eDummy][cumDummy];
|
||||
eDiffCrossSectionZ>>fAngleData_H2O[eDummy][cumDummy];
|
||||
//if (cumDummy != eCumZ[0][eDummy].back()){
|
||||
if (cumDummy != eCum_H2O[eDummy].back()){
|
||||
//eCumZ[0][eDummy].push_back(cumDummy);
|
||||
eCum_H2O[eDummy].push_back(cumDummy);
|
||||
}
|
||||
eDiffCrossSectionZ>>fAngleDataZ[0][eDummy][cumDummy];
|
||||
if (cumDummy != eCumZ[0][eDummy].back())
|
||||
eCumZ[0][eDummy].push_back(cumDummy);
|
||||
}while(!eDiffCrossSectionZ.eof());
|
||||
}
|
||||
}
|
||||
@@ -310,7 +376,10 @@ const G4DataVector& )
|
||||
}
|
||||
} // Loop on couples
|
||||
|
||||
|
||||
fParticleChangeForGamma = GetParticleChangeForGamma();
|
||||
fpMolDensity = 0;
|
||||
|
||||
isInitialised = true;
|
||||
}
|
||||
|
||||
@@ -346,29 +415,34 @@ G4double G4DNAELSEPAElasticModel::CrossSectionPerVolume
|
||||
atomicNDensity = material->GetAtomicNumDensityVector()[0];
|
||||
if(atomicNDensity!= 0.0)
|
||||
{
|
||||
if (ekin < highEnergyLimit)
|
||||
if (ekin < fhighEnergyLimit)
|
||||
{
|
||||
if (ekin < killBelowEnergy) return DBL_MAX;
|
||||
if (ekin < fkillBelowEnergy_Au) return DBL_MAX;
|
||||
|
||||
std::map< G4int,G4DNACrossSectionDataSet*,
|
||||
std::less<G4String> >::iterator pos;
|
||||
pos = tableZData.find(Z);
|
||||
|
||||
if (pos != tableZData.end())
|
||||
{
|
||||
G4DNACrossSectionDataSet* table = pos->second;
|
||||
if (table != 0)
|
||||
{
|
||||
// XS takes its 10 eV value below 10 eV for GOLD
|
||||
if (ekin < 10*eV) sigma = table->FindValue(10*eV);
|
||||
else sigma = table->FindValue(ekin);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("G4DNAELSEPAElasticModel::ComputeCrossSectionPerVolume",
|
||||
"em0006",FatalException,"Model not applicable to particle type.");
|
||||
}
|
||||
//std::map< G4int,G4DNACrossSectionDataSet*,
|
||||
// std::less<G4String> >::iterator pos;
|
||||
////pos = tableZData_Au.find(0);
|
||||
//pos = tableZData.find(Z);
|
||||
//
|
||||
////if (pos != tableZData_Au.end())
|
||||
//if (pos != tableZData.end())
|
||||
//{
|
||||
// G4DNACrossSectionDataSet* table = pos->second;
|
||||
// if (table != 0)
|
||||
// {
|
||||
// // XS takes its 10 eV value below 10 eV for GOLD
|
||||
// if (ekin < 10*eV) sigma = table->FindValue(10*eV);
|
||||
// else sigma = table->FindValue(ekin);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// G4Exception("G4DNAELSEPAElasticModel::ComputeCrossSectionPerVolume",
|
||||
// "em0006",FatalException,"Model not applicable to particle type.");
|
||||
//}
|
||||
|
||||
if (ekin < 10*eV) sigma = fpData_Au->FindValue(10*eV);
|
||||
else sigma = fpData_Au->FindValue(ekin);
|
||||
}
|
||||
}
|
||||
if (verboseLevel > 2)
|
||||
@@ -385,7 +459,7 @@ G4double G4DNAELSEPAElasticModel::CrossSectionPerVolume
|
||||
G4cout << "=== G4DNAELSEPAElasticModel - XS INFO END" << G4endl;
|
||||
}
|
||||
}else{
|
||||
fpMolDensity =
|
||||
fpMolDensity =
|
||||
G4DNAMolecularMaterial::Instance()->
|
||||
GetNumMolPerVolTableFor(G4Material::GetMaterial("G4_WATER"));
|
||||
atomicNDensity = (*fpMolDensity)[material->GetIndex()];
|
||||
@@ -393,19 +467,23 @@ G4double G4DNAELSEPAElasticModel::CrossSectionPerVolume
|
||||
{
|
||||
if (ekin < HighEnergyLimit() && ekin >= LowEnergyLimit())
|
||||
{
|
||||
std::map< G4int,G4DNACrossSectionDataSet*,
|
||||
std::less<G4String> >::iterator pos;
|
||||
pos = tableZData.find(0); // the data is stored as Z=0
|
||||
//SI : XS must not be zero
|
||||
// otherwise sampling of secondaries method ignored
|
||||
if (pos != tableZData.end())
|
||||
{
|
||||
G4DNACrossSectionDataSet* table = pos->second;
|
||||
if (table != 0)
|
||||
{
|
||||
sigma = table->FindValue(ekin);
|
||||
}
|
||||
}
|
||||
//std::map< G4int,G4DNACrossSectionDataSet*,
|
||||
//std::less<G4String> >::iterator pos;
|
||||
////pos = tableZData_H2O.find(0); // the data is stored as Z=0
|
||||
//pos = tableZData.find(0); // the data is stored as Z=0
|
||||
////SI : XS must not be zero
|
||||
//// otherwise sampling of secondaries method ignored
|
||||
////if (pos != tableZData_H2O.end())
|
||||
//if (pos != tableZData.end())
|
||||
//{
|
||||
// G4DNACrossSectionDataSet* table = pos->second;
|
||||
// if (table != 0)
|
||||
// {
|
||||
// sigma = table->FindValue(ekin);
|
||||
// }
|
||||
//}
|
||||
|
||||
sigma = fpData_H2O->FindValue(ekin);
|
||||
}
|
||||
}
|
||||
if (verboseLevel > 2)
|
||||
@@ -449,7 +527,7 @@ void G4DNAELSEPAElasticModel::SampleSecondaries(
|
||||
if (nelm==1){// Protection: only for single element
|
||||
G4int Z = G4lrint((*theElementVector)[0]->GetZ());
|
||||
if (Z!=79) return;
|
||||
if (electronEnergy0 < killBelowEnergy)
|
||||
if (electronEnergy0 < fkillBelowEnergy_Au)
|
||||
{
|
||||
fParticleChangeForGamma->SetProposedKineticEnergy(0.);
|
||||
fParticleChangeForGamma->ProposeMomentumDirection(G4ThreeVector(0,0,0));
|
||||
@@ -458,7 +536,7 @@ void G4DNAELSEPAElasticModel::SampleSecondaries(
|
||||
return;
|
||||
}
|
||||
|
||||
if(electronEnergy0>= killBelowEnergy && electronEnergy0 < highEnergyLimit)
|
||||
if(electronEnergy0>= fkillBelowEnergy_Au && electronEnergy0 < fhighEnergyLimit)
|
||||
{
|
||||
G4double cosTheta = 0;
|
||||
if (electronEnergy0>=10*eV){
|
||||
@@ -528,20 +606,45 @@ G4double G4DNAELSEPAElasticModel::Theta(G4int Z,
|
||||
|
||||
if (particleDefinition == G4Electron::ElectronDefinition())
|
||||
{
|
||||
std::vector<G4double>::iterator e2
|
||||
= std::upper_bound(eEdummyVecZ[Z].begin(),
|
||||
eEdummyVecZ[Z].end(), k);
|
||||
//std::vector<G4double>::iterator e2
|
||||
// = std::upper_bound(eEdummyVecZ[Z].begin(),
|
||||
// eEdummyVecZ[Z].end(), k);
|
||||
std::vector<G4double>::iterator e2;
|
||||
if(Z==0){
|
||||
e2 = std::upper_bound(eEdummyVec_H2O.begin(),
|
||||
eEdummyVec_H2O.end(), k);
|
||||
}else if (Z==79){
|
||||
e2 = std::upper_bound(eEdummyVec_Au.begin(),
|
||||
eEdummyVec_Au.end(), k);
|
||||
}
|
||||
|
||||
std::vector<G4double>::iterator e1 = e2 - 1;
|
||||
|
||||
std::vector<G4double>::iterator cum12
|
||||
= std::upper_bound(eCumZ[Z][(*e1)].begin(),
|
||||
eCumZ[Z][(*e1)].end(),integrDiff);
|
||||
//std::vector<G4double>::iterator cum12
|
||||
// = std::upper_bound(eCumZ[Z][(*e1)].begin(),
|
||||
// eCumZ[Z][(*e1)].end(),integrDiff);
|
||||
std::vector<G4double>::iterator cum12;
|
||||
if(Z==0){
|
||||
cum12 = std::upper_bound(eCum_H2O[(*e1)].begin(),
|
||||
eCum_H2O[(*e1)].end(),integrDiff);
|
||||
}else if (Z==79){
|
||||
cum12 = std::upper_bound(eCum_Au[(*e1)].begin(),
|
||||
eCum_Au[(*e1)].end(),integrDiff);
|
||||
}
|
||||
|
||||
std::vector<G4double>::iterator cum11 = cum12 - 1;
|
||||
|
||||
std::vector<G4double>::iterator cum22
|
||||
= std::upper_bound(eCumZ[Z][(*e2)].begin(),
|
||||
eCumZ[Z][(*e2)].end(),integrDiff);
|
||||
//std::vector<G4double>::iterator cum22
|
||||
// = std::upper_bound(eCumZ[Z][(*e2)].begin(),
|
||||
// eCumZ[Z][(*e2)].end(),integrDiff);
|
||||
std::vector<G4double>::iterator cum22;
|
||||
if(Z==0){
|
||||
cum22 = std::upper_bound(eCum_H2O[(*e2)].begin(),
|
||||
eCum_H2O[(*e2)].end(),integrDiff);
|
||||
}else if(Z==79){
|
||||
cum22 = std::upper_bound(eCum_Au[(*e2)].begin(),
|
||||
eCum_Au[(*e2)].end(),integrDiff);
|
||||
}
|
||||
|
||||
std::vector<G4double>::iterator cum21 = cum22 - 1;
|
||||
|
||||
@@ -553,10 +656,21 @@ G4double G4DNAELSEPAElasticModel::Theta(G4int Z,
|
||||
valuecum22 = *cum22;
|
||||
|
||||
|
||||
a11 = fAngleDataZ[Z][valueE1][valuecum11];
|
||||
a12 = fAngleDataZ[Z][valueE1][valuecum12];
|
||||
a21 = fAngleDataZ[Z][valueE2][valuecum21];
|
||||
a22 = fAngleDataZ[Z][valueE2][valuecum22];
|
||||
//a11 = fAngleDataZ[Z][valueE1][valuecum11];
|
||||
//a12 = fAngleDataZ[Z][valueE1][valuecum12];
|
||||
//a21 = fAngleDataZ[Z][valueE2][valuecum21];
|
||||
//a22 = fAngleDataZ[Z][valueE2][valuecum22];
|
||||
if(Z==0){
|
||||
a11 = fAngleData_H2O[valueE1][valuecum11];
|
||||
a12 = fAngleData_H2O[valueE1][valuecum12];
|
||||
a21 = fAngleData_H2O[valueE2][valuecum21];
|
||||
a22 = fAngleData_H2O[valueE2][valuecum22];
|
||||
}else if (Z==79){
|
||||
a11 = fAngleData_Au[valueE1][valuecum11];
|
||||
a12 = fAngleData_Au[valueE1][valuecum12];
|
||||
a21 = fAngleData_Au[valueE2][valuecum21];
|
||||
a22 = fAngleData_Au[valueE2][valuecum22];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -694,7 +808,7 @@ G4double G4DNAELSEPAElasticModel::RandomizeCosTheta(G4int Z, G4double k)
|
||||
|
||||
void G4DNAELSEPAElasticModel::SetKillBelowThreshold(G4double threshold)
|
||||
{
|
||||
killBelowEnergy = threshold;
|
||||
fkillBelowEnergy_Au = threshold;
|
||||
|
||||
if (threshold < 10 * eV)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,686 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
#include <memory>
|
||||
#include "G4DNAEventScheduler.hh"
|
||||
#include "G4DNAGillespieDirectMethod.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4DNAUpdateSystemModel.hh"
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
#include "G4Timer.hh"
|
||||
#include "G4Scheduler.hh"
|
||||
#include "G4UserMeshAction.hh"
|
||||
#include "G4MoleculeCounter.hh"
|
||||
#include "G4DNAScavengerMaterial.hh"
|
||||
|
||||
G4DNAEventScheduler::G4DNAEventScheduler(const G4DNABoundingBox& boundingBox,
|
||||
G4int pixel)
|
||||
: IEventScheduler()
|
||||
, fVerbose(0)
|
||||
, fInitialized(false)
|
||||
, fStartTime(1 * ps)
|
||||
, fEndTime(10000 * s)
|
||||
, fStepNumber(0)
|
||||
, fMaxStep(INT_MAX)
|
||||
, fRunning(true)
|
||||
, fTimeStep(DBL_MAX)
|
||||
, fGlobalTime(fStartTime)
|
||||
, fJumpingNumber(0)
|
||||
, fReactionNumber(0)
|
||||
, fPixel(pixel)
|
||||
, fIsChangeMesh(false)
|
||||
, fSetChangeMesh(true)
|
||||
, fStepNumberInMesh(0)
|
||||
, fInitialPixels(fPixel)
|
||||
, fpMesh(new G4DNAMesh(boundingBox, fPixel))
|
||||
, fpGillespieReaction(new G4DNAGillespieDirectMethod())
|
||||
, fpEventSet(new G4DNAEventSet())
|
||||
, fpUpdateSystem(new G4DNAUpdateSystemModel())
|
||||
, fpUserMeshAction(nullptr)
|
||||
{
|
||||
if(!CheckingReactionRadius(fpMesh->GetResolution()))
|
||||
{
|
||||
G4String WarMessage = "resolution is not good : " +
|
||||
std::to_string(fpMesh->GetResolution() / nm);
|
||||
G4Exception("G4DNAEventScheduler::InitializeInMesh()", "WrongResolution",
|
||||
JustWarning, WarMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::ClearAndReChargeCounter()
|
||||
{
|
||||
fCounterMap.clear();
|
||||
if(fTimeToRecord.empty())
|
||||
{
|
||||
G4cout << "fTimeToRecord is empty " << G4endl;
|
||||
}
|
||||
fLastRecoredTime = fTimeToRecord.begin();
|
||||
|
||||
if(G4VMoleculeCounter::Instance()->InUse()) // copy from MoleculeCounter
|
||||
{
|
||||
G4MoleculeCounter::RecordedMolecules species;
|
||||
species = G4MoleculeCounter::Instance()->GetRecordedMolecules();
|
||||
if(species.get() == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(species->empty())
|
||||
{
|
||||
G4MoleculeCounter::Instance()->ResetCounter();
|
||||
return;
|
||||
}
|
||||
for(auto time_mol : fTimeToRecord)
|
||||
{
|
||||
if(time_mol > fStartTime)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for(auto molecule : *species)
|
||||
{
|
||||
G4int n_mol = G4MoleculeCounter::Instance()->GetNMoleculesAtTime(
|
||||
molecule, time_mol);
|
||||
|
||||
if(n_mol < 0)
|
||||
{
|
||||
G4cerr << "G4DNAEventScheduler::ClearAndReChargeCounter() ::N "
|
||||
"molecules not valid < 0 "
|
||||
<< G4endl;
|
||||
G4Exception("", "N<0", FatalException, "");
|
||||
}
|
||||
fCounterMap[time_mol][molecule] = n_mol;
|
||||
}
|
||||
|
||||
fLastRecoredTime++;
|
||||
}
|
||||
G4MoleculeCounter::Instance()->ResetCounter(); // reset
|
||||
G4MoleculeCounter::Instance()->Use(false); // no more used
|
||||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]] void G4DNAEventScheduler::AddTimeToRecord(const G4double& time)
|
||||
{
|
||||
if(fTimeToRecord.find(time) == fTimeToRecord.end())
|
||||
{
|
||||
fTimeToRecord.insert(time);
|
||||
}
|
||||
}
|
||||
|
||||
G4DNAEventScheduler::~G4DNAEventScheduler() = default;
|
||||
|
||||
void G4DNAEventScheduler::Voxelizing()
|
||||
{
|
||||
auto pMainList = G4ITTrackHolder::Instance()->GetMainList();
|
||||
std::map<G4DNAMesh::Key, MapList> TrackKeyMap;
|
||||
for(auto track : *pMainList)
|
||||
{
|
||||
auto molType = GetMolecule(track)->GetMolecularConfiguration();
|
||||
|
||||
auto pScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
|
||||
G4Scheduler::Instance()->GetScavengerMaterial());
|
||||
if(pScavengerMaterial != nullptr &&
|
||||
pScavengerMaterial->find(molType)) // avoid voxelize the scavenger
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto key = fpMesh->GetKey(track->GetPosition());
|
||||
if(TrackKeyMap.find(key) != TrackKeyMap.end())
|
||||
{
|
||||
std::map<MolType, size_t>& TrackTypeMap = TrackKeyMap[key];
|
||||
if(TrackTypeMap.find(molType) != TrackTypeMap.end())
|
||||
{
|
||||
TrackTypeMap[molType]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
TrackTypeMap[molType] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TrackKeyMap[key][molType] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(auto& it : TrackKeyMap)
|
||||
{
|
||||
fpMesh->SetVoxelMapList(it.first, std::move(it.second));
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::ReVoxelizing(G4int pixel)
|
||||
{
|
||||
fPixel = pixel;
|
||||
auto newMesh = new G4DNAMesh(fpMesh->GetBoundingBox(), fPixel);
|
||||
|
||||
auto begin = fpMesh->begin();
|
||||
auto end = fpMesh->end();
|
||||
std::map<G4DNAMesh::Key, MapList> TrackKeyMap;
|
||||
for(; begin != end; begin++)
|
||||
{
|
||||
auto index = fpMesh->GetIndex(begin->first);
|
||||
auto newKey = newMesh->GetKey(fpMesh->GetIndex(index, fPixel));
|
||||
auto node = begin->second;
|
||||
// if (node == nullptr) continue;
|
||||
if(TrackKeyMap.find(newKey) == TrackKeyMap.end())
|
||||
{
|
||||
TrackKeyMap[newKey] = node->GetMapList();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(const auto& it : node->GetMapList())
|
||||
{
|
||||
TrackKeyMap[newKey][it.first] += it.second;
|
||||
}
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << "key : " << begin->first << " index : " << index
|
||||
<< " new index : " << fpMesh->GetIndex(index, fPixel)
|
||||
<< " new key : " << newKey
|
||||
<< " number: " << node->GetMapList().begin()->second << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
fpMesh.reset(newMesh);
|
||||
|
||||
for(auto& it : TrackKeyMap)
|
||||
{
|
||||
fpMesh->SetVoxelMapList(it.first, std::move(it.second));
|
||||
}
|
||||
}
|
||||
void G4DNAEventScheduler::Reset()
|
||||
{
|
||||
// find another solultion
|
||||
fGlobalTime = fEndTime;
|
||||
|
||||
//
|
||||
// RecordTime();//Last register for counter
|
||||
|
||||
if(fVerbose > 0)
|
||||
{
|
||||
G4cout << "End Processing and reset Gird, ScavengerTable, EventSet for new "
|
||||
"simulation!!!!"
|
||||
<< G4endl;
|
||||
}
|
||||
fInitialized = false;
|
||||
fTimeStep = 0;
|
||||
fStepNumber = 0;
|
||||
fGlobalTime = fStartTime;
|
||||
fRunning = true;
|
||||
fReactionNumber = 0;
|
||||
fJumpingNumber = 0;
|
||||
|
||||
fpEventSet->RemoveEventSet();
|
||||
fpMesh->Reset();
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::Initialize()
|
||||
{
|
||||
if(!fInitialized)
|
||||
{
|
||||
fPixel = fInitialPixels;
|
||||
fpMesh = std::make_unique<G4DNAMesh>(fpMesh->GetBoundingBox(), fPixel);
|
||||
|
||||
// Scavenger();
|
||||
|
||||
auto pScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
|
||||
G4Scheduler::Instance()->GetScavengerMaterial());
|
||||
if(pScavengerMaterial == nullptr)
|
||||
{
|
||||
G4cout << "pScavengerMaterial == nullptr" << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
pScavengerMaterial->PrintInfo();
|
||||
}
|
||||
}
|
||||
|
||||
Voxelizing();
|
||||
fpGillespieReaction->SetVoxelMesh(*fpMesh);
|
||||
fpGillespieReaction->SetEventSet(fpEventSet.get());
|
||||
fpGillespieReaction->SetTimeStep(
|
||||
0); // reset fTimeStep = 0 in fpGillespieReaction
|
||||
fpGillespieReaction->Initialize();
|
||||
fpUpdateSystem->SetMesh(fpMesh.get());
|
||||
ClearAndReChargeCounter();
|
||||
fInitialized = true;
|
||||
}
|
||||
|
||||
if(fVerbose > 0)
|
||||
{
|
||||
fpUpdateSystem->SetVerbose(1);
|
||||
}
|
||||
|
||||
if(fVerbose > 2)
|
||||
{
|
||||
fpMesh->PrintMesh();
|
||||
}
|
||||
}
|
||||
void G4DNAEventScheduler::InitializeInMesh()
|
||||
{
|
||||
if(fPixel <= 1)
|
||||
{
|
||||
fRunning = false;
|
||||
return;
|
||||
}
|
||||
// TEST /3
|
||||
ReVoxelizing(fPixel / 2); //
|
||||
// ReVoxelizing(fPixel/3);//
|
||||
|
||||
fpGillespieReaction->SetVoxelMesh(*fpMesh);
|
||||
fpUpdateSystem->SetMesh(fpMesh.get());
|
||||
fpGillespieReaction->Initialize();
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::ResetInMesh()
|
||||
{
|
||||
if(fVerbose > 0)
|
||||
{
|
||||
G4cout
|
||||
<< "*** End Processing In Mesh and reset Mesh, EventSet for new Mesh!!!!"
|
||||
<< G4endl;
|
||||
}
|
||||
fpEventSet->RemoveEventSet();
|
||||
fInitialized = false;
|
||||
fIsChangeMesh = false;
|
||||
fReactionNumber = 0;
|
||||
fJumpingNumber = 0;
|
||||
fStepNumberInMesh = 0;
|
||||
}
|
||||
|
||||
G4double G4DNAEventScheduler::GetStartTime() const { return fStartTime; }
|
||||
|
||||
G4double G4DNAEventScheduler::GetEndTime() const { return fEndTime; }
|
||||
|
||||
[[maybe_unused]] G4double G4DNAEventScheduler::GetTimeStep() const { return fTimeStep; }
|
||||
|
||||
G4int G4DNAEventScheduler::GetVerbose() const { return fVerbose; }
|
||||
|
||||
[[maybe_unused]] void G4DNAEventScheduler::SetMaxNbSteps(G4int max) { fMaxStep = max; }
|
||||
|
||||
[[maybe_unused]] void G4DNAEventScheduler::SetStartTime(G4double time)
|
||||
{
|
||||
fStartTime = time;
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::Stop() { fRunning = false; }
|
||||
void G4DNAEventScheduler::Run()
|
||||
{
|
||||
G4Timer localtimer;
|
||||
if(fVerbose > 0)
|
||||
{
|
||||
localtimer.Start();
|
||||
G4cout << "***G4DNAEventScheduler::Run*** for Pixel : " << fPixel << G4endl;
|
||||
}
|
||||
while(fEndTime > fGlobalTime && fRunning)
|
||||
{
|
||||
RunInMesh();
|
||||
}
|
||||
if(fVerbose > 0)
|
||||
{
|
||||
if(!fRunning)
|
||||
{
|
||||
G4cout << " StepNumber(" << fStepNumber << ") = MaxStep(" << fMaxStep
|
||||
<< ")" << G4endl;
|
||||
}
|
||||
else if(fEndTime <= fGlobalTime)
|
||||
{
|
||||
G4cout << " GlobalTime(" << fGlobalTime << ") > EndTime(" << fEndTime
|
||||
<< ")"
|
||||
<< " StepNumber : " << fStepNumber << G4endl;
|
||||
}
|
||||
localtimer.Stop();
|
||||
G4cout << "***G4DNAEventScheduler::Ending::"
|
||||
<< G4BestUnit(fGlobalTime, "Time")
|
||||
<< " Events left : " << fpEventSet->size() << G4endl;
|
||||
if(fVerbose > 1) {
|
||||
fpMesh->PrintMesh();
|
||||
}
|
||||
G4cout << " Computing Time : " << localtimer << G4endl;
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::RunInMesh()
|
||||
{
|
||||
if(!fInitialized)
|
||||
{
|
||||
InitializeInMesh();
|
||||
}
|
||||
G4Timer localtimerInMesh;
|
||||
// if (fVerbose > 0)
|
||||
{
|
||||
localtimerInMesh.Start();
|
||||
G4double C = 20;
|
||||
G4double D = G4MoleculeTable::Instance()
|
||||
->GetConfiguration("H2O2")
|
||||
->GetDiffusionCoefficient();
|
||||
G4double transferTime = std::pow(fpMesh->GetResolution(), 2) * C / (6 * D);
|
||||
G4cout << "***G4DNAEventScheduler::RunInMesh*** for Pixel : " << fPixel
|
||||
<< " transferTime : " << G4BestUnit(transferTime, "Time") << G4endl;
|
||||
G4cout << " resolution : " << G4BestUnit(fpMesh->GetResolution(), "Length")
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
if(fVerbose > 2)
|
||||
{
|
||||
fpMesh->PrintMesh();
|
||||
}
|
||||
|
||||
if(fpUserMeshAction != nullptr)
|
||||
{
|
||||
fpUserMeshAction->BeginOfMesh(fpMesh.get(), fGlobalTime);
|
||||
}
|
||||
|
||||
// if diffusive jumping is avaiable, EventSet is never empty
|
||||
while(!fpEventSet->Empty() && !fIsChangeMesh && fEndTime > fGlobalTime)
|
||||
{
|
||||
Stepping();
|
||||
fGlobalTime = fTimeStep + fStartTime;
|
||||
|
||||
if(fpUserMeshAction != nullptr)
|
||||
{
|
||||
fpUserMeshAction->InMesh(fpMesh.get(), fGlobalTime);
|
||||
}
|
||||
|
||||
if(fVerbose > 2)
|
||||
{
|
||||
G4cout << "fGlobalTime : " << G4BestUnit(fGlobalTime, "Time")
|
||||
<< " fTimeStep : " << G4BestUnit(fTimeStep, "Time") << G4endl;
|
||||
}
|
||||
|
||||
G4double C = 20;
|
||||
G4double D = G4MoleculeTable::Instance()
|
||||
->GetConfiguration("H2O2")
|
||||
->GetDiffusionCoefficient();
|
||||
if(D == 0)
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "D == 0";
|
||||
G4Exception("G4DNAEventScheduler::RunInMesh", "G4DNAEventScheduler001",
|
||||
FatalErrorInArgument, exceptionDescription);
|
||||
}
|
||||
G4double transferTime = std::pow(fpMesh->GetResolution(), 2) * C / (6 * D);
|
||||
|
||||
// if(fStepNumberInMesh > 40000 && fPixel != 1)
|
||||
if(transferTime < fTimeStep &&
|
||||
fPixel != 1) // dont change Mesj if fPixel == 1
|
||||
{
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << " Pixels : " << fPixel << " resolution : "
|
||||
<< G4BestUnit(fpMesh->GetResolution(), "Length")
|
||||
<< " fStepNumberInMesh : " << fStepNumberInMesh
|
||||
<< " at fGlobalTime : " << G4BestUnit(fGlobalTime, "Time")
|
||||
<< " at fTimeStep : " << G4BestUnit(fTimeStep, "Time")
|
||||
<< " fReactionNumber : " << fReactionNumber
|
||||
<< " transferTime : " << G4BestUnit(transferTime, "Time")
|
||||
<< G4endl;
|
||||
}
|
||||
if(fSetChangeMesh)
|
||||
{
|
||||
fIsChangeMesh = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
localtimerInMesh.Stop();
|
||||
G4cout << "***G4DNAEventScheduler::Ending::"
|
||||
<< G4BestUnit(fGlobalTime, "Time")
|
||||
<< " Event left : " << fpEventSet->size() << G4endl;
|
||||
G4cout << " Computing Time : " << localtimerInMesh << " Due to : ";
|
||||
if(fpEventSet->Empty())
|
||||
{
|
||||
G4cout << "EventSet is Empty" << G4endl;
|
||||
}
|
||||
else if(fIsChangeMesh)
|
||||
{
|
||||
G4cout << "Changing Mesh from : " << fPixel
|
||||
<< " pixels to : " << fPixel / 2 << " pixels" << G4endl;
|
||||
G4cout << "Info : ReactionNumber : " << fReactionNumber
|
||||
<< " JumpingNumber : " << fJumpingNumber << G4endl;
|
||||
}
|
||||
else if(fEndTime > fGlobalTime)
|
||||
{
|
||||
G4cout << " GlobalTime(" << fGlobalTime << ") > EndTime(" << fEndTime
|
||||
<< ")"
|
||||
<< " StepNumber : " << fStepNumber << G4endl;
|
||||
}
|
||||
if(fVerbose > 2)
|
||||
{
|
||||
fpMesh->PrintMesh();
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
if(fpUserMeshAction != nullptr)
|
||||
{
|
||||
fpUserMeshAction->EndOfMesh(fpMesh.get(), fGlobalTime);
|
||||
}
|
||||
ResetInMesh();
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::Stepping() // this event loop
|
||||
{
|
||||
fStepNumber < fMaxStep ? fStepNumber++ : fRunning = false;
|
||||
|
||||
if(fpEventSet->size() > fpMesh->size())
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "fpEventSet->size() > fpMesh->size()";
|
||||
G4Exception("G4DNAEventScheduler::Stepping", "G4DNAEventScheduler002",
|
||||
FatalErrorInArgument, exceptionDescription);
|
||||
};
|
||||
|
||||
auto selected = fpEventSet->begin();
|
||||
const auto& key = (*selected)->GetKey();
|
||||
auto index = fpMesh->GetIndex(key);
|
||||
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << "G4DNAEventScheduler::Stepping()*********************************"
|
||||
"*******"
|
||||
<< G4endl;
|
||||
(*selected)->PrintEvent();
|
||||
}
|
||||
|
||||
// get selected time step
|
||||
fTimeStep = (*selected)->GetTime();
|
||||
|
||||
// selected data
|
||||
auto pJumping = (*selected)->GetJumpingData();
|
||||
auto pReaction = (*selected)->GetReactionData();
|
||||
|
||||
fpUpdateSystem->SetGlobalTime(fTimeStep +
|
||||
fStartTime); // this is just for printing
|
||||
|
||||
if(pJumping == nullptr && pReaction == nullptr)
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "pJumping == nullptr && pReaction == nullptr";
|
||||
G4Exception("G4DNAEventScheduler::Stepping", "G4DNAEventScheduler003",
|
||||
FatalErrorInArgument, exceptionDescription);
|
||||
}
|
||||
|
||||
fpGillespieReaction->SetTimeStep(fTimeStep);
|
||||
|
||||
if(pJumping == nullptr)
|
||||
{
|
||||
fpUpdateSystem->UpdateSystem(index, *pReaction);
|
||||
|
||||
fpEventSet->RemoveEvent(selected);
|
||||
// create new event
|
||||
fpGillespieReaction->CreateEvent(key);
|
||||
fReactionNumber++;
|
||||
|
||||
// recordTime in reaction
|
||||
RecordTime();
|
||||
}
|
||||
else if(pReaction == nullptr)
|
||||
{
|
||||
// dont change this
|
||||
fpUpdateSystem->UpdateSystem(index, *pJumping);
|
||||
auto jumpingKey = fpMesh->GetKey(pJumping->second);
|
||||
fpEventSet->RemoveEvent(selected);
|
||||
|
||||
// create new event
|
||||
// should create Jumping before key
|
||||
fpGillespieReaction->CreateEvent(jumpingKey);
|
||||
fpGillespieReaction->CreateEvent(key);
|
||||
|
||||
fJumpingNumber++;
|
||||
}
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << "G4DNAEventScheduler::Stepping::end "
|
||||
"Print***********************************"
|
||||
<< G4endl;
|
||||
G4cout << G4endl;
|
||||
}
|
||||
fStepNumberInMesh++;
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::SetEndTime(const G4double& endTime)
|
||||
{
|
||||
fEndTime = endTime;
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::RecordTime()
|
||||
{
|
||||
auto recordTime = *fLastRecoredTime;
|
||||
if(fGlobalTime >= recordTime && fCounterMap[recordTime].empty())
|
||||
{
|
||||
auto begin = fpMesh->begin();
|
||||
auto end = fpMesh->end();
|
||||
for(; begin != end; begin++)
|
||||
{
|
||||
auto node = begin->second;
|
||||
if(node == nullptr) {
|
||||
continue;
|
||||
}
|
||||
for(const auto& it : node->GetMapList())
|
||||
{
|
||||
fCounterMap[recordTime][it.first] += it.second;
|
||||
}
|
||||
}
|
||||
fLastRecoredTime++;
|
||||
|
||||
#ifdef DEBUG
|
||||
PrintRecordTime();
|
||||
G4MoleculeTable* pMoleculeTable = G4MoleculeTable::Instance();
|
||||
auto iter = pMoleculeTable->GetConfigurationIterator();
|
||||
iter.reset();
|
||||
while(iter())
|
||||
{
|
||||
auto conf = iter.value();
|
||||
|
||||
G4cout << "GlobalTime : " << G4BestUnit(fGlobalTime, "Time")
|
||||
<< " recordTime : " << G4BestUnit(recordTime, "Time") << " "
|
||||
<< conf->GetName()
|
||||
<< " number : " << fCounterMap[recordTime][conf]
|
||||
<< " MoleculeCounter : "
|
||||
<< G4MoleculeCounter::Instance()->GetCurrentNumberOf(conf)
|
||||
<< G4endl;
|
||||
|
||||
assert(G4MoleculeCounter::Instance()->GetCurrentNumberOf(conf) ==
|
||||
fCounterMap[recordTime][conf]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::PrintRecordTime()
|
||||
{
|
||||
G4cout << "fCounterMap.size : " << fCounterMap.size() << G4endl;
|
||||
|
||||
for(const auto& i : fCounterMap)
|
||||
{
|
||||
auto map = i.second;
|
||||
auto begin = map.begin(); //
|
||||
auto end = map.end(); //
|
||||
for(; begin != end; begin++)
|
||||
{
|
||||
auto molecule = begin->first;
|
||||
auto number = begin->second;
|
||||
if(number == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
G4cout << "molecule : " << molecule->GetName() << " number : " << number
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::map<G4double /*time*/, G4DNAEventScheduler::MapCounter>
|
||||
G4DNAEventScheduler::GetCounterMap() const
|
||||
{
|
||||
return fCounterMap;
|
||||
}
|
||||
|
||||
void G4DNAEventScheduler::SetUserMeshAction(
|
||||
std::unique_ptr<G4UserMeshAction> pUserMeshAction)
|
||||
{
|
||||
fpUserMeshAction = std::move(pUserMeshAction);
|
||||
}
|
||||
|
||||
G4DNAMesh* G4DNAEventScheduler::GetMesh() const { return fpMesh.get(); }
|
||||
|
||||
G4int G4DNAEventScheduler::GetPixels() const { return fPixel; }
|
||||
|
||||
G4bool G4DNAEventScheduler::CheckingReactionRadius(G4double resolution)
|
||||
{
|
||||
auto pMolecularReactionTable = G4DNAMolecularReactionTable::Instance();
|
||||
auto reactionDataList = pMolecularReactionTable->GetVectorOfReactionData();
|
||||
if(reactionDataList.empty())
|
||||
{
|
||||
G4cout << "reactionDataList.empty()" << G4endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(auto it : reactionDataList)
|
||||
{
|
||||
if(it->GetEffectiveReactionRadius() >= resolution / CLHEP::pi)
|
||||
{
|
||||
G4cout << it->GetReactant1()->GetName() << " + "
|
||||
<< it->GetReactant2()->GetName() << G4endl;
|
||||
G4cout << "G4DNAEventScheduler::ReactionRadius : "
|
||||
<< G4BestUnit(it->GetEffectiveReactionRadius(), "Length")
|
||||
<< G4endl;
|
||||
G4cout << "resolution : " << G4BestUnit(resolution, "Length") << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
#include "G4DNAGillespieDirectMethod.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include "G4DNAEventSet.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4DNAScavengerMaterial.hh"
|
||||
#include "G4Scheduler.hh"
|
||||
#include <cassert>
|
||||
|
||||
G4DNAGillespieDirectMethod::G4DNAGillespieDirectMethod()
|
||||
: fMolecularReactions(G4DNAMolecularReactionTable::Instance())
|
||||
, fpMesh(nullptr)
|
||||
, fTimeStep(0)
|
||||
, fpEventSet(nullptr)
|
||||
, fVerbose(0)
|
||||
, fpScavengerMaterial(nullptr)
|
||||
{}
|
||||
|
||||
G4DNAGillespieDirectMethod::~G4DNAGillespieDirectMethod() = default;
|
||||
|
||||
void G4DNAGillespieDirectMethod::SetEventSet(G4DNAEventSet* pEventSet)
|
||||
{
|
||||
fpEventSet = pEventSet;
|
||||
}
|
||||
|
||||
//#define DEBUG 1
|
||||
|
||||
G4double G4DNAGillespieDirectMethod::VolumeOfNode(const Index& index)
|
||||
{
|
||||
auto LengthY = fpMesh->GetBoundingBox(index).Getyhi() -
|
||||
fpMesh->GetBoundingBox(index).Getylo();
|
||||
auto LengthX = fpMesh->GetBoundingBox(index).Getxhi() -
|
||||
fpMesh->GetBoundingBox(index).Getxlo();
|
||||
auto LengthZ = fpMesh->GetBoundingBox(index).Getzhi() -
|
||||
fpMesh->GetBoundingBox(index).Getzlo();
|
||||
G4double V = LengthY * LengthX * LengthZ;
|
||||
assert(V > 0);
|
||||
return V;
|
||||
}
|
||||
G4double G4DNAGillespieDirectMethod::PropensityFunction(const Index& index,
|
||||
MolType moleType)
|
||||
{
|
||||
if(moleType->GetDiffusionCoefficient() == 0)
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
const auto& node = fpMesh->GetVoxelMapList(index);
|
||||
G4double alpha = 0;
|
||||
auto it = node.find(moleType);
|
||||
if(it != node.end())
|
||||
{
|
||||
auto LengthY = fpMesh->GetBoundingBox(index).Getyhi() -
|
||||
fpMesh->GetBoundingBox(index).Getylo();
|
||||
G4double d = it->first->GetDiffusionCoefficient() / std::pow(LengthY, 2);
|
||||
alpha = d * it->second;
|
||||
|
||||
#ifdef DEBUG
|
||||
G4cout << it->first->GetName() << " " << it->second
|
||||
<< " D : " << it->first->GetDiffusionCoefficient()
|
||||
<< " LengthY : " << LengthY << " PropensityFunction : " << alpha
|
||||
<< G4endl;
|
||||
#endif
|
||||
}
|
||||
return alpha;
|
||||
}
|
||||
|
||||
G4double G4DNAGillespieDirectMethod::PropensityFunction(const Index& index,
|
||||
ReactionData* data)
|
||||
{
|
||||
G4double value;
|
||||
auto ConfA = data->GetReactant1();
|
||||
auto ConfB = data->GetReactant2();
|
||||
G4double scavengerNumber = 0;
|
||||
auto typeANumber = FindScavenging(index, ConfA, scavengerNumber)
|
||||
? scavengerNumber
|
||||
: ComputeNumberInNode(index, ConfA);
|
||||
|
||||
auto typeBNumber = FindScavenging(index, ConfB, scavengerNumber)
|
||||
? scavengerNumber
|
||||
: ComputeNumberInNode(index, ConfB);
|
||||
|
||||
if(typeANumber == 0 || typeBNumber == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto k =
|
||||
data->GetObservedReactionRateConstant() / (Avogadro * VolumeOfNode(index));
|
||||
if(ConfA == ConfB)
|
||||
{
|
||||
value = typeANumber * (typeBNumber - 1) * k;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = typeANumber * typeBNumber * k;
|
||||
}
|
||||
|
||||
if(value < 0)
|
||||
{
|
||||
G4cout << "G4DNAGillespieDirectMethod::PropensityFunction for : "
|
||||
<< ConfA->GetName() << "(" << typeANumber << ") + "
|
||||
<< ConfB->GetName() << "(" << typeBNumber
|
||||
<< ") : propensity : " << value
|
||||
<< " GetObservedReactionRateConstant : "
|
||||
<< data->GetObservedReactionRateConstant()
|
||||
<< " GetEffectiveReactionRadius : "
|
||||
<< G4BestUnit(data->GetEffectiveReactionRadius(), "Length")
|
||||
<< " k : " << k << " volume : " << VolumeOfNode(index)
|
||||
<< " Index : " << index << G4endl;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if(value > 0)
|
||||
G4cout << "G4DNAGillespieDirectMethod::PropensityFunction for : "
|
||||
<< ConfA->GetName() << "(" << typeANumber << ") + "
|
||||
<< ConfB->GetName() << "(" << typeBNumber
|
||||
<< ") : propensity : " << value
|
||||
<< " Time to Reaction : " << G4BestUnit(timeToReaction, "Time")
|
||||
<< " k : " << k << " Index : " << index << G4endl;
|
||||
#endif
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void G4DNAGillespieDirectMethod::Initialize()
|
||||
{
|
||||
// for Scavenger
|
||||
fpScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
|
||||
G4Scheduler::Instance()->GetScavengerMaterial());
|
||||
|
||||
auto begin = fpMesh->begin();
|
||||
auto end = fpMesh->end();
|
||||
for(; begin != end; begin++)
|
||||
{
|
||||
auto key = begin->first;
|
||||
#ifdef DEBUG
|
||||
fpMesh->PrintVoxel(fpMesh->GetIndex(key));
|
||||
#endif
|
||||
CreateEvent(key);
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAGillespieDirectMethod::SetTimeStep(const G4double& stepTime)
|
||||
{
|
||||
fTimeStep = stepTime;
|
||||
}
|
||||
void G4DNAGillespieDirectMethod::CreateEvent(unsigned int key)
|
||||
{
|
||||
G4double r1 = G4UniformRand();
|
||||
G4double r2 = G4UniformRand();
|
||||
auto index = fpMesh->GetIndex(key);
|
||||
G4double dAlpha0 = DiffusiveJumping(index);
|
||||
G4double rAlpha0 = Reaction(index);
|
||||
G4double alphaTotal = dAlpha0 + rAlpha0;
|
||||
|
||||
if(alphaTotal == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto timeStep = ((1.0 / (alphaTotal)) * std::log(1.0 / r1)) + fTimeStep;
|
||||
|
||||
#ifdef DEBUG
|
||||
G4cout << "r2 : " << r2 << " rAlpha0 : " << rAlpha0
|
||||
<< " dAlpha0 : " << dAlpha0 << " rAlpha0 / (dAlpha0 + rAlpha0) : "
|
||||
<< rAlpha0 / (dAlpha0 + rAlpha0) << G4endl;
|
||||
#endif
|
||||
if(r2 < rAlpha0 / alphaTotal)
|
||||
{
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << "=>>>>reaction at : " << timeStep << " timeStep : "
|
||||
<< G4BestUnit(((1.0 / alphaTotal) * std::log(1.0 / r1)), "Time")
|
||||
<< G4endl;
|
||||
}
|
||||
auto rSelectedIter = fReactionDataMap.upper_bound(r2 * alphaTotal);
|
||||
fpEventSet->CreateEvent(timeStep, key, rSelectedIter->second);
|
||||
}
|
||||
else if(dAlpha0 > 0)
|
||||
{
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << "=>>>>jumping at : " << timeStep << " timeStep : "
|
||||
<< G4BestUnit(((1.0 / alphaTotal) * std::log(1.0 / r1)), "Time")
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
auto dSelectedIter = fJumpingDataMap.upper_bound(r2 * alphaTotal - rAlpha0);
|
||||
auto pDSelected =
|
||||
std::make_unique<std::pair<MolType, Index>>(dSelectedIter->second);
|
||||
fpEventSet->CreateEvent(timeStep, key, std::move(pDSelected));
|
||||
}
|
||||
#ifdef DEBUG
|
||||
G4cout << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
G4double G4DNAGillespieDirectMethod::Reaction(const Index& index)
|
||||
{
|
||||
fReactionDataMap.clear();
|
||||
G4double alpha0 = 0;
|
||||
auto dataList = fMolecularReactions->GetVectorOfReactionData();
|
||||
if(dataList.empty())
|
||||
{
|
||||
G4cout << "MolecularReactionTable empty" << G4endl;
|
||||
assert(false);
|
||||
}
|
||||
for(const auto& it : dataList)
|
||||
{
|
||||
auto propensity = PropensityFunction(index, it);
|
||||
if(propensity == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
alpha0 += propensity;
|
||||
fReactionDataMap[alpha0] = it;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
G4cout << "Reaction :alpha0 : " << alpha0 << G4endl;
|
||||
#endif
|
||||
return alpha0;
|
||||
}
|
||||
|
||||
G4double G4DNAGillespieDirectMethod::DiffusiveJumping(const Index& index)
|
||||
{
|
||||
fJumpingDataMap.clear();
|
||||
G4double alpha0 = 0;
|
||||
auto NeighboringVoxels = fpMesh->FindNeighboringVoxels(index);
|
||||
if(NeighboringVoxels.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
auto iter = G4MoleculeTable::Instance()->GetConfigurationIterator();
|
||||
while(iter())
|
||||
{
|
||||
const auto conf = iter.value();
|
||||
auto propensity = PropensityFunction(index, conf);
|
||||
if(propensity == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for(const auto& it_Neighbor : NeighboringVoxels)
|
||||
{
|
||||
alpha0 += propensity;
|
||||
fJumpingDataMap[alpha0] = std::make_pair(conf, it_Neighbor);
|
||||
#ifdef DEBUG
|
||||
G4cout << "mole : " << conf->GetName()
|
||||
<< " number : " << ComputeNumberInNode(index, conf)
|
||||
<< " propensity : " << propensity << " alpha0 : " << alpha0
|
||||
<< G4endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
G4cout << "DiffusiveJumping :alpha0 : " << alpha0 << G4endl;
|
||||
#endif
|
||||
return alpha0;
|
||||
}
|
||||
|
||||
G4double G4DNAGillespieDirectMethod::ComputeNumberInNode(
|
||||
const Index& index, MolType type) // depend node ?
|
||||
{
|
||||
if(type->GetDiffusionCoefficient() != 0)
|
||||
{
|
||||
const auto& node = fpMesh->GetVoxelMapList(index);
|
||||
const auto& it = node.find(type);
|
||||
return (it != node.end()) ? (it->second) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4DNAGillespieDirectMethod::FindScavenging(const Index& index,
|
||||
MolType moletype,
|
||||
G4double& numberOfScavenger)
|
||||
{
|
||||
numberOfScavenger = 0;
|
||||
if(fpScavengerMaterial == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto volumeOfNode = VolumeOfNode(index);
|
||||
if(G4MoleculeTable::Instance()->GetConfiguration("H2O") == moletype)
|
||||
{
|
||||
auto factor = Avogadro * volumeOfNode;
|
||||
numberOfScavenger = factor;
|
||||
return true;
|
||||
}
|
||||
|
||||
G4double totalNumber =
|
||||
fpScavengerMaterial->GetNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
moletype);
|
||||
if(totalNumber == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4double numberInDouble =
|
||||
volumeOfNode * std::floor(totalNumber) / fpMesh->GetBoundingBox().Volume();
|
||||
auto numberInInterg = (int) (std::floor(numberInDouble));
|
||||
G4double ram = G4UniformRand();
|
||||
G4double change = numberInDouble - numberInInterg;
|
||||
if(ram > change)
|
||||
{
|
||||
numberOfScavenger = numberInInterg;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfScavenger = numberInInterg + 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ G4VITReactionProcess(),
|
||||
fMolReactionTable(reference_cast<const G4DNAMolecularReactionTable*>(fpReactionTable)),
|
||||
fpReactionModel(nullptr),
|
||||
fTrackHolder(G4ITTrackHolder::Instance()),
|
||||
fReactionSet(0)
|
||||
fReactionSet(nullptr)
|
||||
{
|
||||
timeMin = G4Scheduler::Instance()->GetStartTime();
|
||||
timeMax = G4Scheduler::Instance()->GetEndTime();
|
||||
@@ -247,10 +247,11 @@ void G4DNAIRT::Sampling(G4Track* track){
|
||||
for(size_t u=0; u<fReactionDatas->size();u++){
|
||||
if((*fReactionDatas)[u]->GetReactant2()->GetDiffusionCoefficient() == 0){
|
||||
G4double kObs = (*fReactionDatas)[u]->GetObservedReactionRateConstant();
|
||||
if(kObs == 0) continue;
|
||||
G4double time = -(std::log(1.0 - G4UniformRand())/kObs) + globalTime;
|
||||
if( time < minTime && time >= globalTime && time < timeMax){
|
||||
minTime = time;
|
||||
index = (int) u;
|
||||
index = (G4int)u;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,18 +278,19 @@ G4double G4DNAIRT::GetIndependentReactionTime(const G4MolecularConfiguration* mo
|
||||
G4double irt = -1 * ps;
|
||||
G4double D = molA->GetDiffusionCoefficient() +
|
||||
molB->GetDiffusionCoefficient();
|
||||
if(D == 0) D += 1e-20*(m2/s);
|
||||
G4double rc = fReactionData->GetOnsagerRadius();
|
||||
|
||||
if ( reactionType == 0){
|
||||
G4double sigma = fReactionData->GetEffectiveReactionRadius();
|
||||
|
||||
if( rc != 0) r0 = -rc / (1-std::exp(rc/r0));
|
||||
if(sigma > r0) return 0; // contact reaction
|
||||
if( rc != 0) r0 = -rc / (1-std::exp(rc/r0));
|
||||
|
||||
G4double Winf = sigma/r0;
|
||||
G4double W = G4UniformRand();
|
||||
|
||||
if ( W < Winf ) irt = (0.25/D) * std::pow( (r0-sigma)/erfc->erfcInv(r0*W/sigma), 2 );
|
||||
if ( W > 0 && W < Winf ) irt = (0.25/D) * std::pow( (r0-sigma)/erfc->erfcInv(r0*W/sigma), 2 );
|
||||
|
||||
return irt;
|
||||
}
|
||||
@@ -319,8 +321,8 @@ G4double G4DNAIRT::GetIndependentReactionTime(const G4MolecularConfiguration* mo
|
||||
Winf = sigma / r0 * kobs / kdif;
|
||||
|
||||
if(Winf > G4UniformRand()) irt = SamplePDC(a,b)/D;
|
||||
return irt;
|
||||
}
|
||||
return irt;
|
||||
}
|
||||
|
||||
return -1 * ps;
|
||||
}
|
||||
@@ -404,7 +406,7 @@ std::unique_ptr<G4ITReactionChange> G4DNAIRT::MakeReaction(const G4Track& trackA
|
||||
|
||||
G4double dt = globalTime - trackA.GetGlobalTime();
|
||||
|
||||
if(dt != 0){
|
||||
if(dt != 0 && (D1 + D2) != 0 && r0 != 0){
|
||||
G4double s12 = 2.0 * D1 * dt;
|
||||
G4double s22 = 2.0 * D2 * dt;
|
||||
if(s12 == 0) r2 = r1;
|
||||
@@ -415,6 +417,9 @@ std::unique_ptr<G4ITReactionChange> G4DNAIRT::MakeReaction(const G4Track& trackA
|
||||
G4RandGauss::shoot(0, s12 + s22 * s22 / s12),
|
||||
G4RandGauss::shoot(0, s12 + s22 * s22 / s12));
|
||||
|
||||
if(alpha == 0){
|
||||
return pChanges;
|
||||
}
|
||||
S1.setPhi(rad * G4UniformRand() * 2.0 * CLHEP::pi);
|
||||
S1.setTheta(rad * std::acos(1.0 + 1./alpha * std::log(1.0 - G4UniformRand() * (1 - std::exp(-2.0 * alpha)))));
|
||||
|
||||
@@ -441,6 +446,9 @@ std::unique_ptr<G4ITReactionChange> G4DNAIRT::MakeReaction(const G4Track& trackA
|
||||
|
||||
const G4double sqrD1 = D1 == 0. ? 0. : std::sqrt(D1);
|
||||
const G4double sqrD2 = D2 == 0. ? 0. : std::sqrt(D2);
|
||||
if((sqrD1 + sqrD2) == 0){
|
||||
return pChanges;
|
||||
}
|
||||
const G4double inv_numerator = 1./(sqrD1 + sqrD2);
|
||||
const G4ThreeVector reactionSite = sqrD2 * inv_numerator * trackA.GetPosition()
|
||||
+ sqrD1 * inv_numerator * trackB.GetPosition();
|
||||
@@ -487,9 +495,9 @@ std::unique_ptr<G4ITReactionChange> G4DNAIRT::MakeReaction(const G4Track& trackA
|
||||
|
||||
std::vector<std::unique_ptr<G4ITReactionChange>> G4DNAIRT::FindReaction(
|
||||
G4ITReactionSet* pReactionSet,
|
||||
const double /*currentStepTime*/,
|
||||
const double fGlobalTime,
|
||||
const bool /*reachedUserStepTimeLimit*/)
|
||||
const G4double /*currentStepTime*/,
|
||||
const G4double fGlobalTime,
|
||||
const G4bool /*reachedUserStepTimeLimit*/)
|
||||
{
|
||||
std::vector<std::unique_ptr<G4ITReactionChange>> fReactionInfo;
|
||||
fReactionInfo.clear();
|
||||
@@ -528,8 +536,8 @@ std::vector<std::unique_ptr<G4ITReactionChange>> G4DNAIRT::FindReaction(
|
||||
|
||||
G4bool G4DNAIRT::TestReactibility(const G4Track& /*trackA*/,
|
||||
const G4Track& /*trackB*/,
|
||||
double /*currentStepTime*/,
|
||||
bool /*userStepTimeLimit*/) /*const*/
|
||||
G4double /*currentStepTime*/,
|
||||
G4bool /*userStepTimeLimit*/) /*const*/
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,642 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/*
|
||||
* G4DNAIRT_geometries.cc
|
||||
*
|
||||
* Created on: Jul 23, 2019
|
||||
* Author: W. G. Shin
|
||||
* J. Ramos-Mendez and B. Faddegon
|
||||
*/
|
||||
|
||||
|
||||
#include "G4DNAIRT_geometries.hh"
|
||||
#include "G4ErrorFunction.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
#include "G4MolecularConfiguration.hh"
|
||||
#include "G4Molecule.hh"
|
||||
#include "G4ITReactionChange.hh"
|
||||
#include "G4ITTrackHolder.hh"
|
||||
#include "G4ITReaction.hh"
|
||||
#include "G4Scheduler.hh"
|
||||
#include "G4MoleculeTable.hh"
|
||||
#include "G4NavigationHistory.hh"
|
||||
#include "G4DNAMolecularMaterial.hh"
|
||||
#include "G4VDNAMolecularGeometry.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
G4DNAIRT_geometries::G4DNAIRT_geometries() :
|
||||
G4VITReactionProcess(),
|
||||
fMolReactionTable(reference_cast<const G4DNAMolecularReactionTable*>(fpReactionTable)),
|
||||
fpReactionModel(nullptr),
|
||||
fTrackHolder(G4ITTrackHolder::Instance()),
|
||||
fReactionSet(nullptr),
|
||||
fGeometry(nullptr)
|
||||
{
|
||||
timeMin = G4Scheduler::Instance()->GetStartTime();
|
||||
timeMax = G4Scheduler::Instance()->GetEndTime();
|
||||
|
||||
fXMin = 1e9*nm;
|
||||
fYMin = 1e9*nm;
|
||||
fZMin = 1e9*nm;
|
||||
|
||||
fXMax = 0e0*nm;
|
||||
fYMax = 0e0*nm;
|
||||
fZMax = 0e0*nm;
|
||||
|
||||
fNx = 0;
|
||||
fNy = 0;
|
||||
fNz = 0;
|
||||
|
||||
xiniIndex = 0, yiniIndex = 0, ziniIndex = 0;
|
||||
xendIndex = 0, yendIndex = 0, zendIndex = 0;
|
||||
|
||||
fRCutOff =
|
||||
1.45 * nm + 2 * std::sqrt(8*9.46e9*nm*nm/s * timeMax); // 95% confidence level
|
||||
|
||||
erfc = new G4ErrorFunction();
|
||||
}
|
||||
|
||||
|
||||
G4DNAIRT_geometries::G4DNAIRT_geometries(G4VDNAReactionModel* pReactionModel)
|
||||
: G4DNAIRT_geometries()
|
||||
{
|
||||
fpReactionModel = pReactionModel;
|
||||
}
|
||||
|
||||
G4DNAIRT_geometries::~G4DNAIRT_geometries()
|
||||
{
|
||||
delete erfc;
|
||||
}
|
||||
|
||||
void G4DNAIRT_geometries::Initialize(){
|
||||
|
||||
timeMin = G4Scheduler::Instance()->GetGlobalTime();
|
||||
timeMax = std::min(timeMin + G4Scheduler::Instance()->GetLimitingTimeStep(),
|
||||
G4Scheduler::Instance()->GetEndTime());
|
||||
if(timeMin == 0) return;
|
||||
|
||||
fTrackHolder = G4ITTrackHolder::Instance();
|
||||
if(fTrackHolder->GetMainList()->size() == 0) return;
|
||||
|
||||
fReactionSet = G4ITReactionSet::Instance();
|
||||
fReactionSet->CleanAllReaction();
|
||||
fReactionSet->SortByTime();
|
||||
|
||||
spaceBinned.clear();
|
||||
positionMap.clear();
|
||||
|
||||
fRCutOff =
|
||||
1.45 * nm + 2 * std::sqrt(8*9.46e9*nm*nm/s * (timeMax - timeMin));
|
||||
|
||||
xiniIndex = 0;
|
||||
yiniIndex = 0;
|
||||
ziniIndex = 0;
|
||||
xendIndex = 0;
|
||||
yendIndex = 0;
|
||||
zendIndex = 0;
|
||||
|
||||
fXMin = 1e9*nm;
|
||||
fYMin = 1e9*nm;
|
||||
fZMin = 1e9*nm;
|
||||
|
||||
fXMax = 0e0*nm;
|
||||
fYMax = 0e0*nm;
|
||||
fZMax = 0e0*nm;
|
||||
|
||||
fNx = 0;
|
||||
fNy = 0;
|
||||
fNz = 0;
|
||||
|
||||
fGeometry = fMolReactionTable->GetGeometry();
|
||||
|
||||
SpaceBinning(); // 1. binning the space
|
||||
IRTSampling(); // 2. Sampling of the IRT
|
||||
|
||||
}
|
||||
|
||||
void G4DNAIRT_geometries::SpaceBinning(){
|
||||
G4double time_step = G4Scheduler::Instance()->GetPreviousTimeStep()*ps;
|
||||
|
||||
auto it_begin = fTrackHolder->GetMainList()->begin();
|
||||
while(it_begin != fTrackHolder->GetMainList()->end()){
|
||||
|
||||
// for diffusion
|
||||
G4double D = GetMolecule(*it_begin)->GetDiffusionCoefficient();
|
||||
G4double sqrt_2Dt = sqrt(2 * D * time_step);
|
||||
|
||||
G4double x = G4RandGauss::shoot(0,sqrt_2Dt);
|
||||
G4double y = G4RandGauss::shoot(0,sqrt_2Dt);
|
||||
G4double z = G4RandGauss::shoot(0,sqrt_2Dt);
|
||||
|
||||
G4ThreeVector position_ori = it_begin->GetPosition();
|
||||
G4ThreeVector position = position_ori + G4ThreeVector(x,y,z);
|
||||
it_begin->SetPosition(position);
|
||||
it_begin->SetGlobalTime(timeMax);
|
||||
|
||||
if ( fXMin > position.x() ) fXMin = position.x();
|
||||
if ( fYMin > position.y() ) fYMin = position.y();
|
||||
if ( fZMin > position.z() ) fZMin = position.z();
|
||||
|
||||
if ( fXMax < position.x() ) fXMax = position.x();
|
||||
if ( fYMax < position.y() ) fYMax = position.y();
|
||||
if ( fZMax < position.z() ) fZMax = position.z();
|
||||
|
||||
++it_begin;
|
||||
}
|
||||
|
||||
fNx = G4int((fXMax-fXMin)/fRCutOff) == 0 ? 1 : G4int((fXMax-fXMin)/fRCutOff);
|
||||
fNy = G4int((fYMax-fYMin)/fRCutOff) == 0 ? 1 : G4int((fYMax-fYMin)/fRCutOff);
|
||||
fNz = G4int((fZMax-fZMin)/fRCutOff) == 0 ? 1 : G4int((fZMax-fZMin)/fRCutOff);
|
||||
|
||||
}
|
||||
|
||||
void G4DNAIRT_geometries::IRTSampling(){
|
||||
|
||||
auto it_begin = fTrackHolder->GetMainList()->begin();
|
||||
while(it_begin != fTrackHolder->GetMainList()->end()){
|
||||
G4int I = FindBin(fNx, fXMin, fXMax, it_begin->GetPosition().x());
|
||||
G4int J = FindBin(fNy, fYMin, fYMax, it_begin->GetPosition().y());
|
||||
G4int K = FindBin(fNz, fZMin, fZMax, it_begin->GetPosition().z());
|
||||
|
||||
spaceBinned[I][J][K].push_back(*it_begin);
|
||||
|
||||
Sampling(*it_begin);
|
||||
++it_begin;
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAIRT_geometries::Sampling(G4Track* track){
|
||||
G4Molecule* molA = G4Molecule::GetMolecule(track);
|
||||
const G4MolecularConfiguration* molConfA = molA->GetMolecularConfiguration();
|
||||
if(molConfA->GetDiffusionCoefficient() == 0) return;
|
||||
|
||||
const vector<const G4MolecularConfiguration*>* reactivesVector =
|
||||
fMolReactionTable->CanReactWith(molConfA);
|
||||
|
||||
if(reactivesVector == nullptr) return;
|
||||
|
||||
G4double globalTime = G4Scheduler::Instance()->GetGlobalTime();
|
||||
G4double minTime = timeMax;
|
||||
|
||||
xiniIndex = FindBin(fNx, fXMin, fXMax, track->GetPosition().x()-fRCutOff);
|
||||
xendIndex = FindBin(fNx, fXMin, fXMax, track->GetPosition().x()+fRCutOff);
|
||||
yiniIndex = FindBin(fNy, fYMin, fYMax, track->GetPosition().y()-fRCutOff);
|
||||
yendIndex = FindBin(fNy, fYMin, fYMax, track->GetPosition().y()+fRCutOff);
|
||||
ziniIndex = FindBin(fNz, fZMin, fZMax, track->GetPosition().z()-fRCutOff);
|
||||
zendIndex = FindBin(fNz, fZMin, fZMax, track->GetPosition().z()+fRCutOff);
|
||||
|
||||
for ( G4int ii = xiniIndex; ii <= xendIndex; ++ii ) {
|
||||
for ( G4int jj = yiniIndex; jj <= yendIndex; ++jj ) {
|
||||
for ( G4int kk = ziniIndex; kk <= zendIndex; ++kk ) {
|
||||
|
||||
std::vector<G4Track*> spaceBin = spaceBinned[ii][jj][kk];
|
||||
for ( G4int n = 0; n < (G4int)spaceBinned[ii][jj][kk].size(); ++n ) {
|
||||
if(!spaceBin[n] || track == spaceBin[n]) continue;
|
||||
if(spaceBin[n]->GetTrackStatus() == fStopButAlive) continue;
|
||||
|
||||
G4Molecule* molB = G4Molecule::GetMolecule(spaceBin[n]);
|
||||
if(!molB) continue;
|
||||
|
||||
const G4MolecularConfiguration* molConfB = molB->GetMolecularConfiguration();
|
||||
if(molConfB->GetDiffusionCoefficient() == 0) continue;
|
||||
|
||||
auto it = std::find(reactivesVector->begin(), reactivesVector->end(), molConfB);
|
||||
if(it == reactivesVector->end()) continue;
|
||||
|
||||
G4ThreeVector orgPosB = spaceBin[n]->GetPosition();
|
||||
G4double dt = track->GetGlobalTime() - spaceBin[n]->GetGlobalTime();
|
||||
G4ThreeVector newPosB = orgPosB;
|
||||
|
||||
if(dt > 0){
|
||||
G4double sigma, x, y, z;
|
||||
G4double diffusionCoefficient = G4Molecule::GetMolecule(spaceBin[n])->GetDiffusionCoefficient();
|
||||
|
||||
sigma = std::sqrt(2.0 * diffusionCoefficient * dt);
|
||||
|
||||
x = G4RandGauss::shoot(0., 1.0)*sigma;
|
||||
y = G4RandGauss::shoot(0., 1.0)*sigma;
|
||||
z = G4RandGauss::shoot(0., 1.0)*sigma;
|
||||
|
||||
newPosB = orgPosB + G4ThreeVector(x,y,z);
|
||||
}else if(dt < 0) continue;
|
||||
|
||||
G4double r0 = (newPosB - track->GetPosition()).mag();
|
||||
G4double irt = GetIndependentReactionTime(molConfA,
|
||||
molConfB,
|
||||
r0);
|
||||
if(irt>=0 && irt<timeMax - globalTime)
|
||||
{
|
||||
irt += globalTime;
|
||||
if(irt < minTime) minTime = irt;
|
||||
#ifdef DEBUG
|
||||
G4cout<<irt<<'\t'<<molConfA->GetName()<<" "<<track->GetTrackID()<<'\t'<<molConfB->GetName()<<" "<<spaceBin[n]->GetTrackID()<<'\n';
|
||||
#endif
|
||||
fReactionSet->AddReaction(irt,track,spaceBin[n]);
|
||||
}
|
||||
}
|
||||
spaceBin.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scavenging & first order reactions
|
||||
|
||||
auto fReactionDatas = fMolReactionTable->GetReactionData(molConfA);
|
||||
G4int index = -1;
|
||||
|
||||
for(size_t u=0; u<fReactionDatas->size();++u){
|
||||
auto molB = (*fReactionDatas)[u]->GetReactant2();
|
||||
if(molB == G4MoleculeTable::Instance()->GetConfiguration("H2O(B)") ||
|
||||
molB == G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)") ||
|
||||
molB == G4MoleculeTable::Instance()->GetConfiguration("OHm(B)")){
|
||||
G4double kObs = (*fReactionDatas)[u]->GetObservedReactionRateConstant();
|
||||
if(kObs == 0) continue;
|
||||
G4double time = -(std::log(1.0 - G4UniformRand())/kObs) + globalTime;
|
||||
if( time < minTime && time >= globalTime && time < timeMax){
|
||||
minTime = time;
|
||||
index = (G4int)u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(index != -1){
|
||||
#ifdef DEBUG
|
||||
G4cout<<"scavenged: "<<minTime<<'\t'<<molConfA->GetName()<<it_begin->GetTrackID()<<'\n';
|
||||
#endif
|
||||
G4Molecule* fakeMol = new G4Molecule((*fReactionDatas)[index]->GetReactant2());
|
||||
G4Track* fakeTrack = fakeMol->BuildTrack(globalTime,track->GetPosition());
|
||||
fTrackHolder->Push(fakeTrack);
|
||||
fReactionSet->AddReaction(minTime, track, fakeTrack);
|
||||
}
|
||||
|
||||
|
||||
// DNA reactions
|
||||
if(fGeometry == nullptr) return;
|
||||
|
||||
const G4VTouchable* touchable = track->GetTouchable();
|
||||
if(touchable == nullptr) return;
|
||||
|
||||
const G4LogicalVolume* logicalVolume = touchable->GetVolume()->GetLogicalVolume();
|
||||
|
||||
const G4ThreeVector& globalPos = track->GetPosition();
|
||||
const G4ThreeVector& localPos = touchable->GetHistory()->GetTopTransform().TransformPoint(globalPos);
|
||||
|
||||
G4double D = GetMolecule(track)->GetDiffusionCoefficient();
|
||||
G4double time_step = abs(timeMax - timeMin);
|
||||
G4double search_range = 2*sqrt(2*D*time_step);
|
||||
|
||||
std::vector<G4VPhysicalVolume*> result_pv;
|
||||
result_pv.clear();
|
||||
fGeometry->FindNearbyMolecules(logicalVolume,
|
||||
localPos,
|
||||
result_pv,
|
||||
search_range);
|
||||
|
||||
if(result_pv.empty()) return;
|
||||
|
||||
for(auto physicalVolume : result_pv){
|
||||
const G4Material* material = physicalVolume->GetLogicalVolume()->GetMaterial();
|
||||
G4MolecularConfiguration* dna_molConf =
|
||||
G4DNAMolecularMaterial::Instance()->GetMolecularConfiguration(material);
|
||||
|
||||
auto it = std::find(reactivesVector->begin(), reactivesVector->end(), dna_molConf);
|
||||
if(it == reactivesVector->end()) continue;
|
||||
G4ThreeVector pos = physicalVolume->GetTranslation();
|
||||
|
||||
G4ThreeVector globalPos_DNA = touchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(pos);
|
||||
|
||||
G4double r0 = (pos - localPos).mag();
|
||||
G4double irt = GetIndependentReactionTime(molConfA,dna_molConf,r0);
|
||||
|
||||
if(irt>=0 && irt<timeMax - globalTime)
|
||||
{
|
||||
|
||||
index = -1;
|
||||
for(size_t i=0;i<positionMap.size();++i){
|
||||
if(globalPos_DNA == positionMap[i].first){
|
||||
index = (G4int)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
G4Track* DNATrack;
|
||||
if(index == -1){
|
||||
auto DNAMol = new G4Molecule(dna_molConf);
|
||||
DNATrack = DNAMol->BuildTrack(globalTime,globalPos_DNA);
|
||||
DNATrack->SetTrackStatus(fAlive);
|
||||
fTrackHolder->Push(DNATrack);
|
||||
positionMap.push_back(std::make_pair(globalPos_DNA,DNATrack));
|
||||
}else{
|
||||
DNATrack = positionMap[index].second;
|
||||
}
|
||||
|
||||
irt += globalTime;
|
||||
if(irt < minTime) minTime = irt;
|
||||
#ifdef DEBUG
|
||||
G4cout<<irt<<'\t'<<globalPos_DNA<<'\t'<<molConfA->GetName()<<" "<<track->GetTrackID()<<'\t'<<dna_molConf->GetName()<<" "<<DNATrack->GetTrackID()<<'\n';
|
||||
#endif
|
||||
fReactionSet->AddReaction(irt,track,DNATrack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4double G4DNAIRT_geometries::GetIndependentReactionTime(const G4MolecularConfiguration* molA, const G4MolecularConfiguration* molB, G4double distance) {
|
||||
const auto pMoleculeA = molA;
|
||||
const auto pMoleculeB = molB;
|
||||
auto fReactionData = fMolReactionTable->GetReactionData(pMoleculeA, pMoleculeB);
|
||||
G4int reactionType = fReactionData->GetReactionType();
|
||||
G4double r0 = distance;
|
||||
if(r0 == 0) r0 += 1e-3*nm;
|
||||
G4double irt = -1 * ps;
|
||||
G4double D = molA->GetDiffusionCoefficient() +
|
||||
molB->GetDiffusionCoefficient();
|
||||
if(D == 0) D += 1e-20*(m2/s);
|
||||
G4double rc = fReactionData->GetOnsagerRadius();
|
||||
|
||||
if ( reactionType == 0){
|
||||
G4double sigma = fReactionData->GetEffectiveReactionRadius();
|
||||
|
||||
if(sigma > r0) return 0; // contact reaction
|
||||
if( rc != 0) r0 = -rc / (1-std::exp(rc/r0));
|
||||
|
||||
G4double Winf = sigma/r0;
|
||||
G4double W = G4UniformRand();
|
||||
|
||||
if ( W > 0 && W < Winf ) irt = (0.25/D) * std::pow( (r0-sigma)/erfc->erfcInv(r0*W/sigma), 2 );
|
||||
|
||||
return irt;
|
||||
}
|
||||
else if ( reactionType == 1 ){
|
||||
G4double sigma = fReactionData->GetReactionRadius();
|
||||
G4double kact = fReactionData->GetActivationRateConstant();
|
||||
G4double kdif = fReactionData->GetDiffusionRateConstant();
|
||||
G4double kobs = fReactionData->GetObservedReactionRateConstant();
|
||||
|
||||
G4double a, b, Winf;
|
||||
|
||||
if ( rc == 0 ) {
|
||||
a = 1/sigma * kact / kobs;
|
||||
b = (r0 - sigma) / 2;
|
||||
} else {
|
||||
G4double v = kact/Avogadro/(4*CLHEP::pi*pow(sigma,2) * exp(-rc / sigma));
|
||||
G4double alpha = v+rc*D/(pow(sigma,2)*(1-exp(-rc/sigma)));
|
||||
a = 4*pow(sigma,2)*alpha/(D*pow(rc,2))*pow(sinh(rc/(2*sigma)),2);
|
||||
b = rc/4*(cosh(rc/(2*r0))/sinh(rc/(2*r0))-cosh(rc/(2*sigma))/sinh(rc/(2*sigma)));
|
||||
r0 = -rc/(1-std::exp(rc/r0));
|
||||
sigma = fReactionData->GetEffectiveReactionRadius();
|
||||
}
|
||||
|
||||
if(sigma > r0){
|
||||
if(fReactionData->GetProbability() > G4UniformRand()) return 0;
|
||||
else return irt;
|
||||
}
|
||||
Winf = sigma / r0 * kobs / kdif;
|
||||
|
||||
if(Winf > G4UniformRand()) irt = SamplePDC(a,b)/D;
|
||||
return irt;
|
||||
}
|
||||
|
||||
return -1 * ps;
|
||||
}
|
||||
|
||||
G4int G4DNAIRT_geometries::FindBin(G4int n, G4double xmin, G4double xmax, G4double value) {
|
||||
|
||||
G4int bin = -1;
|
||||
if ( value <= xmin )
|
||||
bin = 0; //1;
|
||||
else if ( value >= xmax) //!(xmax < value) ) //value >= xmax )
|
||||
bin = n-1; //n;
|
||||
else
|
||||
bin = G4int( n * ( value - xmin )/( xmax - xmin ) ); //bin = 1 + G4int( n * ( value - xmin )/( xmax - xmin ) );
|
||||
|
||||
if ( bin < 0 ) bin = 0;
|
||||
if ( bin >= n ) bin = n-1;
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
G4double G4DNAIRT_geometries::SamplePDC(G4double a, G4double b) {
|
||||
|
||||
G4double p = 2.0 * std::sqrt(2.0*b/a);
|
||||
G4double q = 2.0 / std::sqrt(2.0*b/a);
|
||||
G4double M = max(1.0/(a*a),3.0*b/a);
|
||||
|
||||
G4double X, U, lambdax;
|
||||
|
||||
G4int ntrials = 0;
|
||||
while(1) {
|
||||
|
||||
// Generate X
|
||||
U = G4UniformRand();
|
||||
if ( U < p/(p + q * M) ) X = pow(U * (p + q * M) / 2, 2);
|
||||
else X = pow(2/((1-U)*(p+q*M)/M),2);
|
||||
|
||||
U = G4UniformRand();
|
||||
|
||||
lambdax = std::exp(-b*b/X) * ( 1.0 - a * std::sqrt(CLHEP::pi * X) * erfc->erfcx(b/std::sqrt(X) + a*std::sqrt(X)));
|
||||
|
||||
if ((X <= 2.0*b/a && U <= lambdax) ||
|
||||
(X >= 2.0*b/a && U*M/X <= lambdax)) break;
|
||||
|
||||
ntrials++;
|
||||
|
||||
if ( ntrials > 10000 ){
|
||||
G4cout<<"Totally rejected"<<'\n';
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
return X;
|
||||
}
|
||||
|
||||
std::unique_ptr<G4ITReactionChange> G4DNAIRT_geometries::MakeReaction(const G4Track& trackA,
|
||||
const G4Track& trackB)
|
||||
{
|
||||
|
||||
std::unique_ptr<G4ITReactionChange> pChanges(new G4ITReactionChange());
|
||||
pChanges->Initialize(trackA, trackB);
|
||||
|
||||
const auto pMoleculeA = GetMolecule(trackA)->GetMolecularConfiguration();
|
||||
const auto pMoleculeB = GetMolecule(trackB)->GetMolecularConfiguration();
|
||||
const auto pReactionData = fMolReactionTable->GetReactionData(pMoleculeA, pMoleculeB);
|
||||
|
||||
G4double globalTime = G4Scheduler::Instance()->GetGlobalTime();
|
||||
G4double effectiveReactionRadius = pReactionData->GetEffectiveReactionRadius();
|
||||
|
||||
const G4double D1 = pMoleculeA->GetDiffusionCoefficient();
|
||||
const G4double D2 = pMoleculeB->GetDiffusionCoefficient();
|
||||
|
||||
G4ThreeVector r1 = trackA.GetPosition();
|
||||
G4ThreeVector r2 = trackB.GetPosition();
|
||||
|
||||
if(r1 == r2) r2 += G4ThreeVector(0,0,1e-3*nm);
|
||||
|
||||
G4ThreeVector S1 = r1 - r2;
|
||||
|
||||
G4double r0 = S1.mag();
|
||||
|
||||
S1.setMag(effectiveReactionRadius);
|
||||
|
||||
G4double dt = globalTime - trackA.GetGlobalTime();
|
||||
|
||||
if(dt != 0 && (D1 + D2) != 0 && r0 != 0){
|
||||
G4double s12 = 2.0 * D1 * dt;
|
||||
G4double s22 = 2.0 * D2 * dt;
|
||||
if(s12 == 0) r2 = r1;
|
||||
else if(s22 == 0) r1 = r2;
|
||||
else{
|
||||
G4double alpha = effectiveReactionRadius * r0 / (2*(D1 + D2)*dt);
|
||||
G4ThreeVector S2 = (r1 + (s12 / s22)*r2) + G4ThreeVector(G4RandGauss::shoot(0, s12 + s22 * s22 / s12),
|
||||
G4RandGauss::shoot(0, s12 + s22 * s22 / s12),
|
||||
G4RandGauss::shoot(0, s12 + s22 * s22 / s12));
|
||||
|
||||
S1.setPhi(rad * G4UniformRand() * 2.0 * CLHEP::pi);
|
||||
S1.setTheta(rad * std::acos(1.0 + 1./alpha * std::log(1.0 - G4UniformRand() * (1 - std::exp(-2.0 * alpha)))));
|
||||
|
||||
r1 = (D1 * S1 + D2 * S2) / (D1 + D2);
|
||||
r2 = D2 * (S2 - S1) / (D1 + D2);
|
||||
}
|
||||
}
|
||||
|
||||
auto pTrackA = const_cast<G4Track*>(pChanges->GetTrackA());
|
||||
auto pTrackB = const_cast<G4Track*>(pChanges->GetTrackB());
|
||||
|
||||
pTrackA->SetPosition(r1);
|
||||
pTrackB->SetPosition(r2);
|
||||
|
||||
pTrackA->SetGlobalTime(globalTime);
|
||||
pTrackB->SetGlobalTime(globalTime);
|
||||
|
||||
pTrackA->SetTrackStatus(fStopButAlive);
|
||||
pTrackB->SetTrackStatus(fStopButAlive);
|
||||
|
||||
const G4int nbProducts = pReactionData->GetNbProducts();
|
||||
|
||||
if(nbProducts){
|
||||
|
||||
const G4double sqrD1 = D1 == 0. ? 0. : std::sqrt(D1);
|
||||
const G4double sqrD2 = D2 == 0. ? 0. : std::sqrt(D2);
|
||||
const G4double inv_numerator = 1./(sqrD1 + sqrD2);
|
||||
const G4ThreeVector reactionSite = sqrD2 * inv_numerator * trackA.GetPosition()
|
||||
+ sqrD1 * inv_numerator * trackB.GetPosition();
|
||||
|
||||
std::vector<G4ThreeVector> position;
|
||||
|
||||
if(nbProducts == 1){
|
||||
position.push_back(reactionSite);
|
||||
}else if(nbProducts == 2){
|
||||
position.push_back(trackA.GetPosition());
|
||||
position.push_back(trackB.GetPosition());
|
||||
}else if (nbProducts == 3){
|
||||
position.push_back(reactionSite);
|
||||
position.push_back(trackA.GetPosition());
|
||||
position.push_back(trackB.GetPosition());
|
||||
}
|
||||
|
||||
for(G4int u = 0; u < nbProducts; ++u){
|
||||
|
||||
auto product = new G4Molecule(pReactionData->GetProduct(u));
|
||||
auto productTrack = product->BuildTrack(globalTime,
|
||||
position[u]);
|
||||
|
||||
productTrack->SetTrackStatus(fAlive);
|
||||
fTrackHolder->Push(productTrack);
|
||||
|
||||
pChanges->AddSecondary(productTrack);
|
||||
|
||||
G4int I = FindBin(fNx, fXMin, fXMax, position[u].x());
|
||||
G4int J = FindBin(fNy, fYMin, fYMax, position[u].y());
|
||||
G4int K = FindBin(fNz, fZMin, fZMax, position[u].z());
|
||||
|
||||
spaceBinned[I][J][K].push_back(productTrack);
|
||||
|
||||
Sampling(productTrack);
|
||||
}
|
||||
}
|
||||
|
||||
fTrackHolder->MergeSecondariesWithMainList();
|
||||
pChanges->KillParents(true);
|
||||
return pChanges;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<G4ITReactionChange>> G4DNAIRT_geometries::FindReaction(
|
||||
G4ITReactionSet* pReactionSet,
|
||||
const G4double /*currentStepTime*/,
|
||||
const G4double fGlobalTime,
|
||||
const G4bool /*reachedUserStepTimeLimit*/)
|
||||
{
|
||||
std::vector<std::unique_ptr<G4ITReactionChange>> fReactionInfo;
|
||||
fReactionInfo.clear();
|
||||
|
||||
if (pReactionSet == nullptr)
|
||||
{
|
||||
return fReactionInfo;
|
||||
}
|
||||
|
||||
auto fReactionsetInTime = pReactionSet->GetReactionsPerTime();
|
||||
assert(fReactionsetInTime.begin() != fReactionsetInTime.end());
|
||||
|
||||
auto it_begin = fReactionsetInTime.begin();
|
||||
while(it_begin != fReactionsetInTime.end())
|
||||
{
|
||||
G4double irt = it_begin->get()->GetTime();
|
||||
|
||||
if(fGlobalTime < irt) break;
|
||||
|
||||
pReactionSet->SelectThisReaction(*it_begin);
|
||||
|
||||
G4Track* pTrackA = it_begin->get()->GetReactants().first;
|
||||
G4Track* pTrackB = it_begin->get()->GetReactants().second;
|
||||
auto pReactionChange = MakeReaction(*pTrackA, *pTrackB);
|
||||
|
||||
if(pReactionChange){
|
||||
fReactionInfo.push_back(std::move(pReactionChange));
|
||||
}
|
||||
|
||||
fReactionsetInTime = pReactionSet->GetReactionsPerTime();
|
||||
it_begin = fReactionsetInTime.begin();
|
||||
}
|
||||
|
||||
return fReactionInfo;
|
||||
}
|
||||
|
||||
G4bool G4DNAIRT_geometries::TestReactibility(const G4Track& /*trackA*/,
|
||||
const G4Track& /*trackB*/,
|
||||
G4double /*currentStepTime*/,
|
||||
G4bool /*userStepTimeLimit*/) /*const*/
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void G4DNAIRT_geometries::SetReactionModel(G4VDNAReactionModel* model)
|
||||
{
|
||||
fpReactionModel = model;
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
#include "G4DNAUpdateSystemModel.hh"
|
||||
#include "G4Molecule.hh"
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4MoleculeCounter.hh"
|
||||
#include "G4DNAScavengerMaterial.hh"
|
||||
#include "G4Scheduler.hh"
|
||||
G4DNAUpdateSystemModel::G4DNAUpdateSystemModel()
|
||||
: G4VUpdateSystemModel()
|
||||
, fpMesh(nullptr)
|
||||
, fVerbose(0)
|
||||
, fGlobalTime(DBL_MAX)
|
||||
{}
|
||||
|
||||
void G4DNAUpdateSystemModel::SetMesh(G4DNAMesh* pMesh) { fpMesh = pMesh; }
|
||||
void G4DNAUpdateSystemModel::KillMolecule(const Index& index, MolType type)
|
||||
{
|
||||
// kill normal molecule
|
||||
auto& node = fpMesh->GetVoxelMapList(index);
|
||||
auto iter = node.find(type);
|
||||
if(iter != node.end())
|
||||
{
|
||||
if(iter->second <= 0)
|
||||
{
|
||||
G4cout << "G4DNAUpdateSystemModel::KillMolecule::molecule : "
|
||||
<< type->GetName() << " index : " << index
|
||||
<< " number : " << iter->second << G4endl;
|
||||
assert(false);
|
||||
}
|
||||
iter->second--;
|
||||
if(G4VMoleculeCounter::Instance()->InUse())
|
||||
{
|
||||
G4VMoleculeCounter::Instance()->RemoveAMoleculeAtTime(type, fGlobalTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
|
||||
G4Scheduler::Instance()->GetScavengerMaterial());
|
||||
if(pScavengerMaterial != nullptr)
|
||||
{
|
||||
pScavengerMaterial->ReduceNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
type, fGlobalTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "index : " << index << " " << type->GetName() << G4endl;
|
||||
G4cout << "This molecule is not belong scavengers or particle-base"
|
||||
<< G4endl;
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAUpdateSystemModel::JumpTo(const Index& index, MolType type)
|
||||
{
|
||||
auto& node = fpMesh->GetVoxelMapList(index);
|
||||
|
||||
auto iter = node.find(type);
|
||||
if(iter != node.end())
|
||||
{
|
||||
if(iter->second <= 0)
|
||||
{
|
||||
G4cout << "G4DNAUpdateSystemModel::KillMolecule::molecule : "
|
||||
<< type->GetName() << " index : " << index
|
||||
<< " number : " << iter->second << G4endl;
|
||||
assert(false);
|
||||
}
|
||||
iter->second--;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "index : " << index << " " << type->GetName() << G4endl;
|
||||
G4cout << "This molecule is not belong particle-base" << G4endl;
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAUpdateSystemModel::CreateMolecule(const Index& index, MolType type)
|
||||
{
|
||||
// for scavenger
|
||||
auto pScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
|
||||
G4Scheduler::Instance()->GetScavengerMaterial());
|
||||
if(pScavengerMaterial != nullptr && pScavengerMaterial->find(type))
|
||||
{
|
||||
pScavengerMaterial->AddNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
type, fGlobalTime);
|
||||
return;
|
||||
}
|
||||
// for molecule
|
||||
auto& node = fpMesh->GetVoxelMapList(index);
|
||||
auto iter = node.find(type);
|
||||
if(iter != node.end())
|
||||
{
|
||||
iter->second++;
|
||||
}
|
||||
else
|
||||
{
|
||||
node[type] = 1;
|
||||
}
|
||||
|
||||
if(G4VMoleculeCounter::Instance()->InUse())
|
||||
{
|
||||
G4VMoleculeCounter::Instance()->AddAMoleculeAtTime(type, fGlobalTime);
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAUpdateSystemModel::JumpIn(const Index& index, MolType type)
|
||||
{
|
||||
// for molecule
|
||||
auto& node = fpMesh->GetVoxelMapList(index);
|
||||
auto iter = node.find(type);
|
||||
if(iter != node.end())
|
||||
{
|
||||
iter->second++;
|
||||
}
|
||||
else
|
||||
{
|
||||
node[type] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAUpdateSystemModel::UpdateSystem(const Index& index,
|
||||
const ReactionData& data)
|
||||
{
|
||||
auto reactant1 = data.GetReactant1();
|
||||
auto reactant2 = data.GetReactant2();
|
||||
#ifdef G4VERBOSE
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << "At time : " << std::setw(7) << G4BestUnit(fGlobalTime, "Time")
|
||||
<< " Reaction : " << reactant1->GetName() << " + "
|
||||
<< reactant2->GetName() << " -> ";
|
||||
}
|
||||
#endif
|
||||
const G4int nbProducts = data.GetNbProducts();
|
||||
if(nbProducts != 0)
|
||||
{
|
||||
for(size_t j = 0; j < (size_t) nbProducts; ++j)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if((fVerbose != 0) && j != 0)
|
||||
{
|
||||
G4cout << " + ";
|
||||
}
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << data.GetProduct(j)->GetName();
|
||||
// for test
|
||||
// G4cout<<" fGlobalTime : "<<fGlobalTime;
|
||||
// end fortest
|
||||
}
|
||||
#endif
|
||||
CreateMolecule(index, data.GetProduct(j));
|
||||
//#define DEBUG 1
|
||||
|
||||
#ifdef DEBUG
|
||||
if(G4MoleculeCounter::Instance()->InUse())
|
||||
if(fpMesh->GetNumberOfType(data.GetProduct(j)) !=
|
||||
G4MoleculeCounter::Instance()->GetCurrentNumberOf(
|
||||
data.GetProduct(j)))
|
||||
{
|
||||
G4cout << "*********G4DNAUpdateSystemModel::DEBUG::GetNumberOfType("
|
||||
<< data.GetProduct(j)->GetName()
|
||||
<< ") : " << fpMesh->GetNumberOfType(data.GetProduct(j))
|
||||
<< G4endl;
|
||||
G4cout << "G4MoleculeCounter::GetCurrentNumberOf ("
|
||||
<< data.GetProduct(j)->GetName() << ") : "
|
||||
<< G4MoleculeCounter::Instance()->GetCurrentNumberOf(
|
||||
data.GetProduct(j))
|
||||
<< G4endl;
|
||||
G4MoleculeCounter::Instance()->Dump();
|
||||
throw;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << "No product";
|
||||
// for test
|
||||
// G4cout<<" fGlobalTime : "<<fGlobalTime;
|
||||
// end fortest
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
}
|
||||
#endif
|
||||
KillMolecule(index, reactant1);
|
||||
#ifdef DEBUG
|
||||
if(G4MoleculeCounter::Instance()->InUse())
|
||||
if(fpMesh->GetNumberOfType(reactant1) !=
|
||||
G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant1))
|
||||
{
|
||||
G4cout << "*********G4DNAUpdateSystemModel::DEBUG::GetNumberOfType("
|
||||
<< reactant1->GetName()
|
||||
<< ") : " << fpMesh->GetNumberOfType(reactant1) << G4endl;
|
||||
G4cout << "G4MoleculeCounter::GetCurrentNumberOf ("
|
||||
<< reactant1->GetName() << ") : "
|
||||
<< G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant1)
|
||||
<< G4endl;
|
||||
G4MoleculeCounter::Instance()->Dump();
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
KillMolecule(index, reactant2);
|
||||
#ifdef DEBUG
|
||||
|
||||
if(G4MoleculeCounter::Instance()->InUse())
|
||||
if(fpMesh->GetNumberOfType(reactant2) !=
|
||||
G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant2))
|
||||
{
|
||||
G4cout << "*********G4DNAUpdateSystemModel::DEBUG::GetNumberOfType("
|
||||
<< reactant2->GetName()
|
||||
<< ") : " << fpMesh->GetNumberOfType(reactant2) << G4endl;
|
||||
G4cout << "G4MoleculeCounter::GetCurrentNumberOf ("
|
||||
<< reactant2->GetName() << ") : "
|
||||
<< G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant2)
|
||||
<< G4endl;
|
||||
G4MoleculeCounter::Instance()->Dump();
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void G4DNAUpdateSystemModel::UpdateSystem(const Index& index,
|
||||
const JumpingData& data)
|
||||
{
|
||||
auto reactant = std::get<0>(data);
|
||||
auto JunpToIndex = std::get<1>(data);
|
||||
#ifdef G4VERBOSE
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << "At time : " << std::setw(7) << G4BestUnit(fGlobalTime, "Time")
|
||||
<< " Jumping : " << reactant->GetName() << " from " << index
|
||||
<< " -> " << JunpToIndex << G4endl;
|
||||
}
|
||||
#endif
|
||||
JumpTo(index, reactant);
|
||||
JumpIn(JunpToIndex, reactant);
|
||||
}
|
||||
@@ -68,16 +68,13 @@ G4double G4VLEPTSModel::GetMeanFreePath(const G4Material* aMaterial,
|
||||
const G4ParticleDefinition* ,
|
||||
G4double kineticEnergy )
|
||||
{
|
||||
|
||||
G4double MeanFreePath;
|
||||
G4bool isOutRange ;
|
||||
|
||||
if( verboseLevel >= 3 ) G4cout << aMaterial->GetIndex() << " G4VLEPTSModel::GetMeanFreePath " << kineticEnergy << " > " << theHighestEnergyLimit << " < " << theLowestEnergyLimit << G4endl;
|
||||
if (kineticEnergy > theHighestEnergyLimit || kineticEnergy < theLowestEnergyLimit)
|
||||
MeanFreePath = DBL_MAX;
|
||||
else
|
||||
MeanFreePath = (*theMeanFreePathTable)(aMaterial->GetIndex())->
|
||||
GetValue(kineticEnergy, isOutRange);
|
||||
MeanFreePath = (*theMeanFreePathTable)(aMaterial->GetIndex())->Value(kineticEnergy);
|
||||
|
||||
return MeanFreePath;
|
||||
}
|
||||
@@ -184,8 +181,8 @@ void G4VLEPTSModel::BuildMeanFreePathTable( const G4Material* aMaterial, std::ma
|
||||
G4PhysicsLogVector* ptrVector = new G4PhysicsLogVector(theLowestEnergyLimit, theHighestEnergyLimit, theNumbBinTable);
|
||||
|
||||
for (G4int ii=0; ii < theNumbBinTable; ii++) {
|
||||
LowEdgeEnergy = ptrVector->GetLowEdgeEnergy(ii);
|
||||
if( verboseLevel >= 2 ) G4cout << GetName() << " " << ii << " LowEdgeEnergy " << LowEdgeEnergy << " > " << theLowestEnergyLimit << " < " << theHighestEnergyLimit << G4endl;
|
||||
LowEdgeEnergy = ptrVector->Energy(ii);
|
||||
if( verboseLevel >= 2 ) G4cout << GetName() << " " << ii << " Energy " << LowEdgeEnergy << " > " << theLowestEnergyLimit << " < " << theHighestEnergyLimit << G4endl;
|
||||
//- fValue = ComputeMFP(LowEdgeEnergy, material, aParticleName);
|
||||
fValue = 0.;
|
||||
if( LowEdgeEnergy >= theLowestEnergyLimit &&
|
||||
|
||||
Reference in New Issue
Block a user