Hi Ali,

here is one possible example for an OVITO

batch script that uses a python modifier function to calculate the angle between three specified particles at every simulation frame and saves that information as a global attribute. Finally the time evolution of the angle is saved in a textfile "theta.txt".

I'll leave it up to you to finish the part with the particle indices since I didn't know which of these atoms was supposed to be the central atom.

`from ovito.io import *`

from ovito.modifiers import *

from ovito.data import *

import numpy as np

#User defined modifier funtion to calculate the angle between particles 3493, 1805 and 1813

def compute_theta(frame, input, output):

#Get particle indices from Particle Identifiers

particle_identifiers = input.particles["Particle Identifier"]

central_particle_index = np.where(particle_identifiers == 3493)[0][0]

neighbor_1_index = ...

neighbor_2_index = ...

#Calculate the distance vectors

positions = input.particles['Position']

dist_1 = positions[neighbor_1_index] - positions[central_particle_index]

dist_2 = positions[neighbor_2_index] - positions[central_particle_index]

#Get the angle

cos_theta = np.dot(dist_1,dist_2)/np.linalg.norm(dist_1)/np.linalg.norm(dist_2)

theta = np.arccos(cos_theta)

#Save as global attribute

output.attributes['theta'] = np.degrees(theta)

# Load the simulation dataset to be analyzed.

pipeline = import_file("simulation.dump")

pipeline.modifiers.append(PythonScriptModifier(function = compute_theta))

# Export calculated theta values to a text file and let OVITO's data pipeline do the rest:

export_file(pipeline, "theta.txt", format = "txt", columns = ["Timestep", "theta"], multiple_frames = True)

Let me know if that works for you and if you have questions.

Edit: Also note that I was assuming you're using OVITO3.

-Constanze