示例#1
0
def test_electronic_structure_modification_in_place():
    """Test that ElectronicStructure instances can be modified in-place"""
    struct = ElectronicStructure({"1s": 2, "2s": 2, "2p": 4})
    expected = ElectronicStructure({"1s": 2, "2s": 2, "2p": 3, "4s": 1})
    struct["2p"] -= 1
    struct["4s"] += 1
    assert struct == expected
示例#2
0
 def test_modification_in_place(self):
     """ Test that ElectronicStructure instances can be modified in-place """
     struct = ElectronicStructure({"1s": 2, "2s": 2, "2p": 4})
     expected = ElectronicStructure({"1s": 2, "2s": 2, "2p": 3, "4s": 1})
     struct["2p"] -= 1
     struct["4s"] += 1
     self.assertEqual(struct, expected)
示例#3
0
    def test_valence_shell(self):
        """ Test that the outermost shell is as expected """
        struct = ElectronicStructure({"1s": 2})
        self.assertEqual(struct.outer_shell, Orbital("1s"))

        # Intentionally omitting 2s
        struct = ElectronicStructure({"1s": 2, "2p": 4})
        self.assertEqual(struct.outer_shell, Orbital("2p"))
示例#4
0
def test_electronic_structure_valence_shell():
    """Test that the outermost shell is as expected"""
    struct = ElectronicStructure({"1s": 2})
    assert struct.outer_shell == Orbital("1s")

    # Intentionally omitting 2s
    struct = ElectronicStructure({"1s": 2, "2p": 4})
    assert struct.outer_shell == Orbital("2p")
示例#5
0
 def test_orbital_keys(self):
     """ Test that orbital occupancies can be accessed either with strings or Orbital """
     struct = ElectronicStructure.ground_state("He")
     self.assertEqual(struct["1s"], struct[Orbital.one_s])
示例#6
0
 def test_missing_orbital(self):
     """ Test that 'missing' orbitals will return 0 electrons """
     struct = ElectronicStructure.ground_state("He")
     self.assertEqual(struct["2p"], 0)
示例#7
0
 def test_pickable(self):
     """ Test that ElectronicStructure instances are pickable. """
     structure = ElectronicStructure.ground_state("W")
     self.assertEqual(structure, pickle.loads(pickle.dumps(structure)))
示例#8
0
 def test_maximum_electrons(self):
     """ Test that an error is raised for impossible electronic structures. """
     with self.assertRaises(ValueError):
         ElectronicStructure({"1s": 3})
示例#9
0
def test_electronic_structure_orbital_keys():
    """Test that orbital occupancies can be accessed either with strings or Orbital"""
    struct = ElectronicStructure.ground_state("He")
    assert struct["1s"] == struct[Orbital.one_s]
示例#10
0
def test_electronic_structure_missing_orbital():
    """Test that 'missing' orbitals will return 0 electrons"""
    struct = ElectronicStructure.ground_state("He")
    assert struct["2p"] == 0
示例#11
0
def test_electronic_structure_pickable():
    """Test that ElectronicStructure instances are pickable."""
    structure = ElectronicStructure.ground_state("W")
    assert structure == pickle.loads(pickle.dumps(structure))
示例#12
0
def test_electronic_structure_maximum_electrons():
    """Test that an error is raised for impossible electronic structures."""
    with pytest.raises(ValueError):
        ElectronicStructure({"1s": 3})