コード例 #1
0
ファイル: empirical_dispersion.py プロジェクト: wdong5/psi4
    def compute_energy(self, molecule):
        """Compute dispersion energy based on engine, dispersion level, and parameters in `self`.

        Parameters
        ----------
        molecule : psi4.core.Molecule
            System for which to compute empirical dispersion correction.

        Returns
        -------
        float
            Dispersion energy [Eh].

        Notes
        -----
        DISPERSION CORRECTION ENERGY
            Disp always set. Overridden in SCF finalization, but that only changes for "-3C" methods.
        self.fctldash + DISPERSION CORRECTION ENERGY
            Set if `fctldash` nonempty.

        """
        if self.engine == 'dftd3':
            jobrec = intf_dftd3.run_dftd3_from_arrays(
                molrec=molecule.to_dict(np_out=False),
                name_hint=self.fctldash,
                level_hint=self.dashlevel,
                param_tweaks=self.dashparams,
                dashcoeff_supplement=self.dashcoeff_supplement,
                ptype='energy',
                verbose=1)

            dashd_part = float(
                jobrec['qcvars']['DISPERSION CORRECTION ENERGY'].data)
            for k, qca in jobrec['qcvars'].items():
                if not isinstance(qca.data, np.ndarray):
                    core.set_variable(k, qca.data)

            if self.fctldash in ['hf3c', 'pbeh3c']:
                gcp_part = gcp.run_gcp(molecule,
                                       self.fctldash,
                                       verbose=False,
                                       dertype=0)
                dashd_part += gcp_part

            return dashd_part
        else:
            ene = self.disp.compute_energy(molecule)
            core.set_variable('DISPERSION CORRECTION ENERGY', ene)
            if self.fctldash:
                core.set_variable(
                    '{} DISPERSION CORRECTION ENERGY'.format(self.fctldash),
                    ene)
            return ene
コード例 #2
0
    def compute_energy(self, molecule):
        """Compute dispersion energy based on engine, dispersion level, and parameters in `self`.

        Parameters
        ----------
        molecule : psi4.core.Molecule
            System for which to compute empirical dispersion correction.

        Returns
        -------
        float
            Dispersion energy [Eh].

        Notes
        -----
        DISPERSION CORRECTION ENERGY
            Disp always set. Overridden in SCF finalization, but that only changes for "-3C" methods.
        self.fctldash + DISPERSION CORRECTION ENERGY
            Set if `fctldash` nonempty.

        """
        if self.engine == 'dftd3':
            jobrec = intf_dftd3.run_dftd3_from_arrays(
                molrec=molecule.to_dict(np_out=False),
                name_hint=self.fctldash,
                level_hint=self.dashlevel,
                param_tweaks=self.dashparams,
                dashcoeff_supplement=self.dashcoeff_supplement,
                ptype='energy',
                verbose=1)

            dashd_part = float(jobrec['qcvars']['DISPERSION CORRECTION ENERGY'].data)
            for k, qca in jobrec['qcvars'].items():
                if not isinstance(qca.data, np.ndarray):
                    core.set_variable(k, qca.data)

            if self.fctldash in ['hf3c', 'pbeh3c']:
                gcp_part = gcp.run_gcp(molecule, self.fctldash, verbose=False, dertype=0)
                dashd_part += gcp_part

            return dashd_part
        else:
            ene = self.disp.compute_energy(molecule)
            core.set_variable('DISPERSION CORRECTION ENERGY', ene)
            if self.fctldash:
                core.set_variable('{} DISPERSION CORRECTION ENERGY'.format(self.fctldash), ene)
            return ene
コード例 #3
0
ファイル: empirical_dispersion.py プロジェクト: wdong5/psi4
    def compute_gradient(self, molecule):
        """Compute dispersion gradient based on engine, dispersion level, and parameters in `self`.

        Parameters
        ----------
        molecule : psi4.core.Molecule
            System for which to compute empirical dispersion correction.

        Returns
        -------
        psi4.core.Matrix
            (nat, 3) dispersion gradient [Eh/a0].

        """
        if self.engine == 'dftd3':
            jobrec = intf_dftd3.run_dftd3_from_arrays(
                molrec=molecule.to_dict(np_out=False),
                name_hint=self.fctldash,
                level_hint=self.dashlevel,
                param_tweaks=self.dashparams,
                dashcoeff_supplement=self.dashcoeff_supplement,
                ptype='gradient',
                verbose=1)

            dashd_part = core.Matrix.from_array(
                jobrec['qcvars']['DISPERSION CORRECTION GRADIENT'].data)
            for k, qca in jobrec['qcvars'].items():
                if not isinstance(qca.data, np.ndarray):
                    core.set_variable(k, qca.data)

            if self.fctldash in ['hf3c', 'pbeh3c']:
                gcp_part = gcp.run_gcp(molecule,
                                       self.fctldash,
                                       verbose=False,
                                       dertype=1)
                dashd_part.add(gcp_part)

            return dashd_part
        else:
            return self.disp.compute_gradient(molecule)
コード例 #4
0
    def compute_gradient(self, molecule):
        """Compute dispersion gradient based on engine, dispersion level, and parameters in `self`.

        Parameters
        ----------
        molecule : psi4.core.Molecule
            System for which to compute empirical dispersion correction.

        Returns
        -------
        psi4.core.Matrix
            (nat, 3) dispersion gradient [Eh/a0].

        """
        if self.engine == 'dftd3':
            jobrec = intf_dftd3.run_dftd3_from_arrays(
                molrec=molecule.to_dict(np_out=False),
                name_hint=self.fctldash,
                level_hint=self.dashlevel,
                param_tweaks=self.dashparams,
                dashcoeff_supplement=self.dashcoeff_supplement,
                ptype='gradient',
                verbose=1)

            dashd_part = core.Matrix.from_array(jobrec['qcvars']['DISPERSION CORRECTION GRADIENT'].data)
            for k, qca in jobrec['qcvars'].items():
                if not isinstance(qca.data, np.ndarray):
                    core.set_variable(k, qca.data)

            if self.fctldash in ['hf3c', 'pbeh3c']:
                gcp_part = gcp.run_gcp(molecule, self.fctldash, verbose=False, dertype=1)
                dashd_part.add(gcp_part)

            return dashd_part
        else:
            return self.disp.compute_gradient(molecule)