Hello everyone! My OVITO version is 2.9.0. I first use “atom strain” and than use “bin and reduce” to get the average value of strain in specific area. In this way I have a strain array in one frame. But I can only save one frame of data. I want to output all frmaes of data in a single dat or txt file. How to write Python script to achieve this? My core question in code is how to define the variable I need? What is the exact form?
For example, I try to define timestep in the MSD example like below:
import numpy
def modify(frame, input, output):
# Access the per-particle displacement magnitudes computed by an existing
# Displacement Vectors modifier that precedes this custom modifier in the
# data pipeline:
displacement_magnitudes = input.particle_properties.displacement_magnitude.array
# Compute MSD:
msd = numpy.sum(displacement_magnitudes ** 2) / len(displacement_magnitudes)
step = input.particle_properties.timestep.array
# Output MSD value as a global attribute:
output.attributes["MSD"] = msd
current_frame = input.attributes['SourceFrame']
print("In frame {}, the vaule of MSD is {}".format(current_frame, msd))
with open('E:\MD simulation of interfacial friction (20221229-)\modified Morse potential model\ForceRateLoading\Rc122E0001\Rate1e-9\MSD.dat','a+') as f:
f.write("{} {}\n".format(timestep, msd))
The error is:
The Python script has exited with an error.
Traceback (most recent call last):
File "<string>", line 13, in modify
File "D:\Ovito2.9.0\plugins\python\ovito\data\particles\__init__.py", line 82, in __getattr__
raise AttributeError("DataCollection does not contain the particle property '%s'." % name)
AttributeError: DataCollection does not contain the particle property 'timestep'.
Generally speaking, I do not know how to get the right form of defining timestep in Python script. Where can I get relevant information? I did not find the detailed description in OVITO’s manual.
Any help will be appreciated and thanks advance!