24小时热门版块排行榜    

查看: 3328  |  回复: 10
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

1970-01-01 08:00:00
已阅   申请模拟EPI   回复此楼   编辑   查看我的主页

bluewhale

铁杆木虫 (正式写手)

引用回帖:
7楼: Originally posted by 青春逍遥啊 at 2015-12-08 09:12:52
就是一个石墨烯的坐标模型,都是c原子,。。。...

仅仅.xyz转过去是不完整的(见下),还有bond, angle, dihedral的定义。
xyz2lmp.m
--------------
function xyz2lmp(f_xyz)
% This script converts .xyz file to lammps data file.
% Input:
%   f_xyz: name of the input .xyz file.
% Example:
%   xyz2lmp('PdAu.xyz')
% NOTE: The second line must be in specified format as:
%   PdAu xlo xhi ylo yhi zlo zhi
% Poweed by Xianbao Duan
% Email: xianbao.d@gmail.com
% Website: http://www.52souji.net/

% open the .xyz file
fidin = fopen(f_xyz,'r');
if fidin == -1
    error('Failed to open the file. Please check!');
end

% number of all the atoms
atom_num_a = fscanf(fidin,'%d');

% comment
comment = textscan(fidin,'%s %f %f %f %f %f %f',1);
xlo = comment{2};
xhi= comment{3};
ylo = comment{4};
yhi= comment{5};
zlo = comment{6};
zhi= comment{7};

% coordinates of the atoms
atoms = textscan(fidin,'%s %f %f %f',atom_num_a);
fclose(fidin);

% initialize
type_name = atoms{1}(1);    % names of types
atom_num(1) = 1;            % atom number of each type

% sort the atoms according to their types
for i = 2: length(atoms{1})
    flag = 0;
    for j = 1:length(type_name)
        if strcmp(atoms{1}(i),type_name(j)) == 1
            atom_num(j) = atom_num(j) + 1;
            flag = 1;
            break;
        end
    end
    if flag == 0
        type_name(end+1) = atoms{1}(i);
        atom_num(end+1) = 1;
    end
end
type_num = length(type_name);

% write the lammps file
outfilename = strrep(f_xyz,'.xyz','.lmp');
fidout = fopen(outfilename, 'w');
new_comment =  ['Converted from .xyz to .lmp @ ',datestr(now) ];
fprintf(fidout,'%s\n\n',new_comment);
fprintf(fidout,'%d \t %s\n',atom_num_a,'atoms');
fprintf(fidout,'%d \t %s\n',type_num,'atom types');
fprintf(fidout,'%f  %f \t%s\n',xlo,xhi,'xlo xhi');
fprintf(fidout,'%f  %f \t%s\n',ylo,yhi,'ylo yhi');
fprintf(fidout,'%f  %f \t%s\n\n',zlo,zhi,'zlo zhi');
fprintf(fidout,'%s\n\n','Atoms');
% the data
for i = 1:length(atoms{1})
    for j = 1:type_num
        if strcmp(atoms{1}(i),type_name(j)) == 1
            fprintf(fidout,'%d \t %d \t %f \t %f \t %f \n',...
                i,j,atoms{2}(i),atoms{3}(i),atoms{4}(i));
            break;
        end
    end
end
fclose(fidout);
8楼2015-12-08 11:05:38
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 11 个回答

luftf

木虫 (正式写手)

【答案】应助回帖

感谢参与,应助指数 +1
首先要看你用lammps模拟什么材料,用的什么势函数
data文件的结构跟势函数有关
不同势函数用的data文件的结构都不一样
LAMMPS手册里面有具体的说明
2楼2015-12-07 20:16:28
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

cyfjkf

至尊木虫 (著名写手)

3楼2015-12-07 21:18:57
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

bluewhale

铁杆木虫 (正式写手)

【答案】应助回帖

感谢参与,应助指数 +1
有机分子,还是纯金属?
4楼2015-12-07 23:34:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见