How to Construct a spherical nanoparticles from the large bulk structure using python3

158 Views Asked by At

Problem definition: I wanted to construct spherical nanoparticles of maghemite nanoparticles(gamma Fe2O3) with a radius of 40 angstrom (4nm). I have the lammps data file of large bulk system (replicate :10 10 10, 160000 atoms). I am a beginner in python but I have managed to write a code in python I tried deleting the x,y,z coordinates from the center of all three axis which is not within the radius distance but it is not working, only after looking at the output in VMD i understood i am doing things wrongly but i don't know how to cut a sphere out of a cube please some one help me in this. following is my python code.Thanks in advance.

import pandas as pd
import numpy as np
df = pd.read_csv("data.supercell443.txt",sep='\t',header=None)

optdf = pd.DataFrame([])

IL = 1

xmid = df[4].max()/2
ymid = df[5].max()/2
zmid = df[6].max()/2
xallowed_less = xmid+40
xallowed_more = xmid-40
yallowed_less = ymid+40
yallowed_more = ymid-40
zallowed_more = zmid-40
zallowed_less = zmid+40
for i,j,k,l,x,y,z in df.values:
  if abs(xmid-x) = 40:
    tdf = pd.DataFrame([IL,j,k,l,x,y,z])
    optdf = optdf.append(tdf.T)
  IL+=1

Input image from data file using VMD software Output image of code

1

There are 1 best solutions below

1
On

Is it necessary to do this in Python? This is easily done in LAMMPS itself using the 'group' command or using existing tools such as Atomsk.