4. Calculating and plotting band diagrams
3. Visualizing dielectric functions
When MPB is executed, one of the first things done by the program is the generation of three dimensional dielectric function that is subsequently used in the calculations. This file is always called epsilon.h5 and is located with the control (ctl) file used. Before frequencies from a dielectric function are analyzed, it makes sense to review the function that was created from the (make geometry...) commands used in the ctl file. The visualization program of choice is called Mayavi2, and comes along with PythonXY which is available for both Linux and Windows. When visualizing a dielectric function, the function first has to be pre-processed in Linux. Once Mayavi2 is open, the steps for opening and viewing a function are the same in both Linux and Windows versions.
Getting an epsilon.h5 file
Run MPB with the ctl file discussed in detail previously by navigating, in the Linux terminal, to the folder containing the Inv_Opal.ctl file and executing MPB with the file:
matt@matt-desktop:/media/windows/LinuxShared/ctl$ mpb Inv_Opal.ctl
The output from the running program should scroll over the screen. You should see the following line as part of the output:
epsilon: 1-4.84, mean 1.99654, harm. mean 1.28331, 31.097% > 1, 25.9516% "fill"
Outputting epsilon...
When the program moves beyond this, the dielectric file was successfully output and you may kill the program by hitting ctrl+c (no need to wait while it solves all 86 k-points).
Pre-processing the epsilon.h5 file
3. Visualizing dielectric functions
When MPB is executed, one of the first things done by the program is the generation of three dimensional dielectric function that is subsequently used in the calculations. This file is always called epsilon.h5 and is located with the control (ctl) file used. Before frequencies from a dielectric function are analyzed, it makes sense to review the function that was created from the (make geometry...) commands used in the ctl file. The visualization program of choice is called Mayavi2, and comes along with PythonXY which is available for both Linux and Windows. When visualizing a dielectric function, the function first has to be pre-processed in Linux. Once Mayavi2 is open, the steps for opening and viewing a function are the same in both Linux and Windows versions.
Getting an epsilon.h5 file
Run MPB with the ctl file discussed in detail previously by navigating, in the Linux terminal, to the folder containing the Inv_Opal.ctl file and executing MPB with the file:
matt@matt-desktop:/media/windows/LinuxShared/ctl$ mpb Inv_Opal.ctl
The output from the running program should scroll over the screen. You should see the following line as part of the output:
epsilon: 1-4.84, mean 1.99654, harm. mean 1.28331, 31.097% > 1, 25.9516% "fill"
Outputting epsilon...
When the program moves beyond this, the dielectric file was successfully output and you may kill the program by hitting ctrl+c (no need to wait while it solves all 86 k-points).
Pre-processing the epsilon.h5 file
![]() |
The commands used to pre-format the dielectric function for visualization: mpb-data (with modifiers), h5ls, h5tovtk, and mv. |
The epsilon.h5 file contains only the primitive unit cell, and is not plotted on a regular cartesian grid but a grid in which the three primitive lattice vectors are the axis. Use the following command to rearrange the data into a rectangular cell (-r), expand it to contain multiple periods (-m 3), and set the resolution (-n 64). Basically, the primitive cell is being replotted fron the original with a resolution of whatever you specify. A large resolution can make the file size very large, but greatly improves the quality of the visualization. A resolution of 64 and repeated 3 times yields a file size of about 200 MB.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ mpb-data -r -m 3 -n 64 epsilon.h5
mpb-data places the pre-processed data in a sub-section of the epsilon.h5 file. All the different parts of the file can be seen using the h5ls command.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ h5ls epsilon.h5
Convert the new dielectric function, epsilon.h5:data-new, to a vtk file that can be understood by Mayavi2.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ H5tovtk epsilonh5:data-new
The new VTK file should be much smaller, like around 6 MB. Finally, the new processed dielectric needs to be renamed. In the Linux terminal, this can be done by "moving" the file.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ mv epsilon.vtk Inv_Opal_Dielectric.vtk
Open Mayavi2 in Linux by typing mayavi2 at the command prompt. In Windows, open Mayavi2 using its icon. Open up the dielectric function by selecting "Add Data Source," then "Load data from file," and select your file. The file will open, but you won’t see anything until you select a module or filter. There are two that I frequently use: volume, and scalar cut plane. After selecting volume, you can play with many different parameters to adjust the appearance of the visualization. When you are satisfied with the way it looks, save a snapshot of the image by clicking the disk icon in the scene area.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ mpb-data -r -m 3 -n 64 epsilon.h5
mpb-data places the pre-processed data in a sub-section of the epsilon.h5 file. All the different parts of the file can be seen using the h5ls command.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ h5ls epsilon.h5
Convert the new dielectric function, epsilon.h5:data-new, to a vtk file that can be understood by Mayavi2.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ H5tovtk epsilonh5:data-new
The new VTK file should be much smaller, like around 6 MB. Finally, the new processed dielectric needs to be renamed. In the Linux terminal, this can be done by "moving" the file.
matt@matt-desktop:/media/windows/LinuxShared/ctl$ mv epsilon.vtk Inv_Opal_Dielectric.vtk
Open Mayavi2 in Linux by typing mayavi2 at the command prompt. In Windows, open Mayavi2 using its icon. Open up the dielectric function by selecting "Add Data Source," then "Load data from file," and select your file. The file will open, but you won’t see anything until you select a module or filter. There are two that I frequently use: volume, and scalar cut plane. After selecting volume, you can play with many different parameters to adjust the appearance of the visualization. When you are satisfied with the way it looks, save a snapshot of the image by clicking the disk icon in the scene area.
![]() |
Dielectric function for the inverse opal example, plotted in Myavi2 using the default settings in the volume module. |
No comments:
Post a Comment