Beispiel #1
0
 def test_atom_type_with_topology_and_site_change_properties(self):
     site1 = Site()
     site2 = Site()
     top = Topology()
     atom_type1 = AtomType()
     atom_type2 = AtomType()
     site1.atom_type = atom_type1
     site2.atom_type = atom_type2
     top.add_site(site1)
     top.add_site(site2)
     site1.atom_type.mass = 250
     assert site2.atom_type.mass == 250
     assert top.atom_types[0].mass == 250
Beispiel #2
0
 def test_atom_type_with_topology_and_site(self):
     site1 = Site()
     site2 = Site()
     top = Topology()
     atom_type1 = AtomType()
     atom_type2 = AtomType()
     site1.atom_type = atom_type1
     site2.atom_type = atom_type2
     top.add_site(site1)
     top.add_site(site2)
     assert id(site1.atom_type) == id(site2.atom_type)
     assert site1.atom_type is not None
     assert len(top.atom_types) == 1
     assert site1.atom_type.topology == top
     assert site2.atom_type.topology == top
Beispiel #3
0
    def test_set_with_atom_type(self):
        lithium_type = AtomType(mass=6.941, charge=1)
        site = Site(name='Lithium')
        site.atom_type = lithium_type

        assert site.charge == 1 * u.elementary_charge
        assert site.mass == 6.941 * u.gram / u.mol
Beispiel #4
0
 def test_with_1000_atom_types(self):
     top = Topology()
     for i in range(1000):
         site = Site()
         atom_type = AtomType()
         site.atom_type = atom_type
         top.add_site(site, update_types=False)
     top.update_topology()
     assert len(top.atom_types) == 1
     assert top.n_sites == 1000
Beispiel #5
0
 def test_topology_atom_type_changes(self):
     top = Topology()
     for i in range(100):
         site = Site(name='site{}'.format(i))
         atom_type = AtomType(name='atom_type{}'.format(i % 10))
         site.atom_type = atom_type
         top.add_site(site, update_types=False)
     top.update_topology()
     assert len(top.atom_types) == 10
     top.sites[0].atom_type.name = 'atom_type_changed'
     assert id(top.sites[0].atom_type) == id(top.sites[10].atom_type)
     assert top.sites[10].atom_type.name == 'atom_type_changed'
     assert top.is_typed()
Beispiel #6
0
    def test_top_update(self):
        top = Topology()
        top.update_topology()
        assert top.n_sites == 0
        assert len(top.atom_types) == 0
        assert len(top.atom_type_expressions) == 0
        assert top.n_connections == 0
        assert len(top.connection_types) == 0
        assert len(top.connection_type_expressions) == 0

        atomtype = AtomType()
        site1 = Site(name='site1', atom_type=atomtype)
        top.add_site(site1)
        site2 = Site(name='site2', atom_type=atomtype)
        top.add_site(site2)

        assert top.n_sites == 2
        assert len(top.atom_types) == 1
        assert len(top.atom_type_expressions) == 1
        assert top.n_connections == 0
        assert len(top.connection_types) == 0
        assert len(top.connection_type_expressions) == 0


        ctype = BondType()
        connection_12 = Bond(connection_members=[site1, site2],
                             connection_type=ctype)
        top.add_connection(connection_12)

        assert top.n_sites == 2
        assert len(top.atom_types) == 1
        assert len(top.atom_type_expressions) == 1
        assert top.n_connections == 1
        assert len(top.connection_types) == 1
        assert len(top.connection_type_expressions) == 1

        site1.atom_type = AtomType(expression='sigma*epsilon')
        assert top.n_sites == 2
        assert len(top.atom_types) == 1
        assert len(top.atom_type_expressions) == 1
        assert top.n_connections == 1
        assert len(top.connection_types) == 1
        assert len(top.connection_type_expressions) == 1
        top.update_atom_types()
        assert top.n_sites == 2
        assert len(top.atom_types) == 2
        assert len(top.atom_type_expressions) == 2
        assert top.n_connections == 1
        assert len(top.connection_types) == 1
        assert len(top.connection_type_expressions) == 1