| 24小時(shí)熱門版塊排行榜 |
| 5 | 1/1 | 返回列表 |
| 查看: 927 | 回復(fù): 2 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
[交流]
【求助】緊急求教讀取CHGCAR的matlab腳本,謝謝
|
|||
| 現(xiàn)在需要深入研究vasp的CHGCAR,希望用matlab讀取它,但對(duì)矩陣的讀取一直沒(méi)查到相關(guān)資料,求教哪位有讀能提供取CHGCAR的matlab小腳本,謝謝。 |
» 搶金幣啦!回帖就可以得到:
+1/644
+1/164
+1/85
+1/84
+1/66
+1/47
+1/40
+1/36
+1/33
+1/20
+1/16
+5/10
+1/7
+1/7
+1/6
+1/5
+1/1
+1/1
+1/1
+1/1
鐵桿木蟲(chóng) (職業(yè)作家)
木蟲(chóng) (小有名氣)
|
% 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: ------------------------------ |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 材料學(xué)碩318求調(diào)劑 +4 | February_Feb 2026-03-19 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 321求調(diào)劑 +8 | 何潤(rùn)采123 2026-03-18 | 10/500 |
|
|
[考研] 能源材料化學(xué)課題組招收碩士研究生8-10名 +4 | 脫穎而出 2026-03-16 | 12/600 |
|
|
[考研] 0817調(diào)劑 +3 | 沒(méi)有答案_ 2026-03-14 | 3/150 |
|
|
[考研] 0703化學(xué)調(diào)劑,求各位老師收留 +10 | 秋有木北 2026-03-14 | 10/500 |
|
|
[考研] 330求調(diào)劑 +3 | 小材化本科 2026-03-18 | 3/150 |
|
|
[考研] 化學(xué)工程321分求調(diào)劑 +15 | 大米飯! 2026-03-15 | 18/900 |
|
|
[考研]
|
胡辣湯放糖 2026-03-15 | 6/300 |
|
|
[考研] 299求調(diào)劑 +5 | △小透明* 2026-03-17 | 5/250 |
|
|
[考博] 環(huán)境領(lǐng)域全國(guó)重點(diǎn)實(shí)驗(yàn)室招收博士1-2名 +3 | QGZDSYS 2026-03-13 | 5/250 |
|
|
[考研] 0703化學(xué)調(diào)劑 +3 | 妮妮ninicgb 2026-03-17 | 3/150 |
|
|
[考研] 301求調(diào)劑 +9 | yy要上岸呀 2026-03-17 | 9/450 |
|
|
[考研] 278求調(diào)劑 +5 | 煙火先于春 2026-03-17 | 5/250 |
|
|
[考研] 277調(diào)劑 +5 | 自由煎餅果子 2026-03-16 | 6/300 |
|
|
[考研] 有沒(méi)有道鐵/土木的想調(diào)劑南林,給自己招師弟中~ +3 | TqlXswl 2026-03-16 | 7/350 |
|
|
[考研] 一志愿蘇州大學(xué)材料工程(085601)專碩有科研經(jīng)歷三項(xiàng)國(guó)獎(jiǎng)兩個(gè)實(shí)用型專利一項(xiàng)省級(jí)立項(xiàng) +6 | 大火山小火山 2026-03-16 | 8/400 |
|
|
[考研] 機(jī)械專碩325,尋找調(diào)劑院校 +3 | y9999 2026-03-15 | 5/250 |
|
|
[考研] 22408總分284求調(diào)劑 +3 | InAspic 2026-03-13 | 3/150 |
|
|
[考研] 中科大材料專碩319求調(diào)劑 +3 | 孟鑫材料 2026-03-13 | 3/150 |
|
|
[考研] 070303一志愿西北大學(xué)學(xué)碩310找調(diào)劑 +3 | d如愿上岸 2026-03-13 | 3/150 |
|