示例#1
0
        def __init__(self):
            bond = 1.42
            sq3h = 3.**.5 * 0.5
            self.sc = SuperCell(
                np.array([[1.5, sq3h, 0.], [1.5, -sq3h, 0.], [0., 0., 10.]],
                         np.float64) * bond,
                nsc=[3, 3, 1])

            n = 60
            rf = np.linspace(0, bond * 1.01, n)
            rf = (rf, rf)
            orb = SphericalOrbital(1, rf, 2.)
            C = Atom(6, orb.toAtomicOrbital())
            self.g = Geometry(
                np.array([[0., 0., 0.], [1., 0., 0.]], np.float64) * bond,
                atom=C,
                sc=self.sc)
            self.D = DensityMatrix(self.g)
            self.DS = DensityMatrix(self.g, orthogonal=False)

            def func(D, ia, idxs, idxs_xyz):
                idx = D.geom.close(ia,
                                   R=(0.1, 1.44),
                                   idx=idxs,
                                   idx_xyz=idxs_xyz)
                ia = ia * 3

                i0 = idx[0] * 3
                i1 = idx[1] * 3
                # on-site
                p = 1.
                D.D[ia, i0] = p
                D.D[ia + 1, i0 + 1] = p
                D.D[ia + 2, i0 + 2] = p

                # nn
                p = 0.1

                # on-site directions
                D.D[ia, ia + 1] = p
                D.D[ia, ia + 2] = p
                D.D[ia + 1, ia] = p
                D.D[ia + 1, ia + 2] = p
                D.D[ia + 2, ia] = p
                D.D[ia + 2, ia + 1] = p

                D.D[ia, i1 + 1] = p
                D.D[ia, i1 + 2] = p

                D.D[ia + 1, i1] = p
                D.D[ia + 1, i1 + 2] = p

                D.D[ia + 2, i1] = p
                D.D[ia + 2, i1 + 1] = p

            self.func = func
示例#2
0
        def __init__(self):
            bond = 1.42
            sq3h = 3.**.5 * 0.5
            self.sc = SuperCell(np.array([[1.5, sq3h, 0.],
                                          [1.5, -sq3h, 0.],
                                          [0., 0., 10.]], np.float64) * bond, nsc=[3, 3, 1])

            n = 60
            rf = np.linspace(0, bond * 1.01, n)
            rf = (rf, rf)
            orb = SphericalOrbital(1, rf, 2.)
            C = Atom(6, orb.toAtomicOrbital())
            self.g = Geometry(np.array([[0., 0., 0.],
                                        [1., 0., 0.]], np.float64) * bond,
                              atoms=C, sc=self.sc)
            self.S = Overlap(self.g)
示例#3
0
def test_wavefunction1():
    N = 50
    o1 = SphericalOrbital(0, (np.linspace(0, 2, N), np.exp(-np.linspace(0, 100, N))))
    G = Geometry([[1] * 3, [2] * 3], Atom(6, o1), sc=[4, 4, 4])
    H = Hamiltonian(G)
    R, param = [0.1, 1.5], [1., 0.1]
    H.construct([R, param])
    ES = H.eigenstate(dtype=np.float64)
    # Plot in the full thing
    grid = Grid(0.1, geometry=H.geom)
    grid.fill(0.)
    ES.sub(0).wavefunction(grid)
示例#4
0
def test_wavefunction_eta():
    N = 50
    o1 = SphericalOrbital(0, (np.linspace(0, 2, N), np.exp(-np.linspace(0, 100, N))))
    G = Geometry([[1] * 3, [2] * 3], Atom(6, o1), sc=[4, 4, 4])
    H = Hamiltonian(G, spin=Spin('nc'))
    R, param = [0.1, 1.5], [[0., 0., 0.1, -0.1],
                            [1., 1., 0.1, -0.1]]
    H.construct([R, param])
    ES = H.eigenstate()
    # Plot in the full thing
    grid = Grid(0.1, dtype=np.complex128, sc=SuperCell([2, 2, 2], origo=[-1] * 3))
    grid.fill(0.)
    ES.sub(0).wavefunction(grid, eta=True)
示例#5
0
def test_wavefunction2():
    N = 50
    o1 = SphericalOrbital(0, (np.linspace(0, 2, N), np.exp(-np.linspace(0, 100, N))))
    G = Geometry([[1] * 3, [2] * 3], Atom(6, o1), sc=[4, 4, 4])
    H = Hamiltonian(G)
    R, param = [0.1, 1.5], [1., 0.1]
    H.construct([R, param])
    ES = H.eigenstate(dtype=np.float64)
    # This is effectively plotting outside where no atoms exists
    # (there could however still be psi weight).
    grid = Grid(0.1, sc=SuperCell([2, 2, 2], origo=[2] * 3))
    grid.fill(0.)
    ES.sub(0).wavefunction(grid)
示例#6
0
    def test_rho2(self, setup):
        bond = 1.42
        sq3h = 3.**.5 * 0.5
        sc = SuperCell(np.array(
            [[1.5, sq3h, 0.], [1.5, -sq3h, 0.], [0., 0., 10.]], np.float64) *
                       bond,
                       nsc=[3, 3, 1])

        n = 60
        rf = np.linspace(0, bond * 1.01, n)
        rf = (rf, rf)
        orb = SphericalOrbital(1, rf, 2.)
        C = Atom(6, orb)
        g = Geometry(np.array([[0., 0., 0.], [1., 0., 0.]], np.float64) * bond,
                     atom=C,
                     sc=sc)
        D = DensityMatrix(g)
        D.construct([[0.1, bond + 0.01], [1., 0.1]])
        grid = Grid(0.2, geometry=D.geom)
        D.density(grid)

        D = DensityMatrix(g, spin=Spin('P'))
        D.construct([[0.1, bond + 0.01], [(1., 0.5), (0.1, 0.1)]])
        grid = Grid(0.2, geometry=D.geom)
        D.density(grid)
        D.density(grid, [1., -1])
        D.density(grid, 0)
        D.density(grid, 1)

        D = DensityMatrix(g, spin=Spin('NC'))
        D.construct([[0.1, bond + 0.01],
                     [(1., 0.5, 0.01, 0.01), (0.1, 0.1, 0.1, 0.1)]])
        grid = Grid(0.2, geometry=D.geom)
        D.density(grid)
        D.density(grid, [[1., 0.], [0., -1]])

        D = DensityMatrix(g, spin=Spin('SO'))
        D.construct([[0.1, bond + 0.01],
                     [(1., 0.5, 0.01, 0.01, 0.01, 0.01, 0., 0.),
                      (0.1, 0.1, 0.1, 0.1, 0., 0., 0., 0.)]])
        grid = Grid(0.2, geometry=D.geom)
        D.density(grid)
        D.density(grid, [[1., 0.], [0., -1]])
        D.density(grid, Spin.X)
        D.density(grid, Spin.Y)
        D.density(grid, Spin.Z)
示例#7
0
文件: omx.py 项目: silsgs/sisl
        def decompose_basis(l):
            # Only split once
            Zr, spec = l.split('-', 1)
            idx = 0
            for i, c in enumerate(Zr):
                if c.isdigit():
                    idx = i
                    break
            R = -1
            if idx == 0:
                Z = Zr
            else:
                Z = Zr[:idx]
                try:
                    R = float(Zr[idx:])
                except:
                    pass

            # Now figure out the orbitals
            orbs = []
            m_order = {
                0: [0],
                1: [1, -1, 0],  # px, py, pz
                2: [0, 2, -2, 1, -1],  # d3z^2-r^2, dx^2-y^2, dxy, dxz, dyz
                3: [
                    0, 1, -1, 2, -2, 3, -3
                ],  # f5z^2-3r^2, f5xz^2-xr^2, f5yz^2-yr^2, fzx^2-zy^2, fxyz, fx^3-3*xy^2, f3yx^2-y^3
                4: [0, 1, -1, 2, -2, 3, -3, 4, -4]
            }
            for i, c in enumerate(spec):
                try:
                    l = 'spdfg'.index(c)
                    try:
                        nZ = int(spec[i + 1])
                    except:
                        nZ = 1
                    for z in range(nZ):
                        orbs.extend(
                            SphericalOrbital(l, rf_func(R)).toAtomicOrbital(
                                m=m_order[l], Z=z + 1))
                except:
                    pass

            return Z, orbs
示例#8
0
    def test_rho_fail_nc(self, setup):
        bond = 1.42
        sq3h = 3.**.5 * 0.5
        sc = SuperCell(np.array([[1.5, sq3h, 0.],
                                      [1.5, -sq3h, 0.],
                                      [0., 0., 10.]], np.float64) * bond, nsc=[3, 3, 1])

        n = 60
        rf = np.linspace(0, bond * 1.01, n)
        rf = (rf, rf)
        orb = SphericalOrbital(1, rf, 2.)
        C = Atom(6, orb)
        g = Geometry(np.array([[0., 0., 0.],
                                    [1., 0., 0.]], np.float64) * bond,
                        atoms=C, sc=sc)

        D = DensityMatrix(g, spin=Spin('NC'))
        D.construct([[0.1, bond + 0.01], [(1., 0.5, 0.01, 0.01), (0.1, 0.1, 0.1, 0.1)]])
        grid = Grid(0.2, geometry=D.geometry)
        with pytest.raises(ValueError):
            D.density(grid, [1., 0.])
示例#9
0
    def read_basis(self):
        """ Returns a set of atoms corresponding to the basis-sets in the nc file """
        if 'BASIS' not in self.groups:
            return None

        basis = self.groups['BASIS']
        atom = [None] * len(basis.groups)

        for a_str in basis.groups:
            a = basis.groups[a_str]

            if 'orbnl_l' not in a.variables:

                # Do the easy thing.

                # Get number of orbitals
                label = a.Label.strip()
                Z = int(a.Atomic_number)
                mass = float(a.Mass)

                i = int(a.ID) - 1
                atom[i] = Atom(Z, [-1] * a.Number_of_orbitals,
                               mass=mass,
                               tag=label)
                continue

            # Retrieve values
            orb_l = a.variables['orbnl_l'][:]  # angular quantum number
            orb_n = a.variables['orbnl_n'][:]  # principal quantum number
            orb_z = a.variables['orbnl_z'][:]  # zeta
            orb_P = a.variables[
                'orbnl_ispol'][:] > 0  # polarization shell, or not
            orb_q0 = a.variables['orbnl_pop'][:]  # q0 for the orbitals
            orb_delta = a.variables['delta'][:]  # delta for the functions
            orb_psi = a.variables['orb'][:, :]

            # Now loop over all orbitals
            orbital = []

            # Number of basis-orbitals (before m-expansion)
            no = len(a.dimensions['norbs'])

            # All orbital data
            for io in range(no):

                n = orb_n[io]
                l = orb_l[io]
                z = orb_z[io]
                P = orb_P[io]

                # Grid spacing in Bohr (conversion is done later
                # because the normalization is easier)
                delta = orb_delta[io]

                # Since the readed data has fewer significant digits we
                # might as well re-create the table of the radial component.
                r = aranged(orb_psi.shape[1]) * delta

                # To get it per Ang**3
                # TODO, check that this is correct.
                # The fact that we have to have it normalized means that we need
                # to convert psi /sqrt(Bohr**3) -> /sqrt(Ang**3)
                # \int psi^\dagger psi == 1
                psi = orb_psi[io, :] * r**l / Bohr2Ang**(3. / 2.)

                # Create the sphericalorbital and then the atomicorbital
                sorb = SphericalOrbital(l, (r * Bohr2Ang, psi), orb_q0[io])

                # This will be -l:l (this is the way siesta does it)
                orbital.extend(sorb.toAtomicOrbital(n=n, Z=z, P=P))

            # Get number of orbitals
            label = a.Label.strip()
            Z = int(a.Atomic_number)
            mass = float(a.Mass)

            i = int(a.ID) - 1
            atom[i] = Atom(Z, orbital, mass=mass, tag=label)
        return atom