Author Topic: Property summation and periodic boundary conditions  (Read 89 times)

emy|jer

  • Newbie
  • *
  • Posts: 2
Property summation and periodic boundary conditions
« on: November 10, 2017, 03:40:04 PM »
Hello,

First of all, thanks to OVITO's developers for this great software !

I am working on a vitreous system simulated by Molecular Dynamics. Simulation box dimensions are CellSize.X = 150 Å, CellSize.Y = 50 Å, CellSize.Z = 150 Å.

I would like to determine some properties relating to clusters defined by the Cluster analysis modifier. To determine such quantity,  I select all atoms of a given cluster and I used the including Neighbor particles  option of the compute property modifier to sum over all selected atoms the quantity of interest.

Without boundary conditions, this way of computing works perfectly. But obviously, clusters are truncated.

A problem arise when activating the boundary conditions (in the Simulation Cell objet of the input section). Since the simulation box is non-cubic, cutoff value of the compute property modifier has undesired effects on the evaluated quantities.

In one hand, I have to set the cutoff value to CellSize.X/2 (or CellSize.Z/2) in order to include once all selected particles (or their periodic images) in X and Z directions. But in the other hand, this cutoff value include in Y direction all selected particles (or their periodic images) more than once.

I tried to use if-else conditions operating on ParticleIdentifier or ParticleIndex parameters but without success.

An impractical solution is to apply, with bin and reduce modifier, a sum operation on selected particles within a unique spatial bin (ie the simulation box).

Does other computation way exist to evaluate property summation with periodic boundary conditions ?

Thanks and best regards,

Jeremy

Alexander Stukowski

  • Administrator
  • Full Member
  • *****
  • Posts: 221
Re: Property summation and periodic boundary conditions
« Reply #1 on: November 11, 2017, 08:13:53 PM »
Hi Jeremy,

The Compute Property modifier is probably not the right tool to compute an aggregate value from a set of atoms. If I understand you correctly, you used the Include Neighbour Terms option and a cutoff range that is large enough to include the entire atom cluster. Then all atoms in the cluster are visited during the computation and you can sum up their property values at one or all atoms of the cluster. However, if your system is periodic, additional images of the same cluster may reach into the cutoff range and you get additional, undesired contributions.

A better solution is to use a simple Python Script modifier to do the reduction computation. Let's say you want to compute the sum of the 'Potential Energy' property of all currently selected atoms. The following script function does that for you:

Code: [Select]
import numpy as np

def modify(frame, input, output):
energies = input.particle_properties['Potential Energy'].array
selection = input.particle_properties['Selection'].array
output.attributes['energy_sum'] = np.sum(energies[selection != 0])

The computed total value is output as a global attribute by the script. You can access the value in various ways, for example export it to a text file using OVITO's file export function or display it in the viewports using the Text Label Overlay.

You could extend the script further and let it compute the aggregate values for each cluster simultaneously (not just the currently selected one) and write the per-cluster values directly to an output file.

-Alex

emy|jer

  • Newbie
  • *
  • Posts: 2
Re: Property summation and periodic boundary conditions
« Reply #2 on: November 13, 2017, 05:04:54 PM »
It works!

Thank you very much for your response and your help.

Have a good day.