char elem[3];
for (i=0; i<nat; i++)
{
fscanf(infile,"%s%f%f%f",&elem,&x,&y,&z);
dd=(x-x0)*(x-x0)+(y-y0)*(y-y0)+(z-z0)*(z-z0);
dis=sqrt(dd);
if ((dis < max)&&(dis > min))
{
fprintf(outfile,"%s%12.6f%12.6f%12.6f\n",elem,x,y,z);
}
}
fclose(infile);
fclose(outfile);
}
' > cal.c
gcc cal.c -o getAtom -lm
# select the atoms in the given range
echo '# + Collecting the atoms in the ball range, please wait'
echo '# - The center of sphere : ('$center_X', '$center_Y', '$center_Z') '
echo '# - The R ranging from '$Rmin' to '$Rmax', in Angstrom '
./getAtom coor.tmp ball.tmp $center_X $center_Y $center_Z $Rmin $Rmax $natom
建立纳米球模型,我一般采用如下方法,以Cu纳米球为例:
1. MS中导入Cu晶体结构(import-->structures-->metal-->pure metal-->Cu.msi )。
2. 根据自己需要的尺寸大小,建立超晶胞。(build-->symmetry-->supercell-->设置ABC三个方向的超晶胞数目)
3. 将建好的超晶胞导出成*.PDB格式,然后用程序处理(在linux环境下测试可用),可得到需要的Cu纳米球结构。(*.xyz格式,MS可识别)
附:处理程序(使用前先修改程序的第10-15行,指定球的球心坐标和R半径范围,Rmin=最小半径,Rmax=最大半径。实心球则指定Rmin=0。)
#!/bin/bash
#
# Script to generate ball like structre
# Coded by Han Bo: hanbo39200900@gmail.com
# Usage: ballgen.sh inputfile.pdb output.xyz
# initial parameters
# define the center of the ball
center_X=20.2475
center_Y=20.2475
center_Z=20.2475
# define the R range
Rmin=16
Rmax=20
###########################################################
echo ""
echo '############################################################'
echo '## Script to generate ball like structre ##'
echo '## Coded by Han Bo: hanbo39200900@gmail.com ##'
echo '############################################################'
echo "#"
echo '#Usage: ballgen.sh inputfile.pdb output.xyz'
echo "#"
echo "# * * * * * * * * * * * * * * * * * * * * * * * * * * *"
echo "# * please edit the line 10-15 of the code before using *"
echo "# * * * * * * * * * * * * * * * * * * * * * * * * * * *"
echo "#"
############################################################
# pretreatment
echo '# + Formating the input file'
grep ATOM $1 | awk '{print $11, $6, $7, $8}' > coor.tmp
# calculate the number of atoms in the input file
natom=`grep ATOM $1 | wc -l`
echo '# + I found '$natom' atoms in the input file'
# c code for distance calculation.
echo '# + Preparing C code for distance calculation'
echo '
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv)
{
FILE *infile, *outfile;
infile=fopen(argv[1],"r");
outfile=fopen(argv[2],"w+");
float x0, y0, z0, x, y, z;
float min, max, dd, dis;
int i, nat;
x0=atof(argv[3]);
y0=atof(argv[4]);
z0=atof(argv[5]);
min=atof(argv[6]);
max=atof(argv[7]);
nat=(int)(atof(argv[8]));
char elem[3];
for (i=0; i<nat; i++)
{
fscanf(infile,"%s%f%f%f",&elem,&x,&y,&z);
dd=(x-x0)*(x-x0)+(y-y0)*(y-y0)+(z-z0)*(z-z0);
dis=sqrt(dd);
if ((dis < max)&&(dis > min))
{
fprintf(outfile,"%s%12.6f%12.6f%12.6f\n",elem,x,y,z);
}
}
fclose(infile);
fclose(outfile);
}
' > cal.c
gcc cal.c -o getAtom -lm
# select the atoms in the given range
echo '# + Collecting the atoms in the ball range, please wait'
echo '# - The center of sphere : ('$center_X', '$center_Y', '$center_Z') '
echo '# - The R ranging from '$Rmin' to '$Rmax', in Angstrom '
./getAtom coor.tmp ball.tmp $center_X $center_Y $center_Z $Rmin $Rmax $natom
nball=`cat ball.tmp | wc -l`
echo '# - '$nball' atoms collected'
# combine the files to *.xyz format
echo " $nball" > ball2.tmp
echo "" >> ball2.tmp
cat ball2.tmp ball.tmp > $2
# clean
rm ball.tmp ball2.tmp coor.tmp cal.c getdis
# Job done
echo '# + Please find your result : '$2''
echo "#*************************************"
echo '#'
echo '# !! Job done !! '
echo '#'
echo "######################################",
貌似有些字符变成了表情。。。那两个笑脸是两个英文(半角)的反括号。
谢谢高手指导,请问一下,怎么在MS中模拟得到,此纳米球高温下(1873K)的的热力学性质啊?或者用哪个模块去做呢?
这程序不能用啊
############################################################
## Script to generate ball like structre ##
## Coded by Han Bo: hanbo39200900@gmail.com ##
############################################################
#
#Usage: ballgen.sh inputfile.pdb output.xyz
#
# * * * * * * * * * * * * * * * * * * * * * * * * * * *
# * please edit the line 10-15 of the code before using *
# * * * * * * * * * * * * * * * * * * * * * * * * * * *
#
# + Formating the input file
然后就执行不下去了,只能强行 ctrl+D 了
请问你这个问题解决了吗?能否请教下