当前位置: 首页>>代码示例>>Python>>正文


Python Options.geometry方法代码示例

本文整理汇总了Python中pymontecarlo.options.options.Options.geometry方法的典型用法代码示例。如果您正苦于以下问题:Python Options.geometry方法的具体用法?Python Options.geometry怎么用?Python Options.geometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymontecarlo.options.options.Options的用法示例。


在下文中一共展示了Options.geometry方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testexport_multilayers1

# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import geometry [as 别名]
    def testexport_multilayers1(self):
        # Create options
        mat1 = Material({79: 0.5, 47: 0.5}, "Mat1", absorption_energy_eV={ELECTRON: 123.0})
        mat2 = Material({29: 0.5, 30: 0.5}, "Mat2", absorption_energy_eV={ELECTRON: 89.0})
        mat3 = Material({13: 0.5, 14: 0.5}, "Mat3", absorption_energy_eV={ELECTRON: 89.0})

        ops = Options()
        ops.beam.energy_eV = 1234
        ops.beam.diameter_m = 25e-9
        ops.beam.origin_m = (100e-9, 0, 1)

        ops.geometry = HorizontalLayers(mat1)
        ops.geometry.add_layer(mat2, 25e-9)
        ops.geometry.add_layer(mat3, 55e-9)

        ops.limits.add(ShowersLimit(5678))

        # Export to CAS
        casfile = self.e.export_cas(ops)

        # Test
        simdata = casfile.getOptionSimulationData()
        simops = simdata.getSimulationOptions()
        regionops = simdata.getRegionOptions()

        self.assertAlmostEqual(1.234, simops.getIncidentEnergy_keV(0), 4)
        self.assertAlmostEqual(34.93392125, simops.Beam_Diameter, 4)  # FWHM
        self.assertAlmostEqual(100.0, simops._positionStart_nm, 4)

        self.assertEqual(3, regionops.getNumberRegions())

        region = regionops.getRegion(0)
        elements = list(map(attrgetter("Z"), region.getElements()))
        self.assertAlmostEqual(mat2.density_kg_m3 / 1000.0, region.Rho, 4)
        self.assertEqual("Mat2", region.Name)
        self.assertEqual(2, len(elements))
        self.assertTrue(29 in elements)
        self.assertTrue(30 in elements)

        region = regionops.getRegion(1)
        elements = list(map(attrgetter("Z"), region.getElements()))
        self.assertAlmostEqual(mat3.density_kg_m3 / 1000.0, region.Rho, 4)
        self.assertEqual("Mat3", region.Name)
        self.assertEqual(2, len(elements))
        self.assertTrue(13 in elements)
        self.assertTrue(14 in elements)

        region = regionops.getRegion(2)
        elements = list(map(attrgetter("Z"), region.getElements()))
        self.assertAlmostEqual(mat1.density_kg_m3 / 1000.0, region.Rho, 4)
        self.assertEqual("Mat1", region.Name)
        self.assertEqual(2, len(elements))
        self.assertTrue(79 in elements)
        self.assertTrue(47 in elements)

        self.assertAlmostEqual(0.089, simops.Eminimum, 3)

        self.assertEqual(5678, simops.getNumberElectrons())

        self.assertFalse(simops.FEmissionRX)
开发者ID:pymontecarlo,项目名称:pymontecarlo-casino2,代码行数:62,代码来源:test_exporter.py

示例2: testexport_inclusion

# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import geometry [as 别名]
    def testexport_inclusion(self):
        # Create
        mat1 = PenelopeMaterial({79: 0.5, 47: 0.5}, "mat")
        mat2 = PenelopeMaterial({29: 0.5, 30: 0.5}, "mat")

        ops = Options()
        ops.geometry = Inclusion(mat1, mat2, 0.01)
        ops.limits.add(TimeLimit(100))

        self.c._convert_geometry(ops)
        self.e.export_geometry(ops.geometry, self.tmpdir)

        # Test
        geofilepath = os.path.join(self.tmpdir, "inclusion.geo")
        repfilepath = os.path.join(self.tmpdir, "geometry.rep")
        nmat, nbody = pengeom.init(geofilepath, repfilepath)

        self.assertEqual(2, nmat)
        self.assertEqual(3, nbody)

        matfilepath = os.path.join(self.tmpdir, "mat1.mat")
        self.assertTrue(os.path.exists(matfilepath))

        matfilepath = os.path.join(self.tmpdir, "mat2.mat")
        self.assertTrue(os.path.exists(matfilepath))
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:27,代码来源:test_exporter.py

示例3: testexport_vertical_layers

# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import geometry [as 别名]
    def testexport_vertical_layers(self):
        # Create
        mat1 = PenelopeMaterial({79: 0.5, 47: 0.5}, "mat1")
        mat2 = PenelopeMaterial({29: 0.5, 30: 0.5}, "mat2")
        mat3 = PenelopeMaterial({13: 0.5, 14: 0.5}, "mat3")

        ops = Options()
        ops.beam.energy_eV = 1234
        ops.beam.diameter_m = 25e-9
        ops.beam.origin_m = (100e-9, 0, 1)

        ops.geometry = VerticalLayers(mat1, mat2)
        ops.geometry.add_layer(mat3, 5e-3)

        ops.limits.add(TimeLimit(100))

        self.c._convert_geometry(ops)
        self.e.export_geometry(ops.geometry, self.tmpdir)

        # Test
        geofilepath = os.path.join(self.tmpdir, "verticallayers.geo")
        repfilepath = os.path.join(self.tmpdir, "geometry.rep")
        nmat, nbody = pengeom.init(geofilepath, repfilepath)

        self.assertEqual(3, nmat)
        self.assertEqual(4, nbody)

        matfilepath = os.path.join(self.tmpdir, "mat1.mat")
        self.assertTrue(os.path.exists(matfilepath))

        matfilepath = os.path.join(self.tmpdir, "mat2.mat")
        self.assertTrue(os.path.exists(matfilepath))

        matfilepath = os.path.join(self.tmpdir, "mat3.mat")
        self.assertTrue(os.path.exists(matfilepath))
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:37,代码来源:test_exporter.py

示例4: _run

# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import geometry [as 别名]
    def _run(self, element):
        self._update_status(0.1, "Check version")
        if self.is_cancelled():
            return
        version = self._read_version(element)
        if version != VERSION:
            raise ValueError("Incompatible version: %s != %s" % (version, VERSION))

        self._update_status(0.13, "Reading name")
        if self.is_cancelled():
            return
        name = self._read_name(element)
        options = Options(name)

        self._update_status(0.16, "Reading UUID")
        if self.is_cancelled():
            return
        options._uuid = self._read_uuid(element)

        self._update_status(0.2, "Reading programs")
        if self.is_cancelled():
            return
        options.programs.update(self._read_programs(element))

        self._update_status(0.3, "Reading beams")
        if self.is_cancelled():
            return
        options.beam = self._read_beams(element)

        self._update_status(0.4, "Reading geometries")
        if self.is_cancelled():
            return
        options.geometry = self._read_geometries(element)

        self._update_status(0.6, "Reading detectors")
        if self.is_cancelled():
            return
        options.detectors.update(self._read_detectors(element))

        self._update_status(0.8, "Reading limits")
        if self.is_cancelled():
            return
        options.limits.update(self._read_limits(element))

        self._update_status(0.9, "Reading models")
        if self.is_cancelled():
            return
        options.models.update(self._read_models(element))

        return options
开发者ID:pymontecarlo,项目名称:pymontecarlo,代码行数:52,代码来源:options.py

示例5: test_convert_geometry_substrate

# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import geometry [as 别名]
    def test_convert_geometry_substrate(self):
        # Base options
        ops = Options(name="Test")
        mat = Material.pure(29, absorption_energy_eV={POSITRON: 63.4})
        ops.geometry = Substrate(mat)
        ops.limits.add(TimeLimit(100))

        # Convert
        self.converter._convert_geometry(ops)

        # Test
        self.assertEqual('Copper', str(ops.geometry.body.material))

        for material in ops.geometry.get_materials():
            self.assertAlmostEqual(0.1, material.elastic_scattering[0], 4)
            self.assertAlmostEqual(0.2, material.elastic_scattering[1], 4)
            self.assertAlmostEqual(51.2, material.cutoff_energy_inelastic_eV, 4)
            self.assertAlmostEqual(53.4, material.cutoff_energy_bremsstrahlung_eV, 4)
            self.assertAlmostEqual(63.4, material.absorption_energy_eV[POSITRON], 4)
            self.assertAlmostEqual(1e20, material.maximum_step_length_m, 4)
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:22,代码来源:test_converter.py

示例6: testexport_substrate

# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import geometry [as 别名]
    def testexport_substrate(self):
        # Create
        mat1 = PenelopeMaterial({79: 0.5, 47: 0.5}, "mat")

        ops = Options()
        ops.geometry = Substrate(mat1)
        ops.limits.add(TimeLimit(100))

        self.c._convert_geometry(ops)
        self.e.export_geometry(ops.geometry, self.tmpdir)

        # Test
        geofilepath = os.path.join(self.tmpdir, "substrate.geo")
        repfilepath = os.path.join(self.tmpdir, "geometry.rep")
        nmat, nbody = pengeom.init(geofilepath, repfilepath)

        self.assertEqual(1, nmat)
        self.assertEqual(2, nbody)

        matfilepath = os.path.join(self.tmpdir, "mat1.mat")
        self.assertTrue(os.path.exists(matfilepath))
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:23,代码来源:test_exporter.py


注:本文中的pymontecarlo.options.options.Options.geometry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。