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


Python options.Options类代码示例

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


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

示例1: testexport_multilayers1

    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,代码行数:60,代码来源:test_exporter.py

示例2: test_detector_photon_intensity

    def test_detector_photon_intensity(self):
        # Create
        ops = Options(name="test1")
        ops.beam.energy_eV = 20e3
        ops.detectors["xray1"] = PhotonIntensityDetector((radians(35), radians(45)), (0, radians(360.0)))
        ops.detectors["xray2"] = PhotonIntensityDetector((radians(-45), radians(-35)), (0, radians(360.0)))

        # Import
        resultscontainer = self.i.import_(ops, self.testdata)

        # Test
        #        self.assertEqual(2, len(resultscontainer))

        result = resultscontainer["xray2"]

        val, unc = result.intensity("W Ma1")
        self.assertAlmostEqual(6.07152e-05, val, 9)
        self.assertAlmostEqual(2.23e-06, unc, 9)

        val, unc = result.intensity("W Ma1", fluorescence=False)
        self.assertAlmostEqual(5.437632e-05, val, 9)
        self.assertAlmostEqual(2.12e-06, unc, 9)

        val, unc = result.intensity("W Ma1", absorption=False)
        self.assertAlmostEqual(5.521557e-4, val, 9)
        self.assertAlmostEqual(4.79e-06, unc, 9)

        val, unc = result.intensity("W Ma1", absorption=False, fluorescence=False)
        self.assertAlmostEqual(4.883132e-4, val, 9)
        self.assertAlmostEqual(4.45e-06, unc, 9)
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:30,代码来源:test_importer.py

示例3: testconvert1

    def testconvert1(self):
        # Base options
        ops = Options(name="Test")
        ops.beam = PencilBeam(1234)
        ops.detectors['xrays'] = PhotonIntensityDetector((0.1, 0.2), (0.3, 0.4))
        ops.limits.add(ShowersLimit(5678))

        # Convert
        with warnings.catch_warnings(record=True) as ws:
            opss = self.converter.convert(ops)

        # 6 warnings for the default models
        self.assertEqual(5, len(ws))
        self.assertEqual(1, len(opss))

        # Test
        self.assertAlmostEqual(1234, opss[0].beam.energy_eV, 4)

        self.assertEqual(1, len(opss[0].detectors))

        self.assertEqual(1, len(opss[0].limits))
        limit = list(ops.limits.iterclass(ShowersLimit))[0]
        self.assertEqual(5678, limit.showers)

        self.assertEqual(5, len(opss[0].models))
开发者ID:pymontecarlo,项目名称:pymontecarlo-monaco,代码行数:25,代码来源:test_converter.py

示例4: setUp

    def setUp(self):
        TestCase.setUp(self)

        # Results 1
        self.ops1 = Options(name='test1')
        self.ops1.detectors['det1'] = PhotonIntensityDetector((0, 1), (0, 1))
        self.ops1.detectors['det2'] = TimeDetector()
        self.ops1.detectors['det3'] = ElectronFractionDetector()

        results1 = {}
        results1['det1'] = PhotonIntensityResult()
        results1['det2'] = TimeResult()
        results1['det3'] = ElectronFractionResult()

        # Results 2
        ops2 = Options(name='test2')
        ops2.detectors['det1'] = PhotonIntensityDetector((0, 1), (0, 1))

        results2 = {}
        results2['det1'] = PhotonIntensityResult()

        # Base options
        self.ops = Options(name='base')

        # Sequence
        list_results = [(self.ops1, results1), (ops2, results2)]
        self.results = Results(self.ops, list_results)
开发者ID:pymontecarlo,项目名称:pymontecarlo,代码行数:27,代码来源:test_results.py

示例5: testconvert2

    def testconvert2(self):
        # Base options
        ops = Options(name="Test")
        ops.beam = PencilBeam(1234)
        ops.detectors['bse'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
        ops.detectors['photon'] = \
            PhotonSpectrumDetector((radians(35), radians(45)), (0, radians(360.0)),
                                   1000, (12.34, 56.78))
        ops.limits.add(ShowersLimit(5678))
        ops.limits.add(TimeLimit(60))

        # Convert
        opss = self.converter.convert(ops)

        # Test
        self.assertEqual(1, len(opss))

        self.assertAlmostEqual(1234, opss[0].beam.energy_eV, 4)

        self.assertEqual(1, len(opss[0].detectors))
        det = ops.detectors['bse']
        self.assertAlmostEqual(0, det.limits_eV[0], 4)
        self.assertAlmostEqual(1234, det.limits_eV[1], 4)
        self.assertEqual(1000, det.channels)

        self.assertEqual(1, len(opss[0].limits))
        limit = list(ops.limits.iterclass(ShowersLimit))[0]
        self.assertEqual(5678, limit.showers)

        self.assertEqual(7, len(opss[0].models))
开发者ID:pymontecarlo,项目名称:pymontecarlo-casino2,代码行数:30,代码来源:test_converter.py

示例6: testexport_vertical_layers

    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,代码行数:35,代码来源:test_exporter.py

示例7: testconvert4

    def testconvert4(self):
        # Base options
        ops = Options(name="Test")
        ops.beam.energy = 100e3
        ops.detectors['prz'] = PhiZDetector((0, 1), (2, 3), 1000)
        ops.detectors['xray'] = PhotonIntensityDetector((0, 1), (2, 3))
        ops.limits.add(ShowersLimit(5678))

        # Convert
        opss = self.converter.convert(ops)

        # Test
        self.assertEqual(1, len(opss))

        self.assertEqual(2, len(opss[0].detectors))
        self.assertEqual(7, len(opss[0].models))

        # Test difference in elevation
        ops.detectors['xray'] = PhotonIntensityDetector((0.5, 1), (2, 3))

        opss = self.converter.convert(ops)

        self.assertEqual(2, len(opss))

        # Test difference in azimuth
        ops.detectors['xray'] = PhotonIntensityDetector((0, 1), (2.5, 3))

        opss = self.converter.convert(ops)

        self.assertEqual(2, len(opss))
开发者ID:pymontecarlo,项目名称:pymontecarlo-casino2,代码行数:30,代码来源:test_converter.py

示例8: testconvert1

    def testconvert1(self):
        # Base options
        ops = Options(name="Test")
        ops.beam.energy_eV = 1234
        ops.detectors['bse'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
        ops.limits.add(ShowersLimit(5678))
        ops.models.add(IONIZATION_CROSS_SECTION.jakoby)

        # Convert
        opss = self.converter.convert(ops)

        # Test
        self.assertEqual(1, len(opss))

        self.assertAlmostEqual(1234, opss[0].beam.energy_eV, 4)

        self.assertEqual(1, len(opss[0].detectors))
        det = ops.detectors['bse']
        self.assertAlmostEqual(0, det.limits_eV[0], 4)
        self.assertAlmostEqual(1234, det.limits_eV[1], 4)
        self.assertEqual(1000, det.channels)

        self.assertEqual(1, len(opss[0].limits))
        limit = list(ops.limits.iterclass(ShowersLimit))[0]
        self.assertEqual(5678, limit.showers)

        self.assertEqual(7, len(opss[0].models))
        model = list(ops.models.iterclass(IONIZATION_CROSS_SECTION))[0]
        self.assertEqual(IONIZATION_CROSS_SECTION.jakoby, model)
开发者ID:pymontecarlo,项目名称:pymontecarlo-casino2,代码行数:29,代码来源:test_converter.py

示例9: test_detector_photon_spectrum

    def test_detector_photon_spectrum(self):
        # Create
        ops = Options(name="test1")
        ops.beam.energy_eV = 20e3
        ops.detectors["spectrum"] = PhotonSpectrumDetector(
            (radians(35), radians(45)), (0, radians(360.0)), 1000, (0, 20e3)
        )

        # Import
        resultscontainer = self.i.import_(ops, self.testdata)

        # Test
        self.assertEqual(1, len(resultscontainer))

        result = resultscontainer["spectrum"]

        total = result.get_total()
        self.assertEqual(1000, len(total))
        self.assertAlmostEqual(10.0, total[0, 0], 4)
        self.assertAlmostEqual(19990.0, total[-1, 0], 4)
        self.assertAlmostEqual(2.841637e-6, total[31, 1], 10)
        self.assertAlmostEqual(8.402574e-6, total[31, 2], 10)

        background = result.get_background()
        self.assertEqual(1000, len(background))
        self.assertAlmostEqual(10.0, background[0, 0], 4)
        self.assertAlmostEqual(19990.0, background[-1, 0], 4)
        self.assertAlmostEqual(0.0, background[31, 1], 10)
        self.assertAlmostEqual(0.0, background[31, 2], 10)
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:29,代码来源:test_importer.py

示例10: test_detector_photon_depth

    def test_detector_photon_depth(self):
        # Create
        ops = Options(name="test1")
        ops.beam.energy_eV = 20e3
        ops.detectors["prz"] = PhotonDepthDetector((radians(35), radians(45)), (0, radians(360.0)), 100)

        # Import
        resultscontainer = self.i.import_(ops, self.testdata)

        # Test
        self.assertEqual(1, len(resultscontainer))

        result = resultscontainer["prz"]

        self.assertTrue(result.exists("Cu La1", absorption=True))
        self.assertTrue(result.exists("Cu La1", absorption=False))
        self.assertFalse(result.exists("Cu Ka1", absorption=True))

        dist = result.get("Cu La1", absorption=False)
        self.assertAlmostEqual(-5.750000e-7, dist[2, 0], 4)
        self.assertAlmostEqual(4.737908e-6, dist[2, 1], 4)
        self.assertAlmostEqual(1.005021e-5, dist[2, 2], 4)

        dist = result.get("Cu La1", absorption=True)
        self.assertAlmostEqual(-5.150000e-7, dist[8, 0], 4)
        self.assertAlmostEqual(4.228566e-5, dist[8, 1], 4)
        self.assertAlmostEqual(1.268544e-4, dist[8, 2], 4)
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:27,代码来源:test_importer.py

示例11: testexport_inclusion

    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,代码行数:25,代码来源:test_exporter.py

示例12: testexport

    def testexport(self):
        # Create
        ops = Options(name="test1")
        ops.beam.energy_eV = 30e3
        ops.detectors["trajectories"] = TrajectoryDetector(False)
        ops.limits.add(ShowersLimit(100))

        # Export
        opss = self.c.convert(ops)
        self.e.export(opss[0], self.tmpdir)
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:10,代码来源:test_exporter.py

示例13: test_append_photon_detectors_maxchannels

    def test_append_photon_detectors_maxchannels(self):
        ops = Options()
        ops.limits.add(TimeLimit(100))
        ops.detectors['spectrum'] = \
            PhotonSpectrumDetector((radians(35), radians(45)), (0, radians(360.0)),
                                   50000, (0, 1000))

        opss = self.c.convert(ops)

        self.e.export(opss[0], self.tmpdir)
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:10,代码来源:test_exporter.py

示例14: test_append_photon_detectors_maxlimit

    def test_append_photon_detectors_maxlimit(self):
        ops = Options()
        ops.limits.add(TimeLimit(100))

        for i in range(MAX_PHOTON_DETECTORS + 1):
            ops.detectors['det%i' % i] = \
                PhotonSpectrumDetector((radians(i), radians(45)), (0, radians(360.0)),
                                       500, (0, 1000))

        opss = self.c.convert(ops)
        self.assertRaises(ExporterException, self.e.export, opss[0], self.tmpdir)
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:11,代码来源:test_exporter.py

示例15: testconvert_nolimit

    def testconvert_nolimit(self):
        # Base options
        ops = Options(name="Test")
        ops.detectors['trajectories'] = TrajectoryDetector(100)
        ops.limits.add(TimeLimit(1))

        # Convert
        opss = self.converter.convert(ops)

        # Test
        self.assertEqual(0, len(opss))
开发者ID:pymontecarlo,项目名称:pymontecarlo-penelope,代码行数:11,代码来源:test_converter.py


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