本文整理汇总了Python中pymontecarlo.options.options.Options.beam方法的典型用法代码示例。如果您正苦于以下问题:Python Options.beam方法的具体用法?Python Options.beam怎么用?Python Options.beam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymontecarlo.options.options.Options
的用法示例。
在下文中一共展示了Options.beam方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testconvert1
# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import beam [as 别名]
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))
示例2: testconvert2
# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import beam [as 别名]
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))
示例3: _run
# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import beam [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
示例4: setUp
# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import beam [as 别名]
def setUp(self):
TestCase.setUp(self)
self.outputdir = tempfile.mkdtemp()
self.workdir = tempfile.mkdtemp()
ops = Options('test')
ops.beam = PencilBeam(5e3)
ops.geometry.body.material = \
Material({6: 0.4, 13: 0.6}, absorption_energy_eV={ELECTRON: 234.0})
ops.detectors['xray'] = \
PhotonIntensityDetector.annular(d2r(40.0), d2r(5.0))
ops.limits.add(ShowersLimit(1))
self.ops = Converter().convert(ops)[0]
self.worker = Worker(program)
示例5: testconvert_pencilbeam
# 需要导入模块: from pymontecarlo.options.options import Options [as 别名]
# 或者: from pymontecarlo.options.options.Options import beam [as 别名]
def testconvert_pencilbeam(self):
# Base options
ops = Options(name="Test")
ops.beam = PencilBeam(1234)
ops.detectors['det1'] = TimeDetector()
ops.limits.add(TimeLimit(100))
# Convert
with warnings.catch_warnings(record=True) as ws:
opss = self.converter.convert(ops)
# 7 warning:
# PencilBeam -> GaussianBeam
# Set default models (6)
self.assertEqual(1, len(opss))
self.assertEqual(7, len(ws))
# Test
self.assertAlmostEqual(1234, opss[0].beam.energy_eV, 4)
self.assertAlmostEqual(0.0, opss[0].beam.diameter_m, 4)
self.assertEqual(6, len(opss[0].models))