diff --git a/G4.code-workspace b/G4.code-workspace index bf12ff8..8cd08cc 100644 --- a/G4.code-workspace +++ b/G4.code-workspace @@ -88,7 +88,8 @@ "xstring": "cpp", "xtr1common": "cpp", "xtree": "cpp", - "xutility": "cpp" + "xutility": "cpp", + "bbox_action": "cpp" } } } \ No newline at end of file diff --git a/docs/Shell.png b/docs/Shell.png new file mode 100644 index 0000000..ca7237c Binary files /dev/null and b/docs/Shell.png differ diff --git a/docs/Taparan.png b/docs/Taparan.png new file mode 100644 index 0000000..0933a83 Binary files /dev/null and b/docs/Taparan.png differ diff --git a/docs/Tianhe.jpg b/docs/Tianhe.jpg new file mode 100644 index 0000000..ad67dd1 Binary files /dev/null and b/docs/Tianhe.jpg differ diff --git a/docs/空间站无太阳能板.stl b/docs/空间站无太阳能板.stl new file mode 100644 index 0000000..675e860 Binary files /dev/null and b/docs/空间站无太阳能板.stl differ diff --git a/include/ActionInitialization.h b/include/ActionInitialization.h index e7d1c31..7f3f7c7 100644 --- a/include/ActionInitialization.h +++ b/include/ActionInitialization.h @@ -11,4 +11,4 @@ public: void Build() const override; }; -#endif \ No newline at end of file +#endif diff --git a/include/Material.h b/include/Material.h index dcdc66a..f5ea7c5 100644 --- a/include/Material.h +++ b/include/Material.h @@ -5,4 +5,4 @@ void DefineMaterials(); -#endif \ No newline at end of file +#endif diff --git a/main.cpp b/main.cpp index f430ace..262f28f 100644 --- a/main.cpp +++ b/main.cpp @@ -9,7 +9,6 @@ #include "G4VisExecutive.hh" #include "QBBC.hh" - int main(int argc, char** argv) { G4UIExecutive* ui = nullptr; if (argc == 1) ui = new G4UIExecutive(argc, argv); @@ -37,4 +36,4 @@ int main(int argc, char** argv) { delete runManager; delete visManager; return 0; -} \ No newline at end of file +} diff --git a/src/ActionInitialization.cpp b/src/ActionInitialization.cpp index 189dc72..f563642 100644 --- a/src/ActionInitialization.cpp +++ b/src/ActionInitialization.cpp @@ -5,4 +5,4 @@ ActionInitialization::ActionInitialization() {} ActionInitialization::~ActionInitialization() {} -void ActionInitialization::Build() const { SetUserAction(new PrimaryGeneratorAction); } \ No newline at end of file +void ActionInitialization::Build() const { SetUserAction(new PrimaryGeneratorAction); } diff --git a/src/DetectorConstruction.cpp b/src/DetectorConstruction.cpp index 07bd1be..8101369 100644 --- a/src/DetectorConstruction.cpp +++ b/src/DetectorConstruction.cpp @@ -2,34 +2,89 @@ #include "Material.h" #include "G4Box.hh" +#include "G4IntersectionSolid.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" +#include "G4SubtractionSolid.hh" #include "G4SystemOfUnits.hh" #include "G4Tubs.hh" +#include "G4UnionSolid.hh" DetectorConstruction::DetectorConstruction() {} DetectorConstruction::~DetectorConstruction() {} +static G4double ConstrustSectionBig(G4LogicalVolume* fMotherLogical, G4double zBias) { + G4double pRmaxBig = 4.2 / 2 * m; + G4double hzBig = 6.72 / 2 * m; + G4double hxBigBox = 2.4 / 2 * m; + G4double pRmaxBigMid = pRmaxBig - 10 * cm; + G4ThreeVector pos1 = G4ThreeVector(0, 0, -(zBias + hzBig)); + G4double pos2 = -(zBias + hzBig * 2) + 9.8 * cm; + + // 外壳 + G4Tubs* solidShellAl1 = new G4Tubs("sectionBigShellAl1", pRmaxBig - 2, pRmaxBig, hzBig, 0, 360); + G4LogicalVolume* logicShellAl1 = new G4LogicalVolume( + solidShellAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigShellAl1"); + new G4PVPlacement(0, pos1, logicShellAl1, "sectionBigShellAl1", fMotherLogical, false, 0, true); + + G4Tubs* solidShellTap = new G4Tubs("sectionBigShellTap", pRmaxBig - 55, pRmaxBig - 45, hzBig, 0, 360); + G4LogicalVolume* logicShellTap = new G4LogicalVolume( + solidShellTap, G4Material::GetMaterial("Taparan"), "sectionBigShellTap"); + new G4PVPlacement(0, pos1, logicShellTap, "sectionBigShellTap", fMotherLogical, false, 0, true); + + G4Tubs* solidShellAl2 = new G4Tubs("sectionBigShellAl2", pRmaxBigMid, pRmaxBigMid + 5, hzBig, 0, 360); + G4LogicalVolume* logicShellAl2 = new G4LogicalVolume( + solidShellAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigShellAl2"); + new G4PVPlacement(0, pos1, logicShellAl2, "sectionBigShellAl2", fMotherLogical, false, 0, true); + + // 填充 + G4Tubs* solidMidTubs = new G4Tubs("sectionBigMidTubs", 0, pRmaxBigMid, hzBig, 0, 360); + G4Box* solidMidBox = new G4Box("sectionBigMidBox", hxBigBox, hxBigBox, hzBig); + G4SubtractionSolid* solidMid = + new G4SubtractionSolid("sectionBigMid", solidMidTubs, solidMidBox); + G4LogicalVolume* logicMid = + new G4LogicalVolume(solidMid, G4Material::GetMaterial("G4_Al"), "sectionBigMid"); + new G4PVPlacement(0, pos1, logicMid, "sectionBigMid", fMotherLogical, false, 0, true); + + // 空气 + G4Box* solidAir = new G4Box("sectionBigAirBox", hxBigBox, hxBigBox, hzBig); + G4LogicalVolume* logicAir = + new G4LogicalVolume(solidAir, G4Material::GetMaterial("G4_AIR"), "sectionBigAir"); + new G4PVPlacement(0, pos1, logicAir, "sectionBigAir", fMotherLogical, false, 0, true); + + // 尾部 + G4Tubs* solidTailAl1 = new G4Tubs("sectionBigTailAl1", 0, pRmaxBigMid, 2.5, 0, 360); + G4LogicalVolume* logicTailAl1 = new G4LogicalVolume( + solidTailAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigTailAl1"); + new G4PVPlacement(0, G4ThreeVector(0, 0, pos2 - 2.5), logicTailAl1, "sectionBigTailAl1", fMotherLogical, false, 0, true); + + G4Tubs* solidTailTap = new G4Tubs("sectionBigTailTap", 0, pRmaxBigMid, 5, 0, 360); + G4LogicalVolume* logicTailTap = new G4LogicalVolume( + solidTailTap, G4Material::GetMaterial("Taparan"), "sectionBigTailTap"); + new G4PVPlacement(0, G4ThreeVector(0, 0, pos2 - 50), logicTailTap, "sectionBigTailTap", fMotherLogical, false, 0, true); + + G4Tubs* solidTailAl2 = new G4Tubs("sectionBigTailAl2", 0, pRmaxBig, 1, 0, 360); + G4LogicalVolume* logicTailAl2 = new G4LogicalVolume( + solidTailAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigTailAl2"); + new G4PVPlacement(0, G4ThreeVector(0, 0, pos2 - 99), logicTailAl2, "sectionBigTailAl2", fMotherLogical, false, 0, true); + + return zBias + hzBig; +} + G4VPhysicalVolume* DetectorConstruction::Construct() { + G4double zBias = 0.815 * m; + // 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); + G4Box* solidWorld = new G4Box("World", 3. * m, 3. * m, 10. * m); + G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), "World"); + G4VPhysicalVolume* physicsWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "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); + zBias = ConstrustSectionBig(logicWorld, zBias); - return physics_world; + return physicsWorld; } diff --git a/src/Material.cpp b/src/Material.cpp index acc1e01..7e9d507 100644 --- a/src/Material.cpp +++ b/src/Material.cpp @@ -6,12 +6,16 @@ #include "G4SystemOfUnits.hh" void DefineMaterials() { - G4double a, z; // 摩尔质量, 原子序数 - G4int ncomponents, fractionmass; // 组分数, 质量分数 + G4double a, z; // 摩尔质量, 原子序数 + G4int ncomponents, fractionmass, natoms; // 组分数, 质量分数, 原子数 G4double density, pressure, temperature; G4NistManager* nist = G4NistManager::Instance(); + // 已有 + nist->FindOrBuildMaterial("G4_AIR"); + nist->FindOrBuildMaterial("G4_Al"); + // 真空 density = universe_mean_density; pressure = 3.e-18 * pascal; @@ -20,16 +24,24 @@ void DefineMaterials() { // 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); + G4Material* AlAlloyS5 = new G4Material("AluminumAlloySeries5", density, ncomponents = 9); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Si"), fractionmass = .4 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Fe"), fractionmass = .35 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Cu"), fractionmass = .1 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Mn"), fractionmass = .7 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Mg"), fractionmass = 4.5 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Cr"), fractionmass = .15 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Zn"), fractionmass = .25 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Ti"), fractionmass = .15 * perCent); + AlAlloyS5->AddElement(nist->FindOrBuildElement("Al"), fractionmass = 93.4 * perCent); + + // 泰普龙 Taparan + density = 1.44 * g / cm3; + G4Material* Taparan = new G4Material("Taparan", density, ncomponents = 4); + Taparan->AddElement(nist->FindOrBuildElement("C"), natoms = 14); + Taparan->AddElement(nist->FindOrBuildElement("H"), natoms = 10); + Taparan->AddElement(nist->FindOrBuildElement("N"), natoms = 2); + Taparan->AddElement(nist->FindOrBuildElement("O"), natoms = 2); std::cout << *(G4Material::GetMaterialTable()) << std::endl; -} \ No newline at end of file +} diff --git a/vis.mac b/vis.mac index 70cc493..a077020 100644 --- a/vis.mac +++ b/vis.mac @@ -33,7 +33,8 @@ # 设置颜色 /vis/geometry/set/visibility World 0 false -/vis/geometry/set/colour section_big_life 0 0 0 1 .3 +/vis/geometry/set/colour sectionBigMid 0 0.631373 0.686275 0.733333 0.584314 +/vis/geometry/set/colour sectionBigAir 0 0.631373 0.686275 0.733333 0.584314 /vis/viewer/set/style surface # 坐标轴