code: def dipole(self):
          
          dipole = np.zeros(3)
          mid_pt = np.sum(self.cart_coords, axis=0) / len(self)
          normal = self.normal
          for site in self:
              charge = sum([getattr(sp, "oxi_state", 0) * amt
                            for sp, amt in site.species.items()])
              dipole += charge * np.dot(site.coords - mid_pt, normal) * normal
          return dipole
docs: Calculates the dipole of the Slab in the direction of the surface
          normal. Note that the Slab must be oxidation state-decorated for this
          to work properly. Otherwise, the Slab will always have a dipole of 0.