2023-03-04 区分纳米颗粒核壳原子
声明:未经允许,不得擅自复制、转载。
欢迎引用:
Laser-Assisted Synthesis of Bi-Decorated Pt Aerogel for Efficient Methanol Oxidation Electrocatalysis
Applied Surface Science ( IF 6.707 ) Pub Date : 2022-04-01 , DOI: 10.1016/j.apsusc.2022.153219
Liye Zhu, Ran Zhang, Xuan Liu, Jiayin Zhu, Ziang Guo, Yan Zhao
Click Here!
利用MS构建纳米颗粒R,指定壳厚,可将核原子的坐标和壳原子坐标区分开来。
# /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Author: Liye Zhu
"""from tkinter.filedialog import askopenfilename
import matplotlib.pyplot as plt
from scipy import interpolate
import numpy as npclass xyzReading:def readxyz(self):path_and_name = askopenfilename(title='Select xyz data: ', filetypes=[('TXT', '*.txt')],initialdir='C:\\\\Users\\\\Mr. Zhu\\\\Desktop')x = []y = []z = []with open(path_and_name, 'r') as TXTFile:line = TXTFile.readlines()first_data_line = 9constant = float(line[4].split(' ')[3].lstrip(' '))constant = int(constant)print(constant)# constant = 100for index, row in enumerate(line):if index in range(first_data_line, len(line)):row = row.lstrip(' ')row = row.rstrip('\\n')xyz = row.split(' ', 2)xyz = np.array(xyz)xp = float(xyz[0])*constantyp = float(xyz[1])*constantzp = float(xyz[2])*constantx.append(xp)y.append(yp)z.append(zp)x = np.array(x)y = np.array(y)z = np.array(z)return x, y, z, path_and_namefile_output = path_and_name[0:path_and_name.rfind('.', 1) + 1] + 'dat'np.savetxt(file_output, [x, y, z])class xyzProcessing:def __init__(self, x0, y0, z0, path_and_name):self.x0 = x0self.y0 = y0self.z0 = z0self.path_and_name = path_and_namedef findshell(self):xc = (max(self.x0) + min(self.x0)) / 2yc = (max(self.y0) + min(self.y0)) / 2zc = (max(self.z0) + min(self.z0)) / 2r = (max(self.x0) - min(self.x0)) / 2print('xc, yc, zc and radius (脜): ')print(xc, yc, zc, r)thickness = 1num = len(self.x0)Xc = xc*np.ones(num)Yc = yc * np.ones(num)Zc = zc * np.ones(num)dsqure = (self.x0-Xc)2+(self.y0-Yc)2 + (self.z0-Zc)2Xout = self.x0[dsqure > (r-thickness)2]Yout = self.y0[dsqure > (r-thickness)2]Zout = self.z0[dsqure > (r-thickness)2]Xin = self.x0[dsqure < (r - thickness) 2]Yin = self.y0[dsqure < (r - thickness) 2]Zin = self.z0[dsqure < (r - thickness) 2]# Xout = Xout.T# Yout = Yout.T# Zout = Zout.T# Xin = Xin.T# Yin = Yin.T# Zin = Zin.Toutpath = path_and_name[0:path_and_name.rfind('/', 1)]+'/out.dat'inpath = path_and_name[0:path_and_name.rfind('/', 1)]+'/in.dat'np.savetxt(outpath, [Xout, Yout, Zout])np.savetxt(inpath, [Xin, Yin, Zin])print(len(Xout))xyzRead = xyzReading()
[x, y, z, path_and_name] = xyzRead.readxyz()
XYZProcess = xyzProcessing(x, y, z, path_and_name)XYZProcess.findshell()# thickness = input('Please Input a shell thickness: ')