def __init__(self, parent, shift_z): material = G4.G4NistManager.Instance().FindOrBuildMaterial( "G4_Fe") # выбираем материал - железо position = G4.G4ThreeVector(0.0 * cm, 0.0 * cm, 0.0 * cm + shift_z) dimensions = G4.G4Box("Plate", 4.0 * cm, 4.0 * cm, 5.0 * mm) # размеры пластины (±x, ±y, ±z) self.logical = G4.G4LogicalVolume(dimensions, material, "Plate") # заполнение его материалом self.physical = G4.G4PVPlacement(None, position, self.logical, "Plate", parent, False, 0)
def __init__(self): material = G4.G4NistManager.Instance().FindOrBuildMaterial( "G4_AIR") # выбираем материал - воздух position = G4.G4ThreeVector(0.0 * cm, 0.0 * cm, 0.0 * cm) dimensions = G4.G4Box("WorldBox", 6.0 * cm, 6.0 * cm, 20.0 * cm) # известное нам пространство (±x, ±y, ±z) self.logical = G4.G4LogicalVolume(dimensions, material, "piece") # заполнение его материалом self.physical = G4.G4PVPlacement(None, position, self.logical, "World", None, False, 0)
def Construct(self): check_overlap = False many = False geometry_keys = list(self.conf['Geometry'].keys()) if len(geometry_keys) != 1: raise ValueError('Must define exactly one top-level Geometry') world_name = geometry_keys[0] global geom_s, geom_l, geom_p geom_s = {} geom_l = {} geom_p = {} for geom in depth_first_tree_traversal(self.conf['Geometry']): geom_type = geom['Type'] geom_name = geom['Name'] parent_name = geom_name.rsplit('.', 1)[0] if parent_name in geom_p: parent_p = geom_p[parent_name] else: parent_p = None if geom_type == 'G4Box': solid = g4.G4Box(geom_name, geom['pX'] * mm, geom['pY'] * mm, geom['pZ'] * mm) elif geom_type == 'G4Tubs': solid = g4.G4Tubs(geom_name, geom['pRMin'] * mm, geom['pRMax'] * mm, geom['pDz'] * mm, geom['pSPhi'] * deg, geom['pDPhi'] * deg) elif geom_type == 'CadMesh': mesh = compton.cadmesh.TessellatedMesh(geom['File']) if 'SolidName' in geom: solid = mesh.GetSolid(geom['SolidName']) else: solid = mesh.GetSolid(0) else: raise ValueError( "unimplemented geometry type '{}'".format(geom_type)) logical = g4.G4LogicalVolume( solid, g4.gNistManager.FindOrBuildMaterial(geom['Material']), geom_name) transform = g4.G4Transform3D() if 'Transformation' in geom: for operation, value in zip(*geom['Transformation']): translation = g4.G4ThreeVector() rotation = g4.G4RotationMatrix() if operation == 'TranslateX': translation += g4.G4ThreeVector(value * mm, 0, 0) elif operation == 'TranslateY': translation += g4.G4ThreeVector(0, value * mm, 0) elif operation == 'TranslateZ': translation += g4.G4ThreeVector(0, 0, value * mm) elif operation == 'RotateX': rotation.rotateX(value * deg) elif operation == 'RotateY': rotation.rotateY(value * deg) elif operation == 'RotateZ': rotation.rotateZ(value * deg) else: assert (False) transform = (g4.G4Transform3D(rotation, translation) * transform) if 'Rotation' in geom: euler = np.array(geom['Rotation']) * deg rotation = g4.G4RotationMatrix() rotation.rotateZ(euler[0]) rotation.rotateY(euler[1]) rotation.rotateZ(euler[2]) else: rotation = g4.G4RotationMatrix() if 'Translation' in geom: translation = g4.G4ThreeVector(*np.array(geom['Translation']) * mm) else: translation = g4.G4ThreeVector() physical = g4.G4PVPlacement( g4.G4Transform3D(rotation, translation) * transform, geom_name, logical, parent_p, many, 0, check_overlap) if 'Visible' in geom: logical.SetVisAttributes(g4.G4VisAttributes(geom['Visible'])) if 'Color' in geom: logical.SetVisAttributes( g4.G4VisAttributes(g4.G4Color(*geom['Color']))) geom_s[geom_name] = solid geom_l[geom_name] = logical geom_p[geom_name] = physical return geom_p[world_name]
def ConstructDevice(self): """ """ # make colours white = g4.G4Color(1.0, 1.0, 1.0) orange = g4.G4Color(.75, .55, 0.0) world_visatt = g4.G4VisAttributes(True, white) process_space_visatt = g4.G4VisAttributes(False, orange) # ======== # World # ======== world_length_x = settings.world_length_x * g4.micrometer world_length_y = settings.world_length_y * g4.micrometer world_length_z = settings.world_length_z * g4.micrometer world_solid = g4.G4Box("world_solid", world_length_x, world_length_y, world_length_z) world_logical = g4.G4LogicalVolume(world_solid, self.world_material, "world_logical") world_logical.SetVisAttributes(world_visatt) self.world_physical = g4.G4PVPlacement(g4.G4Transform3D(), world_logical, "world_physical", None, False, 0) # =============== # process space # =============== process_space_length_x = settings.process_space_length_x * g4.micrometer process_space_length_y = settings.process_space_length_y * g4.micrometer process_space_length_z = settings.process_space_length_z * g4.micrometer process_space_solid = g4.G4Box("process_space_solid", process_space_length_x, process_space_length_y, process_space_length_z) process_space_logical = g4.G4LogicalVolume(process_space_solid, self.process_space_material, "process_space_logical") process_space_logical.SetVisAttributes(process_space_visatt) process_space_pos = g4.G4ThreeVector(0, 0, -process_space_length_z) process_space_physical = g4.G4PVPlacement(None, process_space_pos, "process_space_physical", process_space_logical, self.world_physical, False, 0, True) # ======================== # process wafer phantom # ======================== voxel_length_x = process_space_length_x / self.n_voxel_x voxel_length_y = process_space_length_y / self.n_voxel_y voxel_length_z = process_space_length_z / self.n_voxel_z voxel_solid = g4.G4Box("voxel_solid", voxel_length_x, voxel_length_y, voxel_length_z) self.voxel_logical = g4.G4LogicalVolume(voxel_solid, self.process_space_material, "voxel_logical") # voxel_logical.SetVisAttributes(g4.G4VisAttributes(G4VisAttributes::GetInvisible())) wafer = PhantomParameterisationColour() # set color for mat_name, color in settings.COLOR_MAP.items(): cred = color[0] cgreen = color[1] cblue = color[2] copacity = color[3] g4_color = g4.G4Color(cred, cgreen, cblue, copacity) visAtt = g4.G4VisAttributes(g4_color) # visAtt.SetForceSolid(True) visAtt.SetVisibility(True) wafer.AddColor(mat_name, visAtt) wafer.SetVoxelDimensions(voxel_length_x, voxel_length_y, voxel_length_z) wafer.SetNoVoxel(self.n_voxel_x, self.n_voxel_y, self.n_voxel_z) wafer.SetMaterials(self.materials) wafer.SetMaterialIndices(self.material_IDs) wafer.BuildContainerSolid(process_space_physical) wafer.CheckVoxelsFillContainer(process_space_solid.GetXHalfLength(), process_space_solid.GetYHalfLength(), process_space_solid.GetZHalfLength()) n_voxel = self.n_voxel_x * self.n_voxel_y * self.n_voxel_z wafer_physical = G4PVParameterised("wafer_physical", self.voxel_logical, process_space_logical, g4.G4global.EAxis.kXAxis, n_voxel, wafer, False) wafer_physical.SetRegularStructureId(1) return self.world_physical