| 3 | 1/1 | 返回列表 |
| 查看: 929 | 回復(fù): 2 | |||
[交流]
【求助】緊急求教讀取CHGCAR的matlab腳本,謝謝
|
| 現(xiàn)在需要深入研究vasp的CHGCAR,希望用matlab讀取它,但對矩陣的讀取一直沒查到相關(guān)資料,求教哪位有讀能提供取CHGCAR的matlab小腳本,謝謝。 |
» 搶金幣啦!回帖就可以得到:
+1/163
+1/85
+2/76
+1/62
+1/40
+1/35
+1/35
+2/34
+1/31
+1/30
+2/24
+1/12
+1/5
+1/3
+1/3
+1/2
+1/2
+1/1
+1/1
+1/1
|
% Read in CHG file to 3D matrix. fid = fopen('CHG','r'); % Read POSCAR part of CHG file: sysname = fgetl(fid); lconst = fscanf(fid,'%f',1); basisvec = fscanf(fid,'%f',[3,3])'; temp1 = fgetl(fid); temp2 = fgetl(fid); species = sscanf(temp2,'%i'); Natoms = sum(species); temp3 = fgetl(fid); atompos_f3 = fscanf(fid,'%f',[3,Natoms])'; volume = abs(dot(basisvec(1, ,cross(basisvec(2, ,basisvec(3, )))*lconst^3;% Read charge density data. (i,j,k) value in i+(j+k*Ny)*Nx, with coordinate % system defined by basis vectors!: gridsize = fscanf(fid,'%i',3); Nx = gridsize(1); Ny = gridsize(2); Nz = gridsize(3); temp4 = fscanf(fid,'%f',[Nx*Ny*Nz,1]); density_sub_h1_surf=reshape(temp4,Nx,Ny,Nz)/volume; % % Magnitization (if present): % temp5 = fscanf(fid,'%i',3); % temp6 = fscanf(fid,'%f',[Nx*Ny*Nz,1]); % magn_lowacc_t2_N�蕆eshape(temp6,Nx,Ny,Nz)/volume; % minval = min(min(min(density))); % maxval = max(max(max(density))); % For rectangular unit cell, unit axes: % Plot isosurface: % prect = patch(isosurface(density,7.5), 'FaceColor', 'red', 'EdgeColor', 'none'); % isonormals(density,prect); % %axis tight; % camlight; lighting phong; % Non-rectangular (general) unit cell: % Need to created position 3D matrices xtemp = zeros(Nx*Ny*Nz,1); ytemp = zeros(Nx*Ny*Nz,1); ztemp = zeros(Nx*Ny*Nz,1); for k = 0:Nz-1 for j = 0:Ny-1 for i = 0:Nx-1 xtemp(1+i+(j+k*Ny)*Nx) = i/Nx*basisvec(1,1)+j/Ny*basisvec(2,1)+k/Nz*basisvec(3,1); ytemp(1+i+(j+k*Ny)*Nx) = i/Nx*basisvec(1,2)+j/Ny*basisvec(2,2)+k/Nz*basisvec(3,2); ztemp(1+i+(j+k*Ny)*Nx) = i/Nx*basisvec(1,3)+j/Ny*basisvec(2,3)+k/Nz*basisvec(3,3); end end end X = reshape(xtemp,Nx,Ny,Nz)*lconst; Y = reshape(ytemp,Nx,Ny,Nz)*lconst; Z = reshape(ztemp,Nx,Ny,Nz)*lconst; z = squeeze(Z(1,1, );ave_z_h1 = squeeze(sum(sum(density_sub_h1_surf,1),2))/(Nx*Ny); %(sqrt(2)*Nx*Ny)*lconst^2; figure %subplot(211) plot(z,ave_z_h1,'k') % figure % p = patch(isosurface(X,Y,Z,density,7.5), 'FaceColor', 'red', 'EdgeColor', 'none'); % isonormals(density,p); % % maxx = max(basisvec(:,1))*lconst; % % minx = min(basisvec(:,1))*lconst; % % maxy = max(basisvec(:,2))*lconst; % % miny = min(basisvec(:,2))*lconst; % % maxz = max(basisvec(:,3))*lconst; % % minz = min(basisvec(:,3))*lconst; % % axis([minx maxx miny maxy minz maxz]) % camlight; lighting phong; % Extract charge density along certain lines: ------------------------------ |
| 3 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 求調(diào)劑 +3 | 暗涌afhb 2026-03-16 | 3/150 |
|
|---|---|---|---|---|
|
[考研] 一志愿吉林大學(xué)材料學(xué)碩321求調(diào)劑 +9 | Ymlll 2026-03-18 | 12/600 |
|
|
[考研] 0703化學(xué)調(diào)劑 +10 | 妮妮ninicgb 2026-03-15 | 14/700 |
|
|
[考研] 生物學(xué)調(diào)劑招人。! +3 | 山海天嵐 2026-03-17 | 4/200 |
|
|
[考研] 【考研調(diào)劑】化學(xué)專業(yè) 281分,一志愿四川大學(xué),誠心求調(diào)劑 +5 | 吃吃吃才有意義 2026-03-19 | 5/250 |
|
|
[考研] 0703化學(xué)調(diào)劑 +4 | 18889395102 2026-03-18 | 4/200 |
|
|
[考研] 324分 085600材料化工求調(diào)劑 +3 | llllkkkhh 2026-03-18 | 3/150 |
|
|
[考研] 一志愿中海洋材料工程專碩330分求調(diào)劑 +7 | 小材化本科 2026-03-18 | 7/350 |
|
|
[考研] 化學(xué)工程321分求調(diào)劑 +15 | 大米飯! 2026-03-15 | 18/900 |
|
|
[考研] 311求調(diào)劑 +6 | 26研0 2026-03-15 | 6/300 |
|
|
[考研] 材料專碩306英一數(shù)二 +10 | z1z2z3879 2026-03-16 | 13/650 |
|
|
[考研]
|
胡辣湯放糖 2026-03-15 | 6/300 |
|
|
[考研] 280求調(diào)劑 +6 | 咕嚕曉曉 2026-03-18 | 7/350 |
|
|
[考研] 085601求調(diào)劑 +4 | Du.11 2026-03-16 | 4/200 |
|
|
[考研] [導(dǎo)師推薦]西南科技大學(xué)國防/材料導(dǎo)師推薦 +3 | 尖角小荷 2026-03-16 | 6/300 |
|
|
[考研] 333求調(diào)劑 +3 | 文思客 2026-03-16 | 7/350 |
|
|
[考研] 0856求調(diào)劑 +3 | 劉夢微 2026-03-15 | 3/150 |
|
|
[考研] 本科南京大學(xué)一志愿川大藥學(xué)327 +3 | 麥田耕者 2026-03-14 | 3/150 |
|
|
[考研] 297求調(diào)劑 +4 | 學(xué)海漂泊 2026-03-13 | 4/200 |
|
|
[考研] 304求調(diào)劑 +7 | 7712b 2026-03-13 | 7/350 |
|