Esempio n. 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])

            C = Atom(Z=6, R=[bond * 1.01] * 3)
            self.g = Geometry(
                np.array([[0., 0., 0.], [1., 0., 0.]], np.float64) * bond,
                atoms=C,
                sc=self.sc)
            self.E = EnergyDensityMatrix(self.g)
            self.ES = EnergyDensityMatrix(self.g, orthogonal=False)

            def func(E, ia, idxs, idxs_xyz):
                idx = E.geometry.close(ia,
                                       R=(0.1, 1.44),
                                       atoms=idxs,
                                       atoms_xyz=idxs_xyz)
                ia = ia * 3

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

                # nn
                p = 0.1

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

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

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

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

            self.func = func
Esempio n. 2
0
def test_nc_EDM_non_colinear(sisl_tmp):
    EDM1 = EnergyDensityMatrix(sisl.geom.graphene(), spin=sisl.Spin('NC'))
    EDM1.construct(([0.1, 1.44], [0.1, 0.2, 0.3, 0.4]))

    f1 = sisl_tmp('EDM1.nc', _dir)
    f2 = sisl_tmp('EDM2.nc', _dir)
    EDM1.write(f1)
    EDM1.finalize()
    EDM2 = sisl.get_sile(f1).read_energy_density_matrix()
    EDM2.write(f2)
    EDM3 = sisl.get_sile(f2).read_energy_density_matrix()
    assert EDM1._csr.spsame(EDM2._csr)
    assert np.allclose(EDM1._csr._D, EDM2._csr._D)
    assert EDM1._csr.spsame(EDM3._csr)
    assert np.allclose(EDM1._csr._D, EDM3._csr._D)
Esempio n. 3
0
def test_nc_EDM_non_colinear(sisl_tmp):
    EDM1 = EnergyDensityMatrix(sisl.geom.graphene(), spin=sisl.Spin('NC'))
    EDM1.construct(([0.1, 1.44], [[0.1, 0.2, 0.3, 0.4], [0.2, 0.3, 0.4, 0.5]]))

    f1 = sisl_tmp('EDM1.nc', _dir)
    f2 = sisl_tmp('EDM2.nc', _dir)
    EDM1.write(f1, sort=False)
    EDM1.finalize()
    EDM2 = sisl.get_sile(f1).read_energy_density_matrix(sort=False)
    EDM2.write(f2, sort=False)
    EDM3 = sisl.get_sile(f2).read_energy_density_matrix(sort=False)
    assert EDM1._csr.spsame(EDM2._csr)
    assert EDM1._csr.spsame(EDM3._csr)
    # EDM1 is finalized, but EDM2 is not finalized
    assert not np.allclose(EDM1._csr._D, EDM2._csr._D)
    # EDM2 and EDM3 are the same
    assert np.allclose(EDM2._csr._D, EDM3._csr._D)
    EDM2.finalize()
    assert np.allclose(EDM1._csr._D, EDM2._csr._D)
 def test_read_write_energy_density_matrix(self, sisl_tmp, sisl_system, sile):
     G = sisl_system.g.rotatec(-30)
     EDM = EnergyDensityMatrix(G, orthogonal=True)
     EDM.construct([[0.1, 1.45], [0.1, -2.7]])
     f = sisl_tmp('test_read_write_energy_density_matrix.win', _dir)
     # Write
     sile(f, mode='w').write_energy_density_matrix(EDM)
     # Read 1
     try:
         edm = sile(f, mode='r').read_energy_density_matrix(geometry=EDM.geom)
         assert EDM.spsame(edm)
     except UnicodeDecodeError as e:
         pass
     # Read 2
     try:
         edm = EnergyDensityMatrix.read(sile(f, mode='r'), geometry=EDM.geom)
         assert EDM.spsame(edm)
     except UnicodeDecodeError as e:
         pass
Esempio n. 5
0
 def test_spin(self, setup):
     g = setup.g.copy()
     EnergyDensityMatrix(g)
     EnergyDensityMatrix(g, spin=Spin('P'))
     EnergyDensityMatrix(g, spin=Spin('NC'))
     EnergyDensityMatrix(g, spin=Spin('SO'))