示例#1
0
文件: test_ase.py 项目: ncrubin/pyscf
def test_pyscf():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom=Diamond(symbol='C', latticeconstant=3.5668)
    print ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h=ase_atom.cell
    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    #cell.gs=np.array([10,10,10])
    cell.gs=np.array([20,20,20])
    cell.verbose=7

    cell.build(None,None)
    print cell._atom

    print "Cell nimgs =", cell.nimgs
    print "Cell _basis =", cell._basis
    print "Cell _pseudo =", cell._pseudo
    print "Cell nelectron =", cell.nelectron

    mf=pbcdft.RKS(cell)
    mf.xc='lda,vwn'
    mf.analytic_int=False
    print mf.scf() # [10,10,10]: -44.8811199336
示例#2
0
def test_cubic_diamond_C():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom = Diamond(symbol='C', latticeconstant=3.5668)
    print "Cell volume =", ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell
    cell.basis = "gth-szv"
    cell.pseudo = "gth-pade"

    cell.gs = np.array([10, 10, 10])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int = False
    mf.xc = 'lda,vwn'
    print mf.scf()

    # Gamma point gs: 10x10x10: -11.220279983393
    #             gs: 14x14x14: -11.220122248175
    # K pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2, 2, 2))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    kmf.verbose = 7
    print kmf.scf()
示例#3
0
def test_cubic_diamond_C():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom = Diamond(symbol='C', latticeconstant=3.5668)
    print "Cell volume =", ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell
    cell.basis = "gth-szv"
    cell.pseudo = "gth-pade"

    cell.gs = np.array([10,10,10])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int = False
    mf.xc = 'lda,vwn'
    print mf.scf()

    # Gamma point gs: 10x10x10: -11.220279983393
    #             gs: 14x14x14: -11.220122248175
    # K pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2,2,2))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    kmf.verbose = 7
    print kmf.scf()
示例#4
0
def test_cubic_diamond_He():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom=Diamond(symbol='He', latticeconstant=3.5)
    print ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h=ase_atom.cell.T
    cell.basis = {"He" : [[0, (1.0, 1.0)], [0, (0.8, 1.0)]] }

    cell.gs = np.array([15,15,15])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int=False
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic: -18.2278622592408

    mf = pbcdft.RKS(cell)
    mf.analytic_int=True
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic (analytic): -18.2278622592283
    #                         = -4.556965564807075 / cell              

    # K pt calc
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((2,2,2))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
示例#5
0
def test_cubic_diamond_He():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom=Diamond(symbol='He', latticeconstant=3.5)
    print ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h=ase_atom.cell
    cell.basis = {"He" : [[0, (1.0, 1.0)], [0, (0.8, 1.0)]] }

    cell.gs = np.array([15,15,15])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int=False
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic: -18.2278622592408

    mf = pbcdft.RKS(cell)
    mf.analytic_int=True
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic (analytic): -18.2278622592283
    #                         = -4.556965564807075 / cell              

    # K pt calc
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((2,2,2))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
示例#6
0
文件: test_ase.py 项目: ncrubin/pyscf
def test_calculator():
    """
    Take ASE structure, PySCF object,
    and run through ASE calculator interface. 
    
    This allows other ASE methods to be used with PySCF;
    here we try to compute an equation of state.
    """
    ase_atom=Diamond(symbol='C', latticeconstant=3.5668)

    # Set up a cell; everything except atom; the ASE calculator will
    # set the atom variable
    cell = pbcgto.Cell()
    cell.h=ase_atom.cell
    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs=np.array([8,8,8])
    cell.verbose = 0

    # Set up the kind of calculation to be done
    # Additional variables for mf_class are passed through mf_dict
    mf_class=pbcdft.RKS
    mf_dict = { 'xc' : 'lda,vwn' }

    # Once this is setup, ASE is used for everything from this point on
    ase_atom.set_calculator(pyscf_ase.PySCF(molcell=cell, mf_class=mf_class, mf_dict=mf_dict))

    print "ASE energy", ase_atom.get_potential_energy()
    print "ASE energy (should avoid re-evaluation)", ase_atom.get_potential_energy()
    # Compute equation of state
    ase_cell=ase_atom.cell
    volumes = []
    energies = []
    for x in np.linspace(0.95, 1.2, 5):
        ase_atom.set_cell(ase_cell * x, scale_atoms = True)
        print "[x: %f, E: %f]" % (x, ase_atom.get_potential_energy())
        volumes.append(ase_atom.get_volume())
        energies.append(ase_atom.get_potential_energy())

    eos = EquationOfState(volumes, energies)
    v0, e0, B = eos.fit()
    print(B / kJ * 1.0e24, 'GPa')
    eos.plot('eos.png')
示例#7
0
"""
Take ASE Diamond structure, input into PySCF and run
"""

import numpy as np
import pyscf.pbc.gto as pbcgto
import pyscf.pbc.dft as pbcdft
from pyscf.pbc.tools import pyscf_ase

import ase
import ase.lattice
from ase.lattice.cubic import Diamond

ase_atom = Diamond(symbol='C', latticeconstant=3.5668)
print(ase_atom.get_volume())

cell = pbcgto.Cell()
cell.verbose = 5
cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
cell.a = ase_atom.cell
cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.build()

mf = pbcdft.RKS(cell)

mf.xc = 'lda,vwn'

print(mf.kernel())  # [10,10,10]: -44.8811199336
示例#8
0
# Set up the kind of calculation to be done
# Additional variables for mf_class are passed through mf_dict
# E.g. gamma-point SCF calculation can be set to
mf_class = pbcdft.RKS
# SCF with k-point sampling can be set to
mf_class = lambda cell: pbcdft.KRKS(cell, kpts=cell.make_kpts([2, 2, 2]))

mf_dict = {'xc': 'lda,vwn'}

# Once this is setup, ASE is used for everything from this point on
ase_atom.set_calculator(
    pyscf_ase.PySCF(molcell=cell, mf_class=mf_class, mf_dict=mf_dict))

print("ASE energy", ase_atom.get_potential_energy())
print("ASE energy (should avoid re-evaluation)",
      ase_atom.get_potential_energy())
# Compute equation of state
ase_cell = ase_atom.cell
volumes = []
energies = []
for x in np.linspace(0.95, 1.2, 5):
    ase_atom.set_cell(ase_cell * x, scale_atoms=True)
    print "[x: %f, E: %f]" % (x, ase_atom.get_potential_energy())
    volumes.append(ase_atom.get_volume())
    energies.append(ase_atom.get_potential_energy())

eos = EquationOfState(volumes, energies)
v0, e0, B = eos.fit()
print(B / kJ * 1.0e24, 'GPa')
eos.plot('eos.png')
示例#9
0
cell.verbose = 0

# Set up the kind of calculation to be done
# Additional variables for mf_class are passed through mf_dict
# E.g. gamma-point SCF calculation can be set to
mf_class = pbcdft.RKS
# SCF with k-point sampling can be set to
mf_class = lambda cell: pbcdft.KRKS(cell, kpts=cell.make_kpts([2,2,2]))

mf_dict = { 'xc' : 'lda,vwn' }

# Once this is setup, ASE is used for everything from this point on
ase_atom.set_calculator(pyscf_ase.PySCF(molcell=cell, mf_class=mf_class, mf_dict=mf_dict))

print("ASE energy", ase_atom.get_potential_energy())
print("ASE energy (should avoid re-evaluation)", ase_atom.get_potential_energy())
# Compute equation of state
ase_cell=ase_atom.cell
volumes = []
energies = []
for x in np.linspace(0.95, 1.2, 5):
    ase_atom.set_cell(ase_cell * x, scale_atoms = True)
    print "[x: %f, E: %f]" % (x, ase_atom.get_potential_energy())
    volumes.append(ase_atom.get_volume())
    energies.append(ase_atom.get_potential_energy())

eos = EquationOfState(volumes, energies)
v0, e0, B = eos.fit()
print(B / kJ * 1.0e24, 'GPa')
eos.plot('eos.png')
示例#10
0
"""
Take ASE Diamond structure, input into PySCF and run
"""

import numpy as np
import pyscf.pbc.gto as pbcgto
import pyscf.pbc.dft as pbcdft
from pyscf.pbc.tools import pyscf_ase

import ase
import ase.lattice
from ase.lattice.cubic import Diamond


ase_atom=Diamond(symbol='C', latticeconstant=3.5668)
print(ase_atom.get_volume())

cell = pbcgto.Cell()
cell.verbose = 5
cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
cell.a=ase_atom.cell
cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.build()

mf=pbcdft.RKS(cell)

mf.xc='lda,vwn'

print(mf.kernel()) # [10,10,10]: -44.8811199336