diff --git a/doc/manual_en.tex b/doc/manual_en.tex deleted file mode 100644 index d5922d4..0000000 --- a/doc/manual_en.tex +++ /dev/null @@ -1,560 +0,0 @@ -\documentclass[12pt]{article} -\usepackage{fancyhdr} -%\usepackage{jtygm} -\usepackage{amsmath} -\usepackage{amssymb} -\usepackage{graphicx} -\usepackage{braket} -\usepackage{color} -\usepackage{bm}% bold math -\usepackage{dcolumn}% Align table columns on decimal point - -\topmargin=-10mm -\textheight=25cm -\textwidth=17cm -\oddsidemargin=-0.04 cm -\evensidemargin=-1.04cm - -\begin{document} -% -% Cover -% -\title{Manual for FermiSurfer\\ -version 1.4} -\author{Mitsuaki KAWAMURA\footnote{mkawamura@issp.u-tokyo.ac.jp}} -%\date{} -\maketitle - -\tableofcontents - -\section{Introduction} - -This document is a manual for the Fermi surface drawing program ``Fermi Surfer". -Fermi Surfer have been developed since 2012 by Mitsuaki Kawamura -(ISSP, The University of Tokyo); -it is opened on web at November, 2014. -It draws Fermi surfaces, and -plot $k$-depend matrix elements such as the superconducting gap and -orbital character with colors. - -\section{MIT License} - -Copyright (c) 2014 Mitsuaki Kawamura - -\vspace{0.5cm} -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -\vspace{0.5cm} -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -\vspace{0.5cm} -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -\section{Files in this package} - -\begin{description} -\item[\texttt{bin/fermisurfer.exe}] Executable for Windows -\item[\texttt{doc/manual\_en.pdf}] Manual (English) -\item[\texttt{doc/manual\_ja.pdf}] Manual (Japanese) -\item[\texttt{examples/mgb2\_vfz.frmsf}] Sample input file -\item[\texttt{src/fermisurfer.c}] Source file -\item[\texttt{src/mac.diff}] Patch for Mac OSX -\item[\texttt{src/Makefile}] Makefile for Linux -\item[\texttt{src/Makefile-mac}] Makefile for Mac OSX -\end{description} - -\section{Install} - -\subsection{Installation in Linux} - -\begin{enumerate} - -\item Install the required package - - \begin{itemize} - \item For Debian/Ubuntu - \begin{verbatim} - $ sudo aptitude install freeglut3-dev - \end{verbatim} - \item For Red Hat Enterprise Linux/CentOS - \begin{verbatim} - $ sudo yum install freeglut-devel.x86_64 - \end{verbatim} - \end{itemize} - -\item Make - -\begin{verbatim} - $ cd ./src - $ make fermisurfer - $ make install -\end{verbatim} - -\end{enumerate} - -Then a binary file \texttt{fermisurfer} is generated and put -in \verb|/usr/local/bin/|. - -\subsection{For Mac OSX} - -\begin{enumerate} - -\item Install Xcode. - -\item Patch the source code. -\begin{verbatim} - $ cd ./src - $ patch -p1 < mac.diff -\end{verbatim} - -\item Make. -\begin{verbatim} - $ make -f Makefile-mac fermisurfer - $ make -f Makefile-mac install -\end{verbatim} - -Then a binary file \texttt{fermisurfer} is generated and put -in \verb|/usr/local/bin/|. - -\end{enumerate} - -\subsection{Installation in Windows} - -\begin{enumerate} - -\item Download the \verb|zip| file which contains \verb|freeglut.dll| -from ``freeglut Windows Development Library'' site -\begin{verbatim} -http://www.transmissionzero.co.uk/software/freeglut-devel/ -\end{verbatim} -(in ``freeglut MSVC package'' item). -Then, \verb|unzip| it. - -\item copy \verb|.\bin\freeglut.dll| to the folder which contains - \verb|fermisurfer.exe| (\verb|bin|). - (You should not use \verb|.\bin\x64\freeglut.dll|) - -\end{enumerate} - -\section{Input file} - -\subsection{input-file format} - -You have to prepare following data: -\begin{itemize} -\item The number of $k$ grid (three direction) -\item Reciprocal lattice vectors -\item The number of bands -\item The orbital energy at each band and $k$ (We call it ``energy'') . -\item Variables that you want to plot with color (We call it ``matrix elements''). -\end{itemize} - -This program supports two kind of uniform $k$ grid, -a grid (${\rm \Gamma}$ centered) and grid with a half-grid shift. -The latter is used when the matrix element becomes singular -at ${\rm \Gamma}$. - -The input file is as follows (\verb|mgb2_vfz.fs|): - -\begin{verbatim} - 40 40 36 (1) - 0 (2) - 3 (3) - 1.0000000 0.57735026 -0.0000000 (4) - 0.0000000 1.1547005 0.0000000 (5) - 0.0000000 -0.0000000 0.87206507 (6) - 2.91340202E-02 (7) - 2.93242838E-02 - 2.98905596E-02 - 3.08193434E-02 - : - : - 0.14393796 - 0.12800488 - 0.0000000 (8) - 0.36269817 - 0.71675694 - 1.0535113 - 1.3644149 - : - : - -26.409407 - -19.318560 - -10.315671 -\end{verbatim} - -\begin{enumerate} - \renewcommand{\labelenumi}{(\arabic{enumi})} - \item The $k$ point grid - \item 0 for ${\rm \Gamma}$centered grid. 1 for shifted grid. - \item The number of bands - \item Reciprocal lattice vector 1 (arbitrary unit) - \item Reciprocal lattice vector 2 - \item Reciprocal lattice vector 3 - \item Energy - \item Matrix elements -\end{enumerate} - -\subsection{How to produce the input file in C and fortran programs} - -fortran - -\begin{verbatim} - real(4) :: bvec1(3), bvec2(3), bvec3(3) ! Resiplocal lattice vector - integer :: nk1, nk2, nk3 ! k-grid of each direction - integer :: ishift ! 1 for shifted grid, 0 for unshifted grid. - integer :: nbnd ! The number of bands - real(4) :: eig(nk3,nk2,nk1,nbnd) ! energy - real(4) :: x(nk3,nk2,nk1,nbnd) ! matrix element - - integer :: ik1, ik2, ik3, ibnd, fo - - open(fo, file = "sample.fs") - write(fo,*) nk1, nk2, nk3 - write(fo,*) ishift - write(fo,*) nbnd - write(fo,*) real(bvec1(1:3)) - write(fo,*) real(bvec2(1:3)) - write(fo,*) real(bvec3(1:3)) - do ibnd = 1, nbnd - do ik1 = 1, nk1 - do ik2 = 1, nk2 - do ik3 = 1, nk3 - write(fo,*) real(eig(ik3,ik2,ik1,ibnd)) - end do - end do - end do - end do - do ibnd = 1, nbnd - do ik1 = 1, nk1 - do ik2 = 1, nk2 - do ik3 = 1, nk3 - write(fo,*) real(x(ik3,ik2,ik1,ibnd)) - end do - end do - end do - end do - close(fo) -\end{verbatim} - -C - -\begin{verbatim} - float bvec1[3], bvec2[3], bvec3[3]; /*Resiplocal lattice vector*/ - int nk1, nk2, nk3; /*k-grid of each direction*/ - int ishift; /*1 for shifted grid, 0 for unshifted grid.*/ - int nbnd; /*The number of bands*/ - float eig[nbnd][nk1][nk2][nk3]; /*Energy*/ - float x[nbnd][nk1][nk2][nk3]; /*Matrix element*/ - - FILE* fo; - int ibnd, ik1, ik2, ik3; - - fo = fopen("sample.fs", "w"); - ierr = fprintf(fo, "%d %d %d", nk1, nk2, nk3); - ierr = fprintf(fo, "%d, iswitch); - ierr = fprintf(fo, "%d, nbnd); - ierr = fprintf(fp, "%e %e %e", bvec1[0], bvec1[1], bvec1[2]); - ierr = fprintf(fp, "%e %e %e", bvec2[0], bvec2[1], bvec2[2]); - ierr = fprintf(fp, "%e %e %e", bvec3[0], bvec3[1], bvec3[2]); - for (ibnd = 0; ibnd < nbnd; ++ibnd) { - for (ik1 = 0; ik1 < nk1; ++ik1) { - for (ik2 = 0; ik2 < nk2; ++ik2) { - for (ik3 = 0; ik3 < nk3; ++ik3) { - ierr = fprintf(fo, "%e", eig[ibnd][ik1][ik2][ik3]); - } - } - } - } - for (ibnd = 0; ibnd < nbnd; ++ibnd) { - for (ik1 = 0; ik1 < nk1; ++ik1) { - for (ik2 = 0; ik2 < nk2; ++ik2) { - for (ik3 = 0; ik3 < nk3; ++ik3) { - ierr = fprintf(fo, "%e", x[ibnd][ik1][ik2][ik3]); - } - } - } - } - fclose(fo); -\end{verbatim} - -\section{Control FermiSurfer} - -\subsection{For Linux} -You can launch generated executable as follows: -\begin{verbatim} -$ ./fermisurfer mgb2_vfz.fs -\end{verbatim} -You need a space between the command and input-file name. -(The sample input file \verb|mgb2_vfz.fs| contains -$z$ element of the Fermi velocity in MgB$_2$.) - -\subsection{For Windows} -Click mouse right button on the input file. -Choose ``Open With ...'' menu, -then choose \verb|fermisurfer.exe|. - -\vspace{0.5cm} -After that, \verb|fermisurfer| runs as the same whether you use Linux or Windows. -The information from the input file is printed. - -\begin{verbatim} -##### Brillouin zone informations ##### - -k point grid : 40 40 36 -k point grid is not shifted -# of bands : 3 -bvec 1 : 1.000000 0.577350 -0.000000 -bvec 2 : 0.000000 1.154701 0.000000 -bvec 3 : 0.000000 -0.000000 0.872065 - -# of lines for BZ : 84 (1) - -##### Max. and Min. of each bands ##### - -Band Eig_Min. Eig_Max Mat_Min Mat_Max -1 -0.428153 0.056262 -24.048639 24.048639 (2) -2 -0.289572 0.121181 -23.320309 23.320309 (2) -3 -0.133566 0.497620 -43.651634 43.651634 (2) - -##### First Brillouin zone mode ##### - -band # of patchs -1 8824 (3) -2 29469 (3) -3 28315 (3) - -band # of nodeline -1 632 (4) -2 1524 (4) -3 2268 (4) - -##### Full color scale ##### - -Max. value : 22.283419 (5) -Min. value : -22.283419 (5) - -\end{verbatim} - -\begin{enumerate} - \renewcommand{\labelenumi}{(\arabic{enumi})} - \item The number of lines on the edge of the Brillouin zone. - \item The maximum/minimum value of energies and matrix elements in each bands. - \item The number of patches (planes that makes Fermi surfaces) in each bands. - \item The number of node lines in each band. - \item The maximum and the minimum of matrix elements on - Fermi surface. - These correspond to the red and the blue; - in this case, the matrix element is -22.283419 in the blue region, - and that is 22.283419 in the red region. - [(2) is Max./Min. in whole Brillouin zone.] -\end{enumerate} - -Then, Operations are printed, and -Fermi surfaces are drawn. - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/start.eps} - \caption{Main view.} - \label{fig_start} -\end{figure} - -The following operations are available: -\begin{itemize} -\item Rotation of objects with mouse drag -\item Expand and shrink with mouse wheel -\item Window re-sizing -\item Moving objects with cursor keys -\item Opening the menu with mouse right button -\end{itemize} - -Here, I will explain all menus. - -\subsection{Band} - -It makes each band enable/disable (Fig. \ref{fig_band}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/band.eps} - \caption{You make each band enable/disable with \texttt{Band} menu.} - \label{fig_band} -\end{figure} - -\subsection{Mouse Drag} - -It turns the event of the mouse-left-drag. - -\begin{description} -\item[Rotate(default)] Rotate the figure along the mouse drag. -\item[Scale] Expand/shrink the figure in upward/downward drag. -\item[Translate] Translate the figure along the mouse drag. -\end{description} - -\subsection{Shift Fermi energy} - -It shifts the Fermi energy (= 0 in default) to arbitrary value. -When you use this menu, -first, it displays minimum and maximum energy in the input file -and the current Fermi energy; -\begin{verbatim} -Min Max E_F --0.428153 0.497620 0.000000 -Fermi energy shift : -\end{verbatim} -Then, you should type the new Fermi energy; -finally, the new Fermi surfaces are depicted (Fig. \ref{fig_shift}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/shift.eps} - \caption{The Fermi energy is set from 0 Ry to 0.1 Ry - with \texttt{Shift Fermi energy} menu} - \label{fig_shift} -\end{figure} - -\subsection{Background color} - -The background color is toggled between black and white; -The edge of the Brillouin Zone is also toggled -between white and black (Fig. \ref{fig_background}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/background.eps} - \caption{The background color is toggled with \texttt{Background color} menu.} - \label{fig_background} -\end{figure} - -\subsection{Color scale mode} - -It turns color pattern on Fermi surfaces (Fig. \ref{fig_colorscale}). -\begin{description} -\item[Auto(default)] - It makes blue as the minimum on Fermi surfaces and - red as the maximum on them. -\item[Manual] You can set manually (from standard input) - values corresponding to blue and red. -\item[Uni-color] Fermi surfaces of each band are depicted with uni-color - without relation to the matrix element. -\item[Periodic] It makes periodic color plot enable. - When the matrix element varies as - $0 \rightarrow \pi/3 \rightarrow 2\pi/3 \rightarrow \pi \rightarrow - 4\pi/3 \rightarrow 5\pi/3 \rightarrow 2\pi$, - the color varies as - red $\rightarrow$ yellow $\rightarrow$ green $\rightarrow$ - cyan $\rightarrow$ blue $\rightarrow$ magenta $\rightarrow$ red. -\end{description} - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/colorscale.eps} - \caption{\texttt{Color scale mode} menu.} - \label{fig_colorscale} -\end{figure} - -\subsection{Brillouin zone} - -You choose Brillouin-zone type as follows (Fig. \ref{fig_brillouinzone}): -\begin{description} -\item[First Brillouin Zone] The region surrounded by Bragg's planes - the nearest to ${\rm \Gamma}$ point. -\item[Primitive Brillouin Zone] A hexahedron - whose corner is the reciprocal lattice point. -\end{description} - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/brillouinzone.eps} - \caption{You can change the type of the Brillouin zone - with \texttt{Brillouin zone} menu.} - \label{fig_brillouinzone} -\end{figure} - -\subsection{Node line} - -The line on which the matrix element becomes 0 (we call it node line) -becomes enable/disable (Fig. \ref{fig_nodeline}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/nodeline.eps} - \caption{Toggling the node line with \texttt{Node line} menu.} - \label{fig_nodeline} -\end{figure} - -\subsection{Color bar On/Off} - -The color bar becomes enable/disable (Fig. \ref{fig_colorbar}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/colorbar.eps} - \caption{Toggling the color bar with \texttt{Color bar On/Off} menu.} - \label{fig_colorbar} -\end{figure} - -\subsection{Stereogram} - -The stereogram (parallel eyes and cross eyes) becomes -enabled/disabled (Fig. \ref{fig_stereogram}). -\begin{description} -\item[None (Default)] -\item[Parallel] Parallel-eyes stereogram -\item[Cross] Cross-eyes stereogram -\end{description} - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/stereogram.eps} - \caption{The stereogram becomes enabled/disabled with \texttt{Stereogram} menu.} - \label{fig_stereogram} -\end{figure} - -\subsection{Tetrahedron} - -You change the scheme to divide into tetrahedra (\texttt{tetra \# 1} as default). -It is experimental. - -\subsection{Exit} - -This finishes \verb|fermisurfer|. - -\section{Gallery} - -Contributions of each Fermi surfaces to the Hall effect -in IrO$_2$ -(Fig. \ref{fig_iro2}. Provided by Mr. Wataru Sano in Arita group, RIKEN) - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/iro2.eps} - \caption{Contributions of each Fermi surfaces to the Hall effect} - \label{fig_iro2} -\end{figure} - -\section{Acknowledgment} - -I thank Dr. Yusuke Konishi in ISSP; -he performed a test in Mac OSX, -and proposed Makefiles and a patch. - -\section{Contact} - -Please post bag reports and questions to the forum -\begin{verbatim} -http://sourceforge.jp/projects/fermisurfer/forums/ -\end{verbatim} - -When you want to join us, please contact me as follows. - -The Institute of Solid State Physics - -Mitsuaki Kawamura - -\verb|mkawamura@issp.u-tokyo.ac.jp| - -\end{document} diff --git a/doc/manual_ja.tex b/doc/manual_ja.tex deleted file mode 100644 index 7f62d5e..0000000 --- a/doc/manual_ja.tex +++ /dev/null @@ -1,544 +0,0 @@ -\documentclass[12pt]{jarticle} -\usepackage{fancyhdr} -%\usepackage{jtygm} -\usepackage{amsmath} -\usepackage{amssymb} -\usepackage{graphicx} -\usepackage{braket} -\usepackage{color} -\usepackage{bm}% bold math -\usepackage{dcolumn}% Align table columns on decimal point - -\topmargin=-10mm -\textheight=25cm -\textwidth=17cm -\oddsidemargin=-0.04 cm -\evensidemargin=-1.04cm - -\begin{document} -% -% Cover -% -\title{FermiSurfer マニュアル \\ -version 1.4} -\author{河村 光晶\footnote{mkawamura@issp.u-tokyo.ac.jp}} -%\date{} -\maketitle - -\tableofcontents - -\section{はじめに} - -この文書ではFermi面描画ソフト「Fermi Surfer」についての解説を行っています. -Fermi Surferは東京大学の河村光晶 -が2012年頃から開発を行っていたもので, -2014年11月に公開されました. -Fermi面を描画しその上に各種物理量(超伝導ギャップ関数や軌道キャラクターなど) -をカラープロットするソフトウェアです. - -\section{MIT ライセンス} - -Copyright (c) 2014 Mitsuaki Kawamura - -\vspace{0.5cm} -以下に定める条件に従い、 -本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべての人に対し、 -ソフトウェアを無制限に扱うことを無償で許可します。 -これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、 -および/または販売する権利、およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。 - -\vspace{0.5cm} -上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。 - -\vspace{0.5cm} -ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。 -ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、 -それに限定されるものではありません。 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、 -ソフトウェアに起因または関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、 -その他の義務について何らの責任も負わないものとします。 - -\section{このパッケージに含まれているファイル} -\begin{description} -\item[\texttt{bin/fermisurfer.exe}] Windows用実行ファイル -\item[\texttt{doc/manual\_en.pdf}] マニュアル(英語) -\item[\texttt{doc/manual\_ja.pdf}] マニュアル(日本語) -\item[\texttt{examples/mgb2\_vfz.frmsf}] サンプル入力ファイル -\item[\texttt{src/fermisurfer.c}] ソースファイル -\item[\texttt{src/mac.diff}] Mac OSX用 パッチ -\item[\texttt{src/Makefile}] Linux用 Makefile -\item[\texttt{src/Makefile-mac}] Mac OSX用 Makefile -\end{description} - -\section{インストール手順} - -\subsection{Linuxの場合} - -\begin{enumerate} - -\item 必要なパッケージをインストール(既にパッケージが入っている場合は何も起こりません. ) - - \begin{itemize} - \item Debian/Ubuntu 等 - \begin{verbatim} - $ sudo aptitude install freeglut3-dev - \end{verbatim} - \item Red Hat Enterprise Linux/CentOS 等 - \begin{verbatim} - $ sudo yum install freeglut-devel.x86_64 - \end{verbatim} - \end{itemize} - -\item メイク - -\begin{verbatim} - $ cd ./src - $ make fermisurfer - $ make install -\end{verbatim} - -\end{enumerate} - -以上で実行可能ファイル \texttt{fermisurfer} が作られ、\verb|/usr/local/bin/|にコピーされます. - -\subsection{Mac OSX の場合} - -\begin{enumerate} - -\item Xcodeをあらかじめインストールしておく -\item ソースコードにパッチを当てる -\begin{verbatim} - $ cd ./src - $ patch -p1 < mac.diff -\end{verbatim} - -\item メイク -\begin{verbatim} - $ make -f Makefile-mac fermisurfer - $ make -f Makefile-mac install -\end{verbatim} - -\end{enumerate} - -以上で実行可能ファイル \texttt{fermisurfer} が作られ、\verb|/usr/local/bin/|にコピーされます. - -\subsection{Windowsの場合} - -\begin{enumerate} - -\item freeglutWindows Development Libraryのサイト -\begin{verbatim} -http://www.transmissionzero.co.uk/software/freeglut-devel/ -\end{verbatim} -内の「freeglut MSVC package」という項目から -\texttt{freeglut.dll}を含む\texttt{zip}ファイルを -ダウンロードし, 展開する. - -\item 展開したフォルダ内の\texttt{bin}というフォルダに入っている, -\texttt{freeglut.dll}を\texttt{fermisurfer.exe}のあるフォルダ(\verb|bin|)にコピーする. - -(注) \verb|bin\x64\|にも\verb|freeglut.dll|があるが, そちらは使わない. - -\item \verb|fermisurfer.exe|と\verb|freeglut.dll|は常に同じフォルダにおいておくこと. - -\end{enumerate} - -\section{Input file} - -\subsection{input fileの書式} - -用意するデータは, -\begin{itemize} -\item Brillouin領域分割数(3方向) -\item 逆格子ベクトル -\item バンド本数 -\item 軌道固有値(以下エネルギーと呼びます)の各バンド, $k$グリッド点での値 -\item カラープロットしたい物理量(以下物理量と呼びます)の各バンド, $k$グリッド点での値 -\end{itemize} -です. - -※ $k$グリッドの取り方 -$k$点の取り方として, ${\rm \Gamma}$点を含むグリッドと, -${\rm \Gamma}$点から半グリッド分だけずらしたグリッドの二つに対応しています(図1). -後者はプロットしたい物理量が${\rm \Gamma}$点で特異的になっている -場合等に使われる事を想定しています. - -上記データを次のとおりの書式で並べます(サンプルファイル \verb|mgb2_vfz.frmsf|の中身). - -\begin{verbatim} - 40 40 36 (1) - 0 (2) - 3 (3) - 1.0000000 0.57735026 -0.0000000 (4) - 0.0000000 1.1547005 0.0000000 (5) - 0.0000000 -0.0000000 0.87206507 (6) - 2.91340202E-02 (7) - 2.93242838E-02 - 2.98905596E-02 - 3.08193434E-02 - : - : - 0.14393796 - 0.12800488 - 0.0000000 (8) - 0.36269817 - 0.71675694 - 1.0535113 - 1.3644149 - : - : - -26.409407 - -19.318560 - -10.315671 -\end{verbatim} - -\begin{enumerate} - \renewcommand{\labelenumi}{(\arabic{enumi})} - \item $k$グリッド数 - \item ${\rm \Gamma}$点を含むグリッド(含まないグリッドでは1とする) - \item バンド本数 - \item 逆格子ベクトル1 (任意単位) - \item 逆格子ベクトル2 - \item 逆格子ベクトル3 - \item エネルギー (並び順は下記参照) - \item 物理量 (並び順は下記参照) -\end{enumerate} - -\subsection{C, fortranでの入力ファイルの書き出し方} - -・fortran - -\begin{verbatim} - real(4) :: bvec1(3), bvec2(3), bvec3(3) !逆格子ベクトル - integer :: nk1, nk2, nk3 !各逆格子ベクトルの方向の分割数 - integer :: ishift !グリットをシフトさせるか(=1)否か(=0) - integer :: nbnd !バンド数 - real(4) :: eig(nk3,nk2,nk1,nbnd) !エネルギー - real(4) :: x(nk3,nk2,nk1,nbnd) !物理量 - - integer :: ik1, ik2, ik3, ibnd, fo - - open(fo, file = “sample.frmsf”) - write(fo,*) nk1, nk2, nk3 - write(fo,*) ishift - write(fo,*) nbnd - write(fo,*) real(bvec1(1:3)) - write(fo,*) real(bvec2(1:3)) - write(fo,*) real(bvec3(1:3)) - do ibnd = 1, nbnd - do ik1 = 1, nk1 - do ik2 = 1, nk2 - do ik3 = 1, nk3 - write(fo,*) real(eig(ik3,ik2,ik1,ibnd)) - end do - end do - end do - end do - do ibnd = 1, nbnd - do ik1 = 1, nk1 - do ik2 = 1, nk2 - do ik3 = 1, nk3 - write(fo,*) real(x(ik3,ik2,ik1,ibnd)) - end do - end do - end do - end do - close(fo) -\end{verbatim} - -・C言語 - -\begin{verbatim} - float bvec1[3], bvec2[3], bvec3[3]; /*逆格子ベクトル*/ - int nk1, nk2, nk3; /*各逆格子ベクトルの方向の分割数*/ - int ishift; /*グリットをシフトさせるか(=1)否か(=0)*/ - int nbnd; /*バンド数*/ - float eig[nbnd][nk1][nk2][nk3]; /*エネルギー*/ - float x[nbnd][nk1][nk2][nk3]; /*物理量*/ - - FILE* fo; - int ibnd, ik1, ik2, ik3; - - fo = fopen(“sample.frmsf”, “w”); - ierr = fprintf(fo, "%d %d %d", nk1, nk2, nk3); - ierr = fprintf(fo, "%d, iswitch); - ierr = fprintf(fo, "%d, nbnd); - ierr = fprintf(fp, "%e %e %e", bvec1[0], bvec1[1], bvec1[2]); - ierr = fprintf(fp, "%e %e %e", bvec2[0], bvec2[1], bvec2[2]); - ierr = fprintf(fp, "%e %e %e", bvec3[0], bvec3[1], bvec3[2]); - for (ibnd = 0; ibnd < nbnd; ++ibnd) { - for (ik1 = 0; ik1 < nk1; ++ik1) { - for (ik2 = 0; ik2 < nk2; ++ik2) { - for (ik3 = 0; ik3 < nk3; ++ik3) { - ierr = fprintf(fo, "%e", eig[ibnd][ik1][ik2][ik3]); - } - } - } - } - for (ibnd = 0; ibnd < nbnd; ++ibnd) { - for (ik1 = 0; ik1 < nk1; ++ik1) { - for (ik2 = 0; ik2 < nk2; ++ik2) { - for (ik3 = 0; ik3 < nk3; ++ik3) { - ierr = fprintf(fo, "%e", x[ibnd][ik1][ik2][ik3]); - } - } - } - } - fclose(fo); -\end{verbatim} - -\section{操作方法} - -\subsection{Linuxの場合} -作成した実行可能ファイル\verb|fermisurfer|にパスが通っている状態で -\begin{verbatim} -$ fermisurfer mgb2_vfz.frmsf -\end{verbatim} -とコマンド, スペース, 入力ファイル名とタイプします. -(サンプルファイルの中身はMgB$_2$のFermi速度の$z$方向成分です. ) - -\subsection{Windowsの場合} - -入力ファイル(この場合は\verb|mgb2_vfz.frmsf|)を右クリックし, -メニューから「プログラムから開く」を選択し, -実行ファイルを\verb|fermisurfer.exe|に設定してください. - -\vspace{0.5cm} -このあとはLinux, Windows共通です. -\verb|fermisurfer|が起動すると, -まずファイルから読み取った情報が出力されます. - -\begin{verbatim} -##### Brillouin zone informations ##### - -k point grid : 40 40 36 -k point grid is not shifted -# of bands : 3 -bvec 1 : 1.000000 0.577350 -0.000000 -bvec 2 : 0.000000 1.154701 0.000000 -bvec 3 : 0.000000 -0.000000 0.872065 - -# of lines for BZ : 84 (1) - -##### Max. and Min. of each bands ##### - -Band Eig_Min. Eig_Max Mat_Min Mat_Max -1 -0.428153 0.056262 -24.048639 24.048639 (2) -2 -0.289572 0.121181 -23.320309 23.320309 (2) -3 -0.133566 0.497620 -43.651634 43.651634 (2) - -##### First Brillouin zone mode ##### - -band # of patchs -1 8824 (3) -2 29469 (3) -3 28315 (3) - -band # of nodeline -1 632 (4) -2 1524 (4) -3 2268 (4) - -##### Full color scale ##### - -Max. value : 22.283419 (5) -Min. value : -22.283419 (5) - -\end{verbatim} - -\begin{enumerate} - \renewcommand{\labelenumi}{(\arabic{enumi})} - \item Brillouin領域の境界を表示する線の数. - \item それぞれのバンドにおけるエネルギーと物理量の最小値・最大値. - \item それぞれのバンドにおけるパッチ(Fermi面を構成する平面)の数. - \item それぞれのバンドにおけるnode line (後述)の本数. - \item 物理量のFermi面における最大値と最小値. - この数字がカラーバーの最大・最小に対応します. - 下の例では一番青いところが-22.283419, 一番赤いところが22.283419となります. - (2)で表示されているのはBrillouin領域全体のものです. -\end{enumerate} - -次に操作方法が出力され, Fermi面が描画されます. - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/start.eps} - \caption{Fermisurferを起動した直後の画面.} - \label{fig_start} -\end{figure} - -\begin{itemize} -\item マウスのドラッグによる回転が出来ます. -\item マウスのホイールを使っての拡大・縮小が出来ます. -\item ウィンドウの大きさを変えることもできます. -\item カーソルキーを使ってウィンドウ内で上下左右に図を動かせます. -\item ウィンドウ内でマウスの右クリックをするとメニューが表示されます. -\end{itemize} - -次から右クリックで表示されるメニューを説明します. - -\subsection{Band} - -バンド毎の表示on/offを切り替えます(図\ref{fig_band}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/band.eps} - \caption{\texttt{Band} メニューで3番目のバンドの表示/非表示を切り替える.} - \label{fig_band} -\end{figure} - -\subsection{Mouse Drag} - -マウスの左ボタンドラッグを行った時の動作を変更します. - -\begin{description} -\item[Rotate(デフォルト)] ドラッグをした方向に図形を回転させます. -\item[Scale] 上方にドラッグすると図形を拡大, 下方にドラッグすると図形を縮小します. -\item[Translate] ドラッグした方向に図形を動かします. -\end{description} - -\subsection{Shift Fermi energy} - -Fermiエネルギー(デフォルトでは0)を任意の値にずらします. -このメニューを選択すると次のようにインプット中の最小のエネルギー, -最大のエネルギー, -現在のFermiエネルギーが標準出力として表示されます. -\begin{verbatim} -Min Max E_F --0.428153 0.497620 0.000000 -Fermi energy shift : -\end{verbatim} -次に新しいFermiエネルギーを入力すると, -Fermi面が再描画されます (図\ref{fig_shift}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/shift.eps} - \caption{\texttt{Shift Fermi energy}メニューで - Fermi エネルギーを0 Ryから0.1 Ryに変える.} - \label{fig_shift} -\end{figure} - -\subsection{Background color} - -背景色を黒または白に切り替えます. -Brillouin Zoneの枠線も白/黒と切り替わります (図\ref{fig_background}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/background.eps} - \caption{\texttt{Background color}メニューで背景色を白/黒に切り替える.} - \label{fig_background} -\end{figure} - -\subsection{Color scale mode} - -Fermi面の色表示のさせ方を変更します(図\ref{fig_colorscale}). -\begin{description} -\item[Auto(デフォルト)] - カラースケールの範囲をFermi面上での物理量の最小値から最大値までとします. -\item[Manual] カラースケールの範囲を標準入力から設定します. -\item[Unicolor] 物理量に関係なく, 各バンド毎に単色でFermi面を塗ります. -\item[Periodic] 周期的な量のプロットに用います。 - 物理量が - 0 $\rightarrow$ $\pi/3$ $\rightarrow$ $2\pi/3$ $\rightarrow$ $\pi$ $\rightarrow$ - $4\pi/3$ $\rightarrow$ $5\pi/3$ $\rightarrow$ $2\pi$ - と変化するに連れて色が - 赤$\rightarrow$黄$\rightarrow$緑$\rightarrow$シアン$\rightarrow$青$\rightarrow$ - マゼンタ$\rightarrow$赤と変わります. -\end{description} - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/colorscale.eps} - \caption{\texttt{Color scale mode}メニュー.} - \label{fig_colorscale} -\end{figure} - -\subsection{Brillouin zone} - -描画範囲をFirst Brillouin Zone/Primitive Brillouin Zoneと切り替える事が出来ます -(図\ref{fig_brillouinzone}). -\begin{description} -\item[Fisrst Brillouin Zone] ${\rm \Gamma}$ 点から一番近いBragg面で囲まれた領域 -\item[Primitive Brillouine Zone] 逆格子ベクトルを辺とする平行6面体領域 -\end{description} - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/brillouinzone.eps} - \caption{\texttt{Brillouin zone} メニューでBrillouin領域のとり方を変更する.} - \label{fig_brillouinzone} -\end{figure} - -\subsection{Node line} - -物理量が0となるところに引く線(node line)のOn/Offを切り替えます(図\ref{fig_nodeline}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/nodeline.eps} - \caption{\texttt{Node line} メニューでnode lineの表示/非表示を切り替える.} - \label{fig_nodeline} -\end{figure} - -\subsection{Color bar On/Off} - -カラーバーの表示/非表示を切り替えます(図 \ref{fig_colorbar}). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/colorbar.eps} - \caption{\texttt{Color bar On/Off}メニューでカラーバーの表示/非表示を切り替える.} - \label{fig_colorbar} -\end{figure} - -\subsection{Stereogram} - -裸眼立体視用の図の表示/非表示を切り替えます(図 \ref{fig_stereogram}). -\begin{description} -\item[None (デフォルト)] 立体視を無効にします. -\item[Parallel] 平行法用の図を表示します. -\item[Cross] 交差法用の図を表示します. -\end{description} - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/stereogram.eps} - \caption{\texttt{Stereogram} メニューで立体視用画像を表示する.} - \label{fig_stereogram} -\end{figure} - -\subsection{Tetrahedron} - -四面体の切り方を変えます(デフォルトは\texttt{tetra \# 1}). -図が綺麗になる可能性がありますが, -多くの場合は逆に図がギザギザして汚くなるようです. - -\subsection{Exit} - -Fermi Surferを終了します. - -\section{ギャラリー} - -IrO$_2$のHall係数に対するFermi面上の各軌道からの寄与 -(Fig. \ref{fig_iro2}. 理化学研究所 有田グループ 佐野航氏提供). - -\begin{figure}[!ht] - \includegraphics[width=17cm]{figs/iro2.eps} - \caption{IrO$_2$のHall係数に対するFermi面上の各軌道からの寄与.} - \label{fig_iro2} -\end{figure} - -\section{謝辞} - -東京大学物性研究所 小西優祐氏には, Mac OSXでの動作チェックおよびMakefile, -パッチの提供をしていただいたことに感謝する. - -\section{問い合わせ先} - -プログラムのバグや質問は以下のフォーラムへご投稿ください. -\begin{verbatim} -http://sourceforge.jp/projects/fermisurfer/forums/ -\end{verbatim} - -開発に参加したい方は以下の連絡先にて受け付けております. - -東京大学物性研究所 - -河村光晶 - -\verb|mkawamura@issp.u-tokyo.ac.jp| - -\end{document} diff --git a/doc/manual_right_en.html b/doc/manual_right_en.html index 755e397..c97d74f 100644 --- a/doc/manual_right_en.html +++ b/doc/manual_right_en.html @@ -18,7 +18,7 @@

Manual for FermiSurfer

-

Version 1.4

+

Version 1.5

Mitsuaki Kawamura


@@ -59,9 +59,7 @@

1, Introduction

doc/manual_ja.pdf : Manual (Japanese)

examples/mgb2_vfz.frmsf : Sample input file

src/fermisurfer.c : Source file

-

src/mac.diff : Patch for Mac OSX

-

src/Makefile : Makefile for Linux

-

src/Makefile-mac : Makefile for Mac OSX

+

src/Makefile : Makefile for Linux & Mac OSX


4, Install

@@ -93,16 +91,17 @@

1, Introduction

  1. Install Xcode.

  2. -
  3. Patch the source code.

    +
  4. Open Makefile with an editor, and delete # + below #mac.

    
     $ cd ./src
    -$ patch -p1 < mac.diff
    +$ emacs Makefile
             
  5. Make.

    
    -$ make -f Makefile-mac fermisurfer
    -$ make -f Makefile-mac install
    +$ make fermisurfer
    +$ make install
             

    Then a binary file fermisurfer is generated and put in /usr/local/bin/.

  6. @@ -110,17 +109,7 @@

    1, Introduction


    4.3, Installation in Windows

    -
      -
    1. Download the zip file which contains freeglut.dll - from "freeglut Windows Development Library" site

      -
      
      -http://www.transmissionzero.co.uk/software/freeglut-devel/
      -        
      -

      (in "freeglut MSVC package" item). Then, unzip it.

    2. -
    3. copy .\bin\freeglut.dll to the folder - which contains fermisurfer.exe (bin). - (You should not use .\bin\x64\freeglut.dll)

    4. -
    +

    Use an executable bin/fermisurfer.exe


    5, Input file

    diff --git a/doc/manual_right_ja.html b/doc/manual_right_ja.html index 206adc9..adeb3b1 100644 --- a/doc/manual_right_ja.html +++ b/doc/manual_right_ja.html @@ -18,7 +18,7 @@

    FermiSurferマニュアル

    -

    バージョン1.4

    +

    バージョン1.5

    河村光晶


    1, はじめに

    @@ -58,9 +58,7 @@

    doc/manual_ja.pdf : マニュアル(日本語)

    examples/mgb2_vfz.frmsf : サンプル入力ファイル

    src/fermisurfer.c : ソースファイル

    -

    src/mac.diff : Mac OSX用 パッチ

    -

    src/Makefile : Linux用 Makefile

    -

    src/Makefile-mac : Mac OSX用 Makefile

    +

    src/Makefile : Makefile


    4, インストール手順

    @@ -96,16 +94,16 @@
    1. Xcodeをあらかじめインストールしておく

    2. -
    3. ソースコードにパッチを当てる

      +
    4. Makefileを適当なエディタで開いて#macの下の行の#を消す.

      
       $ cd ./src
      -$ patch -p1 < mac.diff
      +$ emacs Makefile 
               
    5. メイク

      
      -$ make -f Makefile-mac fermisurfer
      -$ make -f Makefile-mac install
      +$ make fermisurfer
      +$ make install
               
    @@ -114,21 +112,7 @@

    4.3, Windowsの場合

    -
      -
    1. freeglutWindows Development Libraryのサイト

      -
      
      -http://www.transmissionzero.co.uk/software/freeglut-devel/
      -        
      -

      内の「freeglut MSVC package」という項目から freeglut.dllを含む - zipファイルを ダウンロードし, 展開する.

    2. -
    3. 展開したフォルダ内のbinというフォルダに入っている, - freeglut.dllfermisurfer.exe - のあるフォルダ(bin)にコピーする.

      -

      (注) bin\x64\にもfreeglut.dllがあるが, - そちらは使わない.

    4. -
    5. fermisurfer.exefreeglut.dllは - 常に同じフォルダにおいておくこと.

    6. -
    +

    実行可能ファイルbin/fermisurfer.exeを直接実行します.


    5, Input file

    diff --git a/examples/mgb2_vfz.frmsf b/examples/mgb2_vfz.frmsf index 886616e..9e301d0 100644 --- a/examples/mgb2_vfz.frmsf +++ b/examples/mgb2_vfz.frmsf @@ -1,5 +1,5 @@ 40 40 36 - 0 + 1 3 1.0000000 0.57735026 -0.0000000 0.0000000 1.1547005 0.0000000 diff --git a/src/Makefile b/src/Makefile index 615ac13..ef0bf04 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,12 +1,24 @@ -fermisurfer:fermisurfer.c - gcc fermisurfer.c -fopenmp -O3 -lglut -lGLU -lGL -lm -o fermisurfer - -install: - sudo cp fermisurfer /usr/local/bin/fermisurfer - -uninstall: - sudo rm /usr/local/bin/fermisurfer - -clean: - rm fermisurfer - + +CC = gcc +CFLAGS=-fopenmp -O3 -lglut -lGLU -lGL -lm -g + +# for mac +#CFLAGS=-D mac -O3 -lglut -lGLU -lGL -lm + +all:fermisurfer bxsf2frmsf + +fermisurfer:fermisurfer.c + $(CC) $< $(CFLAGS) -o $@ + +bxsf2frmsf:bxsf2frmsf.c + $(CC) $< $(CFLAGS) -o $@ + +install: + sudo cp fermisurfer /usr/local/bin/fermisurfer + +uninstall: + sudo rm /usr/local/bin/fermisurfer + +clean: + rm -rf fermisurfer bxsf2frmsf + diff --git a/src/bxsf2frmsf.c b/src/bxsf2frmsf.c new file mode 100644 index 0000000..ecbc7c4 --- /dev/null +++ b/src/bxsf2frmsf.c @@ -0,0 +1,294 @@ +/* + The MIT License (MIT) + + Copyright (c) 2014 Mitsuaki KAWAMURA + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +#include +#include +#include +#include + +int nb; +int ng[3]; + +double bvec[3][3]; + +double ****eig; +double *****vf; + +void read_dat(char *fname/**<[in] fname Input file name*/) { + FILE *fp; + char ctmp[256], ctmpEF1[16], ctmpEF2[16]; + int ierr, ii, ib, ik0, ik1, ik2; + char *cerr; + double EF; + + if ((fp = fopen(fname, "r")) == NULL) { + printf("file open error!!\n"); + printf(" Press any key to exit.\n"); + getchar(); + exit(EXIT_FAILURE); + } + printf("\n##### Reading BXSF file %s #####\n\n", fname); + + cerr = fgets(ctmp, 256, fp); + while (strstr(ctmp, "Fermi Energy:") == NULL) { + cerr = fgets(ctmp, 256, fp); + } + ierr = sscanf(ctmp, "%s %s %lf", ctmpEF1, ctmpEF2, &EF); + printf(" Fermi energy : %le\n", EF); + + cerr = fgets(ctmp, 256, fp); + while (strstr(ctmp, "BEGIN_BLOCK_BANDGRID_3D") == NULL) { + cerr = fgets(ctmp, 256, fp); + } + cerr = fgets(ctmp, 256, fp); + cerr = fgets(ctmp, 256, fp); + + cerr = fgets(ctmp, 256, fp); + ierr = sscanf(ctmp, "%d", &nb); + printf(" Number of bands : %d \n", nb); + cerr = fgets(ctmp, 256, fp); + ierr = sscanf(ctmp, "%d%d%d", &ng[0], &ng[1], &ng[2]); + for (ii = 0; ii < 3; ii++) ng[ii] -= 1; + printf(" k point grid : %d %d %d \n", ng[0], ng[1], ng[2]); + + cerr = fgets(ctmp, 256, fp); + for (ii = 0; ii < 3; ++ii) { + cerr = fgets(ctmp, 256, fp); + ierr = sscanf(ctmp, "%le%le%le", &bvec[0][ii], &bvec[1][ii], &bvec[2][ii]); + printf(" bvec %d : %f %f %f \n", ii + 1, bvec[0][ii], bvec[1][ii], bvec[2][ii]); + } + + eig = (double****)malloc(nb * sizeof(double***)); + for (ib = 0; ib < nb; ib++) { + eig[ib] = (double***)malloc((ng[0] + 1) * sizeof(double**)); + for (ik0 = 0; ik0 <= ng[0]; ik0++) { + eig[ib][ik0] = (double**)malloc((ng[1] + 1) * sizeof(double*)); + for (ik1 = 0; ik1 <= ng[1]; ik1++) { + eig[ib][ik0][ik1] = (double*)malloc((ng[2] + 1) * sizeof(double)); + }/*for (ik1 = 0; ik1 < ng[1]; ik1++)*/ + }/*for (ik0 = 0; ik0 < ng[0]; ik0++)*/ + }/*for (ib = 0; ib < nb; ib++)*/ + + for (ib = 0; ib < nb; ib++) { + cerr = fgets(ctmp, 256, fp); + printf(" Reading %s", ctmp); + + for (ik0 = 0; ik0 <= ng[0]; ik0++) { + for (ik1 = 0; ik1 <= ng[1]; ik1++) { + for (ik2 = 0; ik2 <= ng[2]; ik2++) { + ierr = fscanf(fp, "%le", &eig[ib][ik0][ik1][ik2]); + eig[ib][ik0][ik1][ik2] -= EF; + }/*for (ik2 = 0; ik2 < ng[2]; ik2++)*/ + }/*for (ik1 = 0; ik1 < ng[1]; ik1++)*/ + }/*for (ik0 = 0; ik0 < ng[0]; ik0++)*/ + + cerr = fgets(ctmp, 256, fp); + + }/*for (ib = 0; ib < nb; ib++)*/ +} + +void fvel() { + /* + !-------------------------------------------------------------------------- + ! + ! This routine compute the Fermi verocity from differentiate of e_{n k}. + ! + */ + int ik0, ik1, ik2, ib, ii, jj, ikv[3], ikp[3], ikm[3]; + double de[3]; + double det, avec[3][3], alength[3]; + + printf("\n##### Compute the Fermi velocity #####\n\n"); + + /* + Compute direct lattice vectors + */ + det = -bvec[0][2] * bvec[1][1] * bvec[2][0] + + bvec[0][1] * bvec[1][2] * bvec[2][0] + + bvec[0][2] * bvec[1][0] * bvec[2][1] + - bvec[0][0] * bvec[1][2] * bvec[2][1] + - bvec[0][1] * bvec[1][0] * bvec[2][2] + + bvec[0][0] * bvec[1][1] * bvec[2][2]; + + avec[0][0] = -bvec[1][2] * bvec[2][1] + bvec[1][1] * bvec[2][2]; + avec[0][1] = bvec[0][2] * bvec[2][1] - bvec[0][1] * bvec[2][2]; + avec[0][2] = -bvec[0][2] * bvec[1][1] + bvec[0][1] * bvec[1][2]; + avec[1][0] = bvec[1][2] * bvec[2][0] - bvec[1][0] * bvec[2][2]; + avec[1][1] = -bvec[0][2] * bvec[2][0] + bvec[0][0] * bvec[2][2]; + avec[1][2] = bvec[0][2] * bvec[1][0] - bvec[0][0] * bvec[1][2]; + avec[2][0] = -bvec[1][1] * bvec[2][0] + bvec[1][0] * bvec[2][1]; + avec[2][1] = bvec[0][1] * bvec[2][0] - bvec[0][0] * bvec[2][1]; + avec[2][2] = -bvec[0][1] * bvec[1][0] + bvec[0][0] * bvec[1][1]; + for (ii = 0; ii < 3; ++ii) { + for (jj = 0; jj < 3; ++jj) avec[ii][jj] /= det; + printf(" avec %d : %f %f %f \n", ii + 1, avec[ii][0], avec[ii][1], avec[ii][2]); + } + + for (ii = 0; ii < 3; ii++) + alength[ii] = sqrt( + avec[0][ii] * avec[0][ii] + avec[1][ii] * avec[1][ii] + avec[2][ii] * avec[2][ii]); + printf(" alength : %f %f %f \n", alength[0], alength[1], alength[2]); + /* + malloc fermi velocity + */ + vf = (double*****)malloc(nb * sizeof(double****)); + for (ib = 0; ib < nb; ib++) { + vf[ib] = (double****)malloc(ng[0] * sizeof(double***)); + for (ik0 = 0; ik0 < ng[0]; ik0++) { + vf[ib][ik0] = (double***)malloc(ng[1] * sizeof(double**)); + for (ik1 = 0; ik1 < ng[1]; ik1++) { + vf[ib][ik0][ik1] = (double**)malloc(ng[2] * sizeof(double*)); + for (ik2 = 0; ik2 < ng[2]; ik2++) { + vf[ib][ik0][ik1][ik2] = (double*)malloc(7 * sizeof(double)); + } + }/*for (ik1 = 0; ik1 < ng[1]; ik1++)*/ + }/*for (ik0 = 0; ik0 < ng[0]; ik0++)*/ + }/*for (ib = 0; ib < nb; ib++)*/ + + for (ik0 = 0; ik0 < ng[0]; ik0++) { + ikv[0] = ik0; + for (ik1 = 0; ik1 < ng[1]; ik1++) { + ikv[1] = ik1; + for (ik2 = 0; ik2 < ng[2]; ik2++) { + ikv[2] = ik2; + + for (ib = 0; ib < nb; ib++) { + for (ii = 0; ii < 3; ii++) { + + for (jj = 0; jj < 3; jj++) { + ikp[jj] = ikv[jj]; + ikm[jj] = ikv[jj]; + } + if(ikv[ii] == ng[ii] - 1) ikp[ii] = 0; + else ikp[ii] += 1; + + if (ikv[ii] == 0) ikm[ii] = ng[ii] - 1; + else ikm[ii] -= 1; + + de[ii] = eig[ib][ikp[0]][ikp[1]][ikp[2]] + - eig[ib][ikm[0]][ikm[1]][ikm[2]]; + de[ii] *= 0.5 * (double)ng[ii]; + }/*for (ii = 0; ii < 3; ii++)*/ + + for (ii = 0; ii < 3; ii++) { + vf[ib][ik0][ik1][ik2][ii] = de[ii] * alength[ii]; + vf[ib][ik0][ik1][ik2][ii + 3] = + avec[0][ii] * de[0] + avec[1][ii] * de[1] + avec[2][ii] * de[2]; + }/*for (ii = 0; ii < 3; ii++)*/ + vf[ib][ik0][ik1][ik2][6] = sqrt( + vf[ib][ik0][ik1][ik2][3] * vf[ib][ik0][ik1][ik2][3] + + vf[ib][ik0][ik1][ik2][4] * vf[ib][ik0][ik1][ik2][4] + + vf[ib][ik0][ik1][ik2][5] * vf[ib][ik0][ik1][ik2][5]); + + }/*for (ib = 0; ib < nb; ib++)*/ + }/* for (ik2 = 0; ik2 < ng[2]; ik2++)*/ + }/*for (ik1 = 0; ik1 < ng[1]; ik1++)*/ + }/* for (ik0 = 0; ik0 < ng[0]; ik0++)*/ +}/*void fvel()*/ + + +void write_file(char *fname1, char *ext, int component) { + FILE* fo; + int ierr, ibnd, ik0, ik1, ik2, ii; + char fname2[256]; + char *p; + + ii = 0; + if (strstr(fname1, ".bxsf") != NULL) { + for (p = &fname1[0]; p < strstr(fname1, ".bxsf"); p++) fname2[ii++] = *p; + } + else if (strstr(fname1, ".BXSF") != NULL) { + for (p = &fname1[0]; p < strstr(fname1, ".BXSF"); p++) fname2[ii++] = *p; + } + else if (strstr(fname1, ".Bxsf") != NULL) { + for (p = &fname1[0]; p < strstr(fname1, ".Bxsf"); p++) fname2[ii++] = *p; + } + else { + printf("ERROR! Extension shoud be .bxsf, .BXSF, or .Bxsf !\n"); + printf(" Press any key to exit.\n"); + getchar(); + exit(-1); + } + sprintf(&fname2[ii], "%s", ext); + + printf(" %s\n", fname2); + + fo = fopen(fname2, "w"); + ierr = fprintf(fo, "%d %d %d\n", ng[0], ng[1], ng[2]); + ierr = fprintf(fo, "%d\n", 1); + ierr = fprintf(fo, "%d\n", nb); + ierr = fprintf(fo, "%e %e %e\n", bvec[0][0], bvec[1][0], bvec[2][0]); + ierr = fprintf(fo, "%e %e %e\n", bvec[0][1], bvec[1][1], bvec[2][1]); + ierr = fprintf(fo, "%e %e %e\n", bvec[0][2], bvec[1][2], bvec[2][2]); + + for (ibnd = 0; ibnd < nb; ++ibnd) { + for (ik0 = 0; ik0 < ng[0]; ++ik0) { + for (ik1 = 0; ik1 < ng[1]; ++ik1) { + for (ik2 = 0; ik2 < ng[2]; ++ik2) { + ierr = fprintf(fo, "%e\n", eig[ibnd][ik0][ik1][ik2]); + } + } + } + } + for (ibnd = 0; ibnd < nb; ++ibnd) { + for (ik0 = 0; ik0 < ng[0]; ++ik0) { + for (ik1 = 0; ik1 < ng[1]; ++ik1) { + for (ik2 = 0; ik2 < ng[2]; ++ik2) { + ierr = fprintf(fo, "%e\n", vf[ibnd][ik0][ik1][ik2][component]); + } + } + } + } + fclose(fo); + +}/*void write_file()*/ + +int main( + int argc /**< [in] */, + char *argv[] /**< [in] */) +{ + if (argc < 2) { + printf("\n\nInput file is not specified !\n"); + printf(" Press any key to exit.\n"); + getchar(); + exit(-1); + } + + read_dat(argv[1]); + + fvel(); + + printf("\n##### Output files #####\n\n"); + + write_file(argv[1], "_vfa1.frmsf\0", 0); + write_file(argv[1], "_vfa2.frmsf\0", 1); + write_file(argv[1], "_vfa3.frmsf\0", 2); + write_file(argv[1], "_vfx.frmsf\0", 3); + write_file(argv[1], "_vfy.frmsf\0", 4); + write_file(argv[1], "_vfz.frmsf\0", 5); + write_file(argv[1], "_vf.frmsf\0", 6); + + printf("\n##### DONE #####\n"); + printf(" Press any key to exit.\n"); + getchar(); +} diff --git a/src/fermisurfer.c b/src/fermisurfer.c index 87a832d..7ceff70 100644 --- a/src/fermisurfer.c +++ b/src/fermisurfer.c @@ -48,6 +48,7 @@ */ int ng[3]; /**< BZ grids */ int lshift; /**< Switch for shifted Brillouin zone */ +int shiftk[3]; int nb; /**< The number of Bands */ GLfloat bvec[3][3]; /**< Resiplocal lattice vector */ GLfloat ****eig; /**< Eigenvalues [nb][ng[0]][ng[1]][ng[2]] */ @@ -117,7 +118,7 @@ GLfloat blue[] = {0.0, 0.0, 1.0, 1.0}; /**< Blue color code */ */ int query; /**< Query switch */ int corner[6][4]; /**< Corners of tetrahedron */ -GLfloat def = 0.0; /**< Shift of Fermi energy */ +GLfloat EF = 0.0; /**< Fermi energy */ enum { MOUSE_SCROLL_UP = 3, /**< Mouse wheel up */ @@ -128,13 +129,15 @@ enum */ void read_file(char *fname/**<[in] fname Input file name*/) { - int ib, i, i1, i2, i3, ierr; + int ib, i, i0, i1, i2, ii0, ii1, ii2, ierr; FILE *fp; /* Open input file. */ if ((fp = fopen(fname, "r")) == NULL) { printf("file open error!!\n"); + printf(" Press any key to exit.\n"); + getchar(); exit(EXIT_FAILURE); } printf("\n##### Brillouin zone informations ##### \n\n"); @@ -149,11 +152,18 @@ void read_file(char *fname/**<[in] fname Input file name*/) */ ierr = fscanf(fp, "%d", &lshift); if(ierr == 0) printf("error ! reading lshift"); - if(lshift == 0){ - printf("k point grid is not shifted \n"); + + if (lshift == 0) { + printf("k point grid is the Monkhorst-Pack grid. \n"); + for (i = 0; i < 3; i++) shiftk[i] = (ng[i] + 1) % 2; } else if(lshift == 1){ - printf("k point grid is shifted on 0.5, 0.5, 0.5 . \n"); + printf("k point grid starts from Gamma. \n"); + for (i = 0; i < 3; i++) shiftk[i] = 0; + } + else if(lshift == 2){ + printf("k point grid starts from Gamma + a half grid. \n"); + for (i = 0; i < 3; i++) shiftk[i] = 1; } else{ exit(0); @@ -184,12 +194,12 @@ void read_file(char *fname/**<[in] fname Input file name*/) for (ib = 0; ib < nb; ib++){ eig[ib] = (GLfloat***)malloc(ng[0] * sizeof(GLfloat**)); mat[ib] = (GLfloat***)malloc(ng[0] * sizeof(GLfloat**)); - for (i1 = 0; i1 < ng[0]; i1++){ - eig[ib][i1] = (GLfloat**)malloc(ng[1] * sizeof(GLfloat*)); - mat[ib][i1] = (GLfloat**)malloc(ng[1] * sizeof(GLfloat*)); - for (i2 = 0; i2 < ng[1]; i2++){ - eig[ib][i1][i2] = (GLfloat*)malloc(ng[2] * sizeof(GLfloat)); - mat[ib][i1][i2] = (GLfloat*)malloc(ng[2] * sizeof(GLfloat)); + for (i0 = 0; i0 < ng[0]; i0++){ + eig[ib][i0] = (GLfloat**)malloc(ng[1] * sizeof(GLfloat*)); + mat[ib][i0] = (GLfloat**)malloc(ng[1] * sizeof(GLfloat*)); + for (i1 = 0; i1 < ng[1]; i1++){ + eig[ib][i0][i1] = (GLfloat*)malloc(ng[2] * sizeof(GLfloat)); + mat[ib][i0][i1] = (GLfloat*)malloc(ng[2] * sizeof(GLfloat)); } } } @@ -197,10 +207,25 @@ void read_file(char *fname/**<[in] fname Input file name*/) Kohn-Sham energies */ for (ib = 0; ib < nb; ++ib) { - for (i1 = 0; i1 < ng[0]; ++i1) { - for (i2 = 0; i2 < ng[1]; ++i2) { - for (i3 = 0; i3 < ng[2]; ++i3) { - ierr = fscanf(fp, "%e", &eig[ib][i1][i2][i3]); + for (i0 = 0; i0 < ng[0]; ++i0) { + if (lshift != 0) ii0 = i0; + else { + ii0 = i0 + (ng[0] + 1) / 2; + if (ii0 >= ng[0]) ii0 -= ng[0]; + } + for (i1 = 0; i1 < ng[1]; ++i1) { + if (lshift != 0) ii1 = i1; + else { + ii1 = i1 + (ng[1] + 1) / 2; + if (ii1 >= ng[1]) ii1 -= ng[1]; + } + for (i2 = 0; i2 < ng[2]; ++i2) { + if (lshift != 0) ii2 = i2; + else { + ii2 = i2 + (ng[2] + 1) / 2; + if (ii2 >= ng[2]) ii2 -= ng[2]; + } + ierr = fscanf(fp, "%e", &eig[ib][ii0][ii1][ii2]); } } } @@ -209,10 +234,25 @@ void read_file(char *fname/**<[in] fname Input file name*/) Matrix elements */ for (ib = 0; ib < nb; ++ib) { - for (i1 = 0; i1 < ng[0]; ++i1) { - for (i2 = 0; i2 < ng[1]; ++i2) { - for (i3 = 0; i3 < ng[2]; ++i3) { - ierr = fscanf(fp, "%e", &mat[ib][i1][i2][i3]); + for (i0 = 0; i0 < ng[0]; ++i0) { + if (lshift != 0) ii0 = i0; + else { + ii0 = i0 + (ng[0] + 1) / 2; + if (ii0 >= ng[0]) ii0 -= ng[0]; + } + for (i1 = 0; i1 < ng[1]; ++i1) { + if (lshift != 0) ii1 = i1; + else { + ii1 = i1 + (ng[1] + 1) / 2; + if (ii1 >= ng[1]) ii1 -= ng[1]; + } + for (i2 = 0; i2 < ng[2]; ++i2) { + if (lshift != 0) ii2 = i2; + else { + ii2 = i2 + (ng[2] + 1) / 2; + if (ii2 >= ng[2]) ii2 -= ng[2]; + } + ierr = fscanf(fp, "%e", &mat[ib][ii0][ii1][ii2]); } } } @@ -382,20 +422,20 @@ void init_corner(){ * Compute Bragg vetor */ void bragg_vector(){ - int i1, i2, i3, i, ibr; + int i0, i1, i2, i, ibr; /**/ ibr = 0; /**/ - for(i1 = -1; i1 <= 1; ++i1){ - for(i2 = -1; i2 <= 1; ++i2){ - for(i3 = -1; i3 <= 1; ++i3){ + for(i0 = -1; i0 <= 1; ++i0){ + for(i1 = -1; i1 <= 1; ++i1){ + for(i2 = -1; i2 <= 1; ++i2){ /**/ - if(i1 == 0 && i2 == 0 && i3 ==0){ + if(i0 == 0 && i1 == 0 && i2 ==0){ } else { - for(i = 0; i < 3; ++i) bragg[ibr][i] = (( GLfloat)i1 * bvec[0][i] - + (GLfloat)i2 * bvec[1][i] - + (GLfloat)i3 * bvec[2][i]) * 0.5; + for(i = 0; i < 3; ++i) bragg[ibr][i] = (( GLfloat)i0 * bvec[0][i] + + (GLfloat)i1 * bvec[1][i] + + (GLfloat)i2 * bvec[2][i]) * 0.5; /**/ brnrm[ibr] = bragg[ibr][0] * bragg[ibr][0] + bragg[ibr][1] * bragg[ibr][1] @@ -551,7 +591,7 @@ void bz_lines(){ * Max and Minimum in Brillouine zone */ void max_and_min_bz(){ - int ib, i1, i2, i3; + int ib, i0, i1, i2; GLfloat eigmin, eigmax, matmin, matmax; /**/ printf("\n##### Max. and Min. of each bands ##### \n\n"); @@ -561,13 +601,13 @@ void max_and_min_bz(){ eigmin = 100000000.0000; matmax = - 100000000.0000; matmin = 100000000.0000; - for (i1 = 0; i1 < ng[0]; ++i1) { - for (i2 = 0; i2 < ng[1]; ++i2) { - for (i3 = 0; i3 < ng[2]; ++i3) { - if(eig[ib][i1][i2][i3] > eigmax) eigmax = eig[ib][i1][i2][i3]; - if(eig[ib][i1][i2][i3] < eigmin) eigmin = eig[ib][i1][i2][i3]; - if(mat[ib][i1][i2][i3] > matmax) matmax = mat[ib][i1][i2][i3]; - if(mat[ib][i1][i2][i3] < matmin) matmin = mat[ib][i1][i2][i3]; + for (i0 = 0; i0 < ng[0]; ++i0) { + for (i1 = 0; i1 < ng[1]; ++i1) { + for (i2 = 0; i2 < ng[2]; ++i2) { + if(eig[ib][i0][i1][i2] > eigmax) eigmax = eig[ib][i0][i1][i2]; + if(eig[ib][i0][i1][i2] < eigmin) eigmin = eig[ib][i0][i1][i2]; + if(mat[ib][i0][i1][i2] > matmax) matmax = mat[ib][i0][i1][i2]; + if(mat[ib][i0][i1][i2] < matmin) matmin = mat[ib][i0][i1][i2]; } } } @@ -796,94 +836,92 @@ void tetrahedron( */ void fermi_patch() { - int ib, i1, i2, i3, ii1, ii2, ii3, j1, j2, j3, start[3], i, j; + int ib, i0, i1, i2, ii0, ii1, ii2, j0, j1, j2, start[3], i, j; GLfloat kvec1[8][3], eig1[8], mat1[8]; /**/ if(fbz == 1){ - for(i1 = 0; i1 < 3;++i1) start[i1] = - ng[i1]; + for(i0 = 0; i0 < 3;++i0) start[i0] = - ng[i0]; } else{ - for(i1 = 0; i1 < 3;++i1) start[i1] = 0; + for(i0 = 0; i0 < 3;++i0) start[i0] = 0; } /**/ #pragma omp parallel default(none) \ - shared(nb,ntri,start,ng,eig,mat,lshift) \ - private(ib,j1,j2,j3,i1,i2,i3,ii1,ii2,ii3,kvec1,eig1,mat1,i,j) + shared(nb,ntri,start,ng,eig,EF,mat,shiftk) \ + private(ib,j0,j1,j2,i0,i1,i2,ii0,ii1,ii2,kvec1,eig1,mat1,i,j) { #pragma omp for nowait for (ib = 0; ib < nb; ++ib) { ntri[ib] = 0; - for (j1 = start[0]; j1 < ng[0]; ++j1) { - for (j2 = start[1]; j2 < ng[1]; ++j2) { - for (j3 = start[2]; j3 < ng[2]; ++j3) { + for (j0 = start[0]; j0 < ng[0]; ++j0) { + for (j1 = start[1]; j1 < ng[1]; ++j1) { + for (j2 = start[2]; j2 < ng[2]; ++j2) { /**/ + i0 = j0; i1 = j1; i2 = j2; - i3 = j3; + ii0 = j0 + 1; ii1 = j1 + 1; ii2 = j2 + 1; - ii3 = j3 + 1; /**/ - kvec1[0][0] = (GLfloat)i1 / (GLfloat)ng[0]; - kvec1[1][0] = (GLfloat)i1 / (GLfloat)ng[0]; - kvec1[2][0] = (GLfloat)i1 / (GLfloat)ng[0]; - kvec1[3][0] = (GLfloat)i1 / (GLfloat)ng[0]; - kvec1[4][0] = (GLfloat)ii1 / (GLfloat)ng[0]; - kvec1[5][0] = (GLfloat)ii1 / (GLfloat)ng[0]; - kvec1[6][0] = (GLfloat)ii1 / (GLfloat)ng[0]; - kvec1[7][0] = (GLfloat)ii1 / (GLfloat)ng[0]; + kvec1[0][0] = (GLfloat)i0 / (GLfloat)ng[0]; + kvec1[1][0] = (GLfloat)i0 / (GLfloat)ng[0]; + kvec1[2][0] = (GLfloat)i0 / (GLfloat)ng[0]; + kvec1[3][0] = (GLfloat)i0 / (GLfloat)ng[0]; + kvec1[4][0] = (GLfloat)ii0 / (GLfloat)ng[0]; + kvec1[5][0] = (GLfloat)ii0 / (GLfloat)ng[0]; + kvec1[6][0] = (GLfloat)ii0 / (GLfloat)ng[0]; + kvec1[7][0] = (GLfloat)ii0 / (GLfloat)ng[0]; /**/ - kvec1[0][1] = (GLfloat)i2 / (GLfloat)ng[1]; - kvec1[1][1] = (GLfloat)i2 / (GLfloat)ng[1]; - kvec1[2][1] = (GLfloat)ii2 / (GLfloat)ng[1]; - kvec1[3][1] = (GLfloat)ii2 / (GLfloat)ng[1]; - kvec1[4][1] = (GLfloat)i2 / (GLfloat)ng[1]; - kvec1[5][1] = (GLfloat)i2 / (GLfloat)ng[1]; - kvec1[6][1] = (GLfloat)ii2 / (GLfloat)ng[1]; - kvec1[7][1] = (GLfloat)ii2 / (GLfloat)ng[1]; + kvec1[0][1] = (GLfloat)i1 / (GLfloat)ng[1]; + kvec1[1][1] = (GLfloat)i1 / (GLfloat)ng[1]; + kvec1[2][1] = (GLfloat)ii1 / (GLfloat)ng[1]; + kvec1[3][1] = (GLfloat)ii1 / (GLfloat)ng[1]; + kvec1[4][1] = (GLfloat)i1 / (GLfloat)ng[1]; + kvec1[5][1] = (GLfloat)i1 / (GLfloat)ng[1]; + kvec1[6][1] = (GLfloat)ii1 / (GLfloat)ng[1]; + kvec1[7][1] = (GLfloat)ii1 / (GLfloat)ng[1]; /**/ - kvec1[0][2] = (GLfloat)i3 / (GLfloat)ng[2]; - kvec1[1][2] = (GLfloat)ii3 / (GLfloat)ng[2]; - kvec1[2][2] = (GLfloat)i3 / (GLfloat)ng[2]; - kvec1[3][2] = (GLfloat)ii3 / (GLfloat)ng[2]; - kvec1[4][2] = (GLfloat)i3 / (GLfloat)ng[2]; - kvec1[5][2] = (GLfloat)ii3 / (GLfloat)ng[2]; - kvec1[6][2] = (GLfloat)i3 / (GLfloat)ng[2]; - kvec1[7][2] = (GLfloat)ii3 / (GLfloat)ng[2]; + kvec1[0][2] = (GLfloat)i2 / (GLfloat)ng[2]; + kvec1[1][2] = (GLfloat)ii2 / (GLfloat)ng[2]; + kvec1[2][2] = (GLfloat)i2 / (GLfloat)ng[2]; + kvec1[3][2] = (GLfloat)ii2 / (GLfloat)ng[2]; + kvec1[4][2] = (GLfloat)i2 / (GLfloat)ng[2]; + kvec1[5][2] = (GLfloat)ii2 / (GLfloat)ng[2]; + kvec1[6][2] = (GLfloat)i2 / (GLfloat)ng[2]; + kvec1[7][2] = (GLfloat)ii2 / (GLfloat)ng[2]; /**/ - if (lshift == 1){ - for (i = 0; i < 8; i++)for (j = 0; j < 3; j++) - kvec1[i][j] = kvec1[i][j] + 0.50 / (GLfloat)ng[j]; - } + for (i = 0; i < 8; i++)for (j = 0; j < 3; j++) + kvec1[i][j] = kvec1[i][j] + (double)shiftk[j] / (GLfloat)(2 * ng[j]); /**/ - if (i1 < 0) i1 = i1 + ng[0]; - if (i2 < 0) i2 = i2 + ng[1]; - if (i3 < 0) i3 = i3 + ng[2]; - if (ii1 < 0) ii1 = ii1 + ng[0]; - if (ii2 < 0) ii2 = ii2 + ng[1]; - if (ii3 < 0) ii3 = ii3 + ng[2]; + if (i0 < 0) i0 = i0 + ng[0]; + if (i1 < 0) i1 = i1 + ng[1]; + if (i2 < 0) i2 = i2 + ng[2]; + if (ii0 < 0) ii0 = ii0 + ng[0]; + if (ii1 < 0) ii1 = ii1 + ng[1]; + if (ii2 < 0) ii2 = ii2 + ng[2]; /**/ - if (ii1 >= ng[0]) ii1 = 0; - if (ii2 >= ng[1]) ii2 = 0; - if (ii3 >= ng[2]) ii3 = 0; + if (ii0 >= ng[0]) ii0 = 0; + if (ii1 >= ng[1]) ii1 = 0; + if (ii2 >= ng[2]) ii2 = 0; /**/ - eig1[0] = eig[ib][i1][i2][i3]; - eig1[1] = eig[ib][i1][i2][ii3]; - eig1[2] = eig[ib][i1][ii2][i3]; - eig1[3] = eig[ib][i1][ii2][ii3]; - eig1[4] = eig[ib][ii1][i2][i3]; - eig1[5] = eig[ib][ii1][i2][ii3]; - eig1[6] = eig[ib][ii1][ii2][i3]; - eig1[7] = eig[ib][ii1][ii2][ii3]; + eig1[0] = eig[ib][i0][i1][i2] - EF; + eig1[1] = eig[ib][i0][i1][ii2] - EF; + eig1[2] = eig[ib][i0][ii1][i2] - EF; + eig1[3] = eig[ib][i0][ii1][ii2] - EF; + eig1[4] = eig[ib][ii0][i1][i2] - EF; + eig1[5] = eig[ib][ii0][i1][ii2] - EF; + eig1[6] = eig[ib][ii0][ii1][i2] - EF; + eig1[7] = eig[ib][ii0][ii1][ii2] - EF; /**/ - mat1[0] = mat[ib][i1][i2][i3]; - mat1[1] = mat[ib][i1][i2][ii3]; - mat1[2] = mat[ib][i1][ii2][i3]; - mat1[3] = mat[ib][i1][ii2][ii3]; - mat1[4] = mat[ib][ii1][i2][i3]; - mat1[5] = mat[ib][ii1][i2][ii3]; - mat1[6] = mat[ib][ii1][ii2][i3]; - mat1[7] = mat[ib][ii1][ii2][ii3]; + mat1[0] = mat[ib][i0][i1][i2]; + mat1[1] = mat[ib][i0][i1][ii2]; + mat1[2] = mat[ib][i0][ii1][i2]; + mat1[3] = mat[ib][i0][ii1][ii2]; + mat1[4] = mat[ib][ii0][i1][i2]; + mat1[5] = mat[ib][ii0][i1][ii2]; + mat1[6] = mat[ib][ii0][ii1][i2]; + mat1[7] = mat[ib][ii0][ii1][ii2]; /**/ tetrahedron(ib, eig1, mat1, kvec1); } @@ -910,14 +948,14 @@ void fermi_patch() matp[ib] = (GLfloat**)malloc(ntri[ib] * sizeof(GLfloat*)); clr[ib] = (GLfloat***)malloc(ntri[ib] * sizeof(GLfloat**)); kvp[ib] = (GLfloat***)malloc(ntri[ib] * sizeof(GLfloat**)); - for (i1 = 0; i1 < ntri[ib]; ++i1){ - nmlp[ib][i1] = (GLfloat*)malloc(3 * sizeof(GLfloat)); - matp[ib][i1] = (GLfloat*)malloc(3 * sizeof(GLfloat)); - clr[ib][i1] = (GLfloat**)malloc(3 * sizeof(GLfloat*)); - kvp[ib][i1] = (GLfloat**)malloc(3 * sizeof(GLfloat*)); - for (i2 = 0; i2 < 3; ++i2){ - kvp[ib][i1][i2] = (GLfloat*)malloc(3 * sizeof(GLfloat)); - clr[ib][i1][i2] = (GLfloat*)malloc(4 * sizeof(GLfloat)); + for (i0 = 0; i0 < ntri[ib]; ++i0){ + nmlp[ib][i0] = (GLfloat*)malloc(3 * sizeof(GLfloat)); + matp[ib][i0] = (GLfloat*)malloc(3 * sizeof(GLfloat)); + clr[ib][i0] = (GLfloat**)malloc(3 * sizeof(GLfloat*)); + kvp[ib][i0] = (GLfloat**)malloc(3 * sizeof(GLfloat*)); + for (i1 = 0; i1 < 3; ++i1){ + kvp[ib][i0][i1] = (GLfloat*)malloc(3 * sizeof(GLfloat)); + clr[ib][i0][i1] = (GLfloat*)malloc(4 * sizeof(GLfloat)); } } } @@ -1769,45 +1807,93 @@ void special_key( /**/ } } /* special_key */ -/** + /** + * Free variables for patch + */ +void free_patch() { + int ib, i0, i1; + + for (ib = 0; ib < nb; ++ib) { + for (i0 = 0; i0 < ntri[ib]; ++i0) { + for (i1 = 0; i1 < 3; ++i1) { + free(kvp[ib][i0][i1]); + free(clr[ib][i0][i1]); + } + free(nmlp[ib][i0]); + free(matp[ib][i0]); + free(clr[ib][i0]); + free(kvp[ib][i0]); + } + free(nmlp[ib]); + free(matp[ib]); + free(clr[ib]); + free(kvp[ib]); + } + free(nmlp); + free(matp); + free(clr); + free(kvp); + + for (ib = 0; ib < nb; ++ib) { + for (i0 = 0; i0 < nnl[ib]; ++i0) { + for (i1 = 0; i1 < 2; ++i1) { + free(kvnl[ib][i0][i1]); + } + free(kvnl[ib][i0]); + } + free(kvnl[ib]); + } + free(kvnl); + +}/** * Main menu */ void main_menu(int value /**< [in] Selected menu*/){ /**/ - int ib, i1, i2, i3, ierr; - GLfloat emin, emax; - /**/ - if(value == 2){ + if (value == 9) { /* - Shift Fermi energy + Exit */ - emin = 100000.0; + printf("\nExit. \n\n"); + free(eig); + free(mat); + free(ntri); + free(draw_band); + free(bzl); + free(nnl); + free_patch(); + exit(0); + } +} +/* + Shift Fermi energy +*/ +void menu_shiftEF(int value /**< [in] Selected menu*/) +{ + int ib, i0, i1, i2, ierr; + GLfloat emin, emax; + + if (value == 1) { + emin = 100000.0; emax = -100000.0; - for (ib = 0; ib < nb; ++ib) { - for (i1 = 0; i1 < ng[0]; ++i1) { - for (i2 = 0; i2 < ng[1]; ++i2) { - for (i3 = 0; i3 < ng[2]; ++i3) { - eig[ib][i1][i2][i3] = eig[ib][i1][i2][i3] + def; - if(emin > eig[ib][i1][i2][i3]) emin = eig[ib][i1][i2][i3]; - if(emax < eig[ib][i1][i2][i3]) emax = eig[ib][i1][i2][i3]; + for (ib = 0; ib < nb; ++ib) { + for (i0 = 0; i0 < ng[0]; ++i0) { + for (i1 = 0; i1 < ng[1]; ++i1) { + for (i2 = 0; i2 < ng[2]; ++i2) { + if (emin > eig[ib][i0][i1][i2]) emin = eig[ib][i0][i1][i2]; + if (emax < eig[ib][i0][i1][i2]) emax = eig[ib][i0][i1][i2]; } } } } printf("Min Max E_F \n"); - printf("%f %f %f \n",emin, emax, def); + printf("%f %f %f \n", emin, emax, EF); printf("New Fermi energy : "); - ierr = scanf("%f", &def); - if(ierr == 0) printf("error ! reading ef"); - for (ib = 0; ib < nb; ++ib) { - for (i1 = 0; i1 < ng[0]; ++i1) { - for (i2 = 0; i2 < ng[1]; ++i2) { - for (i3 = 0; i3 < ng[2]; ++i3) { - eig[ib][i1][i2][i3] = eig[ib][i1][i2][i3] - def; - } - } - } - } + // + ierr = scanf("%f", &EF); + if (ierr != 1) printf("error ! reading ef"); + /**/ + free_patch(); query = 1; fermi_patch(); query = 0; @@ -1818,25 +1904,8 @@ void main_menu(int value /**< [in] Selected menu*/){ /**/ glutPostRedisplay(); } - else if(value == 9){ - /* - Exit - */ - printf("\nExit. \n\n"); - free(eig); - free(mat); - free(ntri); - free(draw_band); - free(nmlp); - free(kvp); - free(matp); - free(clr); - free(bzl); - free(nnl); - free(kvnl); - exit(0); - } } + /** * Change mouse function */ @@ -1919,12 +1988,8 @@ void menu_colorscale(int value /**<[in] Selected menu*/){ void menu_bzmode(int value /**<[in] Selected menu*/){ if(value == 1 && fbz != 1){ fbz = 1; - free(kvp); - free(nmlp); - free(clr); - free(matp); - free(kvnl); /**/ + free_patch(); query = 1; fermi_patch(); query = 0; @@ -1937,12 +2002,8 @@ void menu_bzmode(int value /**<[in] Selected menu*/){ } else if(value == 2 && fbz != -1){ fbz = -1; - free(kvp); - free(nmlp); - free(clr); - free(matp); - free(kvnl); /**/ + free_patch(); query = 1; fermi_patch(); query = 0; @@ -2002,17 +2063,12 @@ void menu_colorbar(int value /**<[in] Selected menu*/){ * Change tetrahedron */ void menu_tetra(int value) /**<[in] Selected menu*/{ - int imenu2; /**/ if(value != itet){ printf("Tetra patern %d \n", value + 1); itet = value; - free(kvp); - free(nmlp); - free(clr); - free(matp); - free(kvnl); init_corner(); + free_patch(); query = 1; fermi_patch(); query = 0; @@ -2122,7 +2178,7 @@ Munu */ void FS_CreateMenu() { - int ib; + int ib, ishiftEF; char ibstr[20] = { 0 }; /**/ imousemenu = glutCreateMenu(menu_mouse); @@ -2139,6 +2195,9 @@ void FS_CreateMenu() else sprintf(ibstr, "[ ] band # %d", ib + 1); glutAddMenuEntry(ibstr, ib); } + /* Shift Fermi energy */ + ishiftEF = glutCreateMenu(menu_shiftEF); + glutAddMenuEntry("Shift Fermi energy", 1); /* Background color */ ibgmenu = glutCreateMenu(menu_bgcolor); if (blackback == 1) glutAddMenuEntry("[x] Black", 1); @@ -2194,7 +2253,7 @@ void FS_CreateMenu() imenu = glutCreateMenu(main_menu); glutAddSubMenu("Band", ibandmenu); glutAddSubMenu("Mouse Drag", imousemenu); - glutAddMenuEntry("Shift Fermi energy", 2); + glutAddSubMenu("Shift Fermi energy", ishiftEF); glutAddSubMenu("Background color", ibgmenu); glutAddSubMenu("Color scale mode", icsmenu); glutAddSubMenu("Brillouin zone", ibzmenu); @@ -2226,6 +2285,13 @@ int main( int argc /**< [in] */, char *argv[] /**< [in] */) { + if (argc < 2) { + printf("\n\nInput file is not specified !\n"); + printf(" Press any key to exit.\n"); + getchar(); + exit(-1); + } + /**/ read_file(argv[1]); init_corner();