Example #1
0
    def test_bond_angle(self, molecule, control_filepath, delete_tmp_dir):
        ms = MoleculeSystem(molecule)
        ms.add_bond_angle(0, 1, 2, value=30, weights=[1.0])
        assert ms.has_inconsistencies()

        with temp_dir(delete_tmp_dir) as tmp_dir:
            ms.to_file("coord", fmt="coord")
            shutil.copy2(control_filepath, "control")
            dr = DefineRunner(parameters=dr_parameters)
            assert dr.run_update_internal_coords()

            ms_new = MoleculeSystem.from_file("coord")
            assert not ms_new.has_inconsistencies()

            # check that intdef is present and that the value has been updated
            assert len(ms_new.int_def) == 1
            assert ms_new.int_def[0].value == pytest.approx(
                ms.int_def[0].value, abs=1e-4)

            # check that there are the same user-defined bonds
            assert ms.user_defined_bonds == ms_new.user_defined_bonds

            # check that in redundant the coordinate has been taken into account
            dg = DataGroups.from_file("coord")
            redundant = dg.sdg("redundant", strict=True)
            assert re.search(r"\d+\s+f\s+1\.0+\s+bend\s+1\s+2\s+3\s+val=\s*30",
                             redundant)

            assert str(ms_new.int_def[0])
Example #2
0
    def test_add_bond_angle(self, molecule):
        ms = MoleculeSystem(molecule)
        ms.add_bond_angle(1, 2, 3)
        assert not ms.has_inconsistencies()
        assert len(ms.user_defined_bonds) == 2
        ms.add_bond_angle(0,
                          1,
                          2,
                          status="k",
                          add_user_def_bonds=False,
                          value=35.26438972)
        assert not ms.has_inconsistencies()
        assert len(ms.user_defined_bonds) == 2

        ms.add_bond_angle(2, 3, 4, value=10, weights=1.0)
        assert ms.has_inconsistencies()

        ms.add_bond_angle([0, 1], [2, 3], [3, 4])
        assert len(ms.int_def[-1].indices) == 2

        with pytest.raises(ValueError):
            ms.add_bond_angle([1, 2, 3], [1, 2], [2, 3])