Esempio n. 1
0
def run_hf(xyz, basis, charge=0, multiplicity=1, conv_tol=None,
           conv_tol_grad=1e-8, max_iter=150):
    basis_remap = {
        "sto3g": "sto-3g",
        "def2tzvp": "def2-tzvp",
        "ccpvdz": "cc-pvdz",
    }

    with tempfile.TemporaryDirectory() as tmpdir:
        infile = os.path.join(tmpdir, "vlx.in")
        outfile = os.path.join(tmpdir, "vlx.out")
        with open(infile, "w") as fp:
            lines = ["@jobs", "task: hf", "@end", ""]
            lines += ["@method settings",
                      "basis: {}".format(basis_remap.get(basis, basis)),
                      "@end"]
            lines += ["@molecule",
                      "charge: {}".format(charge),
                      "multiplicity: {}".format(multiplicity),
                      "units: bohr",
                      "xyz:\n{}".format("\n".join(xyz.split(";"))),
                      "@end"]
            fp.write("\n".join(lines))
        task = vlx.MpiTask([infile, outfile], MPI.COMM_WORLD)

        scfdrv = vlx.ScfRestrictedDriver(task.mpi_comm, task.ostream)
        # elec. gradient norm
        scfdrv.conv_thresh = conv_tol_grad
        scfdrv.max_iter = max_iter
        scfdrv.compute(task.molecule, task.ao_basis, task.min_basis)
        scfdrv.task = task
    return scfdrv
Esempio n. 2
0
File: vlx.py Progetto: vkimb/qcifc
    def run_scf(self, mol, conv_thresh=1e-6):
        inp = str(pathlib.Path(self.get_workdir()) / f'{mol}.inp')
        out = str(pathlib.Path(self.get_workdir()) / f'{mol}.out')
        self.task = vlx.MpiTask((inp, out), self.comm)

        if self.task.molecule.get_multiplicity() == 1:
            self.scf_driver = vlx.ScfRestrictedDriver(self.comm,
                                                      self.task.ostream)
        else:
            self.scf_driver = vlx.ScfUnrestrictedDriver(
                self.comm, self.task.ostream)
        self.scf_driver.conv_thresh = conv_thresh
        self.scf_driver.compute(self.task.molecule, self.task.ao_basis,
                                self.task.min_basis)
Esempio n. 3
0
def run_hf(xyz,
           basis,
           charge=0,
           multiplicity=1,
           conv_tol_grad=1e-8,
           max_iter=150,
           pe_options=None):
    basis_remap = {
        "sto3g": "sto-3g",
        "def2tzvp": "def2-tzvp",
        "ccpvdz": "cc-pvdz",
    }

    with tempfile.TemporaryDirectory() as tmpdir:
        infile = os.path.join(tmpdir, "vlx.in")
        outfile = os.path.join(tmpdir, "vlx.out")
        with open(infile, "w") as fp:
            lines = ["@jobs", "task: hf", "@end", ""]
            lines += [
                "@method settings",
                "basis: {}".format(basis_remap.get(basis, basis))
            ]
            # TODO: PE results in VeloxChem are currently wrong, because
            # polarizabilities are always made isotropic
            if pe_options:
                potfile = pe_options["potfile"]
                lines += ["pe: yes", f"potfile: {potfile}"]
            lines += ["@end"]
            lines += [
                "@molecule", "charge: {}".format(charge),
                "multiplicity: {}".format(multiplicity), "units: bohr",
                "xyz:\n{}".format("\n".join(xyz.split(";"))), "@end"
            ]
            fp.write("\n".join(lines))
        task = MpiTask([infile, outfile], MPI.COMM_WORLD)

        scfdrv = vlx.ScfRestrictedDriver(task.mpi_comm, task.ostream)
        scfdrv.update_settings(task.input_dict['scf'],
                               task.input_dict['method_settings'])
        # elec. gradient norm
        scfdrv.conv_thresh = conv_tol_grad
        scfdrv.max_iter = max_iter
        scfdrv.compute(task.molecule, task.ao_basis, task.min_basis)
        scfdrv.task = task
    return scfdrv
Esempio n. 4
0
    with open(infile, "w") as fp:
        fp.write("""
                 @jobs
                 task: hf
                 @end

                 @method settings
                 basis: sto-3g
                 @end

                 @molecule
                 charge: 0
                 multiplicity: 1
                 units: bohr
                 xyz:
                 O 0 0 0
                 H 0 0 1.795239827225189
                 H 1.693194615993441 0 -0.599043184453037
                 @end
                 """)
    task = MpiTask([infile, outfile], MPI.COMM_WORLD)
    scfdrv = vlx.ScfRestrictedDriver(task.mpi_comm, task.ostream)
    scfdrv.conv_thresh = 1e-8
    scfdrv.compute(task.molecule, task.ao_basis, task.min_basis)
    scfdrv.task = task

# Run an adc2 calculation:
state = adcc.adc2(scfdrv, n_singlets=5)
print(state.describe())
Esempio n. 5
0
method_settings = {}

comm = MPI.COMM_WORLD
ostream = vlx.OutputStream(sys.stdout)

molecule = vlx.Molecule.read_str(molecule_string, units='angs')
basis = vlx.MolecularBasis.read(molecule, basis_set_label)

ostream.print_block(molecule.get_string())
ostream.print_block(basis.get_string('Atomic Basis', molecule))
ostream.flush()

# SCF calculation

# Do SCF again with non-custom routine
scfdrv = vlx.ScfRestrictedDriver(comm, ostream)
scfdrv.update_settings(scf_settings, method_settings)
scfdrv.compute(molecule, basis)

MOs = scfdrv.scf_tensors['C']
F = scfdrv.scf_tensors['F'][0]

# AO integrals (pq|rs)
n_ao = MOs.shape[0]
pqrs = np.zeros((n_ao, n_ao, n_ao, n_ao))

eri_drv = vlx.ElectronRepulsionIntegralsDriver(comm)
eri_drv.compute_in_mem(molecule, basis, pqrs)

# MO integrals (tu|vw), chemists' notation
tqrs = np.einsum('pqrs,pt->tqrs', pqrs, MOs, optimize=True)