Forum Navigation
You need to log in to create posts and topics.

Viewing x, y, and z ranges of particles

I'm trying to find the x, y, and z ranges of particles in OVITO. The best way I've been able to do this so far is by creating three histograms (for Position.X, Position.Y, and Position.Z), finding the max/min values, and then calculating the ranges. However, it's a bit time-consuming to do this. I thought the "Compute Property" modifier would help, but I can't find a way to calculate a max or min property from there. Is there a different modifier that I could use to calculate these ranges automatically?

No, there is no built-in modifier or function that would allow you to do this specific calculation. But computing the bounding box with a simple Python modifier function is straightforward:

import numpy

def modify(frame, data):
    coords_min = numpy.amin(data.particles.positions, axis=0)
    coords_max = numpy.amax(data.particles.positions, axis=0)
    print("Min:", coords_min)
    print("Max:", coords_max)

    data.attributes['min_x'], data.attributes['min_y'], data.attributes['min_z'] = coords_min
    data.attributes['max_x'], data.attributes['max_y'], data.attributes['max_z'] = coords_max

The function prints the minimum and maximum coordinates to the log window and also outputs them as global attributes to the data pipeline, making them available for file export or visualization/inspection.

(My initial statement is not the entire truth. In fact, the Spatial Binning modifier provides the MIN and MAX reduction operations and may be used to compute the value range of the 'Position' particle property by using a single bin. But that's a hack I cannot really recommend.)

Thanks a lot for the information! This is super cool. I also tried writing a script using the gsd python package for this specifically because I wanted some other information about the system. Your method is also great! Thank you.