24小时热门版块排行榜    

查看: 3803  |  回复: 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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考博] 澳大利亚 Murdoch University 全奖博士招生(3个名额)地质化工冶金领域 +44 AI8RaGaPaSCR 2026-08-07 46/2300 2026-08-14 01:15 by oXaCpVTh6uOA
[基金申请] 欢迎发来filecode的Mz6后的代码验证其规律 +11 医学老男孩 2026-08-13 29/1450 2026-08-14 00:04 by 大快人心啦
[基金申请] 小木虫上这么多卖论文的,真有人买论文么?感觉没必要啊 +9 Tide man 2026-08-10 10/500 2026-08-13 20:33 by 温淼淼淼
[基金申请] 静等基金结果 +8 gjjjzhong 2026-08-10 21/1050 2026-08-13 17:56 by 且听虎啸
[基金申请] filecode +14 documentary 2026-08-10 16/800 2026-08-13 16:39 by 润生71
[基金申请] Filecode 又变了,巨变 +3 WH3796 2026-08-12 4/200 2026-08-13 14:13 by 小木虫6752397
[基金申请] 分享一下我之前已中青C的计划书的filecode +4 布布和一二 2026-08-11 5/250 2026-08-13 12:56 by cratir
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +9 家与远方 2026-08-10 14/700 2026-08-13 09:41 by 臭臭不臭01
[基金申请] 综述论文作为代表作会不会影响评审专家的印象分? +11 yufeiwaner 2026-08-09 13/650 2026-08-12 08:17 by yufeiwaner
[基金申请] 是这周出结果还是下周出结果? +3 yuleib84 2026-08-11 3/150 2026-08-11 21:53 by jnhyjjm
[硕博家园] 读博的好处 +3 lnee 2026-08-11 3/150 2026-08-11 18:10 by 希望我好好的
[基金申请] 什么时候出结果,有咨询渠道??? +3 Tide man 2026-08-11 3/150 2026-08-11 17:54 by kudofaye
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 2026国自然放榜时间 +9 布布和一二 2026-08-08 9/450 2026-08-10 11:22 by xxxx2020
[基金申请] 这样的filecode谁见过 +11 布布和一二 2026-08-08 22/1100 2026-08-10 11:10 by wmfsnow
[基金申请] filecode与中标关系的预测 +5 布布和一二 2026-08-07 5/250 2026-08-09 16:15 by 袁向阳007
[基金申请] 关于filecode,很负责任的告诉大家 +6 爱看书的可乐 2026-08-08 7/350 2026-08-08 22:13 by a_niu
[基金申请] 国基金的申报应该改成非等额制,评价高的钱多评价低的钱少,但是增加资助率 +7 a089 2026-08-07 7/350 2026-08-08 18:05 by gltch
[基金申请] 关于filecode +4 布布和一二 2026-08-07 7/350 2026-08-07 22:55 by zhanghaozhu
[基金申请] 化学口download_prp&fileCode的固定段好像这几天一直没变,有变的大神么? +3 Tide man 2026-08-07 4/200 2026-08-07 22:39 by Tide man
信息提示
请填处理意见