当前位置: 首页>>代码示例>>Python>>正文


Python Vasp.stop_if方法代码示例

本文整理汇总了Python中vasp.Vasp.stop_if方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.stop_if方法的具体用法?Python Vasp.stop_if怎么用?Python Vasp.stop_if使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vasp.Vasp的用法示例。


在下文中一共展示了Vasp.stop_if方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FaceCenteredCubic

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from vasp import Vasp
from ase.lattice.cubic import FaceCenteredCubic
from ase import Atoms, Atom
# bulk system
atoms = FaceCenteredCubic(directions=[[0, 1, 1],
                                      [1, 0, 1],
                                      [1, 1, 0]],
                                      size=(1, 1, 1),
                                      symbol='Rh')
calc = Vasp('bulk/bulk-rh',
            xc='PBE',
            encut=350,
            kpts=[4, 4, 4],
            isif=3,
            ibrion=2,
            nsw=10,
            atoms=atoms)
bulk_energy = atoms.get_potential_energy()
# atomic system
atoms = Atoms([Atom('Rh',[5, 5, 5])],
              cell=(7, 8, 9))
calc = Vasp('bulk/atomic-rh',
            xc='PBE',
            encut=350,
            kpts=[1, 1, 1],
            atoms=atoms)
atomic_energy = atoms.get_potential_energy()
calc.stop_if(None in (bulk_energy, atomic_energy))
cohesive_energy = atomic_energy - bulk_energy
print 'The cohesive energy is {0:1.3f} eV'.format(cohesive_energy)
开发者ID:beeruyue,项目名称:dft-book,代码行数:32,代码来源:script-122.py

示例2: Vasp

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
# Run NH3 NEB calculations
from vasp import Vasp
from ase.neb import NEB
from ase.io import read
atoms = Vasp('molecules/nh3-initial').get_atoms()
atoms2 = Vasp('molecules/nh3-final').get_atoms()
# 5 images including endpoints
images = [atoms]   # initial state
images += [atoms.copy() for i in range(3)]
images += [atoms2]  # final state
neb = NEB(images)
neb.interpolate()
calc = Vasp('molecules/nh3-neb',
            xc='PBE',
            ibrion=1, encut=350,
            nsw=90,
            spring=-5.0,
            atoms=images)
#calc.write_db(atoms, 'molecules/nh3-neb/00/DB.db')
#calc.write_db(atoms2, 'molecules/nh3-neb/04/DB.db')
images, energies = calc.get_neb()
calc.stop_if(None in energies)
print images
print energies
p = calc.plot_neb(show=False)
import matplotlib.pyplot as plt
plt.savefig('images/nh3-neb.png')
开发者ID:beeruyue,项目名称:dft-book,代码行数:29,代码来源:script-84.py

示例3: len

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from vasp import Vasp
# don't forget to normalize your total energy to a formula unit. Cu2O
# has 3 atoms, so the number of formula units in an atoms is
# len(atoms)/3.
calc = Vasp('bulk/Cu2O')
atoms1 = calc.get_atoms()
cu2o_energy = atoms1.get_potential_energy()
calc = Vasp('bulk/CuO')
atoms2 = calc.get_atoms()
cuo_energy = atoms2.get_potential_energy()
# make sure to use the same cutoff energy for the O2 molecule!
calc = Vasp('molecules/O2-sp-triplet-400')
atoms3 = calc.get_atoms()
o2_energy = atoms3.get_potential_energy()
calc.stop_if(None in [cu2o_energy, cuo_energy, o2_energy])
cu2o_energy /= (len(atoms1) / 3)  # note integer math
cuo_energy /= (len(atoms2) / 2)
rxn_energy = 4.0 * cuo_energy - o2_energy - 2.0 * cu2o_energy
print 'Reaction energy = {0} eV'.format(rxn_energy)
开发者ID:beeruyue,项目名称:dft-book,代码行数:21,代码来源:script-145.py

示例4: Vasp

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
                                      [1, 0, 1],
                                      [1, 1, 0]],
                                      size=(1, 1, 1),
                                      symbol='Ni')
atoms[0].magmom = 1
calc = Vasp('bulk/Ni-PBE',
            ismear=-5,
            kpts=[5, 5, 5],
            xc='PBE',
            ispin=2,
            lorbit=11,
            lwave=True, lcharg=True,  # store for reuse
            atoms=atoms)
e = atoms.get_potential_energy()
print('PBE energy:   ',e)
calc.stop_if(e is None)
dos = DOS(calc, width=0.2)
e_pbe = dos.get_energies()
d_pbe = dos.get_dos()
calc.clone('bulk/Ni-PBE0')
calc.set(xc='pbe0')
atoms = calc.get_atoms()
pbe0_e = atoms.get_potential_energy()
if atoms.get_potential_energy() is not None:
    dos = DOS(calc, width=0.2)
    e_pbe0 = dos.get_energies()
    d_pbe0 = dos.get_dos()
## HSE06
calc = Vasp('bulk/Ni-PBE')
calc.clone('bulk/Ni-HSE06')
calc.set(xc='hse06')
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-219.py

示例5: molecule

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
### Setup calculators
benzene = molecule('C6H6')
benzene.set_cell([10, 10, 10])
benzene.center()
calc1 = Vasp('molecules/benzene',
            xc='PBE',
            nbands=18,
            encut=350,
            atoms=benzene)
calc1.set(lcharg=True)
chlorobenzene =  molecule('C6H6')
chlorobenzene.set_cell([10, 10, 10])
chlorobenzene.center()
chlorobenzene[11].symbol ='Cl'
calc2 = Vasp('molecules/chlorobenzene',
            xc='PBE',
            nbands=22,
            encut=350,
            atoms=chlorobenzene)
calc2.set(lcharg=True)
calc2.stop_if(None in (calc1.potential_energy, calc2.potential_energy))
x1, y1, z1, cd1 = calc1.get_charge_density()
x2, y2, z2, cd2 = calc2.get_charge_density()
cdiff = cd2 - cd1
print(cdiff.min(), cdiff.max())
##########################################
##### set up visualization of charge difference
from enthought.mayavi import mlab
mlab.contour3d(x1, y1, z1, cdiff,
               contours=[-0.02, 0.02])
mlab.savefig('images/cdiff.png')
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-30.py

示例6: Atoms

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from vasp import Vasp
from ase import Atom, Atoms
import numpy as np
# fcc
LC = [3.5, 3.55, 3.6, 3.65, 3.7, 3.75]
fcc_energies = []
ready = True
for a in LC:
    atoms = Atoms([Atom('Cu', (0, 0, 0))],
                  cell=0.5 * a * np.array([[1.0, 1.0, 0.0],
                                           [0.0, 1.0, 1.0],
                                           [1.0, 0.0, 1.0]]))
    calc = Vasp('bulk/Cu-{0}'.format(a),
                xc='PBE',
                encut=350,
                kpts=[8, 8, 8],
                atoms=atoms)
    e = atoms.get_potential_energy()
    fcc_energies.append(e)
calc.stop_if(None in fcc_energies)
import matplotlib.pyplot as plt
plt.plot(LC, fcc_energies)
plt.xlabel('Lattice constant ($\AA$)')
plt.ylabel('Total energy (eV)')
plt.savefig('images/Cu-fcc.png')
print '#+tblname: cu-fcc-energies'
print r'| lattice constant ($\AA$) | Total Energy (eV) |'
for lc, e in zip(LC, fcc_energies):
    print '| {0} | {1} |'.format(lc, e)
开发者ID:beeruyue,项目名称:dft-book,代码行数:31,代码来源:script-102.py

示例7: enumerate

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from vasp import Vasp
import matplotlib.pyplot as plt
import numpy as np
x = [2.5, 2.6, 2.7, 2.8, 2.9]
y = [1.4, 1.5, 1.6, 1.7, 1.8]
X,Y = np.meshgrid(x, y)
Z = np.zeros(X.shape)
for i,a in enumerate(x):
    for j,covera in enumerate(y):
        wd = 'bulk/Ru/{0:1.2f}-{1:1.2f}'.format(a, covera)
        calc = Vasp(wd)
        Z[i][j] = calc.potential_energy
calc.stop_if(None in Z)
cf = plt.contourf(X, Y, Z, 20,
                  cmap=plt.cm.jet)
cbar = plt.colorbar(cf)
cbar.ax.set_ylabel('Energy (eV)')
plt.xlabel('$a$ ($\AA$)')
plt.ylabel('$c/a$')
plt.legend()
plt.savefig('images/ru-contourf.png')
plt.show()
开发者ID:beeruyue,项目名称:dft-book,代码行数:24,代码来源:script-108.py

示例8: FaceCenteredCubic

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from vasp import Vasp
from ase.lattice.cubic import FaceCenteredCubic
from ase import Atoms, Atom
# bulk system
atoms = FaceCenteredCubic(directions=[[0, 1, 1],
                                      [1, 0, 1],
                                      [1, 1, 0]],
                                     size=(1, 1, 1),
                                     symbol='Rh')
calc = Vasp('bulk/bulk-rh',
            xc='PBE',
            encut=350,
            kpts=[4, 4, 4],
            isif=3,
            ibrion=2,
            nsw=10,
            atoms=atoms)
bulk_energy = atoms.get_potential_energy()
# atomic system
atoms = Atoms([Atom('Rh',[5, 5, 5], magmom=1)],
              cell=(7, 8, 9))
calc = Vasp('bulk/atomic-rh-sp',
            xc='PBE',
            encut=350,
            kpts=[1, 1, 1],
            ispin=2,
            atoms=atoms)
atomic_energy = atoms.get_potential_energy()
calc.stop_if(None in [atomic_energy, bulk_energy])
cohesive_energy = atomic_energy - bulk_energy
print 'The cohesive energy is {0:1.3f} eV'.format(cohesive_energy)
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-124.py

示例9: Vasp

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from vasp import Vasp
from ase.dft.dos import DOS
import matplotlib.pyplot as plt
# get the geometry from another calculation
calc = Vasp('molecules/simple-co')
atoms = calc.get_atoms()
calc = Vasp('molecules/co-ados',
            encut=300,
            xc='PBE',
            rwigs={'C': 1.0, 'O': 1.0},     # these are the cutoff radii for projected states
            atoms=atoms)
calc.stop_if(calc.potential_energy is None)
# now get results
dos = DOS(calc)
plt.plot(dos.get_energies(), dos.get_dos() + 10)
energies, c_s = calc.get_ados(0, 's')
_, c_p = calc.get_ados(0, 'p')
_, o_s = calc.get_ados(1, 's')
_, o_p = calc.get_ados(1, 'p')
_, c_d = calc.get_ados(0, 'd')
_, o_d = calc.get_ados(1, 'd')
plt.plot(energies, c_s + 6, energies, o_s + 5)
plt.plot(energies, c_p + 4, energies, o_p + 3)
plt.plot(energies, c_d, energies, o_d + 2)
plt.xlabel('Energy - $E_f$ (eV)')
plt.ylabel('DOS')
plt.legend(['DOS',
            'C$_s$', 'O$_s$',
            'C$_p$', 'O$_p$',
            'C$_d$', 'O$_d$'],
           ncol=2, loc='best')
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-35.py

示例10: Vasp

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from vasp import Vasp
from vasp.VaspChargeDensity import VaspChargeDensity
import numpy as np
from ase.units import Debye
import os
calc = Vasp('molecules/co-centered')
atoms = calc.get_atoms()
calc.stop_if(atoms.get_potential_energy() is None)
vcd = VaspChargeDensity('molecules/co-centered/CHG')
cd = np.array(vcd.chg[0])
n0, n1, n2 = cd.shape
s0 = 1.0 / n0
s1 = 1.0 / n1
s2 = 1.0 / n2
X, Y, Z = np.mgrid[0.0:1.0:s0,
                   0.0:1.0:s1,
                   0.0:1.0:s2]
C = np.column_stack([X.ravel(),
                     Y.ravel(),
                     Z.ravel()])
atoms = calc.get_atoms()
uc = atoms.get_cell()
real = np.dot(C, uc)
# now convert arrays back to unitcell shape
x = np.reshape(real[:, 0], (n0, n1, n2))
y = np.reshape(real[:, 1], (n0, n1, n2))
z = np.reshape(real[:, 2], (n0, n1, n2))
nelements = n0 * n1 * n2
voxel_volume = atoms.get_volume() / nelements
total_electron_charge = -cd.sum() * voxel_volume
electron_density_center = np.array([(cd * x).sum(),
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-32.py

示例11: fcc111

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import stop_if [as 别名]
from ase.io import write
atoms = fcc111('Pt', size=(2, 2, 3), vacuum=10.0)
# note this function only works when atoms are created by the surface module.
add_adsorbate(atoms, 'O', height=1.2, position='bridge')
constraint1 = FixAtoms(mask=[atom.symbol != 'O' for atom in atoms])
# fix in xy-direction, free in z. actually, freeze movement in surface
# unit cell, and free along 3rd lattice vector
constraint2 = FixScaled(atoms.get_cell(), 12, [True, True, False])
atoms.set_constraint([constraint1, constraint2])
write('images/Pt-O-bridge-constrained-initial.png', atoms, show_unit_cell=2)
print 'Initial O position: {0}'.format(atoms.positions[-1])
calc = Vasp('surfaces/Pt-slab-O-bridge-xy-constrained',
            xc='PBE',
            kpts=[4, 4, 1],
            encut=350,
            ibrion=2,
            nsw=25,
            atoms=atoms)
e_bridge = atoms.get_potential_energy()
write('images/Pt-O-bridge-constrained-final.png', atoms, show_unit_cell=2)
print 'Final O position  : {0}'.format(atoms.positions[-1])
# now compute Hads
calc = Vasp('surfaces/Pt-slab')
atoms = calc.get_atoms()
e_slab = atoms.get_potential_energy()
calc = Vasp('molecules/O2-sp-triplet-350')
atoms = calc.get_atoms()
e_O2 = atoms.get_potential_energy()
calc.stop_if(None in [e_bridge, e_slab, e_O2])
Hads_bridge = e_bridge - e_slab - 0.5*e_O2
print 'Hads (bridge) = {0:1.3f} eV/O'.format(Hads_bridge)
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-198.py


注:本文中的vasp.Vasp.stop_if方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。