コード例 #1
0
    def test_optimize_contraction(self):
        bas = gto.parse(r'''
#BASIS SET: (6s,3p) -> [2s,1p]
        C    S
              2.9412494             -0.09996723
              0.6834831              0.39951283
              0.2222899              0.70011547
        C    S
              2.9412494             0.15591627
              0.6834831             0.60768372
              0.2222899             0.39195739
                                    ''',
                        optimize=True)
        self.assertEqual(len(bas), 1)

        bas = [[
            1, 0, [2.9412494, -0.09996723], [0.6834831, 0.39951283],
            [0.2222899, 0.70011547]
        ],
               [
                   1, 1, [2.9412494, -0.09996723], [0.6834831, 0.39951283],
                   [0.2222899, 0.70011547]
               ],
               [
                   1, 1, [2.9412494, 0.15591627], [0.6834831, 0.60768372],
                   [0.2222899, 0.39195739]
               ]]
        bas = gto.basis.parse_nwchem.optimize_contraction(bas)
        self.assertEqual(len(bas), 2)
コード例 #2
0
ファイル: test_basis_parser.py プロジェクト: chrinide/pyscf
    def test_optimize_contraction(self):
        bas = gto.parse(r'''
#BASIS SET: (6s,3p) -> [2s,1p]
        C    S
              2.9412494             -0.09996723
              0.6834831              0.39951283
              0.2222899              0.70011547
        C    S
              2.9412494             0.15591627
              0.6834831             0.60768372
              0.2222899             0.39195739
                                    ''', optimize=True)
        self.assertEqual(len(bas), 1)

        bas = [[1, 0,
                [2.9412494, -0.09996723],
                [0.6834831,  0.39951283],
                [0.2222899,  0.70011547]],
               [1, 1,
                [2.9412494, -0.09996723],
                [0.6834831,  0.39951283],
                [0.2222899,  0.70011547]],
               [1, 1,
                [2.9412494,  0.15591627],
                [0.6834831,  0.60768372],
                [0.2222899,  0.39195739]]]
        bas = gto.basis.parse_nwchem.optimize_contraction(bas)
        self.assertEqual(len(bas), 2)
コード例 #3
0
    def test_remove_zero(self):
        bas = gto.parse(r'''
        C    S
        7.2610457926   0.0000000000   0.0000000000
        2.1056583087   0.0000000000   0.0000000000
        0.6439906571   1.0000000000   0.0000000000
        0.0797152017   0.0000000000   1.0000000000
        0.0294029590   0.0000000000   0.0000000000
                                    ''')
        self.assertEqual(len(bas[0]), 3)

        bas = [[0, 0,
                [7.2610457926,  0.0000000000,  0.0000000000],
                [2.1056583087,  0.0000000000,  0.0000000000],
                [0.6439906571,  1.0000000000,  0.0000000000],
                [0.0797152017,  0.0000000000,  1.0000000000],
                [0.0294029590,  0.0000000000,  0.0000000000]]]
        bas = gto.basis.parse_nwchem.remove_zero(bas)
        self.assertEqual(len(bas[0]), 4)
コード例 #4
0
ファイル: test_basis_parser.py プロジェクト: chrinide/pyscf
    def test_remove_zero(self):
        bas = gto.parse(r'''
        C    S
        7.2610457926   0.0000000000   0.0000000000
        2.1056583087   0.0000000000   0.0000000000
        0.6439906571   1.0000000000   0.0000000000
        0.0797152017   0.0000000000   1.0000000000
        0.0294029590   0.0000000000   0.0000000000
                                    ''')
        self.assertEqual(len(bas[0]), 3)

        bas = [[0, 0,
                [7.2610457926,  0.0000000000,  0.0000000000],
                [2.1056583087,  0.0000000000,  0.0000000000],
                [0.6439906571,  1.0000000000,  0.0000000000],
                [0.0797152017,  0.0000000000,  1.0000000000],
                [0.0294029590,  0.0000000000,  0.0000000000]]]
        bas = gto.basis.parse_nwchem.remove_zero(bas)
        self.assertEqual(len(bas[0]), 4)
コード例 #5
0
def gen_qe_gto(qe_info, bset, x=[], fname='pyscf.orbitals.h5', prec=1e-12):
    """ Writes periodic AO basis set in real space to hdf5 file.
        This routine constructs a new gaussian basis set from a OptimizableBasisSet
        object and an array of optimizable parameters. 
        With the resulting basis set, a new gto.Cell object is constructed consistent 
        with the QE calculation and used to generate the periodic AO basis set.

    Parameters
    ----------
    qe_info: Python Dictionary.
        Dictionary with information from QE calculation, generated by qe_driver_init.
    bset: Object of type OptimizableBasisSet.
        Contains information about a (possibly dynamic) basis set.
    x: fp array. Default: [] (no variable parameters in bset)
        Array with variational parameters in the bset object.
    fname: string. Default: 'pyscf.orbitals.h5'
        Name of hdf5 file.
    prec: floating point number. Default: 1e-12
        Precision used to generate AO orbitals in real space. Controls sum over periodic images. 

    Returns
    -------
    nao: integer
        Number of atomic orbitals generates.
    """
    assert (len(x) == bset.number_of_params)
    basis = {}
    for I, atm in enumerate(qe_info['species']):
        basis.update({atm: molgto.parse(bset.basis_str(atm, x))})

    cell = make_cell(qe_info['latt'],
                     qe_info['species'],
                     qe_info['at_id'],
                     qe_info['at_pos'],
                     basis_=basis,
                     mesh=qe_info['mesh'],
                     prec=prec)
    nao = cell.nao_nr()
    write_esh5_orbitals(cell, qe_info['outdir'] + fname, kpts=qe_info['kpts'])
    return nao
コード例 #6
0
ファイル: 04-input_basis.py プロジェクト: ushnishray/pyscf
'''
Use gto.basis.parse and gto.basis.load functions to input user-specified basis functions.
'''

dirnow = os.path.realpath(os.path.join(__file__, '..'))
basis_file_from_user = os.path.join(dirnow, 'h_sto3g.dat')

mol = gto.M(
    atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
    basis = {'O': gto.parse('''
# Parse NWChem format basis string (see https://bse.pnl.gov/bse/portal).
# Comment lines are ignored
#BASIS SET: (6s,3p) -> [2s,1p]
O    S
    130.7093200              0.15432897       
     23.8088610              0.53532814       
      6.4436083              0.44463454       
O    SP
      5.0331513             -0.09996723             0.15591627       
      1.1695961              0.39951283             0.60768372       
      0.3803890              0.70011547             0.39195739       
                                '''),
             'H1': gto.load(basis_file_from_user, 'H'),
             'H2': gto.load('sto-3g', 'He')  # or use basis of another atom
            }
)

mol = gto.M(
    atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
    basis = {'O': 'unc-ccpvdz', # prefix "unc-" will uncontract the ccpvdz basis.
                                # It is equivalent to assigning
コード例 #7
0
    def test_format_basis(self):
        mol = gto.M(atom='''O 0 0 0; 1 0 1 0; H 0 0 1''', basis={8: 'ccpvdz'})
        self.assertEqual(mol.nao_nr(), 14)

        mol = gto.M(atom='''O 0 0 0; H:1 0 1 0; H@2 0 0 1''',
                    basis={
                        'O': 'ccpvdz',
                        'H:1': 'sto3g',
                        'H': 'unc-iglo3'
                    })
        self.assertEqual(mol.nao_nr(), 32)

        mol = gto.M(atom='''O 0 0 0; H1 0 1 0; H2 0 0 1''',
                    basis={
                        'default': ('6-31g', [[0, [.05, 1.]], []]),
                        'H2': 'sto3g'
                    })
        self.assertEqual(mol.nao_nr(), 14)

        mol = gto.M(
            atom='''O 0 0 0; H1 0 1 0; H2 0 0 1''',
            basis={
                'H1':
                gto.parse('''
# Parse NWChem format basis string (see https://bse.pnl.gov/bse/portal).
# Comment lines are ignored
#BASIS SET: (6s,3p) -> [2s,1p]
        H    S
              2.9412494             -0.09996723
              0.6834831              0.39951283
              0.2222899              0.70011547
        H    S
              2.9412494             0.15591627
              0.6834831             0.60768372
              0.2222899             0.39195739
                                    ''',
                          optimize=True),
                'O':
                'unc-ccpvdz',
                'H2':
                gto.load('sto-3g', 'He')  # or use basis of another atom
            })
        self.assertEqual(mol.nao_nr(), 29)

        mol = gto.M(
            atom='''O 0 0 0; H1 0 1 0; H2 0 0 1''',
            basis={
                'H': [
                    'sto3g', '''unc
        C    S
             71.6168370              0.15432897
             13.0450960              0.53532814
              3.5305122              0.44463454
        C    SP
              2.9412494             -0.09996723             0.15591627
              0.6834831              0.39951283             0.60768372
              0.2222899              0.70011547             0.39195739
        '''
                ],
                'O':
                mol.expand_etbs([
                    (0, 4, 1.5, 2.2),  # s-function
                    (1, 2, 0.5, 2.2)
                ])  # p-function
            })
        self.assertEqual(mol.nao_nr(), 42)

        mol = gto.M(atom='''O 0 0 0; H1 0 1 0; H2 0 0 1''',
                    basis=('sto3g', 'ccpvdz', '3-21g',
                           gto.etbs([(0, 4, 1.5, 2.2), (1, 2, 0.5, 2.2)]),
                           [[0, numpy.array([1e3, 1.])]]))
        self.assertEqual(mol.nao_nr(), 77)

        mol.atom = 'Hg'
        mol.basis = 'ccpvdz'
        self.assertRaises(RuntimeError, mol.build)
コード例 #8
0
mol.basis = {
    'H':
    gto.parse('''
H S
23.843185 0.00411490
10.212443 0.01046440
4.374164 0.02801110
1.873529 0.07588620
0.802465 0.18210620
0.343709 0.34852140
0.147217 0.37823130
0.063055 0.11642410
H S
0.029292 1.00000000
H S
0.091791 1.00000000
H S
0.287637 1.00000000
H P
0.106105 1.00000000
H P
0.393954 1.00000000
H P
1.462694 1.00000000
H D
0.295883 1.00000000
H D
1.065841 1.00000000
'''),
    'O':
    gto.parse('''
コード例 #9
0
def run():
    ###     PYSCF INPUT
    r0 = 1.50
    molecule = '''
    Cr
    Cr   1   {}
    '''.format(r0)
    charge = 0
    spin = 0
    basis_set = 'def2-svp'

    ###     TPSCI BASIS INPUT
    orb_basis = 'scf'
    cas = True
    cas_nstart = 12
    cas_nstop = 42
    loc_start = 1
    loc_stop = 6
    cas_nel = 24

    def ordering_diatomics_cr(mol, C):
        # {{{
        ##DZ basis diatomics reordering with frozen 1s

        orb_type = ['s', 'pz', 'dz', 'px', 'dxz', 'py', 'dyz', 'dx2-y2', 'dxy']
        ref = np.zeros(C.shape[1])

        ## Find dimension of each space
        dim_orb = []
        for orb in orb_type:
            print("Orb type", orb)
            idx = 0
            for label in mol.ao_labels():
                if orb in label:
                    #print(label)
                    idx += 1

            ##frozen 1s orbitals
            if orb == 's':
                idx -= 6
            elif orb == 'px':
                idx -= 2
            elif orb == 'py':
                idx -= 2
            elif orb == 'pz':
                idx -= 2
            dim_orb.append(idx)
            print(idx)

        new_idx = []
        ## Find orbitals corresponding to each orb space
        for i, orb in enumerate(orb_type):
            print("Orbital type:", orb)
            from pyscf import mo_mapping
            s_pop = mo_mapping.mo_comps(orb, mol, C)
            print(s_pop)
            ref += s_pop
            cas_list = s_pop.argsort()[-dim_orb[i]:]
            print('cas_list', np.array(cas_list))
            new_idx.extend(cas_list)
            #print(orb,' population for active space orbitals', s_pop[cas_list])

        ao_labels = mol.ao_labels()
        #idx = mol.search_ao_label(['N.*s'])
        #for i in idx:
        #    print(i, ao_labels[i])
        print(ref)
        print(new_idx)
        for label in mol.ao_labels():
            print(label)

        return new_idx

    # }}}

    # basis is SVP read comments by alex thom paper DOI:10.1021/acs.jctc.9b01023
    from pyscf import gto
    basis_set = {
        'Cr':
        gto.parse('''
    BASIS "ao basis" PRINT
    #BASIS SET: (14s,8p,5d) -> [5s,2p,2d]
    Cr    S
      51528.086349               0.14405823106E-02
       7737.2103487              0.11036202287E-01
       1760.3748470              0.54676651806E-01
        496.87706544             0.18965038103
        161.46520598             0.38295412850
         55.466352268            0.29090050668
    Cr    S
        107.54732999            -0.10932281100
         12.408671897            0.64472599471
          5.0423628826           0.46262712560
    Cr    S
          8.5461640165          -0.22711013286
          1.3900441221           0.73301527591
          0.56066602876          0.44225565433
    Cr    S
          0.71483705972E-01      1.0000000000
    Cr    S
          0.28250687604E-01      1.0000000000
    Cr    P
        640.48536096             0.96126715203E-02
        150.69711194             0.70889834655E-01
         47.503755296            0.27065258990
         16.934120165            0.52437343414
          6.2409680590           0.34107994714
    Cr    P
          3.0885463206           0.33973986903
          1.1791047769           0.57272062927
          0.43369774432          0.24582728206
    Cr    D
         27.559479426            0.30612488044E-01
          7.4687020327           0.15593270944
          2.4345903574           0.36984421276
          0.78244754808          0.47071118077
    Cr    D
          0.21995774311          0.33941649889
    END''')
    }

    ###     TPSCI CLUSTER INPUT
    init_fspace = ((1, 1), (3, 3), (3, 3), (3, 3), (1, 1), (1, 1))
    blocks = [
        range(0, 4),
        range(4, 10),
        range(10, 16),
        range(16, 22),
        range(22, 26),
        range(26, 30)
    ]

    # Integrals from pyscf
    #Integrals from pyscf
    pmol = PyscfHelper()
    pmol.init(molecule,
              charge,
              spin,
              basis_set,
              orb_basis,
              cas_nstart=cas_nstart,
              cas_nstop=cas_nstop,
              cas_nel=cas_nel,
              cas=True,
              loc_nstart=loc_start,
              loc_nstop=loc_stop)

    h = pmol.h
    g = pmol.g
    ecore = pmol.ecore
    print("Ecore:%16.8f" % ecore)
    C = pmol.C
    K = pmol.K
    mol = pmol.mol
    mo_energy = pmol.mf.mo_energy
    dm_aa = pmol.dm_aa
    dm_bb = pmol.dm_bb

    do_tci = 1

    #cluster using hcore

    idx = ordering_diatomics_cr(mol, C)
    h, g = reorder_integrals(idx, h, g)
    C = C[:, idx]
    mo_energy = mo_energy[idx]
    dm_aa = dm_aa[:, idx]
    dm_aa = dm_aa[idx, :]
    dm_bb = dm_bb[:, idx]
    dm_bb = dm_bb[idx, :]

    print(dm_aa)

    from pyscf import molden
    molden.from_mo(pmol.mol, 'h8.molden', C)
    print(h)
    mol = pmol.mol
    if mol.symmetry == True:
        from pyscf import symm
        mo = symm.symmetrize_orb(mol, C)
        osym = symm.label_orb_symm(mol, mol.irrep_name, mol.symm_orb, mo)
        #symm.addons.symmetrize_space(mol, mo, s=None, check=True, tol=1e-07)
        for i in range(len(osym)):
            print("%4d %8s %16.8f" % (i + 1, osym[i], mo_energy[i]))

    clusters, clustered_ham, ci_vector = system_setup(h,
                                                      g,
                                                      ecore,
                                                      blocks,
                                                      init_fspace,
                                                      cmf_maxiter=20,
                                                      cmf_dm_guess=(dm_aa,
                                                                    dm_bb),
                                                      cmf_diis=True,
                                                      max_roots=100,
                                                      delta_elec=3)

    ndata = 0
    for ci in clusters:
        for o in ci.ops:
            for f in ci.ops[o]:
                ndata += ci.ops[o][f].size * ci.ops[o][f].itemsize
    print(" Amount of data stored in TDMs: %12.2f Gb" % (ndata * 1e-9))

    init_fspace = ((1, 1), (3, 3), (3, 3), (3, 3), (1, 1), (1, 1))

    ci_vector, pt_vector, etci, etci2, t_conv = bc_cipsi_tucker(
        ci_vector.copy(),
        clustered_ham,
        pt_type='mp',
        thresh_cipsi=1e-3,
        thresh_ci_clip=1e-6,
        max_tucker_iter=4,
        nbody_limit=4,
        thresh_search=1e-3,
        thresh_asci=1e-2,
        tucker_state_clip=100,  #don't use any pt for tucker 
        tucker_conv_target=0,  #converge variational energy
        nproc=None)

    ci_vector, pt_vector, etci, etci2, t_conv = bc_cipsi_tucker(
        ci_vector.copy(),
        clustered_ham,
        pt_type='mp',
        thresh_cipsi=1e-5,
        thresh_ci_clip=1e-7,
        max_tucker_iter=2,
        nbody_limit=4,
        thresh_search=1e-4,
        thresh_asci=1e-2,
        tucker_state_clip=100,  #don't use any pt for tucker 
        tucker_conv_target=0,  #converge variational energy
        nproc=None)

    ci_vector, pt_vector, etci, etci2, t_conv = bc_cipsi_tucker(
        ci_vector.copy(),
        clustered_ham,
        pt_type='mp',
        thresh_cipsi=1e-6,
        thresh_ci_clip=1e-8,
        max_tucker_iter=2,
        nbody_limit=4,
        thresh_search=1e-4,
        thresh_asci=1e-2,
        tucker_state_clip=100,  #don't use any pt for tucker 
        tucker_conv_target=0,  #converge variational energy
        nproc=None)

    ci_vector, pt_vector, etci, etci2, t_conv = bc_cipsi_tucker(
        ci_vector.copy(),
        clustered_ham,
        pt_type='mp',
        thresh_cipsi=1e-7,
        thresh_ci_clip=1e-9,
        max_tucker_iter=4,
        nbody_limit=4,
        thresh_search=1e-4,
        thresh_asci=1e-2,
        tucker_state_clip=100,  #don't use any pt for tucker 
        tucker_conv_target=0,  #converge variational energy
        nproc=None)

    tci_dim = len(ci_vector)
    ci_vector.print()
    ecore = clustered_ham.core_energy

    etci += ecore
    etci2 += ecore

    print(" TCI:        %12.9f Dim:%6d" % (etci, tci_dim))
コード例 #10
0
    'Al':
    Mgto.parse('''
Al S
8.257944 0.003287
4.514245 -0.017168
2.467734 0.069766
1.348998 -0.183475
0.737436 -0.147133
0.403123 0.046882
0.220369 0.308423
0.120466 0.451564
0.065853 0.302904
0.035999 0.079545
Al S
0.236926 1.000000
Al P
1.570603 -0.002645
0.977752 -0.037850
0.608683 0.006636
0.378925 0.089291
0.235893 0.134421
0.146851 0.256105
0.091420 0.238970
0.056912 0.260677
0.035429 0.112350
0.022056 0.052665
Al P
0.202698 1.000000
Al D
0.192882 1.000000
''')
}
コード例 #11
0
ファイル: test_mole.py プロジェクト: chrinide/pyscf
    def test_format_basis(self):
        mol = gto.M(atom = '''O 0 0 0; 1 0 1 0; H 0 0 1''',
                    basis = {8: 'ccpvdz'})
        self.assertEqual(mol.nao_nr(), 14)

        mol = gto.M(atom = '''O 0 0 0; H:1 0 1 0; H@2 0 0 1''',
                    basis = {'O': 'ccpvdz', 'H:1': 'sto3g', 'H': 'unc-iglo3'})
        self.assertEqual(mol.nao_nr(), 32)

        mol = gto.M(
            atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
            basis = {'default': ('6-31g', [[0, [.05, 1.]], []]), 'H2': 'sto3g'}
        )
        self.assertEqual(mol.nao_nr(), 14)

        mol = gto.M(
            atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
            basis = {'H1': gto.parse('''
# Parse NWChem format basis string (see https://bse.pnl.gov/bse/portal).
# Comment lines are ignored
#BASIS SET: (6s,3p) -> [2s,1p]
        H    S
              2.9412494             -0.09996723
              0.6834831              0.39951283
              0.2222899              0.70011547
        H    S
              2.9412494             0.15591627
              0.6834831             0.60768372
              0.2222899             0.39195739
                                    ''', optimize=True),
                     'O': 'unc-ccpvdz',
                     'H2': gto.load('sto-3g', 'He')  # or use basis of another atom
                    }
        )
        self.assertEqual(mol.nao_nr(), 29)

        mol = gto.M(
            atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
            basis = {'H': ['sto3g', '''unc
        C    S
             71.6168370              0.15432897
             13.0450960              0.53532814
              3.5305122              0.44463454
        C    SP
              2.9412494             -0.09996723             0.15591627
              0.6834831              0.39951283             0.60768372
              0.2222899              0.70011547             0.39195739
        '''],
                     'O': mol.expand_etbs([(0, 4, 1.5, 2.2),  # s-function
                                           (1, 2, 0.5, 2.2)]) # p-function
                    }
        )
        self.assertEqual(mol.nao_nr(), 42)

        mol = gto.M(
            atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
            basis = ('sto3g', 'ccpvdz', '3-21g',
                     gto.etbs([(0, 4, 1.5, 2.2), (1, 2, 0.5, 2.2)]),
                    [[0, numpy.array([1e3, 1.])]])
        )
        self.assertEqual(mol.nao_nr(), 77)

        mol.atom = 'Hg'
        mol.basis = 'ccpvdz'
        self.assertRaises(RuntimeError, mol.build)
コード例 #12
0
def generate_hamiltonian():
    ###     PYSCF INPUT
    r0 = 1.50
    molecule = '''
    Cr
    Cr   1   {}
    '''.format(r0)
    charge = 0
    spin  = 0
    basis_set = 'def2-svp'

    ###     TPSCI BASIS INPUT
    orb_basis = 'scf'
    cas = True
    cas_nstart = 12
    cas_nstop =  42
    loc_start = 1
    loc_stop = 6
    cas_nel = 24

    def ordering_diatomics_cr(mol,C):
    # {{{
        ##DZ basis diatomics reordering with frozen 1s

        orb_type = ['s','pz','dz','px','dxz','py','dyz','dx2-y2','dxy']
        ref = np.zeros(C.shape[1])

        ## Find dimension of each space
        dim_orb = []
        for orb in orb_type:
            print("Orb type",orb)
            idx = 0
            for label in mol.ao_labels():
                if orb in label:
                    #print(label)
                    idx += 1

            ##frozen 1s orbitals
            if orb == 's':
                idx -= 6
            elif orb == 'px':
                idx -=2
            elif orb == 'py':
                idx -=2
            elif orb == 'pz':
                idx -=2
            dim_orb.append(idx)
            print(idx)


        new_idx = []
        ## Find orbitals corresponding to each orb space
        for i,orb in enumerate(orb_type):
            print("Orbital type:",orb)
            from pyscf import mo_mapping
            s_pop = mo_mapping.mo_comps(orb, mol, C)
            print(s_pop)
            ref += s_pop
            cas_list = s_pop.argsort()[-dim_orb[i]:]
            print('cas_list', np.array(cas_list))
            new_idx.extend(cas_list)
            #print(orb,' population for active space orbitals', s_pop[cas_list])

        ao_labels = mol.ao_labels()
        #idx = mol.search_ao_label(['N.*s'])
        #for i in idx:
        #    print(i, ao_labels[i])
        print(ref)
        print(new_idx)
        for label in mol.ao_labels():
            print(label)

        return new_idx
    # }}}

    # basis is SVP read comments by alex thom paper DOI:10.1021/acs.jctc.9b01023
    from pyscf import gto
    basis_set={'Cr': gto.parse('''
    BASIS "ao basis" PRINT
    #BASIS SET: (14s,8p,5d) -> [5s,2p,2d]
    Cr    S
      51528.086349               0.14405823106E-02
       7737.2103487              0.11036202287E-01
       1760.3748470              0.54676651806E-01
        496.87706544             0.18965038103
        161.46520598             0.38295412850
         55.466352268            0.29090050668
    Cr    S
        107.54732999            -0.10932281100
         12.408671897            0.64472599471
          5.0423628826           0.46262712560
    Cr    S
          8.5461640165          -0.22711013286
          1.3900441221           0.73301527591
          0.56066602876          0.44225565433
    Cr    S
          0.71483705972E-01      1.0000000000
    Cr    S
          0.28250687604E-01      1.0000000000
    Cr    P
        640.48536096             0.96126715203E-02
        150.69711194             0.70889834655E-01
         47.503755296            0.27065258990
         16.934120165            0.52437343414
          6.2409680590           0.34107994714
    Cr    P
          3.0885463206           0.33973986903
          1.1791047769           0.57272062927
          0.43369774432          0.24582728206
    Cr    D
         27.559479426            0.30612488044E-01
          7.4687020327           0.15593270944
          2.4345903574           0.36984421276
          0.78244754808          0.47071118077
    Cr    D
          0.21995774311          0.33941649889
    END''')}


    ###     TPSCI CLUSTER INPUT
    init_fspace = ((1, 1),(3, 3),(3, 3),(3, 3), (1, 1), (1, 1))
    blocks = [range(0,4),range(4,10),range(10,16),range(16,22),range(22,26),range(26,30)]

    # Integrals from pyscf
    #Integrals from pyscf
    pmol = PyscfHelper()
    pmol.init(molecule,charge,spin,basis_set,orb_basis,
                    cas_nstart=cas_nstart,cas_nstop=cas_nstop,cas_nel=cas_nel,cas=True,
                    loc_nstart=loc_start,loc_nstop = loc_stop)

    h = pmol.h
    g = pmol.g
    ecore = pmol.ecore
    print("Ecore:%16.8f"%ecore)
    C = pmol.C
    K = pmol.K
    mol = pmol.mol
    mo_energy = pmol.mf.mo_energy
    dm_aa = pmol.dm_aa
    dm_bb = pmol.dm_bb

    do_fci = 0
    do_hci = 0
    do_tci = 1

    if do_fci:
        efci, fci_dim = run_fci_pyscf(h,g,nelec,ecore=ecore)
    if do_hci:
        ehci, hci_dim = run_hci_pyscf(h,g,nelec,ecore=ecore,select_cutoff=5e-4,ci_cutoff=5e-4)

    #cluster using hcore

    idx = ordering_diatomics_cr(mol,C)
    h,g = reorder_integrals(idx,h,g)
    C = C[:,idx]
    mo_energy = mo_energy[idx]
    dm_aa = dm_aa[:,idx]
    dm_aa = dm_aa[idx,:]
    dm_bb = dm_bb[:,idx]
    dm_bb = dm_bb[idx,:]

    print(dm_aa)


    from pyscf import molden
    molden.from_mo(pmol.mol, 'h8.molden', C)
    print(h)
    mol = pmol.mol
    if mol.symmetry == True:
        from pyscf import symm
        mo = symm.symmetrize_orb(mol, C)
        osym = symm.label_orb_symm(mol, mol.irrep_name, mol.symm_orb, mo)
        #symm.addons.symmetrize_space(mol, mo, s=None, check=True, tol=1e-07)
        for i in range(len(osym)):
            print("%4d %8s %16.8f"%(i+1,osym[i],mo_energy[i]))




    clusters = []

    for ci,c in enumerate(blocks):
        clusters.append(Cluster(ci,c))

    print(" Clusters:")
    [print(ci) for ci in clusters]

    clustered_ham = ClusteredOperator(clusters, core_energy=ecore)
    print(" Add 1-body terms")
    clustered_ham.add_local_terms()
    clustered_ham.add_1b_terms(h)
    print(" Add 2-body terms")
    clustered_ham.add_2b_terms(g)

    # intial state
    ci_vector = ClusteredState(clusters)
    ci_vector.init(init_fspace)
    ci_vector.print()

    # do cmf
    do_cmf = 1
    if do_cmf:
        # Get CMF reference
        e_cmf, cmf_conv, rdm_a, rdm_b = cmf(clustered_ham, ci_vector, h, g, max_iter=10, dm_guess=(dm_aa, dm_bb), diis=True)

    print(" Final CMF Total Energy %12.8f" %(e_cmf + ecore))

    # build cluster basis and operator matrices using CMF optimized density matrices
    for ci_idx, ci in enumerate(clusters):
        print(ci)
        fspaces_i = init_fspace[ci_idx]
        delta_e = 2
        fspaces_i = ci.possible_fockspaces( delta_elec=(fspaces_i[0], fspaces_i[1], delta_e) )


        print()
        print(" Form basis by diagonalizing local Hamiltonian for cluster: ",ci_idx)

        ci.form_fockspace_eigbasis(h, g, fspaces_i, max_roots=100, rdm1_a=rdm_a, rdm1_b=rdm_b)


        print(" Build mats for cluster ",ci.idx)
        ci.build_op_matrices()
        ci.build_local_terms(h,g)


    hamiltonian_file = open('hamiltonian_file', 'wb')
    pickle.dump(clustered_ham, hamiltonian_file)

    print(" Done.")
コード例 #13
0
ファイル: cr2-sv.py プロジェクト: vibinabraham/FermiCluster
    gto.parse('''
BASIS "ao basis" PRINT
#BASIS SET: (14s,8p,5d) -> [5s,2p,2d]
Cr    S
  51528.086349               0.14405823106E-02
   7737.2103487              0.11036202287E-01
   1760.3748470              0.54676651806E-01
    496.87706544             0.18965038103
    161.46520598             0.38295412850
     55.466352268            0.29090050668
Cr    S
    107.54732999            -0.10932281100
     12.408671897            0.64472599471
      5.0423628826           0.46262712560
Cr    S
      8.5461640165          -0.22711013286
      1.3900441221           0.73301527591
      0.56066602876          0.44225565433
Cr    S
      0.71483705972E-01      1.0000000000
Cr    S
      0.28250687604E-01      1.0000000000
Cr    P
    640.48536096             0.96126715203E-02
    150.69711194             0.70889834655E-01
     47.503755296            0.27065258990
     16.934120165            0.52437343414
      6.2409680590           0.34107994714
Cr    P
      3.0885463206           0.33973986903
      1.1791047769           0.57272062927
      0.43369774432          0.24582728206
Cr    D
     27.559479426            0.30612488044E-01
      7.4687020327           0.15593270944
      2.4345903574           0.36984421276
      0.78244754808          0.47071118077
Cr    D
      0.21995774311          0.33941649889
END''')