コード例 #1
0
def bcc_elastic_constants(work_dir, alloys, l=2.86):
    atoms = bulk('Fe', 'bcc', a=l)
    atoms.set_tags([1])

    calc = EMTO()
    calc.set(lat=3, kpts=[27, 27, 27], dmax=2.20, amix=0.02)

    calc.set_alloys(alloys)

    v0, e0, B = EMTO_EOS(work_dir + '/B', atoms, calc)

    print v0, e0, B

    l = (2.0 * v0)**(1.0 / 3.0)
    atoms = bulk('Fe', 'bcc', a=l)
    atoms.set_tags([1])

    C = EC_BCC_C(work_dir + '/C', atoms, calc)
    C44 = EC_BCC_C44(work_dir + '/C44', atoms, calc)
    C11 = (3.0 * B + 2.0 * C) / 3.0
    C12 = (3.0 * B - C) / 3.0
    A = 2.0 * C44 / C
    Gv = (C + 3.0 * C44) / 5.0
    Gr = (5.0 * C * C44) / (4.0 * C44 + 3.0 * C)
    Gh = (Gv + Gr) / 2.0

    return v0, e0, B, C, C44, C11, C12, A, Gv, Gr, Gh
コード例 #2
0
def fcc_elastic_constants(work_dir, alloys, l=3.60):
    atoms = bulk('Fe', 'fcc', a=l)
    atoms.set_tags([1])

    calc = EMTO()
    calc.set(
        lat=2,
        kpts=[13, 13, 13], )

    calc.set_alloys(alloys)

    v0, e0, B = EMTO_EOS(work_dir + '/B', atoms, calc, np.linspace(0.98, 1.02, 9))

    l = (4.0 * v0) ** (1.0 / 3.0)
    atoms = bulk('Fe', 'fcc', a=l)
    atoms.set_tags([1])

    C = EC_FCC_C(work_dir + '/C', atoms, calc)
    C44 = EC_FCC_C44(work_dir + '/C44', atoms, calc)
    C11 = (3.0 * B + 2.0 * C) / 3.0
    C12 = (3.0 * B - C) / 3.0
    A = 2.0 * C44 / C
    Gv = (C + 3.0 * C44) / 5.0
    Gr = (5.0 * C * C44) / (4.0 * C44 + 3.0 * C)
    Gh = (Gv + Gr) / 2.0

    return v0, e0, B, C, C44, C11, C12, A, Gv, Gr, Gh
コード例 #3
0
ファイル: helpers.py プロジェクト: eronca/pyscf
def get_ase_diamond_primitive(atom='C'):
    """Get the ASE atoms for primitive (2-atom) diamond unit cell."""
    from ase.lattice import bulk
    if atom == 'C':
        ase_atom = bulk('C', 'diamond', a=3.5668*A2B)
    else:
        ase_atom = bulk('Si', 'diamond', a=5.431*A2B)
    return ase_atom
コード例 #4
0
ファイル: helpers.py プロジェクト: sunchong137/pyscf_2017
def get_ase_diamond_primitive(atom='C'):
    """Get the ASE atoms for primitive (2-atom) diamond unit cell."""
    from ase.lattice import bulk
    if atom == 'C':
        ase_atom = bulk('C', 'diamond', a=3.5668*A2B)
    else:
        ase_atom = bulk('Si', 'diamond', a=5.431*A2B)
    return ase_atom
コード例 #5
0
ファイル: helpers.py プロジェクト: berquist/pyscf
def get_ase_diamond_primitive(atom="C"):
    """Get the ASE atoms for primitive (2-atom) diamond unit cell."""
    from ase.lattice import bulk

    if atom == "C":
        ase_atom = bulk("C", "diamond", a=3.5668 * A2B)
    else:
        ase_atom = bulk("Si", "diamond", a=5.431 * A2B)
    return ase_atom
コード例 #6
0
ファイル: lattice.py プロジェクト: chrinide/pyscf
def get_ase_diamond_primitive(atom='C'):
    """Get the ASE atoms for primitive (2-atom) diamond unit cell."""
    from ase.build import bulk
    if atom == 'C':
        ase_atom = bulk('C', 'diamond', a=3.5668*A2B)
    elif atom == 'Si':
        ase_atom = bulk('Si', 'diamond', a=5.431*A2B)
    elif atom == 'Ge':
        ase_atom = bulk('Ge', 'diamond', a=5.658*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            atom, '.  Choose a different system?  Or add it to the list!')
    return ase_atom
コード例 #7
0
def get_ase_diamond_primitive(atom='C'):
    """Get the ASE atoms for primitive (2-atom) diamond unit cell."""
    from ase.build import bulk
    if atom == 'C':
        ase_atom = bulk('C', 'diamond', a=3.5668*A2B)
    elif atom == 'Si':
        ase_atom = bulk('Si', 'diamond', a=5.431*A2B)
    elif atom == 'Ge':
        ase_atom = bulk('Ge', 'diamond', a=5.658*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            atom, '.  Choose a different system?  Or add it to the list!')
    return ase_atom
コード例 #8
0
ファイル: gbrv.py プロジェクト: jboes/ase
 def __getitem__(self, name):
     a = self.d[name]
     c = self.category
     if c in ['fcc', 'bcc', 'rocksalt']:
         b = bulk(name, crystalstructure=c, a=a, cubic=True)
     elif c == 'perovskite':
         b = perovskite(name, a)
     elif c == 'halfheusler':
         b = halfheusler(name, a)
     elif c == 'magnetic_moments':
         b = bulk(name, crystalstructure='rocksalt',
                  a=self.data['rocksalt'][name], cubic=True)
         b.set_initial_magnetic_moments([a * 4 / len(b) for i in range(len(b))])
     return b
コード例 #9
0
ファイル: lattice.py プロジェクト: chrinide/pyscf
def get_ase_zincblende(A='Ga', B='As'):
    # Lattice constants from Shishkin and Kresse, PRB 75, 235102 (2007)
    assert A in ['Si', 'Ga', 'Cd', 'Zn', 'B', 'Al']
    assert B in ['C', 'As', 'S', 'O', 'N', 'P']
    from ase.lattice import bulk
    if A=='Si' and B=='C':
        ase_atom = bulk('SiC', 'zincblende', a=4.350*A2B)
    elif A=='Ga' and B=='As':
        ase_atom = bulk('GaAs', 'zincblende', a=5.648*A2B)
    elif A=='Ga' and B=='N':
        ase_atom = bulk('GaN', 'zincblende', a=4.520*A2B)
    elif A=='Cd' and B=='S':
        ase_atom = bulk('CdS', 'zincblende', a=5.832*A2B)
    elif A=='Zn' and B=='S':
        ase_atom = bulk('ZnS', 'zincblende', a=5.420*A2B)
    elif A=='Zn' and B=='O':
        ase_atom = bulk('ZnO', 'zincblende', a=4.580*A2B)
    elif A=='B' and B=='N':
        ase_atom = bulk('BN', 'zincblende', a=3.615*A2B)
    elif A=='Al' and B=='P':
        ase_atom = bulk('AlP', 'zincblende', a=5.451*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            A, B, '.  Choose a different system?  Or add it to the list!')

    return ase_atom
コード例 #10
0
def get_ase_zincblende(A='Ga', B='As'):
    # Lattice constants from Shishkin and Kresse, PRB 75, 235102 (2007)
    assert A in ['Si', 'Ga', 'Cd', 'Zn', 'B', 'Al']
    assert B in ['C', 'As', 'S', 'O', 'N', 'P']
    from ase.lattice import bulk
    if A=='Si' and B=='C':
        ase_atom = bulk('SiC', 'zincblende', a=4.350*A2B)
    elif A=='Ga' and B=='As':
        ase_atom = bulk('GaAs', 'zincblende', a=5.648*A2B)
    elif A=='Ga' and B=='N':
        ase_atom = bulk('GaN', 'zincblende', a=4.520*A2B)
    elif A=='Cd' and B=='S':
        ase_atom = bulk('CdS', 'zincblende', a=5.832*A2B)
    elif A=='Zn' and B=='S':
        ase_atom = bulk('ZnS', 'zincblende', a=5.420*A2B)
    elif A=='Zn' and B=='O':
        ase_atom = bulk('ZnO', 'zincblende', a=4.580*A2B)
    elif A=='B' and B=='N':
        ase_atom = bulk('BN', 'zincblende', a=3.615*A2B)
    elif A=='Al' and B=='P':
        ase_atom = bulk('AlP', 'zincblende', a=5.451*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            A, B, '.  Choose a different system?  Or add it to the list!')

    return ase_atom
コード例 #11
0
ファイル: helpers.py プロジェクト: berquist/pyscf
def get_ase_graphene_xxx(vacuum=5.0):
    """Get the ASE atoms for primitive (2-atom) graphene unit cell."""
    from ase.lattice import bulk

    ase_atom = bulk("C", "hcp", a=2.46 * A2B, c=vacuum * A2B)
    ase_atom.positions[1, 2] = 0.0
    return ase_atom
コード例 #12
0
def test_si_scf_cg():

    si = bulk('Si', 'fcc', 10.2 * Bohr)

    kpts = np.asarray([[0.1250000, 0.1250000, 0.1250000, 1.00],
                       [0.1250000, 0.1250000, 0.3750000, 3.00],
                       [0.1250000, 0.1250000, 0.6250000, 3.00],
                       [0.1250000, 0.1250000, 0.8750000, 3.00],
                       [0.1250000, 0.3750000, 0.3750000, 3.00],
                       [0.1250000, 0.3750000, 0.6250000, 6.00],
                       [0.1250000, 0.3750000, 0.8750000, 6.00],
                       [0.1250000, 0.6250000, 0.6250000, 3.00],
                       [0.3750000, 0.3750000, 0.3750000, 1.00],
                       [0.3750000, 0.3750000, 0.6250000, 3.00]])

    calc = Espresso(pw=18.0 * Rydberg,
                    calculation='scf',
                    kpts=kpts,
                    tprnfor=True,
                    tstress=True,
                    occupations='smearing',
                    smearing='marzari-vanderbilt',
                    degauss=0.05,
                    convergence={
                        'energy': 1e-6,
                        'mixing': 0.7,
                        'maxsteps': 100,
                        'diag': 'cg'
                    },
                    outdir='si_scf')

    si.set_calculator(calc)

    calc.calculate(si)
コード例 #13
0
ファイル: bandgap.py プロジェクト: jboes/ase
def run(name):
    Calculator = get_calculator(name)
    par = required.get(name, {})
    calc = Calculator(label=name + '_bandgap', xc='PBE',
                      kpts=kpts, **par)
                      # abinit, aims, elk - do not recognize the syntax below:
                      # https://trac.fysik.dtu.dk/projects/ase/ticket/98
                      #kpts={'size': kpts, 'gamma': True}, **par)
    si = bulk('Si', crystalstructure='diamond', a=5.43)
    si.calc = calc
    e = si.get_potential_energy()
    print(name, get_band_gap(si.calc))
    del si.calc
    # test spin-polarization
    calc = Calculator(label=name + '_bandgap_spinpol', xc='PBE',
                      kpts=kpts, **par)
                      # abinit, aims, elk - do not recognize the syntax below:
                      # https://trac.fysik.dtu.dk/projects/ase/ticket/98
                      #kpts={'size': kpts, 'gamma': True}, **par)
    si.set_initial_magnetic_moments([-0.1, 0.1])
    # this should not be neccesary in the new ase interface standard ...
    if si.get_initial_magnetic_moments().any():  # spin-polarization
        if name == 'aims':
            calc.set(spin='collinear')
        if name == 'elk':
            calc.set(spinpol=True)
    si.set_calculator(calc)
    e = si.get_potential_energy()
    print(name, get_band_gap(si.calc))
コード例 #14
0
def vasp_vol_relax():
    Al = bulk('Al', 'fcc', a=4.5, cubic=True)
    calc = Vasp(xc='LDA',
                isif=7,
                nsw=5,
                ibrion=1,
                ediffg=-1e-3,
                lwave=False,
                lcharg=False)
    calc.calculate(Al)

    # Explicitly parse atomic position output file from Vasp
    CONTCAR_Al = io.read('CONTCAR', format='vasp')

    print 'Stress after relaxation:\n', calc.read_stress()

    print 'Al cell post relaxation from calc:\n', calc.get_atoms().get_cell()
    print 'Al cell post relaxation from atoms:\n', Al.get_cell()
    print 'Al cell post relaxation from CONTCAR:\n', CONTCAR_Al.get_cell()

    # All the cells should be the same.
    assert (calc.get_atoms().get_cell() == CONTCAR_Al.get_cell()).all()
    assert (Al.get_cell() == CONTCAR_Al.get_cell()).all()

    return Al
コード例 #15
0
ファイル: hsk.py プロジェクト: eojons/gpaw-scme
    def __getitem__(self, name):
        d = self.data[name]
        if self.xc == 'PBE':
            a = d[1]
        else:
            a = d[3]

        return bulk(name, crystalstructure=d[0], a=a)
コード例 #16
0
ファイル: helpers.py プロジェクト: eronca/pyscf
def get_ase_rocksalt(A='Li', B='Cl'):
    assert A in ['Li', 'Mg']
    # Add Na, K
    assert B in ['H', 'F', 'Cl', 'O']
    # Add Br, I
    from ase.lattice import bulk
    if A=='Li':
        if B=='H':
            ase_atom = bulk('LiH', 'rocksalt', a=4.0834*A2B)
        elif B=='F':
            ase_atom = bulk('LiF', 'rocksalt', a=4.0351*A2B)
        elif B=='Cl':
            ase_atom = bulk('LiCl', 'rocksalt', a=5.13*A2B)
    elif A=='Mg' and B=='O':
        ase_atom = bulk('MgO', 'rocksalt', a=4.213*A2B)

    return ase_atom
コード例 #17
0
ファイル: diamond.py プロジェクト: xiexingzhu/aces
    def lmp_structure(self):
        atoms = bulk('C', 'diamond', a=self.bond, cubic=self.cubic)
        atoms = atoms.repeat([self.latx, self.laty, self.latz])
        atoms.set_pbc([self.xp, self.yp, self.zp])

        if not self.al:
            atoms.center()
        return atoms
コード例 #18
0
ファイル: helpers.py プロジェクト: sunchong137/pyscf_2017
def get_ase_rocksalt(A='Li', B='Cl'):
    assert A in ['Li', 'Mg']
    # Add Na, K
    assert B in ['H', 'F', 'Cl', 'O']
    # Add Br, I
    from ase.lattice import bulk
    if A=='Li':
        if B=='H':
            ase_atom = bulk('LiH', 'rocksalt', a=4.0834*A2B)
        elif B=='F':
            ase_atom = bulk('LiF', 'rocksalt', a=4.0351*A2B)
        elif B=='Cl':
            ase_atom = bulk('LiCl', 'rocksalt', a=5.13*A2B)
    elif A=='Mg' and B=='O':
        ase_atom = bulk('MgO', 'rocksalt', a=4.213*A2B)

    return ase_atom
コード例 #19
0
ファイル: helpers.py プロジェクト: berquist/pyscf
def get_ase_rocksalt(A="Li", B="Cl"):
    assert A in ["Li", "Mg"]
    # Add Na, K
    assert B in ["H", "F", "Cl", "O"]
    # Add Br, I
    from ase.lattice import bulk

    if A == "Li":
        if B == "H":
            ase_atom = bulk("LiH", "rocksalt", a=4.0834 * A2B)
        elif B == "F":
            ase_atom = bulk("LiF", "rocksalt", a=4.0351 * A2B)
        elif B == "Cl":
            ase_atom = bulk("LiCl", "rocksalt", a=5.13 * A2B)
    elif A == "Mg" and B == "O":
        ase_atom = bulk("MgO", "rocksalt", a=4.213 * A2B)

    return ase_atom
コード例 #20
0
ファイル: Al.py プロジェクト: xiexingzhu/aces
	def lmp_structure(self):
		atoms = bulk('Al', 'fcc', a=self.bond, cubic=self.cubic).repeat([self.latx,self.laty,self.latz])
		atoms.set_pbc([self.xp,self.yp,self.zp])
		atoms.center()
		return atoms
		
	

		
コード例 #21
0
ファイル: structure.py プロジェクト: jboes/ase
def estimate_lattice_constant(name, crystalstructure, covera):
    from ase.lattice import bulk
    atoms = bulk(name, crystalstructure, 1.0, covera)
    v0 = atoms.get_volume()
    v = 0.0
    for Z in atoms.get_atomic_numbers():
        r = covalent_radii[Z]
        v += 4 * np.pi / 3 * r**3 * 1.5
    return (v / v0)**(1.0 / 3)
コード例 #22
0
ファイル: structure.py プロジェクト: adbX/ase
def estimate_lattice_constant(name, crystalstructure, covera):
    from ase.lattice import bulk
    atoms = bulk(name, crystalstructure, 1.0, covera)
    v0 = atoms.get_volume()
    v = 0.0
    for Z in atoms.get_atomic_numbers():
        r = covalent_radii[Z]
        v += 4 * np.pi / 3 * r**3 * 1.5
    return (v / v0)**(1.0 / 3)
コード例 #23
0
ファイル: SC.py プロジェクト: vanceeasleaf/aces
	def lmp_structure(self):
		atoms = bulk('Ar', 'sc', a=self.bond, cubic=self.cubic).repeat([self.latx,self.laty,self.latz])
		atoms.set_pbc([self.xp,self.yp,self.zp])
		atoms.center()
		return atoms
		
	

		
コード例 #24
0
 def test_klda8_primitive_gamma(self):
     ase_atom = bulk('C', 'diamond', a=LATTICE_CONST)
     cell = build_cell(ase_atom, 8)
     mf = pbcdft.RKS(cell)
     mf.xc = 'lda,vwn'
     #kmf.verbose = 7
     e1 = mf.scf()
     #print "mf._ecoul =", mf._ecoul
     #print "mf._exc =", mf._exc
     self.assertAlmostEqual(e1, -10.221426938778345, 8)
コード例 #25
0
ファイル: si_pbe.py プロジェクト: robwarm/gpaw-symm
def groundstate(a, k):
    si = bulk('Si', 'diamond', a)
    si.calc = GPAW(kpts=(k, k, k),
                   xc='PBE',
                   gpts=(20, 20, 20),
                   occupations=FermiDirac(0.01),
                   parallel={'domain': 1, 'band': 1},
                   txt='Si-PBE-%.3f-%d.txt' % (a, k))
    si.get_potential_energy()
    return si
コード例 #26
0
ファイル: test_krks.py プロジェクト: eronca/pyscf
 def test_klda8_primitive_gamma(self):
     ase_atom = bulk('C', 'diamond', a=LATTICE_CONST)
     cell = build_cell(ase_atom, 8)
     mf = pbcdft.RKS(cell)
     mf.xc = 'lda,vwn'
     #kmf.verbose = 7
     e1 = mf.scf()
     #print "mf._ecoul =", mf._ecoul
     #print "mf._exc =", mf._exc
     self.assertAlmostEqual(e1, -10.221426938778345, 8)
コード例 #27
0
ファイル: test_krks.py プロジェクト: ncrubin/pyscf
 def test_klda8_primitive_gamma(self):
     from ase.lattice import bulk
     ase_atom = bulk('C', 'diamond', a=LATTICE_CONST)
     cell = build_cell(ase_atom, 8)
     mf = pbcdft.RKS(cell)
     mf.xc = 'lda,vwn'
     #kmf.verbose = 7
     e1 = mf.scf()
     print "mf._ecoul =", mf._ecoul
     print "mf._exc =", mf._exc
     self.assertAlmostEqual(e1, -10.2214263103746, 8)
コード例 #28
0
def get_ase_rocksalt(A='Li', B='Cl'):
    assert A in ['Li', 'Mg']
    # Add Na, K
    assert B in ['H', 'F', 'Cl', 'O']
    # Add Br, I
    from ase.lattice import bulk
    if A=='Li':
        if B=='H':
            ase_atom = bulk('LiH', 'rocksalt', a=4.0834*A2B)
        elif B=='F':
            ase_atom = bulk('LiF', 'rocksalt', a=4.0351*A2B)
        elif B=='Cl':
            ase_atom = bulk('LiCl', 'rocksalt', a=5.13*A2B)
    elif A=='Mg' and B=='O':
        ase_atom = bulk('MgO', 'rocksalt', a=4.213*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            A, B, '.  Choose a different system?  Or add it to the list!')

    return ase_atom
コード例 #29
0
ファイル: test_band_ase.py プロジェクト: lichen5/pyscf
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(c)
    cell.h = c.cell.T

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([5, 5, 5])
    cell.verbose = 7
    cell.build(None, None)

    scaled_kpts = ase.dft.kpoints.monkhorst_pack((1, 1, 1))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    print kmf.scf()

    e_kn = []
    for kpt in band_kpts:
        fb, sb = kmf.get_band_fock_ovlp(kmf.get_hcore() + kmf.get_veff(),
                                        kmf.get_ovlp(), kpt)
        e, c = hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)

    emin = -1
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
コード例 #30
0
ファイル: lattice.py プロジェクト: chrinide/pyscf
def get_ase_rocksalt(A='Li', B='Cl'):
    assert A in ['Li', 'Mg']
    # Add Na, K
    assert B in ['H', 'F', 'Cl', 'O']
    # Add Br, I
    from ase.lattice import bulk
    if A=='Li':
        if B=='H':
            ase_atom = bulk('LiH', 'rocksalt', a=4.0834*A2B)
        elif B=='F':
            ase_atom = bulk('LiF', 'rocksalt', a=4.0351*A2B)
        elif B=='Cl':
            ase_atom = bulk('LiCl', 'rocksalt', a=5.13*A2B)
    elif A=='Mg' and B=='O':
        ase_atom = bulk('MgO', 'rocksalt', a=4.213*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            A, B, '.  Choose a different system?  Or add it to the list!')

    return ase_atom
コード例 #31
0
ファイル: lattice.py プロジェクト: chrinide/pyscf
def get_ase_wurtzite(A='Zn', B='O'):
    # Lattice constants taken from wikipedia (TODO: is wikipedia a valid
    # citation at this point? en.wikipedia.org/wiki/Lattice_constant)
    assert A in ['Zn']
    assert B in ['O']
    from ase.lattice import bulk
    if A=='Zn' and B=='O':
        ase_atom = bulk('ZnO', 'wurtzite', a=3.25*A2B, c=5.2*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            A, B, '.  Choose a different system?  Or add it to the list!')
コード例 #32
0
ファイル: test_band_ase.py プロジェクト: eronca/pyscf
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(c)
    cell.a=c.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs=np.array([5,5,5])
    cell.verbose=7
    cell.build(None,None)
    
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((1,1,1))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
 
    e_kn = []
    for kpt in band_kpts:
        fb, sb=kmf.get_band_fock_ovlp(kmf.get_hcore()+kmf.get_veff(),
                                      kmf.get_ovlp(), kpt)
        e, c=hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)
    
    emin = -1 
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
コード例 #33
0
def setup_bulk(solid, offset=0., set_lp=True):
    from ase.lattice import bulk
    in_bulk_data(solid)
    symbol = get_solid_symbols(solid)
    s = get_solid_crystal_structure(solid)
    if set_lp:
        lp = offset
    else:
        lp = get_solid_lattice_parameter(solid) + offset
    m = get_solid_magmom(solid)
    if s == 'hcp':
        cov = get_hcp_covera(solid)
        atoms = bulk(symbol, s, a=lp, covera=cov)
    else:
        atoms = bulk(symbol, s, a=lp)
    atoms.set_pbc(True)
    if m != None:
        mm = np.zeros(len(atoms))
        mm[:] = m
        atoms.set_initial_magnetic_moments(mm)
    return atoms
コード例 #34
0
ファイル: htb.py プロジェクト: PHOTOX/fuase
    def __getitem__(self, name):
        d = self.data[name]
        # the index of functional in labels less one
        # (solid is already as key in d)
        a = d[self.labels.index(self.xc) - 1]
        cs = strukturbericht[d[0]]
        b = bulk(name, crystalstructure=cs, a=a)
        M = {'Fe': 2.3, 'Co': 1.2, 'Ni': 0.6}.get(name)
        if M is not None:
            b.set_initial_magnetic_moments([M] * len(b))

        return b
コード例 #35
0
ファイル: Si.py プロジェクト: vanceeasleaf/aces
	def lmp_structure(self):
		atoms = bulk('Si', 'diamond', a=self.bond, cubic=self.cubic)
		atoms=atoms.repeat([self.latx,self.laty,self.latz])
		atoms.set_pbc([self.xp,self.yp,self.zp])
		
		if not self.al:
			atoms.center()
		return atoms
		
	

		
コード例 #36
0
ファイル: htb.py プロジェクト: martin-stoehr/ase-devel
    def __getitem__(self, name):
        d = self.data[name]
        # the index of functional in labels less one
        # (solid is already as key in d)
        a = d[self.labels.index(self.xc) - 1]
        cs = strukturbericht[d[0]]
        b = bulk(name, crystalstructure=cs, a=a)
        M = {'Fe': 2.3, 'Co': 1.2, 'Ni': 0.6}.get(name)
        if M is not None:
            b.set_initial_magnetic_moments([M] * len(b))

        return b
コード例 #37
0
def get_ase_wurtzite(A='Zn', B='O'):
    # Lattice constants taken from wikipedia (TODO: is wikipedia a valid
    # citation at this point? en.wikipedia.org/wiki/Lattice_constant)
    assert A in ['Zn']
    assert B in ['O']
    from ase.lattice import bulk
    if A=='Zn' and B=='O':
        ase_atom = bulk('ZnO', 'wurtzite', a=3.25*A2B, c=5.2*A2B)
    else:
        raise NotImplementedError('No formula found for system ',
            A, B, '.  Choose a different system?  Or add it to the list!')
    return ase_atom
コード例 #38
0
def test_diamond_C():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    C = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(C)
    cell.a = C.cell

    # cell.basis = 'gth-tzvp'
    cell.basis = 'gth-szv'
    # cell.basis = {'C': [[0, (4.3362376436, 0.1490797872), (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051), (0.1187877657, -0.3964426906)], [1, (4.3362376436, -0.0878123619), (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093), (0.1187877657, -0.4058039291)]]}
    # Easier basis for quick testing
    #cell.basis = {'C': [[0, (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051)], [1, (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093) ]]}

    # Cell used for K-points
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([8, 8, 8])
    cell.verbose = 7
    cell.build(None, None)

    # Replicate cell NxNxN for comparison
    # repcell = pyscf.pbc.tools.replicate_cell(cell, (2,2,2))
    # repcell.gs = np.array([12,12,12]) # for 3 replicated cells, then
    # #                                 # ngs must be of the form [3gs0 + 1, gs1, gs2]
    # repcell.build()
    # # # Replicated MF calc
    # mf = pbcdft.RKS(repcell)
    # # mf.analytic_int = True
    # mf.xc = 'lda,vwn'
    # mf.init_guess = '1e'
    # mf.diis = True
    # mf.scf()

    # K-pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2, 2, 2))

    # shift if 2x2x2 includes Gamma point
    # shift = np.array([1./4., 1./4., 1./4.])
    # scaled_kpts += shift
    abs_kpts = cell.get_abs_kpts(scaled_kpts)
    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.diis = True
    kmf.init_guess = '1e'
    kmf.xc = 'lda,vwn'
    print "N imgs", cell.nimgs
    print "Cutoff for 400 eV", pyscf.pbc.tools.cutoff_to_gs(
        cell.lattice_vectors(), 400 / 27.2)

    #kmf.max_cycle = 3
    kmf.scf()
コード例 #39
0
ファイル: si_pbe.py プロジェクト: Xu-Kai/lotsofcoresbook2code
def groundstate(a, k):
    si = bulk('Si', 'diamond', a)
    si.calc = GPAW(kpts=(k, k, k),
                   xc='PBE',
                   gpts=(20, 20, 20),
                   occupations=FermiDirac(0.01),
                   parallel={
                       'domain': 1,
                       'band': 1
                   },
                   txt='Si-PBE-%.3f-%d.txt' % (a, k))
    si.get_potential_energy()
    return si
コード例 #40
0
ファイル: test_krks.py プロジェクト: eronca/pyscf
 def test_klda8_primitive_kpt_222(self):
     ase_atom = bulk('C', 'diamond', a=LATTICE_CONST)
     scaled_kpts = ase.dft.kpoints.monkhorst_pack((2,2,2))
     cell = build_cell(ase_atom, 8)
     abs_kpts = cell.get_abs_kpts(scaled_kpts)
     mf = pbcdft.KRKS(cell, abs_kpts)
     #mf.analytic_int = False
     mf.xc = 'lda,vwn'
     #mf.verbose = 7
     e1 = mf.scf()
     #print "mf._ecoul =", mf._ecoul
     #print "mf._exc =", mf._exc
     self.assertAlmostEqual(e1, -11.353643738291005, 8)
コード例 #41
0
 def test_klda8_primitive_kpt_222(self):
     ase_atom = bulk('C', 'diamond', a=LATTICE_CONST)
     scaled_kpts = ase.dft.kpoints.monkhorst_pack((2, 2, 2))
     cell = build_cell(ase_atom, 8)
     abs_kpts = cell.get_abs_kpts(scaled_kpts)
     mf = pbcdft.KRKS(cell, abs_kpts)
     #mf.analytic_int = False
     mf.xc = 'lda,vwn'
     #mf.verbose = 7
     e1 = mf.scf()
     #print "mf._ecoul =", mf._ecoul
     #print "mf._exc =", mf._exc
     self.assertAlmostEqual(e1, -11.353643738291005, 8)
コード例 #42
0
ファイル: test_diamond_C.py プロジェクト: berquist/pyscf
def test_diamond_C():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    C = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(C)
    cell.h = C.cell

    # cell.basis = 'gth-tzvp'
    cell.basis = 'gth-szv'
    # cell.basis = {'C': [[0, (4.3362376436, 0.1490797872), (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051), (0.1187877657, -0.3964426906)], [1, (4.3362376436, -0.0878123619), (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093), (0.1187877657, -0.4058039291)]]}
    # Easier basis for quick testing
    #cell.basis = {'C': [[0, (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051)], [1, (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093) ]]}

    # Cell used for K-points
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([8,8,8])
    cell.verbose = 7
    cell.build(None,None)

    # Replicate cell NxNxN for comparison
    # repcell = pyscf.pbc.tools.replicate_cell(cell, (2,2,2))
    # repcell.gs = np.array([12,12,12]) # for 3 replicated cells, then
    # #                                 # ngs must be of the form [3gs0 + 1, gs1, gs2]
    # repcell.build()
    # # # Replicated MF calc
    # mf = pbcdft.RKS(repcell)
    # # mf.analytic_int = True
    # mf.xc = 'lda,vwn'
    # mf.init_guess = '1e'
    # mf.diis = True
    # mf.scf()
    
    # K-pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2,2,2))

    # shift if 2x2x2 includes Gamma point
    # shift = np.array([1./4., 1./4., 1./4.])
    # scaled_kpts += shift
    abs_kpts = cell.get_abs_kpts(scaled_kpts)
    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.diis = True
    kmf.init_guess = '1e'
    kmf.xc = 'lda,vwn'
    print "N imgs", cell.nimgs
    print "Cutoff for 400 eV", pyscf.pbc.tools.cutoff_to_gs(cell.lattice_vectors(), 400/27.2)

    #kmf.max_cycle = 3
    kmf.scf() 
コード例 #43
0
def ase_vol_relax():
    Al = bulk('Al', 'fcc', a=4.5, cubic=True)
    calc = Vasp(xc='LDA')
    Al.set_calculator(calc)

    from ase.constraints import StrainFilter
    sf = StrainFilter(Al)
    qn = QuasiNewton(sf, logfile='relaxation.log')
    qn.run(fmax=0.1, steps=5)

    print 'Stress:\n', calc.read_stress()
    print 'Al post ASE volume relaxation\n', calc.get_atoms().get_cell()

    return Al
コード例 #44
0
ファイル: crack.py プロジェクト: Montmorency/fracture
 def calculate_c(self, pot, size=(1,1,1)):
   """
   Calculate the elastic constants for the underlying crack unit cell.
   """
   if self.symbol=='Si':
     at_bulk = bulk('Si', a=self.a0, cubic=True)
   elif self.symbol=='Fe':
     at_bulk = BodyCenteredCubic(directions=[self.crack_direction, self.cleavage_plane, self.crack_front],
                              size=size, symbol='Fe', pbc=(1,1,1),
                              latticeconstant=self.a0)
   at_bulk.set_calculator(pot)
   self.cij  = pot.get_elastic_constants(at_bulk)
   print((self.cij / units.GPa).round(2))
   return
コード例 #45
0
ファイル: build.py プロジェクト: jboes/ase
def build_bulk(name, opts):
    L = opts.lattice_constant.replace(',', ' ').split()
    d = dict([(key, float(x)) for key, x in zip('ac', L)])
    atoms = bulk(name, crystalstructure=opts.crystal_structure,
                 a=d.get('a'), c=d.get('c'),
                 orthorhombic=opts.orthorhombic, cubic=opts.cubic)

    M, X = {'Fe': (2.3, 'bcc'),
            'Co': (1.2, 'hcp'),
            'Ni': (0.6, 'fcc')}.get(name, (None, None))
    if M is not None and opts.crystal_structure == X:
        atoms.set_initial_magnetic_moments([M] * len(atoms))

    return atoms
コード例 #46
0
def ase_vol_relax():
    Al = bulk('Al', 'fcc', a=4.5, cubic=True)
    calc = Vasp(xc='LDA')
    Al.set_calculator(calc)

    from ase.constraints import StrainFilter
    sf = StrainFilter(Al)
    qn = QuasiNewton(sf, logfile='relaxation.log')
    qn.run(fmax=0.1, steps=5)

    print 'Stress:\n', calc.read_stress()
    print 'Al post ASE volume relaxation\n', calc.get_atoms().get_cell()

    return Al
コード例 #47
0
ファイル: bulk.py プロジェクト: izxle/VaspTools
def main(argv=[]):
    args = getArgs(argv)
    # create slab
    kw = dict(vars(args))
    del kw['pad']
    atoms = bulk(**kw)
    # write POSCAR
    kw = {'format': 'vasp',
          'sort': True,
          'vasp5': True,
          'direct': True}
          
    nam = 'POSCAR' + args.pad
    write(nam, atoms, **kw)
コード例 #48
0
ファイル: vasp_Al_volrelax.py プロジェクト: jboes/ase
def ase_vol_relax():
    Al = bulk("Al", "fcc", a=4.5, cubic=True)
    calc = Vasp(xc="LDA")
    Al.set_calculator(calc)

    from ase.constraints import StrainFilter

    sf = StrainFilter(Al)
    qn = QuasiNewton(sf, logfile="relaxation.log")
    qn.run(fmax=0.1, steps=5)

    print("Stress:\n", calc.read_stress())
    print("Al post ASE volume relaxation\n", calc.get_atoms().get_cell())

    return Al
コード例 #49
0
ファイル: test_pbc.py プロジェクト: sunchong137/pyscf_2017
 def test_coulG(self):
     numpy.random.seed(19)
     kpt = numpy.random.random(3)
     ase_atom = bulk('C', 'diamond', a=3.5668)
     cell = pbcgto.Cell()
     cell.unit = 'A'
     cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
     cell.h = ase_atom.cell + numpy.random.random((3, 3))
     cell.basis = 'gth-szv'
     cell.pseudo = 'gth-pade'
     cell.gs = [5, 4, 3]
     cell.verbose = 5
     cell.output = '/dev/null'
     cell.build()
     coulG = tools.get_coulG(cell, kpt)
     self.assertAlmostEqual(finger(coulG), 62.75448804333378, 9)
コード例 #50
0
def make_primitive_cell(ngs):
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    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([ngs, ngs, ngs])

    #cell.nimgs = np.array([7,7,7])
    cell.verbose = 0
    cell.build()
    return cell
コード例 #51
0
    def build_system(self, name):
        atoms = bulk(name, crystalstructure=self.crystal_structure,
                     a=self.lattice_constant, covera=self.c_over_a,
                     orthorhombic=self.orthorhombic, cubic=self.cubic)

        M = {'Fe': 2.3, 'Co': 1.2, 'Ni': 0.6}.get(name)
        if M is not None:
            atoms.set_initial_magnetic_moments([M] * len(atoms))

        if self.repeat is not None:
            r = self.repeat.split(',')
            if len(r) == 1:
                r = 3 * r
            atoms = atoms.repeat([int(c) for c in r])

        return atoms
コード例 #52
0
ファイル: test_pbc.py プロジェクト: sunchong137/pyscf_2017
 def test_coulG_ws(self):
     ase_atom = bulk('C', 'diamond', a=3.5668)
     cell = pbcgto.Cell()
     cell.unit = 'A'
     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 = [5] * 3
     cell.verbose = 5
     cell.output = '/dev/null'
     cell.build()
     mf = khf.KRHF(cell, exxdiv='vcut_ws')
     mf.kpts = cell.make_kpts([2, 2, 2])
     coulG = tools.get_coulG(cell, mf.kpts[2], True, mf)
     self.assertAlmostEqual(finger(coulG), 166.15891996685517, 9)
コード例 #53
0
ファイル: test_sampling.py プロジェクト: berquist/pyscf
def make_primitive_cell(ngs):
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    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([ngs,ngs,ngs])

    #cell.nimgs = np.array([7,7,7])
    cell.verbose = 0
    cell.build()
    return cell
コード例 #54
0
def test():

    ANALYTIC=False
    ase_atom=bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h=ase_atom.cell
    cell.verbose = 7

    # gth-szv for C
    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'

    cell.gs = np.array([4,1,1])
    cell.build(None, None)

    print "N images: ", cell.nimgs
    cell.nimgs = [10,1,1]
    repcell = pyscf.pbc.tools.replicate_cell(cell, (3,1,1))
    print "REPCELL", repcell.pseudo

    mf = pbcdft.RKS(repcell)
    mf.verbose = 5
    mf.diis = False
    mf.analytic_int=ANALYTIC
    mf.xc = 'lda,vwn'
    mf.max_cycle = 1
    mf.init_guess = '1e'
    mf.scf()

    scaled_kpts=np.array(ase.dft.kpoints.monkhorst_pack((3,1,1)))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    cell.gs = np.array([1,1,1])
    cell.nimgs = [14,1,1]
    cell.build(None, None)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=ANALYTIC
    kmf.diis = False
    kmf.verbose = 5
    kmf.xc = 'lda,vwn'
    kmf.max_cycle = 1
    kmf.init_guess = '1e'
    kmf.scf()
コード例 #55
0
ファイル: test_khf.py プロジェクト: eronca/pyscf
def make_primitive_cell(ngs):
    from ase.lattice import bulk
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    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([ngs,ngs,ngs])

    cell.verbose = 5
    cell.output = '/dev/null'
    cell.build()
    return cell
コード例 #56
0
ファイル: test_khf.py プロジェクト: lichen5/pyscf
def make_primitive_cell(ngs):
    from ase.lattice import bulk
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell.T

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs,ngs,ngs])

    cell.verbose = 5
    cell.output = '/dev/null'
    cell.build()
    return cell
コード例 #57
0
 def calculate_c(self, pot, size=(1, 1, 1)):
     """
 Calculate the elastic constants for the underlying crack unit cell.
 """
     if self.symbol == 'Si':
         at_bulk = bulk('Si', a=self.a0, cubic=True)
     elif self.symbol == 'Fe':
         at_bulk = BodyCenteredCubic(directions=[
             self.crack_direction, self.cleavage_plane, self.crack_front
         ],
                                     size=size,
                                     symbol='Fe',
                                     pbc=(1, 1, 1),
                                     latticeconstant=self.a0)
     at_bulk.set_calculator(pot)
     self.cij = pot.get_elastic_constants(at_bulk)
     print((self.cij / units.GPa).round(2))
     return
コード例 #58
0
ファイル: al.py プロジェクト: grhawk/ASE
def run(name):
    Calculator = get_calculator(name)
    par = required.get(name, {})
    calc = Calculator(label=name, xc='LDA', kpts=1.0, **par)
    al = bulk('AlO', crystalstructure='rocksalt', a=4.5)
    al.calc = calc
    e = al.get_potential_energy()
    calc.set(xc='PBE', kpts=(2, 2, 2))
    epbe = al.get_potential_energy()
    print(e, epbe)
    calc = Calculator(name)
    print calc.parameters, calc.results, calc.atoms
    assert not calc.calculation_required(al, ['energy'])
    al = calc.get_atoms()
    print al.get_potential_energy()
    label = 'dir/' + name + '-2'
    calc = Calculator(label=label, atoms=al, xc='LDA', kpts=1.0, **par)
    print al.get_potential_energy()
    print Calculator.read_atoms(label).get_potential_energy()
コード例 #59
0
ファイル: build.py プロジェクト: adbX/ase
def build_bulk(name, opts):
    L = opts.lattice_constant.replace(',', ' ').split()
    d = dict([(key, float(x)) for key, x in zip('ac', L)])
    atoms = bulk(name,
                 crystalstructure=opts.crystal_structure,
                 a=d.get('a'),
                 c=d.get('c'),
                 orthorhombic=opts.orthorhombic,
                 cubic=opts.cubic)

    M, X = {
        'Fe': (2.3, 'bcc'),
        'Co': (1.2, 'hcp'),
        'Ni': (0.6, 'fcc')
    }.get(name, (None, None))
    if M is not None and opts.crystal_structure == X:
        atoms.set_initial_magnetic_moments([M] * len(atoms))

    return atoms