Exemplo n.º 1
0
def from_sa_mcscf(mc,
                  fname,
                  state=None,
                  cas_natorb=False,
                  cas_mo_energy=False,
                  **kwargs):
    if state is None:
        return from_mcscf(mc, fname, cas_natorb=cas_natorb, **kwargs)
    casdm1 = mc.fcisolver.states_make_rdm1(mc.ci, mc.ncas, mc.nelecas)[state]
    mo_coeff, mo_ci, mo_energy = mc.canonicalize(ci=mc.ci[state],
                                                 cas_natorb=cas_natorb,
                                                 casdm1=casdm1)
    if not cas_mo_energy:
        mo_energy[mc.ncore:][:mc.ncas] = 0.0
    # TODO: cleaner interface. Probably invent "state_make_?dm*" functions ("state" singular)
    # and apply them also to the StateAverageMCSCFSolver instance
    mo_occ = np.zeros_like(mo_energy)
    mo_occ[:mc.ncore] = 2.0
    ci = mc.ci
    ci[state] = mo_ci
    mo_occ[mc.ncore:][:mc.ncas] = mc.fcisolver.states_make_rdm1(
        ci, mc.ncas, mc.nelecas)[state].diagonal()
    return from_mo(mc.mol,
                   fname,
                   mo_coeff,
                   occ=mo_occ,
                   ene=mo_energy,
                   **kwargs)
Exemplo n.º 2
0
#
# Load MF orbitals
#
chkname = "_chk/pp_dianion_dz_b3lyp.chk"
mol = chkfile.load_mol(chkname)
mol.verbose = 5
mf = dft.RKS(mol)
mf.__dict__.update(chkfile.load(chkname, "scf"))

#
# SA-MCSCF
#
nelecas, ncas = (4, 4)
n_states = 3
weights = np.ones(n_states) / n_states

mc = mcscf.CASSCF(mf, ncas, nelecas).state_average_(weights)
mc.fix_spin(ss=0)
mc.natorb = True
mc.chkfile = "_chk/pp_dianion_dz_cas_4e_4o.chk"
cas_list = [142, 143, 150, 151]
mo = mcscf.sort_mo(mc, mf.mo_coeff, cas_list)
mc.mc1step(mo)

#
# Analysis and processing
#
mc.analyze()
molden.from_mcscf(mc, "_molden/pp_dianion_dz_cas_4e_4o.molden")
molden.from_mo(mol, "_molden/pp_dianion_dz_cas_4e_4o_alt.molden", mc.mo_coeff)
Exemplo n.º 3
0
mf.chkfile = "_chk/pp_anion_pt_chg_dz_b3lyp.chk"
mf.kernel()
# mf.analyze()

#
# Dump orbitals
#
molden.dump_scf(mf, "_molden/pp_anion_pt_chg_dz_b3lyp.molden")

#
# SA-MCSCF
#
nelecas, ncas = (4, 4)
n_states = 3
weights = np.ones(n_states) / n_states

mc = mcscf.CASSCF(mf, ncas, nelecas).state_average_(weights)
mc.fix_spin(ss=0)
mc.natorb = True
mc.chkfile = "_chk/pp_anion_pt_chg_dz_cas_4e_4o.chk"
cas_list = [118, 119, 120, 121]
mo = mcscf.sort_mo(mc, mf.mo_coeff, cas_list)
mc.mc1step(mo)

#
# Analysis and processing
#
mc.analyze()
molden.from_mcscf(mc, "_molden/pp_anion_pt_chg_dz_cas.molden")
molden.from_mo(mol, "_molden/pp_anion_pt_chg_dz_cas_alt.molden", mc.mo_coeff)
Exemplo n.º 4
0
    gsmo = np.load(gsmofile)
    mc = mcpdft.CASSCF(mf, transl_type + fnal, ncas, nelecas, grids_level=3)
    mo = mcscf.project_init_guess(mc, gsmo, prev_mol=gsmol)
    molden.from_mo(mol, 'check_projection.molden', mo)
    mc.kernel(mo)
    mc = mc.as_scanner()
else:
    mc = mcpdft.CASSCF(mf, transl_type + fnal, ncas, nelecas,
                       grids_level=3).run().as_scanner()
mc0 = mcpdft.CASSCF(mf, otfnal0, ncas, nelecas,
                    grids_level=3).run().as_scanner()
mc1 = mcpdft.CASSCF(mf, otfnal1, ncas, nelecas,
                    grids_level=3).run().as_scanner()
mc2 = mcpdft.CASSCF(mf, otfnal2, ncas, nelecas,
                    grids_level=3).run().as_scanner()
molden.from_mcscf(mc0, moldenfile)
np.save(mofile, mc.mo_coeff)

# Do MCSCF scan forwards
table = np.zeros((HHrange.size, 9))
table[:, 0] = HHrange
for ix, HHdist in enumerate(HHrange):
    geom = 'H 0 0 0; H 0 0 {:.6f}'.format(HHdist)
    efci = fci(geom)
    epdft = mc(geom)
    mc0.mo_coeff = mc1.mo_coeff = mc2.mo_coeff = mc.mo_coeff
    molden.from_mo(mol, logfile[:-3] + '{:.2f}.molden'.format(HHdist),
                   mc.mo_coeff)
    epdft0 = mc0(geom)
    epdft1 = mc1(geom)
    epdft2 = mc2(geom)
Exemplo n.º 5
0
# Load MF orbitals
#
chkname = "_chk/pp_neutral_dz_b3lyp.chk"
mol = chkfile.load_mol(chkname)
mol.verbose = 5
mf = dft.RKS(mol)
mf.__dict__.update(chkfile.load(chkname, "scf"))

#
# SA-MCSCF
#
nelecas, ncas = (4, 4)
n_states = 3
weights = np.ones(n_states) / n_states

mc = mcscf.CASSCF(mf, ncas, nelecas).state_average_(weights)
mc.fix_spin(ss=0)
mc.natorb = True
mc.chkfile = "_chk/pp_neutral_dz_cas_4e_4o.chk"
cas_list = [148, 149, 150, 151]
mo = mcscf.sort_mo(mc, mf.mo_coeff, cas_list)
mc.mc1step(mo)

#
# Analysis and processing
#
mc.analyze()

molden.from_mo(mol, "_molden/pp_neutral_dz_cas_4e_4o_alt.molden", mc.mo_coeff)
molden.from_mcscf(mc, "_molden/pp_neutral_dz_cas_4e_4o.molden")