尝试使用ase运行aMD模拟,继续得到错误值错误:形状(0,)和(3,3)未对齐:0(尺寸0)!=3(尺寸0)

2024-10-01 07:19:10 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的python代码。我必须为我的星团使用嵌入原子势。我导入的结构是由1013个原子组成的双金属纳米团簇。我需要在3000 K的固定温度下运行MD。模拟从0开始,跳到53573K,然后跳到50656K,然后给出错误消息。在

from ase.md.langevin import Langevin

from ase.io.trajectory import Trajectory

from ase import units

import numpy as np

from ase import Atoms

from ase.calculators.eam import EAM

from ase.io import write, read

# Kelvin (Set up the temperature)

T = 3000 

#Import the global minimum structure 

fName= 'globalminstr.xyz'

#Interatomic Potential

atoms = read(fName)
calc= EAM(potential='Zope-Ti-Al-2003.eam.alloy')
atoms.set_calculator(calc)

#Langevin dynamics

dyn = Langevin(atoms, 5 * units.fs, T * units.kB, 0.002)

def printenergy(a=atoms):  # store a reference to atoms in the definition.
"""Function to print the potential, kinetic and total energy."""
epot = a.get_potential_energy() / len(a)
ekin = a.get_kinetic_energy() / len(a)
print('Energy per atom: Epot = %.3feV  Ekin = %.3feV (T=%3.0fK)  '
'Etot = %.3feV' % (epot, ekin, ekin / (1.5 * units.kB), epot +   ekin))

dyn.attach(printenergy, interval=50)

# Saving the positions of all atoms after every 100th time step.
traj = Trajectory('moldyn.traj', 'w', atoms)
dyn.attach(traj.write, interval=50)

# Running dynamics
printenergy()
dyn.run(5000)

Tags: thefromimportenergypotentialunitsase原子