def __init__(self, molecule, rem, opt=None, pcm=None, solvent=None, smx=None): self.molecule = molecule self.rem = lower_and_check_unique(rem) self.opt = opt self.pcm = lower_and_check_unique(pcm) self.solvent = lower_and_check_unique(solvent) self.smx = lower_and_check_unique(smx) # Make sure molecule is valid: either the string "read" or a pymatgen molecule object if isinstance(self.molecule, str): self.molecule = self.molecule.lower() if self.molecule != "read": raise ValueError( 'The only acceptable text value for molecule is "read"') elif not isinstance(self.molecule, Molecule): raise ValueError( "The molecule must either be the string 'read' or be a pymatgen Molecule object" ) # Make sure rem is valid: # - Has a basis # - Has a method or DFT exchange functional # - Has a valid job_type or jobtype valid_job_types = [ "opt", "optimization", "sp", "freq", "frequency", "nmr" ] if "basis" not in self.rem: raise ValueError("The rem dictionary must contain a 'basis' entry") if "method" not in self.rem: if "exchange" not in self.rem: raise ValueError( "The rem dictionary must contain either a 'method' entry or an 'exchange' entry" ) if "job_type" not in self.rem: raise ValueError( "The rem dictionary must contain a 'job_type' entry") if self.rem.get("job_type").lower() not in valid_job_types: raise ValueError( "The rem dictionary must contain a valid 'job_type' entry")
def __init__(self, rem, pcm=None, solvent=None, smx=None): self.rem = lower_and_check_unique(rem) self.pcm = lower_and_check_unique(pcm) self.solvent = lower_and_check_unique(solvent) self.smx = lower_and_check_unique(smx) # Only force jobs should be used with GSM self.rem["job_type"] = "force" if "basis" not in self.rem: raise ValueError("The rem dictionary must contain a 'basis' entry") if "method" not in self.rem: if "exchange" not in self.rem: raise ValueError( "The rem dictionary must contain either a 'method' entry or an 'exchange' entry" )
def __init__(self, molecule, job_type, basis_set, scf_algorithm, dft_rung=4, pcm_dielectric=None, smd_solvent=None, max_scf_cycles=200, geom_opt_max_cycles=200, overwrite_inputs=None): """ Args: molecule (Pymatgen molecule object) job_type (str) basis_set (str) scf_algorithm (str) dft_rung (int) pcm_dielectric (str) max_scf_cycles (int) geom_opt_max_cycles (int) overwrite_inputs (dict): This is dictionary of QChem input sections to add or overwrite variables, the available sections are currently rem, pcm, and solvent. So the accepted keys are rem, pcm, or solvent and the value is a dictionary of key value pairs relevant to the section. An example would be adding a new variable to the rem section that sets symmetry to false. ex. overwrite_inputs = {"rem": {"symmetry": "false"}} ***It should be noted that if something like basis is added to the rem dict it will overwrite the default basis.*** """ self.molecule = molecule self.job_type = job_type self.basis_set = basis_set self.scf_algorithm = scf_algorithm self.dft_rung = dft_rung self.pcm_dielectric = pcm_dielectric self.smd_solvent = smd_solvent self.max_scf_cycles = max_scf_cycles self.geom_opt_max_cycles = geom_opt_max_cycles self.overwrite_inputs = overwrite_inputs pcm_defaults = { "heavypoints": "194", "hpoints": "194", "radii": "uff", "theory": "cpcm", "vdwscale": "1.1" } mypcm = {} mysolvent = {} mysmx = {} myrem = {} myrem["job_type"] = job_type myrem["basis"] = self.basis_set myrem["max_scf_cycles"] = self.max_scf_cycles myrem["gen_scfman"] = "true" myrem["scf_algorithm"] = self.scf_algorithm if self.dft_rung == 1: myrem["exchange"] = "B3LYP" elif self.dft_rung == 2: myrem["method"] = "B97-D3" myrem["dft_D"] = "D3_BJ" elif self.dft_rung == 3: myrem["method"] = "B97M-rV" elif self.dft_rung == 4: myrem["method"] = "wb97xd" elif self.dft_rung == 5: myrem["method"] = "wB97M-V" else: raise ValueError("dft_rung should be between 1 and 5!") if self.job_type.lower() == "opt": myrem["geom_opt_max_cycles"] = self.geom_opt_max_cycles if self.pcm_dielectric is not None and self.smd_solvent is not None: raise ValueError( "Only one of pcm or smd may be used for solvation.") if self.pcm_dielectric is not None: mypcm = pcm_defaults mysolvent["dielectric"] = self.pcm_dielectric myrem["solvent_method"] = 'pcm' if self.smd_solvent is not None: mysmx["solvent"] = self.smd_solvent myrem["solvent_method"] = "smd" if self.overwrite_inputs: for sec, sec_dict in self.overwrite_inputs.items(): if sec == "rem": temp_rem = lower_and_check_unique(sec_dict) for k, v in temp_rem.items(): myrem[k] = v if sec == "pcm": temp_pcm = lower_and_check_unique(sec_dict) for k, v in temp_pcm.items(): mypcm[k] = v if sec == "solvent": temp_solvent = lower_and_check_unique(sec_dict) for k, v in temp_solvent.items(): mysolvent[k] = v if sec == "smx": temp_smx = lower_and_check_unique(sec_dict) for k, v in temp_smx.items(): mysmx[k] = v super().__init__(self.molecule, rem=myrem, pcm=mypcm, solvent=mysolvent, smx=mysmx)
def __init__( self, molecule: Molecule, job_type: str, basis_set: str, scf_algorithm: str, dft_rung: int = 4, pcm_dielectric: Optional[float] = None, smd_solvent: Optional[str] = None, custom_smd: Optional[str] = None, opt_variables: Optional[Dict[str, List]] = None, scan_variables: Optional[Dict[str, List]] = None, max_scf_cycles: int = 200, geom_opt_max_cycles: int = 200, plot_cubes: bool = False, nbo_params: Optional[Dict] = None, overwrite_inputs: Optional[Dict] = None, vdw_mode: str = "atomic", ): """ Args: molecule (Pymatgen Molecule object) job_type (str): QChem job type to run. Valid options are "opt" for optimization, "sp" for single point, "freq" for frequency calculation, or "force" for force evaluation. basis_set (str): Basis set to use. For example, "def2-tzvpd". scf_algorithm (str): Algorithm to use for converging the SCF. Recommended choices are "DIIS", "GDM", and "DIIS_GDM". Other algorithms supported by Qchem's GEN_SCFMAN module will also likely perform well. Refer to the QChem manual for further details. dft_rung (int): Select the DFT functional among 5 recommended levels of theory, in order of increasing accuracy/cost. 1 = B3LYP, 2=B3lYP+D3, 3=ωB97X-D, 4=ωB97X-V, 5=ωB97M-V. (Default: 4) To set a functional not given by one of the above, set the overwrite_inputs argument to {"method":"<NAME OF FUNCTIONAL>"} **Note that the "rungs" in this argument do NOT correspond to rungs on "Jacob's Ladder of Density Functional Approxmations"** pcm_dielectric (float): Dielectric constant to use for PCM implicit solvation model. (Default: None) smd_solvent (str): Solvent to use for SMD implicit solvation model. (Default: None) Examples include "water", "ethanol", "methanol", and "acetonitrile". Refer to the QChem manual for a complete list of solvents available. To define a custom solvent, set this argument to "custom" and populate custom_smd with the necessary parameters. **Note that only one of smd_solvent and pcm_dielectric may be set.** custom_smd (str): List of parameters to define a custom solvent in SMD. (Default: None) Must be given as a string of seven comma separated values in the following order: "dielectric, refractive index, acidity, basicity, surface tension, aromaticity, electronegative halogenicity" Refer to the QChem manual for further details. opt_variables (dict): A dictionary of opt sections, where each opt section is a key and the corresponding values are a list of strings. Stings must be formatted as instructed by the QChem manual. The different opt sections are: CONSTRAINT, FIXED, DUMMY, and CONNECT. Ex. opt = {"CONSTRAINT": ["tors 2 3 4 5 25.0", "tors 2 5 7 9 80.0"], "FIXED": ["2 XY"]} scan_variables (dict): A dictionary of scan variables. Because two constraints of the same type are allowed (for instance, two torsions or two bond stretches), each TYPE of variable (stre, bend, tors) should be its own key in the dict, rather than each variable. Note that the total number of variable (sum of lengths of all lists) CANNOT be more than two. Ex. scan_variables = {"stre": ["3 6 1.5 1.9 0.1"], "tors": ["1 2 3 4 -180 180 15"]} max_scf_cycles (int): Maximum number of SCF iterations. (Default: 200) geom_opt_max_cycles (int): Maximum number of geometry optimization iterations. (Default: 200) plot_cubes (bool): Whether to write CUBE files of the electron density. (Default: False) nbo_params (list): A list of strings for the desired NBO params. If an empty list is passed, default NBO analysis will be performed. (Default: False) overwrite_inputs (dict): Dictionary of QChem input sections to add or overwrite variables. The currently available sections (keys) are rem, pcm, solvent, smx, opt, scan, van_der_waals, and plots. The value of each key is a dictionary of key value pairs relevant to that section. For example, to add a new variable to the rem section that sets symmetry to false, use overwrite_inputs = {"rem": {"symmetry": "false"}} **Note that if something like basis is added to the rem dict it will overwrite the default basis.** **Note that supplying a van_der_waals section here will automatically modify the PCM "radii" setting to "read".** **Note that all keys must be given as strings, even when they are numbers!** vdw_mode (str): Method of specifying custom van der Waals radii. Applies only if you are using overwrite_inputs to add a $van_der_waals section to the input. Valid value are 'atomic' and 'sequential'. In 'atomic' mode (default), dict keys represent the atomic number associated with each radius (e.g., '12' = carbon). In 'sequential' mode, dict keys represent the sequential position of a single specific atom in the input structure. """ self.molecule = molecule self.job_type = job_type self.basis_set = basis_set self.scf_algorithm = scf_algorithm self.dft_rung = dft_rung self.pcm_dielectric = pcm_dielectric self.smd_solvent = smd_solvent self.custom_smd = custom_smd self.opt_variables = opt_variables self.scan_variables = scan_variables self.max_scf_cycles = max_scf_cycles self.geom_opt_max_cycles = geom_opt_max_cycles self.plot_cubes = plot_cubes self.nbo_params = nbo_params self.overwrite_inputs = overwrite_inputs self.vdw_mode = vdw_mode pcm_defaults = { "heavypoints": "194", "hpoints": "194", "radii": "uff", "theory": "cpcm", "vdwscale": "1.1", } plots_defaults = {"grid_spacing": "0.05", "total_density": "0"} if self.opt_variables is None: myopt = dict() else: myopt = self.opt_variables if self.scan_variables is None: myscan = dict() else: myscan = self.scan_variables mypcm = dict() mysolvent = dict() mysmx = dict() myvdw = dict() myplots = dict() myrem = dict() myrem["job_type"] = job_type myrem["basis"] = self.basis_set myrem["max_scf_cycles"] = str(self.max_scf_cycles) myrem["gen_scfman"] = "true" myrem["xc_grid"] = "3" myrem["scf_algorithm"] = self.scf_algorithm myrem["resp_charges"] = "true" myrem["symmetry"] = "false" myrem["sym_ignore"] = "true" if self.dft_rung == 1: myrem["method"] = "b3lyp" elif self.dft_rung == 2: myrem["method"] = "b3lyp" myrem["dft_D"] = "D3_BJ" elif self.dft_rung == 3: myrem["method"] = "wb97xd" elif self.dft_rung == 4: myrem["method"] = "wb97xv" elif self.dft_rung == 5: myrem["method"] = "wb97mv" else: raise ValueError("dft_rung should be between 1 and 5!") if self.job_type.lower() in ["opt", "ts", "pes_scan"]: myrem["geom_opt_max_cycles"] = str(self.geom_opt_max_cycles) if self.pcm_dielectric is not None and self.smd_solvent is not None: raise ValueError( "Only one of pcm or smd may be used for solvation.") if self.pcm_dielectric is not None: mypcm = pcm_defaults mysolvent["dielectric"] = self.pcm_dielectric myrem["solvent_method"] = "pcm" if self.smd_solvent is not None: if self.smd_solvent == "custom": mysmx["solvent"] = "other" else: mysmx["solvent"] = self.smd_solvent myrem["solvent_method"] = "smd" myrem["ideriv"] = "1" if self.smd_solvent == "custom" or self.smd_solvent == "other": if self.custom_smd is None: raise ValueError( "A user-defined SMD requires passing custom_smd, a string" + " of seven comma separated values in the following order:" + " dielectric, refractive index, acidity, basicity, surface" + " tension, aromaticity, electronegative halogenicity") if self.plot_cubes: myplots = plots_defaults myrem["plots"] = "true" myrem["make_cube_files"] = "true" if self.nbo_params is not None: myrem["nbo"] = "true" if self.overwrite_inputs: for sec, sec_dict in self.overwrite_inputs.items(): if sec == "rem": temp_rem = lower_and_check_unique(sec_dict) for k, v in temp_rem.items(): myrem[k] = v if sec == "pcm": temp_pcm = lower_and_check_unique(sec_dict) for k, v in temp_pcm.items(): mypcm[k] = v if sec == "solvent": temp_solvent = lower_and_check_unique(sec_dict) for k, v in temp_solvent.items(): mysolvent[k] = v if sec == "smx": temp_smx = lower_and_check_unique(sec_dict) for k, v in temp_smx.items(): mysmx[k] = v if sec == "scan": temp_scan = lower_and_check_unique(sec_dict) for k, v in temp_scan.items(): myscan[k] = v if sec == "van_der_waals": temp_vdw = lower_and_check_unique(sec_dict) for k, v in temp_vdw.items(): myvdw[k] = v # set the PCM section to read custom radii mypcm["radii"] = "read" if sec == "plots": temp_plots = lower_and_check_unique(sec_dict) for k, v in temp_plots.items(): myplots[k] = v if sec == "nbo": temp_plots = lower_and_check_unique(sec_dict) for k, v in temp_plots.items(): myplots[k] = v if sec == "opt": temp_opts = lower_and_check_unique(sec_dict) for k, v in temp_opts.items(): myopt[k] = v super().__init__( self.molecule, rem=myrem, opt=myopt, pcm=mypcm, solvent=mysolvent, smx=mysmx, scan=myscan, van_der_waals=myvdw, vdw_mode=self.vdw_mode, plots=myplots, nbo=self.nbo_params, )
def __init__( self, molecule, job_type, basis_set, scf_algorithm, dft_rung=4, pcm_dielectric=None, smd_solvent=None, custom_smd=None, max_scf_cycles=200, geom_opt_max_cycles=200, overwrite_inputs=None, ): """ Args: molecule (Pymatgen molecule object) job_type (str) basis_set (str) scf_algorithm (str) dft_rung (int) pcm_dielectric (str) max_scf_cycles (int) geom_opt_max_cycles (int) overwrite_inputs (dict): This is dictionary of QChem input sections to add or overwrite variables, the available sections are currently rem, pcm, and solvent. So the accepted keys are rem, pcm, or solvent and the value is a dictionary of key value pairs relevant to the section. An example would be adding a new variable to the rem section that sets symmetry to false. ex. overwrite_inputs = {"rem": {"symmetry": "false"}} ***It should be noted that if something like basis is added to the rem dict it will overwrite the default basis.*** """ self.molecule = molecule self.job_type = job_type self.basis_set = basis_set self.scf_algorithm = scf_algorithm self.dft_rung = dft_rung self.pcm_dielectric = pcm_dielectric self.smd_solvent = smd_solvent self.custom_smd = custom_smd self.max_scf_cycles = max_scf_cycles self.geom_opt_max_cycles = geom_opt_max_cycles self.overwrite_inputs = overwrite_inputs pcm_defaults = { "heavypoints": "194", "hpoints": "194", "radii": "uff", "theory": "cpcm", "vdwscale": "1.1", } mypcm = {} mysolvent = {} mysmx = {} myrem = {} myrem["job_type"] = job_type myrem["basis"] = self.basis_set myrem["max_scf_cycles"] = self.max_scf_cycles myrem["gen_scfman"] = "true" myrem["xc_grid"] = "3" myrem["scf_algorithm"] = self.scf_algorithm myrem["resp_charges"] = "true" myrem["symmetry"] = "false" myrem["sym_ignore"] = "true" if self.dft_rung == 1: myrem["method"] = "b3lyp" elif self.dft_rung == 2: myrem["method"] = "b3lyp" myrem["dft_D"] = "D3_BJ" elif self.dft_rung == 3: myrem["method"] = "wb97xd" elif self.dft_rung == 4: myrem["method"] = "wb97xv" elif self.dft_rung == 5: myrem["method"] = "wb97mv" else: raise ValueError("dft_rung should be between 1 and 5!") if self.job_type.lower() == "opt": myrem["geom_opt_max_cycles"] = self.geom_opt_max_cycles if self.pcm_dielectric is not None and self.smd_solvent is not None: raise ValueError( "Only one of pcm or smd may be used for solvation.") if self.pcm_dielectric is not None: mypcm = pcm_defaults mysolvent["dielectric"] = self.pcm_dielectric myrem["solvent_method"] = "pcm" if self.smd_solvent is not None: if self.smd_solvent == "custom": mysmx["solvent"] = "other" else: mysmx["solvent"] = self.smd_solvent myrem["solvent_method"] = "smd" myrem["ideriv"] = "1" if self.smd_solvent == "custom" or self.smd_solvent == "other": if self.custom_smd is None: raise ValueError( "A user-defined SMD requires passing custom_smd, a string" + " of seven comma separated values in the following order:" + " dielectric, refractive index, acidity, basicity, surface" + " tension, aromaticity, electronegative halogenicity") if self.overwrite_inputs: for sec, sec_dict in self.overwrite_inputs.items(): if sec == "rem": temp_rem = lower_and_check_unique(sec_dict) for k, v in temp_rem.items(): myrem[k] = v if sec == "pcm": temp_pcm = lower_and_check_unique(sec_dict) for k, v in temp_pcm.items(): mypcm[k] = v if sec == "solvent": temp_solvent = lower_and_check_unique(sec_dict) for k, v in temp_solvent.items(): mysolvent[k] = v if sec == "smx": temp_smx = lower_and_check_unique(sec_dict) for k, v in temp_smx.items(): mysmx[k] = v super().__init__(self.molecule, rem=myrem, pcm=mypcm, solvent=mysolvent, smx=mysmx)
def __init__(self, molecule, job_type, basis_set, scf_algorithm, dft_rung=4, pcm_dielectric=None, max_scf_cycles=200, geom_opt_max_cycles=200, overwrite_inputs=None): """ Args: molecule (Pymatgen molecule object) job_type (str) basis_set (str) scf_algorithm (str) dft_rung (int) pcm_dielectric (str) max_scf_cycles (int) geom_opt_max_cycles (int) overwrite_inputs (dict): This is dictionary of QChem input sections to add or overwrite variables, the available sections are currently rem, pcm, and solvent. So the accepted keys are rem, pcm, or solvent and the value is a dictionary of key value pairs relevant to the section. An example would be adding a new variable to the rem section that sets symmetry to false. ex. overwrite_inputs = {"rem": {"symmetry": "false"}} ***It should be noted that if something like basis is added to the rem dict it will overwrite the default basis.*** """ self.molecule = molecule self.job_type = job_type self.basis_set = basis_set self.scf_algorithm = scf_algorithm self.dft_rung = dft_rung self.pcm_dielectric = pcm_dielectric self.max_scf_cycles = max_scf_cycles self.geom_opt_max_cycles = geom_opt_max_cycles self.overwrite_inputs = overwrite_inputs pcm_defaults = { "heavypoints": "194", "hpoints": "194", "radii": "uff", "theory": "cpcm", "vdwscale": "1.1" } mypcm = {} mysolvent = {} myrem = {} myrem["job_type"] = job_type myrem["basis"] = self.basis_set myrem["max_scf_cycles"] = self.max_scf_cycles myrem["gen_scfman"] = "true" myrem["scf_algorithm"] = self.scf_algorithm if self.dft_rung == 1: myrem["exchange"] = "B3LYP" elif self.dft_rung == 2: myrem["method"] = "B97-D3" myrem["dft_D"] = "D3_BJ" elif self.dft_rung == 3: myrem["method"] = "B97M-rV" elif self.dft_rung == 4: myrem["method"] = "wb97xd" elif self.dft_rung == 5: myrem["method"] = "wB97M-V" else: raise ValueError("dft_rung should be between 1 and 5!") if self.job_type.lower() == "opt": myrem["geom_opt_max_cycles"] = self.geom_opt_max_cycles if self.pcm_dielectric != None: mypcm = pcm_defaults mysolvent["dielectric"] = self.pcm_dielectric myrem["solvent_method"] = 'pcm' if self.overwrite_inputs: for sec, sec_dict in self.overwrite_inputs.items(): if sec == "rem": temp_rem = lower_and_check_unique(sec_dict) for k, v in temp_rem.items(): myrem[k] = v if sec == "pcm": temp_pcm = lower_and_check_unique(sec_dict) for k, v in temp_pcm.items(): mypcm[k] = v if sec == "solvent": temp_solvent = lower_and_check_unique(sec_dict) for k, v in temp_solvent.items(): mysolvent[k] = v super(QChemDictSet, self).__init__( self.molecule, rem=myrem, pcm=mypcm, solvent=mysolvent)