Beispiel #1
0
    def setUp(self):
        TestCase.setUp(self)

        self.outputdir = tempfile.mkdtemp()
        self.workdir = tempfile.mkdtemp()

        ops = Options('test')
        ops.geometry.body.material = Material.pure(79)
        ops.detectors['time'] = TimeDetector()
        ops.limits.add(ShowersLimit(1))
        self.ops = Converter().convert(ops)[0]

        self.worker = Worker(program)
Beispiel #2
0
    def setUp(self):
        TestCase.setUp(self)

        self.converter = Converter()
Beispiel #3
0
class TestConverter(TestCase):
    def setUp(self):
        TestCase.setUp(self)

        self.converter = Converter()

    def tearDown(self):
        TestCase.tearDown(self)

    def testskeleton(self):
        self.assertTrue(True)

#    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(RANDOM_NUMBER_GENERATOR.press1966_rand1)
#
#        # 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 = opss[0].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(opss[0].limits.iterclass(ShowersLimit))[0]
#        self.assertEqual(5678, limit.showers)
#
#        self.assertEqual(7, len(opss[0].models))
#        model = list(opss[0].models.iterclass(RANDOM_NUMBER_GENERATOR))[0]
#        self.assertEqual(RANDOM_NUMBER_GENERATOR.press1966_rand1, model)

#    def testconvert2(self):
#        # Base options
#        ops = Options(name="Test")
#        ops.beam = PencilBeam(1234)
#        ops.detectors['bse'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
#        ops.detectors['photon'] = TransmittedElectronEnergyDetector(1000, (0, 1234))
#        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 = opss[0].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(opss[0].limits.iterclass(ShowersLimit))[0]
#        self.assertEqual(5678, limit.showers)
#
#        self.assertEqual(7, len(opss[0].models))

#    def testconvert3(self):
#        # Base options
#        ops = Options(name="Test")
#        ops.beam.energy_eV = 100e3
#        ops.detectors['bse'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
#        ops.detectors['bse2'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
#        ops.limits.add(ShowersLimit(5678))
#
#        # Convert
#        opss = self.converter.convert(ops)
#
#        # Test
#        self.assertEqual(2, len(opss))

    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))

        # Test difference in elevation (PhotonSpectrumDetector)
        ops.detectors['xray'] = PhotonSpectrumDetector((0.5, 1), (2, 3), 1000,
                                                       (0, 1234))
        opss = self.converter.convert(ops)
        self.assertEqual(2, len(opss))
#

    def testconvert6(self):
        NEW_MODEL_TYPE = ModelType('new')
        NEW_MODEL_TYPE.test = ('test', )

        # Base options
        ops = Options(name="Test")
        ops.beam.energy_eV = 100e3
        ops.detectors['prz'] = PhiZDetector((0, 1), (2, 3), 1000)
        ops.models.add(NEW_MODEL_TYPE.test)
        ops.limits.add(ShowersLimit(5678))

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

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


#

    def testconvert7(self):
        # Base options
        ops = Options(name="Test")
        ops.beam.energy_eV = 100e3
        ops.detectors['prz'] = PhiZDetector((0, 1), (2, 3), 1000)

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

        # No shower limit
        self.assertEqual(0, len(opss))
    def setUp(self):
        TestCase.setUp(self)

        self.converter = Converter()
class TestConverter(TestCase):

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

        self.converter = Converter()

    def tearDown(self):
        TestCase.tearDown(self)

    def testskeleton(self):
        self.assertTrue(True)

#    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(RANDOM_NUMBER_GENERATOR.press1966_rand1)
#
#        # 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 = opss[0].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(opss[0].limits.iterclass(ShowersLimit))[0]
#        self.assertEqual(5678, limit.showers)
#
#        self.assertEqual(7, len(opss[0].models))
#        model = list(opss[0].models.iterclass(RANDOM_NUMBER_GENERATOR))[0]
#        self.assertEqual(RANDOM_NUMBER_GENERATOR.press1966_rand1, model)

#    def testconvert2(self):
#        # Base options
#        ops = Options(name="Test")
#        ops.beam = PencilBeam(1234)
#        ops.detectors['bse'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
#        ops.detectors['photon'] = TransmittedElectronEnergyDetector(1000, (0, 1234))
#        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 = opss[0].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(opss[0].limits.iterclass(ShowersLimit))[0]
#        self.assertEqual(5678, limit.showers)
#
#        self.assertEqual(7, len(opss[0].models))

#    def testconvert3(self):
#        # Base options
#        ops = Options(name="Test")
#        ops.beam.energy_eV = 100e3
#        ops.detectors['bse'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
#        ops.detectors['bse2'] = BackscatteredElectronEnergyDetector(1000, (0, 1234))
#        ops.limits.add(ShowersLimit(5678))
#
#        # Convert
#        opss = self.converter.convert(ops)
#
#        # Test
#        self.assertEqual(2, len(opss))

    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))

        # Test difference in elevation (PhotonSpectrumDetector)
        ops.detectors['xray'] = PhotonSpectrumDetector((0.5, 1), (2, 3), 1000, (0, 1234))
        opss = self.converter.convert(ops)
        self.assertEqual(2, len(opss))
#
    def testconvert6(self):
        NEW_MODEL_TYPE = ModelType('new')
        NEW_MODEL_TYPE.test = ('test',)

        # Base options
        ops = Options(name="Test")
        ops.beam.energy_eV = 100e3
        ops.detectors['prz'] = PhiZDetector((0, 1), (2, 3), 1000)
        ops.models.add(NEW_MODEL_TYPE.test)
        ops.limits.add(ShowersLimit(5678))

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

        # Test
        self.assertEqual(1, len(opss))
#
    def testconvert7(self):
        # Base options
        ops = Options(name="Test")
        ops.beam.energy_eV = 100e3
        ops.detectors['prz'] = PhiZDetector((0, 1), (2, 3), 1000)

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

        # No shower limit
        self.assertEqual(0, len(opss))