OVITO Forum

OVITO => Frequently Asked Questions (FAQ) => Topic started by: Alexander Stukowski on November 28, 2016, 09:05:59 AM

Title: How can I determine the minimum/maximum of a particle property?
Post by: Alexander Stukowski on November 28, 2016, 09:05:59 AM
Let's suppose you would like to determine the global maximum of a particle property for every frame of a simulation and export this information to a text file. This can be done by inserting a Python Script modifier (http://www.ovito.org/manual/particles.modifiers.python_script.html) into the data pipeline. The following modifier script computes the maximum (https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.max.html) of the Potential Energy particle property and injects the value as a new global attribute (http://www.ovito.org/manual/python/modules/ovito_data.html#ovito.data.DataCollection.attributes) into the data pipeline:

Code: [Select]
def modify(frame, input, output):
    max_energy = input.particle_properties['Potential Energy'].array.max()
    output.attributes['Maximum Energy'] = float(max_energy)

You can now use OVITO's standard file export function (http://www.ovito.org/manual/usage.export.html) to generate a table of the Maximum Energy attribute and write it to a text file. Select Calculation Results Text File as output file format.