def test_custom_smd_write(self): dict_set = GSMDictSet(basis_set='6-31g*', scf_algorithm='diis', dft_rung=5, smd_solvent="custom", custom_smd="90.00,1.415,0.00,0.735,20.2,0.00,0.00", max_scf_cycles=35) dict_set.write("mol.qin") test_dict = QCTemplate.from_file("mol.qin").as_dict() rem = { "job_type": "force", "basis": "6-31G*", "max_scf_cycles": '35', "method": "wb97mv", "gen_scfman": 'true', "scf_algorithm": "diis", "xc_grid": '3', "solvent_method": "smd", "ideriv": "1", 'symmetry': 'false', 'sym_ignore': 'true', 'resp_charges': 'true' } qc_input = QCTemplate(rem=rem, smx={"solvent": "other"}) for k, v in qc_input.as_dict().items(): self.assertEqual(v, test_dict[k]) os.remove("mol.qin") with open("solvent_data") as sd: lines = sd.readlines() self.assertEqual(lines[0], "90.00,1.415,0.00,0.735,20.2,0.00,0.00") os.remove("solvent_data")
def test_pcm_write(self): dict_set = GSMDictSet(basis_set='6-31g*', scf_algorithm='diis', dft_rung=5, pcm_dielectric=10.0, max_scf_cycles=35) dict_set.write("mol.qin") test_dict = QCTemplate.from_file("mol.qin").as_dict() rem = { "job_type": "force", "basis": "6-31G*", "max_scf_cycles": '35', "method": "wb97mv", "gen_scfman": 'true', "scf_algorithm": "diis", "xc_grid": '3', "solvent_method": "pcm", 'symmetry': 'false', 'sym_ignore': 'true', 'resp_charges': 'true' } pcm = { "heavypoints": "194", "hpoints": "194", "radii": "uff", "theory": "cpcm", "vdwscale": "1.1" } qc_input = QCTemplate(rem=rem, pcm=pcm, solvent={"dielectric": "10.0"}) for k, v in qc_input.as_dict().items(): self.assertEqual(v, test_dict[k]) os.remove("mol.qin")
def test_full_init(self): test_DictSet = GSMDictSet( basis_set='6-31g*', scf_algorithm='diis', dft_rung=1, pcm_dielectric=10.0, max_scf_cycles=35) self.assertEqual( test_DictSet.rem, { 'job_type': 'force', 'gen_scfman': 'true', 'basis': '6-31g*', 'max_scf_cycles': 35, 'method': 'b3lyp', 'scf_algorithm': 'diis', 'xc_grid': '3', 'solvent_method': 'pcm', 'symmetry': 'false', 'sym_ignore': 'true', 'resp_charges': 'true' }) self.assertEqual( test_DictSet.pcm, { 'heavypoints': '194', 'hpoints': '194', 'radii': 'uff', 'theory': 'cpcm', 'vdwscale': '1.1' }) self.assertEqual(test_DictSet.solvent, {'dielectric': 10.0}) test_DictSet = GSMDictSet( basis_set='6-31g*', scf_algorithm='diis', dft_rung=1, smd_solvent='water', max_scf_cycles=35) self.assertEqual( test_DictSet.rem, { 'job_type': 'force', 'gen_scfman': 'true', 'basis': '6-31g*', 'max_scf_cycles': 35, 'method': 'b3lyp', 'scf_algorithm': 'diis', 'xc_grid': '3', 'solvent_method': 'smd', 'ideriv': '1', 'symmetry': 'false', 'sym_ignore': 'true', 'resp_charges': 'true' }) self.assertEqual(test_DictSet.smx, {'solvent': 'water'})
def test_double_solvation(self): raised_error = False dict_set = None try: dict_set = GSMDictSet(basis_set='6-31g*', scf_algorithm='diis', dft_rung=1, pcm_dielectric=10.0, smd_solvent="water", max_scf_cycles=35) except ValueError: raised_error = True self.assertTrue(raised_error) self.assertEqual(dict_set, None)
def test_init(self): test_DictSet = GSMDictSet( basis_set='6-31G*', scf_algorithm='diis') self.assertEqual( test_DictSet.rem, { 'job_type': 'force', 'gen_scfman': 'true', 'basis': '6-31g*', 'max_scf_cycles': 200, 'method': 'wb97xv', 'scf_algorithm': 'diis', 'xc_grid': '3', 'symmetry': 'false', 'sym_ignore': 'true', 'resp_charges': 'true' }) self.assertEqual(test_DictSet.pcm, {}) self.assertEqual(test_DictSet.solvent, {}) self.assertEqual(test_DictSet.smx, {})
def test_overwrite_input(self): overwrite_inputs = { "rem": { 'method': 'b3lyp', 'basis': '6-31g*', 'thresh': 10, "xc_grid": "000150000302" } } test_set = GSMDictSet(overwrite_inputs=overwrite_inputs) act_rem = { 'job_type': 'force', 'gen_scfman': 'true', 'basis': '6-31g*', 'max_scf_cycles': 200, 'method': 'b3lyp', 'scf_algorithm': 'diis', 'xc_grid': '000150000302', 'thresh': 10, 'symmetry': 'false', 'sym_ignore': 'true', 'resp_charges': 'true' } self.assertDictEqual(act_rem, test_set.rem)
def __init__(self, molecule, isomers, base_command="gsm", num_nodes=30, fixed_endpoints=True, name="single-ended GSM", max_cores=32, input_params=None, db_file=None, parents=None, **kwargs): """ Args: molecule (Molecule): Input molecule. isomers (dict): list of coordinates to vary to find transition states base_command (str): Way to call pyGSM. By default this is "gsm". num_nodes (int): Maximum number of nodes along the reaction path. Default is 30. fixed_endpoint (bool): If True (default), do not optimize the input node. name (str): Name for the Firework. max_cores (int): Maximum number of cores to parallelize over. Supports env_chk. input_params (dict): Specify kwargs for instantiating the input set parameters. Basic uses would be to modify the default inputs of the set, such as dft_rung, basis_set, pcm_dielectric, scf_algorithm, or max_scf_cycles. See pymatgen/io/gsm/sets.py for default values of all input parameters. For instance, if a user wanted to use a more advanced DFT functional, include a pcm with a dielectric of 30, and use a larger basis, the user would set qchem_input_params = {"dft_rung": 5, "pcm_dielectric": 30, "basis_set": "6-311++g**"}. However, more advanced customization of the input is also possible through the overwrite_inputs key which allows the user to directly modify the rem, pcm, smd, and solvent dictionaries that QChemDictSet passes to inputs.py to print an actual input file. For instance, if a user wanted to set the sym_ignore flag in the rem section of the input file to true, then they would set qchem_input_params = {"overwrite_inputs": "rem": {"sym_ignore": "true"}}. Of course, overwrite_inputs could be used in conjuction with more typical modifications. db_file (str): Path to file specifying db credentials to place output parsing. parents ([Firework]): Parents of this particular Firework. **kwargs: Other kwargs that are passed to Firework.__init__. """ input_params = input_params or dict() molecule_file = "input.xyz" lot_file = "qin" isomers_file = "isomers.txt" output_file = "gsm.out" flags = [ base_command, "-mode", "SE_GSM", "-xyzfile", molecule_file, "-package", "QChem", "-lot_inp_file", lot_file, "-num_nodes", str(num_nodes), "-isomers", isomers_file, "-charge", str(molecule.charge), "-multiplicity", str(molecule.spin_multiplicity), "-nproc", str(max_cores) ] if fixed_endpoints: flags.append("-reactant_geom_fixed") flags.append(">") flags.append(output_file) t = list() input_set = GSMDictSet(**input_params) t.append( WriteInputFromIOSet(input_set=input_set, molecules=[molecule], molecule_file=molecule_file, lot_file=lot_file)) t.append(WriteIsomer(isomers=isomers, isomers_file=isomers_file)) t.append(RunGSMDirect(cmd=" ".join(flags))) t.append( GSMToDb(db_file=db_file, molecule_file=molecule_file, template_file=lot_file, output_file=output_file, isomers_file=isomers_file, additional_fields={"task_label": name})) super(SingleEndedGSMFW, self).__init__(t, parents=parents, name=name, **kwargs)