geant4模拟阿尔法衰变代码
时间: 2023-12-19 19:05:27 浏览: 70
以下是一个使用Geant4模拟阿尔法衰变的示例代码供参考:
```c++
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4UIterminal.hh"
#include "G4VisExecutive.hh"
#include "G4VModularPhysicsList.hh"
#include "G4EmStandardPhysics.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4PVPlacement.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleTable.hh"
#include "G4IonTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4GenericIon.hh"
#include "G4Event.hh"
#include "G4PrimaryParticle.hh"
#include "G4PrimaryVertex.hh"
#include "Randomize.hh"
int main(int argc, char** argv) {
// 初始化G4运行管理器
G4RunManager* runManager = new G4RunManager;
// 注册G4物理列表
G4VModularPhysicsList* physicsList = new G4VModularPhysicsList;
physicsList->RegisterPhysics(new G4EmStandardPhysics);
runManager->SetUserInitialization(physicsList);
// 构造几何形状
G4NistManager* nist = G4NistManager::Instance();
G4Box* worldBox = new G4Box("World", 10*m, 10*m, 10*m);
G4LogicalVolume* worldLog = new G4LogicalVolume(worldBox, nist->FindOrBuildMaterial("G4_AIR"), "World");
G4VPhysicalVolume* worldPhys = new G4PVPlacement(0, G4ThreeVector(), worldLog, "World", 0, false, 0);
G4Tubs* sourceTube = new G4Tubs("Source", 0, 1*cm, 1*cm, 0, 2*pi);
G4LogicalVolume* sourceLog = new G4LogicalVolume(sourceTube, nist->FindOrBuildMaterial("G4_Al"), "Source");
new G4PVPlacement(0, G4ThreeVector(), sourceLog, "Source", worldLog, false, 0);
// 定义粒子种类和能量
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* alpha = particleTable->GetIonTable()->GetIon(2, 4, 0);
G4double energy = 5.48*MeV;
// 创建主粒子
G4PrimaryParticle* primary = new G4PrimaryParticle(alpha, energy, 0, 0, G4ThreeVector(0, 0, 1));
G4PrimaryVertex* vertex = new G4PrimaryVertex(G4ThreeVector(0, 0, -5*cm), 0);
vertex->SetPrimary(primary);
// 生成事件并打印结果
G4Event event;
event.AddPrimaryVertex(vertex);
event.Print();
// 开始模拟
runManager->BeamOn(1);
// 释放资源
delete runManager;
return 0;
}
```
这个示例代码创建了一个包含一个半径为1cm、长度为2cm的铝源的几何形状,并在源的朝向上发射一个5.48MeV的$\alpha$粒子。运行时,它将生成一个事件并在控制台上打印结果,并通过Geant4模拟出该事件的物理行为。
阅读全文