コード例 #1
0
ファイル: geometry.py プロジェクト: zx-sdu/qutranpy
 def supercell(self, nsuper):
     """Creates a supercell"""
     if self.dimensionality == 0: return self  # zero dimensional
     try:
         nsuper[0][0]  # if matrix is given
         print("Supercell", nsuper)
         return non_orthogonal_supercell(self, nsuper)
     except:
         pass  # continue with normal way
     if self.dimensionality == 1:
         s = supercell1d(self, nsuper)
     elif self.dimensionality == 2:
         try:  # two number given
             nsuper1 = nsuper[0]
             nsuper2 = nsuper[1]
         except:  # one number given
             nsuper1 = nsuper
             nsuper2 = nsuper
         s = supercell2d(self, n1=nsuper1, n2=nsuper2)
     elif self.dimensionality == 3:
         try:  # two number given
             nsuper1 = nsuper[0]
             nsuper2 = nsuper[1]
             nsuper3 = nsuper[2]
         except:  # one number given
             nsuper1 = nsuper
             nsuper2 = nsuper
             nsuper3 = nsuper
         s = supercell3d(self, n1=nsuper1, n2=nsuper2, n3=nsuper3)
     else:
         raise
     s.center()
     s.get_fractional()
     return s
コード例 #2
0
ファイル: geometry.py プロジェクト: zx-sdu/qutranpy
def honeycomb_lattice_C6():
    """Geometry for a honeycomb lattice, taking a unit cell
  with C6 rotational symmetry"""
    g = honeycomb_lattice()  # create geometry
    m = [[2, 1, 0], [1, 2, 0], [0, 0, 1]]
    g = non_orthogonal_supercell(g, m)
    g.r[0] = g.r[0] + g.a2
    g.r[1] = g.r[1] + g.a2
    g.r[4] = g.r[4] - g.a2 + g.a1
    # if it looks stupid but it works, it is not stupid
    g.r2xyz()
    g.update_reciprocal()  # update reciprocal lattice vectors
    return g
コード例 #3
0
def bulk2ribbon(g, boundary=[1, 0], n=10, clean=True):
    """Return the geometry of a ribbon"""
    go = g.copy()  # copy
    m = [[boundary[0], boundary[1], 0], [0, 1, 0], [0, 0, 1]]  # supercell
    if boundary[0] != 1 or boundary[1] != 0:
        go = supercell.non_orthogonal_supercell(go, m, mode="brute")
    go = go.supercell((1, n))  # create a supercell
    go = sculpt.rotate_a2b(go, go.a1, np.array([1., 0., 0.]))
    go.dimensionality = 1  # zero dimensional
    go.a2 = np.array([0., 1., 0.])
    if clean:
        go = go.clean(iterative=True)
        if len(go.r) == 0:
            print("Ribbon is not wide enough")
            raise
    go.real2fractional()
    go.fractional2real()
    go.celldis = go.a1[0]
    go.center()
    return go
コード例 #4
0
def get_geometry():
    name = builder.get_object("ribbon_type").get_active_text()
    if name == "Honeycomb zigzag":
        geometry_builder = geometry.honeycomb_zigzag_ribbon
    if name == "Honeycomb armchair":
        geometry_builder = geometry.honeycomb_armchair_ribbon
    if name == "Square (10)":
        geometry_builder = geometry.square_tetramer_ribbon
    if name == "Square (11)":
        gb = geometry.square_lattice()  # bulk square lattice
        import supercell
        gb = supercell.non_orthogonal_supercell(
            gb, [[1, 1, 0], [-1, 1, 0], [0, 0, 1]], mode="brute")

        def geometry_builder(n):
            g = gb.supercell((1, n))
            g.dimensionality = 1
            g = sculpt.rotate_a2b(g, g.a1, np.array([1., 0., 0.]))
            return g

    g = geometry_builder(int(get("width")))
    return g