I have the following variables:
nframe: int # the number of frames
force: numpy.ndarray # shape: (nframe,231,3)
coord: numpy.ndarray # shape: (nframe,231,3)
box: numpy.ndarray # shape: (nframe,9)
energy: numpy.ndarray # shape: (nframe,)
chemical_symbol: str # "C60O57H114"
Now I want to use the above information to construct “atom” objects iteratively and then write them to a traj format file. Here is the code:
for idx in range(nframe):
curr_atoms = Atoms(
positions = coord[idx],
cell = box[idx].reshape(3,3),
symbols = chemical_symbol,
pbc= True
)
calculator = SinglePointCalculator(curr_atoms,energy=ener[idx],forces=force[idx])
curr_atoms.calc = calculator
write("test.traj",curr_atoms,format="traj",append=True)
Although I can get the “test.traj” file, I can’t read it correctly using the code below:
data = read("test.traj",index=":",format="traj")
len(data) # equal 0
I don’t understand why that is, and I want to know how to write multiple Atoms objects to a traj format file. Looking forward to your help!