Ejemplo n.º 1
0
    def test_get_molecular_operator(self):
        coefficient = 3.
        operators = ((2, 1), (3, 0), (0, 0), (3, 1))
        op = FermionOperator(operators, coefficient)

        molecular_operator = get_interaction_operator(op)
        fermion_operator = get_fermion_operator(molecular_operator)
        fermion_operator = normal_ordered(fermion_operator)
        self.assertTrue(normal_ordered(op) == fermion_operator)
Ejemplo n.º 2
0
 def test_get_interaction_operator_nonmolecular_term(self):
     with self.assertRaises(InteractionOperatorError):
         get_interaction_operator(FermionOperator('3^ 2 1'))
Ejemplo n.º 3
0
 def test_get_interaction_operator_bad_2body_term(self):
     with self.assertRaises(InteractionOperatorError):
         get_interaction_operator(FermionOperator('3^ 2 1 0'))
Ejemplo n.º 4
0
 def test_get_interaction_operator_too_few_qubits(self):
     with self.assertRaises(ValueError):
         get_interaction_operator(FermionOperator('3^ 2^ 1 0'), 3)
Ejemplo n.º 5
0
 def test_get_interaction_operator_bad_input(self):
     with self.assertRaises(TypeError):
         get_interaction_operator('3')