| 查看: 3351 | 回复: 10 | ||
[求助]
求救,如何将xyz格式的文件转化为可以让lammps读的data文件,求大神,感激不尽 。 已有2人参与
|
||
如题/ |
» 猜你喜欢
AI 太可怕了,写基金时,提出想法,直接生成的文字比自己想得深远,还有科学性
已经有3人回复
有院领导为了换新车,用横向课题经费买了俩车
已经有9人回复
酰胺脱乙酰基
已经有13人回复
博士延得我,科研能力直往上蹿
已经有8人回复
同年申请2项不同项目,第1个项目里不写第2个项目的信息,可以吗
已经有4人回复
有时候真觉得大城市人没有县城人甚至个体户幸福
已经有10人回复
天津大学招2026.09的博士生,欢迎大家推荐交流(博导是本人)
已经有5人回复
CSC & MSCA 博洛尼亚大学能源材料课题组博士/博士后招生|MSCA经费充足、排名优
已经有6人回复
遇见不省心的家人很难过
已经有22人回复
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 (幼儿园)
- 金币: 21461.1
- 红花: 106
- 帖子: 1991
- 在线: 128.3小时
- 虫号: 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













回复此楼