def test_get_psi_results_opt(): infile = os.path.join(mydir, 'data_tests', 'gbi-200.sdf') outfile = os.path.join(mydir, 'data_tests', 'gbi-210.sdf') m, b = get_psi_results(infile, outfile, 'opt', "output.dat", "timer.dat") assert m == 'mp2' assert b == 'def2-SV(P)' # read the single mol (from generator) and get its three conformers # confs 2 and 4 failed opt so we should have data from confs 1 3 5 mol = read_mol(outfile, True) confs = list(next(mol).GetConfs()) assert len(confs) == 3 # get one conf and check its tag data conf = confs[1] # handy way to get all tags and data (.GetTag(), .GetValue()) #print([x.GetValue() for x in list(oechem.OEGetSDDataPairs(conf))]) assert oechem.OEGetSDData( conf, 'QM Psi4 Opt. Runtime (sec) mp2/def2-SV(P)') == '2635.0' assert oechem.OEGetSDData( conf, 'QM Psi4 Final Opt. Energy (Har) mp2/def2-SV(P)' ) == '-582.1570265488717' assert oechem.OEGetSDData(conf, 'QM Psi4 Opt. Steps mp2/def2-SV(P)') == '21' assert oechem.OEGetSDData( conf, 'QM Psi4 Initial Opt. Energy (Har) mp2/def2-SV(P)' ) == '-582.146838702714' os.remove(outfile)
def test_get_psi_results_hess(): infile = os.path.join(mydir, 'data_tests', 'carbon-222.sdf') outfile = os.path.join(mydir, 'data_tests', 'carbon_hess-222.sdf') m, b = get_psi_results(infile, outfile, 'hess', "output.dat", "timer.dat") # check the method and basis set returned assert m == 'mp2' assert b == 'def2-tzvp' # check tag of Hessian calculation time for one conformer mols = read_mol(outfile, True) conf = list(next(mols).GetConfs())[0] # only conf of the s1 mol assert oechem.OEGetSDData( conf, 'QM Psi4 Hessian Runtime (sec) mp2/def2-tzvp') == '253.0' # check a few values of the Hessian matrix for each conformer hpickle = os.path.join(mydir, 'data_tests', 'carbon_hess-222.hess.pickle') hdict = pickle.load(open(hpickle, 'rb')) # mol s1, conf 1, row 10, column 23 assert hdict['s1'][1][9][22] == 0.00065859359798 # mol t1, conf 1, row 3, column 9 assert hdict['t1'][1][2][8] == -0.42670095298438 # clean up os.remove(outfile) os.remove(hpickle)
def test_get_psi_results_exists(): infile = os.path.join(mydir, 'data_tests', 'methane_c2p.sdf') with pytest.raises(FileExistsError): m, b = get_psi_results(infile, infile, calctype='opt', psiout="output.dat", timeout="timer.dat") assert True
def test_get_psi_results_calctype(): infile = os.path.join(mydir, 'data_tests', 'methane_c2p.sdf') outfile = os.path.join(mydir, 'data_tests', 'methane_c2p-210.sdf') with pytest.raises(ValueError): m, b = get_psi_results(infile, outfile, calctype='blah', psiout="output.dat", timeout="timer.dat") assert True