def extractFromLinesWithVersion(self, lines): extractMethods = self._createExtractMethods() indexLine = 0 key = KEY_NUMBER_ELEMENTS line = lines[indexLine] if line.startswith(key): items = line.split('=') self.numberElements = extractMethods[key](items[-1]) indexLine += 1 for _indexElement in range(self.numberElements): element = Element.Element() indexLine += element.extractFromLinesWithKey(lines[indexLine:]) self.elements.append(element) key = KEY_USER_DEFINED_MASS_DENSITY line = lines[indexLine] if line.startswith(key): items = line.split('=') regionMassDensity_g_cm3 = extractMethods[key](items[-1]) if regionMassDensity_g_cm3 > 0.0: self.regionMassDensity_g_cm3 = regionMassDensity_g_cm3 indexLine += 1 self.regionType = self._extractRegionTypeWithKey(lines[indexLine]) indexLine += 1 self.regionDimensions = RegionDimensions.createRegionDimensions( self.regionType) self.regionDimensions.extractFromLinesWithKey(lines[indexLine]) indexLine += 1 return indexLine
def extractFromLinesWithoutVersion(self, lines): self.clear() indexLine = 0 self.numberElements = int(lines[indexLine]) indexLine += 1 for _indexElement in range(self.numberElements): element = Element.Element() element.extractFromLineOldVersion(lines[indexLine]) self.elements.append(element) indexLine += 1 # Test if the region mass density is defined by the user in the file. try: regionMassDensity_g_cm3 = float(lines[indexLine]) self.regionMassDensity_g_cm3 = regionMassDensity_g_cm3 indexLine += 1 except ValueError: pass self.regionType = self._extractRegionType(lines[indexLine]) indexLine += 1 self.regionDimensions = RegionDimensions.createRegionDimensions( self.regionType) self.regionDimensions.extractFromLineOldVersion(lines[indexLine]) indexLine += 1 return indexLine
def getLinesAndReference(): lines = """Volume ID = 0 Volume size = 8.000000e+030 Volume extents min (-1.000000e+010, -1.000000e+010, 0.000000e+000) Volume extents max ( 1.000000e+010, 1.000000e+010, 2.000000e+010) BOX -10000000000.000000 10000000000.000000 -10000000000.000000 10000000000.000000 0.000000 20000000000.000000 Exclusion region Volume has holes """.splitlines() regionVolumeRef = RegionVolume.RegionVolume() regionVolumeRef.volumeID = 0 regionVolumeRef.volumeSize = 8.000000e+030 regionVolumeRef.volumeMinimum_A = (-1.0e10, -1.0e10, 0.0) regionVolumeRef.volumeMaximum_A = (1.0e10, 1.0e10, 2.0e10) regionVolumeRef.volumeType = RegionType.REGION_TYPE_BOX parameters = [-10000000000.0, 10000000000.0, -10000000000.0, 10000000000.0, 0.0, 20000000000.0] regionVolumeRef.volumeParameters = RegionDimensions.RegionDimensionsBox(parameters) regionVolumeRef.isExclusion = True regionVolumeRef.isCompact = False regionVolumeRef.isEmpty = False return lines, regionVolumeRef
def test_RegionDimensionsSphere_createLineWithKey(self): """ Tests for class `RegionDimensionsSphere`. """ lineRef = "RegionParameters=500.000000 500.000000 300.000000 300.000000" regionDimensions = RegionDimensions.RegionDimensionsSphere() regionDimensions.positionX = 500.0 regionDimensions.positionY = 500.0 regionDimensions.positionZ = 300.0 regionDimensions.radius = 300.0 line = regionDimensions.createLineWithKey() self.assertEquals(lineRef, line)
def test_RegionDimensionsBox_createLineWithKey(self): """ Tests for class `RegionDimensionsBox`. """ lineRef = "RegionParameters=0.000000 10000000000.000000 -10000000000.000000 10000000000.000000 0.000000 20000000000.000000" regionDimensions = RegionDimensions.RegionDimensionsBox() regionDimensions.minimumX = 0.0 regionDimensions.maximumX = 10000000000.0 regionDimensions.minimumY = -10000000000.0 regionDimensions.maximumY = 10000000000.0 regionDimensions.minimumZ = 0.0 regionDimensions.maximumZ = 20000000000.0 line = regionDimensions.createLineWithKey() self.assertEquals(lineRef, line)
def test_RegionDimensionsSphere_extractFromLinesWithKey(self): """ Tests for class `RegionDimensionsSphere`. """ regionDimensions = RegionDimensions.RegionDimensionsSphere() numberParameters = 4 self.assertEquals(numberParameters, len(regionDimensions._keys)) line = "RegionParameters=500.000000 500.000000 300.000000 300.000000" regionDimensions.extractFromLinesWithKey(line) self.assertEquals(500.0, regionDimensions.positionX) self.assertEquals(500.0, regionDimensions.positionY) self.assertEquals(300.0, regionDimensions.positionZ) self.assertEquals(300.0, regionDimensions.radius)
def test_RegionDimensionsBox_extractFromLineOldVersion(self): """ Tests for class `RegionDimensionsBox`. """ regionDimensions = RegionDimensions.RegionDimensionsBox() numberParameters = 6 self.assertEquals(numberParameters, len(regionDimensions._keys)) line = "0.000000 10000000000.000000 -10000000000.000000 10000000000.000000 0.000000 20000000000.000000" regionDimensions.extractFromLineOldVersion(line) self.assertEquals(0.0, regionDimensions.minimumX) self.assertEquals(10000000000.0, regionDimensions.maximumX) self.assertEquals(-10000000000.0, regionDimensions.minimumY) self.assertEquals(10000000000.0, regionDimensions.maximumY) self.assertEquals(0.0, regionDimensions.minimumZ) self.assertEquals(20000000000.0, regionDimensions.maximumZ)
def test_createRegionDimensions(self): """ Tests for method `createRegionDimensions`. """ classList = {} classList[ RegionType.REGION_TYPE_BOX] = RegionDimensions.RegionDimensionsBox classList[ RegionType. REGION_TYPE_CYLINDER] = RegionDimensions.RegionDimensionsCylinder classList[RegionType. REGION_TYPE_SPHERE] = RegionDimensions.RegionDimensionsSphere for regionType in classList: classRef = classList[regionType] regionDimension = RegionDimensions.createRegionDimensions( regionType) self.assertIsInstance(regionDimension, classRef)
def test_RegionDimensionsCylinder_createLineWithKey(self): """ Tests for class `RegionDimensionsCylinder`. """ lineRef = "RegionParameters=-500.000000 -500.000000 300.000000 0.000000 1.000000 0.350000 1000.000000 300.000000" regionDimensions = RegionDimensions.RegionDimensionsCylinder() 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 line = regionDimensions.createLineWithKey() self.assertEquals(lineRef, line)
def test_RegionDimensionsCylinder_extractFromLinesWithKey(self): """ Tests for class `RegionDimensionsCylinder`. """ regionDimensions = RegionDimensions.RegionDimensionsCylinder() numberParameters = 8 self.assertEquals(numberParameters, len(regionDimensions._keys)) line = "RegionParameters=-500.000000 -500.000000 300.000000 0.000000 1.000000 0.350000 1000.000000 300.000000" regionDimensions.extractFromLinesWithKey(line) self.assertEquals(-500.0, regionDimensions.positionX) self.assertEquals(-500.0, regionDimensions.positionY) self.assertEquals(300.0, regionDimensions.positionZ) self.assertEquals(0.0, regionDimensions.directionX) self.assertEquals(1.0, regionDimensions.directionY) self.assertEquals(0.35, regionDimensions.directionZ) self.assertEquals(1000.0, regionDimensions.length) self.assertEquals(300.0, regionDimensions.radius)
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
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
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