def test_molecule_equality(dmso_qcmol, cc_qcmol): mol = psiresp.Molecule(qcmol=dmso_qcmol) mol.generate_orientations() mol_with_orient = psiresp.Molecule(qcmol=dmso_qcmol) mol_with_orient.generate_orientations() assert mol == mol_with_orient mol_without_orient = psiresp.Molecule(qcmol=dmso_qcmol) assert not mol_without_orient.conformers assert mol.conformers assert mol == mol_without_orient ccmol = psiresp.Molecule(qcmol=cc_qcmol) assert mol != ccmol ccmol.generate_orientations() assert mol != ccmol
def test_conformer_generation(nme2ala2_c1_opt_qcmol): pytest.importorskip("rdkit") options = ConformerGenerationOptions(n_max_conformers=5) mol = psiresp.Molecule(qcmol=nme2ala2_c1_opt_qcmol, conformer_generation_options=options) mol.generate_conformers() mol.generate_orientations() assert len(mol.conformers) == 6 assert len(mol.conformers[0].orientations) == 1
def test_resp2(fractal_client): pytest.importorskip("psi4") # generate molecule c1 = qcel.models.Molecule.from_file(ETHANOL_RESP2_C1) c2 = qcel.models.Molecule.from_file(ETHANOL_RESP2_C2) mol = psiresp.Molecule(qcmol=c1, optimize_geometry=False, keep_original_orientation=True) mol.generate_conformers() mol.add_conformer_with_coordinates(c2.geometry, units="bohr") assert mol.n_conformers == 2 assert mol.n_orientations == 0 job = psiresp.RESP2(molecules=[mol]) job.run(client=fractal_client) assert job.vacuum.n_conformers == 2 assert job.vacuum.n_orientations == 2 assert job.solvated.n_conformers == 2 assert job.solvated.n_orientations == 2 ETOH_SOLV_CHARGES = np.array([ -0.2416, 0.3544, -0.6898, 0.0649, 0.0649, 0.0649, -0.0111, -0.0111, 0.4045 ]) ETOH_GAS_CHARGES = np.array([ -0.2300, 0.3063, -0.5658, 0.0621, 0.0621, 0.0621, -0.0153, -0.0153, 0.3339 ]) ETOH_REF_CHARGES = np.array([ -0.2358, 0.33035, -0.6278, 0.0635, 0.0635, 0.0635, -0.0132, -0.0132, 0.3692 ]) assert_allclose(job.solvated.charges[0], ETOH_SOLV_CHARGES, atol=5e-03) assert_allclose(job.vacuum.charges[0], ETOH_GAS_CHARGES, atol=5e-03) assert_allclose(job.get_charges(delta=0.5)[0], ETOH_REF_CHARGES, atol=5e-03)
def test_config_resp(config_class, red_charges, fractal_client, dmso): pytest.importorskip("psi4") qcdmso = qcel.models.Molecule.from_file(DMSO_O1, fix_com=True, fix_orientation=True) qcdmso2 = qcel.models.Molecule.from_file(DMSO_O2, fix_com=True, fix_orientation=True) dmso = psiresp.Molecule(qcmol=qcdmso, optimize_geometry=False, keep_original_orientation=True) constraints = psiresp.ChargeConstraintOptions(symmetric_methylenes=False, symmetric_methyls=False) indices = [[0, 6], [1, 2, 3, 7, 8, 9]] for ix in indices: constraints.add_charge_equivalence_constraint_for_molecule(dmso, indices=ix) job = config_class( molecules=[dmso], charge_constraints=constraints, ) assert isinstance(job, config_class) job.generate_conformers() dmso_c1 = job.molecules[0].conformers[0] dmso_c1.add_orientation_with_coordinates(qcdmso.geometry, units="bohr") dmso_c1.add_orientation_with_coordinates(qcdmso2.geometry, units="bohr") assert len(job.molecules[0].conformers) == 1 assert len(job.molecules[0].conformers[0].orientations) == 2 job.compute_orientation_energies(client=fractal_client) job.compute_esps() job.compute_charges() assert_allclose(job.charges, red_charges, atol=1e-3)
def test_molecule_defaults(dmso_qcmol): mol = psiresp.Molecule(qcmol=dmso_qcmol) mol.generate_orientations() assert len(mol.conformers) == 1 assert len(mol.conformers[0].orientations) == 1 assert repr(mol) == "Molecule(name=C2H6OS, charge=0) with 1 conformers"