Exemple #1
0
from pyscf.tools import molden
from c2h4n4_struct import structure as struct
from mrh.my_pyscf.mcscf.lasscf_testing import LASSCF

dr_nn = 2.0
mol = struct(dr_nn, dr_nn, '6-31g', symmetry=False)
mol.verbose = lib.logger.DEBUG
mol.output = '/dev/null'
mol.spin = 0
mol.build()
mf = scf.RHF(mol).run()
las = LASSCF(mf, (4, 4), ((3, 1), (1, 3)), spin_sub=(3, 3))
las.max_cycle_macro = 1
las.kernel()
las.mo_coeff = np.loadtxt('test_lasci_mo.dat')
las.ci = [[np.loadtxt('test_lasci_ci0.dat')],
          [-np.loadtxt('test_lasci_ci1.dat').T]]
ugg = las.get_ugg()
h_op = las.get_hop(ugg=ugg)
np.random.seed(0)
x = np.random.rand(ugg.nvar_tot)


def tearDownModule():
    global mol, mf, las, ugg, h_op, x
    mol.stdout.close()
    del mol, mf, las, ugg, h_op, x


class KnownValues(unittest.TestCase):
    def test_grad(self):
        gorb0, gci0, gx0 = las.get_grad(ugg=ugg)
Exemple #2
0
] * 56
nroots = 57
# End building crazy state list

dr_nn = 2.0
mol = struct(dr_nn, dr_nn, '6-31g', symmetry='Cs')
mol.verbose = lib.logger.INFO
mol.output = 'test_lassi_op.log'
mol.spin = 0
mol.build()
mf = scf.RHF(mol).run()
las = LASSCF(mf, (4, 2, 4), (4, 2, 4))
las.state_average_(weights=weights, **states)
las.mo_coeff = las.localize_init_guess(
    (list(range(3)), list(range(3, 7)), list(range(7, 10))), mf.mo_coeff)
las.ci = get_init_guess_ci(las, las.mo_coeff, las.get_h2eff(las.mo_coeff))
np.random.seed(1)
for c in las.ci:
    for iroot in range(len(c)):
        c[iroot] = np.random.rand(*c[iroot].shape)
        c[iroot] /= linalg.norm(c[iroot])
orbsym = getattr(las.mo_coeff, 'orbsym', None)
if orbsym is None and callable(getattr(las, 'label_symmetry_', None)):
    orbsym = las.label_symmetry_(las.mo_coeff).orbsym
if orbsym is not None:
    orbsym = orbsym[las.ncore:las.ncore + las.ncas]
wfnsym = 0
idx_all = np.ones(nroots, dtype=np.bool_)
rand_mat = np.random.rand(57, 57)
rand_mat += rand_mat.T
e, si = linalg.eigh(rand_mat)
Exemple #3
0
las = LASSCF(mf, (4, 4), (4, 4), spin_sub=(1, 1))
mo_loc = las.localize_init_guess((list(range(3)), list(range(9, 12))),
                                 mo_coeff=mo_coeff)
las.state_average_(weights=[0.5, 0.5], spins=[[0, 0], [2, -2]])
las.set(max_cycle_macro=1, max_cycle_micro=1, ah_level_shift=0).kernel()

np.random.seed(1)
ugg = las.get_ugg()
ci0 = [np.random.rand(ncsf) for ncsf in ugg.ncsf_sub.ravel()]
ci0 = [c / linalg.norm(c) for c in ci0]
x0 = np.concatenate([
    np.zeros(ugg.nvar_orb),
] + ci0)
_, ci0_sa = ugg.unpack(x0)
las.mo_coeff = mo_loc
las.ci = ci0_sa
hop = las.get_hop(ugg=ugg)

ci0_sing = [[ci0_sa[0][0]], [ci0_sa[1][0]]]
las_sing = LASSCF(mf, (4, 4), (4, 4), spin_sub=(1, 1)).set(mo_coeff=mo_loc,
                                                           ci=ci0_sing)
las_sing = las_sing.set(ah_level_shift=0, max_cycle_macro=1,
                        max_cycle_micro=1).run()
las_sing = las_sing.set(mo_coeff=mo_loc, ci=ci0_sing)
ugg_sing = las_sing.get_ugg()
hop_sing = las_sing.get_hop(ugg=ugg_sing)

ci0_quin = [[ci0_sa[0][1]], [ci0_sa[1][1]]]
las_quin = LASSCF(mf, (4, 4), ((3, 1), (1, 3)),
                  spin_sub=(3, 3)).set(mo_coeff=mo_loc, ci=ci0_quin)
las_quin = las_quin.set(ah_level_shift=0, max_cycle_macro=1,
Exemple #4
0
mol = struct(dr_nn, dr_nn, '6-31g', symmetry=False)
mol.verbose = lib.logger.DEBUG
mol.output = 'test_lassi.log'
mol.spin = 0
mol.build()
mf = scf.RHF(mol).run()
las = LASSCF(mf, (4, 4), (4, 4), spin_sub=(1, 1))
las.state_average_(weights=[
    1.0 / 5.0,
] * 5,
                   spins=[[0, 0], [0, 0], [2, -2], [-2, 2], [2, 2]],
                   smults=[[1, 1], [3, 3], [3, 3], [3, 3], [3, 3]])
las.frozen = list(range(las.mo_coeff.shape[-1]))
ugg = las.get_ugg()
las.mo_coeff = np.loadtxt('test_lassi_mo.dat')
las.ci = ugg.unpack(np.loadtxt('test_lassi_ci.dat'))[1]
#las.set (conv_tol_grad=1e-8).run ()
#np.savetxt ('test_lassi_mo.dat', las.mo_coeff)
#np.savetxt ('test_lassi_ci.dat', ugg.pack (las.mo_coeff, las.ci))
las.e_states = las.energy_nuc() + las.states_energy_elec()
e_roots, si = las.lassi()
rdm1s, rdm2s = roots_make_rdm12s(las, las.ci, si)


def tearDownModule():
    global mol, mf, las
    mol.stdout.close()
    del mol, mf, las


class KnownValues(unittest.TestCase):