File indexing completed on 2026-04-05 07:50:19
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
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #include "TimeStepAction.hh"
0039
0040 #include "G4MolecularConfiguration.hh"
0041 #include "G4Molecule.hh"
0042 #include "G4MoleculeTable.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4UnitsTable.hh"
0045
0046 #include <G4Scheduler.hh>
0047
0048 TimeStepAction::TimeStepAction() : G4UserTimeStepAction()
0049 {
0050
0051
0052
0053
0054
0055
0056
0057 AddTimeStep(1 * picosecond, 0.1 * picosecond);
0058 AddTimeStep(10 * picosecond, 1 * picosecond);
0059 AddTimeStep(100 * picosecond, 3 * picosecond);
0060 AddTimeStep(1000 * picosecond, 10 * picosecond);
0061 AddTimeStep(10000 * picosecond, 100 * picosecond);
0062 }
0063
0064
0065
0066 void TimeStepAction::UserPostTimeStepAction()
0067 {
0068 if (G4Scheduler::Instance()->GetGlobalTime() > 99 * ns) {
0069 G4cout << "_________________" << G4endl;
0070 G4cout << "At : " << G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(), "Time") << G4endl;
0071
0072 auto species = G4MoleculeTable::Instance()->GetConfiguration("°OH");
0073 PrintSpecieInfo(species);
0074 }
0075 }
0076
0077
0078
0079 void TimeStepAction::UserReactionAction(const G4Track& reactantA, const G4Track& reactantB,
0080 const std::vector<G4Track*>* products)
0081 {
0082
0083 G4cout << G4endl;
0084
0085 G4cout << "At : " << G4Scheduler::Instance()->GetGlobalTime() / ns
0086 << " (ns) reactantA = " << GetMolecule(reactantA)->GetName()
0087 << " (ID number = " << reactantA.GetTrackID() << ")"
0088 << " at position : " << reactantA.GetPosition() / nm
0089 << " reacts with reactantB = " << GetMolecule(&reactantB)->GetName()
0090 << " (ID number = " << reactantB.GetTrackID() << ")"
0091 << " at position : " << reactantA.GetPosition() / nm << G4endl;
0092
0093 if (products) {
0094 auto nbProducts = (G4int)products->size();
0095 for (G4int i = 0; i < nbProducts; i++) {
0096 G4cout << " creating product " << i + 1 << " =" << GetMolecule((*products)[i])->GetName()
0097 << " position : " << (*products)[i]->GetPosition() << G4endl;
0098 }
0099 }
0100 G4cout << G4endl;
0101 }
0102
0103 void TimeStepAction::PrintSpecieInfo(G4MolecularConfiguration* molconf)
0104 {
0105
0106 auto moleculeID = molconf->GetMoleculeID();
0107 const G4String& moleculeName = molconf->GetFormatedName();
0108 G4cout << "Get inf of : " << moleculeName << G4endl;
0109 auto trackList = G4ITTrackHolder::Instance()->GetMainList(moleculeID);
0110
0111 if (trackList == nullptr) {
0112 G4cout << "No species" << G4endl;
0113 return;
0114 }
0115 G4TrackList::iterator it = trackList->begin();
0116 G4TrackList::iterator end = trackList->end();
0117 for (; it != end; ++it) {
0118 auto track = *it;
0119 G4cout << "TrackID: " << track->GetTrackID() << " position : " << track->GetPosition() / nm
0120 << G4endl;
0121 }
0122 }