Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -14,6 +14,41 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------*
|
||||
|
||||
8-11-2021, H. Tran, emdna-V10-07-15
|
||||
- corrected Circular dependencies for mesoscopic model
|
||||
- corrected the problem in IRT
|
||||
|
||||
4-11-2021, H. Tran, emdna-V10-07-14
|
||||
- define a G4FakeParticleID::fLastValue in the header file,
|
||||
delete G4FakeParticleID.cc,
|
||||
solve arithmetic problems,
|
||||
Added new mesoscopic model for dna chemistry
|
||||
|
||||
21-10-2021, W.G.Shin, emdna-V10-07-13
|
||||
- Added a virtual classes for DNA geometry - G4VDNAMolecularGeometry
|
||||
Modified classes - G4DNAIRT, G4DNAIRTMoleculeEncounterStepper,
|
||||
G4ITModelProcessor, G4Scheduler,
|
||||
G4DNAMolecularReactionTable
|
||||
|
||||
23-09-2021, A. Ribon, emdna-V10-07-12
|
||||
- G4ITTransportation, G4DNAElastic, G4DNAExcitation, G4DNAIonisation,
|
||||
G4DNAVibExcitation, G4DNAAttachment, G4DNAChargeDecrease,
|
||||
G4DNAChargeIncrease, G4DNAElectronSolvation, G4DNAMolecularDissociation,
|
||||
G4DNASecondOrderReaction, G4DNAElectronHoleRecombination,
|
||||
G4DNABrownianTransportation : replaced hardwired process-sub-types
|
||||
with enum values introduced in the new class G4LowEnergyEmProcessSubType
|
||||
|
||||
18-07-2021, V. Ivanchenko, emdna-V10-07-11
|
||||
- G4DNABohrExcitationModel2, G4DNABohrIonisationModel2,
|
||||
G4VLEPSModel - updated interfaces to G4PhysicsVector
|
||||
|
||||
16-07-2021, D. Sakata, emdna-V10-07-10
|
||||
- Fixed initialization error in G4DNAELSEPAElasticModel
|
||||
|
||||
28-06-2021, G. Cosmo, emdna-V10-07-09
|
||||
- Fixed compilation error in G4ITMultiNavigator when compiling with c++20
|
||||
enabled.
|
||||
|
||||
31-05-2021, D.Sakata S. Guatelli, emdna-V10-07-08
|
||||
- Added new classes G4DNADiracRMatrixExcitationModel
|
||||
G4DNAQuinnPlasmonExcitationModel
|
||||
|
||||
@@ -33,166 +33,121 @@
|
||||
#include "G4ThreeVector.hh"
|
||||
class G4DNABoundingBox
|
||||
{
|
||||
public:
|
||||
G4DNABoundingBox() = default;
|
||||
~G4DNABoundingBox() = default;
|
||||
template <typename Iterator>
|
||||
G4DNABoundingBox(Iterator begin, Iterator end);
|
||||
G4DNABoundingBox(std::initializer_list<G4double> l);
|
||||
G4DNABoundingBox(G4DNABoundingBox&& rhs) noexcept;
|
||||
G4DNABoundingBox(const G4DNABoundingBox&) = default;
|
||||
G4DNABoundingBox& operator = (const G4DNABoundingBox&) = default;
|
||||
G4DNABoundingBox& operator = (G4DNABoundingBox&& hrs)noexcept;
|
||||
G4bool contains(const G4DNABoundingBox& other) const;
|
||||
G4bool contains(const G4ThreeVector& point) const;
|
||||
G4bool overlap(const G4DNABoundingBox& other, G4DNABoundingBox* out) const;
|
||||
G4bool overlap(const G4ThreeVector& query, const G4double& radius) const;
|
||||
G4bool contains(const G4ThreeVector& query, const G4ThreeVector& Point, const G4double& Radius) const;
|
||||
G4bool contains(const G4ThreeVector& query, const G4double& radius) const;
|
||||
G4double Volume() const;
|
||||
std::array<G4DNABoundingBox,8> partition() const;
|
||||
friend std::ostream& operator<<(std::ostream& s, const G4DNABoundingBox& rhs);
|
||||
G4bool operator == (const G4DNABoundingBox& rhs) const;
|
||||
G4bool operator != (const G4DNABoundingBox& rhs) const;
|
||||
void resize(G4ThreeVector pics[8]);
|
||||
G4DNABoundingBox translate(const G4ThreeVector& trans) const;
|
||||
inline G4double halfSideLengthInX() const;
|
||||
inline G4double halfSideLengthInY() const;
|
||||
inline G4double halfSideLengthInZ() const;
|
||||
inline G4double Getxhi() const;
|
||||
inline G4double Getyhi() const;
|
||||
inline G4double Getzhi() const;
|
||||
inline G4double Getxlo() const;
|
||||
inline G4double Getylo() const;
|
||||
inline G4double Getzlo() const;
|
||||
inline void Setxhi(G4double);
|
||||
inline void Setyhi(G4double);
|
||||
inline void Setzhi(G4double);
|
||||
inline void Setxlo(G4double);
|
||||
inline void Setylo(G4double);
|
||||
inline void Setzlo(G4double);
|
||||
inline G4ThreeVector middlePoint() const;
|
||||
private:
|
||||
G4double fxhi, fxlo, fyhi, fylo, fzhi, fzlo;
|
||||
public:
|
||||
G4DNABoundingBox() = default;
|
||||
~G4DNABoundingBox() = default;
|
||||
template <typename Iterator>
|
||||
G4DNABoundingBox(Iterator begin, Iterator end);
|
||||
G4DNABoundingBox(const std::initializer_list<G4double>& l);
|
||||
G4DNABoundingBox(G4DNABoundingBox&& rhs) noexcept;
|
||||
G4DNABoundingBox(const G4DNABoundingBox&) = default;
|
||||
G4DNABoundingBox& operator=(const G4DNABoundingBox&) = default;
|
||||
G4DNABoundingBox& operator=(G4DNABoundingBox&& hrs) noexcept;
|
||||
G4bool contains(const G4DNABoundingBox& other) const;
|
||||
G4bool contains(const G4ThreeVector& point) const;
|
||||
G4bool overlap(const G4DNABoundingBox& other, G4DNABoundingBox* out) const;
|
||||
G4bool overlap(const G4ThreeVector& query, const G4double& radius) const;
|
||||
G4bool contains(const G4ThreeVector& query, const G4ThreeVector& Point,
|
||||
const G4double& Radius) const;
|
||||
G4bool contains(const G4ThreeVector& query, const G4double& radius) const;
|
||||
G4double Volume() const;
|
||||
std::array<G4DNABoundingBox, 8> partition() const;
|
||||
friend std::ostream& operator<<(std::ostream& s, const G4DNABoundingBox& rhs);
|
||||
G4bool operator==(const G4DNABoundingBox& rhs) const;
|
||||
G4bool operator!=(const G4DNABoundingBox& rhs) const;
|
||||
void resize(G4ThreeVector pics[8]);
|
||||
G4DNABoundingBox translate(const G4ThreeVector& trans) const;
|
||||
inline G4double halfSideLengthInX() const;
|
||||
inline G4double halfSideLengthInY() const;
|
||||
inline G4double halfSideLengthInZ() const;
|
||||
inline G4double Getxhi() const;
|
||||
inline G4double Getyhi() const;
|
||||
inline G4double Getzhi() const;
|
||||
inline G4double Getxlo() const;
|
||||
inline G4double Getylo() const;
|
||||
inline G4double Getzlo() const;
|
||||
inline G4ThreeVector middlePoint() const;
|
||||
|
||||
private:
|
||||
G4double fxhi, fxlo, fyhi, fylo, fzhi, fzlo;
|
||||
};
|
||||
|
||||
const G4DNABoundingBox initial = G4DNABoundingBox{
|
||||
-std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
|
||||
-std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
|
||||
-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()
|
||||
-std::numeric_limits<G4double>::max(), std::numeric_limits<G4double>::max(),
|
||||
-std::numeric_limits<G4double>::max(), std::numeric_limits<G4double>::max(),
|
||||
-std::numeric_limits<G4double>::max(), std::numeric_limits<G4double>::max()
|
||||
};
|
||||
const G4DNABoundingBox invalid =
|
||||
G4DNABoundingBox{
|
||||
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()
|
||||
};
|
||||
G4DNABoundingBox{ std::numeric_limits<G4double>::quiet_NaN(),
|
||||
std::numeric_limits<G4double>::quiet_NaN(),
|
||||
std::numeric_limits<G4double>::quiet_NaN(),
|
||||
std::numeric_limits<G4double>::quiet_NaN(),
|
||||
std::numeric_limits<G4double>::quiet_NaN(),
|
||||
std::numeric_limits<G4double>::quiet_NaN() };
|
||||
|
||||
inline G4ThreeVector G4DNABoundingBox::middlePoint() const
|
||||
{
|
||||
G4ThreeVector mid((fxhi + fxlo)/2.0,(fyhi + fylo)/2.0,(fzhi + fzlo)/2.0);
|
||||
return mid;
|
||||
G4ThreeVector mid((fxhi + fxlo) / 2.0, (fyhi + fylo) / 2.0,
|
||||
(fzhi + fzlo) / 2.0);
|
||||
return mid;
|
||||
}
|
||||
|
||||
inline G4double G4DNABoundingBox::halfSideLengthInX() const
|
||||
{
|
||||
return std::abs(fxhi - fxlo)*0.5;
|
||||
return std::abs(fxhi - fxlo) * 0.5;
|
||||
}
|
||||
|
||||
inline G4double G4DNABoundingBox::halfSideLengthInY() const
|
||||
{
|
||||
return std::abs(fyhi - fylo)*0.5;
|
||||
return std::abs(fyhi - fylo) * 0.5;
|
||||
}
|
||||
|
||||
inline G4double G4DNABoundingBox::halfSideLengthInZ() const
|
||||
{
|
||||
return std::abs(fzhi - fzlo)*0.5;
|
||||
return std::abs(fzhi - fzlo) * 0.5;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
G4DNABoundingBox::G4DNABoundingBox(Iterator begin, Iterator end)
|
||||
: G4DNABoundingBox(initial)
|
||||
: G4DNABoundingBox(initial)
|
||||
{
|
||||
for (; begin != end; ++begin)
|
||||
for(; begin != end; ++begin)
|
||||
{
|
||||
const G4ThreeVector& point = (*begin);
|
||||
|
||||
if(point.x() < fxlo)
|
||||
{
|
||||
const G4ThreeVector& point = (*begin);
|
||||
|
||||
if (point.x() < fxlo)
|
||||
{
|
||||
fxlo = point.x();
|
||||
}
|
||||
if (point.x() > fxhi)
|
||||
{
|
||||
fxhi = point.x();
|
||||
}
|
||||
|
||||
if (point.y() < fylo)
|
||||
{
|
||||
fylo = point.y();
|
||||
}
|
||||
if (point.y() > fyhi)
|
||||
{
|
||||
fyhi = point.y();
|
||||
}
|
||||
|
||||
if (point.z() < fzlo)
|
||||
{
|
||||
fzlo = point.z();
|
||||
}
|
||||
if (point.z() > fzhi)
|
||||
{
|
||||
fzhi = point.z();
|
||||
}
|
||||
fxlo = point.x();
|
||||
}
|
||||
if(point.x() > fxhi)
|
||||
{
|
||||
fxhi = point.x();
|
||||
}
|
||||
|
||||
if(point.y() < fylo)
|
||||
{
|
||||
fylo = point.y();
|
||||
}
|
||||
if(point.y() > fyhi)
|
||||
{
|
||||
fyhi = point.y();
|
||||
}
|
||||
|
||||
if(point.z() < fzlo)
|
||||
{
|
||||
fzlo = point.z();
|
||||
}
|
||||
if(point.z() > fzhi)
|
||||
{
|
||||
fzhi = point.z();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline G4double G4DNABoundingBox::Getxhi() const
|
||||
{
|
||||
return fxhi;
|
||||
}
|
||||
inline G4double G4DNABoundingBox::Getyhi() const
|
||||
{
|
||||
return fyhi;
|
||||
}
|
||||
inline G4double G4DNABoundingBox::Getzhi() const
|
||||
{
|
||||
return fzhi;
|
||||
}
|
||||
inline G4double G4DNABoundingBox::Getxlo() const
|
||||
{
|
||||
return fxlo;
|
||||
}
|
||||
inline G4double G4DNABoundingBox::Getylo() const
|
||||
{
|
||||
return fylo;
|
||||
}
|
||||
inline G4double G4DNABoundingBox::Getzlo() const
|
||||
{
|
||||
return fzlo;
|
||||
}
|
||||
inline void G4DNABoundingBox::Setxhi(G4double limit)
|
||||
{
|
||||
fxhi = limit;
|
||||
}
|
||||
inline void G4DNABoundingBox::Setyhi(G4double limit)
|
||||
{
|
||||
fyhi = limit;
|
||||
}
|
||||
inline void G4DNABoundingBox::Setzhi(G4double limit)
|
||||
{
|
||||
fzhi = limit;
|
||||
}
|
||||
inline void G4DNABoundingBox::Setxlo(G4double limit)
|
||||
{
|
||||
fxlo = limit;
|
||||
}
|
||||
inline void G4DNABoundingBox::Setylo(G4double limit)
|
||||
{
|
||||
fylo = limit;
|
||||
}
|
||||
inline void G4DNABoundingBox::Setzlo(G4double limit)
|
||||
{
|
||||
fzlo = limit;
|
||||
}
|
||||
inline G4double G4DNABoundingBox::Getxhi() const { return fxhi; }
|
||||
inline G4double G4DNABoundingBox::Getyhi() const { return fyhi; }
|
||||
inline G4double G4DNABoundingBox::Getzhi() const { return fzhi; }
|
||||
inline G4double G4DNABoundingBox::Getxlo() const { return fxlo; }
|
||||
inline G4double G4DNABoundingBox::Getylo() const { return fylo; }
|
||||
inline G4double G4DNABoundingBox::Getzlo() const { return fzlo; }
|
||||
#endif
|
||||
|
||||
|
||||
@@ -82,11 +82,11 @@ template<>
|
||||
class G4TrackState<G4ITMultiNavigator> : public G4TrackState<G4ITNavigator>
|
||||
{
|
||||
public:
|
||||
~G4TrackState<G4ITMultiNavigator>()
|
||||
~G4TrackState()
|
||||
{
|
||||
}
|
||||
|
||||
G4TrackState<G4ITMultiNavigator>()
|
||||
G4TrackState()
|
||||
{
|
||||
G4ThreeVector Big3Vector(kInfinity, kInfinity, kInfinity);
|
||||
fLastLocatedPosition = Big3Vector;
|
||||
|
||||
@@ -116,10 +116,10 @@ protected:
|
||||
G4int fLastStepNo, fCurrentStepNo;
|
||||
|
||||
public:
|
||||
virtual ~G4TrackState<G4ITPathFinder>(){}
|
||||
virtual ~G4TrackState(){}
|
||||
|
||||
G4TrackState<G4ITPathFinder>() :
|
||||
G4TrackStateBase<G4ITPathFinder>(),
|
||||
G4TrackState() :
|
||||
G4TrackStateBase(),
|
||||
fEndState( G4ThreeVector(), G4ThreeVector(), 0., 0., 0., 0., 0.),
|
||||
fFieldExertedForce(false),
|
||||
fRelocatedPoint(true),
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "G4ITTrackHolder.hh"
|
||||
#include "G4VStateDependent.hh"
|
||||
#include "G4ITReaction.hh"
|
||||
#include "G4VScavengerMaterial.hh"
|
||||
|
||||
class G4ITTrackingManager;
|
||||
class G4ITModelProcessor;
|
||||
@@ -74,7 +75,7 @@ class G4ITGun;
|
||||
#define compTrackPerID__
|
||||
struct compTrackPerID
|
||||
{
|
||||
bool operator()(G4Track* rhs, G4Track* lhs) const
|
||||
G4bool operator()(G4Track* rhs, G4Track* lhs) const
|
||||
{
|
||||
return rhs->GetTrackID() < lhs->GetTrackID();
|
||||
}
|
||||
@@ -99,12 +100,12 @@ public:
|
||||
static void DeleteInstance();
|
||||
virtual G4bool Notify(G4ApplicationState requestedState);
|
||||
|
||||
virtual void RegisterModel(G4VITStepModel*, double);
|
||||
virtual void RegisterModel(G4VITStepModel*, G4double);
|
||||
|
||||
void Initialize();
|
||||
void ForceReinitialization();
|
||||
inline bool IsInitialized();
|
||||
inline bool IsRunning(){return fRunning;}
|
||||
inline G4bool IsInitialized();
|
||||
inline G4bool IsRunning(){return fRunning;}
|
||||
void Reset();
|
||||
void Process();
|
||||
void ClearList();
|
||||
@@ -121,23 +122,23 @@ public:
|
||||
// is called in case one would like to access some track information
|
||||
void EndTracking();
|
||||
|
||||
void SetEndTime(const double);
|
||||
void SetEndTime(const G4double);
|
||||
|
||||
/* Two tracks below the time tolerance are supposed to be
|
||||
* in the same time slice
|
||||
*/
|
||||
inline void SetTimeTolerance(double);
|
||||
inline double GetTimeTolerance() const;
|
||||
inline void SetTimeTolerance(G4double);
|
||||
inline G4double GetTimeTolerance() const;
|
||||
|
||||
inline void SetMaxZeroTimeAllowed(int);
|
||||
inline int GetMaxZeroTimeAllowed() const;
|
||||
inline void SetMaxZeroTimeAllowed(G4int);
|
||||
inline G4int GetMaxZeroTimeAllowed() const;
|
||||
|
||||
inline G4ITModelHandler* GetModelHandler();
|
||||
|
||||
inline void SetTimeSteps(std::map<double, double>*);
|
||||
inline void AddTimeStep(double, double);
|
||||
inline void SetDefaultTimeStep(double);
|
||||
double GetLimitingTimeStep() const;
|
||||
inline void SetTimeSteps(std::map<G4double, G4double>*);
|
||||
inline void AddTimeStep(G4double, G4double);
|
||||
inline void SetDefaultTimeStep(G4double);
|
||||
G4double GetLimitingTimeStep() const;
|
||||
inline G4int GetNbSteps() const;
|
||||
inline void SetMaxNbSteps(G4int);
|
||||
inline G4int GetMaxNbSteps() const;
|
||||
@@ -160,9 +161,9 @@ public:
|
||||
* 3 : (2) + step info for individual tracks
|
||||
* 4 : (2) + trackList processing info + pushed and killed track info
|
||||
*/
|
||||
inline void SetVerbose(int);
|
||||
inline void SetVerbose(G4int);
|
||||
|
||||
inline int GetVerbose() const;
|
||||
inline G4int GetVerbose() const;
|
||||
|
||||
inline void WhyDoYouStop();
|
||||
|
||||
@@ -173,23 +174,32 @@ public:
|
||||
|
||||
void GetCollisionType(G4String& interactionType);
|
||||
|
||||
void AddWatchedTime(double time)
|
||||
void AddWatchedTime(G4double time)
|
||||
{
|
||||
fWatchedTimes.insert(time);
|
||||
}
|
||||
|
||||
double GetNextWatchedTime() const;
|
||||
G4double GetNextWatchedTime() const;
|
||||
|
||||
inline void SetMaxTimeStep(double maxTimeStep)
|
||||
inline void SetMaxTimeStep(G4double maxTimeStep)
|
||||
{
|
||||
fMaxTimeStep = maxTimeStep;
|
||||
}
|
||||
|
||||
inline double GetMaxTimeStep() const
|
||||
inline G4double GetMaxTimeStep() const
|
||||
{
|
||||
return fMaxTimeStep;
|
||||
}
|
||||
|
||||
inline G4VScavengerMaterial* GetScavengerMaterial() const
|
||||
{
|
||||
return fpUserScavenger.get();
|
||||
}
|
||||
inline void SetScavengerMaterial(std::unique_ptr<G4VScavengerMaterial> scavengerMaterial)
|
||||
{
|
||||
fpUserScavenger = std::move(scavengerMaterial);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void DoProcess();
|
||||
@@ -198,7 +208,7 @@ protected:
|
||||
|
||||
void FindUserPreDefinedTimeStep();
|
||||
|
||||
bool CanICarryOn();
|
||||
G4bool CanICarryOn();
|
||||
|
||||
void PrintWhyDoYouStop();
|
||||
|
||||
@@ -211,46 +221,48 @@ private:
|
||||
G4SchedulerMessenger* fpMessenger;
|
||||
|
||||
static G4ThreadLocal G4Scheduler* fgScheduler;
|
||||
int fVerbose;
|
||||
bool fWhyDoYouStop;
|
||||
bool fInitialized;
|
||||
bool fRunning;
|
||||
G4int fVerbose;
|
||||
G4bool fWhyDoYouStop;
|
||||
G4bool fInitialized;
|
||||
G4bool fRunning;
|
||||
G4bool fContinue;
|
||||
|
||||
int fNbSteps;
|
||||
int fMaxSteps;
|
||||
G4int fNbSteps;
|
||||
G4int fMaxSteps;
|
||||
|
||||
G4ITStepStatus fITStepStatus;
|
||||
|
||||
// Time members
|
||||
G4bool fUseDefaultTimeSteps;
|
||||
double fTimeTolerance;
|
||||
double fGlobalTime;
|
||||
double fTmpGlobalTime;
|
||||
double fStartTime;
|
||||
double fStopTime;
|
||||
double fEndTime;
|
||||
double fPreviousTimeStep;
|
||||
int fZeroTimeCount;
|
||||
int fMaxNZeroTimeStepsAllowed;
|
||||
G4double fTimeTolerance;
|
||||
G4double fGlobalTime;
|
||||
G4double fTmpGlobalTime;
|
||||
G4double fStartTime;
|
||||
G4double fStopTime;
|
||||
G4double fEndTime;
|
||||
G4double fPreviousTimeStep;
|
||||
G4int fZeroTimeCount;
|
||||
G4int fMaxNZeroTimeStepsAllowed;
|
||||
|
||||
double fTimeStep; // The selected minimum time step
|
||||
double fMaxTimeStep;
|
||||
G4double fTimeStep; // The selected minimum time step
|
||||
G4double fMaxTimeStep;
|
||||
|
||||
// User steps
|
||||
bool fUsePreDefinedTimeSteps;
|
||||
double fDefaultMinTimeStep;
|
||||
std::map<double, double>* fpUserTimeSteps;
|
||||
G4bool fUsePreDefinedTimeSteps;
|
||||
G4double fDefaultMinTimeStep;
|
||||
std::map<G4double, G4double>* fpUserTimeSteps;
|
||||
// One can give time steps in respect to the global time
|
||||
mutable double fUserUpperTimeLimit;
|
||||
double fDefinedMinTimeStep;
|
||||
mutable G4double fUserUpperTimeLimit;
|
||||
G4double fDefinedMinTimeStep;
|
||||
// selected user time step in respect to the global time
|
||||
bool fReachedUserTimeLimit; // if fMinTimeStep == the user time step
|
||||
G4bool fReachedUserTimeLimit; // if fMinTimeStep == the user time step
|
||||
|
||||
std::set<double> fWatchedTimes;
|
||||
std::set<G4double> fWatchedTimes;
|
||||
|
||||
G4UserTimeStepAction* fpUserTimeStepAction;
|
||||
|
||||
std::unique_ptr<G4VScavengerMaterial> fpUserScavenger;
|
||||
|
||||
// ==========================================
|
||||
// TO BE REMOVED
|
||||
G4ITStepProcessor* fpStepProcessor;
|
||||
@@ -262,24 +274,26 @@ private:
|
||||
G4ITModelHandler* fpModelHandler;
|
||||
// ==========================================
|
||||
|
||||
double fTSTimeStep;
|
||||
G4double fTSTimeStep;
|
||||
// Time calculated by the time stepper in CalculateMinTimeStep()
|
||||
double fILTimeStep;
|
||||
G4double fILTimeStep;
|
||||
// Time calculated by the interaction length methods
|
||||
// in ComputeInteractionLength()
|
||||
|
||||
bool fInteractionStep;
|
||||
G4bool fInteractionStep;
|
||||
// Flag : if the step is driven by the interaction with the matter and
|
||||
// NOT by the reaction between tracks
|
||||
|
||||
G4ITGun* fpGun;
|
||||
|
||||
// ==========================================
|
||||
//
|
||||
|
||||
//Hoang
|
||||
bool fResetScavenger;
|
||||
public:
|
||||
void ResetScavenger(bool);
|
||||
};
|
||||
|
||||
inline bool G4Scheduler::IsInitialized()
|
||||
inline G4bool G4Scheduler::IsInitialized()
|
||||
{
|
||||
return fInitialized;
|
||||
}
|
||||
@@ -289,23 +303,23 @@ inline G4ITModelHandler* G4Scheduler::GetModelHandler()
|
||||
return fpModelHandler;
|
||||
}
|
||||
|
||||
inline void G4Scheduler::SetEndTime(const double __endtime)
|
||||
inline void G4Scheduler::SetEndTime(const G4double __endtime)
|
||||
{
|
||||
fEndTime = __endtime;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4Scheduler::SetTimeSteps(std::map<double, double>* steps)
|
||||
void G4Scheduler::SetTimeSteps(std::map<G4double, G4double>* steps)
|
||||
{
|
||||
fUsePreDefinedTimeSteps = true;
|
||||
fpUserTimeSteps = steps;
|
||||
}
|
||||
|
||||
inline void G4Scheduler::AddTimeStep(double startingTime, double timeStep)
|
||||
inline void G4Scheduler::AddTimeStep(G4double startingTime, G4double timeStep)
|
||||
{
|
||||
if (fpUserTimeSteps == 0)
|
||||
{
|
||||
fpUserTimeSteps = new std::map<double, double>();
|
||||
fpUserTimeSteps = new std::map<G4double, G4double>();
|
||||
fUsePreDefinedTimeSteps = true;
|
||||
}
|
||||
|
||||
@@ -342,7 +356,7 @@ inline G4double G4Scheduler::GetTimeStep() const
|
||||
return fTimeStep;
|
||||
}
|
||||
|
||||
inline void G4Scheduler::SetDefaultTimeStep(double timeStep)
|
||||
inline void G4Scheduler::SetDefaultTimeStep(G4double timeStep)
|
||||
{
|
||||
fDefaultMinTimeStep = timeStep;
|
||||
}
|
||||
@@ -363,33 +377,33 @@ inline G4UserTimeStepAction* G4Scheduler::GetUserTimeStepAction() const
|
||||
return fpUserTimeStepAction;
|
||||
}
|
||||
|
||||
inline void G4Scheduler::SetVerbose(int verbose)
|
||||
inline void G4Scheduler::SetVerbose(G4int verbose)
|
||||
{
|
||||
fVerbose = verbose;
|
||||
}
|
||||
|
||||
inline int G4Scheduler::GetVerbose() const
|
||||
inline G4int G4Scheduler::GetVerbose() const
|
||||
{
|
||||
return fVerbose;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4Scheduler::SetMaxZeroTimeAllowed(int maxTimeStepAllowed)
|
||||
void G4Scheduler::SetMaxZeroTimeAllowed(G4int maxTimeStepAllowed)
|
||||
{
|
||||
fMaxNZeroTimeStepsAllowed = maxTimeStepAllowed;
|
||||
}
|
||||
|
||||
inline int G4Scheduler::GetMaxZeroTimeAllowed() const
|
||||
inline G4int G4Scheduler::GetMaxZeroTimeAllowed() const
|
||||
{
|
||||
return fMaxNZeroTimeStepsAllowed;
|
||||
}
|
||||
|
||||
inline void G4Scheduler::SetTimeTolerance(double time)
|
||||
inline void G4Scheduler::SetTimeTolerance(G4double time)
|
||||
{
|
||||
fTimeTolerance = time;
|
||||
}
|
||||
|
||||
inline double G4Scheduler::GetTimeTolerance() const
|
||||
inline G4double G4Scheduler::GetTimeTolerance() const
|
||||
{
|
||||
return fTimeTolerance;
|
||||
}
|
||||
@@ -439,4 +453,9 @@ inline G4bool G4Scheduler::AreDefaultTimeStepsUsed()
|
||||
return (fUseDefaultTimeSteps == false && fUsePreDefinedTimeSteps == false);
|
||||
}
|
||||
|
||||
inline void G4Scheduler::ResetScavenger(bool value)
|
||||
{
|
||||
fResetScavenger = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 G4USERMESHACTION_HH
|
||||
#define G4USERMESHACTION_HH
|
||||
|
||||
#include "G4DNAMesh.hh"
|
||||
|
||||
class G4UserMeshAction
|
||||
{
|
||||
public:
|
||||
G4UserMeshAction() = default;
|
||||
virtual ~G4UserMeshAction() = default;
|
||||
|
||||
public:
|
||||
virtual void BeginOfMesh(const G4DNAMesh* /*aMesh*/, G4double /*time*/){};
|
||||
virtual void InMesh(const G4DNAMesh* /*pMesh*/, G4double /*time*/){};
|
||||
virtual void EndOfMesh(const G4DNAMesh* /*aMesh*/, G4double /*time*/){};
|
||||
};
|
||||
#endif // G4USERMESHACTION_HH
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/*
|
||||
* G4VDNAMolecularGeometry.hh
|
||||
*
|
||||
* Created on: 10 Oct. 2021
|
||||
* Author: WG Shin
|
||||
*/
|
||||
|
||||
#ifndef G4VDNAMolecularGeometry_HH
|
||||
#define G4VDNAMolecularGeometry_HH
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
class G4VDNAMolecularGeometry
|
||||
{
|
||||
public:
|
||||
G4VDNAMolecularGeometry(){};
|
||||
virtual ~G4VDNAMolecularGeometry(){};
|
||||
|
||||
virtual void FindNearbyMolecules(const G4LogicalVolume*,
|
||||
const G4ThreeVector&,
|
||||
std::vector<G4VPhysicalVolume*>&,
|
||||
G4double){};
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
+10
-11
@@ -23,16 +23,15 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 10 Oct 2011 M.Karamitros created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#ifndef G4VSCAVENGERMATERIAL_HH
|
||||
#define G4VSCAVENGERMATERIAL_HH
|
||||
|
||||
#include "G4FakeParticleID.hh"
|
||||
|
||||
G4ThreadLocal int G4FakeParticleID::fLastValue(999666999);
|
||||
class G4VScavengerMaterial
|
||||
{
|
||||
public:
|
||||
G4VScavengerMaterial() = default;
|
||||
virtual ~G4VScavengerMaterial() = default;
|
||||
virtual void Reset() = 0;
|
||||
};
|
||||
#endif // G4VSCAVENGERMATERIAL_HH
|
||||
@@ -57,6 +57,7 @@ geant4_add_module(G4emdna-man
|
||||
G4TrackList.hh
|
||||
G4TrackState.hh
|
||||
G4UserTimeStepAction.hh
|
||||
G4VDNAMolecularGeometry.hh
|
||||
G4VITDiscreteProcess.hh
|
||||
G4VITProcess.hh
|
||||
G4VITReactionProcess.hh
|
||||
@@ -75,6 +76,8 @@ geant4_add_module(G4emdna-man
|
||||
G4ChemicalMoleculeFinder.hh
|
||||
G4DNAReactionTypeManager.hh
|
||||
G4VReactionType.hh
|
||||
G4UserMeshAction.hh
|
||||
G4VScavengerMaterial.hh
|
||||
SOURCES
|
||||
G4AllITFinder.cc
|
||||
G4ITBox.cc
|
||||
|
||||
@@ -31,258 +31,255 @@ using std::array;
|
||||
using std::initializer_list;
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4DNABoundingBox::G4DNABoundingBox(G4DNABoundingBox&& rhs)noexcept
|
||||
G4DNABoundingBox::G4DNABoundingBox(G4DNABoundingBox&& rhs) noexcept
|
||||
{
|
||||
fxhi = rhs.fxhi;
|
||||
fxlo = rhs.fxlo;
|
||||
fyhi = rhs.fyhi;
|
||||
fylo = rhs.fylo;
|
||||
fzhi = rhs.fzhi;
|
||||
fzlo = rhs.fzlo;
|
||||
fxhi = rhs.fxhi;
|
||||
fxlo = rhs.fxlo;
|
||||
fyhi = rhs.fyhi;
|
||||
fylo = rhs.fylo;
|
||||
fzhi = rhs.fzhi;
|
||||
fzlo = rhs.fzlo;
|
||||
}
|
||||
////....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4DNABoundingBox::G4DNABoundingBox(initializer_list<G4double> l)
|
||||
G4DNABoundingBox::G4DNABoundingBox(const initializer_list<G4double>& l)
|
||||
{
|
||||
std::copy(l.begin(), l.end(), &fxhi);
|
||||
std::copy(l.begin(), l.end(), &fxhi);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4DNABoundingBox& G4DNABoundingBox::operator=(G4DNABoundingBox&& rhs)noexcept
|
||||
G4DNABoundingBox& G4DNABoundingBox::operator=(G4DNABoundingBox&& rhs) noexcept
|
||||
{
|
||||
fxhi = rhs.fxhi;
|
||||
fxlo = rhs.fxlo;
|
||||
fyhi = rhs.fyhi;
|
||||
fylo = rhs.fylo;
|
||||
fzhi = rhs.fzhi;
|
||||
fzlo = rhs.fzlo;
|
||||
return *this;
|
||||
fxhi = rhs.fxhi;
|
||||
fxlo = rhs.fxlo;
|
||||
fyhi = rhs.fyhi;
|
||||
fylo = rhs.fylo;
|
||||
fzhi = rhs.fzhi;
|
||||
fzlo = rhs.fzlo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4double G4DNABoundingBox::Volume() const
|
||||
{
|
||||
auto LengthY = this->Getyhi() - this->Getylo();
|
||||
auto LengthX = this->Getxhi() - this->Getxlo();
|
||||
auto LengthZ = this->Getzhi() - this->Getzlo();
|
||||
G4double V = LengthY * LengthX * LengthZ;
|
||||
return V;
|
||||
auto LengthY = this->Getyhi() - this->Getylo();
|
||||
auto LengthX = this->Getxhi() - this->Getxlo();
|
||||
auto LengthZ = this->Getzhi() - this->Getzlo();
|
||||
G4double V = LengthY * LengthX * LengthZ;
|
||||
return V;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4DNABoundingBox::resize(G4ThreeVector pics[8])
|
||||
{
|
||||
for(size_t i = 0; i < 8; i++)
|
||||
for(size_t i = 0; i < 8; i++)
|
||||
{
|
||||
const G4ThreeVector& point = pics[i];
|
||||
if(point.x() < fxlo)
|
||||
{
|
||||
const G4ThreeVector& point = pics[i];
|
||||
if (point.x() < fxlo)
|
||||
{
|
||||
fxlo = point.x();
|
||||
}
|
||||
if (point.x() > fxhi)
|
||||
{
|
||||
fxhi = point.x();
|
||||
}
|
||||
|
||||
if (point.y() < fylo)
|
||||
{
|
||||
fylo = point.y();
|
||||
}
|
||||
if (point.y() > fyhi)
|
||||
{
|
||||
fyhi = point.y();
|
||||
}
|
||||
|
||||
if (point.z() < fzlo)
|
||||
{
|
||||
fzlo = point.z();
|
||||
}
|
||||
if (point.z() > fzhi)
|
||||
{
|
||||
fzhi = point.z();
|
||||
}
|
||||
fxlo = point.x();
|
||||
}
|
||||
if(point.x() > fxhi)
|
||||
{
|
||||
fxhi = point.x();
|
||||
}
|
||||
|
||||
if(point.y() < fylo)
|
||||
{
|
||||
fylo = point.y();
|
||||
}
|
||||
if(point.y() > fyhi)
|
||||
{
|
||||
fyhi = point.y();
|
||||
}
|
||||
|
||||
if(point.z() < fzlo)
|
||||
{
|
||||
fzlo = point.z();
|
||||
}
|
||||
if(point.z() > fzhi)
|
||||
{
|
||||
fzhi = point.z();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
G4DNABoundingBox G4DNABoundingBox::translate(const G4ThreeVector& trans) const
|
||||
{
|
||||
G4DNABoundingBox output;
|
||||
|
||||
output.fxhi = fxhi + trans.x();
|
||||
output.fxlo = fxlo + trans.x();
|
||||
G4DNABoundingBox output;
|
||||
|
||||
output.fyhi = fyhi + trans.y();
|
||||
output.fylo = fylo + trans.x();
|
||||
output.fxhi = fxhi + trans.x();
|
||||
output.fxlo = fxlo + trans.x();
|
||||
|
||||
output.fzhi = fzhi + trans.z();
|
||||
output.fzlo = fzlo + trans.z();
|
||||
output.fyhi = fyhi + trans.y();
|
||||
output.fylo = fylo + trans.x();
|
||||
|
||||
return output;
|
||||
output.fzhi = fzhi + trans.z();
|
||||
output.fzlo = fzlo + trans.z();
|
||||
|
||||
return output;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool G4DNABoundingBox::contains(const G4DNABoundingBox& other) const
|
||||
{
|
||||
return fxlo <= other.fxlo && fxhi >= other.fxhi &&
|
||||
fylo <= other.fylo && fyhi >= other.fyhi &&
|
||||
fzlo <= other.fzlo && fzhi >= other.fzhi;
|
||||
return fxlo <= other.fxlo && fxhi >= other.fxhi && fylo <= other.fylo &&
|
||||
fyhi >= other.fyhi && fzlo <= other.fzlo && fzhi >= other.fzhi;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool G4DNABoundingBox::contains(const G4ThreeVector& point) const
|
||||
{
|
||||
return fxlo <= point.x() && fxhi >= point.x() &&
|
||||
fylo <= point.y() && fyhi >= point.y() &&
|
||||
fzlo <= point.z() && fzhi >= point.z();
|
||||
return fxlo <= point.x() && fxhi >= point.x() && fylo <= point.y() &&
|
||||
fyhi >= point.y() && fzlo <= point.z() && fzhi >= point.z();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
G4bool G4DNABoundingBox::overlap(const G4DNABoundingBox& other,
|
||||
G4DNABoundingBox* out) const
|
||||
{
|
||||
if (contains(other))
|
||||
{
|
||||
*out = other;
|
||||
return true;
|
||||
} else if (other.contains(*this))
|
||||
{
|
||||
*out = *this;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if there is no intersection
|
||||
if (fxhi < other.fxlo || fxlo > other.fxhi ||
|
||||
fyhi < other.fylo || fylo > other.fyhi ||
|
||||
fzhi < other.fzlo || fzlo > other.fzhi)
|
||||
{
|
||||
*out = invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
G4double upperX = std::min(fxhi, other.fxhi);
|
||||
G4double upperY = std::min(fyhi, other.fyhi);
|
||||
G4double upperZ = std::min(fzhi, other.fzhi);
|
||||
|
||||
G4double lowerX = std::max(fxlo, other.fxlo);
|
||||
G4double lowerY = std::max(fylo, other.fylo);
|
||||
G4double lowerZ = std::max(fzlo, other.fzlo);
|
||||
|
||||
*out = G4DNABoundingBox{upperX, lowerX, upperY, lowerY, upperZ, lowerZ};
|
||||
if(contains(other))
|
||||
{
|
||||
*out = other;
|
||||
return true;
|
||||
}
|
||||
else if(other.contains(*this))
|
||||
{
|
||||
*out = *this;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if there is no intersection
|
||||
if(fxhi < other.fxlo || fxlo > other.fxhi || fyhi < other.fylo ||
|
||||
fylo > other.fyhi || fzhi < other.fzlo || fzlo > other.fzhi)
|
||||
{
|
||||
*out = invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
G4double upperX = std::min(fxhi, other.fxhi);
|
||||
G4double upperY = std::min(fyhi, other.fyhi);
|
||||
G4double upperZ = std::min(fzhi, other.fzhi);
|
||||
|
||||
G4double lowerX = std::max(fxlo, other.fxlo);
|
||||
G4double lowerY = std::max(fylo, other.fylo);
|
||||
G4double lowerZ = std::max(fzlo, other.fzlo);
|
||||
|
||||
*out = G4DNABoundingBox{ upperX, lowerX, upperY, lowerY, upperZ, lowerZ };
|
||||
return true;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool G4DNABoundingBox::overlap(const G4ThreeVector& query, const G4double& Radius) const
|
||||
G4bool G4DNABoundingBox::overlap(const G4ThreeVector& query,
|
||||
const G4double& Radius) const
|
||||
{
|
||||
G4double x = query.x() - this->middlePoint().x();
|
||||
G4double y = query.y() - this->middlePoint().y();
|
||||
G4double z = query.z() - this->middlePoint().z();
|
||||
G4double x = query.x() - this->middlePoint().x();
|
||||
G4double y = query.y() - this->middlePoint().y();
|
||||
G4double z = query.z() - this->middlePoint().z();
|
||||
|
||||
x = std::abs(x);
|
||||
y = std::abs(y);
|
||||
z = std::abs(z);
|
||||
x = std::abs(x);
|
||||
y = std::abs(y);
|
||||
z = std::abs(z);
|
||||
|
||||
if ((x> (Radius + this->halfSideLengthInX()))||
|
||||
(y> (Radius + this->halfSideLengthInY()))||
|
||||
(z> (Radius + this->halfSideLengthInZ())))
|
||||
{
|
||||
return false;//
|
||||
}
|
||||
G4int num_less_extent =
|
||||
(x < this->halfSideLengthInX()) +
|
||||
(y < this->halfSideLengthInY()) +
|
||||
(z < this->halfSideLengthInZ());
|
||||
if((x > (Radius + this->halfSideLengthInX())) ||
|
||||
(y > (Radius + this->halfSideLengthInY())) ||
|
||||
(z > (Radius + this->halfSideLengthInZ())))
|
||||
{
|
||||
return false; //
|
||||
}
|
||||
G4int num_less_extent = (x < this->halfSideLengthInX()) +
|
||||
(y < this->halfSideLengthInY()) +
|
||||
(z < this->halfSideLengthInZ());
|
||||
|
||||
if (num_less_extent > 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(num_less_extent > 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
x = std::max(x - this->halfSideLengthInX(), 0.0);
|
||||
y = std::max(y - this->halfSideLengthInY(), 0.0);
|
||||
z = std::max(z - this->halfSideLengthInZ(), 0.0);
|
||||
x = std::max(x - this->halfSideLengthInX(), 0.0);
|
||||
y = std::max(y - this->halfSideLengthInY(), 0.0);
|
||||
z = std::max(z - this->halfSideLengthInZ(), 0.0);
|
||||
|
||||
double norm = std::sqrt(x*x + y*y + z*z);
|
||||
G4double norm = std::sqrt(x * x + y * y + z * z);
|
||||
|
||||
return ( norm < Radius);
|
||||
return (norm < Radius);
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool G4DNABoundingBox::contains(const G4ThreeVector& query, const double& Radius) const
|
||||
G4bool G4DNABoundingBox::contains(const G4ThreeVector& query,
|
||||
const G4double& Radius) const
|
||||
{
|
||||
G4ThreeVector temp = query - this->middlePoint();
|
||||
G4double x = std::abs(temp.x()) + this->halfSideLengthInX();
|
||||
G4double y = std::abs(temp.y()) + this->halfSideLengthInY();
|
||||
G4double z = std::abs(temp.z()) + this->halfSideLengthInZ();
|
||||
double norm = std::sqrt(x*x + y*y + z*z);
|
||||
return ( norm < Radius);
|
||||
G4ThreeVector temp = query - this->middlePoint();
|
||||
G4double x = std::abs(temp.x()) + this->halfSideLengthInX();
|
||||
G4double y = std::abs(temp.y()) + this->halfSideLengthInY();
|
||||
G4double z = std::abs(temp.z()) + this->halfSideLengthInZ();
|
||||
G4double norm = std::sqrt(x * x + y * y + z * z);
|
||||
return (norm < Radius);
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
G4bool G4DNABoundingBox::contains(const G4ThreeVector& query, const G4ThreeVector& Point, const double& Radius) const
|
||||
G4bool G4DNABoundingBox::contains(const G4ThreeVector& query,
|
||||
const G4ThreeVector& Point,
|
||||
const G4double& Radius) const
|
||||
{
|
||||
return ( ( (query - Point).mag() ) < Radius);
|
||||
return (((query - Point).mag()) < Radius);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
array<G4DNABoundingBox, 8> G4DNABoundingBox::partition() const
|
||||
{
|
||||
double xmid = (fxhi + fxlo) / 2.;
|
||||
double ymid = (fyhi + fylo) / 2.;
|
||||
double zmid = (fzhi + fzlo) / 2.;
|
||||
G4double xmid = (fxhi + fxlo) / 2.;
|
||||
G4double ymid = (fyhi + fylo) / 2.;
|
||||
G4double zmid = (fzhi + fzlo) / 2.;
|
||||
|
||||
std::array<G4DNABoundingBox, 8> ret
|
||||
{
|
||||
{
|
||||
G4DNABoundingBox{xmid, fxlo, ymid, fylo, zmid, fzlo}, // bottom left front
|
||||
G4DNABoundingBox{fxhi, xmid, ymid, fylo, zmid, fzlo}, // bottom right front
|
||||
G4DNABoundingBox{xmid, fxlo, fyhi, ymid, zmid, fzlo}, // bottom left back
|
||||
G4DNABoundingBox{fxhi, xmid, fyhi, ymid, zmid, fzlo}, // bottom right back
|
||||
G4DNABoundingBox{xmid, fxlo, ymid, fylo, fzhi, zmid}, // top left front
|
||||
G4DNABoundingBox{fxhi, xmid, ymid, fylo, fzhi, zmid}, // top right front
|
||||
G4DNABoundingBox{xmid, fxlo, fyhi, ymid, fzhi, zmid}, // top left back
|
||||
G4DNABoundingBox{fxhi, xmid, fyhi, ymid, fzhi, zmid} // top right back
|
||||
}
|
||||
};
|
||||
return ret;
|
||||
std::array<G4DNABoundingBox, 8> ret{ {
|
||||
G4DNABoundingBox{ xmid, fxlo, ymid, fylo, zmid,
|
||||
fzlo }, // bottom left front
|
||||
G4DNABoundingBox{ fxhi, xmid, ymid, fylo, zmid,
|
||||
fzlo }, // bottom right front
|
||||
G4DNABoundingBox{ xmid, fxlo, fyhi, ymid, zmid, fzlo }, // bottom left back
|
||||
G4DNABoundingBox{ fxhi, xmid, fyhi, ymid, zmid,
|
||||
fzlo }, // bottom right back
|
||||
G4DNABoundingBox{ xmid, fxlo, ymid, fylo, fzhi, zmid }, // top left front
|
||||
G4DNABoundingBox{ fxhi, xmid, ymid, fylo, fzhi, zmid }, // top right front
|
||||
G4DNABoundingBox{ xmid, fxlo, fyhi, ymid, fzhi, zmid }, // top left back
|
||||
G4DNABoundingBox{ fxhi, xmid, fyhi, ymid, fzhi, zmid } // top right back
|
||||
} };
|
||||
return ret;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool G4DNABoundingBox::operator==(const G4DNABoundingBox& rhs) const
|
||||
{
|
||||
return (fxhi == rhs.fxhi && fxlo == rhs.fxlo &&
|
||||
fyhi == rhs.fyhi && fylo == rhs.fylo &&
|
||||
fzhi == rhs.fzhi && fzlo == rhs.fzlo) ||
|
||||
(std::isnan(fxhi) && std::isnan(rhs.fxhi) &&
|
||||
std::isnan(fxlo) && std::isnan(rhs.fxlo) &&
|
||||
std::isnan(fyhi) && std::isnan(rhs.fyhi) &&
|
||||
std::isnan(fylo) && std::isnan(rhs.fylo) &&
|
||||
std::isnan(fzhi) && std::isnan(rhs.fzhi) &&
|
||||
std::isnan(fzlo) && std::isnan(rhs.fzlo));
|
||||
return (fxhi == rhs.fxhi && fxlo == rhs.fxlo && fyhi == rhs.fyhi &&
|
||||
fylo == rhs.fylo && fzhi == rhs.fzhi && fzlo == rhs.fzlo) ||
|
||||
(std::isnan(fxhi) && std::isnan(rhs.fxhi) && std::isnan(fxlo) &&
|
||||
std::isnan(rhs.fxlo) && std::isnan(fyhi) && std::isnan(rhs.fyhi) &&
|
||||
std::isnan(fylo) && std::isnan(rhs.fylo) && std::isnan(fzhi) &&
|
||||
std::isnan(rhs.fzhi) && std::isnan(fzlo) && std::isnan(rhs.fzlo));
|
||||
}
|
||||
|
||||
G4bool G4DNABoundingBox::operator!=(const G4DNABoundingBox& rhs) const {
|
||||
G4bool G4DNABoundingBox::operator!=(const G4DNABoundingBox& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, const G4DNABoundingBox& rhs)
|
||||
{
|
||||
stream << "{" << G4BestUnit(rhs.fxhi,"Length") << ", " << G4BestUnit(rhs.fxlo,"Length") << ", "
|
||||
<<G4BestUnit(rhs.fyhi,"Length")<< ", " <<G4BestUnit(rhs.fylo,"Length") << ", "
|
||||
<<G4BestUnit(rhs.fzhi,"Length") << ", " <<G4BestUnit(rhs.fzlo,"Length") << ", "
|
||||
<< "}";
|
||||
return stream;
|
||||
stream << "{" << G4BestUnit(rhs.fxhi, "Length") << ", "
|
||||
<< G4BestUnit(rhs.fxlo, "Length") << ", "
|
||||
<< G4BestUnit(rhs.fyhi, "Length") << ", "
|
||||
<< G4BestUnit(rhs.fylo, "Length") << ", "
|
||||
<< G4BestUnit(rhs.fzhi, "Length") << ", "
|
||||
<< G4BestUnit(rhs.fzlo, "Length") << ", "
|
||||
<< "}";
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include "G4VITStepModel.hh"
|
||||
#include "G4UserTimeStepAction.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4Scheduler.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include <vector>
|
||||
|
||||
//#define DEBUG_MEM
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
#include "G4ChordFinder.hh"
|
||||
#include "G4ITSafetyHelper.hh"
|
||||
#include "G4FieldManagerStore.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4ReferenceCast.hh"
|
||||
@@ -120,7 +121,7 @@ G4ITTransportation::G4ITTransportation(const G4String& aName, int verbose) :
|
||||
enableAtRestDoIt = false;
|
||||
enableAlongStepDoIt = true;
|
||||
enablePostStepDoIt = true;
|
||||
SetProcessSubType(60);
|
||||
SetProcessSubType(fLowEnergyTransportation);
|
||||
SetInstantiateProcessState(true);
|
||||
G4VITProcess::SetInstantiateProcessState(false);
|
||||
fInstantiateProcessState = true;
|
||||
|
||||
@@ -91,7 +91,7 @@ using namespace std;
|
||||
G4ThreadLocal G4Scheduler* G4Scheduler::fgScheduler(0);
|
||||
|
||||
template<typename T>
|
||||
inline bool IsInf(T value)
|
||||
inline G4bool IsInf(T value)
|
||||
{
|
||||
return std::numeric_limits<T>::has_infinity
|
||||
&& value == std::numeric_limits<T>::infinity();
|
||||
@@ -156,7 +156,7 @@ void G4Scheduler::Create()
|
||||
fPreviousTimeStep = DBL_MAX;
|
||||
|
||||
fZeroTimeCount = 0;
|
||||
fMaxNZeroTimeStepsAllowed = 10;
|
||||
fMaxNZeroTimeStepsAllowed = 10000;
|
||||
|
||||
fStartTime = 0;
|
||||
fTimeTolerance = 1 * picosecond;
|
||||
@@ -192,6 +192,9 @@ void G4Scheduler::Create()
|
||||
fReactionSet = G4ITReactionSet::Instance();
|
||||
fMaxTimeStep = DBL_MAX;
|
||||
|
||||
//hoang add
|
||||
fResetScavenger = true;//true by default
|
||||
|
||||
G4ITTypeManager::Instance()->ReserveRessource();
|
||||
}
|
||||
|
||||
@@ -271,7 +274,7 @@ void G4Scheduler::ClearList()
|
||||
}
|
||||
|
||||
//_________________________________________________________________________
|
||||
void G4Scheduler::RegisterModel(G4VITStepModel* model, double time)
|
||||
void G4Scheduler::RegisterModel(G4VITStepModel* model, G4double time)
|
||||
{
|
||||
fpModelHandler->RegisterModel(model, time);
|
||||
}
|
||||
@@ -404,7 +407,18 @@ void G4Scheduler::Process()
|
||||
fRunning = true;
|
||||
Reset();
|
||||
|
||||
if (fpUserTimeStepAction) fpUserTimeStepAction->StartProcessing();
|
||||
//hoang 7/12/2020
|
||||
|
||||
if(fResetScavenger) {
|
||||
if (fpUserScavenger != nullptr) {
|
||||
fpUserScavenger->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (fpUserTimeStepAction)
|
||||
{
|
||||
fpUserTimeStepAction->StartProcessing();
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
G4bool trackFound = false;
|
||||
@@ -485,9 +499,9 @@ void G4Scheduler::Process()
|
||||
|
||||
//_________________________________________________________________________
|
||||
|
||||
double G4Scheduler::GetNextWatchedTime() const
|
||||
G4double G4Scheduler::GetNextWatchedTime() const
|
||||
{
|
||||
std::set<double>::const_iterator up = fWatchedTimes.upper_bound(fGlobalTime);
|
||||
std::set<G4double>::const_iterator up = fWatchedTimes.upper_bound(fGlobalTime);
|
||||
if(up == fWatchedTimes.end()) return DBL_MAX;
|
||||
return *up;
|
||||
}
|
||||
@@ -521,8 +535,8 @@ void G4Scheduler::SynchronizeTracks()
|
||||
fGlobalTime = fTrackContainer.GetNextTime();
|
||||
G4double tmpGlobalTime = fGlobalTime;
|
||||
|
||||
double nextWatchedTime = -1;
|
||||
bool carryOn = true;
|
||||
G4double nextWatchedTime = -1;
|
||||
G4bool carryOn = true;
|
||||
|
||||
while(fTrackContainer.MergeNextTimeToMainList(tmpGlobalTime) && carryOn)
|
||||
{
|
||||
@@ -547,7 +561,7 @@ void G4Scheduler::SynchronizeTracks()
|
||||
|
||||
//_________________________________________________________________________
|
||||
|
||||
bool G4Scheduler::CanICarryOn()
|
||||
G4bool G4Scheduler::CanICarryOn()
|
||||
{
|
||||
return fGlobalTime < fEndTime && (fMaxSteps == -1 ? true : fNbSteps < fMaxSteps)
|
||||
&& fContinue == true;
|
||||
@@ -740,8 +754,7 @@ void G4Scheduler::Stepping()
|
||||
// Call IL even if fTSTimeStep == 0
|
||||
// if fILTimeStep == 0 give the priority to DoIt processes
|
||||
|
||||
fILTimeStep =
|
||||
fpStepProcessor->ComputeInteractionLength(fPreviousTimeStep);
|
||||
fILTimeStep = fpStepProcessor->ComputeInteractionLength(fPreviousTimeStep);
|
||||
// => at least N loops
|
||||
// All process returns the physical step of interaction
|
||||
// The transportation process calculates the corresponding
|
||||
@@ -937,15 +950,15 @@ void G4Scheduler::Stepping()
|
||||
}
|
||||
//_________________________________________________________________________
|
||||
|
||||
double G4Scheduler::GetLimitingTimeStep() const
|
||||
G4double G4Scheduler::GetLimitingTimeStep() const
|
||||
{
|
||||
if (fpUserTimeSteps == 0) return fDefaultMinTimeStep;
|
||||
if (fabs(fGlobalTime - fUserUpperTimeLimit) < fTimeTolerance)
|
||||
return fDefinedMinTimeStep;
|
||||
|
||||
map<double, double>::const_iterator it_fpUserTimeSteps_i = fpUserTimeSteps
|
||||
map<G4double, G4double>::const_iterator it_fpUserTimeSteps_i = fpUserTimeSteps
|
||||
->upper_bound(fGlobalTime);
|
||||
map<double, double>::const_iterator it_fpUserTimeSteps_low = fpUserTimeSteps
|
||||
map<G4double, G4double>::const_iterator it_fpUserTimeSteps_low = fpUserTimeSteps
|
||||
->lower_bound(fGlobalTime);
|
||||
|
||||
// DEBUG
|
||||
@@ -970,7 +983,7 @@ double G4Scheduler::GetLimitingTimeStep() const
|
||||
// and fpUserTimeSteps_low->first = X picosecond
|
||||
// but the precision is not good enough
|
||||
it_fpUserTimeSteps_i = it_fpUserTimeSteps_low;
|
||||
map<double, double>::const_iterator tmp_it = it_fpUserTimeSteps_low;
|
||||
map<G4double, G4double>::const_iterator tmp_it = it_fpUserTimeSteps_low;
|
||||
++tmp_it;
|
||||
if (tmp_it == fpUserTimeSteps->end())
|
||||
{
|
||||
@@ -1017,9 +1030,9 @@ void G4Scheduler::FindUserPreDefinedTimeStep()
|
||||
exceptionDescription);
|
||||
return; // makes coverity happy
|
||||
}
|
||||
map<double, double>::iterator fpUserTimeSteps_i =
|
||||
map<G4double, G4double>::iterator fpUserTimeSteps_i =
|
||||
fpUserTimeSteps->upper_bound(fGlobalTime);
|
||||
map<double, double>::iterator fpUserTimeSteps_low = fpUserTimeSteps
|
||||
map<G4double, G4double>::iterator fpUserTimeSteps_low = fpUserTimeSteps
|
||||
->lower_bound(fGlobalTime);
|
||||
|
||||
// DEBUG
|
||||
|
||||
@@ -81,7 +81,7 @@ G4SchedulerMessenger::G4SchedulerMessenger(G4Scheduler * stepMgr) :
|
||||
fMaxNULLTimeSteps->SetGuidance("Set maximum allowed zero time steps. After this "
|
||||
"threshold, the simulation is stopped.");
|
||||
fMaxNULLTimeSteps->SetParameterName("numberOfNullTimeSteps", true);
|
||||
fMaxNULLTimeSteps->SetDefaultValue(10);
|
||||
fMaxNULLTimeSteps->SetDefaultValue(10000);
|
||||
fMaxNULLTimeSteps->SetRange("numberOfNullTimeSteps >=0 ");
|
||||
|
||||
fMaxStepNumber = new G4UIcmdWithAnInteger("/scheduler/maxStepNumber", this);
|
||||
|
||||
+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 &&
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ private :
|
||||
friend G4FakeParticleID operator -(const G4FakeParticleID& left,const int& right);
|
||||
int fValue;
|
||||
|
||||
static G4ThreadLocal int fLastValue;
|
||||
inline static G4ThreadLocal int fLastValue = 999666999;
|
||||
|
||||
public :
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ geant4_add_module(G4emdna-molman
|
||||
G4VMolecularDissociationDisplacer.hh
|
||||
G4VMoleculeCounter.hh
|
||||
SOURCES
|
||||
G4FakeParticleID.cc
|
||||
G4MolecularConfiguration.cc
|
||||
G4MolecularDissociationChannel.cc
|
||||
G4MolecularDissociationTable.cc
|
||||
|
||||
-16
@@ -705,14 +705,6 @@ G4MolecularConfiguration::MoveOneElectron(G4int orbitToFree,
|
||||
|
||||
const G4String& G4MolecularConfiguration::GetName() const
|
||||
{
|
||||
// if (fName.isNull())
|
||||
// {
|
||||
// fName = fMoleculeDefinition->GetName();
|
||||
// fName += "^";
|
||||
// // fName+= "{";
|
||||
// fName += G4UIcommand::ConvertToString(fDynCharge);
|
||||
// // fName+= "}";
|
||||
// }
|
||||
return fName;
|
||||
}
|
||||
|
||||
@@ -720,14 +712,6 @@ const G4String& G4MolecularConfiguration::GetName() const
|
||||
|
||||
const G4String& G4MolecularConfiguration::GetFormatedName() const
|
||||
{
|
||||
// if (fFormatedName.isNull())
|
||||
// {
|
||||
// fFormatedName = fMoleculeDefinition->GetFormatedName();
|
||||
// fFormatedName += "^";
|
||||
// fFormatedName += "{";
|
||||
// fFormatedName += G4UIcommand::ConvertToString(fDynCharge);
|
||||
// fFormatedName += "}";
|
||||
// }
|
||||
return fFormatedName;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 G4DNASCAVENGERPROCESS_HH
|
||||
#define G4DNASCAVENGERPROCESS_HH
|
||||
|
||||
#include "G4VITProcess.hh"
|
||||
class G4DNAMolecularReactionData;
|
||||
class G4MolecularConfiguration;
|
||||
class G4DNABoundingBox;
|
||||
class G4DNAScavengerMaterial;
|
||||
class G4DNAScavengerProcess : public G4VITProcess
|
||||
{
|
||||
public:
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
using Data = const G4DNAMolecularReactionData;
|
||||
explicit G4DNAScavengerProcess(const G4String& aName,
|
||||
const G4DNABoundingBox& box,
|
||||
G4ProcessType type = fDecay);
|
||||
~G4DNAScavengerProcess() override;
|
||||
G4DNAScavengerProcess(const G4DNAScavengerProcess&) = delete;
|
||||
G4DNAScavengerProcess& operator=(const G4DNAScavengerProcess&) = delete;
|
||||
void StartTracking(G4Track*) override;
|
||||
void SetReaction(MolType, Data* pData);
|
||||
|
||||
public:
|
||||
void BuildPhysicsTable(const G4ParticleDefinition&) override;
|
||||
|
||||
G4double PostStepGetPhysicalInteractionLength(
|
||||
const G4Track& track, G4double previousStepSize,
|
||||
G4ForceCondition* condition) override;
|
||||
|
||||
G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&) override;
|
||||
|
||||
G4double AtRestGetPhysicalInteractionLength(const G4Track&,
|
||||
G4ForceCondition*) override
|
||||
{
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// no operation in AlongStepDoIt
|
||||
G4double AlongStepGetPhysicalInteractionLength(const G4Track&, G4double,
|
||||
G4double, G4double&,
|
||||
G4GPILSelection*) override
|
||||
{
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
// no operation in AlongStepDoIt
|
||||
G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
struct G4DNAScavengerProcessState : public G4ProcessState
|
||||
{
|
||||
G4DNAScavengerProcessState();
|
||||
~G4DNAScavengerProcessState() override { ; }
|
||||
G4double fPreviousTimeAtPreStepPoint;
|
||||
G4bool fIsInGoodMaterial;
|
||||
};
|
||||
|
||||
protected:
|
||||
G4bool fIsInitialized;
|
||||
G4double fReturnedValue;
|
||||
G4ParticleChange fParticleChange;
|
||||
const G4MolecularConfiguration* fpMolecularConfiguration;
|
||||
std::map<MolType /*MolConf*/, std::map<MolType /*molConfMat*/, Data*>>
|
||||
fConfMap;
|
||||
std::vector<MolType> fpMaterialVector;
|
||||
MolType fpMaterialConf;
|
||||
const G4DNABoundingBox* fpBoundingBox;
|
||||
G4DNAScavengerMaterial* fpScavengerMaterial;
|
||||
G4int fVerbose;
|
||||
};
|
||||
#endif // FLASH1_G4DNASCAVENGERPROCESS_HH
|
||||
@@ -21,6 +21,7 @@ geant4_add_module(G4emdna-processes
|
||||
G4DNARotExcitation.hh
|
||||
G4DNASecondOrderReaction.hh
|
||||
G4DNAVibExcitation.hh
|
||||
G4DNAScavengerProcess.hh
|
||||
SOURCES
|
||||
G4DNAAttachment.cc
|
||||
G4DNABrownianTransportation.cc
|
||||
@@ -38,7 +39,8 @@ geant4_add_module(G4emdna-processes
|
||||
G4DNARotExcitation.cc
|
||||
G4DNAWaterDissociationDisplacer.cc
|
||||
G4DNASecondOrderReaction.cc
|
||||
G4DNAVibExcitation.cc)
|
||||
G4DNAVibExcitation.cc
|
||||
G4DNAScavengerProcess.cc)
|
||||
|
||||
geant4_module_link_libraries(G4emdna-processes
|
||||
PUBLIC
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "G4DNAAttachment.hh"
|
||||
#include "G4LEPTSAttachmentModel.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Positron.hh"
|
||||
@@ -38,7 +39,7 @@ G4DNAAttachment::G4DNAAttachment(const G4String& processName,
|
||||
G4ProcessType type):G4VEmProcess (processName, type),
|
||||
isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(55);
|
||||
SetProcessSubType(fLowEnergyAttachment);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "G4ITNavigator.hh"
|
||||
#include "G4ITSafetyHelper.hh" // Not used yet
|
||||
#include "G4TrackingInformation.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -126,7 +127,7 @@ G4DNABrownianTransportation::G4DNABrownianTransportation(const G4String& aName,
|
||||
fpState.reset(new G4ITBrownianState());
|
||||
|
||||
//ctor
|
||||
SetProcessSubType(61);
|
||||
SetProcessSubType(fLowEnergyBrownianTransportation);
|
||||
|
||||
fNistWater = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
|
||||
fpWaterDensity = 0;
|
||||
@@ -148,7 +149,7 @@ G4DNABrownianTransportation::G4DNABrownianTransportation(const G4DNABrownianTran
|
||||
G4ITTransportation(right)
|
||||
{
|
||||
//copy ctor
|
||||
SetProcessSubType(61);
|
||||
SetProcessSubType(fLowEnergyBrownianTransportation);
|
||||
fUseMaximumTimeBeforeReachingBoundary = right
|
||||
.fUseMaximumTimeBeforeReachingBoundary;
|
||||
fUseSchedulerMinTimeSteps = right.fUseSchedulerMinTimeSteps;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "G4DNAChargeDecrease.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -35,7 +36,7 @@ G4DNAChargeDecrease::G4DNAChargeDecrease(const G4String& processName,
|
||||
G4ProcessType type) :
|
||||
G4VEmProcess(processName, type), isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(56);
|
||||
SetProcessSubType(fLowEnergyChargeDecrease);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "G4DNAChargeIncrease.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -35,7 +36,7 @@ G4DNAChargeIncrease::G4DNAChargeIncrease(const G4String& processName,
|
||||
G4ProcessType type) :
|
||||
G4VEmProcess(processName, type), isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(57);
|
||||
SetProcessSubType(fLowEnergyChargeIncrease);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "G4DNAElastic.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Positron.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -36,7 +37,7 @@ using namespace std;
|
||||
G4DNAElastic::G4DNAElastic(const G4String& processName, G4ProcessType type) :
|
||||
G4VEmProcess(processName, type), isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(51);
|
||||
SetProcessSubType(fLowEnergyElastic);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
+2
-1
@@ -43,6 +43,7 @@
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VMoleculeCounter.hh"
|
||||
#include "G4Exp.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
static G4double onsager_constant = e_squared / (4. * pi * epsilon0 * k_Boltzmann);
|
||||
|
||||
@@ -117,7 +118,7 @@ void G4DNAElectronHoleRecombination::Create()
|
||||
enableAlongStepDoIt = false;
|
||||
enablePostStepDoIt = true;
|
||||
|
||||
SetProcessSubType(60);
|
||||
SetProcessSubType(fLowEnergyTransportation);
|
||||
|
||||
G4VITProcess::SetInstantiateProcessState(false);
|
||||
// ie G4DNAElectronHoleRecombination uses a state class
|
||||
|
||||
@@ -38,12 +38,13 @@
|
||||
#include "G4DNAElectronSolvation.hh"
|
||||
#include "G4Electron.hh"
|
||||
#include "G4DNAWaterExcitationStructure.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
G4DNAElectronSolvation::G4DNAElectronSolvation(const G4String& processName,
|
||||
G4ProcessType type):G4VEmProcess (processName, type),
|
||||
isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(58);
|
||||
SetProcessSubType(fLowEnergyElectronSolvation);
|
||||
}
|
||||
|
||||
G4DNAElectronSolvation::~G4DNAElectronSolvation()
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "G4LEPTSExcitationModel.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Positron.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -37,7 +38,7 @@ G4DNAExcitation::G4DNAExcitation(const G4String& processName,
|
||||
G4ProcessType type) :
|
||||
G4VEmProcess(processName, type), isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(52);
|
||||
SetProcessSubType(fLowEnergyExcitation);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "G4DNAIonisation.hh"
|
||||
#include "G4LEPTSIonisationModel.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//SEB
|
||||
#include "G4GenericIon.hh"
|
||||
@@ -40,7 +41,7 @@ G4DNAIonisation::G4DNAIonisation(const G4String& processName,
|
||||
G4ProcessType type) :
|
||||
G4VEmProcess(processName, type), isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(53);
|
||||
SetProcessSubType(fLowEnergyIonisation);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4ITTransportationManager.hh"
|
||||
#include "G4ITNavigator.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
@@ -52,7 +53,7 @@ G4DNAMolecularDissociation(const G4String& processName,
|
||||
: G4VITRestDiscreteProcess(processName, type)
|
||||
{
|
||||
// set Process Sub Type
|
||||
SetProcessSubType(59); // DNA sub-type
|
||||
SetProcessSubType(fLowEnergyMolecularDecay); // DNA sub-type
|
||||
enableAlongStepDoIt = false;
|
||||
enablePostStepDoIt = true;
|
||||
enableAtRestDoIt = true;
|
||||
@@ -347,4 +348,4 @@ G4double G4DNAMolecularDissociation::GetMeanFreePath(const G4Track&,
|
||||
G4ForceCondition*)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "G4DNAPlasmonExcitation.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -41,7 +42,7 @@ G4DNAPlasmonExcitation::G4DNAPlasmonExcitation(const G4String& processName,
|
||||
G4ProcessType type):G4VEmProcess (processName, type),
|
||||
isInitialised(false)
|
||||
{
|
||||
//SetProcessSubType(56); //dousatsu temp
|
||||
//SetProcessSubType(fLowEnergyChargeDecrease); //dousatsu temp
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -0,0 +1,354 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 "G4DNAScavengerProcess.hh"
|
||||
#include <G4VScheduler.hh>
|
||||
#include <memory>
|
||||
#include "G4Molecule.hh"
|
||||
#include "G4DNAMolecularMaterial.hh"
|
||||
#include "G4MolecularConfiguration.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4TrackingInformation.hh"
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4DNABoundingBox.hh"
|
||||
#include "G4DNAScavengerMaterial.hh"
|
||||
#include "G4MoleculeFinder.hh"
|
||||
#include "G4Scheduler.hh"
|
||||
|
||||
#ifndef State
|
||||
# define State(theXInfo) (GetState<G4DNAScavengerProcessState>()->theXInfo)
|
||||
#endif
|
||||
G4DNAScavengerProcess::G4DNAScavengerProcess(const G4String& aName,
|
||||
const G4DNABoundingBox& box,
|
||||
G4ProcessType type)
|
||||
: G4VITProcess(aName, type)
|
||||
, fpBoundingBox(&box)
|
||||
, fpScavengerMaterial(nullptr)
|
||||
, fVerbose(1)
|
||||
{
|
||||
pParticleChange = &fParticleChange;
|
||||
enableAtRestDoIt = false;
|
||||
enableAlongStepDoIt = false;
|
||||
enablePostStepDoIt = true;
|
||||
SetProcessSubType(66);
|
||||
G4VITProcess::SetInstantiateProcessState(false);
|
||||
fIsInitialized = false;
|
||||
fpMolecularConfiguration = nullptr;
|
||||
fpMaterialConf = nullptr;
|
||||
fProposesTimeStep = true;
|
||||
fReturnedValue = DBL_MAX;
|
||||
verboseLevel = 0;
|
||||
}
|
||||
|
||||
G4DNAScavengerProcess::~G4DNAScavengerProcess()
|
||||
{
|
||||
for(auto& iter : fConfMap)
|
||||
{
|
||||
for(auto& iter2 : iter.second)
|
||||
{
|
||||
delete iter2.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4DNAScavengerProcess::G4DNAScavengerProcessState::G4DNAScavengerProcessState()
|
||||
: G4ProcessState()
|
||||
{
|
||||
fPreviousTimeAtPreStepPoint = -1;
|
||||
fIsInGoodMaterial = false;
|
||||
}
|
||||
void G4DNAScavengerProcess::BuildPhysicsTable(const G4ParticleDefinition&)
|
||||
{
|
||||
fpScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
|
||||
G4Scheduler::Instance()->GetScavengerMaterial());
|
||||
if(fpScavengerMaterial == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
fIsInitialized = true;
|
||||
}
|
||||
|
||||
void G4DNAScavengerProcess::StartTracking(G4Track* track)
|
||||
{
|
||||
G4VProcess::StartTracking(track);
|
||||
G4VITProcess::fpState = std::make_shared<G4DNAScavengerProcessState>();
|
||||
G4VITProcess::StartTracking(track);
|
||||
}
|
||||
|
||||
void G4DNAScavengerProcess::SetReaction(MolType molConf, Data* pData)
|
||||
{
|
||||
if(fIsInitialized)
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription
|
||||
<< "G4DNASecondOrderReaction was already initialised. ";
|
||||
exceptionDescription << "You cannot set a reaction after initialisation.";
|
||||
G4Exception("G4DNASecondOrderReaction::SetReaction",
|
||||
"G4DNASecondOrderReaction001", FatalErrorInArgument,
|
||||
exceptionDescription);
|
||||
}
|
||||
auto materialConf = pData->GetReactant1() == molConf ? pData->GetReactant2()
|
||||
: pData->GetReactant1();
|
||||
if(fVerbose > 0)
|
||||
{
|
||||
G4cout << "G4DNAScavengerProcess::SetReaction : " << molConf->GetName()
|
||||
<< " materialConf : " << materialConf->GetName() << G4endl;
|
||||
}
|
||||
fConfMap[molConf][materialConf] = pData;
|
||||
}
|
||||
|
||||
G4double G4DNAScavengerProcess::PostStepGetPhysicalInteractionLength(
|
||||
const G4Track& track, G4double /*previousStepSize*/,
|
||||
G4ForceCondition* pForceCond)
|
||||
{
|
||||
G4Molecule* molecule = GetMolecule(track);
|
||||
auto molConf = molecule->GetMolecularConfiguration();
|
||||
// reset
|
||||
fpMolecularConfiguration = nullptr;
|
||||
fpMaterialConf = nullptr;
|
||||
|
||||
// this because process for moleculeDifinition not for configuration
|
||||
// TODO: need change this
|
||||
auto it = fConfMap.find(molConf);
|
||||
if(it == fConfMap.end())
|
||||
{
|
||||
return DBL_MAX;
|
||||
}
|
||||
|
||||
fpMolecularConfiguration = molConf;
|
||||
auto MaterialMap = it->second;
|
||||
|
||||
G4double r1 = G4UniformRand();
|
||||
std::map<G4double /*Propensity*/, std::pair<MolType, G4double>>
|
||||
ReactionDataMap;
|
||||
G4double alpha0 = 0;
|
||||
|
||||
for(const auto& mat_it : MaterialMap)
|
||||
{
|
||||
auto matConf = mat_it.first;
|
||||
G4double numMol =
|
||||
fpScavengerMaterial->GetNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
matConf);
|
||||
if(numMol == 0.0) // ie : not found
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(fVerbose > 1)
|
||||
{
|
||||
G4cout << " Material of " << matConf->GetName() << " : " << numMol
|
||||
<< G4endl;
|
||||
}
|
||||
// auto data = fReactionMap[mat_it];
|
||||
auto data = mat_it.second;
|
||||
auto reactionRate = data->GetObservedReactionRateConstant(); //_const
|
||||
G4double propensity =
|
||||
numMol * reactionRate / (fpBoundingBox->Volume() * Avogadro);
|
||||
auto reactionData = std::make_pair(mat_it.first, propensity);
|
||||
if(propensity == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
alpha0 += propensity;
|
||||
ReactionDataMap[alpha0] = reactionData;
|
||||
}
|
||||
if(alpha0 == 0)
|
||||
{
|
||||
if(State(fIsInGoodMaterial))
|
||||
{
|
||||
ResetNumberOfInteractionLengthLeft();
|
||||
State(fIsInGoodMaterial) = false;
|
||||
}
|
||||
return DBL_MAX;
|
||||
}
|
||||
auto rSelectedIter = ReactionDataMap.upper_bound(r1 * alpha0);
|
||||
|
||||
fpMaterialConf = rSelectedIter->second.first;
|
||||
|
||||
State(fIsInGoodMaterial) = true;
|
||||
G4double previousTimeStep(-1.);
|
||||
|
||||
if(State(fPreviousTimeAtPreStepPoint) != -1)
|
||||
{
|
||||
previousTimeStep =
|
||||
track.GetGlobalTime() - State(fPreviousTimeAtPreStepPoint);
|
||||
}
|
||||
|
||||
State(fPreviousTimeAtPreStepPoint) = track.GetGlobalTime();
|
||||
|
||||
// condition is set to "Not Forced"
|
||||
*pForceCond = NotForced;
|
||||
|
||||
if((previousTimeStep <= 0.0) ||
|
||||
(fpState->theNumberOfInteractionLengthLeft <= 0.0))
|
||||
{
|
||||
ResetNumberOfInteractionLengthLeft();
|
||||
}
|
||||
else if(previousTimeStep > 0.0)
|
||||
{
|
||||
SubtractNumberOfInteractionLengthLeft(previousTimeStep);
|
||||
}
|
||||
|
||||
fpState->currentInteractionLength = 1 / (rSelectedIter->second.second);
|
||||
G4double value = DBL_MAX;
|
||||
if(fpState->currentInteractionLength < DBL_MAX)
|
||||
{
|
||||
value = fpState->theNumberOfInteractionLengthLeft *
|
||||
(fpState->currentInteractionLength);
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel > 2)
|
||||
{
|
||||
G4cout << "G4DNAScavengerProcess::PostStepGetPhysicalInteractionLength:: "
|
||||
<< molConf->GetName() << G4endl;
|
||||
G4cout << "theNumberOfInteractionLengthLeft : "
|
||||
<< fpState->theNumberOfInteractionLengthLeft << G4endl;
|
||||
G4cout << "currentInteractionLength : " << fpState->currentInteractionLength
|
||||
<< G4endl;
|
||||
G4cout << "Material : " << fpMaterialConf->GetName()
|
||||
<< " ID: " << track.GetTrackID()
|
||||
<< " Track Time : " << track.GetGlobalTime()
|
||||
<< " name : " << molConf->GetName()
|
||||
<< " Track Position : " << track.GetPosition()
|
||||
<< " Returned time : " << G4BestUnit(value, "Time") << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(value < fReturnedValue)
|
||||
{
|
||||
fReturnedValue = value;
|
||||
}
|
||||
|
||||
return value * -1;
|
||||
// multiple by -1 to indicate to the tracking system that we are returning a
|
||||
// time
|
||||
}
|
||||
|
||||
G4VParticleChange* G4DNAScavengerProcess::PostStepDoIt(const G4Track& track,
|
||||
const G4Step& /*step*/)
|
||||
{
|
||||
G4Molecule* molecule = GetMolecule(track);
|
||||
auto molConf = molecule->GetMolecularConfiguration();
|
||||
if(fpMolecularConfiguration != molConf)
|
||||
{
|
||||
G4cout << "fpMolecularConfiguration : "
|
||||
<< fpMolecularConfiguration->GetName()
|
||||
<< " molConf : " << molConf->GetName() << G4endl;
|
||||
|
||||
assert(false);
|
||||
}
|
||||
std::vector<G4Track*> products;
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel > 1)
|
||||
{
|
||||
G4cout << "___________" << G4endl;
|
||||
G4cout << ">>> Beginning of G4DNAScavengerProcess verbose" << G4endl;
|
||||
G4cout << ">>> Returned value : " << G4BestUnit(fReturnedValue, "Time")
|
||||
<< G4endl;
|
||||
G4cout << ">>> Time Step : "
|
||||
<< G4BestUnit(G4VScheduler::Instance()->GetTimeStep(), "Time")
|
||||
<< G4endl;
|
||||
G4cout << ">>> Global Time : "
|
||||
<< G4BestUnit(G4VScheduler::Instance()->GetGlobalTime(), "Time")
|
||||
<< G4endl;
|
||||
G4cout << ">>> Global Time Track : "
|
||||
<< G4BestUnit(track.GetGlobalTime(), "Time") << G4endl;
|
||||
G4cout << ">>> Track Position : " << track.GetPosition() << G4endl;
|
||||
G4cout << ">>> Reaction : " << molecule->GetName() << "("
|
||||
<< track.GetTrackID() << ") + " << fpMaterialConf->GetName()
|
||||
<< G4endl;
|
||||
G4cout << ">>> End of G4DNAScavengerProcess verbose <<<" << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
G4double reactionTime = track.GetGlobalTime();
|
||||
auto data = fConfMap[fpMolecularConfiguration][fpMaterialConf];
|
||||
|
||||
auto nbSecondaries = data->GetNbProducts();
|
||||
|
||||
for(G4int j = 0; j < nbSecondaries; ++j)
|
||||
{
|
||||
auto pProduct = new G4Molecule(data->GetProduct(j));
|
||||
auto pProductTrack =
|
||||
pProduct->BuildTrack(reactionTime, track.GetPosition());
|
||||
pProductTrack->SetTrackStatus(fAlive);
|
||||
G4ITTrackHolder::Instance()->Push(pProductTrack);
|
||||
G4MoleculeFinder::Instance()->Push(pProductTrack);
|
||||
products.push_back(pProductTrack);
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << "At time : " << std::setw(7) << G4BestUnit(reactionTime, "Time")
|
||||
<< " Reaction : " << GetIT(track)->GetName() << " ("
|
||||
<< track.GetTrackID() << ") + " << fpMaterialConf->GetName() << " ("
|
||||
<< "B"
|
||||
<< ") -> ";
|
||||
}
|
||||
#endif
|
||||
if(nbSecondaries > 0)
|
||||
{
|
||||
for(G4int i = 0; i < nbSecondaries; ++i)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if((fVerbose != 0) && i != 0)
|
||||
{
|
||||
G4cout << " + ";
|
||||
}
|
||||
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << GetIT(products.at(i))->GetName() << " ("
|
||||
<< products.at(i)->GetTrackID() << ")";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << "No product";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
fReturnedValue = DBL_MAX;
|
||||
fParticleChange.Initialize(track);
|
||||
fParticleChange.ProposeTrackStatus(fStopAndKill);
|
||||
fpScavengerMaterial->ReduceNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
fpMaterialConf, reactionTime);
|
||||
State(fPreviousTimeAtPreStepPoint) = -1;
|
||||
return &fParticleChange;
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "G4DNADamage.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4TrackingInformation.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
#ifndef State
|
||||
#define State(theXInfo) (GetState<SecondOrderReactionState>()->theXInfo)
|
||||
@@ -46,7 +47,7 @@ void G4DNASecondOrderReaction::Create()
|
||||
enableAlongStepDoIt = false;
|
||||
enablePostStepDoIt = true;
|
||||
|
||||
SetProcessSubType(60);
|
||||
SetProcessSubType(fLowEnergyTransportation);
|
||||
|
||||
G4VITProcess::SetInstantiateProcessState(false);
|
||||
// meaning G4DNASecondOrderReaction contains a class inheriting from G4ProcessState
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "G4LEPTSVibExcitationModel.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Positron.hh"
|
||||
#include "G4LowEnergyEmProcessSubType.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -37,7 +38,7 @@ G4DNAVibExcitation::G4DNAVibExcitation(const G4String& processName,
|
||||
G4ProcessType type):G4VEmProcess (processName, type),
|
||||
isInitialised(false)
|
||||
{
|
||||
SetProcessSubType(54);
|
||||
SetProcessSubType(fLowEnergyVibrationalExcitation);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -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 G4DNAEventSet_hh
|
||||
#define G4DNAEventSet_hh 1
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <G4memory.hh>
|
||||
#include "G4Track.hh"
|
||||
#include <set>
|
||||
#include "G4DNAMesh.hh"
|
||||
#include <variant>
|
||||
class G4DNAMolecularReactionTable;
|
||||
class G4DNAMolecularReactionData;
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
using Index = G4Voxel::Index;
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
using JumpingData = std::pair<MolType, Index>;
|
||||
using ReactionData = const G4DNAMolecularReactionData;
|
||||
|
||||
// to test C++17
|
||||
// using Data = std::variant<std::unique_ptr<JumpingData>, ReactionData*>
|
||||
using Data = std::pair<std::unique_ptr<JumpingData>, ReactionData*>;
|
||||
|
||||
Event(G4double time, unsigned int key, ReactionData*);
|
||||
Event(G4double time, unsigned int key, std::unique_ptr<JumpingData>&&);
|
||||
|
||||
virtual ~Event();
|
||||
G4double GetTime() const { return fTimeStep; }
|
||||
unsigned int GetKey() const { return fKey; }
|
||||
void PrintEvent() const;
|
||||
|
||||
JumpingData* GetJumpingData() const { return std::get<0>(fData).get(); }
|
||||
|
||||
ReactionData* GetReactionData() const { return std::get<1>(fData); }
|
||||
|
||||
private:
|
||||
G4double fTimeStep;
|
||||
unsigned int fKey;
|
||||
Data fData;
|
||||
};
|
||||
|
||||
struct comparatorEventSet
|
||||
{
|
||||
G4bool operator()(std::unique_ptr<Event> const& rhs,
|
||||
std::unique_ptr<Event> const& lhs) const;
|
||||
};
|
||||
|
||||
class IEventSet
|
||||
{
|
||||
public:
|
||||
IEventSet() = default;
|
||||
~IEventSet() = default;
|
||||
};
|
||||
|
||||
class G4DNAEventSet : public IEventSet
|
||||
{
|
||||
public:
|
||||
using Key = unsigned int;
|
||||
using EventSet = std::set<std::unique_ptr<Event>, comparatorEventSet>;
|
||||
using EventMap = std::map<Key, EventSet::iterator>;
|
||||
G4DNAEventSet();
|
||||
virtual ~G4DNAEventSet();
|
||||
|
||||
void CreateEvent(G4double time, Key index,
|
||||
Event::ReactionData* pReactionData);
|
||||
void CreateEvent(G4double time, Key index,
|
||||
std::unique_ptr<Event::JumpingData> jum);
|
||||
|
||||
void AddEvent(std::unique_ptr<Event> pEvent);
|
||||
void RemoveEventSet()
|
||||
{
|
||||
fEventSet.clear();
|
||||
fEventMap.clear();
|
||||
}
|
||||
void RemoveEventOfVoxel(const size_t& key);
|
||||
|
||||
EventSet::iterator end() { return fEventSet.end(); }
|
||||
EventSet::iterator begin() { return fEventSet.begin(); }
|
||||
|
||||
EventSet::reverse_iterator rend() { return fEventSet.rend(); }
|
||||
EventSet::reverse_iterator rbegin() { return fEventSet.rbegin(); }
|
||||
|
||||
EventSet::const_iterator end() const { return fEventSet.end(); }
|
||||
|
||||
EventSet::const_iterator begin() const { return fEventSet.begin(); }
|
||||
|
||||
size_t size() { return fEventSet.size(); }
|
||||
|
||||
G4bool Empty() { return fEventSet.empty(); }
|
||||
|
||||
void RemoveEvent(EventSet::iterator iter);
|
||||
[[maybe_unused]] void PrintEventSet();
|
||||
|
||||
private:
|
||||
EventSet fEventSet;
|
||||
EventMap fEventMap;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,156 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 G4DNAMesh_hh
|
||||
#define G4DNAMesh_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4DNABoundingBox.hh"
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include "G4MolecularConfiguration.hh"
|
||||
#include "G4Track.hh"
|
||||
|
||||
class G4Voxel
|
||||
{
|
||||
public:
|
||||
struct Index
|
||||
{
|
||||
Index()
|
||||
: x(0)
|
||||
, y(0)
|
||||
, z(0)
|
||||
{}
|
||||
Index(int x0, int y0, int z0)
|
||||
: x(x0)
|
||||
, y(y0)
|
||||
, z(z0)
|
||||
{}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const Index& rhs)
|
||||
{
|
||||
stream << "(" << rhs.x << ", " << rhs.y << ", " << rhs.z << ")";
|
||||
return stream;
|
||||
}
|
||||
G4bool operator==(const Index& rhs) const
|
||||
{
|
||||
return x == rhs.x && y == rhs.y && z == rhs.z;
|
||||
}
|
||||
G4bool operator!=(const Index& rhs) const
|
||||
{
|
||||
return x != rhs.x || y != rhs.y || z != rhs.z;
|
||||
}
|
||||
Index operator+(const Index& rhs) const
|
||||
{
|
||||
return { x + rhs.x, y + rhs.y, z + rhs.z };
|
||||
}
|
||||
int x, y, z;
|
||||
};
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
using MapList = std::map<MolType, size_t>;
|
||||
|
||||
G4Voxel(MapList&& list, Index& index, G4DNABoundingBox&& box)
|
||||
: fMapList(std::move(list))
|
||||
, fIndex(index)
|
||||
, fBox(std::move(box))
|
||||
{}
|
||||
|
||||
~G4Voxel() = default;
|
||||
|
||||
const Index& GetIndex() const { return fIndex; }
|
||||
|
||||
MapList& GetMapList() { return fMapList; }
|
||||
|
||||
void SetMapList(MapList&& mapList) { fMapList = std::move(mapList); }
|
||||
|
||||
G4double GetVolume() const
|
||||
{
|
||||
auto xlo = fBox.Getxlo();
|
||||
auto ylo = fBox.Getylo();
|
||||
auto zlo = fBox.Getzlo();
|
||||
|
||||
auto xhi = fBox.Getxhi();
|
||||
auto yhi = fBox.Getyhi();
|
||||
auto zhi = fBox.Getzhi();
|
||||
|
||||
return (xhi - xlo) * (yhi - ylo) * (zhi - zlo);
|
||||
}
|
||||
|
||||
private:
|
||||
MapList fMapList;
|
||||
Index fIndex;
|
||||
G4DNABoundingBox fBox;
|
||||
};
|
||||
|
||||
class G4DNAMesh
|
||||
{
|
||||
public:
|
||||
using Index = G4Voxel::Index;
|
||||
using Key = unsigned int;
|
||||
using VoxelMap = std::map<Key, G4Voxel*>;
|
||||
G4DNAMesh(const G4DNABoundingBox&, G4int);
|
||||
~G4DNAMesh();
|
||||
|
||||
Key GetKey(const G4ThreeVector& pos) const;
|
||||
Index GetIndex(Key key) const;
|
||||
Index GetIndex(const G4ThreeVector& position) const;
|
||||
|
||||
G4Voxel* GetVoxel(Key key);
|
||||
[[maybe_unused]] G4Voxel* GetVoxel(const Index& index);
|
||||
size_t size() { return fMesh.size(); }
|
||||
Index GetIndex(const Index& index, int) const;
|
||||
std::vector<Index> FindVoxelNeighbors(const Index& index) const;
|
||||
std::vector<Index> FindNeighboringVoxels(const Index& index) const;
|
||||
void Reset();
|
||||
|
||||
G4Voxel::MapList& GetVoxelMapList(Key key);
|
||||
G4Voxel::MapList& GetVoxelMapList(const Index& index);
|
||||
|
||||
Key GetKey(const Index& index) const;
|
||||
VoxelMap::iterator end() { return fMesh.end(); }
|
||||
VoxelMap::iterator begin() { return fMesh.begin(); }
|
||||
VoxelMap::const_iterator end() const { return fMesh.end(); }
|
||||
VoxelMap::const_iterator begin() const { return fMesh.begin(); }
|
||||
|
||||
void PrintMesh();
|
||||
void PrintVoxel(const Index& index);
|
||||
const G4DNABoundingBox& GetBoundingBox() const;
|
||||
G4DNABoundingBox GetBoundingBox(const Index& index);
|
||||
G4int GetNumberOfType(G4Voxel::MolType type) const;
|
||||
void SetVoxelMapList(const Key& key, G4Voxel::MapList&& mapList);
|
||||
|
||||
G4double GetResolution() const;
|
||||
|
||||
private:
|
||||
VoxelMap fMesh;
|
||||
const G4DNABoundingBox* fpBoundingMesh;
|
||||
G4double fResolution;
|
||||
};
|
||||
#endif
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "G4ITReactionTable.hh"
|
||||
#include "G4MolecularConfiguration.hh"
|
||||
#include "G4ReferenceCast.hh"
|
||||
#include "G4VDNAMolecularGeometry.hh"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
@@ -208,6 +209,9 @@ public:
|
||||
|
||||
void SetReaction(G4DNAMolecularReactionData*);
|
||||
|
||||
void SetGeometry(G4VDNAMolecularGeometry* geometry){fGeometry = geometry;};
|
||||
G4VDNAMolecularGeometry* GetGeometry() const;
|
||||
|
||||
Data* GetReactionData(Reactant*, Reactant*) const;
|
||||
|
||||
Data* GetReactionData(const G4String&, const G4String&) const;
|
||||
@@ -238,6 +242,7 @@ public:
|
||||
protected:
|
||||
G4bool fVerbose;
|
||||
|
||||
G4VDNAMolecularGeometry* fGeometry;
|
||||
ReactionDataMap fReactionData;
|
||||
ReactivesMV fReactantsMV;
|
||||
ReactionDataMV fReactionDataMV;
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 G4DNASCAVENGERMATERIAL_HH
|
||||
#define G4DNASCAVENGERMATERIAL_HH
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "G4MoleculeCounter.hh"
|
||||
#include "G4VScavengerMaterial.hh"
|
||||
class G4Material;
|
||||
class G4MolecularConfiguration;
|
||||
class G4VChemistryWorld;
|
||||
|
||||
using NbMoleculeAgainstTime =
|
||||
std::map<G4double, G4int, G4::MoleculeCounter::TimePrecision>;
|
||||
|
||||
class G4DNAScavengerMaterial : public G4VScavengerMaterial
|
||||
{
|
||||
public:
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
using MaterialMap = std::map<MolType, G4double>;
|
||||
using ReactantList = std::vector<MolType>;
|
||||
using CounterMapType = std::map<MolType, NbMoleculeAgainstTime>;
|
||||
G4DNAScavengerMaterial() = default;
|
||||
explicit G4DNAScavengerMaterial(G4VChemistryWorld*);
|
||||
~G4DNAScavengerMaterial() override = default;
|
||||
G4DNAScavengerMaterial(const G4DNAScavengerMaterial& right) = delete;
|
||||
G4DNAScavengerMaterial& operator=(const G4DNAScavengerMaterial&) = delete;
|
||||
void Initialize();
|
||||
|
||||
void ReduceNumberMoleculePerVolumeUnitForMaterialConf(MolType, G4double);
|
||||
void AddNumberMoleculePerVolumeUnitForMaterialConf(MolType, G4double);
|
||||
G4double GetNumberMoleculePerVolumeUnitForMaterialConf(MolType) const;
|
||||
|
||||
void AddAMoleculeAtTime(MolType, G4double time,
|
||||
const G4ThreeVector* position = nullptr,
|
||||
G4int number = 1);
|
||||
void RemoveAMoleculeAtTime(MolType, G4double time,
|
||||
const G4ThreeVector* position = nullptr,
|
||||
G4int number = 1);
|
||||
|
||||
void Reset() override;
|
||||
|
||||
void PrintInfo();
|
||||
|
||||
MaterialMap::iterator end() { return fScavengerTable.end(); }
|
||||
MaterialMap::iterator begin() { return fScavengerTable.begin(); }
|
||||
size_t size() { return fScavengerTable.size(); }
|
||||
|
||||
G4bool find(MolType type)
|
||||
{
|
||||
auto it = fScavengerTable.find(type);
|
||||
if(it != fScavengerTable.end())
|
||||
{
|
||||
return it->second > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void SetCounterAgainstTime() { fCounterAgainstTime = true; }
|
||||
|
||||
std::vector<MolType> GetScavengerList() const
|
||||
{
|
||||
std::vector<MolType> output;
|
||||
for(const auto& it : fScavengerTable)
|
||||
{
|
||||
output.push_back(it.first);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void Dump();
|
||||
G4int GetNMoleculesAtTime(MolType molecule, G4double time);
|
||||
G4bool SearchTimeMap(MolType molecule);
|
||||
G4int SearchUpperBoundTime(G4double time, G4bool sameTypeOfMolecule);
|
||||
|
||||
private:
|
||||
G4VChemistryWorld* fpChemistryInfo;
|
||||
G4bool fIsInitialized;
|
||||
std::map<MolType, G4double> fScavengerTable;
|
||||
CounterMapType fCounterMap;
|
||||
G4bool fCounterAgainstTime;
|
||||
G4int fVerbose;
|
||||
struct Search
|
||||
{
|
||||
Search() { fLowerBoundSet = false; }
|
||||
CounterMapType::iterator fLastMoleculeSearched;
|
||||
NbMoleculeAgainstTime::iterator fLowerBoundTime;
|
||||
G4bool fLowerBoundSet;
|
||||
};
|
||||
|
||||
std::unique_ptr<Search> fpLastSearch;
|
||||
};
|
||||
#endif // G4DNASCAVENGERMATERIAL_HH
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 G4VCHEMISTRYWORLD_HH
|
||||
#define G4VCHEMISTRYWORLD_HH
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
class G4DNABoundingBox;
|
||||
class G4Material;
|
||||
class G4MolecularConfiguration;
|
||||
class G4VChemistryWorld
|
||||
{
|
||||
public:
|
||||
using MolType = const G4MolecularConfiguration*;
|
||||
G4VChemistryWorld() = default;
|
||||
virtual ~G4VChemistryWorld() = default;
|
||||
|
||||
virtual void ConstructChemistryBoundary() = 0;
|
||||
virtual void ConstructChemistryComponents() = 0;
|
||||
|
||||
std::map<MolType,double>::iterator begin()
|
||||
{
|
||||
return fpChemicalComponent.begin();
|
||||
}
|
||||
|
||||
std::map<MolType,double>::iterator end()
|
||||
{
|
||||
return fpChemicalComponent.end();
|
||||
}
|
||||
|
||||
size_t size()
|
||||
{
|
||||
return fpChemicalComponent.size();
|
||||
}
|
||||
|
||||
std::map<MolType,double>::const_iterator begin_const()
|
||||
{
|
||||
return fpChemicalComponent.begin();
|
||||
}
|
||||
|
||||
std::map<MolType,double>::const_iterator end_const()
|
||||
{
|
||||
return fpChemicalComponent.end();
|
||||
}
|
||||
|
||||
G4DNABoundingBox* GetChemistryBoundary() const
|
||||
{
|
||||
return fpChemistryBoundary.get();
|
||||
}
|
||||
protected:
|
||||
std::unique_ptr<G4DNABoundingBox> fpChemistryBoundary;
|
||||
std::map<MolType,double> fpChemicalComponent;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,11 @@ geant4_add_module(G4emdna-utils
|
||||
# physchemIO
|
||||
G4VPhysChemIO.hh
|
||||
G4PhysChemIO.hh
|
||||
G4IRTUtils.hh
|
||||
G4IRTUtils.hh
|
||||
G4DNAScavengerMaterial.hh
|
||||
G4VChemistryWorld.hh
|
||||
G4DNAMesh.hh
|
||||
G4DNAEventSet.hh
|
||||
SOURCES
|
||||
G4DNAChemistryManager.cc
|
||||
G4DNACPA100LogLogInterpolation.cc
|
||||
@@ -54,7 +58,10 @@ geant4_add_module(G4emdna-utils
|
||||
# physchemIO
|
||||
G4VPhysChemIO.cc
|
||||
G4PhysChemIO.cc
|
||||
G4IRTUtils.cc)
|
||||
G4IRTUtils.cc
|
||||
G4DNAScavengerMaterial.cc
|
||||
G4DNAMesh.cc
|
||||
G4DNAEventSet.cc)
|
||||
|
||||
geant4_module_link_libraries(G4emdna-utils
|
||||
PUBLIC
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
// ********************************************************************
|
||||
// * 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 "G4DNAEventSet.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
|
||||
Event::Event(G4double time, unsigned int key, ReactionData* pReactionData)
|
||||
: fTimeStep(time)
|
||||
, fKey(key)
|
||||
, fData(std::pair<std::unique_ptr<JumpingData>, ReactionData*>(nullptr,
|
||||
pReactionData))
|
||||
{}
|
||||
|
||||
Event::Event(G4double time, unsigned int key,
|
||||
std::unique_ptr<JumpingData>&& jumping)
|
||||
: fTimeStep(time)
|
||||
, fKey(key)
|
||||
, fData(std::pair<std::unique_ptr<JumpingData>, ReactionData*>(
|
||||
std::move(jumping), nullptr))
|
||||
{}
|
||||
|
||||
Event::~Event() = default;
|
||||
|
||||
void Event::PrintEvent() const
|
||||
{
|
||||
G4cout << "****PrintEvent::TimeStep : " << G4BestUnit(fTimeStep, "Time")
|
||||
<< " key : " << fKey << " action : ";
|
||||
if(std::get<0>(fData) == nullptr)
|
||||
{
|
||||
G4cout << std::get<1>(fData)->GetReactant1()->GetName() << " + "
|
||||
<< std::get<1>(fData)->GetReactant2()->GetName() << " -> "
|
||||
<< std::get<1>(fData)->GetProducts()->size() << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << std::get<0>(fData)->first->GetName() << " jumping to "
|
||||
<< std::get<0>(fData)->second << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool comparatorEventSet::operator()(std::unique_ptr<Event> const& rhs,
|
||||
std::unique_ptr<Event> const& lhs) const
|
||||
{
|
||||
return rhs->GetTime() < lhs->GetTime();
|
||||
}
|
||||
|
||||
G4DNAEventSet::G4DNAEventSet()
|
||||
: fEventSet(comparatorEventSet())
|
||||
{}
|
||||
|
||||
void G4DNAEventSet::CreateEvent(G4double time, Key key,
|
||||
Event::ReactionData* pReactionData)
|
||||
{
|
||||
auto pEvent = std::make_unique<Event>(time, key, pReactionData);
|
||||
AddEvent(std::move(pEvent));
|
||||
}
|
||||
|
||||
void G4DNAEventSet::CreateEvent(G4double time, Key key,
|
||||
std::unique_ptr<Event::JumpingData> jum)
|
||||
{
|
||||
auto pEvent = std::make_unique<Event>(time, key, std::move(jum));
|
||||
AddEvent(std::move(pEvent));
|
||||
}
|
||||
|
||||
void G4DNAEventSet::RemoveEventOfVoxel(const size_t& key)
|
||||
{
|
||||
auto it = fEventMap.find(key);
|
||||
if(it != fEventMap.end())
|
||||
{
|
||||
fEventSet.erase(it->second);
|
||||
fEventMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAEventSet::RemoveEvent(EventSet::iterator iter)
|
||||
{
|
||||
auto key = (*iter)->GetKey();
|
||||
RemoveEventOfVoxel(key);
|
||||
}
|
||||
|
||||
void G4DNAEventSet::AddEvent(std::unique_ptr<Event> pEvent)
|
||||
{
|
||||
// idea is no 2 events in one key (or index)
|
||||
auto key = pEvent->GetKey();
|
||||
RemoveEventOfVoxel(key);
|
||||
auto it = fEventSet.emplace(std::move(pEvent));
|
||||
fEventMap[key] = std::get<0>(it);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________________
|
||||
|
||||
G4DNAEventSet::~G4DNAEventSet() { RemoveEventSet(); }
|
||||
|
||||
[[maybe_unused]] void G4DNAEventSet::PrintEventSet()
|
||||
{
|
||||
G4cout << "G4DNAEventSet::PrintEventSet()" << G4endl;
|
||||
for(const auto& it : fEventSet)
|
||||
{
|
||||
(*it).PrintEvent();
|
||||
}
|
||||
G4cout << "End PrintEventSet()" << G4endl;
|
||||
G4cout << G4endl;
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
// ********************************************************************
|
||||
// * 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 "G4DNAMesh.hh"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <ostream>
|
||||
|
||||
G4DNAMesh::G4DNAMesh(const G4DNABoundingBox& boundingBox, G4int pixel)
|
||||
: fpBoundingMesh(&boundingBox)
|
||||
, fResolution((2 * boundingBox.halfSideLengthInY() / pixel))
|
||||
{}
|
||||
|
||||
G4DNAMesh::~G4DNAMesh() { Reset(); }
|
||||
|
||||
G4Voxel::MapList& G4DNAMesh::GetVoxelMapList(Key key)
|
||||
{
|
||||
auto iter = fMesh.find(key);
|
||||
if(iter == fMesh.end())
|
||||
{
|
||||
G4Voxel::MapList maplist;
|
||||
SetVoxelMapList(key, std::move(maplist));
|
||||
return GetVoxelMapList(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return iter->second->GetMapList();
|
||||
}
|
||||
}
|
||||
|
||||
G4Voxel::MapList& G4DNAMesh::GetVoxelMapList(const Index& index)
|
||||
{
|
||||
auto key = GetKey(index);
|
||||
return GetVoxelMapList(key);
|
||||
}
|
||||
|
||||
G4DNAMesh::Key G4DNAMesh::GetKey(const Index& index) const
|
||||
{
|
||||
auto xmax = (unsigned int) (std::floor(
|
||||
(fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution));
|
||||
auto ymax = (unsigned int) (std::floor(
|
||||
(fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution));
|
||||
return index.z * ymax * xmax + index.y * xmax + index.x;
|
||||
}
|
||||
|
||||
void G4DNAMesh::PrintMesh()
|
||||
{
|
||||
G4cout << "*********PrintMesh::Size : " << fMesh.size() << G4endl;
|
||||
auto iter = fMesh.begin();
|
||||
for(; iter != fMesh.end(); iter++)
|
||||
{
|
||||
auto index = iter->second->GetIndex();
|
||||
PrintVoxel(index);
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
G4int G4DNAMesh::GetNumberOfType(G4Voxel::MolType type) const
|
||||
{
|
||||
G4int output = 0;
|
||||
auto iter = fMesh.begin();
|
||||
for(; iter != fMesh.end(); iter++)
|
||||
{
|
||||
auto node = dynamic_cast<G4Voxel*>(iter->second);
|
||||
if(node == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
auto it = node->GetMapList().find(type);
|
||||
if(it != node->GetMapList().end())
|
||||
{
|
||||
output += it->second;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void G4DNAMesh::PrintVoxel(const Index& index)
|
||||
{
|
||||
G4cout << "*********PrintVoxel::";
|
||||
G4cout << "key: " << GetKey(index) << " index : " << index
|
||||
<< " number of type : " << this->GetVoxelMapList(index).size()
|
||||
<< G4endl;
|
||||
|
||||
for(const auto& it : this->GetVoxelMapList(index))
|
||||
{
|
||||
G4cout << "_____________" << it.first->GetName() << " : " << it.second
|
||||
<< G4endl;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
void G4DNAMesh::SetVoxelMapList(const Key& key, G4Voxel::MapList&& mapList)
|
||||
{
|
||||
auto index = GetIndex(key);
|
||||
auto pVoxel = fMesh[key];
|
||||
if(nullptr == pVoxel)
|
||||
{
|
||||
pVoxel = new G4Voxel(std::move(mapList), index, GetBoundingBox(index));
|
||||
fMesh[key] = pVoxel;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(pVoxel->GetMapList().empty()); // check if map list is empty
|
||||
pVoxel->SetMapList(std::move(mapList));
|
||||
}
|
||||
}
|
||||
|
||||
G4Voxel::Index G4DNAMesh::GetIndex(const G4ThreeVector& position) const
|
||||
{
|
||||
int dx = std::floor((position.x() - fpBoundingMesh->Getxlo()) / fResolution);
|
||||
int dy = std::floor((position.y() - fpBoundingMesh->Getylo()) / fResolution);
|
||||
int dz = std::floor((position.z() - fpBoundingMesh->Getzlo()) / fResolution);
|
||||
assert(dx >= 0 && dy >= 0 && dz >= 0);
|
||||
return G4Voxel::Index{ dx, dy, dz };
|
||||
}
|
||||
G4Voxel::Index G4DNAMesh::GetIndex(const Index& index, int pixels) const
|
||||
{
|
||||
int xmax =
|
||||
std::floor((fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution);
|
||||
int ymax =
|
||||
std::floor((fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution);
|
||||
int zmax =
|
||||
std::floor((fpBoundingMesh->Getzhi() - fpBoundingMesh->Getzlo()) / fResolution);
|
||||
int dx = (int) (index.x * pixels / xmax);
|
||||
int dy = (int) (index.y * pixels / ymax);
|
||||
int dz = (int) (index.z * pixels / zmax);
|
||||
assert(dx >= 0 && dy >= 0 && dz >= 0);
|
||||
return Index{ dx, dy, dz };
|
||||
}
|
||||
|
||||
G4DNABoundingBox G4DNAMesh::GetBoundingBox(const Index& index)
|
||||
{
|
||||
auto xlo = fpBoundingMesh->Getxlo() + index.x * fResolution;
|
||||
auto ylo = fpBoundingMesh->Getylo() + index.y * fResolution;
|
||||
auto zlo = fpBoundingMesh->Getzlo() + index.z * fResolution;
|
||||
|
||||
auto xhi = fpBoundingMesh->Getxlo() + (index.x + 1) * fResolution;
|
||||
auto yhi = fpBoundingMesh->Getylo() + (index.y + 1) * fResolution;
|
||||
auto zhi = fpBoundingMesh->Getzlo() + (index.z + 1) * fResolution;
|
||||
return G4DNABoundingBox({ xhi, xlo, yhi, ylo, zhi, zlo });
|
||||
}
|
||||
|
||||
G4Voxel::Index G4DNAMesh::GetIndex(Key key) const
|
||||
{
|
||||
G4int xmax =
|
||||
std::floor((fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution);
|
||||
G4int ymax =
|
||||
std::floor((fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution);
|
||||
G4int id = key;
|
||||
G4int x_ = id % xmax;
|
||||
id /= xmax;
|
||||
G4int y_ = id % ymax;
|
||||
id /= ymax;
|
||||
G4int z_ = id;
|
||||
|
||||
if(xmax != ymax)
|
||||
{
|
||||
G4cout << xmax << " " << ymax << " " << key << G4endl;
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "xmax != ymax";
|
||||
G4Exception("G4DNAMesh::GetIndex", "G4DNAMesh006", FatalErrorInArgument,
|
||||
exceptionDescription);
|
||||
}
|
||||
|
||||
if(x_ < 0 || y_ < 0 || z_ < 0)
|
||||
{
|
||||
G4cout << xmax << " " << ymax << " " << key << G4endl;
|
||||
G4cout << x_ << " " << y_ << " " << z_ << G4endl;
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "x_ < 0 || y_ < 0 || z_ < 0";
|
||||
G4Exception("G4DNAMesh::GetIndex", "G4DNAMesh005", FatalErrorInArgument,
|
||||
exceptionDescription);
|
||||
}
|
||||
return Index{ x_, y_, z_ };
|
||||
}
|
||||
|
||||
void G4DNAMesh::Reset()
|
||||
{
|
||||
if(fMesh.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(auto iter : fMesh) // should use smart ptr
|
||||
{
|
||||
delete iter.second;
|
||||
}
|
||||
fMesh.clear();
|
||||
}
|
||||
|
||||
const G4DNABoundingBox& G4DNAMesh::GetBoundingBox() const
|
||||
{
|
||||
return *fpBoundingMesh;
|
||||
}
|
||||
|
||||
G4Voxel* G4DNAMesh::GetVoxel(Key key)
|
||||
{
|
||||
auto it = fMesh.find(key);
|
||||
if(it != fMesh.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
[[maybe_unused]] G4Voxel* G4DNAMesh::GetVoxel(const Index& index)
|
||||
{
|
||||
return GetVoxel(GetKey(index));
|
||||
}
|
||||
|
||||
std::vector<G4Voxel::Index> // array is better ?
|
||||
G4DNAMesh::FindVoxelNeighbors(const Index& index) const
|
||||
{
|
||||
std::vector<Index> neighbors;
|
||||
|
||||
auto xMax = (int) (std::floor(
|
||||
(fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution));
|
||||
auto yMax = (int) (std::floor(
|
||||
(fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution));
|
||||
auto zMax = (int) (std::floor(
|
||||
(fpBoundingMesh->Getzhi() - fpBoundingMesh->Getzlo()) / fResolution));
|
||||
|
||||
auto xmin = (index.x - 1) < 0 ? 0 : (index.x - 1);
|
||||
auto ymin = (index.y - 1) < 0 ? 0 : (index.y - 1);
|
||||
auto zmin = (index.z - 1) < 0 ? 0 : (index.z - 1);
|
||||
|
||||
auto xmax = (index.x + 1) > xMax ? xMax : (index.x + 1);
|
||||
auto ymax = (index.y + 1) > yMax ? yMax : (index.y + 1);
|
||||
auto zmax = (index.z + 1) > zMax ? zMax : (index.z + 1);
|
||||
for(int ix = xmin; ix <= xmax; ix++)
|
||||
{
|
||||
for(int iy = ymin; iy <= ymax; iy++)
|
||||
{
|
||||
for(int iz = zmin; iz <= zmax; iz++)
|
||||
{
|
||||
auto key = iz * yMax * xMax + iy * xMax + ix;
|
||||
if(GetIndex(key) != index)
|
||||
{ // deleting the middle element
|
||||
neighbors.push_back(GetIndex(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(neighbors.empty())
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "neighbors.empty()";
|
||||
G4Exception("G4DNAMesh::FindVoxelNeighbors", "G4DNAMesh001",
|
||||
FatalErrorInArgument, exceptionDescription);
|
||||
}
|
||||
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
std::vector<G4Voxel::Index> // array is better ?
|
||||
G4DNAMesh::FindNeighboringVoxels(const Index& index) const
|
||||
{
|
||||
std::vector<Index> neighbors;
|
||||
// auto key = GetKey(index);
|
||||
auto xMax = (int) (std::floor(
|
||||
(fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution));
|
||||
auto yMax = (int) (std::floor(
|
||||
(fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution));
|
||||
auto zMax = (int) (std::floor(
|
||||
(fpBoundingMesh->Getzhi() - fpBoundingMesh->Getzlo()) / fResolution));
|
||||
|
||||
if(index.x - 1 >= 0)
|
||||
{
|
||||
neighbors.emplace_back(Index(index.x - 1, index.y, index.z));
|
||||
}
|
||||
if(index.y - 1 >= 0)
|
||||
{
|
||||
neighbors.emplace_back(Index(index.x, index.y - 1, index.z));
|
||||
}
|
||||
if(index.z - 1 >= 0)
|
||||
{
|
||||
neighbors.emplace_back(Index(index.x, index.y, index.z - 1));
|
||||
}
|
||||
if(index.x + 1 < xMax)
|
||||
{
|
||||
neighbors.emplace_back(Index(index.x + 1, index.y, index.z));
|
||||
}
|
||||
if(index.y + 1 < yMax)
|
||||
{
|
||||
neighbors.emplace_back(Index(index.x, index.y + 1, index.z));
|
||||
}
|
||||
if(index.z + 1 < zMax)
|
||||
{
|
||||
neighbors.emplace_back(Index(index.x, index.y, index.z + 1));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
G4cout << "Neighbors of : " << index << G4endl;
|
||||
for(const auto& it : neighbors)
|
||||
{
|
||||
G4cout << it << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(neighbors.size() > 6)
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "neighbors.size() > 6";
|
||||
G4Exception("G4DNAMesh::FindVoxelNeighbors", "G4DNAMesh002",
|
||||
FatalErrorInArgument, exceptionDescription);
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
G4double G4DNAMesh::GetResolution() const { return fResolution; }
|
||||
|
||||
G4DNAMesh::Key G4DNAMesh::GetKey(const G4ThreeVector& position) const
|
||||
{
|
||||
if(!fpBoundingMesh->contains(position))
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "the position: " << position
|
||||
<< " is not in the box";
|
||||
G4Exception("G4DNAMesh::GetKey", "G4DNAMesh010", FatalErrorInArgument,
|
||||
exceptionDescription);
|
||||
}
|
||||
|
||||
auto dx = std::floor((position.x() - fpBoundingMesh->Getxlo()) / fResolution);
|
||||
auto dy = std::floor((position.y() - fpBoundingMesh->Getylo()) / fResolution);
|
||||
auto dz = std::floor((position.z() - fpBoundingMesh->Getzlo()) / fResolution);
|
||||
auto xmax =
|
||||
std::floor((fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution);
|
||||
auto ymax =
|
||||
std::floor((fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution);
|
||||
return dz * ymax * xmax + dy * xmax + dx;
|
||||
}
|
||||
@@ -382,6 +382,7 @@ void G4DNAMolecularReactionTable::DeleteInstance()
|
||||
G4DNAMolecularReactionTable::G4DNAMolecularReactionTable()
|
||||
: G4ITReactionTable()
|
||||
, fVerbose(false)
|
||||
, fGeometry(nullptr)
|
||||
, fpMessenger(new G4ReactionTableMessenger(this))
|
||||
{
|
||||
}
|
||||
@@ -592,6 +593,11 @@ void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel
|
||||
//______________________________________________________________________________
|
||||
// Get/Set methods
|
||||
|
||||
G4VDNAMolecularGeometry* G4DNAMolecularReactionTable::GetGeometry() const
|
||||
{
|
||||
return fGeometry;
|
||||
}
|
||||
|
||||
G4DNAMolecularReactionTable::Data*
|
||||
G4DNAMolecularReactionTable::GetReactionData(Reactant* pReactant1,
|
||||
Reactant* pReactant2) const
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 "G4DNAScavengerMaterial.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4DNAMolecularMaterial.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4MolecularConfiguration.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4DNABoundingBox.hh"
|
||||
#include "G4VChemistryWorld.hh"
|
||||
#include "G4Scheduler.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4MoleculeTable.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
G4DNAScavengerMaterial::G4DNAScavengerMaterial(
|
||||
G4VChemistryWorld* pChemistryInfo)
|
||||
: G4VScavengerMaterial()
|
||||
, fpChemistryInfo(pChemistryInfo)
|
||||
, fIsInitialized(false)
|
||||
, fCounterAgainstTime(false)
|
||||
, fVerbose(0)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4DNAScavengerMaterial::Initialize()
|
||||
{
|
||||
if(fIsInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(fpChemistryInfo->size() == 0)
|
||||
{
|
||||
G4cout << "G4DNAScavengerMaterial existed but empty" << G4endl;
|
||||
}
|
||||
Reset();
|
||||
fIsInitialized = true;
|
||||
}
|
||||
|
||||
G4double G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
MolType matConf) const
|
||||
{
|
||||
// no change these molecules
|
||||
if(G4MoleculeTable::Instance()->GetConfiguration("H2O") == matConf)
|
||||
{
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "matConf : "<<matConf->GetName();
|
||||
G4Exception("G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf", "G4DNAScavengerMaterial001",
|
||||
FatalErrorInArgument, exceptionDescription);
|
||||
}
|
||||
|
||||
auto iter = fScavengerTable.find(matConf);
|
||||
if(iter == fScavengerTable.end())
|
||||
{
|
||||
// G4cout<<matConf->GetName()<<G4endl;
|
||||
// throw std::runtime_error("this material is not existed");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(iter->second >= 1)
|
||||
{
|
||||
return (floor)(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAScavengerMaterial::ReduceNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
MolType matConf, G4double time)
|
||||
{
|
||||
// no change these molecules
|
||||
if(G4MoleculeTable::Instance()->GetConfiguration("H2O") == matConf ||
|
||||
G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)") ==
|
||||
matConf || // suppose that pH is not changed during simu
|
||||
G4MoleculeTable::Instance()->GetConfiguration("OHm(B)") == matConf)
|
||||
{
|
||||
// G4cout<<"moletype : "<<matConf->GetName()<<G4endl;
|
||||
// kobs is already counted these molecule concentrations
|
||||
return;
|
||||
}
|
||||
if(!find(matConf)) // matConf must greater than 0
|
||||
{
|
||||
return;
|
||||
}
|
||||
fScavengerTable[matConf]--;
|
||||
if(fScavengerTable[matConf] < 0) // projection
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if(fCounterAgainstTime)
|
||||
{
|
||||
RemoveAMoleculeAtTime(matConf, time);
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAScavengerMaterial::AddNumberMoleculePerVolumeUnitForMaterialConf(
|
||||
MolType matConf, G4double time)
|
||||
{
|
||||
// no change these molecules
|
||||
|
||||
if(G4MoleculeTable::Instance()->GetConfiguration("H2O") == matConf ||
|
||||
G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)") ==
|
||||
matConf || // pH has no change
|
||||
G4MoleculeTable::Instance()->GetConfiguration("OHm(B)") == matConf)
|
||||
{
|
||||
// G4cout<<"moletype : "<<matConf->GetName()<<G4endl;
|
||||
// kobs is already counted these molecule concentrations
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = fScavengerTable.find(matConf);
|
||||
if(it == fScavengerTable.end()) // matConf must be in fScavengerTable
|
||||
{
|
||||
return;
|
||||
}
|
||||
fScavengerTable[matConf]++;
|
||||
|
||||
if(fCounterAgainstTime)
|
||||
{
|
||||
AddAMoleculeAtTime(matConf, time);
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAScavengerMaterial::PrintInfo()
|
||||
{
|
||||
auto pConfinedBox = fpChemistryInfo->GetChemistryBoundary();
|
||||
auto iter = fpChemistryInfo->begin();
|
||||
G4cout << "**************************************************************"
|
||||
<< G4endl;
|
||||
for(; iter != fpChemistryInfo->end(); iter++)
|
||||
{
|
||||
auto containedConf = iter->first;
|
||||
// auto concentration = iter->second;
|
||||
auto concentration =
|
||||
fScavengerTable[containedConf] / (Avogadro * pConfinedBox->Volume());
|
||||
G4cout << "Scavenger:" << containedConf->GetName() << " : "
|
||||
<< concentration / 1.0e-6 /*mm3 to L*/ << " (M) with : "
|
||||
<< fScavengerTable[containedConf] << " (molecules)"
|
||||
<< "in: " << pConfinedBox->Volume() / (um * um * um) << " (um3)"
|
||||
<< G4endl;
|
||||
if(fScavengerTable[containedConf] < 1)
|
||||
{
|
||||
G4cout << "!!!!!!!!!!!!! this molecule has less one molecule for "
|
||||
"considered volume"
|
||||
<< G4endl;
|
||||
// assert(false);
|
||||
}
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
Dump();
|
||||
}
|
||||
}
|
||||
G4cout << "**************************************************************"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
void G4DNAScavengerMaterial::Reset()
|
||||
{
|
||||
if(fpChemistryInfo == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(fpChemistryInfo->size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fScavengerTable.clear();
|
||||
fCounterMap.clear();
|
||||
fpLastSearch.reset(nullptr);
|
||||
|
||||
auto pConfinedBox = fpChemistryInfo->GetChemistryBoundary();
|
||||
auto iter = fpChemistryInfo->begin();
|
||||
for(; iter != fpChemistryInfo->end(); iter++)
|
||||
{
|
||||
auto containedConf = iter->first;
|
||||
auto concentration = iter->second;
|
||||
fScavengerTable[containedConf] =
|
||||
floor(Avogadro * concentration * pConfinedBox->Volume());
|
||||
fCounterMap[containedConf][1 * picosecond] =
|
||||
floor(Avogadro * concentration * pConfinedBox->Volume());
|
||||
}
|
||||
PrintInfo();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4DNAScavengerMaterial::AddAMoleculeAtTime(
|
||||
MolType molecule, G4double time, const G4ThreeVector* /*position*/,
|
||||
int number)
|
||||
{
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
G4cout << "G4DNAScavengerMaterial::AddAMoleculeAtTime : "
|
||||
<< molecule->GetName() << " at time : " << G4BestUnit(time, "Time")
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
auto counterMap_i = fCounterMap.find(molecule);
|
||||
|
||||
if(counterMap_i == fCounterMap.end())
|
||||
{
|
||||
fCounterMap[molecule][time] = number;
|
||||
}
|
||||
else if(counterMap_i->second.empty())
|
||||
{
|
||||
counterMap_i->second[time] = number;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto end = counterMap_i->second.rbegin();
|
||||
|
||||
if(end->first <= time || fabs(end->first - time) <=
|
||||
G4::MoleculeCounter::TimePrecision::fPrecision)
|
||||
{
|
||||
G4double newValue = end->second + number;
|
||||
counterMap_i->second[time] = newValue;
|
||||
if(newValue != (floor)(fScavengerTable[molecule])) // protection
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
// G4cout<<" AddAMoleculeAtTime : "<<molecule->GetName()<< " :
|
||||
// "<<newValue<<G4endl;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
//
|
||||
// G4ExceptionDescription errMsg;
|
||||
// errMsg << "Time of species "
|
||||
// << molecule->GetName() << " is "
|
||||
// << G4BestUnit(time, "Time") << " while "
|
||||
// << " global time is "
|
||||
// <<" end->first : "<<end->first
|
||||
// //<<
|
||||
// G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(),
|
||||
// "Time")
|
||||
// << G4endl;
|
||||
// G4Exception("G4DNAScavengerMaterial::AddAMoleculeAtTime",
|
||||
// "TIME_DONT_MATCH",
|
||||
// FatalException, errMsg);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4DNAScavengerMaterial::RemoveAMoleculeAtTime(
|
||||
MolType pMolecule, G4double time, const G4ThreeVector* /*position*/,
|
||||
int number)
|
||||
{
|
||||
NbMoleculeAgainstTime& nbMolPerTime = fCounterMap[pMolecule];
|
||||
|
||||
if(fVerbose != 0)
|
||||
{
|
||||
auto it_ = nbMolPerTime.rbegin();
|
||||
G4cout << "G4DNAScavengerMaterial::RemoveAMoleculeAtTime : "
|
||||
<< pMolecule->GetName() << " at time : " << G4BestUnit(time, "Time")
|
||||
|
||||
<< " form : " << it_->second << G4endl;
|
||||
}
|
||||
|
||||
if(nbMolPerTime.empty())
|
||||
{
|
||||
Dump();
|
||||
G4String errMsg = "You are trying to remove molecule " +
|
||||
pMolecule->GetName() +
|
||||
" from the counter while this kind of molecules has not "
|
||||
"been registered yet";
|
||||
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "",
|
||||
FatalErrorInArgument, errMsg);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = nbMolPerTime.rbegin();
|
||||
|
||||
if(it == nbMolPerTime.rend())
|
||||
{
|
||||
it--;
|
||||
|
||||
G4String errMsg = "There was no " + pMolecule->GetName() +
|
||||
" recorded at the time or even before the time asked";
|
||||
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "",
|
||||
FatalErrorInArgument, errMsg);
|
||||
}
|
||||
|
||||
G4double finalN = it->second - number;
|
||||
if(finalN < 0)
|
||||
{
|
||||
Dump();
|
||||
|
||||
G4cout << "fScavengerTable : " << pMolecule->GetName() << " : "
|
||||
<< (fScavengerTable[pMolecule]) << G4endl;
|
||||
|
||||
G4ExceptionDescription errMsg;
|
||||
errMsg << "After removal of " << number << " species of "
|
||||
<< " " << it->second << " " << pMolecule->GetName()
|
||||
<< " the final number at time " << G4BestUnit(time, "Time")
|
||||
<< " is less than zero and so not valid." << G4endl;
|
||||
G4cout << " Global time is "
|
||||
<< G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(), "Time")
|
||||
<< ". Previous selected time is " << G4BestUnit(it->first, "Time")
|
||||
<< G4endl;
|
||||
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "N_INF_0",
|
||||
FatalException, errMsg);
|
||||
}
|
||||
nbMolPerTime[time] = finalN;
|
||||
|
||||
if(finalN != (floor)(fScavengerTable[pMolecule])) // protection
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNAScavengerMaterial::Dump()
|
||||
{
|
||||
auto pConfinedBox = fpChemistryInfo->GetChemistryBoundary();
|
||||
auto V = pConfinedBox->Volume();
|
||||
for(auto it : fCounterMap)
|
||||
{
|
||||
auto pReactant = it.first;
|
||||
|
||||
G4cout << " --- > For " << pReactant->GetName() << G4endl;
|
||||
|
||||
for(auto it2 : it.second)
|
||||
{
|
||||
G4cout << " " << G4BestUnit(it2.first, "Time") << " "
|
||||
<< it2.second / (Avogadro * V * 1.0e-6 /*mm3 to L*/) << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int G4DNAScavengerMaterial::GetNMoleculesAtTime(MolType molecule, G4double time)
|
||||
{
|
||||
if(!fCounterAgainstTime)
|
||||
{
|
||||
G4cout << "fCounterAgainstTime == false" << G4endl;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
G4bool sameTypeOfMolecule = SearchTimeMap(molecule);
|
||||
return SearchUpperBoundTime(time, sameTypeOfMolecule);
|
||||
}
|
||||
|
||||
G4bool G4DNAScavengerMaterial::SearchTimeMap(MolType molecule)
|
||||
{
|
||||
if(fpLastSearch == nullptr)
|
||||
{
|
||||
fpLastSearch = std::make_unique<Search>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fpLastSearch->fLowerBoundSet &&
|
||||
fpLastSearch->fLastMoleculeSearched->first == molecule)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
auto mol_it = fCounterMap.find(molecule);
|
||||
fpLastSearch->fLastMoleculeSearched = mol_it;
|
||||
|
||||
if(mol_it != fCounterMap.end())
|
||||
{
|
||||
fpLastSearch->fLowerBoundTime =
|
||||
fpLastSearch->fLastMoleculeSearched->second.end();
|
||||
fpLastSearch->fLowerBoundSet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fpLastSearch->fLowerBoundSet = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int G4DNAScavengerMaterial::SearchUpperBoundTime(G4double time,
|
||||
G4bool sameTypeOfMolecule)
|
||||
{
|
||||
auto mol_it = fpLastSearch->fLastMoleculeSearched;
|
||||
if(mol_it == fCounterMap.end())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NbMoleculeAgainstTime& timeMap = mol_it->second;
|
||||
if(timeMap.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(sameTypeOfMolecule)
|
||||
{
|
||||
if(fpLastSearch->fLowerBoundSet &&
|
||||
fpLastSearch->fLowerBoundTime != timeMap.end())
|
||||
{
|
||||
if(fpLastSearch->fLowerBoundTime->first < time)
|
||||
{
|
||||
auto upperToLast = fpLastSearch->fLowerBoundTime;
|
||||
upperToLast++;
|
||||
|
||||
if(upperToLast == timeMap.end())
|
||||
{
|
||||
return fpLastSearch->fLowerBoundTime->second;
|
||||
}
|
||||
|
||||
if(upperToLast->first > time)
|
||||
{
|
||||
return fpLastSearch->fLowerBoundTime->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto up_time_it = timeMap.upper_bound(time);
|
||||
|
||||
if(up_time_it == timeMap.end())
|
||||
{
|
||||
auto last_time = timeMap.rbegin();
|
||||
return last_time->second;
|
||||
}
|
||||
if(up_time_it == timeMap.begin())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
up_time_it--;
|
||||
|
||||
fpLastSearch->fLowerBoundTime = up_time_it;
|
||||
fpLastSearch->fLowerBoundSet = true;
|
||||
|
||||
return fpLastSearch->fLowerBoundTime->second;
|
||||
}
|
||||
Reference in New Issue
Block a user