add: PrimaryGeneratorAction, 大柱段, readme;

change: code format;
This commit is contained in:
liuyihui 2022-05-09 00:31:02 +08:00
parent 87b0d5f4b0
commit fb9e9ee7fc
17 changed files with 359 additions and 13 deletions

View File

@ -80,21 +80,17 @@ IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^[<"].*\.h[>"]'
Priority: 0
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
- Regex: '^[<"].*\.hh[>"]'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
SortPriority: 1
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
Priority: 2
SortPriority: 2
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''

View File

@ -20,7 +20,6 @@ add_executable(DESCSS main.cpp ${sources} ${headers})
target_link_libraries(DESCSS ${Geant4_LIBRARIES})
set(DESCSS_SCRIPTS
auto.mac
vis.mac
)

View File

@ -6,7 +6,89 @@
],
"settings": {
"files.associations": {
"*.icc": "cpp"
"*.icc": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"deque": "cpp",
"exception": "cpp",
"format": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ostream": "cpp",
"queue": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
}

View File

@ -2,3 +2,31 @@
Dose Estimation by Simulation of China Space Station
中国空间站模拟剂量评估
## 空间辐射环境
## 空间站结构
1. 尺寸与分区[^1]
![](docs/size.webp)
* 全长16.6 m
* 分区:
* 大柱段
* 外径4.2 m
* 长度4.32 + 2.40 m (生活控制舱 + 资源舱)(直线过渡)
* 过渡段0.815 m
* 小柱端
* 外径2.8 m
* 长度5.18 m
* 过渡段0.33 m
* 节点舱
* 长度0.4 + 1.41 + 0.60 m
* 外径2.13 + 2.8 + 1.22 m (球形过渡)
2. 材料
* 大柱段
* 外壳5系铝合金[^2],选用`0.4 Si`+`0.35 Fe`+`0.1 Cu`+`0.7 Mn`+`4.5 Mg`+`0.15 Cr`+`0.25 Zn`+`0.15 Ti`+`93.4 Al`
[^1]: [【知识点·航天】“天和”核心舱、“天宫”空间站和新一代载人飞船的最新知识点(干货版)](https://zhuanlan.zhihu.com/p/103709953)
[^2]: [中铝造为“天和”号核心舱披“铠甲”壮“筋骨”](https://m.thepaper.cn/baijiahao_12484370)

BIN
docs/size.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

View File

@ -0,0 +1,14 @@
#ifndef DESCSS_ActionInitialization_h
#define DESCSS_ActionInitialization_h
#include "G4VUserActionInitialization.hh"
class ActionInitialization : public G4VUserActionInitialization {
public:
ActionInitialization();
~ActionInitialization() override;
void Build() const override;
};
#endif

View File

@ -0,0 +1,19 @@
#ifndef DESCSS_DetectorConstruction_h
#define DESCSS_DetectorConstruction_h
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class DetectorConstruction : public G4VUserDetectorConstruction {
public:
DetectorConstruction();
~DetectorConstruction() override;
G4VPhysicalVolume* Construct() override;
};
#endif

8
include/Material.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef DESCSS_Material_h
#define DESCSS_Material_h
#include "G4Material.hh"
void DefineMaterials();
#endif

View File

@ -0,0 +1,23 @@
#ifndef DESCSS_PrimaryGeneratorAction_h
#define DESCSS_PrimaryGeneratorAction_h
#include "G4ParticleGun.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
class G4Box;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
public:
PrimaryGeneratorAction();
~PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event*);
const G4ParticleGun* GetParticleGun() const { return fParticleGun; }
private:
G4ParticleGun* fParticleGun;
};
#endif

View File

@ -0,0 +1,40 @@
#include "ActionInitialization.h"
#include "DetectorConstruction.h"
#include "PrimaryGeneratorAction.h"
#include "G4MTRunManager.hh"
#include "G4ScoringManager.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "QBBC.hh"
int main(int argc, char** argv) {
G4UIExecutive* ui = nullptr;
if (argc == 1) ui = new G4UIExecutive(argc, argv);
G4MTRunManager* runManager = new G4MTRunManager;
G4VisExecutive* visManager = new G4VisExecutive;
G4UImanager* UIManager = G4UImanager::GetUIpointer();
G4ScoringManager::GetScoringManager();
runManager->SetUserInitialization(new DetectorConstruction());
runManager->SetUserInitialization(new QBBC);
runManager->SetUserInitialization(new ActionInitialization());
visManager->Initialize();
if (!ui) {
G4String command = "/control/execute ";
G4String fileName = argv[1];
UIManager->ApplyCommand(command + fileName);
} else {
UIManager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
delete runManager;
delete visManager;
return 0;
}

View File

View File

@ -0,0 +1,8 @@
#include "ActionInitialization.h"
#include "PrimaryGeneratorAction.h"
ActionInitialization::ActionInitialization() {}
ActionInitialization::~ActionInitialization() {}
void ActionInitialization::Build() const { SetUserAction(new PrimaryGeneratorAction); }

View File

@ -0,0 +1,35 @@
#include "DetectorConstruction.h"
#include "Material.h"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tubs.hh"
DetectorConstruction::DetectorConstruction() {}
DetectorConstruction::~DetectorConstruction() {}
G4VPhysicalVolume* DetectorConstruction::Construct() {
// Define materials
DefineMaterials();
// World
G4Box* solid_world = new G4Box("World", 3. * m, 3. * m, 10. * m);
G4LogicalVolume* logic_world = new G4LogicalVolume(solid_world, G4Material::GetMaterial("Vacuum"), "World");
G4VPhysicalVolume* physics_world = new G4PVPlacement(0, G4ThreeVector(), logic_world, "World", 0, false, 0, true);
// 大柱段
// 生活控制舱
G4double pRmin_big = 2.2 / 2 * m;
G4double pRmax_big = 4.2 / 2 * m;
G4double zLength = 4.32 * m;
G4ThreeVector pos1 = G4ThreeVector(0, 0, -(0.815 * m + zLength / 2));
G4Tubs* solid_section_big_life = new G4Tubs("section_big_life", pRmin_big, pRmax_big, zLength / 2, 0, 360);
G4LogicalVolume* logic_section_big_life = new G4LogicalVolume(
solid_section_big_life, G4Material::GetMaterial("Aluminum alloy Series 5"), "section_big_life");
new G4PVPlacement(0, pos1, logic_section_big_life, "section_big_life", logic_world, false, 0, true);
return physics_world;
}

35
src/Material.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "Material.h"
#include "G4Element.hh"
#include "G4NistManager.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
void DefineMaterials() {
G4double a, z; // 摩尔质量, 原子序数
G4int ncomponents, fractionmass; // 组分数, 质量分数
G4double density, pressure, temperature;
G4NistManager* nist = G4NistManager::Instance();
// 真空
density = universe_mean_density;
pressure = 3.e-18 * pascal;
temperature = 2.73 * kelvin;
new G4Material("Vacuum", z = 1., a = 1.01 * g / mole, density, kStateGas, temperature, pressure);
// 5系铝合金 0.4 Si + 0.35 Fe + 0.1 Cu + 0.7 Mn + 4.5 Mg + 0.15 Cr + 0.25 Zn + 0.15 Ti + 93.4 Al
density = 2.68 * g / cm3;
G4Material* Al_alloy_5 = new G4Material("Aluminum alloy Series 5", density, ncomponents = 9);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Si"), fractionmass = .4 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Fe"), fractionmass = .35 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Cu"), fractionmass = .1 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Mn"), fractionmass = .7 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Mg"), fractionmass = 4.5 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Cr"), fractionmass = .15 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Zn"), fractionmass = .25 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Ti"), fractionmass = .15 * perCent);
Al_alloy_5->AddElement(nist->FindOrBuildElement("Al"), fractionmass = 93.4 * perCent);
std::cout << *(G4Material::GetMaterialTable()) << std::endl;
}

View File

@ -0,0 +1,18 @@
#include "PrimaryGeneratorAction.h"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
PrimaryGeneratorAction::PrimaryGeneratorAction() {
auto table = G4ParticleTable::GetParticleTable();
fParticleGun = new G4ParticleGun(1);
fParticleGun->SetParticleDefinition(table->FindParticle("gamma"));
fParticleGun->SetParticlePosition(G4ThreeVector(0, 0, 555. / 2 * mm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0, 0, -1));
fParticleGun->SetParticleEnergy(1 * MeV);
}
PrimaryGeneratorAction::~PrimaryGeneratorAction() { delete fParticleGun; }
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* e) { fParticleGun->GeneratePrimaryVertex(e); }

41
vis.mac Normal file
View File

@ -0,0 +1,41 @@
# 多线程设置
/run/numberOfThreads 1
# verbose
/control/saveHistory
/control/verbose 2
/run/verbose 1
/event/verbose 0
/tracking/verbose 0
# 初始化
/run/initialize
# 设置视图使用OpenGL
/vis/open OGL 800x800-0+0
# 禁止自动刷新,消息静音(除错误外)
/vis/viewer/set/autoRefresh false
/vis/verbose errors
# 绘制几何体
/vis/drawVolume
# 绘制轨迹 类型为平滑
/vis/scene/add/trajectories smooth
# 根据粒子ID进行绘制
/vis/modeling/trajectories/create/drawByParticleID
# 以2px的宽度绘制节点
/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByParticleID-0/default/setStepPtsSize 2
# 保留、叠加所有事例
/vis/scene/endOfEventAction accumulate
# 设置颜色
/vis/geometry/set/visibility World 0 false
/vis/geometry/set/colour section_big_life 0 0 0 1 .3
/vis/viewer/set/style surface
# 坐标轴
/vis/scene/add/scale # Simple scale line
/vis/scene/add/axes # Simple axes: x=red, y=green, z=blue.