def test_ising_model_3x3(self):
        """
        Test diagonalization of 3x3 ising model with periodic boundary conditions.

        reference: J. Phys. A: Math. Gen 33 6683 (2000).
        "Finite-size scaling in the transverse Ising model on a square lattice" by C J Hamer
        https://doi.org/10.1088/0305-4470/33/38/303

        :return:
        """

        cluster = geom.Geometry.createSquareGeometry(3,
                                                     3,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)
        # paper definition of hamiltonian differs by a factor of two from mine
        jz_critical = -2 * 0.32424925229
        h_transverse = 2 * 1.0
        spin_model = tvi.spinSystem(cluster,
                                    jx=0.0,
                                    jy=0.0,
                                    jz=jz_critical,
                                    hx=h_transverse,
                                    hy=0.0,
                                    hz=0.0,
                                    use_ryd_detunes=0)
        hamiltonian = spin_model.createH()
        eig_vals, eig_vects = spin_model.diagH(hamiltonian)
        # runner_offset the energy by the number of sites to match Hamiltonian in paper
        min_eig_per_site = eig_vals[0] / spin_model.geometry.nsites + 1
        # paper quote -0.075901188836 ... I get a difference in the 11th-12th decimal place
        # I find 38 instead of 36
        self.assertAlmostEqual(min_eig_per_site, -0.0759011888, 10)
    def test_three_by_three_xy_model(self):
        """
        Test exact diagonalization of 3x3 xy model with periodic boundary conditions

        reference: J. Phys. A: Math. Gen 32 51 (1999).
        "Finite-size scaling in the spin-1/2 xy model on a square lattice" by C J Hamer et al
        """
        cluster = geom.Geometry.createSquareGeometry(3,
                                                     3,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)
        spin_model = tvi.spinSystem(cluster,
                                    jx=-1.0,
                                    jy=-1.0,
                                    jz=0.0,
                                    hx=0.0,
                                    hy=0.0,
                                    hz=0.0,
                                    use_ryd_detunes=0)
        hamiltonian = spin_model.createH()
        eig_vals, eig_vects = spin_model.diagH(hamiltonian)
        min_eig_per_site = eig_vals[0] / spin_model.geometry.nsites
        self.assertAlmostEqual(min_eig_per_site, -1.149665828185, 12)
    def test_translational_symm_3x3(self):
        """
        Test translational symmetry by diagonalizing random 3x3 spin system with and without it
        :return:
        """
        cluster = geom.Geometry.createSquareGeometry(3,
                                                     3,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)
        jx = np.random.rand()
        jy = np.random.rand()
        jz = np.random.rand()
        hx = np.random.rand()
        hy = np.random.rand()
        hz = np.random.rand()

        # diagonalize full hamiltonian
        spin_model = tvi.spinSystem(cluster,
                                    jx,
                                    jy,
                                    jz,
                                    hx,
                                    hy,
                                    hz,
                                    use_ryd_detunes=0)
        hamiltonian_full = spin_model.createH()
        eig_vals_full, eig_vects_full = spin_model.diagH(hamiltonian_full)

        xtransl_fn = symm.getTranslFn(np.array([[1], [0]]))
        xtransl_cycles, max_cycle_len_translx = symm.findSiteCycles(
            xtransl_fn, spin_model.geometry)
        xtransl_op = spin_model.get_xform_op(xtransl_cycles)
        xtransl_op = xtransl_op

        # y-translations
        ytransl_fn = symm.getTranslFn(np.array([[0], [1]]))
        ytransl_cycles, max_cycle_len_transly = symm.findSiteCycles(
            ytransl_fn, spin_model.geometry)
        ytransl_op = spin_model.get_xform_op(ytransl_cycles)
        ytransl_op = ytransl_op

        symm_projs, kxs, kys = symm.get2DTranslationProjectors(
            xtransl_op, max_cycle_len_translx, ytransl_op,
            max_cycle_len_transly)

        eig_vals_sectors = []
        for ii, proj in enumerate(symm_projs):
            h_sector = spin_model.createH(projector=proj)
            eig_vals_sector, eig_vects_sector = spin_model.diagH(h_sector)
            eig_vals_sectors.append(eig_vals_sector)

        # why only accurate to 10 decimal places?
        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        max_diff = np.abs(eig_vals_full - eigs_all_sectors).max()

        self.assertAlmostEqual(max_diff, 0, 10)
Пример #4
0
def diag_cluster(cluster_index, cluster_data_out_fname, cluster_data_in_fname):
    with open(cluster_data_in_fname, 'rb') as f:
        data = pickle.load(f)
    cluster_list = data[1]
    cluster = cluster_list[cluster_index]

    print("cluster %d" % cluster_index)
    model = tvi.spinSystem(cluster,
                           jx=0.5,
                           jy=0.5,
                           jz=0.5,
                           hx=0,
                           hy=0,
                           hz=0,
                           use_ryd_detunes=0)
    hamiltonian = model.createH(print_results=True)
    eig_vals, eig_vects = model.diagH(hamiltonian, print_results=True)

    temps = np.logspace(-1, 0.5, 50)
    # compute expectation values
    energies = np.zeros((1, len(temps)))
    entropies = np.zeros((1, len(temps)))
    specific_heats = np.zeros((1, len(temps)))
    szsz_corrs = np.zeros((1, len(temps)))

    t_start = time.process_time()
    for jj, T in enumerate(temps):
        # calculate properties for each temperature
        energies[0, jj] = model.get_exp_vals_thermal(eig_vects, hamiltonian,
                                                     eig_vals, T, 0)
        Z = np.sum(np.exp(-eig_vals / T))
        entropies[0, jj] = (np.log(Z) + energies[0, jj] / T)
        specific_heats[0, jj] = 1. / T ** 2 * \
                                 (model.get_exp_vals_thermal(eig_vects, hamiltonian.dot(hamiltonian), eig_vals, T, 0) - energies[0, jj] ** 2)

        szsz_corrs[0, jj] = 0
        for aa in range(0, model.geometry.nsites):
            for bb in range(aa + 1, model.geometry.nsites):
                szsz_op = model.getTwoSiteOp(aa,
                                             bb,
                                             model.geometry.nsites,
                                             model.pauli_z,
                                             model.pauli_z,
                                             format="boson")
                szsz_exp = model.get_exp_vals_thermal(eig_vects, szsz_op,
                                                      eig_vals, T)
                szsz_corrs[0, jj] = szsz_corrs[0, jj] + szsz_exp

    t_end = time.process_time()
    print("Computing %d finite temperature expectation values took %0.2fs" %
          (len(temps), t_end - t_start))

    data_out = [
        cluster, eig_vals, energies, entropies, specific_heats, szsz_corrs,
        temps, model
    ]
    with open(cluster_data_out_fname, 'wb') as f:
        pickle.dump(data_out, f)
    def test_d4_symm(self):
        """
        Test d4 symmetry by diagonalizing random spin system with and without it
        :return:
        """
        cluster = geom.Geometry.createSquareGeometry(3,
                                                     3,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)
        jx = np.random.rand()
        jy = np.random.rand()
        jz = np.random.rand()
        hx = np.random.rand()
        hy = np.random.rand()
        hz = np.random.rand()

        # diagonalize full hamiltonian
        spin_model = tvi.spinSystem(cluster,
                                    jx,
                                    jy,
                                    jz,
                                    hx,
                                    hy,
                                    hz,
                                    use_ryd_detunes=0)
        hamiltonian_full = spin_model.createH()
        eig_vals_full, eig_vects_full = spin_model.diagH(hamiltonian_full)

        # use rotationl symmetry
        cx, cy = spin_model.geometry.get_center_of_mass()

        rot_fn = symm.getRotFn(4, cx=cx, cy=cy)
        rot_cycles, max_cycle_len_rot = symm.findSiteCycles(
            rot_fn, spin_model.geometry)
        rot_op = spin_model.get_xform_op(rot_cycles)

        refl_fn = symm.getReflFn(np.array([0, 1]), cx=cx, cy=cy)
        refl_cycles, max_cycle_len_ref = symm.findSiteCycles(
            refl_fn, spin_model.geometry)
        refl_op = spin_model.get_xform_op(refl_cycles)

        symm_projs = symm.getD4Projectors(rot_op, refl_op)

        eig_vals_sectors = []
        for ii, proj in enumerate(symm_projs):
            h_sector = spin_model.createH(projector=proj)
            eig_vals_sector, eig_vects_sector = spin_model.diagH(h_sector)
            eig_vals_sectors.append(eig_vals_sector)

        # why only accurate to 10 decimal places?
        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        max_diff = np.abs(eig_vals_full - eigs_all_sectors).max()

        self.assertAlmostEqual(max_diff, 0, 10)
    def test_four_by_four_xy_model_symm(self):
        """
        Test exact diagonalization of 4x4 xy model with periodic boundary conditions

        reference: J. Phys. A: Math. Gen 32 51 (1999).
        "Finite-size scaling in the spin-1/2 xy model on a square lattice" by C J Hamer et al
        """

        cluster = geom.Geometry.createSquareGeometry(4,
                                                     4,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)

        # diagonalize full hamiltonian
        spin_model = tvi.spinSystem(cluster,
                                    jx=-1.0,
                                    jy=-1.0,
                                    jz=0.0,
                                    hx=0.0,
                                    hy=0.0,
                                    hz=0.0,
                                    use_ryd_detunes=0)

        # x-translations
        xtransl_fn = symm.getTranslFn(np.array([[1], [0]]))
        xtransl_cycles, max_cycle_len_translx = symm.findSiteCycles(
            xtransl_fn, spin_model.geometry)
        xtransl_op = spin_model.get_xform_op(xtransl_cycles)
        xtransl_op = xtransl_op

        # y-translations
        ytransl_fn = symm.getTranslFn(np.array([[0], [1]]))
        ytransl_cycles, max_cycle_len_transly = symm.findSiteCycles(
            ytransl_fn, spin_model.geometry)
        ytransl_op = spin_model.get_xform_op(ytransl_cycles)
        ytransl_op = ytransl_op

        symm_projs, kxs, kys = symm.get2DTranslationProjectors(
            xtransl_op, max_cycle_len_translx, ytransl_op,
            max_cycle_len_transly)

        eig_vals_sectors = []
        hfull = spin_model.createH()
        for ii, proj in enumerate(symm_projs):
            h_sector = proj * hfull * proj.conj().transpose()
            eig_vals_sector, eig_vects_sector = spin_model.diagH(
                h_sector, print_results=True)
            eig_vals_sectors.append(eig_vals_sector)

        # why only accurate to 10 decimal places?
        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        min_eig_per_site = eigs_all_sectors[0] / spin_model.geometry.nsites
        self.assertAlmostEqual(min_eig_per_site, -1.124972697436, 12)
    def test_higher_spin(self):
        """
        Test heisenberg system with spin > 0.5
        :return:
        """
        spin = 2.5

        nx = 4
        ny = 1
        phi1 = 0
        phi2 = 0
        bc_open1 = 1
        bc_open2 = 1
        gm = geom.Geometry.createSquareGeometry(nx, ny, phi1, phi2, bc_open1,
                                                bc_open2)
        gm.dispGeometry()

        j1 = 0.3333
        j2 = 0.23623627
        j3 = 0.8434783478
        # -1 to account for difference in definitions
        js = -np.array([[0, j1, j2, j3], [j1, 0, j2, j3], [j2, j2, 0, j3],
                        [j3, j3, j3, 0]])
        ss = tvi.spinSystem(gm, jx=js, jy=js, jz=js, spin=spin)
        hamiltonian = ss.createH()

        eig_vals, eig_vects = ss.diagH(hamiltonian)

        # verify these are equal to expected result
        # E = j1 * [s1*(s1+1) + s2*(s2+1)] + j2 * s3*(s3+1) + j3 * s4*(s4+1) + (j2-j1)*s12*(s12+1) +
        # (j3-j2)*s123*(s123+1) - j3 * s1234 * (s1234 + 1)
        eigs_analytic = []
        s1 = spin
        s2 = s1
        s3 = s1
        s4 = s1
        s12s = np.arange(np.abs(s1 - s2), s1 + s2 + 1)

        for s12 in s12s:
            for s123 in np.arange(np.abs(s3 - s12), s3 + s12 + 1):
                for s1234 in np.arange(np.abs(s4 - s123), s4 + s123 + 1):
                    eig = j1 * (s1 * (s1 + 1) + s2 * (s2 + 1)) + \
                          j2 * s3 * (s3 + 1) + \
                          j3 * s4 * (s4 + 1) + \
                          (j2 - j1) * s12 * (s12 + 1) + \
                          (j3 - j2) * s123 * (s123 + 1) - \
                          j3 * s1234 * (s1234 + 1)
                    multiplicity = int(2 * s1234 + 1)
                    eigs_analytic += [eig] * multiplicity
        eigs_analytic.sort()

        max_diff = np.max(np.abs(eigs_analytic - eig_vals))
        self.assertAlmostEqual(max_diff, 0, 12)
    def test_d3_symm_6sites(self):
        adjacency_mat = np.array([[0, 1, 0, 1, 0, 0], [1, 0, 1, 1, 1, 0],
                                  [0, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1],
                                  [0, 1, 1, 1, 0, 1], [0, 0, 0, 1, 1, 0]])
        cluster = geom.Geometry.createNonPeriodicGeometry(
            xlocs=(0, 1, 2, 0.5, 1.5, 1),
            ylocs=(0, 0, 0, np.sqrt(3) / 2, np.sqrt(3) / 2, np.sqrt(3)),
            adjacency_mat=adjacency_mat)
        jx = np.random.rand()
        jy = np.random.rand()
        jz = np.random.rand()
        hx = np.random.rand()
        hy = np.random.rand()
        hz = np.random.rand()

        # diagonalize full hamiltonian
        spin_model = tvi.spinSystem(cluster,
                                    jx,
                                    jy,
                                    jz,
                                    hx,
                                    hy,
                                    hz,
                                    use_ryd_detunes=0)
        hamiltonian_full = spin_model.createH()
        eig_vals_full, eig_vects_full = spin_model.diagH(hamiltonian_full)

        # use rotationl symmetry
        # triangle center
        cx, cy = 1, 1 / np.sqrt(3)
        rot_fn = symm.getRotFn(3, cx=cx, cy=cy)
        rot_cycles, max_cycle_len_rot = symm.findSiteCycles(
            rot_fn, spin_model.geometry)
        rot_op = spin_model.get_xform_op(rot_cycles)

        refl_fn = symm.getReflFn(np.array([0, 1]), cx=cx, cy=cy)
        refl_cycles, max_cycle_len_ref = symm.findSiteCycles(
            refl_fn, spin_model.geometry)
        refl_op = spin_model.get_xform_op(refl_cycles)

        symm_projs = symm.getD3Projectors(rot_op, refl_op)

        eig_vals_sectors = []
        for ii, proj in enumerate(symm_projs):
            h_sector = spin_model.createH(projector=proj)
            eig_vals_sector, eig_vects_sector = spin_model.diagH(h_sector)
            eig_vals_sectors.append(eig_vals_sector)

        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        max_diff = np.abs(eig_vals_full - eigs_all_sectors).max()

        self.assertAlmostEqual(max_diff, 0, 12)
    def test_d3_symm_3sites(self):
        """
        Test d3 symmetry by diagonalizing random spin system with and without it
        :return:
        """
        # adjacency_mat = np.array([[0, 1, 1], [1, 0, 1], [1, 1, 0]])
        # cluster = geom.Geometry.createNonPeriodicGeometry(xlocs=(0,0.5,1), ylocs=(0,np.sqrt(3)/2,0), adjacency_mat=adjacency_mat)
        cluster = geom.Geometry.createRegularPolygonGeometry(3)
        jx = np.random.rand()
        jy = np.random.rand()
        jz = np.random.rand()
        hx = np.random.rand()
        hy = np.random.rand()
        hz = np.random.rand()

        # diagonalize full hamiltonian
        spin_model = tvi.spinSystem(cluster,
                                    jx,
                                    jy,
                                    jz,
                                    hx,
                                    hy,
                                    hz,
                                    use_ryd_detunes=0)
        hamiltonian_full = spin_model.createH()
        eig_vals_full, eig_vects_full = spin_model.diagH(hamiltonian_full)

        # use rotationl symmetry
        rot_fn = symm.getRotFn(3)
        rot_cycles, max_cycle_len_rot = symm.findSiteCycles(
            rot_fn, spin_model.geometry)
        rot_op = spin_model.get_xform_op(rot_cycles)

        refl_fn = symm.getReflFn(np.array([0, 1]))
        refl_cycles, max_cycle_len_ref = symm.findSiteCycles(
            refl_fn, spin_model.geometry)
        refl_op = spin_model.get_xform_op(refl_cycles)

        symm_projs = symm.getD3Projectors(rot_op, refl_op)

        eig_vals_sectors = []
        for ii, proj in enumerate(symm_projs):
            h_sector = spin_model.createH(projector=proj)
            eig_vals_sector, eig_vects_sector = spin_model.diagH(h_sector)
            eig_vals_sectors.append(eig_vals_sector)

        # why only accurate to 10 decimal places?
        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        max_diff = np.abs(eig_vals_full - eigs_all_sectors).max()

        self.assertAlmostEqual(max_diff, 0, 12)
Пример #10
0
    def test_d7_symm_7sites(self):

        cluster = geom.Geometry.createRegularPolygonGeometry(7)
        jx = np.random.rand()
        jy = np.random.rand()
        jz = np.random.rand()
        hx = np.random.rand()
        hy = np.random.rand()
        hz = np.random.rand()

        # diagonalize full hamiltonian
        spin_model = tvi.spinSystem(cluster,
                                    jx,
                                    jy,
                                    jz,
                                    hx,
                                    hy,
                                    hz,
                                    use_ryd_detunes=0)
        hamiltonian_full = spin_model.createH()
        eig_vals_full, eig_vects_full = spin_model.diagH(hamiltonian_full)

        # use rotationl symmetry
        rot_fn = symm.getRotFn(7)
        rot_cycles, max_cycle_len_rot = symm.findSiteCycles(
            rot_fn, spin_model.geometry)
        rot_op = spin_model.get_xform_op(rot_cycles)

        refl_fn = symm.getReflFn(np.array([0, 1]))
        refl_cycles, max_cycle_len_ref = symm.findSiteCycles(
            refl_fn, spin_model.geometry)
        refl_op = spin_model.get_xform_op(refl_cycles)

        symm_projs = symm.getD6Projectors(rot_op, refl_op)

        eig_vals_sectors = []
        for ii, proj in enumerate(symm_projs):
            h_sector = spin_model.createH(projector=proj)
            eig_vals_sector, eig_vects_sector = spin_model.diagH(h_sector)
            eig_vals_sectors.append(eig_vals_sector)

        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        max_diff = np.abs(eig_vals_full - eigs_all_sectors).max()

        self.assertAlmostEqual(max_diff, 0, 14)
Пример #11
0
    def test_full_symm_3x3(self):
        cluster = geom.Geometry.createSquareGeometry(3,
                                                     3,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)
        jx = np.random.rand()
        jy = np.random.rand()
        jz = np.random.rand()
        hx = np.random.rand()
        hy = np.random.rand()
        hz = np.random.rand()

        # diagonalize full hamiltonian
        spin_model = tvi.spinSystem(cluster,
                                    jx,
                                    jy,
                                    jz,
                                    hx,
                                    hy,
                                    hz,
                                    use_ryd_detunes=0)
        hamiltonian_full = spin_model.createH()
        eig_vals_full, eig_vects_full = spin_model.diagH(hamiltonian_full)

        xtransl_fn = symm.getTranslFn(np.array([[1], [0]]))
        xtransl_cycles, max_cycle_len_translx = symm.findSiteCycles(
            xtransl_fn, spin_model.geometry)
        tx_op = spin_model.get_xform_op(xtransl_cycles)

        # y-translations
        ytransl_fn = symm.getTranslFn(np.array([[0], [1]]))
        ytransl_cycles, max_cycle_len_transly = symm.findSiteCycles(
            ytransl_fn, spin_model.geometry)
        ty_op = spin_model.get_xform_op(ytransl_cycles)

        # rotation
        cx, cy = spin_model.geometry.get_center_of_mass()
        rot_fn = symm.getRotFn(4, cx=cx, cy=cy)
        rot_cycles, max_cycle_len_rot = symm.findSiteCycles(
            rot_fn, spin_model.geometry)
        rot_op = spin_model.get_xform_op(rot_cycles)

        # reflection
        # reflection about y-axis
        refl_fn = symm.getReflFn(np.array([0, 1]), cx=cx, cy=cy)
        refl_cycles, max_cycle_len_refl = symm.findSiteCycles(
            refl_fn, spin_model.geometry)
        refl_op = spin_model.get_xform_op(refl_cycles)

        symm_projs = symm.getC4V_and_3byb3(rot_op, refl_op, tx_op, ty_op)

        eig_vals_sectors = []
        for ii, proj in enumerate(symm_projs):
            h_sector = spin_model.createH(projector=proj)
            eig_vals_sector, eig_vects_sector = spin_model.diagH(h_sector)
            eig_vals_sectors.append(eig_vals_sector)

        # why only accurate to 10 decimal places?
        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        max_diff = np.abs(eig_vals_full - eigs_all_sectors).max()

        self.assertAlmostEqual(max_diff, 0, 10)
phi2 = 0

if nx > 1:
    bc1_open = False
else:
    bc1_open = True

if ny > 1:
    bc2_open = False
else:
    bc2_open = True

for ii, (phi1, phi2) in enumerate(zip(phi1s, phi2s)):
    gm = geom.Geometry.createSquareGeometry(nx, ny, phi1, phi2, bc1_open,
                                            bc2_open)
    ss = ed_spins.spinSystem()

    jsmat = ss.get_interaction_mat_heisenberg(gm, J)

    # build all possible symmetries
    # x-translation
    xtransl_fn = symm.getTranslFn(np.array([[1], [0]]))
    xtransl_cycles, max_cycle_len_translx = symm.findSiteCycles(xtransl_fn, gm)
    xtransl_op = ss.get_xform_op(xtransl_cycles)
    xtransl_op = xtransl_op

    # y-translations
    ytransl_fn = symm.getTranslFn(np.array([[0], [1]]))
    ytransl_cycles, max_cycle_len_transly = symm.findSiteCycles(ytransl_fn, gm)
    ytransl_op = ss.get_xform_op(ytransl_cycles)
    ytransl_op = ytransl_op
Пример #13
0
    def test_ising_model_5x5(self):
        """
        Test diagonalization of 5x5 ising model with periodic boundary conditions.

        reference: J. Phys. A: Math. Gen 33 6683 (2000).
        "Finite-size scaling in the transverse Ising model on a square lattice" by C J Hamer
        https://doi.org/10.1088/0305-4470/33/38/303

        :return:
        """

        cluster = geom.Geometry.createSquareGeometry(5,
                                                     5,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)
        # paper definition of hamiltonian differs by a factor of two from mine
        jz_critical = -2 * 0.32669593806
        h_transverse = 2 * 1.0
        spin_model = tvi.spinSystem(cluster,
                                    jx=0.0,
                                    jy=0.0,
                                    jz=jz_critical,
                                    hx=h_transverse,
                                    hy=0.0,
                                    hz=0.0,
                                    use_ryd_detunes=0)

        # symmetry swapping up/down spins
        spin_swap_op = spin_model.get_swap_up_down_op()

        # x-translations
        xtransl_fn = symm.getTranslFn(np.array([[1], [0]]))
        xtransl_cycles, max_cycle_len_translx = symm.findSiteCycles(
            xtransl_fn, spin_model.geometry)
        xtransl_op = spin_model.get_xform_op(xtransl_cycles)
        xtransl_op = xtransl_op

        # y-translations
        ytransl_fn = symm.getTranslFn(np.array([[0], [1]]))
        ytransl_cycles, max_cycle_len_transly = symm.findSiteCycles(
            ytransl_fn, spin_model.geometry)
        ytransl_op = spin_model.get_xform_op(ytransl_cycles)
        ytransl_op = ytransl_op

        symm_projs, kxs, kys = symm.get2DTranslationProjectors(
            xtransl_op, max_cycle_len_translx, ytransl_op,
            max_cycle_len_transly)

        eig_vals_sectors = []
        full_proj_list = []
        hfull = spin_model.createH()
        for ii, proj in enumerate(symm_projs):
            spin_swap_proj_op = proj * spin_swap_op * proj.conj().transpose()

            # char_table = np.array([[1, 1], [1, -1]])
            # ccs = [[sp.eye(spin_swap_proj_op.shape[0], format="csr")], [spin_swap_proj_op]]
            swap_projs, phase = symm.getZnProjectors(spin_swap_proj_op, 2)

            for jj, sproj in enumerate(swap_projs):
                full_proj_list.append(sproj * proj)

                h_sector = sproj * proj * hfull * proj.conj().transpose(
                ) * sproj.conj().transpose()
                eig_vals_sector, eig_vects_sector = spin_model.diagH(
                    h_sector, print_results=True)
                eig_vals_sectors.append(eig_vals_sector)

        # why only accurate to 10 decimal places?
        eigs_all_sectors = np.sort(np.concatenate(eig_vals_sectors))
        min_eig_per_site = eigs_all_sectors[0] / spin_model.geometry.nsites + 1

        self.assertAlmostEqual(min_eig_per_site, -0.064637823298, 11)
Пример #14
0
########################################
if not os.path.isfile(fname_full_cluster_ed):
    print("did not find file %s, diagonalizing hamiltonian" %
          fname_full_cluster_ed)
    parent_geometry = geom.Geometry.createSquareGeometry(4,
                                                         4,
                                                         0,
                                                         0,
                                                         bc1_open=False,
                                                         bc2_open=False)
    parent_geometry.permute_sites(parent_geometry.get_sorting_permutation())

    model = tvi.spinSystem(parent_geometry,
                           jx,
                           jy,
                           jz,
                           hx,
                           hy,
                           hz,
                           use_ryd_detunes=False)

    # x-translation
    tx_fn = symm.getTranslFn(np.array([[1], [0]]))
    tx_cycles, ntx = symm.findSiteCycles(tx_fn, model.geometry)
    tx_op = model.get_xform_op(tx_cycles)

    # y-translations
    ty_fn = symm.getTranslFn(np.array([[0], [1]]))
    ty_cycles, nty = symm.findSiteCycles(ty_fn, model.geometry)
    ty_op = model.get_xform_op(ty_cycles)

    # symmetry projectors
Пример #15
0
# no staggered magnetization and all correlations.
U = -4
jx = 0.5 * 4 / np.abs(U)  # 4t^2/|U|
jy = jx
jz = jx
hx = 0.
hy = 0.
hz = 2 * (-0.4)  # 2*mu - U
larmor_period = 2 * np.pi / hz
print("U = %0.2f" % U)
print("J = %0.2f" % jx)
print("hz = %0.2f" % hz)
print("larmor period_exp = %0.2f" % larmor_period)
# factor of two based on my convention for hamiltonian = 0.5 *\sum sigma*sigma * 2 * \sum spin*spin

ss = ed_spins.spinSystem(gm, jx, jy, jz, hx, hy, hz)

hamiltonian = ss.createH(projector=None, print_results=print_all)
eigvals, eigvects = ss.diagH(hamiltonian)

# useful operators
sigma_z_op = ss.get_sum_op(ss.pauli_z)
sigma_y_op = ss.get_sum_op(ss.pauli_y)
sigma_x_op = ss.get_sum_op(ss.pauli_x)
# ops on each site
sigma_z_sites = []
sigma_y_sites = []
sigma_x_sites = []
for ii in range(0, ss.geometry.nsites):
    sigma_z_sites.append(
        ss.getSingleSiteOp(ii, ss.geometry.nsites, ss.pauli_z, format="boson"))
Пример #16
0
    def test_directions_equivalent(self):
        """
        Test if all directions are equivalent for the spin system by picking three random fields and interactions_4 and
        diagonalizing all six permutations of spin systems which can be created from these. The compare their eigenvalues

        :return:
        """
        cluster = geom.Geometry.createSquareGeometry(3,
                                                     3,
                                                     0,
                                                     0,
                                                     bc1_open=False,
                                                     bc2_open=False)
        j1 = np.random.rand()
        j2 = np.random.rand()
        j3 = np.random.rand()
        h1 = np.random.rand()
        h2 = np.random.rand()
        h3 = np.random.rand()
        spin_model_list = []
        spin_model_list.append(
            tvi.spinSystem(cluster,
                           jx=j1,
                           jy=j2,
                           jz=j3,
                           hx=h1,
                           hy=h2,
                           hz=h3,
                           use_ryd_detunes=0))
        spin_model_list.append(
            tvi.spinSystem(cluster,
                           jx=j2,
                           jy=j3,
                           jz=j1,
                           hx=h2,
                           hy=h3,
                           hz=h1,
                           use_ryd_detunes=0))
        spin_model_list.append(
            tvi.spinSystem(cluster,
                           jx=j3,
                           jy=j1,
                           jz=j2,
                           hx=h3,
                           hy=h1,
                           hz=h2,
                           use_ryd_detunes=0))
        spin_model_list.append(
            tvi.spinSystem(cluster,
                           jx=j1,
                           jy=j3,
                           jz=j2,
                           hx=h1,
                           hy=h3,
                           hz=h2,
                           use_ryd_detunes=0))
        spin_model_list.append(
            tvi.spinSystem(cluster,
                           jx=j2,
                           jy=j1,
                           jz=j3,
                           hx=h2,
                           hy=h1,
                           hz=h3,
                           use_ryd_detunes=0))
        spin_model_list.append(
            tvi.spinSystem(cluster,
                           jx=j3,
                           jy=j2,
                           jz=j1,
                           hx=h3,
                           hy=h2,
                           hz=h1,
                           use_ryd_detunes=0))

        eig_vals_list = []
        for spin_model in spin_model_list:
            hamiltonian = spin_model.createH()
            eig_vals, eig_vects = spin_model.diagH(hamiltonian)
            # cannot get agreement better than 1e-10
            eig_vals_list.append(np.round(eig_vals, 10))

        n_comparisons = len(spin_model_list) - 1
        eig_val_comparisons = np.zeros(n_comparisons)
        for ii in range(0, n_comparisons):
            eig_val_comparisons[ii] = np.abs(eig_vals_list[ii] -
                                             eig_vals_list[ii + 1]).max() == 0

        self.assertTrue(np.all(eig_val_comparisons))
Пример #17
0
"""
exact digaonalization of Heisenberg system
"""

import numpy as np
import ed_geometry as geom
import ed_spins as spins
import ed_symmetry as symm

# set up system
J = 1
gm = geom.Geometry.createSquareGeometry(10, 1, 0, 0, bc1_open=False, bc2_open=True)
ss = spins.spinSystem(gm, jx=J, jy=J, jz=J)

# total sz and spin flip op
sz_op = ss.get_sum_op(ss.sz)
sz_flip_op = ss.get_swap_up_down_op()

# translation operators
xtransl_fn = symm.getTranslFn(np.array([[1], [0]]))
xtransl_cycles, ntranslations = symm.findSiteCycles(xtransl_fn, ss.geometry)
tx_op = ss.get_xform_op(xtransl_cycles)

# inversion op
cx, cy = ss.geometry.get_center_of_mass()
inv_fn = symm.getInversionFn(cx, cy)
inv_cycles, _ = symm.findSiteCycles(inv_fn, ss.geometry)
inv_op = ss.get_xform_op(inv_cycles)

# get projectors on mz subspace
mz_projs, mzs = ss.get_subspace_projs(sz_op.tocsr())
Пример #18
0
nx = 4
ny = 1
phi1 = 0
phi2 = 0
bc_open1 = 1
bc_open2 = 1
gm = geom.Geometry.createSquareGeometry(nx, ny, phi1, phi2, bc_open1, bc_open2)
gm.dispGeometry()

j1 = 0.3333
j2 = 0.23623627
j3 = 0.8434783478
# -1 to account for difference in definitions
js = -np.array([[0, j1, j2, j3], [j1, 0, j2, j3], [j2, j2, 0, j3], [j3, j3, j3, 0]])
ss = ed_spins.spinSystem(gm, jx=js, jy=js, jz=js, spin=spin)
hamiltonian = ss.createH()

eig_vals, eig_vects = ss.diagH(hamiltonian)

# verify these are equal to expected result
# E = j1 * [s1*(s1+1) + s2*(s2+1)] + j2 * s3*(s3+1) + j3 * s4*(s4+1) + (j2-j1)*s12*(s12+1) + (j3-j2)*s123*(s123+1) - j3 * s1234 * (s1234 + 1)
eigs_analytic = []
s1 = spin
s2 = s1
s3 = s1
s4 = s1
s12s = np.arange(np.abs(s1 - s2), s1 + s2 + 1)

for s12 in s12s:
    for s123 in np.arange(np.abs(s3 - s12), s3 + s12 + 1):