本文整理汇总了Python中ase.calculators.vasp.Vasp.read_stress方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.read_stress方法的具体用法?Python Vasp.read_stress怎么用?Python Vasp.read_stress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ase.calculators.vasp.Vasp
的用法示例。
在下文中一共展示了Vasp.read_stress方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_energy_eval
# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import read_stress [as 别名]
def run_energy_eval(totalsol, calc_method='LAMMPS', fx_region=False, fit_scheme='totalenfit', STR='', static_calc=None):
if calc_method=='VASP':
en=totalsol.get_potential_energy()
calcb=Vasp(restart=True)
totalsol=calcb.get_atoms()
stress=calcb.read_stress()
else:
totcop = totalsol.copy()
OUT = totalsol.calc.calculate(totalsol)
totalsol = OUT['atoms']
totalsol.set_pbc(True)
if fx_region:
STR+='Energy of fixed region calc = {0}\n'.format(OUT['thermo'][-1]['pe'])
totalsol.set_calculator(static_calc)
OUT=totalsol.calc.calculate(totalsol)
totalsol=OUT['atoms']
totalsol.set_pbc(True)
STR+='Energy of static calc = {0}\n'.format(OUT['thermo'][-1]['pe'])
en=OUT['thermo'][-1]['pe']
stress=numpy.array([OUT['thermo'][-1][i] for i in ('pxx','pyy','pzz','pyz','pxz','pxy')])*(-1e-4*GPa)
if fit_scheme == 'enthalpyfit':
pressure = totalsol.get_isotropic_pressure(stress)
else:
pressure = 0
volume = totalsol.get_volume()
energy=en
STR+='Energy per atom = {0}\n'.format(energy/len(totalsol))
return totalsol, energy, pressure, volume, STR
示例2: ase_vol_relax
# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import read_stress [as 别名]
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
示例3: ase_vol_relax
# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import read_stress [as 别名]
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
示例4: vasp_vol_relax
# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import read_stress [as 别名]
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
示例5: vasp_vol_relax
# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import read_stress [as 别名]
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
示例6: eval_energy
# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import read_stress [as 别名]
#.........这里部分代码省略.........
cell=cell_max-cell_min
volume=cell[0]*cell[1]*cell[2]
else:
pressure=0
volume=0
na=totalsol.get_number_of_atoms()
ena=en/na
energy=en
individ[0]=totalsol[0:nat]
bul=totalsol[(nat):len(totalsol)]
STR+='Number of positions = '+repr(len(bul)+len(individ[0]))+'\n'
individ[0].set_cell(csize)
indiv=individ[0]
else:
en=indiv.get_potential_energy()
if Optimizer.fitness_scheme == 'enthalpyfit':
pressure=indiv.get_isotropic_pressure(indiv.get_stress())
cell_max=numpy.maximum.reduce(indiv.get_positions())
cell_min=numpy.minimum.reduce(indiv.get_positions())
cell=cell_max-cell_min
volume=cell[0]*cell[1]*cell[2]
else:
pressure=0
volume=0
na=indiv.get_number_of_atoms()
ena=en/na
energy=ena
individ[0]=indiv
bul=0
else:
if Optimizer.structure=='Defect' or Optimizer.structure=='Surface':
if Optimizer.calc_method=='VASP':
en=totalsol.get_potential_energy()
calcb=Vasp(restart=True)
totalsol=calcb.get_atoms()
stress=calcb.read_stress()
else:
try:
totcop=totalsol.copy()
if debug: write_xyz(Optimizer.debugfile,totcop,'Individual sent to lammps')
OUT=totalsol.calc.calculate(totalsol)
totalsol=OUT['atoms']
totalsol.set_pbc(True)
if Optimizer.fixed_region:
if debug:
print 'Energy of fixed region calc = ', OUT['thermo'][-1]['pe']
totalsol.set_calculator(Optimizer.static_calc)
OUT=totalsol.calc.calculate(totalsol)
totalsol=OUT['atoms']
totalsol.set_pbc(True)
if debug:
print 'Energy of static calc = ', OUT['thermo'][-1]['pe']
en=OUT['thermo'][-1]['pe']
stress=numpy.array([OUT['thermo'][-1][i] for i in ('pxx','pyy','pzz','pyz','pxz','pxy')])*(-1e-4*GPa)
#force=numpy.maximum.reduce(abs(totalsol.get_forces()))
if debug:
write_xyz(Optimizer.debugfile,totalsol,'After Lammps Minimization')
Optimizer.debugfile.flush()
except Exception, e:
os.chdir(cwd)
STR+='WARNING: Exception during energy eval:\n'+repr(e)+'\n'
f=open('problem-structures.xyz','a')
write_xyz(f,totcop,data='Starting structure hindex='+individ.history_index)
write_xyz(f,totalsol,data='Lammps Min structure')
en=10
stress=0
f.close()
if Optimizer.fitness_scheme == 'enthalpyfit':
pressure=totalsol.get_isotropic_pressure(stress)
cell_max=numpy.maximum.reduce(totalsol.get_positions())
cell_min=numpy.minimum.reduce(totalsol.get_positions())
cell=cell_max-cell_min
volume=cell[0]*cell[1]*cell[2]
else:
pressure=totalsol.get_isotropic_pressure(stress)
volume=0
na=totalsol.get_number_of_atoms()
ena=en/na
energy=en
if Optimizer.structure=='Defect':
if Optimizer.fixed_region==True or Optimizer.finddefects==False:
individ[0]=totalsol[0:nat]
bul=totalsol[(nat):len(totalsol)]
individ[0].set_cell(csize)
else:
if 'FI' in Optimizer.debug:
outt=find_defects(totalsol,Optimizer.solidbulk,Optimizer.sf,atomlistcheck=Optimizer.atomlist,trackvacs=Optimizer.trackvacs,trackswaps=Optimizer.trackswaps,debug=Optimizer.debugfile)
else:
outt=find_defects(totalsol,Optimizer.solidbulk,Optimizer.sf,atomlistcheck=Optimizer.atomlist,trackvacs=Optimizer.trackvacs,trackswaps=Optimizer.trackswaps,debug=False)
individ[0]=outt[0]
bul=outt[1]
individ.vacancies = outt[2]
individ.swaps = outt[3]
STR += outt[4]
indiv=individ[0]
else:
top,bul=find_top_layer(totalsol,Optimizer.surftopthick)
indiv=top.copy()
individ[0]=top.copy()
else:
示例7: in
# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import read_stress [as 别名]
individ[0]=outt[0]
bul=outt[1]
individ.vacancies = outt[2]
individ.swaps = outt[3]
STR += outt[4]
indiv=individ[0]
else:
top,bul=find_top_layer(totalsol,Optimizer.surftopthick)
indiv=top.copy()
individ[0]=top.copy()
else:
if Optimizer.calc_method=='VASP':
en=totalsol.get_potential_energy()
calcb=Vasp(restart=True)
totalsol=calcb.get_atoms()
stress=calcb.read_stress()
else:
OUT=indiv.calc.calculate(indiv)
en=OUT['thermo'][-1]['pe']
#indiv.set_positions(OUT['atoms'].get_positions())
#indiv.set_cell(OUT['atoms'].get_cell())
indiv=OUT['atoms']
indiv.set_pbc(True)
stress=numpy.array([OUT['thermo'][-1][i] for i in ('pxx','pyy','pzz','pyz','pxz','pxy')])*(-1e-4*GPa)
if Optimizer.fitness_scheme == 'enthalpyfit':
pressure=indiv.get_isotropic_pressure(stress)
cell_max=numpy.maximum.reduce(indiv.get_positions())
cell_min=numpy.minimum.reduce(indiv.get_positions())
cell=cell_max-cell_min
volume=cell[0]*cell[1]*cell[2]
else: