def test_RunCritic2(self): os.chdir( os.path.join( module_dir, "..", "..", "test_files", "critic_test_files", "small_critic_example", )) firetask = RunCritic2(molecule=self.mol, cube_file="dens.0.cube.gz") firetask.run_task(fw_spec={}) with open("cpreport_correct.json") as f: cpreport_reference = json.load(f) with open("yt_correct.json") as f: yt_reference = json.load(f) with open("cpreport.json") as f: cpreport = json.load(f) with open("yt.json") as f: yt = json.load(f) # Context for below - reference files were built before units were added # to Critic2, and we avoid testing the actual critical points because they # can change order between runs. But comparing everything else is sufficient. for key in cpreport: if key in ["structure", "field"]: self.assertEqual(cpreport_reference[key], cpreport[key]) for key in yt: if key != "units": self.assertEqual(yt_reference[key], yt[key])
def test_CubeAndCritic2FW_defaults(self): firework = CubeAndCritic2FW(molecule=self.act_mol) self.assertEqual( firework.tasks[0].as_dict(), WriteInputFromIOSet(molecule=self.act_mol, qchem_input_set="SinglePointSet", input_file="mol.qin", qchem_input_params={ "plot_cubes": True }).as_dict()) self.assertEqual( firework.tasks[1].as_dict(), RunQChemCustodian(qchem_cmd=">>qchem_cmd<<", multimode=">>multimode<<", input_file="mol.qin", output_file="mol.qout", max_cores=">>max_cores<<", job_type="normal").as_dict()) self.assertEqual( firework.tasks[2].as_dict(), RunCritic2(molecule=self.act_mol, cube_file="dens.0.cube.gz").as_dict()) self.assertEqual(firework.tasks[3].as_dict(), ProcessCritic2(molecule=self.act_mol).as_dict()) self.assertEqual( firework.tasks[4].as_dict(), QChemToDb(db_file=None, input_file="mol.qin", output_file="mol.qout", additional_fields={ "task_label": "cube and critic2" }).as_dict()) self.assertEqual(firework.parents, []) self.assertEqual(firework.name, "cube and critic2")
def test_CubeAndCritic2FW_not_defaults(self): firework = CubeAndCritic2FW( molecule=self.act_mol, name="special cube and critic2", qchem_cmd="qchem -slurm", multimode="mpi", max_cores=12, qchem_input_params={"pcm_dielectric": 10.0}, db_file=os.path.join(db_dir, "db.json"), parents=None, ) self.assertEqual( firework.tasks[0].as_dict(), WriteInputFromIOSet( molecule=self.act_mol, qchem_input_set="SinglePointSet", input_file="mol.qin", qchem_input_params={ "pcm_dielectric": 10.0, "plot_cubes": True }, ).as_dict(), ) self.assertEqual( firework.tasks[1].as_dict(), RunQChemCustodian( qchem_cmd="qchem -slurm", multimode="mpi", input_file="mol.qin", output_file="mol.qout", max_cores=12, job_type="normal", ).as_dict(), ) self.assertEqual( firework.tasks[2].as_dict(), RunCritic2(molecule=self.act_mol, cube_file="dens.0.cube.gz").as_dict(), ) self.assertEqual(firework.tasks[3].as_dict(), ProcessCritic2(molecule=self.act_mol).as_dict()) self.assertEqual( firework.tasks[4].as_dict(), QChemToDb( db_file=os.path.join(db_dir, "db.json"), input_file="mol.qin", output_file="mol.qout", additional_fields={ "task_label": "special cube and critic2" }, ).as_dict(), ) self.assertEqual(firework.parents, []) self.assertEqual(firework.name, "special cube and critic2")
def __init__(self, molecule=None, name="cube and critic2", qchem_cmd=">>qchem_cmd<<", multimode=">>multimode<<", max_cores=">>max_cores<<", qchem_input_params=None, db_file=None, parents=None, **kwargs): """ Args: molecule (Molecule): Input molecule. name (str): Name for the Firework. qchem_cmd (str): Command to run QChem. Supports env_chk. multimode (str): Parallelization scheme, either openmp or mpi. Supports env_chk. max_cores (int): Maximum number of cores to parallelize over. Supports env_chk. qchem_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/qchem/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, as seen in the test_double_FF_opt workflow test. 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__. """ qchem_input_params = copy.deepcopy(qchem_input_params) or {} qchem_input_params["plot_cubes"] = True input_file = "mol.qin" output_file = "mol.qout" t = [] t.append( WriteInputFromIOSet(molecule=molecule, qchem_input_set="SinglePointSet", input_file=input_file, qchem_input_params=qchem_input_params)) t.append( RunQChemCustodian(qchem_cmd=qchem_cmd, multimode=multimode, input_file=input_file, output_file=output_file, max_cores=max_cores, job_type="normal")) t.append(RunCritic2(molecule=molecule, cube_file="dens.0.cube.gz")) t.append( QChemToDb(db_file=db_file, input_file=input_file, output_file=output_file, additional_fields={"task_label": name})) super(CubeAndCritic2FW, self).__init__(t, parents=parents, name=name, **kwargs)