Ejemplo n.º 1
0
def TestVirtualVoronoi():    
    voxelNumbers=(200,200,200)
    imageBounds = (0.0,1.0,0.0,1.0,0.0,1.0)
    nPoint=200
    fiberRadius=0.05
    anisotropy=3
    randomSeed=0
    image=virtMatGen.CreateVirtualVoronoiFoam(voxelNumbers=voxelNumbers,imageBounds=imageBounds,
                                              nPoint=nPoint,fiberRadius=fiberRadius,
                                              anisotropy=anisotropy,randomSeed=randomSeed)
    Utilities.WriteTiff(255*(image.astype(np.uint8)),'TestVoronoi.tif')
    return image 
Ejemplo n.º 2
0
def TestVirtualGDL():
    voxelNumbers=(500,500,200)
    fiberContent=0.1
    fiberRadius=9
    fiberLength=500
    binderContent=0.1
    anisotropy=5
    randomSeed=0
    image = virtMatGen.CreateVirtualGDL(voxelNumbers=voxelNumbers,
                         fiberContent=fiberContent,fiberRadius=fiberRadius,fiberLength=fiberLength,
                         binderContent=binderContent,
                         anisotropy=anisotropy,randomSeed=randomSeed) 
    Utilities.WriteTiff(100*(image.astype(np.uint8)),'TestBigGDL.tif')
    return image 
Ejemplo n.º 3
0
    def test_CylinderArray(self): 
        #Test error between Ej-Heat and Rayleigh formula for a cylinder array
        
#        cylinderRadiusList=[2,5,10,20,30,40]
#        k1List=[0.001,0.01,0.1,0.9,10,100,1000]
        cylinderRadiusList = [10]
        k1List= [0.01]
        
        simu = [[] for i in range(len(cylinderRadiusList))]
        analytical = [[] for i in range(len(cylinderRadiusList))]
        relError = [[] for i in range(len(cylinderRadiusList))]
        matrix= 0 
        cylinders= 255
        
        for i in range(len(cylinderRadiusList)):
            
            cylinderRadius = cylinderRadiusList[i]
            image=VirtualMaterialsGeneration.CreateTestImage_CylinderArray(
                        cylinderRadius = cylinderRadius,voxelNumberParam=0.5 )
            
        
            simu[i]=[]
            analytical[i]=[]
            relError[i]=[] 
            for j in range(len(k1List)):
                km=1
                k1=k1List[j]
                
                beta = np.zeros((256,),dtype=np.float)
                beta[matrix]=km
                beta[cylinders]=k1
                direction='x'
                temperature,B_l,RR,I = EJHeat.EJ_heat(image,beta,direction,1e-6,100)
                 
                phi = np.count_nonzero(image==cylinders)/float(image.size)
                C1 = (k1+km)/float(k1-km)
                C2 = (k1-km)/float(k1+km)
                
                formula = 1 + 2*phi/(C1-phi+C2*(0.30584*phi**4+0.013363*phi**8))
                
                simu[i].append(B_l[0])
                analytical[i].append(formula)
                relError[i].append((abs(B_l[0]-formula)/formula))
        
            self.assertLess(relError[0][0],0.1)
Ejemplo n.º 4
0
def TestVirtualCCL():
    
    voxelNumbers=(200,200,200)
    carbonGrainRadius=4
    nCarbonGrain=5000
    voidRadius=50
    nVoid=200
    nafionThickness=2
    nafionCoveragePercentage=30
    randomSeed=1    
    image = virtMatGen.CreateVirtualCatalystLayer(voxelNumbers=voxelNumbers,
            carbonGrainRadius=carbonGrainRadius,nCarbonGrain=nCarbonGrain,
            voidRadius=voidRadius,nVoid=nVoid,
            nafionThickness=nafionThickness,nafionCoveragePercentage=nafionCoveragePercentage,
            randomSeed=randomSeed)
            
    Utilities.WriteTiff(100*(image.astype(np.uint8)),'TestCCL.tif')
    return image 
Ejemplo n.º 5
0
    def test_CapillaryPressureCurve(self):

        print('Test_CapillaryPressureCurve : need to improve coverage')

        image = VirtualMaterialsGeneration.CreateTestImage_TetrahedronMedialAxis(
        )
        image[image == 50] = 0
        image[image == 100] = 0

        output = FullMorphology.CapillaryPressureCurve(image,
                                                       porePhaseCode=0,
                                                       inletFace=0,
                                                       voxelLength=1,
                                                       nPoints=3)

        output['Saturation list']
        output['Capillary pressure list (in Pa)']
        output['Ball radius list (in voxel)']
Ejemplo n.º 6
0
    def test_FullMorphology(self):

        image = VirtualMaterialsGeneration.CreateTestImage_TetrahedronMedialAxis(
        )
        image[image == 50] = 0
        image[image == 100] = 0

        outputImage = FullMorphology.FullMorphology(image,
                                                    inletFace=1,
                                                    voxelLength=1,
                                                    gamma=72e-3,
                                                    pressureList=[10],
                                                    pressureCode=[110])

        #        self.assertTrue( == )
        #        self.assertTrue(np.all( ==))

        print('Test_FullMorphology : need to improve coverage')
Ejemplo n.º 7
0
def TestInterfaceGDLMPL(): 
    interface=virtMatGen.CreateVirtualInterfaceGDLMPL(penetrationLength=30)   
    Utilities.WriteTiff(50*(interface.astype(np.uint8)),'TestInterfaceGDLMPL_penetration30.tif')    
    return interface 
Ejemplo n.º 8
0
def TestVisualization():
    image = virtMatGen.CreateVirtualGDL(voxelNumbers=(400,400,100),fiberContent=0.2,fiberRadius=9,
                             fiberLength=400,binderContent=0.05,anisotropy=5,randomSeed=0)

    Visualization.VisualizeVolumeRendering(image)
Ejemplo n.º 9
0
    def test_ExtractNetwork(self):

        #Image 1
        image = VirtualMaterialsGeneration.CreateTestImage_TetrahedronMedialAxis(
        )
        PNMGeometricData = PoreNetworkExtraction.ExtractNetwork(
            image=image,
            phases={
                'void0': 0,
                'void1': 50,
                'void2': 100
            },
            seedMethod='hMaxima',
            seedParam=4)

        nPore = 5
        nInternalLink = 4
        interfaceToPore = np.array([[1, 4], [2, 4], [3, 4], [4, 5]])
        porePhase = np.array([100, 50, 0, 0, 0])

        self.assertTrue(PNMGeometricData['imagePores'].max() == nPore)
        self.assertTrue(PNMGeometricData['imageLiens'].max() == nInternalLink)
        self.assertTrue(
            np.all(PNMGeometricData['interfaceToPore'] == interfaceToPore))
        self.assertTrue(np.all(PNMGeometricData['porePhase'] == porePhase))

        #Image 2
        image = VirtualMaterialsGeneration.CreateTestImage_TetrahedronMedialAxis(
        )
        image[image == 50] = 0
        image[image == 100] = 0
        PNMGeometricData = PoreNetworkExtraction.ExtractNetwork(
            image=image, phases={'void': 0}, seedMethod='hMaxima', seedParam=4)

        nPore = 5
        nInternalLink = 4
        interfaceToPore = np.array([[3, 5], [2, 3], [1, 3], [3, 4]])
        porePhase = np.array([0, 0, 0, 0, 0])

        self.assertTrue(PNMGeometricData['imagePores'].max() == nPore)
        self.assertTrue(PNMGeometricData['imageLiens'].max() == nInternalLink)
        self.assertTrue(
            np.all(PNMGeometricData['interfaceToPore'] == interfaceToPore))
        self.assertTrue(np.all(PNMGeometricData['porePhase'] == porePhase))

        #Image 3
        image = VirtualMaterialsGeneration.CreateTestImage_TwoBalls()
        PNMGeometricData = PoreNetworkExtraction.ExtractNetwork(
            image=image, phases={'void': 0}, seedMethod='hMaxima', seedParam=2)

        nPore = 2
        nInternalLink = 1
        interfaceToPore = np.array([[1, 2]])
        porePhase = np.array([0, 0])

        self.assertTrue(PNMGeometricData['imagePores'].max() == nPore)
        self.assertTrue(PNMGeometricData['imageLiens'].max() == nInternalLink)
        self.assertTrue(
            np.all(PNMGeometricData['interfaceToPore'] == interfaceToPore))
        self.assertTrue(np.all(PNMGeometricData['porePhase'] == porePhase))

        #Image 4
        image = VirtualMaterialsGeneration.CreateTestImage_ThreeBalls()
        PNMGeometricData = PoreNetworkExtraction.ExtractNetwork(
            image=image, phases={'void': 0}, seedMethod='hMaxima', seedParam=2)

        nPore = 3
        nInternalLink = 3
        interfaceToPore = np.array([[2, 3], [1, 3], [1, 2]])
        porePhase = np.array([0, 0, 0])

        self.assertTrue(PNMGeometricData['imagePores'].max() == nPore)
        self.assertTrue(PNMGeometricData['imageLiens'].max() == nInternalLink)
        self.assertTrue(
            np.all(PNMGeometricData['interfaceToPore'] == interfaceToPore))
        self.assertTrue(np.all(PNMGeometricData['porePhase'] == porePhase))

        print(
            'Test_PoreNetworkExtraction_ExtractNetwork : need to improve coverage '
        )