Exemple #1
0
def zero_transform(string0: int, unocc: int, occ: int, norb: int) -> bool:
    """Given a bitstring, determine if it satisfies the occupation and
    nonoccupation conditions necessary to be non zero when a product of creation
    and annihilation operators are applied.

    Args:
        string0 (bitstring) - the occupation representation being acted upon
        unocc (bitstring) - orbitals which should be unoccupied in string0
        occ (bitstring) - orbitals which should be occupied in string0
        norb (int) - the number of spatial orbitals for masking the bitstrings

    Returns:
        (bool) - true if the transformation is non zero, false if the
            transformation is zero
    """
    if check_conserved_bits(string0, occ):
        if check_conserved_bits(invert_bitstring_with_mask(string0, norb),
                                unocc):
            return False

    return True
 def test_check_conserved_bits_true_case(self):
     """Check for a positive conservation result
     """
     conserved = 4
     string0 = 1 + 4 + 8
     self.assertTrue(bitstring.check_conserved_bits(string0, conserved))
 def test_check_conserved_bits_false_case(self):
     """Check for a negative conservation result
     """
     conserved = 2
     string0 = 1 + 4 + 8
     self.assertFalse(bitstring.check_conserved_bits(string0, conserved))
 def test_check_conserved_bits_none(self):
     """Make sure that no bits are still conserved bits
     """
     self.assertTrue(bitstring.check_conserved_bits(0, 0))