Hi guys,
I am new in Geant4 and I could use some help.
I am trying to use Dnaphysics to simulate radiation exposure of 98.85 kev 195Pt in a World Volume of Water but everytime I use for example the command /process/em/addDNARegion World DNA_opt6 or for example dna/test/addPhysics raddecay I get the error message below:
illegal application state – command refused:“/process/em/AddDNARegion World DNA_opt6”
illegal application state – command refused:" /dna/test/addPhysics raddecay "
I have tried to use the command before and after /run/initialize but I get the same error.
Do you have any ideas why or how I can fix it ?
Many Thanks in advance
Ergi
It’s probable that the initialization is happening in the C++ code before the commands here are executed. Check the code for lines like:
runManager->Initialize();
That can generally be removed and the initialization deferred to commands, but see the main() programs and command macros in the basic examples for the correct structure.
Thanks for your answer. I searched for a line like this but I don´t seem to find anything that indicates the initialization of the runManager. Below you can find a snippet of my main().
int main(int argc, char **argv) {
// Detect interactive mode (if no arguments) and define UI session
//
G4UIExecutive* ui = nullptr;
if ( argc == 1 ) {
ui = new G4UIExecutive(argc, argv);
}
// Construct the default run manager
auto* runManager = G4RunManagerFactory::CreateRunManager();
if(argc==3) runManager->SetNumberOfThreads(atoi(argv[2]));
else runManager->SetNumberOfThreads(2);
// Set mandatory user initialization classes
auto physlist = new PhysicsList();
runManager->SetUserInitialization(new DetectorConstruction(physlist));
runManager->SetUserInitialization(physlist);
// User action initialization
runManager->SetUserInitialization(new ActionInitialization());
Could you post your macro file, and show where you’re inserting the above two commands? You might have a /run/initialize command in your macro file, and you’re putting those commands after it, rather than before (or vice versa).
I see that you have two occurrences of /run/initialize in your macro file. I’m pretty confident that you need the setMat command before, because that command it changing how the geometry should be built (and /run/initialize triggers building the geometry however it’s configure at that moment).
Conversely, I suspect that the AddDNARegion must be after/run/initialize, because regions get created or named as part of building the geometry.