I want to modify a supercell structure. In this case, I want to remove a list of atoms by index. For example, I want to remove [1,4,8,12,56,45] indexes. how can I do that? Or do you know any other software that can do that?
In Materials Studio, removing a specific list of atoms by index isn't straightforward through the GUI, but you can do it using Python scripting @MaterialsScript API. Here's how you can remove a list of atoms;
Python Script for Materials Studio
from MaterialsScript import *
# Open the document (Assume your file is 'xyz.xsd'
doc = Documents.Open('your_file.xsd')
# Define the list of atom indexes to remove (1-based index)
atom_indices = [1, 4, 8, 12, 56, 45]
# Convert to 0-based index for scripting
atom_indices = [i-1 for i in atom_indices]
# Sort in descending order to avoid index shifts' issues
atom_indices.sort(reverse=True)
# Remove the atoms
for index in atom_indices:
doc.DeleteAtom(doc.Atoms[index])
# Save it
doc.SaveAs('modified_structure.xsd')
To Run the Script:
>Open Materials Studio.
>>Go2 Scripting > Python Script Editor.
>>>Paste the script above.
>>>>Replace 'xyz.xsd' with your actual structure filename.
>>>>> Run the script, and it will remove the specified atoms.
In LAMMPS atoms cannot be deleted by index directly, but you can achieve this by using the delete_atoms command in combination with groups. The process involves creating a data file where the unwanted atoms are marked and then removed.
Assume you have a LAMMPS data file (cell.data) structured as:
Atoms
1 1 0 0 0
2 1 1 0 0
3 1 0 1 0
4 1 1 1 0
etc...
Each line represents an atom with an ID, atom type and coordinates.
Define a group of atoms to remove in LAMMPS input
Create a LAMMPS input script with the following commands:
units metal
dimension 3
boundary p p p
atom_style atomic
read_data supercell.data # Load the geometric structure