Author Topic: Using ovitos to delete atoms  (Read 82 times)

sushmit

  • Newbie
  • *
  • Posts: 3
Using ovitos to delete atoms
« on: November 08, 2017, 01:42:47 AM »
Hello fellow ovito users,

I was wondering if you would help me find a way to delete atoms using ovitos. The requirement is to load a POSCAR file, and delete all atoms with Z position greater than a fixed value.

Appreciate the help.

Alexander Stukowski

  • Administrator
  • Full Member
  • *****
  • Posts: 221
Re: Using ovitos to delete atoms
« Reply #1 on: November 08, 2017, 07:47:36 AM »
Hi,

There are various ways of doing this with OVITO. But the easiest is probably the one based on the Slice modifier.

After loading your POSCAR file in OVITO, add the Slice modifier to the processing pipeline. Set its normal vector to (0,0,1). (Shortcut: click the "Normal (Z)" label). Then adjust the modifier's distance parameter to the z-coordinate above which you want to delete all atoms.

An alternative approach would be to use the Expression Select modifier to select some atoms based on a user-defined criterion, e.g. "Position.Z>25". After that, you insert an instance of the Delete Selected Particles modifier to remove the selected atoms.   

-Alex

sushmit

  • Newbie
  • *
  • Posts: 3
Re: Using ovitos to delete atoms
« Reply #2 on: November 08, 2017, 01:57:17 PM »
Thank you so much Alex, could you help me convert the command to the ovitos scripting interface? I need to delete the top 8 atoms for ~1000 structures and was planning to automate it using ovito.


Thanks.

Alexander Stukowski

  • Administrator
  • Full Member
  • *****
  • Posts: 221
Re: Using ovitos to delete atoms
« Reply #3 on: November 08, 2017, 04:45:03 PM »
I'm sorry, I didn't see that you were referring to "ovitos". That means you would like to use the scripting interface of OVITO to automate the task.

My first draft for an ovitos script would look like this:

Code: [Select]
from ovito.io import import_file, export_file
from ovito.modifiers import SliceModifier

pipeline = import_file("input.poscar")
pipeline.modifiers.append(SliceModifier(normal=(0,0,1), distance=123.45))
export_file(pipeline, "output.poscar", format="vasp")

Of course, this script can be refined further. For example, to batch process a sequence of files in a directory, one could change this to:

Code: [Select]
pipeline = import_file("input.*.poscar")
pipeline.modifiers.append(SliceModifier(normal=(0,0,1), distance=123.45))
export_file(pipeline, "output.*.poscar", format="vasp", multiple_frames=True)

sushmit

  • Newbie
  • *
  • Posts: 3
Re: Using ovitos to delete atoms
« Reply #4 on: November 08, 2017, 07:40:02 PM »
This is great! thank you so much for the help!