示例#1
0
def test_build_bond_list(methane_molecule):
    _, coordinates = methane_molecule
    bonds = molecool.build_bond_list(coordinates)

    assert len(bonds) == 4
    for bond_length in bonds.values():
        assert bond_length == 1.4
示例#2
0
def test_build_bond_list(methane_molecule):
    symbols, coordinates = methane_molecule

    bonds = molecool.build_bond_list(coordinates)

    assert len(bonds) == 4

    for atoms, bonds in bonds.items():
        assert bonds == 1.4
示例#3
0
def test_build_bond_list(methane_molecule):
    ''' Tests the build_bond_list function. There are multiple sub-tests.'''

    symbols, coordinates = methane_molecule

    bonds = molecool.build_bond_list(coordinates)

    # Test coordinates used above should have 4 bonds using default
    # values for minimum and maximum bond length.

    assert len(bonds) == 4

    for bond_length in bonds.values():
        assert bond_length == 1.4

    # Test 2 : Exception should be thrown in min bond length is < 0.
    with pytest.raises(ValueError):
        bonds = molecool.build_bond_list(coordinates, min_bond=-1)
示例#4
0
def test_build_bond_list():

    coordinates = np.array([[1, 1, 1], [2.4, 1, 1], [-0.4, 1, 1], [1, 1, 2.4],
                            [1, 1, -0.4]])

    bonds = molecool.build_bond_list(coordinates)

    assert len(bonds) == 4

    for atoms, bonds in bonds.items():
        assert bonds == 1.4
示例#5
0
def test_build_bond_failure():

    coordinates = np.array([
        [1, 1, 1],
        [2.4, 1, 1],
        [-0.4, 1, 1],
        [1, 1, 2.4],
        [1, 1, 0.4],
    ])
    with pytest.raises(ValueError):
        bonds = molecool.build_bond_list(coordinates, min_bond=-1)
示例#6
0
import molecool as mc  # our package
import os  # file paths
import matplotlib.pyplot as plt

benzene_file_path = os.path.join(
    'D:\\Notre-Dame\\Classes_Research\\conferences_summer_school\\molssi-best-practices\\starting_material\\data\\xyz',
    'benzene.xyz')
benzene_symbols, benzene_coords = mc.open_xyz(benzene_file_path)
benzene_bonds = mc.build_bond_list(benzene_coords)

print(benzene_bonds)

avg_sum = 0

for atoms, bl in benzene_bonds.items():
    avg_sum += bl

avg_bl = avg_sum / len(benzene_bonds)

print('The average bond length is {}'.format(avg_bl))

benzene_fig = mc.draw_molecule(benzene_coords,
                               benzene_symbols,
                               draw_bonds=benzene_bonds)

plt.savefig('benzene.png', dpi=300)

mc.bond_histogram(benzene_bonds, save_location="benzene_histogram.png")
示例#7
0
def test_build_bond_list_failure():
    coordinates = np.array([])

    with pytest.raises(ValueError):
        molecool.build_bond_list(coordinates)
示例#8
0
def test_build_bond_failure(methane_molecule):

    symbols, coordinates = methane_molecule

    with pytest.raises(ValueError):
        bonds = molecool.build_bond_list(coordinates, min_bond=-1)