def test_double_FF_opt(self): # location of test files test_double_FF_files = os.path.join(module_dir, "..", "..", "test_files", "double_FF_wf") # define starting molecule and workflow object initial_qcin = QCInput.from_file( os.path.join(test_double_FF_files, "block", "launcher_first", "mol.qin.opt_0")) initial_mol = initial_qcin.molecule real_wf = get_wf_double_FF_opt( molecule=initial_mol, pcm_dielectric=10.0, qchem_input_params={ "basis_set": "6-311++g**", "scf_algorithm": "diis", "overwrite_inputs": { "rem": { "sym_ignore": "true" } } }) # use powerup to replace run with fake run ref_dirs = { "first_FF_no_pcm": os.path.join(test_double_FF_files, "block", "launcher_first"), "second_FF_with_pcm": os.path.join(test_double_FF_files, "block", "launcher_second") } fake_wf = use_fake_qchem(real_wf, ref_dirs) self.lp.add_wf(fake_wf) rapidfire( self.lp, fworker=FWorker(env={"max_cores": 32, "db_file": os.path.join(db_dir, "db.json")})) wf_test = self.lp.get_wf_by_fw_id(1) self.assertTrue( all([s == "COMPLETED" for s in wf_test.fw_states.values()])) first_FF = self.get_task_collection().find_one({ "task_label": "first_FF_no_pcm" }) self.assertEqual(first_FF["calcs_reversed"][0]["input"]["solvent"], None) self.assertEqual(first_FF["num_frequencies_flattened"], 1) first_FF_final_mol = Molecule.from_dict( first_FF["output"]["optimized_molecule"]) second_FF = self.get_task_collection().find_one({ "task_label": "second_FF_with_pcm" }) self.assertEqual(second_FF["calcs_reversed"][0]["input"]["solvent"], {"dielectric": "10.0"}) self.assertEqual(second_FF["num_frequencies_flattened"], 1) second_FF_initial_mol = Molecule.from_dict( second_FF["input"]["initial_molecule"]) self.assertEqual(first_FF_final_mol, second_FF_initial_mol)
def test_double_FF_opt(self): # location of test files test_double_FF_files = os.path.join(module_dir, "..", "..", "test_files", "double_FF_wf") # define starting molecule and workflow object initial_qcin = QCInput.from_file( os.path.join(test_double_FF_files, "block", "launcher_first", "mol.qin.opt_0")) initial_mol = initial_qcin.molecule real_wf = get_wf_double_FF_opt( molecule=initial_mol, pcm_dielectric=10.0, max_cores=32, qchem_input_params={ "basis_set": "6-311++g**", "overwrite_inputs": { "rem": { "sym_ignore": "true" } } }) # use powerup to replace run with fake run ref_dirs = { "first_FF_no_pcm": os.path.join(test_double_FF_files, "block", "launcher_first"), "second_FF_with_pcm": os.path.join(test_double_FF_files, "block", "launcher_second") } fake_wf = use_fake_qchem(real_wf, ref_dirs) self.lp.add_wf(fake_wf) rapidfire( self.lp, fworker=FWorker(env={"db_file": os.path.join(db_dir, "db.json")})) wf_test = self.lp.get_wf_by_fw_id(1) self.assertTrue( all([s == "COMPLETED" for s in wf_test.fw_states.values()])) first_FF = self.get_task_collection().find_one({ "task_label": "first_FF_no_pcm" }) self.assertEqual(first_FF["calcs_reversed"][0]["input"]["solvent"], None) self.assertEqual(first_FF["num_frequencies_flattened"], 1) first_FF_final_mol = Molecule.from_dict( first_FF["output"]["optimized_molecule"]) second_FF = self.get_task_collection().find_one({ "task_label": "second_FF_with_pcm" }) self.assertEqual(second_FF["calcs_reversed"][0]["input"]["solvent"], {"dielectric": "10.0"}) self.assertEqual(second_FF["num_frequencies_flattened"], 1) second_FF_initial_mol = Molecule.from_dict( second_FF["input"]["initial_molecule"]) self.assertEqual(first_FF_final_mol, second_FF_initial_mol)
def from_dict(cls, d): return NwInput(Molecule.from_dict(d["mol"]), tasks=[NwTask.from_dict(dt) for dt in d["tasks"]], directives=[tuple(li) for li in d["directives"]], geometry_options=d["geometry_options"], symmetry_options=d["symmetry_options"], memory_options=d["memory_options"])
def from_dict(cls, d): mol = Molecule.from_dict(d["mol"]) return NwTask(mol, charge=d["charge"], spin_multiplicity=d["spin_multiplicity"], title=d["title"], theory=d["theory"], operation=d["operation"], basis_set=d["basis_set"], theory_directives=d["theory_directives"])
def from_dict(cls, d): return FiestaInput(Molecule.from_dict(d["mol"]), correlation_grid=d["correlation_grid"], Exc_DFT_option=d["Exc_DFT_option"], COHSEX_options=d["geometry_options"], GW_options=d["symmetry_options"], BSE_TDDFT_options=d["memory_options"])
def from_dict(cls, d): return GaussianInput(mol=Molecule.from_dict(d["molecule"]), functional=d["functional"], basis_set=d["basis_set"], route_parameters=d["route_parameters"], title=d["title"], charge=d["charge"], spin_multiplicity=d["spin_multiplicity"], input_parameters=d["input_parameters"], link0_parameters=d["link0_parameters"])
def test_rotate_torsion(self): atom_indexes = [6, 8, 9, 10] angle = 90.0 ft = RotateTorsion({ "molecule": self.pt_mol, "atom_indexes": atom_indexes, "angle": angle }) rot_mol = ft.run_task({}) test_mol = Molecule.from_dict( rot_mol.as_dict()["update_spec"]["prev_calc_molecule"]) np.testing.assert_equal(self.pt_rot_90_mol.species, test_mol.species) np.testing.assert_allclose( self.pt_rot_90_mol.cart_coords, test_mol.cart_coords, atol=0.0001)
def test_torsion_potential(self): # location of test files test_tor_files = os.path.join(module_dir, "..", "..", "test_files", "torsion_wf") # define starting molecule and torsion potential workflow object initial_qcin = QCInput.from_file( os.path.join(test_tor_files, "initial_opt", "mol.qin")) initial_mol = initial_qcin.molecule atom_indexes = [6, 8, 9, 10] angles = [0.0, 90.0, 180.0] rem = [] # add the first rem section rem.append({ "jobtype": "opt", "method": "wb97m-v", "basis": "def2-tzvppd", "gen_scfman": "true", "geom_opt_max_cycles": 75, "max_scf_cycles": 300, "scf_algorithm": "diis", "scf_guess": "sad", "sym_ignore": "true", "symmetry": "false", "thresh": 14 }) # the second rem section rem.append({ "jobtype": "opt", "method": "wb97m-v", "basis": "def2-tzvppd", "geom_opt_max_cycles": 75, "max_scf_cycles": 300, "scf_algorithm": "diis", "scf_guess": "sad", "sym_ignore": "true", "symmetry": "false", "thresh": 14 }) real_wf = get_wf_torsion_potential(molecule=initial_mol, atom_indexes=atom_indexes, angles=angles, rem=rem, db_file=">>db_file<<") # use powerup to replace run with fake run # def ref_dirs ref_dirs = { "initial_opt": os.path.join(test_tor_files, "initial_opt"), "opt_0": os.path.join(test_tor_files, "opt_0"), "opt_90": os.path.join(test_tor_files, "opt_90"), "opt_180": os.path.join(test_tor_files, "opt_180") } fake_wf = use_fake_qchem(real_wf, ref_dirs) self.lp.add_wf(fake_wf) rapidfire( self.lp, fworker=FWorker(env={"db_file": os.path.join(db_dir, "db.json")})) wf_test = self.lp.get_wf_by_fw_id(1) self.assertTrue( all([s == "COMPLETED" for s in wf_test.fw_states.values()])) # Checking of the inputs happens in fake_run_qchem so there is no point to retest the inputs # Check the output info that gets inserted in the DB init_opt = self.get_task_collection().find_one( {"task_label": "initial_opt"}) init_opt_final_mol = Molecule.from_dict( init_opt["output"]["optimized_molecule"]) init_opt_final_e = init_opt["output"]["final_energy"] # parse output file act_init_opt_out = QCOutput( os.path.join(test_tor_files, "initial_opt", "mol.qout")) act_init_opt_mol = act_init_opt_out.data[ "molecule_from_optimized_geometry"] act_init_opt_final_e = act_init_opt_out.data["final_energy"] np.testing.assert_equal(act_init_opt_mol.species, init_opt_final_mol.species) np.testing.assert_allclose(act_init_opt_mol.cart_coords, init_opt_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_init_opt_final_e, init_opt_final_e) # Optimization of 0 torsion opt_0 = self.get_task_collection().find_one({"task_label": "opt_0"}) opt_0_final_mol = Molecule.from_dict( opt_0["output"]["optimized_molecule"]) opt_0_final_e = opt_0["output"]["final_energy"] # parse output file act_opt_0_out = QCOutput( os.path.join(test_tor_files, "opt_0", "mol.qout")) act_opt_0_mol = act_opt_0_out.data["molecule_from_optimized_geometry"] act_opt_0_final_e = act_opt_0_out.data["final_energy"] np.testing.assert_equal(act_opt_0_mol.species, opt_0_final_mol.species) np.testing.assert_allclose(act_opt_0_mol.cart_coords, opt_0_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_opt_0_final_e, opt_0_final_e) # Optimization of 90 torsion opt_90 = self.get_task_collection().find_one({"task_label": "opt_90"}) opt_90_final_mol = Molecule.from_dict( opt_90["output"]["optimized_molecule"]) opt_90_final_e = opt_90["output"]["final_energy"] # parse output file act_opt_90_out = QCOutput( os.path.join(test_tor_files, "opt_90", "mol.qout")) act_opt_90_mol = act_opt_90_out.data[ "molecule_from_optimized_geometry"] act_opt_90_final_e = act_opt_90_out.data["final_energy"] np.testing.assert_equal(act_opt_90_mol.species, opt_90_final_mol.species) np.testing.assert_allclose(act_opt_90_mol.cart_coords, opt_90_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_opt_90_final_e, opt_90_final_e) # Optimization of 180 torsion opt_180 = self.get_task_collection().find_one( {"task_label": "opt_180"}) opt_180_final_mol = Molecule.from_dict( opt_180["output"]["optimized_molecule"]) opt_180_final_e = opt_180["output"]["final_energy"] # parse output file act_opt_180_out = QCOutput( os.path.join(test_tor_files, "opt_180", "mol.qout")) act_opt_180_mol = act_opt_180_out.data[ "molecule_from_optimized_geometry"] act_opt_180_final_e = act_opt_180_out.data["final_energy"] np.testing.assert_equal(act_opt_180_mol.species, opt_180_final_mol.species) np.testing.assert_allclose(act_opt_180_mol.cart_coords, opt_180_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_opt_180_final_e, opt_180_final_e)
def test_FFopt_and_critic(self): # location of test files test_files = os.path.join(module_dir, "..", "..", "test_files", "critic_test_files") # define starting molecule and workflow object initial_qcin = QCInput.from_file( os.path.join(test_files, "FFopt", "mol.qin.orig")) initial_mol = initial_qcin.molecule real_wf = get_wf_FFopt_and_critic( molecule=initial_mol, suffix="testing", qchem_input_params={ "dft_rung": 4, "smd_solvent": "custom", "custom_smd": "18.5,1.415,0.00,0.735,20.2,0.00,0.00", "overwrite_inputs": { "rem": { "thresh": "14", "scf_guess_always": "True" } } }) # use powerup to replace run with fake run ref_dirs = { "{}:{}".format(initial_mol.composition.alphabetical_formula, "FFopt_testing"): os.path.join(test_files, "FFopt"), "{}:{}".format(initial_mol.composition.alphabetical_formula, "CC2_testing"): os.path.join(test_files, "critic_example") } fake_wf = use_fake_qchem(real_wf, ref_dirs) self.lp.add_wf(fake_wf) rapidfire(self.lp, fworker=FWorker(env={ "max_cores": 32, "db_file": os.path.join(db_dir, "db.json") })) wf_test = self.lp.get_wf_by_fw_id(1) self.assertTrue( all([s == "COMPLETED" for s in wf_test.fw_states.values()])) FFopt = self.get_task_collection().find_one({ "task_label": "{}:{}".format(initial_mol.composition.alphabetical_formula, "FFopt_testing") }) self.assertEqual(FFopt["calcs_reversed"][0]["input"]["smx"]["solvent"], "other") self.assertEqual(FFopt["num_frequencies_flattened"], 0) FFopt_final_mol = Molecule.from_dict( FFopt["output"]["optimized_molecule"]) CC2 = self.get_task_collection().find_one({ "task_label": "{}:{}".format(initial_mol.composition.alphabetical_formula, "CC2_testing") }) CC2_initial_mol = Molecule.from_dict(CC2["input"]["initial_molecule"]) self.assertEqual(FFopt_final_mol, CC2_initial_mol) self.assertEqual(CC2["output"]["job_type"], "sp") self.assertEqual(CC2["output"]["final_energy"], -343.4820411597) critic2_drone_ref = loadfn( os.path.join(test_files, "critic_example", "critic2_drone_ref.json")) self.assertEqual(CC2["critic2"], critic2_drone_ref)
def test_torsion_potential(self): # location of test files test_tor_files = os.path.join(module_dir, "..", "..", "test_files", "torsion_wf") # define starting molecule and torsion potential workflow object initial_qcin = QCInput.from_file( os.path.join(test_tor_files, "initial_opt", "mol.qin")) initial_mol = initial_qcin.molecule atom_indexes = [6, 8, 9, 10] angles = [0.0, 90.0, 180.0] rem = [] # add the first rem section rem.append({ "jobtype": "opt", "method": "wb97m-v", "basis": "def2-tzvppd", "gen_scfman": "true", "geom_opt_max_cycles": 75, "max_scf_cycles": 300, "scf_algorithm": "diis", "scf_guess": "sad", "sym_ignore": "true", "symmetry": "false", "thresh": 14 }) # the second rem section rem.append({ "jobtype": "opt", "method": "wb97m-v", "basis": "def2-tzvppd", "geom_opt_max_cycles": 75, "max_scf_cycles": 300, "scf_algorithm": "diis", "scf_guess": "sad", "sym_ignore": "true", "symmetry": "false", "thresh": 14 }) real_wf = get_wf_torsion_potential( molecule=initial_mol, atom_indexes=atom_indexes, angles=angles, rem=rem, db_file=">>db_file<<") # use powerup to replace run with fake run # def ref_dirs ref_dirs = { "initial_opt": os.path.join(test_tor_files, "initial_opt"), "opt_0": os.path.join(test_tor_files, "opt_0"), "opt_90": os.path.join(test_tor_files, "opt_90"), "opt_180": os.path.join(test_tor_files, "opt_180") } fake_wf = use_fake_qchem(real_wf, ref_dirs) self.lp.add_wf(fake_wf) rapidfire( self.lp, fworker=FWorker(env={"db_file": os.path.join(db_dir, "db.json")})) wf_test = self.lp.get_wf_by_fw_id(1) self.assertTrue( all([s == "COMPLETED" for s in wf_test.fw_states.values()])) # Checking of the inputs happens in fake_run_qchem so there is no point to retest the inputs # Check the output info that gets inserted in the DB init_opt = self.get_task_collection().find_one({ "task_label": "initial_opt" }) init_opt_final_mol = Molecule.from_dict( init_opt["output"]["optimized_molecule"]) init_opt_final_e = init_opt["output"]["final_energy"] # parse output file act_init_opt_out = QCOutput( os.path.join(test_tor_files, "initial_opt", "mol.qout")) act_init_opt_mol = act_init_opt_out.data[ "molecule_from_optimized_geometry"] act_init_opt_final_e = act_init_opt_out.data["final_energy"] np.testing.assert_equal(act_init_opt_mol.species, init_opt_final_mol.species) np.testing.assert_allclose( act_init_opt_mol.cart_coords, init_opt_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_init_opt_final_e, init_opt_final_e) # Optimization of 0 torsion opt_0 = self.get_task_collection().find_one({"task_label": "opt_0"}) opt_0_final_mol = Molecule.from_dict( opt_0["output"]["optimized_molecule"]) opt_0_final_e = opt_0["output"]["final_energy"] # parse output file act_opt_0_out = QCOutput( os.path.join(test_tor_files, "opt_0", "mol.qout")) act_opt_0_mol = act_opt_0_out.data["molecule_from_optimized_geometry"] act_opt_0_final_e = act_opt_0_out.data["final_energy"] np.testing.assert_equal(act_opt_0_mol.species, opt_0_final_mol.species) np.testing.assert_allclose( act_opt_0_mol.cart_coords, opt_0_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_opt_0_final_e, opt_0_final_e) # Optimization of 90 torsion opt_90 = self.get_task_collection().find_one({"task_label": "opt_90"}) opt_90_final_mol = Molecule.from_dict( opt_90["output"]["optimized_molecule"]) opt_90_final_e = opt_90["output"]["final_energy"] # parse output file act_opt_90_out = QCOutput( os.path.join(test_tor_files, "opt_90", "mol.qout")) act_opt_90_mol = act_opt_90_out.data[ "molecule_from_optimized_geometry"] act_opt_90_final_e = act_opt_90_out.data["final_energy"] np.testing.assert_equal(act_opt_90_mol.species, opt_90_final_mol.species) np.testing.assert_allclose( act_opt_90_mol.cart_coords, opt_90_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_opt_90_final_e, opt_90_final_e) # Optimization of 180 torsion opt_180 = self.get_task_collection().find_one({ "task_label": "opt_180" }) opt_180_final_mol = Molecule.from_dict( opt_180["output"]["optimized_molecule"]) opt_180_final_e = opt_180["output"]["final_energy"] # parse output file act_opt_180_out = QCOutput( os.path.join(test_tor_files, "opt_180", "mol.qout")) act_opt_180_mol = act_opt_180_out.data[ "molecule_from_optimized_geometry"] act_opt_180_final_e = act_opt_180_out.data["final_energy"] np.testing.assert_equal(act_opt_180_mol.species, opt_180_final_mol.species) np.testing.assert_allclose( act_opt_180_mol.cart_coords, opt_180_final_mol.cart_coords, atol=0.0001) np.testing.assert_equal(act_opt_180_final_e, opt_180_final_e)
def from_dict(cls, d): return NwInput(Molecule.from_dict(d["mol"]), [NwTask.from_dict(dt) for dt in d["tasks"]], d["directives"])