#NEWLINE# def test_distance_center( ) : #NEWLINE# #INDENT# shape = sp . array ( [ 7 , 5 , 9 ] ) #NEWLINE# spacing = sp . array ( [ 2 , 1 , 0.5 ] ) #NEWLINE# pn = OpenPNM . Network . Cubic ( shape = shape , spacing = spacing ) #NEWLINE# ( sx , sy , sz ) = spacing #NEWLINE# center_coord = sp . around ( topology . find_centroid ( pn [ 'pore.coords' ] ) , 7 ) #NEWLINE# ( cx , cy , cz ) = center_coord #NEWLINE# coords = pn [ 'pore.coords' ] #NEWLINE# ( x , y , z ) = coords . T #NEWLINE# coords = sp . concatenate ( ( coords , center_coord . reshape ( ( 1 , 3 ) ) ) ) #NEWLINE# pn [ 'pore.center' ] = False #NEWLINE# mask1 = ( ( ( x <= ( cx + ( sx / 2 ) ) ) * ( y <= ( cy + ( sy / 2 ) ) ) ) * ( z <= ( cz + ( sz / 2 ) ) ) ) #NEWLINE# mask2 = ( ( ( x >= ( cx - ( sx / 2 ) ) ) * ( L1 >= ( cy - ( sy / 2 ) ) ) ) * ( z >= ( cz - ( sz / 2 ) ) ) ) #NEWLINE# center_pores_mask = pn . Ps [ ( mask1 * mask2 ) ] #NEWLINE# pn [ 'pore.center' ] [ center_pores_mask ] = True #NEWLINE# center = pn . Ps [ pn [ 'pore.center' ] ] #NEWLINE# L1 = sp . amax ( topology . find_pores_distance ( network = pn , pores1 = center , pores2 = pn . Ps ) ) #NEWLINE# L2 = sp . amax ( topology . find_pores_distance ( network = pn , pores1 = pn . Ps , pores2 = pn . Ps ) ) #NEWLINE# l1 = ( ( ( shape [ 0 ] - 1 ) * sx ) ** 2 ) #NEWLINE# l2 = ( ( ( shape [ 1 ] - 1 ) * sy ) ** 2 ) #NEWLINE# l3 = ( ( ( shape [ 2 ] - 1 ) * sz ) ** 2 ) #NEWLINE# L3 = sp . sqrt ( ( ( l1 + l2 ) + l3 ) ) #NEWLINE# assert ( sp . around ( ( L1 * 2 ) , 7 ) == sp . around ( L2 , 7 ) ) #NEWLINE# assert ( sp . around ( L2 , 7 ) == sp . around ( L3 , 7 ) )