Example #1
0
  def test_scf_calculations_with_symbolic_xc(self, xc_code, functional, params):
    hybrid_coeff, rsh_params = utils.get_hybrid_rsh_params(xc_code)
    ks_ref = dft.RKS(self.mol)
    ks_ref.xc = xc_code
    etot_ref = ks_ref.kernel()

    ks = dft.RKS(self.mol)
    ks.define_xc_(
        functional.make_eval_xc(omega=rsh_params[0], **params),
        xctype='MGGA',
        hyb=hybrid_coeff,
        rsh=rsh_params)
    etot = ks.kernel()

    logging.info('Etot = %f, Etot_libxc = %f, diff = %f',
                 etot, etot_ref, abs(etot - etot_ref))
    self.assertAlmostEqual(etot, etot_ref, delta=2e-6)
Example #2
0
  def test_scf_calculations_with_custom_xc(self, xc_name, xc_code):
    hybrid_coeff, rsh_params = utils.get_hybrid_rsh_params(xc_name)
    ks_ref = dft.UKS(self.mol)
    ks_ref.xc = xc_code
    etot_ref = ks_ref.kernel()

    ks = dft.UKS(self.mol)
    ks.define_xc_(
        xc.make_eval_xc(xc_name),
        xctype='MGGA',
        hyb=hybrid_coeff,
        rsh=rsh_params)
    etot = ks.kernel()

    logging.info('Etot = %f, Etot_libxc = %f, diff = %f',
                 etot, etot_ref, abs(etot - etot_ref))
    self.assertAlmostEqual(etot, etot_ref, delta=2e-6)
    def test_scf_calculation_with_custom_xc_default_params(
            self, xc_name, xc_name_libxc, charge, spin):
        hybrid_coeff, rsh_params = utils.get_hybrid_rsh_params(xc_name)
        res_libxc = scf.run_scf_for_mol(atom='H  0. 0. 0.;H  0. 0. 0.74',
                                        charge=charge,
                                        spin=spin,
                                        xc=xc_name_libxc,
                                        basis='def2svpd')

        res_custom = scf.run_scf_for_mol(atom='H  0. 0. 0.;H  0. 0. 0.74',
                                         charge=charge,
                                         spin=spin,
                                         xc=xc_name,
                                         xc_fun=xc.make_eval_xc(xc_name),
                                         hybrid_coeff=hybrid_coeff,
                                         rsh_params=rsh_params,
                                         basis='def2svpd')

        for energy in ['Etot', 'Exc', 'Exx', 'Exxlr', 'Enlc']:
            self.assertAlmostEqual(res_libxc[energy],
                                   res_custom[energy],
                                   delta=2e-6)
    def test_scf_calculation_with_custom_xc_custom_params(self, charge, spin):
        hybrid_coeff, rsh_params = utils.get_hybrid_rsh_params('b97m_v')
        res_libxc = scf.run_scf_for_mol(atom='H  0. 0. 0.;H  0. 0. 0.74',
                                        charge=charge,
                                        spin=spin,
                                        xc='b97m_v',
                                        basis='def2svpd')

        res_custom = scf.run_scf_for_mol(atom='H  0. 0. 0.;H  0. 0. 0.74',
                                         charge=charge,
                                         spin=spin,
                                         xc='b97m_v',
                                         xc_fun=xc.make_eval_xc(
                                             'wb97m_v',
                                             params=mgga.B97MV_PARAMS),
                                         hybrid_coeff=hybrid_coeff,
                                         rsh_params=rsh_params,
                                         basis='def2svpd')

        for energy in ['Etot', 'Exc', 'Exx', 'Exxlr', 'Enlc']:
            self.assertAlmostEqual(res_libxc[energy],
                                   res_custom[energy],
                                   delta=2e-6)
    def test_scf_calculation_with_symbolic_functional(self, charge, spin):
        hybrid_coeff, rsh_params = utils.get_hybrid_rsh_params('wb97m_v')
        res_libxc = scf.run_scf_for_mol(atom='H  0. 0. 0.;H  0. 0. 0.74',
                                        charge=charge,
                                        spin=spin,
                                        xc='wb97m_v',
                                        basis='def2svpd')

        res_custom = scf.run_scf_for_mol(
            atom='H  0. 0. 0.;H  0. 0. 0.74',
            charge=charge,
            spin=spin,
            xc='wb97m_v',
            xc_fun=xc_functionals.wb97mv_short.make_eval_xc(
                omega=rsh_params[0],
                **xc_functionals.WB97MV_PARAMETERS_UTRANSFORM),
            hybrid_coeff=hybrid_coeff,
            rsh_params=rsh_params,
            basis='def2svpd')

        for energy in ['Etot', 'Exc', 'Exx', 'Exxlr', 'Enlc']:
            self.assertAlmostEqual(res_libxc[energy],
                                   res_custom[energy],
                                   delta=2e-6)
  def test_get_hybrid_rsh_params(self):
    hybrid_coeff, rsh_params = utils.get_hybrid_rsh_params('wb97m_v')

    self.assertAlmostEqual(hybrid_coeff, 1.0)
    self.assertSequenceAlmostEqual(rsh_params, (0.3, 1.0, -0.85))