5
$\begingroup$

Basically, I am trying to get the running coordination number (CN), but the result isn't correct? I am multiplying the Radial Distribution Function (RDF) with 4*np.pi*x*x*Number_of_Atoms/(A*B*C) .

from ovito.io import import_file
from ovito.modifiers import CoordinationAnalysisModifier

cutoff=12.0 
number_of_bins=200

# Load input data.
pipeline = import_file("./traj/BEC/ge7/run10/local_minima.xyz")

# Print the list of input particle types.
# They are represented by ParticleType objects attached to the 'Particle Type' particle property.
for t in pipeline.compute().particles.particle_types.types:
    print("Type %i: %s" % (t.id, t.name))

# Calculate partial RDFs:
pipeline.modifiers.append(CoordinationAnalysisModifier(cutoff=12.0, number_of_bins=200, partial=True))

# Access the output DataTable:
rdf_table = pipeline.compute().tables['coordination-rdf']

# The y-property of the data points of the DataTable is now a vectorial property.
# Each vector component represents one partial RDF.
rdf_names = rdf_table.y.component_names

# The DataTable.xy() method yields everthing as one combined NumPy table.
# This includes the 'r' values in the first array column, followed by the
# tabulated g(r) partial functions in the remaining columns. 

dr = cutoff/number_of_bins
x = [x for x in np.arange(0, int(cutoff), dr)]

A = 12.6
B = 12.6
C = 13.3

rdf_gege_lst = []

for i in rdf_table.y[:,4]:
    rdf_gege_lst.append(i)  

cn_GeGe_final = []

cn_GeGe = (np.array(rdf_gege_lst) * 4 * np.pi * x * x * 10) / (A * B * C) 

for i in range(len(x)):
    result_GeGe = integrate.simps(cn_GeGe[:i + 1],x[:i+ 1])
    cn_GeGe_final.append(result_GeGe)

plt.plot(x, rdf_gege_lst, 'g', label = "Ge-Ge")
plt.plot(x, cn_GeGe_final, 'b', label = "Ge-Ge")
$\endgroup$
3
  • $\begingroup$ +1 for a nice question, for formatting it nicely, and for asking what seems to be our first OVITO question! But can you please explain what you meant by "but the result isn't correct?"? $\endgroup$ Dec 15, 2021 at 7:50
  • $\begingroup$ Agreed on the clarification request. For example, the plotting output could be pretty useful to see. As a way of debugging, consider multiplying your cn_GeGe by dr, then using np.cumsum() on it instead of the for-loop, and plotting that. This in essence does the radial integration as a discrete series. $\endgroup$ Jan 14, 2022 at 7:59
  • $\begingroup$ This question appears to be abandoned. It can be reopened if OP addresses questions/suggestions in the comments or if someone would like to provide an answer. $\endgroup$
    – Tyberius
    Jan 20, 2022 at 23:46

0