def test_torsion_handler_charmm_potential(self): """ Test creation of TorsionHandlers with the deprecated 0.2 potential value "charmm" instead of the current supported potential value "fourier". """ import re # Test creating ProperTorsionHandlers err_msg = re.escape( "Attempted to set ProperTorsionHandler.potential to charmm. Currently, " "only the following values are supported: ['k*(1+cos(periodicity*theta-phase))']." ) with pytest.raises(SMIRNOFFSpecError, match=err_msg): ph1 = ProperTorsionHandler(potential='charmm', skip_version_check=True) ph1 = ProperTorsionHandler( potential='k*(1+cos(periodicity*theta-phase))', skip_version_check=True) # Same test, but with ImproperTorsionHandler err_msg = re.escape( "Attempted to set ImproperTorsionHandler.potential to charmm. Currently, " "only the following values are supported: ['k*(1+cos(periodicity*theta-phase))']." ) with pytest.raises(SMIRNOFFSpecError, match=err_msg): ph1 = ImproperTorsionHandler(potential='charmm', skip_version_check=True) ph1 = ImproperTorsionHandler( potential='k*(1+cos(periodicity*theta-phase))', skip_version_check=True)
def test_single_term_proper_torsion(self): """ Test creation and serialization of a single-term proper torsion """ from simtk import unit p1 = ProperTorsionHandler.ProperTorsionType( smirks='[*:1]-[*:2]-[*:3]-[*:4]', phase1=30 * unit.degree, periodicity1=2, k1=5 * unit.kilocalorie_per_mole) param_dict = p1.to_dict() assert ('k1', 5 * unit.kilocalorie_per_mole) in param_dict.items() assert ('phase1', 30 * unit.degree) in param_dict.items() assert ('periodicity1', 2) in param_dict.items() assert 'idivf' not in param_dict
def test_multi_term_proper_torsion_skip_index(self): """ Test creation and serialization of a multi-term proper torsion where the indices are not consecutive and a SMIRNOFFSpecError is raised """ from simtk import unit with pytest.raises(SMIRNOFFSpecError, match="Unexpected kwarg (phase3: 31 deg)*") as context: p1 = ProperTorsionHandler.ProperTorsionType(smirks='[*:1]-[*:2]-[*:3]-[*:4]', phase1=30 * unit.degree, periodicity1=2, k1=5 * unit.kilocalorie_per_mole, phase3=31 * unit.degree, periodicity3=3, k3=6 * unit.kilocalorie_per_mole, )
def test_multi_term_proper_torsion_bad_units(self): """ Test creation and serialization of a multi-term proper torsion where one of the terms has incorrect units """ from simtk import unit with pytest.raises(IncompatibleUnitError, match="should have units of")\ as context: p1 = ProperTorsionHandler.ProperTorsionType(smirks='[*:1]-[*:2]-[*:3]-[*:4]', phase1=30 * unit.degree, periodicity1=2, k1=5 * unit.kilocalorie_per_mole, phase2=31 * unit.angstrom, # This should be caught periodicity2=3, k2=6 * unit.kilocalorie_per_mole, )
def test_multi_term_proper_torsion(self): """ Test creation and serialization of a multi-term proper torsion """ from simtk import unit p1 = ProperTorsionHandler.ProperTorsionType(smirks='[*:1]-[*:2]-[*:3]-[*:4]', phase1=30 * unit.degree, periodicity1=2, k1=5 * unit.kilocalorie_per_mole, phase2=31 * unit.degree, periodicity2=3, k2=6 * unit.kilocalorie_per_mole, ) param_dict = p1.to_dict() assert param_dict['k1'] == 5 * unit.kilocalorie_per_mole assert param_dict['phase1'] == 30 * unit.degree assert param_dict['periodicity1'] == 2 assert param_dict['k2'] == 6 * unit.kilocalorie_per_mole assert param_dict['phase2'] == 31 * unit.degree assert param_dict['periodicity2'] == 3