コード例 #1
0
ファイル: test_mo_mapping.py プロジェクト: berquist/pyscf
    def test_mo_comps(self):
        mol = gto.M(atom = '''O 0 0 0; O 0 0 1''', basis='ccpvdz')
        numpy.random.seed(1)

        mo = numpy.random.random((mol.nao_nr(), 15))
        idx4d = [i for i,s in enumerate(mol.spheric_labels(1)) if '4d' in s]
        c = mo_mapping.mo_comps(idx4d, mol, mo, cart=False)
        self.assertAlmostEqual(abs(c).sum(), 0, 12)

        mo = numpy.random.random((mol.nao_cart(), 15)) * .2
        c = mo_mapping.mo_comps(lambda x: '3d' in x, mol, mo, cart=True)
        self.assertAlmostEqual(abs(c).sum(), 1.0643140119943388, 9)
コード例 #2
0
    def test_mo_comps(self):
        mol = gto.M(atom='''O 0 0 0; O 0 0 1''', basis='ccpvdz')
        numpy.random.seed(1)

        mo = numpy.random.random((mol.nao_nr(), 15))
        idx4d = [i for i, s in enumerate(mol.spheric_labels(1)) if '4d' in s]
        c = mo_mapping.mo_comps(idx4d, mol, mo, cart=False)
        self.assertAlmostEqual(abs(c).sum(), 0, 12)

        mo = numpy.random.random((mol.nao_cart(), 15)) * .2
        c = mo_mapping.mo_comps(lambda x: '3d' in x, mol, mo, cart=True)
        self.assertAlmostEqual(abs(c).sum(), 1.0643140119943388, 9)
コード例 #3
0
ファイル: test_mo_mapping.py プロジェクト: zzy2014/pyscf
    def test_mo_comps(self):
        mol = gto.M(atom='''O 0 0 0; O 0 0 1''', basis='ccpvdz')
        numpy.random.seed(1)

        mo = numpy.random.random((mol.nao_nr(), 15))
        idx4d = [i for i, s in enumerate(mol.ao_labels()) if '4d' in s]
        c = mo_mapping.mo_comps(idx4d, mol, mo, cart=False)
        self.assertAlmostEqual(abs(c).sum(), 0, 12)
コード例 #4
0
ファイル: test_mo_mapping.py プロジェクト: chrinide/pyscf
    def test_mo_comps(self):
        mol = gto.M(atom = '''O 0 0 0; O 0 0 1''', basis='ccpvdz')
        numpy.random.seed(1)

        mo = numpy.random.random((mol.nao_nr(), 15))
        idx4d = [i for i,s in enumerate(mol.ao_labels()) if '4d' in s]
        c = mo_mapping.mo_comps(idx4d, mol, mo, cart=False)
        self.assertAlmostEqual(abs(c).sum(), 0, 12)
コード例 #5
0
c  -1.217739890298750  0.703062453466927  0.000000000000000
h  -2.172991468538160  1.254577209307266  0.000000000000000
c  -1.217739890298750 -0.703062453466927  0.000000000000000
h  -2.172991468538160 -1.254577209307266  0.000000000000000
c   0.000000000000000 -1.406124906933854  0.000000000000000
h   0.000000000000000 -2.509154418614532  0.000000000000000
''',
                  basis=bas)
    cpu0 = get_cpu_timings()

    mf = mol.RHF().run()
    cpu0 = log.timer('C6H6 %s RHF' % bas, *cpu0)

    mymp2 = mf.MP2().run()
    cpu0 = log.timer('C6H6 %s MP2' % bas, *cpu0)

    mymc = mf.CASSCF(6, 6)
    idx_2pz = mo_comps('2pz', mol, mf.mo_coeff).argsort()[-6:]
    mo = mymc.sort_mo(idx_2pz, base=0)
    mymc.kernel(mo)
    cpu0 = log.timer('C6H6 %s CASSCF' % bas, *cpu0)

    mycc = mf.CCSD().run()
    cpu0 = log.timer('C6H6 %s CCSD' % bas, *cpu0)

    mf = mol.RKS().run(xc='b3lyp')
    cpu0 = log.timer('C6H6 %s B3LYP' % bas, *cpu0)

    mf = mf.density_fit().run()
    cpu0 = log.timer('C6H6 %s density-fit RHF' % bas, *cpu0)
コード例 #6
0
mf.chkfile = 'benzene-631g.chk'
mf.kernel()

pz_idx = numpy.array([17, 20, 21, 22, 23, 30, 36, 41, 42, 47, 48, 49]) - 1
loc_orb = lo.Boys(mol, mf.mo_coeff[:, pz_idx]).kernel()
molden.from_mo(mol, 'benzene-631g-boys.molden', loc_orb)

import numpy
from pyscf import lib
from pyscf import tools
from pyscf.tools import mo_mapping

mol, mo_energy, mo_coeff, mo_occ, irrep_labels, spins = \
        tools.molden.load('benzene-631g-boys.molden')

comp = mo_mapping.mo_comps(
    'C.*2p[yz]',  # regular expression
    mol,
    mo_coeff)

mol = lib.chkfile.load_mol('benzene-631g.chk')
mo = lib.chkfile.load('benzene-631g.chk', 'scf/mo_coeff')
comp = mo_mapping.mo_comps('C 2p', mol, mo)

#label = mol.ao_labels(True)
#tools.dump_mat.dump_rec(mol.stdout, mo_coeff, label, start=1)

print('rank   MO-id    components')
for i, j in enumerate(numpy.argsort(-comp)):
    print('%3d    %3d      %.10f' % (i, j, comp[j]))
コード例 #7
0
mf.chkfile = 'benzene-631g.chk'
mf.kernel()

pz_idx = numpy.array([17,20,21,22,23,30,36,41,42,47,48,49])-1
loc_orb = lo.Boys(mol, mf.mo_coeff[:,pz_idx]).kernel()
molden.from_mo(mol, 'benzene-631g-boys.molden', loc_orb)



import numpy
from pyscf import lib
from pyscf import tools
from pyscf.tools import mo_mapping

mol, mo_energy, mo_coeff, mo_occ, irrep_labels, spins = \
        tools.molden.load('benzene-631g-boys.molden')

comp = mo_mapping.mo_comps('C.*2p[yz]',  # regular expression
                           mol, mo_coeff)

mol = lib.chkfile.load_mol('benzene-631g.chk')
mo = lib.chkfile.load('benzene-631g.chk', 'scf/mo_coeff')
comp = mo_mapping.mo_comps('C 2p', mol, mo)

#label = mol.ao_labels()
#tools.dump_mat.dump_rec(mol.stdout, mo_coeff, label, start=1)

print('rank   MO-id    components')
for i,j in enumerate(numpy.argsort(-comp)):
    print('%3d    %3d      %.10f' % (i, j, comp[j]))
コード例 #8
0
ファイル: n2.py プロジェクト: zzy2014/pyscf
            log.note(line[:-1])
            break
with open('/proc/meminfo') as f:
    log.note(f.readline()[:-1])
log.note('OMP_NUM_THREADS=%s\n', os.environ.get('OMP_NUM_THREADS', None))

for bas in ('3-21g', '6-31g*', 'cc-pVTZ', 'ANO-Roos-TZ'):
    mol = pyscf.M(atom='N 0 0 0; N 0 0 1.1', basis=bas)
    cpu0 = time.clock(), time.time()

    mf = mol.RHF().run()
    cpu0 = log.timer('N2 %s RHF' % bas, *cpu0)

    mymp2 = mf.MP2().run()
    cpu0 = log.timer('N2 %s MP2' % bas, *cpu0)

    mymc = mf.CASSCF(4, 4)
    idx_2pz = mo_comps('2p[xy]', mol, mf.mo_coeff).argsort()[-4:]
    mo = mymc.sort_mo(idx_2pz, base=0)
    mymc.kernel(mo)
    cpu0 = log.timer('N2 %s CASSCF' % bas, *cpu0)

    mycc = mf.CCSD().run()
    cpu0 = log.timer('N2 %s CCSD' % bas, *cpu0)

    mf = mol.RKS().run(xc='b3lyp')
    cpu0 = log.timer('N2 %s B3LYP' % bas, *cpu0)

    mf = mf.density_fit().run()
    cpu0 = log.timer('N2 %s density-fit RHF' % bas, *cpu0)
コード例 #9
0
Read localized orbitals from molden, then find out C 2py and 2pz orbitals
'''


mol, mo_energy, mo_coeff, mo_occ, irrep_labels, spins = \
        tools.molden.load('benzene-631g-boys.molden')

#
# Note mol._cart_gto is not a built-in attribute defined in Mole class.  It is
# tagged in tools.molden.load function to indicate whether the orbitals read
# from molden file are based on cartesian gaussians (6d 10f).
#
if mol._cart_gto:
    # If molden file does not have 5d,9g label, it's in Cartesian Gaussian
    label = mol.cart_labels(True)
    comp = mo_mapping.mo_comps(lambda x: re.search('C.*2p[yz]', x),
                               mol, mo_coeff, cart=True)
else:
    label = mol.spheric_labels(True)
    comp = mo_mapping.mo_comps(lambda x: re.search('C.*2p[yz]', x),
                               mol, mo_coeff)
#
# For orbitals generated by pyscf (or read from pyscf chkfile), the orbitals
# are all represented on spheric gaussians (5d 7f).
#
mol = lib.chkfile.load_mol('benzene-631g.chk')
mo = lib.chkfile.load('benzene-631g.chk', 'scf/mo_coeff')
label = mol.spheric_labels(True)
idx = [i for i,s in enumerate(labels) if 'C 2p' in s]
comp = mo_mapping.mo_comps(idx, mol, mo_coeff)

#tools.dump_mat.dump_rec(mol.stdout, mo_coeff, label, start=1)