def test_write_file_from_OptSet(self): from pymatgen.io.qchem.sets import OptSet odd_dict = loadfn(os.path.join(os.path.dirname(__file__), "odd.json")) odd_mol = odd_dict["spec"]["_tasks"][0]["molecule"] qcinp = OptSet(odd_mol) qcinp.write_file(os.path.join(os.path.dirname(__file__), "test.qin")) test_dict = QCInput.from_file(os.path.join(os.path.dirname(__file__), "test.qin")).as_dict() test_ref_dict = QCInput.from_file(os.path.join(os.path.dirname(__file__), "test_ref.qin")).as_dict() for key in test_dict: self.assertEqual(test_dict[key], test_ref_dict[key]) os.remove(os.path.join(os.path.dirname(__file__), "test.qin"))
def test_write_file_from_OptSet_with_vdw(self): from pymatgen.io.qchem.sets import OptSet odd_dict = loadfn(os.path.join(os.path.dirname(__file__), "odd.json")) odd_mol = odd_dict["spec"]["_tasks"][0]["molecule"] qcinp = OptSet(odd_mol, overwrite_inputs={"van_der_waals": {"16": 3.14159}}) qcinp.write_file(os.path.join(os.path.dirname(__file__), "test_vdw.qin")) test_file = open(os.path.join(os.path.dirname(__file__), "test_vdw.qin")) ref_file = open(os.path.join(os.path.dirname(__file__), "test_ref_vdw.qin")) for l_test, l_ref in zip(test_file, ref_file): # By default, if this statement fails the offending line will be printed assert l_test == l_ref test_file.close() ref_file.close() os.remove(os.path.join(os.path.dirname(__file__), "test_vdw.qin"))
def generate_opt_input(molfile, qinfile, basis_set="6-311++G*", pcm_dielectric=None, overwrite_inputs=None): """ Generates a QChem input file from Molecule after conformer search. :param molfile: Absolute path to the input file (.mol, .sdf, etc.) :param qinfile: Absolute path to the output file (.in) :param basis_set: To overwrite default basis. :param pcm_dielectric: To use solvent :param overwrite_inputs: To overwrite any set defaults :return: """ mol = get_molecule(molfile) qcinput = OptSet(mol, basis_set=basis_set, pcm_dielectric=pcm_dielectric, overwrite_inputs=overwrite_inputs) qcinput.write_file(qinfile)