File indexing completed on 2025-02-23 09:22:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #include "TimeStepAction.hh"
0028
0029 #include "PulseAction.hh"
0030
0031 #include "G4DNAEventScheduler.hh"
0032 #include "G4DNAGillespieDirectMethod.hh"
0033 #include "G4DNAMolecularReactionTable.hh"
0034 #include "G4EventManager.hh"
0035 #include "G4ITLeadingTracks.hh"
0036 #include "G4MoleculeCounter.hh"
0037 #include "G4Scheduler.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4Track.hh"
0040 #include "G4UnitsTable.hh"
0041 #include "G4VChemistryWorld.hh"
0042 #include "G4VPrimitiveScorer.hh"
0043
0044 TimeStepAction::TimeStepAction(const G4VChemistryWorld* pChemWorld, PulseAction* pPulse)
0045 : G4UserTimeStepAction(), fpPulse(pPulse), fpChemWorld(pChemWorld)
0046 {
0047 fpEventScheduler = std::make_unique<G4DNAEventScheduler>();
0048 fScheduler = G4Scheduler::Instance();
0049 }
0050
0051
0052
0053 void TimeStepAction::UserPreTimeStepAction() {}
0054
0055
0056
0057 void TimeStepAction::UserPostTimeStepAction()
0058 {
0059 G4double T1 = 5 * CLHEP::ns;
0060 if (fpPulse != nullptr && fpPulse->IsActivedPulse()) {
0061 G4MoleculeCounter::Instance()->Use(false);
0062
0063 T1 = fpPulse->GetLonggestDelayedTime() + 5 * CLHEP::ns;
0064 }
0065
0066 if (fScheduler->GetGlobalTime() >= T1) {
0067 CompartmentBased();
0068 }
0069 }
0070
0071
0072
0073 void TimeStepAction::UserReactionAction(const G4Track& , const G4Track& ,
0074 const std::vector<G4Track*>* )
0075 {}
0076
0077
0078
0079 void TimeStepAction::EndProcessing() {}
0080
0081
0082
0083 void TimeStepAction::CompartmentBased()
0084 {
0085 SetInitialPixel();
0086 fpEventScheduler->SetVerbose(fScheduler->GetVerbose());
0087 fpEventScheduler->SetStartTime(fScheduler->GetGlobalTime());
0088 fpEventScheduler->SetEndTime(fScheduler->GetEndTime() - 1 * ps);
0089 fpEventScheduler->SetChangeMesh(true);
0090 fpEventScheduler->Initialize(*fpChemWorld->GetChemistryBoundary(), fPixel);
0091 fpEventScheduler->Run();
0092 fScheduler->Stop();
0093 }
0094
0095
0096
0097 G4DNAEventScheduler* TimeStepAction::GetEventScheduler() const
0098 {
0099 return fpEventScheduler.get();
0100 }
0101
0102
0103
0104 void TimeStepAction::SetInitialPixel()
0105 {
0106 auto pBoundingBox = fpChemWorld->GetChemistryBoundary();
0107 G4double Box = pBoundingBox->halfSideLengthInX();
0108 if (Box == 1.6 * um) {
0109 fPixel = 512;
0110 }
0111 else if (Box == 0.8 * um) {
0112 fPixel = 256;
0113 }
0114 else {
0115 G4cout << "Box : " << *pBoundingBox << " Pixel : " << fPixel << G4endl;
0116 G4Exception("This chem volume is not optimized and the result may be incorrect.",
0117 "TimeStepAction::TimeStepAction", FatalException, "");
0118 }
0119
0120
0121 }
0122
0123
0124
0125 void TimeStepAction::StartProcessing()
0126 {
0127 auto currentEvent = G4EventManager::GetEventManager();
0128 if (currentEvent->GetConstCurrentEvent()->IsAborted()) {
0129 G4cout << "This event is fully aborted" << G4endl;
0130 fScheduler->Stop();
0131 }
0132 }
0133
0134