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

Ratio between first max. and first min. of g[r] vs time from Coordination analysis

Hello Constanze,

I’m trying to calculate the ratio between first max. and the first min. value of g[r] .
I did a coordination analysis(for calculating RDF) and then using a python script modifier implemented max() and min() function.
But the problem with this is, it’s not finding the 1st max. and 1min. value. For min. it takes 0. Also if there is two-particle type in the system then it can not take value for rdf.y and return nan.

So, is there any possible way to do it in Ovito by using python modifier.

I tried something like this:

from import *
import numpy as np
def modify(frame, data, output):
    rdf = data.tables[‘coordination-rdf’]
    rdf_max = np.max(rdf.y)
    rdf_min = np.min(rdf.y)
    rdf_ratio = (rdf_min/rdf_max)





Uploaded files:

Hi Prashant,

yes, that is the expected behavior of the numpy.max() and numpy.min() functions, please refer to the numpy documentation

There are a lot of different ways of finding local maxima or minima in a 1-d numpy array with python, see e.g.

Concerning the shape of rdf.y: Please note that when you activate the option "Compute partial RDFs", data.tables[‘coordination-rdf’].y will be a numpy array of shape (n, X), where n is the number of bins and X is the number of possible particle type pair-combinations. If your system consists of 2 particle types, you will thus get three columns, i.e. 1-1, 1-2 and 2-2, and you can access them like this:




Thank you, Constanze.

It works.

Have a nice day.