示例#1
0
    def test_two_by_two_spinful_phs(self):
        hubbard_model = fermi_hubbard(
            self.x_dimension, self.y_dimension, self.tunneling, self.coulomb,
            self.chemical_potential, self.magnetic_field,
            self.periodic, self.spinless, False)

        hubbard_model_phs = fermi_hubbard(
            self.x_dimension, self.y_dimension, self.tunneling, self.coulomb,
            self.chemical_potential, self.magnetic_field,
            self.periodic, self.spinless, True)

        # Compute difference between the models with and without
        # spin symmetry.
        difference = hubbard_model_phs - hubbard_model

        # Check constant term in difference.
        self.assertAlmostEqual(difference.terms[()], 1.0)

        # Check up spin on site terms in difference.
        self.assertAlmostEqual(difference.terms[((0, 1), (0, 0))], -.50)
        self.assertAlmostEqual(difference.terms[((2, 1), (2, 0))], -.50)
        self.assertAlmostEqual(difference.terms[((4, 1), (4, 0))], -.50)
        self.assertAlmostEqual(difference.terms[((6, 1), (6, 0))], -.50)

        # Check down spin on site terms in difference.
        self.assertAlmostEqual(difference.terms[((1, 1), (1, 0))], -.50)
        self.assertAlmostEqual(difference.terms[((3, 1), (3, 0))], -.50)
        self.assertAlmostEqual(difference.terms[((5, 1), (5, 0))], -.50)
        self.assertAlmostEqual(difference.terms[((7, 1), (7, 0))], -.50)
示例#2
0
    def test_two_by_two_spinless_periodic_rudimentary(self):
        hubbard_model = fermi_hubbard(
            self.x_dimension, self.y_dimension, self.tunneling, self.coulomb,
            self.chemical_potential, self.magnetic_field,
            periodic=True, spinless=True, particle_hole_symmetry=False)

        hubbard_model = fermi_hubbard(
            self.x_dimension, self.y_dimension, self.tunneling, self.coulomb,
            self.chemical_potential, self.magnetic_field,
            periodic=True, spinless=True, particle_hole_symmetry=True)
    def setUp(self):
        self.x_dimension = 2
        self.y_dimension = 3

        # Create a Hamiltonian with nearest-neighbor hopping terms
        self.ferm_op = fermi_hubbard(self.x_dimension, self.y_dimension, 1.,
                                     0., 0., 0., False, True)

        # Get the ground energy and ground state
        self.ferm_op_sparse = get_sparse_operator(self.ferm_op)
        self.ferm_op_ground_energy, self.ferm_op_ground_state = (
            get_ground_state(self.ferm_op_sparse))

        # Transform the FermionOperator to a QubitOperator
        self.transformed_op = verstraete_cirac_2d_square(
            self.ferm_op,
            self.x_dimension,
            self.y_dimension,
            add_auxiliary_hamiltonian=True,
            snake=False)

        # Get the ground energy and state of the transformed operator
        self.transformed_sparse = get_sparse_operator(self.transformed_op)
        self.transformed_ground_energy, self.transformed_ground_state = (
            get_ground_state(self.transformed_sparse))
    def setUp(self):
        self.x_dimension = 6
        self.y_dimension = 6

        # Create a Hubbard Hamiltonian
        self.ferm_op = fermi_hubbard(self.x_dimension, self.y_dimension, 1.0,
                                     4.0, 0.0, 0.0, False, True)

        # Transform the FermionOperator to a QubitOperator without including
        # the auxiliary Hamiltonian
        self.transformed_op_no_aux = verstraete_cirac_2d_square(
            self.ferm_op,
            self.x_dimension,
            self.y_dimension,
            add_auxiliary_hamiltonian=False,
            snake=False)
        self.transformed_op_no_aux.compress()

        # Transform the FermionOperator to a QubitOperator, including
        # the auxiliary Hamiltonian
        self.transformed_op_aux = verstraete_cirac_2d_square(
            self.ferm_op,
            self.x_dimension,
            self.y_dimension,
            add_auxiliary_hamiltonian=True,
            snake=False)
        self.transformed_op_aux.compress()
示例#5
0
    def test_fermion_operator_hermitian(self):
        op = FermionOperator('0^ 1 2^ 3')
        op += FermionOperator('3^ 2 1^ 0')
        self.assertTrue(is_hermitian(op))

        op = fermi_hubbard(2, 2, 1., 1.)
        self.assertTrue(is_hermitian(op))
示例#6
0
    def test_get_ground_state_rdm_from_qubit_op(self):
        # Given
        n_sites = 2
        U = 5.0
        fhm = fermi_hubbard(
            x_dimension=n_sites,
            y_dimension=1,
            tunneling=1.0,
            coulomb=U,
            chemical_potential=U / 2,
            magnetic_field=0,
            periodic=False,
            spinless=False,
            particle_hole_symmetry=False,
        )
        fhm_qubit = jordan_wigner(fhm)
        fhm_int = get_interaction_operator(fhm)
        e, wf = jw_get_ground_state_at_particle_number(
            get_sparse_operator(fhm), n_sites
        )

        # When
        rdm = get_ground_state_rdm_from_qubit_op(
            qubit_operator=fhm_qubit, n_particles=n_sites
        )

        # Then
        self.assertAlmostEqual(e, rdm.expectation(fhm_int))
示例#7
0
def test_fermi_hubbard_2x2_spinless():
    hubbard_model = fermi_hubbard(2,
                                  2,
                                  1.0,
                                  4.0,
                                  chemical_potential=0.5,
                                  spinless=True)
    assert str(hubbard_model).strip() == """
-0.5 [0^ 0] +
4.0 [0^ 0 1^ 1] +
4.0 [0^ 0 2^ 2] +
-1.0 [0^ 1] +
-1.0 [0^ 2] +
-1.0 [1^ 0] +
-0.5 [1^ 1] +
4.0 [1^ 1 3^ 3] +
-1.0 [1^ 3] +
-1.0 [2^ 0] +
-0.5 [2^ 2] +
4.0 [2^ 2 3^ 3] +
-1.0 [2^ 3] +
-1.0 [3^ 1] +
-1.0 [3^ 2] +
-0.5 [3^ 3]
""".strip()
示例#8
0
 def test_three_by_two_spinless_periodic_rudimentary(self):
     hubbard_model = fermi_hubbard(
         3, 2, self.tunneling, self.coulomb,
         self.chemical_potential, self.magnetic_field,
         periodic=True, spinless=True, particle_hole_symmetry=False)
     # Check up top/bottom hopping terms.
     self.assertAlmostEqual(hubbard_model.terms[((2, 1), (0, 0))],
                            -self.tunneling)
示例#9
0
    def test_sum_of_ordered_terms_equals_full_hamiltonian_odd_side_len(self):
        hamiltonian = normal_ordered(
            fermi_hubbard(5, 5, 1.0, -0.3, periodic=False))
        hamiltonian.compress()

        terms = simulation_ordered_grouped_hubbard_terms_with_info(
            hamiltonian)[0]
        terms_total = sum(terms, FermionOperator.zero())

        self.assertTrue(terms_total == hamiltonian)
示例#10
0
    def test_two_by_two_spinful(self):

        # Initialize the Hamiltonians.
        hubbard_model = fermi_hubbard(self.x_dimension, self.y_dimension,
                                      self.tunneling, self.coulomb,
                                      self.chemical_potential,
                                      self.magnetic_field, self.periodic,
                                      self.spinless, False)

        # Check up spin on site terms.
        self.assertAlmostEqual(hubbard_model.terms[((0, 1), (0, 0))], -.75)
        self.assertAlmostEqual(hubbard_model.terms[((2, 1), (2, 0))], -.75)
        self.assertAlmostEqual(hubbard_model.terms[((4, 1), (4, 0))], -.75)
        self.assertAlmostEqual(hubbard_model.terms[((6, 1), (6, 0))], -.75)

        # Check down spin on site terms.
        self.assertAlmostEqual(hubbard_model.terms[((1, 1), (1, 0))], .25)
        self.assertAlmostEqual(hubbard_model.terms[((3, 1), (3, 0))], .25)
        self.assertAlmostEqual(hubbard_model.terms[((5, 1), (5, 0))], .25)
        self.assertAlmostEqual(hubbard_model.terms[((7, 1), (7, 0))], .25)

        # Check up right/left hopping terms.
        self.assertAlmostEqual(hubbard_model.terms[((0, 1), (2, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((2, 1), (0, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((4, 1), (6, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((6, 1), (4, 0))], -2.)

        # Check up top/bottom hopping terms.
        self.assertAlmostEqual(hubbard_model.terms[((0, 1), (4, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((4, 1), (0, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((2, 1), (6, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((6, 1), (2, 0))], -2.)

        # Check down right/left hopping terms.
        self.assertAlmostEqual(hubbard_model.terms[((1, 1), (3, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((3, 1), (1, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((5, 1), (7, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((7, 1), (5, 0))], -2.)

        # Check down top/bottom hopping terms.
        self.assertAlmostEqual(hubbard_model.terms[((1, 1), (5, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((5, 1), (1, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((3, 1), (7, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((7, 1), (3, 0))], -2.)

        # Check on site interaction term.
        self.assertAlmostEqual(
            hubbard_model.terms[((0, 1), (0, 0), (1, 1), (1, 0))], 1.)
        self.assertAlmostEqual(
            hubbard_model.terms[((2, 1), (2, 0), (3, 1), (3, 0))], 1.)
        self.assertAlmostEqual(
            hubbard_model.terms[((4, 1), (4, 0), (5, 1), (5, 0))], 1.)
        self.assertAlmostEqual(
            hubbard_model.terms[((6, 1), (6, 0), (7, 1), (7, 0))], 1.)
示例#11
0
def test_fermi_hubbard_square_special_general_equivalence(
        x_dimension, y_dimension, tunneling, coulomb,
        chemical_potential, spinless, periodic, magnetic_field):
    hubbard_model_special = fermi_hubbard(
            x_dimension, y_dimension, tunneling, coulomb,
            chemical_potential=chemical_potential, spinless=spinless,
            periodic=periodic, magnetic_field=magnetic_field)
    hubbard_model_general = fermi_hubbard_from_general(
            x_dimension, y_dimension, tunneling, coulomb,
            chemical_potential=chemical_potential, spinless=spinless,
            periodic=periodic, magnetic_field=magnetic_field)
    assert hubbard_model_special == hubbard_model_general
示例#12
0
    def test_total_length_odd_side_length_full_hubbard(self):
        hamiltonian = normal_ordered(
            fermi_hubbard(5, 5, -1., -0.3, periodic=False))
        hamiltonian.compress()

        # Unpack result into terms, indices they act on, and whether they're
        # hopping operators.
        result = simulation_ordered_grouped_hubbard_terms_with_info(
            hamiltonian)
        terms, _, _ = result

        self.assertEqual(len(terms), 105)
示例#13
0
    def test_total_length_even_side_length_onsite_only(self):
        hamiltonian = normal_ordered(
            fermi_hubbard(4, 4, 0., -0.3, periodic=False))
        hamiltonian.compress()

        # Unpack result into terms, indices they act on, and whether they're
        # hopping operators.
        result = simulation_ordered_grouped_hubbard_terms_with_info(
            hamiltonian)
        terms, indices, is_hopping = result

        self.assertEqual(len(terms), 16)
示例#14
0
    def test_sum_of_ordered_terms_equals_full_side_length_2_hopping_only(self):
        hamiltonian = normal_ordered(
            fermi_hubbard(2, 2, 1., 0.0, periodic=False))
        hamiltonian.compress()

        # Unpack result into terms, indices they act on, and whether they're
        # hopping operators.
        result = simulation_ordered_grouped_hubbard_terms_with_info(
            hamiltonian)
        terms, _, _ = result

        terms_total = sum(terms, FermionOperator.zero())

        self.assertTrue(terms_total == hamiltonian)
示例#15
0
    def test_error_bound_using_info_even_side_length(self):
        # Generate the Hamiltonian.
        hamiltonian = normal_ordered(
            fermi_hubbard(4, 4, 0.5, 0.2, periodic=False))
        hamiltonian.compress()

        # Unpack result into terms, indices they act on, and whether they're
        # hopping operators.
        result = simulation_ordered_grouped_hubbard_terms_with_info(
            hamiltonian)
        terms, indices, is_hopping = result

        self.assertAlmostEqual(
            low_depth_second_order_trotter_error_bound(terms, indices,
                                                       is_hopping), 13.59)
    def test_restrict_interaction_hamiltonian(self):
        """Test restricting a coulomb repulsion Hamiltonian to a specified
        Sz manifold."""
        x_dim = 3
        y_dim = 2

        interaction_term = fermi_hubbard(x_dim, y_dim, 0., 1.)
        interaction_sparse = get_sparse_operator(interaction_term)
        sz_value = 2
        interaction_restricted = jw_sz_restrict_operator(interaction_sparse,
                                                         sz_value)
        restricted_interaction_values = set([
            int(value.real) for value in interaction_restricted.diagonal()])
        # Originally the eigenvalues run from 0 to 6 but after restricting,
        # they should run from 0 to 2
        self.assertEqual(restricted_interaction_values, {0, 1, 2})
示例#17
0
    def test_is_hopping_operator_terms_with_info(self):
        hamiltonian = normal_ordered(
            fermi_hubbard(5, 5, 1., -1., periodic=False))
        hamiltonian.compress()

        # Unpack result into terms, indices they act on, and whether they're
        # hopping operators.
        result = simulation_ordered_grouped_hubbard_terms_with_info(
            hamiltonian)
        terms, _, is_hopping = result

        for i in range(len(terms)):
            single_term = list(terms[i].terms)[0]
            is_hopping_term = not (single_term[1][1]
                                   or single_term[0][0] == single_term[1][0])
            self.assertEqual(is_hopping_term, is_hopping[i])
示例#18
0
    def test_strong_interaction_hubbard_VT_order_gives_larger_error(self):
        hamiltonian = normal_ordered(fermi_hubbard(4, 4, 1., 10.0))

        TV_error_operator = (
            split_operator_trotter_error_operator_diagonal_two_body(
                hamiltonian, order='T+V'))
        TV_error_bound = numpy.sum(
            numpy.absolute(list(TV_error_operator.terms.values())))

        VT_error_operator = (
            split_operator_trotter_error_operator_diagonal_two_body(
                hamiltonian, order='V+T'))
        VT_error_bound = numpy.sum(
            numpy.absolute(list(VT_error_operator.terms.values())))

        self.assertGreater(VT_error_bound, TV_error_bound)
示例#19
0
    def test_hubbard(self):
        x_dim = 4
        y_dim = 5
        tunneling = 2.
        coulomb = 3.
        chemical_potential = 7.
        magnetic_field = 11.
        periodic = False

        hubbard_model = fermi_hubbard(x_dim, y_dim, tunneling, coulomb,
                                      chemical_potential, magnetic_field,
                                      periodic)

        self.assertTrue(
            jordan_wigner(hubbard_model) == jordan_wigner(
                get_diagonal_coulomb_hamiltonian(hubbard_model)))
示例#20
0
    def test_intermediate_interaction_hubbard_TV_order_has_larger_error(self):
        hamiltonian = normal_ordered(fermi_hubbard(4, 4, 1., 4.0))

        TV_error_operator = (
            split_operator_trotter_error_operator_diagonal_two_body(
                hamiltonian, order='T+V'))
        TV_error_bound = numpy.sum(
            numpy.absolute(list(TV_error_operator.terms.values())))

        VT_error_operator = (
            split_operator_trotter_error_operator_diagonal_two_body(
                hamiltonian, order='V+T'))
        VT_error_bound = numpy.sum(
            numpy.absolute(list(VT_error_operator.terms.values())))

        self.assertAlmostEqual(TV_error_bound, 1706.66666666666)
        self.assertAlmostEqual(VT_error_bound, 1365.33333333333)
示例#21
0
    def test_two_by_two_spinless(self):

        # Initialize the Hamiltonian.
        hubbard_model = fermi_hubbard(self.x_dimension,
                                      self.y_dimension,
                                      self.tunneling,
                                      self.coulomb,
                                      self.chemical_potential,
                                      self.magnetic_field,
                                      self.periodic,
                                      spinless=True)

        # Check on site terms and magnetic field.
        self.assertAlmostEqual(hubbard_model.terms[((0, 1), (0, 0))], -0.25)
        self.assertAlmostEqual(hubbard_model.terms[((1, 1), (1, 0))], -0.25)
        self.assertAlmostEqual(hubbard_model.terms[((2, 1), (2, 0))], -0.25)
        self.assertAlmostEqual(hubbard_model.terms[((3, 1), (3, 0))], -0.25)

        # Check right/left hopping terms.
        self.assertAlmostEqual(hubbard_model.terms[((0, 1), (1, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((1, 1), (0, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((3, 1), (2, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((2, 1), (3, 0))], -2.)

        # Check top/bottom hopping terms.
        self.assertAlmostEqual(hubbard_model.terms[((0, 1), (2, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((2, 1), (0, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((3, 1), (1, 0))], -2.)
        self.assertAlmostEqual(hubbard_model.terms[((1, 1), (3, 0))], -2.)

        # Check left/right Coulomb terms.
        self.assertAlmostEqual(
            hubbard_model.terms[((0, 1), (0, 0), (1, 1), (1, 0))], 1.)
        self.assertAlmostEqual(
            hubbard_model.terms[((2, 1), (2, 0), (3, 1), (3, 0))], 1.)

        # Check top/bottom Coulomb terms.
        self.assertAlmostEqual(
            hubbard_model.terms[((0, 1), (0, 0), (2, 1), (2, 0))], 1.)
        self.assertAlmostEqual(
            hubbard_model.terms[((1, 1), (1, 0), (3, 1), (3, 0))], 1.)

        # Check that there are no other Coulomb terms.
        self.assertNotIn(((0, 1), (0, 0), (3, 1), (3, 0)), hubbard_model.terms)
        self.assertNotIn(((1, 1), (1, 0), (2, 1), (2, 0)), hubbard_model.terms)
示例#22
0
    def test_correct_indices_terms_with_info(self):
        hamiltonian = normal_ordered(
            fermi_hubbard(5, 5, 1., -1., periodic=False))
        hamiltonian.compress()

        # Unpack result into terms, indices they act on, and whether they're
        # hopping operators.
        result = simulation_ordered_grouped_hubbard_terms_with_info(
            hamiltonian)
        terms, indices, _ = result

        for i in range(len(terms)):
            term = list(terms[i].terms)
            term_indices = set()
            for single_term in term:
                term_indices = term_indices.union(
                    [single_term[j][0] for j in range(len(single_term))])
            self.assertEqual(term_indices, indices[i])
示例#23
0
def set_1D_hubbard(x_dim):
    """ Returns a 1D Fermi-Hubbard Hamiltonian.
    """
    y_dim = 1
    tunneling = 1.0
    coulomb = 1.0
    magnetic_field = 0.0
    chemical_potential = 0.0
    periodic = False
    spinless = False

    num_orbitals = 2 * x_dim * y_dim

    hubbard_model = fermi_hubbard(x_dim, y_dim, tunneling, coulomb,
                                  chemical_potential, magnetic_field, periodic,
                                  spinless)

    return hubbard_model, num_orbitals
    def setUp(self):
        # Set up molecule.
        geometry = [('Li', (0., 0., 0.)), ('H', (0., 0., 1.45))]
        basis = 'sto-3g'
        multiplicity = 1
        filename = os.path.join(THIS_DIRECTORY, 'data',
                                'H1-Li1_sto-3g_singlet_1.45')
        self.molecule = MolecularData(
            geometry, basis, multiplicity, filename=filename)
        self.molecule.load()

        # Get molecular Hamiltonian.
        self.molecular_hamiltonian = self.molecule.get_molecular_hamiltonian()

        self.hubbard_hamiltonian = fermi_hubbard(
            2, 2, 1.0, 4.0,
            chemical_potential=.2,
            magnetic_field=0.0,
            spinless=False)
示例#25
0
    def test_hubbard_trotter_error_matches_low_depth_trotter_error(self):
        hamiltonian = normal_ordered(fermi_hubbard(3, 3, 1., 2.3))

        error_operator = (
            fermionic_swap_trotter_error_operator_diagonal_two_body(
                hamiltonian))
        error_operator.compress()

        # Unpack result into terms, indices they act on, and whether
        # they're hopping operators.
        result = simulation_ordered_grouped_low_depth_terms_with_info(
            hamiltonian)
        terms, indices, is_hopping = result

        old_error_operator = low_depth_second_order_trotter_error_operator(
            terms, indices, is_hopping, jellium_only=True)

        old_error_operator -= error_operator
        self.assertEqual(old_error_operator, FermionOperator.zero())
示例#26
0
def test_fermi_hubbard_2x3_spinless():
    hubbard_model = fermi_hubbard(2,
                                  3,
                                  1.0,
                                  4.0,
                                  chemical_potential=0.5,
                                  spinless=True)
    assert str(hubbard_model).strip() == """
-0.5 [0^ 0] +
4.0 [0^ 0 1^ 1] +
4.0 [0^ 0 2^ 2] +
-1.0 [0^ 1] +
-1.0 [0^ 2] +
-1.0 [0^ 4] +
-1.0 [1^ 0] +
-0.5 [1^ 1] +
4.0 [1^ 1 3^ 3] +
-1.0 [1^ 3] +
-1.0 [1^ 5] +
-1.0 [2^ 0] +
-0.5 [2^ 2] +
4.0 [2^ 2 3^ 3] +
4.0 [2^ 2 4^ 4] +
-1.0 [2^ 3] +
-1.0 [2^ 4] +
-1.0 [3^ 1] +
-1.0 [3^ 2] +
-0.5 [3^ 3] +
4.0 [3^ 3 5^ 5] +
-1.0 [3^ 5] +
-1.0 [4^ 0] +
-1.0 [4^ 2] +
-0.5 [4^ 4] +
4.0 [4^ 4 0^ 0] +
4.0 [4^ 4 5^ 5] +
-1.0 [4^ 5] +
-1.0 [5^ 1] +
-1.0 [5^ 3] +
-1.0 [5^ 4] +
-0.5 [5^ 5] +
4.0 [5^ 5 1^ 1]
""".strip()
示例#27
0
def test_fermi_hubbard_3x2_spinless():
    hubbard_model = fermi_hubbard(3,
                                  2,
                                  1.0,
                                  4.0,
                                  chemical_potential=0.5,
                                  spinless=True)
    assert str(hubbard_model).strip() == """
-0.5 [0^ 0] +
4.0 [0^ 0 1^ 1] +
4.0 [0^ 0 3^ 3] +
-1.0 [0^ 1] +
-1.0 [0^ 2] +
-1.0 [0^ 3] +
-1.0 [1^ 0] +
-0.5 [1^ 1] +
4.0 [1^ 1 2^ 2] +
4.0 [1^ 1 4^ 4] +
-1.0 [1^ 2] +
-1.0 [1^ 4] +
-1.0 [2^ 0] +
-1.0 [2^ 1] +
-0.5 [2^ 2] +
4.0 [2^ 2 0^ 0] +
4.0 [2^ 2 5^ 5] +
-1.0 [2^ 5] +
-1.0 [3^ 0] +
-0.5 [3^ 3] +
4.0 [3^ 3 4^ 4] +
-1.0 [3^ 4] +
-1.0 [3^ 5] +
-1.0 [4^ 1] +
-1.0 [4^ 3] +
-0.5 [4^ 4] +
4.0 [4^ 4 5^ 5] +
-1.0 [4^ 5] +
-1.0 [5^ 2] +
-1.0 [5^ 3] +
-1.0 [5^ 4] +
-0.5 [5^ 5] +
4.0 [5^ 5 3^ 3]
""".strip()
示例#28
0
def test_fermi_hubbard_3x1_spinless():
    hubbard_model = fermi_hubbard(3,
                                  1,
                                  1.0,
                                  4.0,
                                  chemical_potential=0.5,
                                  spinless=True)
    assert str(hubbard_model).strip() == """
-0.5 [0^ 0] +
4.0 [0^ 0 1^ 1] +
-1.0 [0^ 1] +
-1.0 [0^ 2] +
-1.0 [1^ 0] +
-0.5 [1^ 1] +
4.0 [1^ 1 2^ 2] +
-1.0 [1^ 2] +
-1.0 [2^ 0] +
-1.0 [2^ 1] +
-0.5 [2^ 2] +
4.0 [2^ 2 0^ 0]
""".strip()
示例#29
0
def test_fermi_hubbard_2x2_spinful_phs():
    hubbard_model = fermi_hubbard(2,
                                  2,
                                  1.0,
                                  4.0,
                                  chemical_potential=0.5,
                                  magnetic_field=0.3,
                                  spinless=False,
                                  particle_hole_symmetry=True)
    assert str(hubbard_model).strip() == """
4.0 [] +
-2.8 [0^ 0] +
4.0 [0^ 0 1^ 1] +
-1.0 [0^ 2] +
-1.0 [0^ 4] +
-2.2 [1^ 1] +
-1.0 [1^ 3] +
-1.0 [1^ 5] +
-1.0 [2^ 0] +
-2.8 [2^ 2] +
4.0 [2^ 2 3^ 3] +
-1.0 [2^ 6] +
-1.0 [3^ 1] +
-2.2 [3^ 3] +
-1.0 [3^ 7] +
-1.0 [4^ 0] +
-2.8 [4^ 4] +
4.0 [4^ 4 5^ 5] +
-1.0 [4^ 6] +
-1.0 [5^ 1] +
-2.2 [5^ 5] +
-1.0 [5^ 7] +
-1.0 [6^ 2] +
-1.0 [6^ 4] +
-2.8 [6^ 6] +
4.0 [6^ 6 7^ 7] +
-1.0 [7^ 3] +
-1.0 [7^ 5] +
-2.2 [7^ 7]
""".strip()
示例#30
0
def test_fermi_hubbard_2x2_spinful_aperiodic():
    hubbard_model = fermi_hubbard(2,
                                  2,
                                  1.0,
                                  4.0,
                                  chemical_potential=0.5,
                                  magnetic_field=0.3,
                                  spinless=False,
                                  periodic=False)
    assert str(hubbard_model).strip() == """
-0.8 [0^ 0] +
4.0 [0^ 0 1^ 1] +
-1.0 [0^ 2] +
-1.0 [0^ 4] +
-0.2 [1^ 1] +
-1.0 [1^ 3] +
-1.0 [1^ 5] +
-1.0 [2^ 0] +
-0.8 [2^ 2] +
4.0 [2^ 2 3^ 3] +
-1.0 [2^ 6] +
-1.0 [3^ 1] +
-0.2 [3^ 3] +
-1.0 [3^ 7] +
-1.0 [4^ 0] +
-0.8 [4^ 4] +
4.0 [4^ 4 5^ 5] +
-1.0 [4^ 6] +
-1.0 [5^ 1] +
-0.2 [5^ 5] +
-1.0 [5^ 7] +
-1.0 [6^ 2] +
-1.0 [6^ 4] +
-0.8 [6^ 6] +
4.0 [6^ 6 7^ 7] +
-1.0 [7^ 3] +
-1.0 [7^ 5] +
-0.2 [7^ 7]
""".strip()