Load OOMMF file to Matlab array
バージョン 1.0.7 (21.9 KB) 作成者:
Nikolai Khokhlov
The function imports vector file (.omf/.ovf) from micromagnetic simulation output (OOMMF, mumax3 or Boris) into Matlab arrays
The function imports vector file archives from oommf [1], mumax3 [2], Boris [3] into Matlab arrays.
*with mumax3 was not tested, but should work with proper saving .ovf as a text. See comments about saving in OOMMF and Boris
The file is inspired by H. Corte and his function oommf2matlab.m
ChatGPT [4] was used also.
Main modification: fileToRead is processed with fileread function, not line-by-line. It works much faster for large files (100+Mb)
OOMMF vector files must be writen with the output Specifications "text %g" instead of the default "binary 4" option. And the type of grid must be rectangular. In Boris use ns.saveovf2mag('text', output_file, bufferCommand=True)
Vector files will be imported into the object "data" which will have this fields (if exist in fileToRead):
datax: component x of vector on data file
datay: component y of vector on data file
dataz: component z of vector on data file
time: total simulation time
xmin: minimum x value
xnodes: number of nodes used along x
xmax: maximum x value
ymin: minimum y value
ynodes: number of nodes used along y
ymax: maximum y value
zmin: minimum z value
znodes: number of nodes used along z
zmax: maximum z value
positionx: x positions of vectors
positiony: y positions of vectors
positionz: z positions of vectors
The number of fields could be extended easily
Basic usage:
dataOMF = oommf2matlab("your_file_name.ovf")% it loads the data to variable dataOMF
% and you can use it as next
Mx = dataOMF.datax % returns array of Mx components
% replace 'datax' with the desired vector (see above)
% be careful - it returns 1D array other the nodes.
% to plot 2D data correctly refer to next example:
Example: Plot 2D images from all files in directory:
%% read file names
dir_name = './DirName/';
file_extention = '*.ovf'; % .omf is also good
f_n = dir([dir_name file_extention]);
%% sort files by date
[~,idx] = sort([f_n.datenum]);
f_n = f_n(idx);
fileNames = {f_n.name};
mult = 1e6; % switch dimentions to microns
for ff = 1:length(fileNames)
dataOMF = omf2matlab([dir_name fileNames{ff}]);
Xvector = mult* linspace(dataOMF.xmin, dataOMF.xmax, dataOMF.xnodes);
Yvector = mult* linspace(dataOMF.ymin, dataOMF.ymax, dataOMF.ynodes);
Magn_z = dataOMF.dataz
imagesc(Xvector, Yvector, Magn_z');
drawnow;
end;
You can find the example of use with corresponding .mif files on my GitHub repository: https://github.com/NikolaiKh/OOMMF-to-Matlab
Some instrument control programs (for pump-probe measurements, imaging etc) are also on github. Thus, welome :))
The code was used for article: Khokhlov, N. E., Filatov, I. A., & Kalashnikova, A. M. Spatial asymmetry of optically excited spin waves in anisotropic ferromagnetic film. Journal of Magnetism and Magnetic Materials, 589, 171514 (2024) [https://doi.org/10.1016/j.jmmm.2023.171514]
The citation is welcome
References:
[1] OOMMF: Object Oriented MicroMagnetic Framework, NIST,
[2] mumax3, a GPU-accelerated micromagnetic simulation
[3] Boris Computational Spintronics,
Multi-physics magnetisation dynamics and spin transport simulations,
[4] ChatGPT https://chat.openai.com/
This function was written by N. Khokhlov
引用
Nikolai Khokhlov (2024). Load OOMMF file to Matlab array (https://github.com/NikolaiKh/OOMMF-to-Matlab), GitHub. に取得済み.
MATLAB リリースの互換性
作成:
R2021b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linuxタグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!GitHub の既定のブランチを使用するバージョンはダウンロードできません
バージョン | 公開済み | リリース ノート | |
---|---|---|---|
1.0.7 | Citation updated |
|
|
1.0.6 | Citation added |
|
|
1.0.5 | Github repository is connected |
|
|
1.0.4 | Fields "x/y/zstepsize" are added |
||
1.0.3 | Description updated |
||
1.0.2 | Basic example is added;
|
||
1.0.1 | Fixed an issue with "# Begin: Data Text" and "# Begin: data text" recognition. Now both versions are readeble |
||
1.0.0 |
この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。
この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。