gsize +

关于Geant4中的物理过程

最近在修改HPGe_simulation程序中如何引入直接从粒子发生器(G4VUserPrimaryGeneratorAction)中输入衰变粒子即可得到该粒子的gamma能谱。 只要在PhysicsList中加G4RadioactiveDecayPhysics类,即可实现对衰变核素的gamma跃迁进行模拟。顺便了解Geant4中物理过程(PhysicsList)的组成。


粒子物理基础知识


先复习一下粒子物理知识,世间万物由以下粒子组成(除了最后一个),类似于面向对象编程中的对象——类,它们之间相互作用类似为类的操作。 粒子种类如下:

其中,重子和介子统称为强子。

目前的物理模型中,粒子作用概括为四种作用,分别为:


关于Geant4中的物理过程


用户在写Geant4应用程序时,要么自己实现PhysicsList,要么直接使用集成好的物理过程。 Geant4实现的物理作用集中在强作用与电磁作用两方面。


手动实现PhysicsList

在Geant4中,用户的PhysicsList类一般继承自G4VUserPhysicsListG4VModularPhysicsList这两个类。 PhysicsList包括粒子种类,对应的物理作用类型,以及相关的能量截断值(cut)设置。

早期在搭建自己的物理过程时会选用前者,现在写PhysicsList使用后者。因为G4VModularPhysicsList继承自G4VUserPhysicsList, 并提供了更多灵活的操作函数,可以模块化选择所需要的物理过程。 下面是G4VModularPhysicsList相关的操作函数:

    // Register Physics Constructor 
	void RegisterPhysics(G4VPhysicsConstructor* );
	 
	const G4VPhysicsConstructor* GetPhysics(G4int index) const;
	const G4VPhysicsConstructor* GetPhysics(const G4String& name) const;
	const G4VPhysicsConstructor* GetPhysicsWithType(G4int physics_type) const;

	// Replace Physics Constructor 
	//  The existing physics constructor with same physics_type as one of
	//  the given physics constructor is replaced
	//  (existing physics will be deleted)
	//  If a corresponding physics constructor is NOT found, 
	//  the given physics constructor is just added         
    void ReplacePhysics(G4VPhysicsConstructor* );

	// Remove Physics Constructor from the list
    void RemovePhysics(G4VPhysicsConstructor* );
    void RemovePhysics(G4int type);
    void RemovePhysics(const G4String& name);

通过调用RegisterPhysics()函数简便加入所需的物理过程,ReplacePhysics()加入新的或替换已存在同类型的物理过程, RemovePhysics()移除物理过程。利用G4VModularPhysicsList操作的各类物理过程实现代码都在Geant4源代码physics_list/constructors目录之中, 其中包含了decay、electromagnetic、gammat_lepto_nuclear、hadron_elastic、hadron_inelastic、ions、limiters、stopping。PhysicsList类中具体实现如下:

// EM physics
	RegisterPhysics(new G4EmLivermorePhysics());

// Decay
	RegisterPhysics(new G4DecayPhysics());

// Radioactive decay
	RegisterPhysics(new G4RadioactiveDecayPhysics());

同时,G4VModularPhysicsList类实现自动调用void ConstructParticle()void ConstructProcess()函数, 无需像G4VUserPhysicsList重写(override)这两个函数。


使用G4GenericPhysicsList调用constructors的物理过程

利用G4GenericPhysicsList类实现在mac脚本或物理过程的名称列表调用Geant4源代码physics_list/constructors中的各种物理过程。 具体实现参考extended/hadronic/Hadr05例子。 下面展示在main()函数中的用法:

  G4VModularPhysicsList* phys = 0;
  G4UImanager* UImanager = G4UImanager::GetUIpointer();
 
  // Physics List name defined via 3nd argument
  if (argc>=3) 
    { 
      phys = new G4GenericPhysicsList();
      G4String physListMacro = argv[2];
      UImanager->ApplyCommand("/control/execute "+physListMacro);
    }
  else
    {

      std::vector<G4String>* MyConstr = new std::vector<G4String>;

      MyConstr->push_back("G4EmStandardPhysics");
      MyConstr->push_back("G4EmExtraPhysics");
      MyConstr->push_back("G4DecayPhysics");
      MyConstr->push_back("G4HadronElasticPhysics");
      MyConstr->push_back("G4HadronPhysicsFTFP_BERT");
      MyConstr->push_back("G4StoppingPhysics");
      MyConstr->push_back("G4IonPhysics");
      MyConstr->push_back("G4NeutronTrackingCut");

      phys = new G4GenericPhysicsList(MyConstr);
    }

  runManager->SetUserInitialization(phys);

不过这个类有一个不足,在runManager初始化之前,必须先加载好物理过程,否则,运行时会提示错误。 下面的示例为mac脚本

/PhysicsList/defaultCutValue  0.7
/PhysicsList/SetVerboseLevel 1

/PhysicsList/RegisterPhysics G4EmStandardPhysics
/PhysicsList/RegisterPhysics G4EmExtraPhysics
/PhysicsList/RegisterPhysics G4DecayPhysics
/PhysicsList/RegisterPhysics G4HadronElasticPhysics
/PhysicsList/RegisterPhysics G4HadronPhysicsFTFP_BERT
/PhysicsList/RegisterPhysics G4StoppingPhysics
/PhysicsList/RegisterPhysics G4IonPhysics
/PhysicsList/RegisterPhysics G4NeutronTrackingCut


使用G4PhysListFactory调用集成的物理过程

目前,Geant4集成了很多可直接调用的PhysicsList类,这些物理过程可以在源代码G4PhysListFactory, 也可以在Geant4网站中看到它们的适用范围。 这些集成的物理过程如下所列:

涉及到电磁作用的物理过程可索引网站查看详细信息,目前有以下7个

这些集成的物理都可以直接声明使用,但为了程序对调用不同类型物理过程的灵活性,一般使用 G4PhysListFactory实现模拟前物理过程的快速切换,详细可见例子Hadr00, 下面是放在main()函数中关于G4PhysListFactory的用法。

	G4PhysListFactory factory;
	G4VModularPhysicsList* phys = 0;
	G4String physName = "";
	
	// Physics List name defined via 3nd argument
	if (argc>=3) { physName = argv[2]; }
	
	// Physics List is defined via environment variable PHYSLIST
	if("" == physName) {
	char* path = getenv("PHYSLIST");
	if (path) { physName = G4String(path); }
	}
	
	// if name is not known to the factory use FTFP_BERT
	if("" == physName || !factory.IsReferencePhysList(physName)) {
	physName = "FTFP_BERT"; 
	}
	
	// reference PhysicsList via its name
	phys = factory.GetReferencePhysList(physName);
	
	runManager->SetUserInitialization(phys);

通过上面的代码可发现,在运行程序前先设置好环境变量PHYSLIST,即可实现不同物理过程的调用。 例如,export PhysList=FTFP_BERT_LIV定义好环境变量后,应用程序将自动调用FTFP_BERT()G4EmLivermorePhysics()这两个物理过程,实现强作用和电磁作用的调用。

也能采用PhysicsListMessager来管理物理过程的选择,方便在mac文件中调用。 在PhysicsList类中添加一个AddPackage(const G4String& name),实现代码如下:

	#include "G4PhysListFactory.hh"
	void PhysicsList::AddPackage(const G4String& name)
	{
		G4PhysListFactory factory;
		G4VModularPhysicsList* phys =factory.GetReferencePhysList(name);

		for (G4int i = 0; ; ++i) {
			G4VPhysicsConstructor* elem =
			const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i));
			if (elem == NULL) break;
				G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
				//RegisterPhysics(elem);
				ReplacePhysics(elem);
		}
	}

其中,不用RegisterPhysics(elem),改用ReplacePhysics(elem),因为前者在相同类型的物理过程已经存在时无法被替换。


其实,Geant4软件有相当完善的资料提供给开发人员及用户,这些资料在Geant4用户支持页面之中。 里面包含了:

点击查看评论

Blog