<s> """<STR_LIT>""" <EOL> import scipy as sp <EOL> from OpenPNM . Network import GenericNetwork <EOL> from OpenPNM . Base import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> class TestNet ( GenericNetwork ) : <EOL> r"""<STR_LIT>""" <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( ) . __init__ ( ** kwargs ) <EOL> self . generate ( ) <EOL> def generate ( self ) : <EOL> r"""<STR_LIT>""" <EOL> self . _generate_setup ( ) <EOL> self . _generate_pores ( ) <EOL> self . _generate_throats ( ) <EOL> self . _add_labels ( ) <EOL> return self <EOL> def _generate_setup ( self ) : <EOL> r"""<STR_LIT>""" <EOL> self . _Nx = <NUM_LIT:5> <EOL> self . _Ny = <NUM_LIT:5> <EOL> self . _Nz = <NUM_LIT:5> <EOL> self . _Lc = <NUM_LIT:1> <EOL> self . _Lx = sp . float16 ( self . _Nx * self . _Lc ) <EOL> self . _Ly = sp . float16 ( self . _Ny * self . _Lc ) <EOL> self . _Lz = sp . float16 ( self . _Nz * self . _Lc ) <EOL> def _generate_pores ( self ) : <EOL> r"""<STR_LIT>""" <EOL> Nx = self . _Nx <EOL> Ny = self . _Ny <EOL> Nz = self . _Nz <EOL> Lc = self . _Lc <EOL> Np = Nx * Ny * Nz <EOL> ind = sp . arange ( <NUM_LIT:0> , Np ) <EOL> self [ '<STR_LIT>' ] = sp . ones_like ( ind , dtype = bool ) <EOL> unraveled_index = sp . unravel_index ( ind , dims = ( Nx , Ny , Nz ) , order = '<STR_LIT:F>' ) <EOL> pore_coords = Lc / <NUM_LIT:2> + Lc * sp . array ( unraveled_index , dtype = sp . float64 ) . T <EOL> self [ '<STR_LIT>' ] = pore_coords <EOL> def _generate_throats ( self ) : <EOL> r"""<STR_LIT>""" <EOL> Nx = self . _Nx <EOL> Ny = self . _Ny <EOL> Nz = self . _Nz <EOL> Np = Nx * Ny * Nz <EOL> ind = sp . arange ( <NUM_LIT:0> , Np ) <EOL> tpore1_1 = ind [ ( ind % Nx ) < ( Nx - <NUM_LIT:1> ) ] <EOL> tpore2_1 = tpore1_1 + <NUM_LIT:1> <EOL> tpore1_2 = ind [ ( ind % ( Nx * Ny ) ) < ( Nx * ( Ny - <NUM_LIT:1> ) ) ] <EOL> tpore2_2 = tpore1_2 + Nx <EOL> tpore1_3 = ind [ ( ind % Np ) < ( Nx * Ny * ( Nz - <NUM_LIT:1> ) ) ] <EOL> tpore2_3 = tpore1_3 + Nx * Ny <EOL> tpore1 = sp . hstack ( ( tpore1_1 , tpore1_2 , tpore1_3 ) ) <EOL> tpore2 = sp . hstack ( ( tpore2_1 , tpore2_2 , tpore2_3 ) ) <EOL> connections = sp . vstack ( ( tpore1 , tpore2 ) ) . T <EOL> connections = connections [ sp . lexsort ( ( connections [ : , <NUM_LIT:1> ] , connections [ : , <NUM_LIT:0> ] ) ) ] <EOL> self [ '<STR_LIT>' ] = sp . ones_like ( sp . arange ( <NUM_LIT:0> , sp . shape ( tpore1 ) [ <NUM_LIT:0> ] ) , <EOL> dtype = bool ) <EOL> self [ '<STR_LIT>' ] = connections <EOL> def _add_labels ( self ) : <EOL> coords = self [ '<STR_LIT>' ] <EOL> self [ '<STR_LIT>' ] = self . tomask ( coords [ : , <NUM_LIT:0> ] <= self . _Lc ) <EOL> self [ '<STR_LIT>' ] = self . tomask ( coords [ : , <NUM_LIT:1> ] <= self . _Lc ) <EOL> self [ '<STR_LIT>' ] = self . tomask ( coords [ : , <NUM_LIT:2> ] <= self . _Lc ) <EOL> self [ '<STR_LIT>' ] = self . tomask ( coords [ : , <NUM_LIT:0> ] >= ( self . _Lc * ( self . _Nx - <NUM_LIT:1> ) ) ) <EOL> self [ '<STR_LIT>' ] = self . tomask ( coords [ : , <NUM_LIT:1> ] >= ( self . _Lc * ( self . _Ny - <NUM_LIT:1> ) ) ) <EOL> self [ '<STR_LIT>' ] = self . tomask ( coords [ : , <NUM_LIT:2> ] >= ( self . _Lc * ( self . _Nz - <NUM_LIT:1> ) ) ) <EOL> for item in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:left>' , '<STR_LIT:right>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> ps = self . pores ( item ) <EOL> ts = self . find_neighbor_throats ( ps ) <EOL> ps = self . find_connected_pores ( ts ) <EOL> ps0 = self [ '<STR_LIT>' + item ] [ ps [ : , <NUM_LIT:0> ] ] <EOL> ps1 = self [ '<STR_LIT>' + item ] [ ps [ : , <NUM_LIT:1> ] ] <EOL> ts = ts [ ps1 * ps0 ] <EOL> self [ '<STR_LIT>' + item ] = self . tomask ( throats = ts ) </s>
