[docs]@docstr.dedentclassFaceCenteredCubic(Network):r""" Face-Centered Cubic lattice which is a simple cubic lattice with additional pores located on each face of the cubic unit cells. These pores are connected to each other and their diagonal neighbors. Parameters ---------- shape : array_like The number of pores forming the corners of the unit cell in each direction spacing : array_like (optional) The spacing between pores that form the corners of the unit cells %(Network.parameters)s See Also -------- Cubic BodyCenteredCubic Notes ----- The pores are labelled as beloning to 'corner_sites' and 'face_sites' Throats are labelled by the which type of pores they connect, e.g. 'throat.corner_to_body'. """def__init__(self,shape,mode='sc',spacing=1,**kwargs):super().__init__(**kwargs)shape=np.array(shape)ifnp.any(shape<2):raiseException('FCC lattice networks must have at least 2 ''pores in all directions')net=fcc(shape=shape,spacing=spacing,node_prefix='pore',edge_prefix='throat')self.update(net)# Add labelsTs1=np.all(self['pore.corner'][self.conns],axis=1)self['throat.corner_to_corner']=Ts1Ts2=np.all(self['pore.face'][self.conns],axis=1)self['throat.face_to_face']=Ts2self['throat.corner_to_face']=~(Ts1+Ts2)topotools.label_faces(self)Ps=self.pores(['xmin','xmax','ymin','ymax','zmin','zmax'])Ps=self.to_mask(pores=Ps)self['pore.surface']=Ps# Finally scale network to specified spacingself['pore.coords']*=np.array(spacing)
[docs]defadd_boundary_pores(self,labels,spacing):r""" Add boundary pores to the specified faces of the network Pores are offset from the faces by 1/2 of the given ``spacing``, such that they lie directly on the boundaries. Parameters ---------- labels : str or list[str] The labels indicating the pores defining each face where boundary pores are to be added (e.g. 'left' or ['left', 'right']) spacing : scalar or array_like The spacing of the network (e.g. [1, 1, 1]). This must be given since it can be quite difficult to infer from the network, for instance if boundary pores have already added to other faces. """spacing=np.array(spacing)ifspacing.size==1:spacing=np.ones(3)*spacingforiteminlabels:Ps=self.pores(item)coords=np.absolute(self['pore.coords'][Ps])axis=np.count_nonzero(np.diff(coords,axis=0),axis=0)==0offset=np.array(axis,dtype=int)/2ifnp.amin(coords)==np.amin(coords[:,np.where(axis)[0]]):offset=-1*offsettopotools.add_boundary_pores(network=self,pores=Ps,offset=offset,apply_label=item+'_boundary')