Import Geant4 11.4.0.beta source tree
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// Created by ngoc hoang tran on 03/08/2023.
|
||||
//
|
||||
|
||||
#include "G4ChemEquilibrium.hh"
|
||||
#include "G4DNAMolecularReactionTable.hh"
|
||||
|
||||
G4ChemEquilibrium::G4ChemEquilibrium(const G4int& type, const G4double& time)
|
||||
: fEquilibriumDuration(time), fRectionType(type)
|
||||
{}
|
||||
|
||||
void G4ChemEquilibrium::Initialize()
|
||||
{
|
||||
Reset();
|
||||
MolType H2O =
|
||||
G4MoleculeTable::Instance()->GetConfiguration("H2O");
|
||||
MolType H3OpB =
|
||||
G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)");
|
||||
MolType OHmB =
|
||||
G4MoleculeTable::Instance()->GetConfiguration("OHm(B)");
|
||||
const auto& reactionList = G4DNAMolecularReactionTable::Instance()->
|
||||
GetVectorOfReactionData();
|
||||
for(const auto& it : reactionList)
|
||||
{
|
||||
if(it->GetReactionType()==fRectionType)
|
||||
{
|
||||
if(it->GetReactant1() != H2O
|
||||
&& it->GetReactant1() != H3OpB
|
||||
&& it->GetReactant1() != OHmB)
|
||||
{
|
||||
fReactant1 = it->GetReactant1();
|
||||
fReactantB1 = it->GetReactant2();
|
||||
}else
|
||||
{
|
||||
fReactant1 = it->GetReactant2();
|
||||
fReactantB1 = it->GetReactant1();
|
||||
}
|
||||
for(const auto& itt : *(it->GetProducts()))
|
||||
{
|
||||
if(itt != H3OpB
|
||||
&& itt != OHmB)
|
||||
{
|
||||
fReactant2 = itt;
|
||||
}else
|
||||
{
|
||||
fReactantB2 = itt;
|
||||
}
|
||||
}
|
||||
if(fVerbose > 1) {
|
||||
G4cout << "Equilibrium processes(ID) " << fRectionType << " : " << fReactant1->GetName()
|
||||
<< " <=> " << fReactant2->GetName()
|
||||
<< " Time to Equilibrium : " << fEquilibriumDuration / CLHEP::us
|
||||
<< " Initial status : " << fAddEquilibrium << G4endl;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4ChemEquilibrium::PrintInfo() const
|
||||
{
|
||||
G4cout<<"Equilibrium reactions : "<<fReactant1->GetName()
|
||||
<<" + "<<fReactantB1->GetName()
|
||||
<<" <=> "<<fReactant2->GetName()
|
||||
<<" + "<<fReactantB2->GetName()
|
||||
<<" Status : "<<fAddEquilibrium
|
||||
<<" from "<<G4BestUnit(fEquilibriumTime,"Time")<<" to "
|
||||
<<G4BestUnit(fEquilibriumTime + fEquilibriumDuration,"Time")<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
void G4ChemEquilibrium::SetEquilibrium(Reaction pReaction)
|
||||
{
|
||||
if(pReaction == nullptr){
|
||||
return;
|
||||
}
|
||||
if(pReaction->GetReactionType() != fRectionType)
|
||||
{
|
||||
std::vector<MolType> molVector;
|
||||
molVector.push_back(pReaction->GetReactant1());
|
||||
molVector.push_back(pReaction->GetReactant2());
|
||||
const G4int nbProducts = pReaction->GetNbProducts();
|
||||
if (nbProducts) {
|
||||
for (G4int j = 0; j < nbProducts; ++j) {
|
||||
auto product = pReaction->GetProduct(j);
|
||||
molVector.push_back(product);
|
||||
}
|
||||
}
|
||||
for(const auto& it : molVector)
|
||||
{
|
||||
if(it == fReactant1 || it == fReactant2 )
|
||||
{
|
||||
fAddEquilibrium = true;
|
||||
fEquilibriumTime = fGlobalTime;
|
||||
if(fVerbose >1)
|
||||
{
|
||||
G4cout << "Reaction type : " << pReaction->GetReactionType() << " : "
|
||||
<< pReaction->GetReactant1()->GetName() << " + "
|
||||
<< pReaction->GetReactant2()->GetName() << G4endl;
|
||||
G4cout << "SetEquilibrium : on " << fRectionType << " fEquilibriumTime : "
|
||||
<< G4BestUnit(fEquilibriumTime, "Time")<<G4endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "G4H2O.hh"
|
||||
#include "G4MolecularConfiguration.hh"
|
||||
#include "G4Molecule.hh"
|
||||
#include "G4MoleculeCounterManager.hh"
|
||||
#include "G4MoleculeFinder.hh"
|
||||
#include "G4MoleculeTable.hh"
|
||||
#include "G4PhysChemIO.hh"
|
||||
@@ -186,7 +187,8 @@ void G4DNAChemistryManager::Clear()
|
||||
|
||||
G4DNAMolecularReactionTable::DeleteInstance();
|
||||
G4MolecularConfiguration::DeleteManager();
|
||||
G4VMoleculeCounter::DeleteInstance();
|
||||
if (G4MoleculeCounterManager::GetInstanceIfExists() != nullptr)
|
||||
G4MoleculeCounterManager::DeleteInstance();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -325,11 +327,9 @@ void G4DNAChemistryManager::Run()
|
||||
}
|
||||
|
||||
G4MoleculeTable::Instance()->Finalize();
|
||||
|
||||
G4Scheduler::Instance()->Process();
|
||||
if (fResetCounterWhenRunEnds)
|
||||
{
|
||||
G4VMoleculeCounter::Instance()->ResetCounter();
|
||||
}
|
||||
|
||||
CloseFile();
|
||||
}
|
||||
|
||||
@@ -418,6 +418,10 @@ void G4DNAChemistryManager::InitializeMaster()
|
||||
|
||||
G4Scheduler::Instance();
|
||||
// creates a concrete object of the scheduler
|
||||
|
||||
if (G4MoleculeCounterManager::GetInstanceIfExists() != nullptr)
|
||||
G4MoleculeCounterManager::Instance()->Initialize();
|
||||
|
||||
fMasterInitialized = true;
|
||||
}
|
||||
|
||||
@@ -484,9 +488,10 @@ void G4DNAChemistryManager::InitializeThread()
|
||||
|
||||
G4Scheduler::Instance()->Initialize();
|
||||
|
||||
fpThreadData->fThreadInitialized = true;
|
||||
if (G4MoleculeCounterManager::GetInstanceIfExists() != nullptr)
|
||||
G4MoleculeCounterManager::Instance()->Initialize();
|
||||
|
||||
G4VMoleculeCounter::InitializeInstance();
|
||||
fpThreadData->fThreadInitialized = true;
|
||||
|
||||
InitializeFile();
|
||||
}
|
||||
@@ -647,8 +652,9 @@ void G4DNAChemistryManager::CreateWaterMolecule(ElectronicModification modificat
|
||||
}
|
||||
}
|
||||
|
||||
G4Track* pH2OTrack = pH2OMolecule->BuildTrack(picosecond + delayedTime,
|
||||
pIncomingTrack->GetPosition());
|
||||
G4Track *pH2OTrack = pH2OMolecule->BuildTrack(picosecond + delayedTime,
|
||||
pIncomingTrack->GetPosition(),
|
||||
pIncomingTrack);
|
||||
|
||||
pH2OTrack->SetParentID(pIncomingTrack->GetTrackID());
|
||||
pH2OTrack->SetTrackStatus(fStopButAlive);
|
||||
@@ -683,8 +689,9 @@ void G4DNAChemistryManager::CreateSolvatedElectron(const G4Track* pIncomingTrack
|
||||
|
||||
PushMolecule(std::make_unique<G4Molecule>(G4Electron_aq::Definition()),
|
||||
picosecond + delayedTime,
|
||||
pFinalPosition != nullptr ? *pFinalPosition : pIncomingTrack->GetPosition(),
|
||||
pIncomingTrack->GetTrackID());
|
||||
pFinalPosition ? *pFinalPosition : pIncomingTrack->GetPosition(),
|
||||
pIncomingTrack->GetTrackID(),
|
||||
pIncomingTrack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,13 +699,14 @@ void G4DNAChemistryManager::CreateSolvatedElectron(const G4Track* pIncomingTrack
|
||||
|
||||
void G4DNAChemistryManager::PushMolecule(std::unique_ptr<G4Molecule> pMolecule,
|
||||
double time,
|
||||
const G4ThreeVector& position,
|
||||
int parentID)
|
||||
const G4ThreeVector &position,
|
||||
int parentID,
|
||||
const G4Track *parentTrack)
|
||||
{
|
||||
assert(fActiveChemistry
|
||||
&& "To inject chemical species, the chemistry must be activated. "
|
||||
"Check chemistry activation before injecting species.");
|
||||
G4Track* pTrack = pMolecule->BuildTrack(time, position);
|
||||
G4Track* pTrack = pMolecule->BuildTrack(time, position, parentTrack);
|
||||
pTrack->SetTrackStatus(fAlive);
|
||||
pTrack->SetParentID(parentID);
|
||||
pMolecule.release();
|
||||
@@ -767,16 +775,30 @@ void G4DNAChemistryManager::SetVerbose(G4int verbose)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
G4bool G4DNAChemistryManager::IsCounterResetWhenRunEnds() const
|
||||
void G4DNAChemistryManager::BeginOfEventAction(const G4Event* pEvent)
|
||||
{
|
||||
return fResetCounterWhenRunEnds;
|
||||
G4MoleculeCounterManager::Instance()->BeginOfEventAction(pEvent);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4DNAChemistryManager::ResetCounterWhenRunEnds(G4bool resetCounterWhenRunEnds)
|
||||
void G4DNAChemistryManager::BeginOfRunAction(const G4Run* pRun)
|
||||
{
|
||||
fResetCounterWhenRunEnds = resetCounterWhenRunEnds;
|
||||
G4MoleculeCounterManager::Instance()->BeginOfRunAction(pRun);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4DNAChemistryManager::EndOfEventAction(const G4Event* pEvent)
|
||||
{
|
||||
G4MoleculeCounterManager::Instance()->EndOfEventAction(pEvent);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4DNAChemistryManager::EndOfRunAction(const G4Run* pRun) // for potential future use
|
||||
{
|
||||
G4MoleculeCounterManager::Instance()->EndOfRunAction(pRun);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -65,6 +65,10 @@ void Event::PrintEvent() const
|
||||
G4bool comparatorEventSet::operator()(std::unique_ptr<Event> const& rhs,
|
||||
std::unique_ptr<Event> const& lhs) const
|
||||
{
|
||||
if(rhs->GetTime() == lhs->GetTime())
|
||||
{
|
||||
return rhs->GetIndex() < lhs->GetIndex();
|
||||
}
|
||||
return rhs->GetTime() < lhs->GetTime();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
#include "G4ITTrackHolder.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, const G4VDNAMesh::Index& rhs)
|
||||
{
|
||||
@@ -232,3 +233,32 @@ G4VDNAMesh::Index G4DNAMesh::ConvertIndex(const Index& index,
|
||||
}
|
||||
return Index{ dx, dy, dz };
|
||||
}
|
||||
|
||||
G4VDNAMesh::Index G4DNAMesh:: GetRandomIndex(const Index& oldIndex, const G4double& OldReso) const
|
||||
{
|
||||
G4double x_min = oldIndex.x * OldReso;
|
||||
G4double x_max = (oldIndex.x + 1) * OldReso;
|
||||
G4double y_min = oldIndex.y * OldReso;
|
||||
G4double y_max = (oldIndex.y + 1) * OldReso;
|
||||
G4double z_min = oldIndex.z * OldReso;
|
||||
G4double z_max = (oldIndex.z + 1) * OldReso;
|
||||
|
||||
G4int i_max = std::floor(x_max / fResolution);
|
||||
G4int j_max = std::floor(y_max / fResolution);
|
||||
G4int k_max = std::floor(z_max / fResolution);
|
||||
|
||||
G4int i_min = std::floor(x_min / fResolution);
|
||||
G4int j_min = std::floor(y_min / fResolution);
|
||||
G4int k_min = std::floor(z_min / fResolution);
|
||||
|
||||
G4double r1 = G4UniformRand();
|
||||
G4double r2 = G4UniformRand();
|
||||
G4double r3 = G4UniformRand();
|
||||
|
||||
G4int i_n = i_min + (G4int)std::floor(r1 * (i_max - i_min + 1));
|
||||
G4int j_n = j_min + (G4int)std::floor(r2 * (j_max - j_min + 1));
|
||||
G4int k_n = k_min + (G4int)std::floor(r3 * (k_max - k_min + 1));
|
||||
|
||||
return Index{ i_n, j_n, k_n };
|
||||
}
|
||||
|
||||
|
||||
@@ -292,15 +292,20 @@ void G4DNAMolecularReactionData::SetReactionType(G4int type)
|
||||
fDiffusionRate = 4 * pi * sumDiffCoeff * fReactionRadius * Avogadro;
|
||||
if (fpReactant1 == fpReactant2) fDiffusionRate/=2;
|
||||
fActivationRate = fDiffusionRate * fObservedReactionRate / (fDiffusionRate - fObservedReactionRate);
|
||||
fProbability = Rs / (Rs + (fDiffusionRate / fActivationRate) * (fReactionRadius + Rs));
|
||||
|
||||
if(fActivationRate > 0) {
|
||||
fProbability =
|
||||
Rs / (Rs + (fDiffusionRate / fActivationRate) * (fReactionRadius + Rs));
|
||||
}
|
||||
}else{ // Type IV
|
||||
fEffectiveReactionRadius = -fOnsagerRadius/(1-exp(fOnsagerRadius/fReactionRadius));
|
||||
fDiffusionRate = 4 * pi * sumDiffCoeff * fEffectiveReactionRadius * Avogadro;
|
||||
if (fpReactant1 == fpReactant2) fDiffusionRate/=2;
|
||||
|
||||
fActivationRate = fDiffusionRate * fObservedReactionRate / (fDiffusionRate - fObservedReactionRate);
|
||||
fProbability = Rs / (Rs + (fDiffusionRate / fActivationRate) * (fEffectiveReactionRadius + Rs));
|
||||
if(fActivationRate > 0) {
|
||||
fProbability =
|
||||
Rs / (Rs + (fDiffusionRate / fActivationRate) * (fEffectiveReactionRadius + Rs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 "G4DNASamplingTable.hh"
|
||||
#include "G4EmParameters.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Log.hh"
|
||||
#include "G4Exp.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
G4DNASamplingTable::G4DNASamplingTable(std::size_t npoints)
|
||||
{
|
||||
fPrimaryEnergy.reserve(npoints);
|
||||
fSecEnergy.reserve(npoints);
|
||||
for (G4int i=0; i<5; ++i) { (fPDF[i]).reserve(npoints); }
|
||||
}
|
||||
|
||||
G4DNASamplingTable::~G4DNASamplingTable()
|
||||
{
|
||||
for (auto & p : fSecEnergy) { delete p; }
|
||||
for (G4int i=0; i<5; ++i) {
|
||||
for (auto & p : fPDF[i]) { delete p; }
|
||||
}
|
||||
}
|
||||
|
||||
void G4DNASamplingTable::LoadData(const G4String& fname, G4double factE,
|
||||
G4double fact, G4bool verbose)
|
||||
{
|
||||
std::ostringstream ost;
|
||||
ost << G4EmParameters::Instance()->GetDirLEDATA() << "/" << fname;
|
||||
std::ifstream fin(ost.str().c_str());
|
||||
if (!fin.is_open()) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "File <" << ost.str().c_str() << "> is not opened!";
|
||||
G4Exception("G4DNASamplingTable::LoadDifferential ", "em0003",
|
||||
FatalException, ed, "");
|
||||
return;
|
||||
}
|
||||
|
||||
G4double t, e, sig;
|
||||
G4double e0{0.0};
|
||||
G4int ntmax{0};
|
||||
G4int nt{0};
|
||||
std::vector<G4double>* v = nullptr;
|
||||
std::vector<G4double>* vPDF[5];
|
||||
for (;;) {
|
||||
fin >> e;
|
||||
if (fin.eof()) { break; }
|
||||
if (e != e0 || nullptr == v) {
|
||||
fPrimaryEnergy.push_back(e*factE);
|
||||
e0 = e;
|
||||
++fNpoints;
|
||||
v = new std::vector<G4double>;
|
||||
fSecEnergy.push_back(v);
|
||||
for (G4int i=0; i<5; ++i) {
|
||||
vPDF[i] = new std::vector<G4double>;
|
||||
(fPDF[i]).push_back(vPDF[i]);
|
||||
}
|
||||
ntmax = std::max(ntmax, nt);
|
||||
nt = 0;
|
||||
}
|
||||
fin >> t;
|
||||
v->push_back(t*factE);
|
||||
++nt;
|
||||
for (G4int i=0; i<5; ++i) {
|
||||
fin >> sig;
|
||||
sig *= fact;
|
||||
(vPDF[i])->push_back(sig);
|
||||
}
|
||||
if (fin.eof()) { break; }
|
||||
}
|
||||
if (verbose) {
|
||||
G4cout << "G4DNASamplingTable::LoadData from file:" << G4endl;
|
||||
G4cout << fname << G4endl;
|
||||
G4cout << " Nenergy= " << fNpoints << " NmaxT= " << ntmax << G4endl;
|
||||
}
|
||||
if (fNpoints > 0) { --fNpoints; }
|
||||
}
|
||||
|
||||
G4double G4DNASamplingTable::GetValue(G4double ekinPrimary,
|
||||
G4double ekinSec, G4int shell) const
|
||||
{
|
||||
std::vector<G4double>* e1{nullptr};
|
||||
std::vector<G4double>* e2{nullptr};
|
||||
std::vector<G4double>* s1{nullptr};
|
||||
std::vector<G4double>* s2{nullptr};
|
||||
G4int idx = GetIndex(fPrimaryEnergy, ekinPrimary);
|
||||
if (idx == -1) {
|
||||
e1 = fSecEnergy[0];
|
||||
s1 = (fPDF[shell])[0];
|
||||
} else if (idx > fNpoints) {
|
||||
e1 = fSecEnergy[fNpoints];
|
||||
s1 = (fPDF[shell])[fNpoints];
|
||||
} else {
|
||||
e1 = fSecEnergy[idx];
|
||||
s1 = (fPDF[shell])[idx];
|
||||
e2 = fSecEnergy[idx + 1];
|
||||
s2 = (fPDF[shell])[idx + 1];
|
||||
}
|
||||
// edge cases
|
||||
G4double res1 = VecInterpolation(e1, s1, ekinSec);
|
||||
if (nullptr == e2) { return res1; }
|
||||
|
||||
// ordinary case
|
||||
G4double res2 = VecInterpolation(e2, s2, ekinSec);
|
||||
G4double res = Interpolate(fPrimaryEnergy[idx], fPrimaryEnergy[idx + 1],
|
||||
ekinPrimary, res1, res2);
|
||||
return res;
|
||||
}
|
||||
|
||||
G4int G4DNASamplingTable::GetIndex(const std::vector<G4double>& v, G4double x) const
|
||||
{
|
||||
G4int idx;
|
||||
if (x <= v[0]) { idx = -1; }
|
||||
else if (x >= v.back()) { idx = (G4int)v.size(); }
|
||||
else {
|
||||
std::size_t i = std::upper_bound(v.cbegin(), v.cend(), x) - v.cbegin() - 1;
|
||||
idx = (G4int)i;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
G4double G4DNASamplingTable::VecInterpolation(const std::vector<G4double>* ener,
|
||||
const std::vector<G4double>* val,
|
||||
G4double e) const
|
||||
{
|
||||
G4int idx = GetIndex(*ener, e);
|
||||
G4double res;
|
||||
if (idx == -1) { res = (*val)[0]; }
|
||||
else if (e >= ener->back()) { res = val->back(); }
|
||||
else {
|
||||
res = Interpolate((*ener)[idx], (*ener)[idx + 1], e, (*val)[idx], (*val)[idx + 1]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
G4double G4DNASamplingTable::Interpolate(G4double e1, G4double e2, G4double e,
|
||||
G4double xs1, G4double xs2) const
|
||||
{
|
||||
G4double res;
|
||||
// special case
|
||||
if (e1 == e2) {
|
||||
res = 0.5 * (xs1 + xs2);
|
||||
|
||||
// Log-log interpolation by default
|
||||
} else if (e1 > 0.0 && e2 > 0.0 && xs1 > 0.0 && xs2 > 0.0) {
|
||||
G4double y = G4Log(xs1) + G4Log(e/e1) * G4Log(xs2/xs1)/G4Log(e2/e1);
|
||||
res = G4Exp(y);
|
||||
|
||||
// Lin-Log interpolation
|
||||
} else if (xs1 > 0.0 && xs2 > 0.0) {
|
||||
G4double y = G4Log(xs1) + (e - e1) * G4Log(xs2/xs1)/(e2 - e1);
|
||||
res = G4Exp(y);
|
||||
|
||||
// Lin-Lin interpolation
|
||||
} else {
|
||||
res = xs1 + (e - e1) * (xs2 - xs1)/(e2 - e1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
G4double
|
||||
G4DNASamplingTable::SampleCumulative(G4double ekinPrimary, G4int shell) const
|
||||
{
|
||||
std::vector<G4double>* e1{nullptr};
|
||||
std::vector<G4double>* e2{nullptr};
|
||||
std::vector<G4double>* s1{nullptr};
|
||||
std::vector<G4double>* s2{nullptr};
|
||||
G4int idx = GetIndex(fPrimaryEnergy, ekinPrimary);
|
||||
if (idx == -1) {
|
||||
e1 = fSecEnergy[0];
|
||||
s1 = (fPDF[shell])[0];
|
||||
} else if (idx > fNpoints) {
|
||||
e1 = fSecEnergy[fNpoints];
|
||||
s1 = (fPDF[shell])[fNpoints];
|
||||
} else {
|
||||
e1 = fSecEnergy[idx];
|
||||
s1 = (fPDF[shell])[idx];
|
||||
e2 = fSecEnergy[idx + 1];
|
||||
s2 = (fPDF[shell])[idx + 1];
|
||||
}
|
||||
G4double q = G4UniformRand();
|
||||
|
||||
// edge cases
|
||||
G4double res1 = VecInterpolation(s1, e1, q);
|
||||
if (nullptr == e2) { return res1; }
|
||||
|
||||
// ordinary case
|
||||
G4double res2 = VecInterpolation(s2, e2, q);
|
||||
G4double res = Interpolate(fPrimaryEnergy[idx], fPrimaryEnergy[idx + 1],
|
||||
ekinPrimary, res1, res2);
|
||||
return res;
|
||||
}
|
||||
@@ -60,6 +60,19 @@ void G4DNAScavengerMaterial::Initialize()
|
||||
G4cout << "G4DNAScavengerMaterial existed but empty" << G4endl;
|
||||
}
|
||||
Reset();
|
||||
|
||||
fEquilibriumProcesses.emplace(
|
||||
std::make_pair(6, std::make_unique<G4ChemEquilibrium>(6, 10 * CLHEP::us)));//reactionType6 and 10 * us
|
||||
fEquilibriumProcesses.emplace(
|
||||
std::make_pair(7, std::make_unique<G4ChemEquilibrium>(7, 10 * CLHEP::us)));//reactionType6 and 10 * us
|
||||
fEquilibriumProcesses.emplace(
|
||||
std::make_pair(8, std::make_unique<G4ChemEquilibrium>(8, 10 * CLHEP::us)));//reactionType6 and 10 * us
|
||||
for(auto& it : fEquilibriumProcesses)
|
||||
{
|
||||
it.second->Initialize();
|
||||
it.second->SetVerbose(fVerbose);
|
||||
}
|
||||
|
||||
fIsInitialized = true;
|
||||
}
|
||||
|
||||
@@ -68,10 +81,7 @@ G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf(MolType ma
|
||||
{
|
||||
// no change these molecules
|
||||
if (fH2O == matConf) {
|
||||
G4ExceptionDescription exceptionDescription;
|
||||
exceptionDescription << "matConf : " << matConf->GetName();
|
||||
G4Exception("G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf",
|
||||
"G4DNAScavengerMaterial001", FatalErrorInArgument, exceptionDescription);
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto iter = fScavengerTable.find(matConf);
|
||||
@@ -118,7 +128,7 @@ void G4DNAScavengerMaterial::AddNumberMoleculePerVolumeUnitForMaterialConf(MolTy
|
||||
// no change these molecules
|
||||
|
||||
if (fH2O == matConf || fH3Op == matConf || // pH has no change
|
||||
G4MoleculeTable::Instance()->GetConfiguration("OHm(B)") == matConf)
|
||||
fHOm == matConf)
|
||||
{
|
||||
// G4cout<<"moletype : "<<matConf->GetName()<<G4endl;
|
||||
// kobs is already counted these molecule concentrations
|
||||
@@ -173,6 +183,8 @@ void G4DNAScavengerMaterial::Reset()
|
||||
return;
|
||||
}
|
||||
|
||||
ResetEquilibrium();
|
||||
|
||||
fScavengerTable.clear();
|
||||
fCounterMap.clear();
|
||||
fpLastSearch.reset(nullptr);
|
||||
@@ -213,12 +225,17 @@ void G4DNAScavengerMaterial::AddAMoleculeAtTime(MolType molecule, G4double time,
|
||||
auto end = counterMap_i->second.rbegin();
|
||||
|
||||
if (end->first <= time
|
||||
|| fabs(end->first - time) <= G4::MoleculeCounter::TimePrecision::fPrecision) {
|
||||
|| fabs(end->first - time) <= G4::MoleculeCounter::FixedTimeComparer::fPrecision) {
|
||||
G4double newValue = end->second + number;
|
||||
counterMap_i->second[time] = newValue;
|
||||
if (newValue != (floor)(fScavengerTable[molecule])) // protection
|
||||
{
|
||||
G4String errMsg = "You are trying to add wrong molecule ";
|
||||
G4String errMsg = "You are trying to add wrong molecule : ";
|
||||
G4cout<< " newValue : "<<newValue<<" " << molecule->GetName()
|
||||
<< " at time : " << G4BestUnit(time, "Time")
|
||||
<< " with number : " << number
|
||||
<<" (floor)(fScavengerTable[molecule]) : "<<(floor)(fScavengerTable[molecule])
|
||||
<< " and the final number is not valid." << G4endl;
|
||||
G4Exception("AddAMoleculeAtTime", "", FatalErrorInArgument, errMsg);
|
||||
}
|
||||
}
|
||||
@@ -427,4 +444,37 @@ G4double G4DNAScavengerMaterial::GetpH()
|
||||
fScavengerTable[fHOm] = 0;
|
||||
}
|
||||
return -pH;
|
||||
}
|
||||
|
||||
G4bool G4DNAScavengerMaterial::SetEquilibrium(const G4DNAMolecularReactionData* pReaction,
|
||||
G4double time)
|
||||
{
|
||||
for(auto& it : fEquilibriumProcesses)
|
||||
{
|
||||
it.second->SetGlobalTime(time);
|
||||
it.second->SetEquilibrium(pReaction);
|
||||
if(it.second->IsStatusChanged()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void G4DNAScavengerMaterial::ResetEquilibrium()
|
||||
{
|
||||
for(auto& it : fEquilibriumProcesses)
|
||||
{
|
||||
it.second->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4DNAScavengerMaterial::IsEquilibrium(const G4int& reactionType) const
|
||||
{
|
||||
auto reaction = fEquilibriumProcesses.find(reactionType);
|
||||
if(reaction == fEquilibriumProcesses.end())
|
||||
{
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return (reaction->second->GetEquilibriumStatus());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Author: Christian Velten (2025)
|
||||
|
||||
#include "G4MoleculeReactionCounter.hh"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
G4String G4MoleculeReactionCounterIndex::FormattedReactionString(const G4DNAMolecularReactionData* reactionData) const
|
||||
{
|
||||
const G4MolecularConfiguration* reactant1 = reactionData->GetReactant1();
|
||||
const G4MolecularConfiguration* reactant2 = reactionData->GetReactant2();
|
||||
|
||||
const std::vector<const G4MolecularConfiguration*>* products = reactionData->GetProducts();
|
||||
|
||||
G4String reactionLhs = "";
|
||||
if (reactant1 != nullptr) {
|
||||
reactionLhs += reactant1->GetUserID();
|
||||
if (reactant2 != nullptr) reactionLhs += " + ";
|
||||
}
|
||||
if (reactant2 != nullptr) reactionLhs += reactant2->GetUserID();
|
||||
|
||||
G4String reactionRhs = "";
|
||||
for (auto it = products->cbegin(); it != products->cend(); ++it) {
|
||||
if (*it != nullptr) {
|
||||
if (it != products->cbegin() && reactionRhs.size() > 0) reactionRhs += " + ";
|
||||
reactionRhs += (*it)->GetUserID();
|
||||
}
|
||||
}
|
||||
|
||||
G4String reactionString = reactionLhs + " -> " + reactionRhs;
|
||||
|
||||
return reactionString;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
G4MoleculeReactionCounter::G4MoleculeReactionCounter() : G4VUserMoleculeReactionCounter() {}
|
||||
|
||||
G4MoleculeReactionCounter::G4MoleculeReactionCounter(G4String name)
|
||||
: G4VUserMoleculeReactionCounter(std::move(name), MoleculeReactionCounterType::Basic)
|
||||
{}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4MoleculeReactionCounter::InitializeUser() {}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr<G4VMoleculeReactionCounter::G4VMoleculeReactionCounterIndex>
|
||||
G4MoleculeReactionCounter::BuildSimpleIndex(const G4DNAMolecularReactionData* reactionData) const
|
||||
{
|
||||
return std::make_unique<G4MoleculeReactionCounterIndex>(reactionData);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "G4PhysChemIO.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4VAnalysisManager.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -42,7 +41,6 @@ using namespace std;
|
||||
namespace G4PhysChemIO{
|
||||
|
||||
FormattedText::FormattedText(){
|
||||
fRunID = -1;
|
||||
fEventID = -1;
|
||||
fFileInitialized = false;
|
||||
}
|
||||
@@ -154,155 +152,4 @@ void FormattedText::CreateSolvatedElectron(const G4Track* theIncomingTrack,
|
||||
fOfstream << G4endl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Using G4analysis
|
||||
//
|
||||
|
||||
G4Analysis::G4Analysis(G4VAnalysisManager* analysisManager):
|
||||
fpAnalysisManager(analysisManager)
|
||||
{
|
||||
fFileInitialized = false;
|
||||
fNtupleID = -1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
G4Analysis::~G4Analysis()
|
||||
{
|
||||
fpAnalysisManager = nullptr;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4Analysis::InitializeFile()
|
||||
{
|
||||
if (fFileInitialized) return;
|
||||
|
||||
fNtupleID = fpAnalysisManager->CreateNtuple("PhysChem","PhysChem");
|
||||
fpAnalysisManager->CreateNtupleIColumn(fNtupleID, "ParentID");
|
||||
fpAnalysisManager->CreateNtupleSColumn(fNtupleID, "Molecule");
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// valid for H2O only
|
||||
fpAnalysisManager->CreateNtupleIColumn(fNtupleID, "ElectronicModif");
|
||||
// ionization = 0 / excitation = 1 / diss att = 2
|
||||
fpAnalysisManager->CreateNtupleIColumn(fNtupleID, "level");
|
||||
// valid for ion and exc only
|
||||
fpAnalysisManager->CreateNtupleDColumn(fNtupleID, "Energy_eV");
|
||||
// valid for ion and exc only
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
fpAnalysisManager->CreateNtupleDColumn(fNtupleID, "x_parent_nm");
|
||||
fpAnalysisManager->CreateNtupleDColumn(fNtupleID, "y_parent_nm");
|
||||
fpAnalysisManager->CreateNtupleDColumn(fNtupleID, "z_parent_nm");
|
||||
fpAnalysisManager->CreateNtupleDColumn(fNtupleID, "x_nm");
|
||||
fpAnalysisManager->CreateNtupleDColumn(fNtupleID, "y_nm");
|
||||
fpAnalysisManager->CreateNtupleDColumn(fNtupleID, "z_nm");
|
||||
fpAnalysisManager->FinishNtuple(fNtupleID);
|
||||
|
||||
fFileInitialized = true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4Analysis::WriteInto(const G4String& output,
|
||||
ios_base::openmode)
|
||||
{
|
||||
fpAnalysisManager->OpenFile(output);
|
||||
fFileInitialized = false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4Analysis::CloseFile()
|
||||
{
|
||||
// fpAnalysisManager->Write();
|
||||
// fpAnalysisManager->CloseFile();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4Analysis::CreateWaterMolecule(G4int modification,
|
||||
G4int electronicLevel,
|
||||
G4double energy,
|
||||
const G4Track* theIncomingTrack)
|
||||
{
|
||||
if(!fFileInitialized) InitializeFile();
|
||||
|
||||
// parent ID
|
||||
fpAnalysisManager->FillNtupleIColumn(fNtupleID, 0,
|
||||
theIncomingTrack->GetTrackID());
|
||||
|
||||
// molecule type
|
||||
fpAnalysisManager->FillNtupleSColumn(fNtupleID, 1, "H2O");
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// valid for H2O only
|
||||
|
||||
// electronic modif
|
||||
fpAnalysisManager->FillNtupleIColumn(fNtupleID, 2, modification);
|
||||
// ionization = 0 / excitation = 1 / diss att = 2
|
||||
fpAnalysisManager->FillNtupleIColumn(fNtupleID, 3, electronicLevel);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID, 4, energy / eV);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const G4ThreeVector& parentPos = theIncomingTrack->GetPosition();
|
||||
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,5,(parentPos.x())/nanometer);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,6,(parentPos.y())/nanometer);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,7,(parentPos.z())/nanometer);
|
||||
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,8,(parentPos.x())/nanometer);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,9,(parentPos.y())/nanometer);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,10,(parentPos.z())/nanometer);
|
||||
fpAnalysisManager->AddNtupleRow(fNtupleID);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void G4Analysis::CreateSolvatedElectron(const G4Track* electronTrack,
|
||||
G4ThreeVector* finalPosition)
|
||||
{
|
||||
if(!fFileInitialized) InitializeFile();
|
||||
|
||||
// parent ID
|
||||
fpAnalysisManager->FillNtupleIColumn(fNtupleID, 0,
|
||||
electronTrack->GetTrackID());
|
||||
|
||||
// molecule type
|
||||
fpAnalysisManager->FillNtupleSColumn(fNtupleID, 1, "e_aq");
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// valid for H2O only
|
||||
|
||||
// electronic modif
|
||||
fpAnalysisManager->FillNtupleIColumn(fNtupleID, 2, -1); // electronic modif
|
||||
fpAnalysisManager->FillNtupleIColumn(fNtupleID, 3, -1); // electronic level
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID, 4,
|
||||
electronTrack->GetKineticEnergy() / eV);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const G4ThreeVector& parentPos = electronTrack->GetPosition();
|
||||
const double i_nm = 1./nanometer;
|
||||
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,5, parentPos.x() *i_nm);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,6, parentPos.y() *i_nm);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,7, parentPos.z() *i_nm);
|
||||
|
||||
if (finalPosition != nullptr)
|
||||
{
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,8, finalPosition->x()*i_nm);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,9, finalPosition->y()*i_nm);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,10, finalPosition->z()*i_nm);
|
||||
}
|
||||
else
|
||||
{
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,8, parentPos.x() *i_nm);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,9, parentPos.y() *i_nm);
|
||||
fpAnalysisManager->FillNtupleDColumn(fNtupleID,10, parentPos.z() *i_nm);
|
||||
}
|
||||
|
||||
fpAnalysisManager->AddNtupleRow(fNtupleID);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user