| 查看: 3322 | 回复: 10 | ||
[求助]
求救,如何将xyz格式的文件转化为可以让lammps读的data文件,求大神,感激不尽 。 已有2人参与
|
||
如题/ |
» 猜你喜欢
计算机、0854电子信息(085401-058412)调剂
已经有5人回复
国自然申请面上模板最新2026版出了吗?
已经有13人回复
基金委咋了?2026年的指南还没有出来?
已经有3人回复
Materials Today Chemistry审稿周期
已经有5人回复
溴的反应液脱色
已经有7人回复
推荐一本书
已经有12人回复
基金申报
已经有4人回复
纳米粒子粒径的测量
已经有7人回复
常年博士招收(双一流,工科)
已经有4人回复
有没有人能给点建议
已经有5人回复
bluewhale
铁杆木虫 (正式写手)
- 应助: 58 (初中生)
- 金币: 8438.3
- 散金: 50
- 红花: 10
- 帖子: 890
- 在线: 362.2小时
- 虫号: 278289
- 注册: 2006-09-10
- 专业: 凝聚态物性I:结构、力学和
|
仅仅.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
luftf
木虫 (正式写手)
- 应助: 51 (初中生)
- 金币: 3257.7
- 散金: 685
- 红花: 19
- 帖子: 541
- 在线: 200.2小时
- 虫号: 821742
- 注册: 2009-08-04
- 性别: GG
- 专业: 金属材料的力学行为
2楼2015-12-07 20:16:28
cyfjkf
至尊木虫 (著名写手)
- 应助: 2 (幼儿园)
- 金币: 21435.3
- 红花: 106
- 帖子: 1985
- 在线: 127.8小时
- 虫号: 102756
- 注册: 2005-11-14
- 专业: 凝聚态物性 II :电子结构
3楼2015-12-07 21:18:57
bluewhale
铁杆木虫 (正式写手)
- 应助: 58 (初中生)
- 金币: 8438.3
- 散金: 50
- 红花: 10
- 帖子: 890
- 在线: 362.2小时
- 虫号: 278289
- 注册: 2006-09-10
- 专业: 凝聚态物性I:结构、力学和
4楼2015-12-07 23:34:49
5楼2015-12-08 09:10:26
6楼2015-12-08 09:11:39
7楼2015-12-08 09:12:52
bluewhale
铁杆木虫 (正式写手)
- 应助: 58 (初中生)
- 金币: 8438.3
- 散金: 50
- 红花: 10
- 帖子: 890
- 在线: 362.2小时
- 虫号: 278289
- 注册: 2006-09-10
- 专业: 凝聚态物性I:结构、力学和
【答案】应助回帖
|
为什么不自己建: units metal boundary p p p atom_style molecular lattice custom 2.4595 a1 1 0 0 a2 0 1.73203 0 a3 0.0 0.0 10 basis 0 0 0 basis 0.5 0.16666666666666666 0 basis 0.5 0.5 0 basis 0 0.6666666666666666 0 region box block 0 80 0 120 -0.5 0.5 create_box 1 box create_atoms 1 box region coldest block INF INF 0 1.5 INF INF region hottest block INF INF 60 61.5 INF INF mass 1 12 pair_style tersoff pair_coeff * * SiC_1994.tersoff C |
9楼2015-12-08 13:56:58
10楼2015-12-08 23:44:37











回复此楼