Exemple #1
0
    def _readOldVersion(self, filepath):
        lines = open(filepath, 'r').readlines()

        extractMethods = self._createExtractMethods()

        indexLine = 0
        while indexLine < len(lines):
            line = lines[indexLine]
            line = line.strip()

            indexLine += 1
            if not line.startswith("***") and len(line) != 0:
                self.numberRegions = extractMethods[KEY_NUMBER_REGIONS](line)

                for _indexRegion in range(self.numberRegions):
                    # Skip blank line.
                    indexLine += 1
                    region = Region.Region()
                    self.regions.append(region)
                    indexLine += region.extractFromLinesWithoutVersion(
                        lines[indexLine:])
Exemple #2
0
    def _readWithVersion(self, filepath):
        lines = open(filepath, 'r').readlines()

        indexLine = 0
        for line in lines:
            indexLine += 1

            line = line.strip()

            key = KEY_NUMBER_REGIONS
            if line.startswith(key):
                items = line.split('=')
                self.numberRegions = int(items[-1])
                break

        for _indexRegion in range(self.numberRegions):
            while lines[indexLine].strip() == "":
                indexLine += 1

            region = Region.Region()
            self.regions.append(region)
            indexLine += region.extractFromLinesWithVersion(lines[indexLine:])
Exemple #3
0
    def test_extractFromLinesWithoutVersion(self):
        """
        Tests for method `read`.
        """
        regionTypes = [
            RegionType.REGION_TYPE_BOX, RegionType.REGION_TYPE_CYLINDER,
            RegionType.REGION_TYPE_SPHERE
        ]

        for userMassDensity in [True, False]:
            logging.info("userMassDensity: %s", userMassDensity)
            for regionType in regionTypes:
                logging.info("regionType: %s", regionType)
                region = Region.Region()

                lines, regionRef = self.getTestRegionLinesWithoutVersion(
                    regionType, userMassDensity)
                region.extractFromLinesWithoutVersion(lines)

                self.assertEquals(regionRef.numberElements,
                                  region.numberElements)

                elementsRef = regionRef.elements
                elements = region.elements

                for elementRef, element in zip(elementsRef, elements):
                    self.assertEquals(elementRef.atomicNumber,
                                      element.atomicNumber)
                    self.assertEquals(elementRef.massFraction,
                                      element.massFraction)

                self.assertEquals(regionRef.regionMassDensity_g_cm3,
                                  region.regionMassDensity_g_cm3)
                self.assertEquals(regionRef.regionType, region.regionType)

                self.assertDictEqual(regionRef.regionDimensions._parameters,
                                     region.regionDimensions._parameters)
Exemple #4
0
    def getSpecimenReference(self, title):
        specimen = Specimen.Specimen()

        if title == "AuBC cyl":
            specimen.numberRegions = 4
            specimen.version = Version.Version(1, 1, 1)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(6)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-10000000000.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0, 20000000000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(79)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [0.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0, 20000000000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(5)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [-500.0, -500.0, 300.0, 0.0, 1.0, 0.35, 1000.0, 300.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(5)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [500.0, 500.0, 300.0, 0.0, -1.0, 0.35, 1000.0, 300.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

        elif title == "BioRitchieNew111017":
            specimen.numberRegions = 7
            specimen.version = Version.Version(1, 1, 1)

            region = Region.Region()
            region.numberElements = 3
            element = Element.Element(6, 0.7)
            region.elements.append(element)
            element = Element.Element(8, 0.28)
            region.elements.append(element)
            element = Element.Element(17, 0.02)
            region.elements.append(element)
            region.regionMassDensity_g_cm3 = 1.14
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-10000000000.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0, 20000000000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 2
            element = Element.Element(8, 0.53)
            region.elements.append(element)
            element = Element.Element(14, 0.47)
            region.elements.append(element)
            region.regionMassDensity_g_cm3 = 2.2
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [-20000.0, 0.0, 30000.0, 1.0, 0.0, 0.0, 40000.0, 30000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 3
            element = Element.Element(6, 0.7)
            region.elements.append(element)
            element = Element.Element(8, 0.28)
            region.elements.append(element)
            element = Element.Element(17, 0.02)
            region.elements.append(element)
            region.regionMassDensity_g_cm3 = 1.14
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [-20000.0, 0.0, 30000.0, 1.0, 0.0, 0.0, 40000.0, 29500.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 7
            region.elements.append(Element.Element(1, 0.071))
            region.elements.append(Element.Element(6, 0.414))
            region.elements.append(Element.Element(7, 0.168))
            region.elements.append(Element.Element(8, 0.285))
            region.elements.append(Element.Element(15, 0.036))
            region.elements.append(Element.Element(16, 0.006))
            region.elements.append(Element.Element(76, 0.02))
            region.regionMassDensity_g_cm3 = 1.32
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [12000.0, 10000.0, 10000.0, 8000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 9
            region.elements.append(Element.Element(1, 0.11))
            region.elements.append(Element.Element(6, 0.49))
            region.elements.append(Element.Element(7, 0.12))
            region.elements.append(Element.Element(8, 0.25))
            region.elements.append(Element.Element(12, 0.003))
            region.elements.append(Element.Element(15, 0.003))
            region.elements.append(Element.Element(16, 0.003))
            region.elements.append(Element.Element(25, 0.001))
            region.elements.append(Element.Element(76, 0.02))
            region.regionMassDensity_g_cm3 = 1.24
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [-10000.0, 0.0, 20000.0, 15000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 9
            region.elements.append(Element.Element(1, 0.11))
            region.elements.append(Element.Element(6, 0.49))
            region.elements.append(Element.Element(7, 0.12))
            region.elements.append(Element.Element(8, 0.25))
            region.elements.append(Element.Element(12, 0.003))
            region.elements.append(Element.Element(15, 0.003))
            region.elements.append(Element.Element(16, 0.003))
            region.elements.append(Element.Element(25, 0.001))
            region.elements.append(Element.Element(76, 0.02))
            region.regionMassDensity_g_cm3 = 1.24
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [10000.0, -5000.0, 25000.0, 6000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 7
            region.elements.append(Element.Element(1, 0.077))
            region.elements.append(Element.Element(6, 0.497))
            region.elements.append(Element.Element(7, 0.11))
            region.elements.append(Element.Element(8, 0.259))
            region.elements.append(Element.Element(15, 0.031))
            region.elements.append(Element.Element(16, 0.006))
            region.elements.append(Element.Element(76, 0.02))
            region.regionMassDensity_g_cm3 = 1.18
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [-23000.0, 4000.0, 33500.0, 2000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

            specimen._shortHeader = True

        elif title == "Bug Al Zr Sphere":
            specimen.numberRegions = 2
            specimen.version = Version.Version(1, 1, 1)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(13)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-10000000000.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0, 1000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(40)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [0.0, 0.0, 500.0, 499.9]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

        elif title == "Mg2SiAlCube3kev":
            specimen.numberRegions = 2
            specimen.version = Version.Version(1, 1, 1)

            region = Region.Region()
            region.numberElements = 2
            element = Element.Element(12, 0.5)
            region.elements.append(element)
            element = Element.Element(13, 0.5)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-10000000000.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0, 20000000000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(6)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = (-10.0, 10.0, -10.0, 10.0, 0.0, 20.0)
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

        elif title == "AlMgBulk5keV_version_1_1_1":
            specimen.numberRegions = 3
            specimen.version = Version.Version(1, 1, 1)

            region = Region.Region()
            region.numberElements = 2
            element = Element.Element(12, 0.5)
            region.elements.append(element)
            element = Element.Element(13, 0.5)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-10000000000.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0, 20000000000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(6)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [0.0, -5000.0, 0.0, 0.0, 1.0, -0.7, 10000.0, 100.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(79)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [0.0, 0.0, 101.0, 100.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

        elif title == "AlMgBulk5keV_version_1_2_0":
            specimen.numberRegions = 3
            specimen.version = Version.Version(1, 2, 0)

            region = Region.Region()
            region.numberElements = 2
            element = Element.Element(14, 0.4)
            region.elements.append(element)
            element = Element.Element(15, 0.6)
            region.elements.append(element)
            region.regionMassDensity_g_cm3 = 23.0
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-2000000000.0, 6000000000.0, -4000000000.0, 5000000000.0, 0.8, 70000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(7)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [0.4, -8000.0, 0.9, 0.1, 0.6, -0.8, 50000.0, 700.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(56)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [0.5, 0.6, 102.0, 101.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

        elif title == "AlMgBulk5keV_version_1_2_1":
            specimen.numberRegions = 3
            specimen.version = Version.Version(1, 2, 1)

            region = Region.Region()
            region.numberElements = 2
            element = Element.Element(14, 0.4)
            region.elements.append(element)
            element = Element.Element(15, 0.6)
            region.elements.append(element)
            region.regionMassDensity_g_cm3 = 23.0
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-2000000000.0, 6000000000.0, -4000000000.0, 5000000000.0, 0.8, 70000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(7)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [0.4, -8000.0, 0.9, 0.1, 0.6, -0.8, 50000.0, 700.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(56)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [0.5, 0.6, 102.0, 101.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

        elif title == "AlMgBulk5keV_version_1_4_1":
            specimen.numberRegions = 3
            specimen.version = Version.Version(1, 4, 1)

            region = Region.Region()
            region.numberElements = 2
            element = Element.Element(14, 0.4)
            region.elements.append(element)
            element = Element.Element(15, 0.6)
            region.elements.append(element)
            region.regionMassDensity_g_cm3 = 23.0
            region.regionType = RegionType.REGION_TYPE_BOX
            parameters = [-2000000000.0, 6000000000.0, -4000000000.0, 5000000000.0, 0.8, 70000.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsBox(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(7)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_CYLINDER
            parameters = [0.4, -8000.0, 0.9, 0.1, 0.6, -0.8, 50000.0, 700.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(parameters)
            specimen.regions.append(region)

            region = Region.Region()
            region.numberElements = 1
            element = Element.Element(56)
            region.elements.append(element)
            region.regionType = RegionType.REGION_TYPE_SPHERE
            parameters = [0.5, 0.6, 102.0, 101.0]
            region.regionDimensions = RegionDimensions.RegionDimensionsSphere(parameters)
            specimen.regions.append(region)

        return specimen
    def createSpecimen(self, parameters):
        specimen = Specimen.Specimen()

        specimen.name = "Maps01"

        specimen.numberRegions = 10

        # Region 0
        region = Region.Region()
        region.numberElements = 0
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [
            -10000000000.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0,
            20000000000.0
        ]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 1
        region = Region.Region()
        region.numberElements = 2
        region.elements = [
            Element.Element(27, massFraction=0.01),
            Element.Element(26, massFraction=0.99)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [-7.5e4, -2.5e4, -7.5e4, -2.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 2
        region = Region.Region()
        region.numberElements = 2
        region.elements = [
            Element.Element(27, massFraction=0.02),
            Element.Element(26, massFraction=0.98)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [-2.5e4, 2.5e4, -7.5e4, -2.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 3
        region = Region.Region()
        region.numberElements = 2
        region.elements = [
            Element.Element(27, massFraction=0.05),
            Element.Element(26, massFraction=0.95)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [2.5e4, 7.5e4, -7.5e4, -2.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 4
        region = Region.Region()
        region.numberElements = 2
        region.elements = [
            Element.Element(28, massFraction=0.01),
            Element.Element(27, massFraction=0.99)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [-7.5e4, -2.5e4, -2.5e4, 2.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 5
        region = Region.Region()
        region.numberElements = 2
        region.elements = [
            Element.Element(28, massFraction=0.02),
            Element.Element(27, massFraction=0.98)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [-2.5e4, 2.5e4, -2.5e4, 2.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 6
        region = Region.Region()
        region.numberElements = 2
        region.elements = [
            Element.Element(28, massFraction=0.05),
            Element.Element(27, massFraction=0.95)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [2.5e4, 7.5e4, -2.5e4, 2.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 7
        region = Region.Region()
        region.numberElements = 3
        region.elements = [
            Element.Element(27, massFraction=0.01),
            Element.Element(26, massFraction=0.495),
            Element.Element(28, massFraction=0.495)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [-7.5e4, -2.5e4, 2.5e4, 7.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 8
        region = Region.Region()
        region.numberElements = 3
        region.elements = [
            Element.Element(27, massFraction=0.02),
            Element.Element(26, massFraction=0.49),
            Element.Element(28, massFraction=0.49)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [-2.5e4, 2.5e4, 2.5e4, 7.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        # Region 9
        region = Region.Region()
        region.numberElements = 3
        region.elements = [
            Element.Element(27, massFraction=0.05),
            Element.Element(26, massFraction=0.475),
            Element.Element(28, massFraction=0.475)
        ]
        region.regionType = RegionType.REGION_TYPE_BOX
        parameters = [2.5e4, 7.5e4, 2.5e4, 7.5e4, 0.0, 0.2e4]
        region.regionDimensions = RegionDimensions.RegionDimensionsBox(
            parameters)
        specimen.regions.append(region)

        return specimen
Exemple #6
0
    def getTestRegionLinesWithVersion(self, title, userMassDensity=True):
        region = Region.Region()

        if not userMassDensity:
            if title == RegionType.REGION_TYPE_BOX:
                lines = \
"""NumberElements=2
AtomicNumber=14
WeightFraction=0.400000000000000
AtomicNumber=15
WeightFraction=0.600000000000000
UserDefinedMassDensity=0
RegionType=BOX
RegionParameters=-2000000000.000000 6000000000.000000 -4000000000.000000 5000000000.000000 0.800000 70000.000000
""".splitlines()
                region.numberElements = 2
                element = Element.Element(14, 0.4)
                region.elements.append(element)
                element = Element.Element(15, 0.6)
                region.elements.append(element)
                region.regionType = RegionType.REGION_TYPE_BOX
                parameters = [
                    -2000000000.0, 6000000000.0, -4000000000.0, 5000000000.0,
                    0.8, 70000.0
                ]
                region.regionDimensions = RegionDimensions.RegionDimensionsBox(
                    parameters)
                return lines, region

            if title == RegionType.REGION_TYPE_CYLINDER:
                lines = \
"""NumberElements=1
AtomicNumber=7
WeightFraction=1.000000000000000
UserDefinedMassDensity=0
RegionType=CYLINDER
RegionParameters=0.400000 -8000.000000 0.900000 0.100000 0.600000 -0.800000 50000.000000 700.000000
""".splitlines()
                region.numberElements = 1
                element = Element.Element(7)
                region.elements.append(element)
                region.regionType = RegionType.REGION_TYPE_CYLINDER
                parameters = [
                    0.4, -8000.0, 0.9, 0.1, 0.6, -0.8, 50000.0, 700.0
                ]
                region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(
                    parameters)
                return lines, region

            if title == RegionType.REGION_TYPE_SPHERE:
                lines = \
"""NumberElements=1
AtomicNumber=56
WeightFraction=1.000000000000000
UserDefinedMassDensity=0
RegionType=SPHERE
RegionParameters=0.500000 0.600000 102.000000 101.000000
""".splitlines()
                region.numberElements = 1
                element = Element.Element(56)
                region.elements.append(element)
                region.regionType = RegionType.REGION_TYPE_SPHERE
                parameters = [0.5, 0.6, 102.0, 101.0]
                region.regionDimensions = RegionDimensions.RegionDimensionsSphere(
                    parameters)
                return lines, region

        if userMassDensity:
            if title == RegionType.REGION_TYPE_BOX:
                lines = \
"""NumberElements=2
AtomicNumber=14
WeightFraction=0.400000000000000
AtomicNumber=15
WeightFraction=0.600000000000000
UserDefinedMassDensity=23
RegionType=BOX
RegionParameters=-2000000000.000000 6000000000.000000 -4000000000.000000 5000000000.000000 0.800000 70000.000000
""".splitlines()
                region.numberElements = 2
                element = Element.Element(14, 0.4)
                region.elements.append(element)
                element = Element.Element(15, 0.6)
                region.elements.append(element)
                region.regionMassDensity_g_cm3 = 23.0
                region.regionType = RegionType.REGION_TYPE_BOX
                parameters = [
                    -2000000000.0, 6000000000.0, -4000000000.0, 5000000000.0,
                    0.8, 70000.0
                ]
                region.regionDimensions = RegionDimensions.RegionDimensionsBox(
                    parameters)
                return lines, region

            if title == RegionType.REGION_TYPE_CYLINDER:
                lines = \
"""NumberElements=1
AtomicNumber=7
WeightFraction=1.000000000000000
UserDefinedMassDensity=2.22
RegionType=CYLINDER
RegionParameters=0.400000 -8000.000000 0.900000 0.100000 0.600000 -0.800000 50000.000000 700.000000
""".splitlines()
                region.numberElements = 1
                element = Element.Element(7)
                region.elements.append(element)
                region.regionMassDensity_g_cm3 = 2.22
                region.regionType = RegionType.REGION_TYPE_CYLINDER
                parameters = [
                    0.4, -8000.0, 0.9, 0.1, 0.6, -0.8, 50000.0, 700.0
                ]
                region.regionDimensions = RegionDimensions.RegionDimensionsCylinder(
                    parameters)
                return lines, region

            if title == RegionType.REGION_TYPE_SPHERE:
                lines = \
"""NumberElements=1
AtomicNumber=56
WeightFraction=1.000000000000000
UserDefinedMassDensity=67.8
RegionType=SPHERE
RegionParameters=0.500000 0.600000 102.000000 101.000000
""".splitlines()
                region.numberElements = 1
                element = Element.Element(56)
                region.elements.append(element)
                region.regionMassDensity_g_cm3 = 67.8
                region.regionType = RegionType.REGION_TYPE_SPHERE
                parameters = [0.5, 0.6, 102.0, 101.0]
                region.regionDimensions = RegionDimensions.RegionDimensionsSphere(
                    parameters)
                return lines, region
Exemple #7
0
    def getTestRegionLinesWithoutVersion(self, title, userMassDensity=True):
        region = Region.Region()

        if not userMassDensity:
            if title == RegionType.REGION_TYPE_BOX:
                lines = \
"""1
79 1.000000000000000
BOX
0.000000 10000000000.000000 -10000000000.000000 10000000000.000000 0.000000 20000000000.000000
""".splitlines()
                region.numberElements = 1
                element = Element.Element()
                element.atomicNumber = 79
                element.massFraction = 1.0
                region.elements.append(element)
                #region.regionMassDensity_g_cm3
                region.regionType = RegionType.REGION_TYPE_BOX
                regionDimensions = RegionDimensions.createRegionDimensions(
                    region.regionType)
                regionDimensions.minimumX = 0.0
                regionDimensions.maximumX = 10000000000.0
                regionDimensions.minimumY = -10000000000.0
                regionDimensions.maximumY = 10000000000.0
                regionDimensions.minimumZ = 0.0
                regionDimensions.maximumZ = 20000000000.0
                region.regionDimensions = regionDimensions
                return lines, region

            if title == RegionType.REGION_TYPE_CYLINDER:
                lines = \
"""1
5 1.000000000000000
CYLINDER
-500.000000 -500.000000 300.000000 0.000000 1.000000 0.350000 1000.000000 300.000000
""".splitlines()
                region.numberElements = 1
                element = Element.Element()
                element.atomicNumber = 5
                element.massFraction = 1.0
                region.elements.append(element)
                #region.regionMassDensity_g_cm3
                region.regionType = RegionType.REGION_TYPE_CYLINDER
                regionDimensions = RegionDimensions.createRegionDimensions(
                    region.regionType)
                regionDimensions.positionX = -500.0
                regionDimensions.positionY = -500.0
                regionDimensions.positionZ = 300.0
                regionDimensions.directionX = 0.0
                regionDimensions.directionY = 1.0
                regionDimensions.directionZ = 0.35
                regionDimensions.length = 1000.0
                regionDimensions.radius = 300.0
                region.regionDimensions = regionDimensions
                return lines, region

            if title == RegionType.REGION_TYPE_SPHERE:
                lines = \
"""1
5 1.000000000000000
SPHERE
500.000000 500.000000 300.000000 300.000000
""".splitlines()
                region.numberElements = 1
                element = Element.Element()
                element.atomicNumber = 5
                element.massFraction = 1.0
                region.elements.append(element)
                #region.regionMassDensity_g_cm3
                region.regionType = RegionType.REGION_TYPE_SPHERE
                regionDimensions = RegionDimensions.createRegionDimensions(
                    region.regionType)
                regionDimensions.positionX = 500.0
                regionDimensions.positionY = 500.0
                regionDimensions.positionZ = 300.0
                regionDimensions.radius = 300.0
                region.regionDimensions = regionDimensions
                return lines, region

        if userMassDensity:
            if title == RegionType.REGION_TYPE_BOX:
                lines = \
"""3
6 0.700000000000000
8 0.280000000000000
17 0.020000000000000
1.140000000000000
BOX
-10000000000.000000 10000000000.000000 -10000000000.000000 10000000000.000000 0.000000 20000000000.000000
""".splitlines()
                region.numberElements = 3
                element = Element.Element()
                element.atomicNumber = 6
                element.massFraction = 0.7
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 8
                element.massFraction = 0.28
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 17
                element.massFraction = 0.02
                region.elements.append(element)
                region.regionMassDensity_g_cm3 = 1.14
                region.regionType = RegionType.REGION_TYPE_BOX
                regionDimensions = RegionDimensions.createRegionDimensions(
                    region.regionType)
                regionDimensions.minimumX = -10000000000.0
                regionDimensions.maximumX = 10000000000.0
                regionDimensions.minimumY = -10000000000.0
                regionDimensions.maximumY = 10000000000.0
                regionDimensions.minimumZ = 0.0
                regionDimensions.maximumZ = 20000000000.0
                region.regionDimensions = regionDimensions
                return lines, region

            if title == RegionType.REGION_TYPE_CYLINDER:
                lines = \
"""2
8 0.530000000000000
14 0.470000000000000
2.200000000000000
CYLINDER
-20000.000000 0.000000 30000.000000 1.000000 0.000000 0.000000 40000.000000 30000.000000
""".splitlines()
                region.numberElements = 2
                element = Element.Element()
                element.atomicNumber = 8
                element.massFraction = 0.53
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 14
                element.massFraction = 0.47
                region.elements.append(element)
                region.regionMassDensity_g_cm3 = 2.2
                region.regionType = RegionType.REGION_TYPE_CYLINDER
                regionDimensions = RegionDimensions.createRegionDimensions(
                    region.regionType)
                regionDimensions.positionX = -20000.0
                regionDimensions.positionY = 0.0
                regionDimensions.positionZ = 30000.0
                regionDimensions.directionX = 1.0
                regionDimensions.directionY = 0.0
                regionDimensions.directionZ = 0.0
                regionDimensions.length = 40000.0
                regionDimensions.radius = 30000.0
                region.regionDimensions = regionDimensions
                return lines, region

            if title == RegionType.REGION_TYPE_SPHERE:
                lines = \
"""7
1 0.071000000000000
6 0.414000000000000
7 0.168000000000000
8 0.285000000000000
15 0.036000000000000
16 0.006000000000000
76 0.020000000000000
1.320000000000000
SPHERE
12000.000000 10000.000000 10000.000000 8000.000000
""".splitlines()
                region.numberElements = 7
                element = Element.Element()
                element.atomicNumber = 1
                element.massFraction = 0.071
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 6
                element.massFraction = 0.414
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 7
                element.massFraction = 0.168
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 8
                element.massFraction = 0.285
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 15
                element.massFraction = 0.036
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 16
                element.massFraction = 0.006
                region.elements.append(element)
                element = Element.Element()
                element.atomicNumber = 76
                element.massFraction = 0.02
                region.elements.append(element)
                region.regionMassDensity_g_cm3 = 1.32
                region.regionType = RegionType.REGION_TYPE_SPHERE
                regionDimensions = RegionDimensions.createRegionDimensions(
                    region.regionType)
                regionDimensions.positionX = 12000.0
                regionDimensions.positionY = 10000.0
                regionDimensions.positionZ = 10000.0
                regionDimensions.radius = 8000.0
                region.regionDimensions = regionDimensions
                return lines, region