Esempio n. 1
0
from pyscf import lib, gto, scf, dft, fci, mcscf, df
from pyscf.tools import molden
from c2h4n4_struct import structure as struct
from mrh.my_pyscf.mcscf.lasscf_o0 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)
nmo, ncore, nocc = h_op.nmo, h_op.ncore, h_op.nocc
np.random.seed(0)
x = np.random.rand(ugg.nvar_tot)
offs_ci1 = ugg.nvar_orb
offs_ci2 = offs_ci1 + np.squeeze(ugg.ncsf_sub)[0]
xorb, xci = ugg.unpack(x)
xci0 = [[
    np.zeros(16),
], [
    np.zeros(16),
]]
Esempio n. 2
0
    for field in ('charges', 'spins', 'smults', 'wfnsyms'):
        states[field] = states[field] + d[field]
weights = [1.0,] + [0.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
Esempio n. 3
0
dr_nn = 2.0
mol = struct (dr_nn, dr_nn, '6-31g', symmetry='Cs')
mol.verbose = lib.logger.DEBUG 
mol.output = 'test_lassi_symm.log'
mol.spin = 0 
mol.symmetry = 'Cs'
mol.build ()
mf = scf.RHF (mol).run ()
las = LASSCF (mf, (4,4), (4,4), spin_sub=(1,1))
las.state_average_(weights=[1.0/7.0,]*7,
    spins=[[0,0],[0,0],[2,-2],[-2,2],[0,0],[0,0],[2,2]],
    smults=[[1,1],[3,3],[3,3],[3,3],[1,1],[1,1],[3,3]],
    wfnsyms=[['A\'','A\''],]*4+[['A"','A\''],['A\'','A"'],['A\'','A\'']])
las.frozen = list (range (las.mo_coeff.shape[-1]))
ugg = las.get_ugg ()
las.mo_coeff = las.label_symmetry_(np.loadtxt ('test_lassi_symm_mo.dat'))
las.ci = ugg.unpack (np.loadtxt ('test_lassi_symm_ci.dat'))[1]
#las.set (conv_tol_grad=1e-8).run ()
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):
    def test_evals (self):
        self.assertAlmostEqual (lib.fp (e_roots), -213.84185089228347, 6)