Problem with definition of ion source

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version: 10.2
Operating System: linux
CMake Version:

Hi experts,
I encountered particle source definition is my code.

G4int Z = 92, A = 238;
G4IonTable* ionTable = G4IonTable::GetIonTable();
G4ParticleDefinition* particle_here = ionTable->GetIon(Z, A, 0.0);

And then this happened:

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : PART105
      issued by : G4IonTable::CreateIon()
Can not create ions because GenericIon is not ready
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

and then the program crashed. Should I Initialize some things before there?
Thanks for any help!!

IonTable cannot be invoked from the constructor of PrimaryGeneratorAction : too early …
It can be called in PrimaryGeneratorAction::GeneratePrimaries().
See example rdecay01 to see the ‘trick’ used.

Thank you so much for your advice!
I put the code later and the problem is solved!
thank again,that’s really helpful! :grinning:

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