How to create an ion in PhysicsList

Hello! In my task free sodium ions, as well as non-bridge oxygen atoms, arise in glass under the influence of proton radiation. Sodium ions also drift under the influence of the electric field of protons induced into the sample. So, I’m trying to understand how to
implement these facts in my PhysicsList. That is how I’ve tried make this (шt didn’t work out). In constructor a standart electromagnetic physics was registered. And in ConstructParticle() I tried to create a sodium ion. A G4GenericIon::GenericIonDefinition() command is included because it necessary to declare an ions possible occurrence (or not?)

#include "physics.hh"

MyPhysicsList::MyPhysicsList()
{
    RegisterPhysics(new G4EmStandardPhysics());
    //RegisterPhysics(new G4OpticalPhysics());
   
}

MyPhysicsList::~MyPhysicsList()
{}

void MyPhysicsList::ConstructParticle()     
{   
 
    //G4Electron::ElectronDefinition();          
    //G4Proton::ProtonDefinition();        
    //G4Gamma::GammaDefinition();
    G4GenericIon::GenericIonDefinition();
    G4IonTable *ionTable = G4IonTable::GetIonTable();
    G4ParticleDefinition *na_ion = ionTable->GetIon(11, 23, 0);
    G4String ion_name = ionTable->GetIonName(11, 23, 0);
    std::ofstream file("/home/ivantozavr/Geant_Projects/output/mytext.txt");
    if (file.is_open())
    {
        file << na_ion->GetParticleName () << G4endl;
        file.close();
    }
}

At program startup a “*** G4Exception : PART105
issued by : G4IonTable::CreateIon()
Can not create ions because GenericIon is not ready” error occurs. That’s my first project and it looks like I’m not realize how PhisicsList works in Geant4. Some examples was viewed but I have not met projects where particular ions were created.

I will be glad of any help!

_Geant4 Version:_11.2.2
_Operating System:_Linux Mint 21.3
_Compiler/Version:_gcc 11.4.0
_CMake Version:_3.22.1

While ions can be defined you need some sort of constructor or physics list to correctly attach processes to it. The particles are constructed in the ConstructParticle() method if not done so already in these other physics lists after physics processes are registered. The hadron examples will have some physics lists you can use as a template.
Edit - Examples that might be helpful are rdecay01, rdecay02, and Hadr07 (the last works with Na22 in one config). Hadron physics lists tend to also include radioactive decay physics that might not be of interest but the physics lists will construct the particle you want.

Thanks a lot! I’ve looked at these examples. It seems that there is no need to create a particular ion. G4GenericIon detects all emerging ions. But it is necessary to specify the physical processes in which it should participate. Is that true?

G4EmStandardPhysics already creates generic ions if you register the physics list. You can delete everything you currently have in your construct particle process and be fine. The actual particle you would want to simulate would be done in UI commands with particle guns or in PrimaryGeneratorAction.
If you are really concerned about it you could have G4EmStandardPhysics build the ions you want explicitly by calling its ConstructParticle() method in your PhysicsLists ConstructParticle() method.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.