code: def fix_pbc(structure, matrix=None):
      
  
      spec = []
      coords = []
      if matrix is None:
          latte = Lattice(structure.lattice.matrix)
      else:
          latte = Lattice(matrix)
  
      for site in structure:
          spec.append(site.specie)
          coord = np.array(site.frac_coords)
          for i in range(3):
              coord[i] -= floor(coord[i])
              if np.allclose(coord[i], 1):
                  coord[i] = 0
              elif np.allclose(coord[i], 0):
                  coord[i] = 0
              else:
                  coord[i] = round(coord[i], 7)
          coords.append(coord)
  
      return Structure(latte, spec, coords, site_properties=structure.site_properties)
docs: Set all frac_coords of the input structure within [0,1].
  
      Args:
          structure (pymatgen structure object):
              input structure
          matrix (lattice matrix, 3 by 3 array/matrix)
              new structure's lattice matrix, if none, use
              input structure's matrix
  
      Return:
          new structure with fixed frac_coords and lattice matrix