Author Topic: Voronoi volume calculation not working via python scripts?  (Read 1663 times)

alexcr

  • Newbie
  • *
  • Posts: 11
Voronoi volume calculation not working via python scripts?
« on: June 06, 2017, 08:25:56 PM »
Hi,

I just tried to compute the voronoi volumes for an amorphous material via this code :

Code: [Select]
# specify particles volumes                                                                                                                                                                                                                   
atypes = node.source.particle_properties.particle_type.type_list
atypes[0].radius = 0.5
atypes[1].radius = 0.3

# set up the Voronoi analysis modifier.                                                                                                                                                                                                       
voro = ovito.modifiers.VoronoiAnalysisModifier(use_radii=True)
node.modifiers.append(voro)

# compute the voronoi atomic volume                                                                                                                                                                                                           
node.compute()
voro_volumes = node.output.particle_properties['Atomic Volume'].array

However the resulting vector I get (voro_volumes) is zero everywhere. I tried it on a couple different files I have, same result every time. I also tried to calculate the Voronoi Indices with the first code on your Examples page, but I still get zero everywhere.

Could this be a bug, or am I overlooking something? Unfortunately I can't include the files I use because attachments are limited to 128 KB.

Alex

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Voronoi volume calculation not working via python scripts?
« Reply #1 on: June 06, 2017, 10:05:47 PM »
Hi Alex,

I couldn't spot any problem in your code. I suggest you use the -g command line option when running this script with ovitos. This will start up the graphical program version while executing your script and your can check if everything was performed as intended and inspect the computation results. Note that you have to add a line 'node.add_to_scene()' to your script to make this work. Ovito's particle inspection utility will allow you to check the assigned 'Atomic Volume' values of individual particles.

-Alex

alexcr

  • Newbie
  • *
  • Posts: 11
Re: Voronoi volume calculation not working via python scripts?
« Reply #2 on: June 06, 2017, 11:04:49 PM »
Oh I see now : the problem seems to be related to my box being 2-dimensional. The Voronoi computation seems to ignore the parameter "Simulation cell dimensionality" : if I select 3D and modify the box's height, I get non-zero Voronoi volumes, but if I select 2D dimensionality it keeps the same value in memory for the box's height (thus zero volumes). Can't Ovito compute 2D Voronoi diagrams?

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Voronoi volume calculation not working via python scripts?
« Reply #3 on: June 07, 2017, 09:13:51 AM »
Ovito internally uses the Voro++ library to compute the Voronoi tessellation. This library only supports 3d tessellation, not 2d.
Note that it should still work if the input cell is 3d, has a finite height, and all points are positioned on the same plane. Of course, you will have to divide the computed atomic volumes by the cell height to get the 2d Voronoi cell areas.

Apparently, Ovito doesn't produce a helpful message. I have created an issue in our issue tracking system here with the aim to improve the situation in the future:

https://gitlab.com/stuko/ovito/issues/26

alexcr

  • Newbie
  • *
  • Posts: 11
Re: Voronoi volume calculation not working via python scripts?
« Reply #4 on: June 07, 2017, 12:22:49 PM »
Excellent, I'll go that way then. Thanks again for your helpful answer.

Alex