def setUp(self): TestCase.setUp(self) self.geo = PenelopeGeometry('Test Geometry') surface1 = zplane(1e-10) surface2 = zplane(-1e-3) surface3 = cylinder(1e-2) surface4 = xplane(0.0) mat1 = PenelopeMaterial.pure(29) self.module1 = Module(self.geo, mat1) self.module1.add_surface(surface1, SIDEPOINTER_NEGATIVE) self.module1.add_surface(surface2, SIDEPOINTER_POSITIVE) self.module1.add_surface(surface3, SIDEPOINTER_NEGATIVE) self.module1.add_surface(surface4, SIDEPOINTER_POSITIVE) self.geo.modules.add(self.module1) mat2 = PenelopeMaterial.pure(30) self.module2 = Module(self.geo, mat2) self.module2.add_surface(surface1, SIDEPOINTER_NEGATIVE) self.module2.add_surface(surface2, SIDEPOINTER_POSITIVE) self.module2.add_surface(surface3, SIDEPOINTER_NEGATIVE) self.module2.add_module(self.module1) self.geo.modules.add(self.module2) self.geo.tilt_rad = radians(45)
def _export_geometry_substrate(self, geometry, pengeom): surface_cylinder = cylinder(0.1) # 10 cm radius surface_top = zplane(0.0) # z = 0 surface_bottom = zplane(-0.1) # z = -10 cm module = Module(pengeom, geometry.body.material, 'Substrate') module.add_surface(surface_cylinder, -1) module.add_surface(surface_top, -1) module.add_surface(surface_bottom, 1) pengeom.modules.add(module)
def _export_geometry_vertical_layers(self, geometry, pengeom): layers = np.array(geometry.layers, ndmin=1) # Surfaces surface_top = zplane(0.0) # z = 0 surface_bottom = zplane(-0.1) # z = -10 cm surface_layers = [] for layer in layers: surface_layers.append(xplane(layer.xmin_m)) surface_layers.append(xplane(layer.xmax_m)) diameter_m = sum(map(attrgetter('thickness_m'), layers)) surface_cylinder = cylinder(0.1 + 3.0 * diameter_m) # 10 cm radius # Modules ## Left substrate module = Module(pengeom, geometry.left_substrate.material, 'Left substrate') module.add_surface(surface_cylinder, -1) module.add_surface(surface_top, -1) module.add_surface(surface_bottom, 1) module.add_surface(surface_layers[0], -1) pengeom.modules.add(module) ## Layers for i, surfaces in enumerate(_pairwise(surface_layers)): surface_left, surface_right = surfaces module = Module(pengeom, layers[i].material, 'Layer %i' % (i + 1, )) module.add_surface(surface_cylinder, -1) module.add_surface(surface_top, -1) module.add_surface(surface_bottom, 1) module.add_surface(surface_left, 1) module.add_surface(surface_right, -1) pengeom.modules.add(module) ## Right substrate module = Module(pengeom, geometry.right_substrate.material, 'Right substrate') module.add_surface(surface_cylinder, -1) module.add_surface(surface_top, -1) module.add_surface(surface_bottom, 1) module.add_surface(surface_layers[-1], 1) pengeom.modules.add(module)
def _export_geometry_inclusion(self, geometry, pengeom): surface_cylinder = cylinder(0.1) # 10 cm radius surface_top = zplane(0.0) # z = 0 surface_bottom = zplane(-0.1) # z = -10 cm surface_sphere = sphere(geometry.inclusion.diameter_m / 2.0) module_inclusion = Module(pengeom, geometry.inclusion.material, 'Inclusion') module_inclusion.add_surface(surface_top, -1) module_inclusion.add_surface(surface_sphere, -1) module_substrate = Module(pengeom, geometry.substrate.material, 'Substrate') module_substrate.add_surface(surface_cylinder, -1) module_substrate.add_surface(surface_top, -1) module_substrate.add_surface(surface_bottom, 1) module_substrate.add_module(module_inclusion) pengeom.modules.add(module_substrate) pengeom.modules.add(module_inclusion)
def _export_geometry_horizontal_layers(self, geometry, pengeom): layers = np.array(geometry.layers, ndmin=1) # Surfaces surface_cylinder = cylinder(0.1) # 10 cm radius surface_layers = [zplane(0.0)] for layer in layers: surface_layers.append(zplane(layer.zmin_m)) # Modules tmpgrouping = [] for i, surfaces in enumerate(_pairwise(surface_layers)): surface_top, surface_bottom = surfaces module = Module(pengeom, layers[i].material, 'Layer %i' % (i + 1, )) module.add_surface(surface_cylinder, -1) module.add_surface(surface_top, -1) module.add_surface(surface_bottom, 1) pengeom.modules.add(module) tmpgrouping.append((module, surface_bottom)) if geometry.has_substrate(): surface_top = surface_layers[-1] surface_bottom = zplane(surface_top.shift.z_m - 0.1) # 10 cm below last layer module = Module(pengeom, geometry.substrate.material, 'Substrate') module.add_surface(surface_cylinder, -1) module.add_surface(surface_top, -1) module.add_surface(surface_bottom, 1) pengeom.modules.add(module) tmpgrouping.append((module, surface_bottom)) # Grouping # G0: s0, s2, m0, m1 # G1: s0, s3, m2, g0 # G2: s0, s4, m3, g1 # etc. if len(tmpgrouping) <= 2: # no grouping required if only 2 modules return module, surface_bottom = tmpgrouping[1] group = Module(pengeom, VACUUM, 'grouping') group.add_surface(surface_cylinder, -1) group.add_surface(surface_layers[0], -1) # top z = 0.0 group.add_surface(surface_bottom, 1) group.add_module(tmpgrouping[0][0]) # m0 group.add_module(module) #m1 pengeom.modules.add(group) for module, surface_bottom in tmpgrouping[2:]: oldgroup = group group = Module(pengeom, VACUUM, 'grouping') group.add_surface(surface_cylinder, -1) group.add_surface(surface_layers[0], -1) # top z = 0.0 group.add_surface(surface_bottom, 1) group.add_module(module) group.add_module(oldgroup) pengeom.modules.add(group)