Message: Can't change Physics of G4VModularPhysicsList after first run Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Can't change Physics of G4VModularPhysicsList after first run 

Forum: Physics List
Date: 30 Sep, 2014
From: Daniel Brandt <Daniel Brandt>

Hi,

I am trying to use a G4VModularPhysicsList together with physics constructors to allow my users a choice of physics list without having to restart the software. Selecting the desired physics list for the first time works great, however once the simulation has run all attempts at changing the physics list have no effect. Does anybody have any tips? I'm on Geant4 v9.6p2, Windows8.1. Below is my code.

In order to initialize the physics list I first switch into pre_init state:

  G4StateManager* sman = G4StateManager::GetStateManager();
  sman->SetNewState(G4State_PreInit);
  initializePhysics();
  runManager->PhysicsHasBeenModified();			
  runManager->InitializePhysics();

Within the initializePhysics-Method:

  //Instantiate derived class of G4VModularPhysicsList
  if(!physicsListPointer) {
	physicsListPointer = new PhysicsList();
  }

  //Choose the physics to use.
  physicsListPointer->AddPhysicsList(name);
  runManager->SetUserInitialization(physicsListPointer);		

Within the physicsListPointer::AddPhysicsList - Method, a new physics list is chosen based on G4String name. The truncated version of the code looks like this (modeled closely on one of the EM-examples):

  RemovePhysics(myPhysicsConstructor);

  if (name == "local") {

    emName = name;
    delete myPhysicsConstructor;
    myPhysicsConstructor = new G4HadronElasticPhysics();	

  } else if (name == "emstandard_opt0"){
    emName = name;
    delete myPhysicsConstructor;
    myPhysicsConstructor = new G4EmStandardPhysics();

  }

Any suggestions as to how to fix this problem would be very much appreciated.

cheers, Daniel

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Idea: Re: Can't change Physics of G4VModularPhysicsList after first run   (Michael H. Kelsey - 01 Oct, 2014)
 Add Message Add Message
to: "Can't change Physics of G4VModularPhysicsList after first run"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]