コード例 #1
0
ファイル: test_dihedral.py プロジェクト: mosdef-hub/gmso
 def test_dihedral_constituent_types(self):
     atom1 = Atom(name="atom1",
                  position=[0, 0, 0],
                  atom_type=AtomType(name="A"))
     atom2 = Atom(name="atom2",
                  position=[1, 0, 0],
                  atom_type=AtomType(name="B"))
     atom3 = Atom(name="atom3",
                  position=[1, 1, 0],
                  atom_type=AtomType(name="C"))
     atom4 = Atom(name="atom4",
                  position=[1, 1, 4],
                  atom_type=AtomType(name="D"))
     dihtype = DihedralType(member_types=[
         atom1.atom_type.name,
         atom2.atom_type.name,
         atom3.atom_type.name,
         atom4.atom_type.name,
     ])
     dih = Dihedral(connection_members=[atom1, atom2, atom3, atom4], )
     dih.dihedral_type = dihtype
     assert "A" in dih.connection_type.member_types
     assert "B" in dih.connection_type.member_types
     assert "C" in dih.connection_type.member_types
     assert "D" in dih.connection_type.member_types
コード例 #2
0
    def test_square(self):
        mytop = Topology()
        s1 = Atom(name="1")
        s2 = Atom(name="2")
        s3 = Atom(name="3")
        s4 = Atom(name="4")
        c12 = Bond(connection_members=[s1, s2])
        c23 = Bond(connection_members=[s2, s3])
        c34 = Bond(connection_members=[s3, s4])
        c41 = Bond(connection_members=[s4, s1])

        for site in [s1, s2, s3, s4]:
            mytop.add_site(site, update_types=False)

        for conn in [c12, c23, c34, c41]:
            mytop.add_connection(conn, update_types=False)

        assert mytop.n_bonds == 4
        assert mytop.n_angles == 0
        assert mytop.n_dihedrals == 0
        assert mytop.n_impropers == 0

        mytop.identify_connections()

        assert mytop.n_bonds == 4
        assert mytop.n_angles == 4
        assert mytop.n_dihedrals == 4
        assert mytop.n_impropers == 0
コード例 #3
0
ファイル: test_improper.py プロジェクト: mosdef-hub/gmso
 def test_improper_constituent_types(self):
     atom1 = Atom(name="atom1",
                  position=[0, 0, 0],
                  atom_type=AtomType(name="A"))
     atom2 = Atom(name="atom2",
                  position=[1, 0, 0],
                  atom_type=AtomType(name="B"))
     atom3 = Atom(name="atom3",
                  position=[1, 1, 0],
                  atom_type=AtomType(name="C"))
     atom4 = Atom(name="atom4",
                  position=[1, 1, 4],
                  atom_type=AtomType(name="D"))
     imptype = ImproperType(member_types=[
         atom1.atom_type.name,
         atom2.atom_type.name,
         atom3.atom_type.name,
         atom4.atom_type.name,
     ])
     imp = Improper(connection_members=[atom1, atom2, atom3, atom4], )
     imp.improper_type = imp.connection_type = imptype
     assert "A" in imp.connection_type.member_types
     assert "B" in imp.connection_type.member_types
     assert "C" in imp.connection_type.member_types
     assert "D" in imp.connection_type.member_types
コード例 #4
0
ファイル: test_angle.py プロジェクト: zijiewu3/gmso
 def test_angle_fake_angletype(self):
     atom1 = Atom(name='atom1')
     atom2 = Atom(name='atom2')
     atom3 = Atom(name='atom3')
     with pytest.raises(ValidationError):
         Angle(connection_members=[atom1, atom2, atom3],
               angle_type='Fake angletype')
コード例 #5
0
ファイル: test_dihedral.py プロジェクト: mosdef-hub/gmso
 def test_dihedral_fake(self):
     atom1 = Atom(name="atom1")
     atom2 = Atom(name="atom2")
     atom3 = Atom(name="atom3")
     atom4 = Atom(name="atom4")
     with pytest.raises(ValidationError):
         Dihedral(connection_members=["fakeatom1", "fakeatom2", 4.2])
コード例 #6
0
ファイル: test_improper.py プロジェクト: zijiewu3/gmso
 def test_improper_fake(self):
     atom1 = Atom(name='atom1')
     atom2 = Atom(name='atom2')
     atom3 = Atom(name='atom3')
     atom4 = Atom(name='atom4')
     with pytest.raises(ValidationError):
         Improper(connection_members=['fakeatom1', 'fakeatom2', 4.2])
コード例 #7
0
ファイル: test_angle.py プロジェクト: zijiewu3/gmso
    def test_angle_nonparametrized(self):
        atom1 = Atom(name='atom1')
        atom2 = Atom(name='atom2')
        atom3 = Atom(name='atom3')

        connect = Angle(connection_members=[atom1, atom2, atom3])
        assert connect.angle_type is None
コード例 #8
0
 def test_dihedral_fake(self):
     atom1 = Atom(name='atom1')
     atom2 = Atom(name='atom2')
     atom3 = Atom(name='atom3')
     atom4 = Atom(name='atom4')
     with pytest.raises(ValidationError):
         Dihedral(connection_members=['fakeatom1', 'fakeatom2', 4.2])
コード例 #9
0
ファイル: test_improper.py プロジェクト: mosdef-hub/gmso
 def test_improper_fake(self):
     atom1 = Atom(name="atom1")
     atom2 = Atom(name="atom2")
     atom3 = Atom(name="atom3")
     atom4 = Atom(name="atom4")
     with pytest.raises(ValidationError):
         Improper(connection_members=["fakeatom1", "fakeatom2", 4.2])
コード例 #10
0
    def test_bond_nonparametrized(self):
        atom1 = Atom(name='atom1')
        atom2 = Atom(name='atom2')

        connect = Bond(connection_members=[atom1, atom2])

        assert connect.bond_type is None
コード例 #11
0
    def test_square_with_bridge(self):
        mytop = Topology()
        s1 = Atom(name="1")
        s2 = Atom(name="2")
        s3 = Atom(name="3")
        s4 = Atom(name="4")
        c12 = Bond(connection_members=[s1, s2])
        c23 = Bond(connection_members=[s2, s3])
        c34 = Bond(connection_members=[s3, s4])
        c41 = Bond(connection_members=[s4, s1])
        c24 = Bond(connection_members=[s2, s4])

        mytop.add_site(s1, update_types=False)
        mytop.add_site(s2, update_types=False)
        mytop.add_site(s3, update_types=False)
        mytop.add_site(s4, update_types=False)

        mytop.add_connection(c12, update_types=False)
        mytop.add_connection(c23, update_types=False)
        mytop.add_connection(c34, update_types=False)
        mytop.add_connection(c41, update_types=False)
        mytop.add_connection(c24, update_types=False)

        assert mytop.n_bonds == 5
        assert mytop.n_angles == 0
        assert mytop.n_dihedrals == 0
        assert mytop.n_impropers == 0

        mytop.identify_connections()

        assert mytop.n_bonds == 5
        assert mytop.n_angles == 8
        assert mytop.n_dihedrals == 6
        assert mytop.n_impropers == 2
コード例 #12
0
 def test_dihedral_fake_dihedraltype(self):
     atom1 = Atom(name='atom1')
     atom2 = Atom(name='atom2')
     atom3 = Atom(name='atom3')
     atom4 = Atom(name='atom4')
     with pytest.raises(ValidationError):
         Dihedral(connection_members=[atom1, atom2, atom3, atom4],
                  dihedral_type='Fake dihedraltype')
コード例 #13
0
ファイル: test_improper.py プロジェクト: zijiewu3/gmso
 def test_improper_fake_impropertype(self):
     atom1 = Atom(name='atom1')
     atom2 = Atom(name='atom2')
     atom3 = Atom(name='atom3')
     atom4 = Atom(name='atom4')
     with pytest.raises(ValidationError):
         Improper(connection_members=[atom1, atom2, atom3, atom4],
                  connection_type='Fake impropertype')
コード例 #14
0
ファイル: test_dihedral.py プロジェクト: mosdef-hub/gmso
    def test_dihedral_nonparametrized(self):
        atom1 = Atom(name="atom1")
        atom2 = Atom(name="atom1")
        atom3 = Atom(name="atom3")
        atom4 = Atom(name="atom4")

        connect = Dihedral(connection_members=[atom1, atom2, atom3, atom4])

        assert connect.connection_type is None
コード例 #15
0
    def test_equivalent_members_set(self):
        atom1 = Atom(name="AtomA")
        atom2 = Atom(name="AtomB")

        bond = Bond(connection_members=[atom1, atom2])
        bond_eq = Bond(connection_members=[atom2, atom1])

        assert (tuple(bond_eq.connection_members) in bond.equivalent_members())
        assert (tuple(bond.connection_members) in bond_eq.equivalent_members())
コード例 #16
0
ファイル: test_atom.py プロジェクト: mosdef-hub/gmso
 def test_equivalence(self):
     ref = Atom(name="atom", position=u.nm * np.zeros(3))
     same_atom = Atom(name="atom", position=u.nm * np.zeros(3))
     other_pos = Atom(name="atom", position=u.nm * np.ones(3))
     other_name = Atom(name="atom", position=u.nm * np.ones(3))
     # Two sites are never equivalent
     assert ref != same_atom
     assert ref != other_pos
     assert ref != other_name
コード例 #17
0
ファイル: test_improper.py プロジェクト: mosdef-hub/gmso
    def test_improper_nonparametrized(self):
        atom1 = Atom(name="atom1")
        atom2 = Atom(name="atom2")
        atom3 = Atom(name="atom3")
        atom4 = Atom(name="atom4")

        connect = Improper(connection_members=[atom1, atom2, atom3, atom4])

        assert connect.connection_type is None
コード例 #18
0
ファイル: test_angle.py プロジェクト: mosdef-hub/gmso
 def test_angle_fake_angletype(self):
     atom1 = Atom(name="atom1")
     atom2 = Atom(name="atom2")
     atom3 = Atom(name="atom3")
     with pytest.raises(ValidationError):
         Angle(
             connection_members=[atom1, atom2, atom3],
             angle_type="Fake angletype",
         )
コード例 #19
0
ファイル: test_dihedral.py プロジェクト: mosdef-hub/gmso
 def test_dihedral_fake_dihedraltype(self):
     atom1 = Atom(name="atom1")
     atom2 = Atom(name="atom2")
     atom3 = Atom(name="atom3")
     atom4 = Atom(name="atom4")
     with pytest.raises(ValidationError):
         Dihedral(
             connection_members=[atom1, atom2, atom3, atom4],
             dihedral_type="Fake dihedraltype",
         )
コード例 #20
0
ファイル: test_improper.py プロジェクト: mosdef-hub/gmso
 def test_improper_fake_impropertype(self):
     atom1 = Atom(name="atom1")
     atom2 = Atom(name="atom2")
     atom3 = Atom(name="atom3")
     atom4 = Atom(name="atom4")
     with pytest.raises(ValidationError):
         Improper(
             connection_members=[atom1, atom2, atom3, atom4],
             connection_type="Fake impropertype",
         )
コード例 #21
0
    def test_add_equivalent_connections(self):
        atom1 = Atom(name="AtomA")
        atom2 = Atom(name="AtomB")

        bond = Bond(connection_members=[atom1, atom2])
        bond_eq = Bond(connection_members=[atom2, atom1])

        top = Topology()
        top.add_connection(bond)
        top.add_connection(bond_eq)
        assert top.n_bonds == 1
コード例 #22
0
ファイル: test_topology.py プロジェクト: chrisjonesBSU/gmso
    def test_add_duplicate_connected_atom(self):
        top = Topology()
        atom1 = Atom(name="AtomA")
        atom2 = Atom(name="AtomB")
        bond = Bond(connection_members=[atom1, atom2])
        bond_eq = Bond(connection_members=[atom1, atom2])

        top.add_connection(bond)
        top.add_connection(bond_eq)
        top.update_topology()
        assert top.n_connections == 1
コード例 #23
0
ファイル: test_topology.py プロジェクト: chrisjonesBSU/gmso
    def test_add_connection(self):
        top = Topology()
        atom1 = Atom(name='atom1')
        atom2 = Atom(name='atom2')
        connect = Bond(connection_members=[atom1, atom2])

        top.add_connection(connect)
        top.add_site(atom1)
        top.add_site(atom2)

        assert len(top.connections) == 1
コード例 #24
0
 def test_bond_constituent_types(self):
     atom1 = Atom(name='atom1',
                  position=[0, 0, 0],
                  atom_type=AtomType(name='A'))
     atom2 = Atom(name='atom2',
                  position=[1, 0, 0],
                  atom_type=AtomType(name='B'))
     bondtype = BondType(
         member_types=[atom1.atom_type.name, atom2.atom_type.name])
     bond = Bond(connection_members=[atom1, atom2], bond_type=bondtype)
     assert 'A' in bond.connection_type.member_types
     assert 'B' in bond.connection_type.member_types
コード例 #25
0
 def test_bond_constituent_types(self):
     atom1 = Atom(name="atom1",
                  position=[0, 0, 0],
                  atom_type=AtomType(name="A"))
     atom2 = Atom(name="atom2",
                  position=[1, 0, 0],
                  atom_type=AtomType(name="B"))
     bondtype = BondType(
         member_types=[atom1.atom_type.name, atom2.atom_type.name])
     bond = Bond(connection_members=[atom1, atom2], bond_type=bondtype)
     assert "A" in bond.connection_type.member_types
     assert "B" in bond.connection_type.member_types
コード例 #26
0
    def test_bond_eq(self):
        atom1 = Atom(name='atom1', position=[0, 0, 0])
        atom2 = Atom(name='atom2', position=[1, 1, 1])

        ref_connection = Bond(connection_members=[atom1, atom2], )

        same_connection = Bond(connection_members=[atom1, atom2], )

        diff_connection = Bond(connection_members=[atom1, atom2], )

        assert ref_connection != same_connection
        assert ref_connection != diff_connection
コード例 #27
0
    def test_bond_parametrized(self):
        atom1 = Atom(name='atom1')
        atom2 = Atom(name='atom2')

        bond_type = BondType()

        connect = Bond(connection_members=[atom1, atom2],
                       bond_type=bond_type,
                       name='bond_name')

        assert len(connect.connection_members) == 2
        assert connect.connection_type is not None
        assert connect.name == 'bond_name'
コード例 #28
0
ファイル: test_atom_type.py プロジェクト: bc118/gmso
 def test_atom_type_with_topology_and_site_change_properties(self):
     site1 = Atom()
     site2 = Atom()
     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
コード例 #29
0
ファイル: test_angle.py プロジェクト: zijiewu3/gmso
    def test_angle_eq(self):
        atom1 = Atom(name='atom1', position=[0, 0, 0])
        atom2 = Atom(name='atom2', position=[1, 1, 1])
        atom3 = Atom(name='atom3', position=[1, 1, 1])

        ref_angle = Angle(connection_members=[atom1, atom2, atom3], )

        same_angle = Angle(connection_members=[atom1, atom2, atom3], )

        diff_angle = Angle(connection_members=[atom3, atom2, atom1], )

        assert ref_angle != same_angle
        assert ref_angle != diff_angle
コード例 #30
0
ファイル: test_angle.py プロジェクト: mosdef-hub/gmso
    def test_equivalent_members_set(self):
        atom1 = Atom(name="AtomA")
        atom2 = Atom(name="AtomB")
        atom3 = Atom(name="AtomC")

        angle = Angle(connection_members=[atom1, atom2, atom3])
        angle_eq = Angle(connection_members=[atom3, atom2, atom1])
        angle_not_eq = Angle(connection_members=[atom1, atom3, atom2])

        assert tuple(angle_eq.connection_members) in angle.equivalent_members()
        assert tuple(angle.connection_members) in angle_eq.equivalent_members()
        assert not (tuple(angle.connection_members)
                    in angle_not_eq.equivalent_members())