使用ase库小例子

可视化 氮气分子能量 和 氮原子受力大小 与 两氮原子间距离的关系

from ase import Atoms  #导入相应的包
from ase.calculators.emt import EMT
import matplotlib.pyplot as plt


#构建氮气分子并初始化相应参数
atoms = Atoms('N2', positions=[[0, 0, -1], [0, 0, 1]])
atoms.calc = EMT()
step = 0.05
nsteps = int(3 / step)
distance = []
energy = []
force = []
#进入循环,计算每步的能量和氮原子受力
for i in range(nsteps):
    d = 0.5 + i * step
    atoms.positions[1, 2] = atoms.positions[0, 2] + d
    e = atoms.get_potential_energy()
    f = atoms.get_forces()
    f = f[0, 2]
    distance.append(d)
    energy.append(e)
    force.append(f)
#绘图
fig = plt.figure()
plt.plot(distance, energy)
plt.plot(distance, force)
plt.show()


结果如下:

横坐标是距离,单位是埃
纵坐标蓝线是能量,单位是ev
纵坐标黄线是受力,负值为排斥力
可见,氮原子在相差1埃的时候能量最低,体系最稳定。

本代码参照ASE官方文档的例子,做小修改。
ase官方文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值