Пример #1
0
    def setup_system(self, add_spin=True, anti_symmetrize=True):
        """The wells are divided by x-axis by default.
        """

        super().setup_system(add_spin=add_spin,
                             anti_symmetrize=anti_symmetrize)

        h_dw = get_smooth_double_well_one_body_elements(
            self.l // 2,
            self.omega,
            self.mass,
            a=self.a,
            b=self.b,
            dtype=np.complex128,
        )

        self.epsilon, C = np.linalg.eigh(h_dw)
        self._h = np.diagflat(self.epsilon[:self.l_dw // 2])
        self._s = np.eye(self.l_dw // 2)
        C_dw = C[:, :self.l_dw // 2]

        if add_spin:
            self._h = add_spin_one_body(self._h, np=np)
            self._s = add_spin_one_body(self._s, np=np)
            C_dw = add_spin_one_body(C_dw, np=np)

        self.change_basis_two_body_elements(C_dw)
        self.change_basis_dipole_moment(C_dw)
        self.change_basis_spf(C_dw)

        self.set_system_size(self.n, self.l_dw)

        self.cast_to_complex()
        self.change_module()
Пример #2
0
    def setup_system(self, axis=0, add_spin=True, anti_symmetrize=True):
        """Function setting up the one- and two-body elements, the
        single-particle functions, dipole moments and other quantities used by
        second quantization methods.
        
        Parameters
        ----------
        axis : int
            The axis argument specifies which
            axis the well barrier is aligned to. (0, 1) = (x, y).
        """

        super().setup_system(add_spin=add_spin,
                             anti_symmetrize=anti_symmetrize)

        self._h = get_double_well_one_body_elements(
            self.l // 2,
            self.omega,
            self.mass,
            self.barrier_strength,
            dtype=np.complex128,
            axis=axis,
        )

        self._s = np.eye(self.l // 2)

        if add_spin:
            self._h = add_spin_one_body(self._h, np=np)
            self._s = add_spin_one_body(self._s, np=np)

        self.cast_to_complex()
        self.change_module()
Пример #3
0
def test_add_spin_one_body():
    l_half = 10
    h = np.random.random((l_half, l_half))
    l = l_half * 2
    h_spin = np.zeros((l, l))

    for p in range(l):
        for q in range(l):
            h_spin[p, q] = spin_delta(p, q) * h[p // 2, q // 2]

    np.testing.assert_allclose(h_spin, add_spin_one_body(h, np=np), atol=1e-10)
Пример #4
0
    def setup_system(self):
        __h = np.zeros((self.l // 2, self.l // 2), dtype=np.complex128)
        for p in range(self.l // 2):
            __h[p, p] = _eigen_energy(
                self.table[self.table.index == p].shell, self.length, self.mass
            )

        self._h = add_spin_one_body(__h)
        self._u = _construct_coulomb_elements(
            self.l,
            self.table[self.n_columns].values.astype(np.int),
            self.length,
        )

        self._f = self.construct_fock_matrix(self._h, self._u)
Пример #5
0
def test_antisymmetric_one_body_elements(h):
    l = len(h)
    _h = add_spin_one_body(get_one_body_elements(l // 2), np=np)

    np.testing.assert_allclose(h, _h, atol=1e-6, rtol=1e-6)
Пример #6
0
def test_add_spin_one_body():
    n = 7
    l = 20

    for n_a in range(0, n):
        n_b = n - n_a

        o_a, o_b, v_a, v_b = get_spin_block_slices(n, n_a, l)
        h = np.arange((l // 2)**2).reshape(l // 2, l // 2) + 1.0
        new_h = add_spin_one_body(h, np)

        np.testing.assert_allclose(np.sum(h) * 2, np.sum(new_h))

        np.testing.assert_allclose(
            new_h[o_a, o_a],
            h[:n_a, :n_a],
        )

        np.testing.assert_allclose(
            new_h[o_b, o_b],
            h[:n_b, :n_b],
        )

        np.testing.assert_allclose(
            new_h[v_a, v_a],
            h[n_a:, n_a:],
        )

        np.testing.assert_allclose(
            new_h[v_b, v_b],
            h[n_b:, n_b:],
        )

        np.testing.assert_allclose(
            new_h[o_a, o_b],
            np.zeros(h[:n_a, :n_b].shape),
        )

        np.testing.assert_allclose(
            new_h[o_b, o_a],
            np.zeros(h[:n_b, :n_a].shape),
        )

        np.testing.assert_allclose(
            new_h[o_a, v_b],
            np.zeros(h[:n_a, n_b:l // 2].shape),
        )

        np.testing.assert_allclose(
            new_h[v_b, o_a],
            np.zeros(h[n_b:l // 2, :n_a].shape),
        )

        np.testing.assert_allclose(
            new_h[o_b, v_a],
            np.zeros(h[:n_b, n_a:l // 2].shape),
        )

        np.testing.assert_allclose(
            new_h[v_a, o_b],
            np.zeros(h[n_a:l // 2, :n_b].shape),
        )

        np.testing.assert_allclose(
            new_h[v_a, v_b],
            np.zeros(h[n_a:l // 2, n_b:l // 2].shape),
        )

        np.testing.assert_allclose(
            new_h[v_b, v_a],
            np.zeros(h[n_b:l // 2, n_a:l // 2].shape),
        )