How to extend simulation "experiment" time?

Geant4 Version:11.2.1
*Operating System:*Ubuntu 22.04.5 LTS
Compiler/Version:11.4.0
CMake Version:3.22.1


I am working in a simulation using a sodium-22 nucleus, which has a half lifetime T_(1/2)≈2.603 y. When I run the simulation, I expect the source to decay emitting gammas and positrons, but since T_(1/2) is in the order of years, the probability of the decay is such that my sources up to N=10^3 just do not decay in the simulation time.

I have partially solved this problem by manually setting lifetime to 1 ns, including

ion->SetPDGLifeTime(1.0 * ns) 

in PrimaryGeneratorAction::GeneratePrimaries(), but since I am not completely sure of not being altering the derived processes, and since the situation of one wanting to set a longer simulation “experiment” time sounds familiar to me and makes me think that there is something already included in Geant4, I want to ask, is there a method to extend what I call here the “simulation experiment time” being that the time that is taken into account when determining the probability of decay of a given radioactive ion in a given simulation?

Thanks in advance.

Not sure I understand what you are trying to do. Each particle in a geant4 simulation has its own global time that has no bearing on past or future primaries. An “absolute” time can be added in post processing to relate the primaries to each other. For example sampling a poission time distribution to add offsets to the timestamps based on your desired “activity” to give a new absolute timestamp to capture effects such as pileup, for example.

If the issue is that the primary simulation global timestamps carry the half life of the parent with them then you can do the following to reset the global timestamp right when the na22 decays then all time is in reference to the actual decay event.

This can be done in the PostUserTrackingAction:


void TrackingAction::PostUserTrackingAction(const G4Track* track)
{


    // Reset global time on first decay (to avoid waiting for half life of first decay)
    if (track->GetParentID() == 0) { // This track belongs to a primary vertex


            // ============Setting secondary tracks to zero global  time==============
            G4TrackVector* secondaries = fpTrackingManager->GimmeSecondaries();
            size_t nSeco = secondaries->size();

            if (nSeco > 0){
                for(size_t i=0; i < nSeco; i++) {
                    (*secondaries)[i]->SetGlobalTime(0.);
                    }
                }
        }

}

You should not be changing the lifetime of the isotope for any decay. Instead try to use Decay Time Biasing and/or extending the threshold for decay time.

Have a look at the extended example “radioactivedecay/rdecay02”, and in particular the “isotopes.mac” macro file which simulates Na24, and uses:

/process/had/rdm/thresholdForVeryLongDecayTime 1.0e+60 year

The details of Decay Time Biasing, and other radioactive decay biasing techniques, are in the documents.

Edit:
Importantly (and wasn’t clear in my original post) in version 11.2 the default time threshold was reduced from about 2x the age of the universe to 1 year.

For your Na-22 decay, which has a half-life of 2.6 years, the decay is not being simulated. This is why you do not see anything and why you must increase the threshold

1 Like

The “2x the age of the universe to one year” detail have me cracking up.
Thank you, the C++ interface implementable method

G4HadronicParameters::Instance()->SetTimeThresholdForRadioactiveDecay( 1.0e+60*CLHEP::year )

inherited from G4HadronicParameters.hh is exactly what I was looking for. According to release notes (11.2), this is intended “to be placed in the main program before run initialization”.