예제 #1
0
def main():

    systems = {
            "H" : { 
                'name'         : 'Hydrogen',
                'symbol'       : 'H',
                'spin'         : 1,
                'positions'    : [[ 0., 0., 0.]]},
            "Li" : {
                'name'         : 'Lithium',
                'symbol'       : 'Li',
                'spin'         : 1,
                'positions'    : [[ 0., 0., 0.]]},
            "O" : {
                'name'         : 'Oxygen',
                'symbol'       : 'O',
                'spin'         : 2,
                'positions'    : [[ 0., 0., 0.]]},
            "Ar" : {
                'name'         : 'Argon',
                'symbol'       : 'Ar',
                'spin'         : 0,
                'positions'    : [[ 0., 0., 0.]]}
    }

    kskernel = kernel.KSKernel()

    for key in systems:

        system = systems[key]

        print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
        print(system['name'] + ' 0.0 0.0 0.0')
        coords = system['symbol'] + ' 0.0 0.0 0.0'

        mol = gto.Mole()
        mol.atom = coords
        mol.basis = 'cc-pvtz'
        mol.spin = system['spin']
        mol.charge = 0
        mol.build()

        kskernel.CalculateKSKernel(mol)

        print('PBE:')
        pbe = DFA(mol, kskernel, 'PBE,PBE')
        xc = pbe.CalculateTotalXC()
        pbepade3p = AC(pbe, 'pade3p')
        ac_xc = pbepade3p.CalculateTotalXC()
        print('AC XC = {:.12e} AVG XC = {:.12e}, Error = {:.12e}'.format(ac_xc, xc, (xc - ac_xc)))

        print('Exact KS:')
        exks = ExKS(mol, kskernel, 'exks,')
        xc = exks.CalculateTotalXC()
        exks_ac = AC(exks, 'pade3p')
        ac_xc = exks_ac.CalculateTotalXC()
        print('AC XC = {:.12e} AVG XC = {:.12e}, Error = {:.12e}'.format(ac_xc, xc, (xc - ac_xc)))


    return
def CalculateTotalEnergies(systems, functionals, pval):

    systems_names = []
    for key in systems:
        system = systems[key]
        systems_names.append(key)

    systems_energies = []

    # ar_es:     array of total energies
    ar_es = np.ndarray((len(systems_names), len(functionals)), dtype=object)
    ar_es[:, 0] = systems_names

    kskernel = kernel.KSKernel()
    for key in systems:

        system = systems[key]

        print(
            '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
        )
        print(system)

        mol = gto.Mole()
        print(MakeMoleculePositions(system['symbol'], system['positions']))
        mol.atom = MakeMoleculePositions(system['symbol'], system['positions'])
        mol.basis = '../basis/6-311+g2dp.nw'
        mol.cart = True
        mol.spin = system['spin']
        mol.charge = 0
        mol.build()

        kskernel.CalculateKSKernel(mol)
        print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(
            kskernel.mf.e_tot, 0.0, 0.0,
            kskernel.mf.get_veff().exc))

        # exks = ExKS(mol, kskernel, 'exks,')
        # Ex = exks.CalculateTotalX()
        # Ec = exks.CalculateTotalC()
        # Exc = exks.CalculateTotalXC()
        # E = exks.CalculateTotalEnergy()
        # print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(E, Ex, Ec, Exc))

        # lsd = DFA(mol, kskernel, 'LDA,PW_MOD')
        # x = lsd.CalculateTotalX()
        # c = lsd.CalculateTotalC()
        # xc = lsd.CalculateTotalXC()
        # e = lsd.CalculateTotalEnergy()
        # print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(e, x, c, xc))

        pbe = DFA(mol, kskernel, 'PBE,PBE')
        Ex = pbe.CalculateTotalX()
        Ec = pbe.CalculateTotalC()
        Exc = pbe.CalculateTotalXC()
        E = pbe.CalculateTotalEnergy()
        print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(
            E, Ex, Ec, Exc))

        # cfx = CF('cfx', mol, kernel)
        # cfx_xc = cfx.CalculateEpsilonXC()
        system['energy'] = E
        systems_energies.append(E)

    ar_es[:, 1] = systems_energies

    return ar_es
def main():

    functionals = ['LDA,PW_MOD', 'PBE,PBE']

    systems = {
        "H": {
            'name': 'Hydrogen',
            'symbol': 'H',
            'spin': 1,
            'positions': [[0., 0., 0.]]
        },
        "Li": {
            'name': 'Lithium',
            'symbol': 'Li',
            'spin': 1,
            'positions': [[0., 0., 0.]]
        },
        "O": {
            'name': 'Oxygen',
            'symbol': 'O',
            'spin': 2,
            'positions': [[0., 0., 0.]]
        },
        "Ar": {
            'name': 'Argon',
            'symbol': 'Ar',
            'spin': 0,
            'positions': [[0., 0., 0.]]
        }
    }

    kskernel = kernel.KSKernel()

    for key in systems:

        system = systems[key]

        print(
            '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
        )
        print(system['name'] + ' 0.0 0.0 0.0')
        coords = system['symbol'] + ' 0.0 0.0 0.0'

        mol = gto.Mole()
        mol.atom = coords
        mol.basis = '../basis/6-311+g2dp.nw'
        mol.cart = True
        mol.spin = system['spin']
        mol.charge = 0
        mol.build()

        kskernel.CalculateKSKernel(mol)
        print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(
            kskernel.mf.e_tot, 0.0, 0.0,
            kskernel.mf.get_veff().exc))

        exks = ExKS(mol, kskernel, 'exks,')
        x = exks.CalculateTotalX()
        c = exks.CalculateTotalC()
        xc = exks.CalculateTotalXC()
        e = exks.CalculateTotalEnergy()
        print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(
            e, x, c, xc))

        lsd = DFA(mol, kskernel, 'LDA,PW_MOD')
        x = lsd.CalculateTotalX()
        c = lsd.CalculateTotalC()
        xc = lsd.CalculateTotalXC()
        e = lsd.CalculateTotalEnergy()
        print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(
            e, x, c, xc))

        pbe = DFA(mol, kskernel, 'PBE,PBE')
        x = pbe.CalculateTotalX()
        c = pbe.CalculateTotalC()
        xc = pbe.CalculateTotalXC()
        e = pbe.CalculateTotalEnergy()
        print('E = {:.12e}\tX = {:.12e}\tC = {:.12e}\tXC = {:.12e}'.format(
            e, x, c, xc))