Skip to content

Commit

Permalink
Merge pull request #197 from xuqimen/master
Browse files Browse the repository at this point in the history
  • Loading branch information
phanish-suryanarayana authored Sep 22, 2023
2 parents 4bacc7e + 8b00d8b commit e128382
Show file tree
Hide file tree
Showing 35 changed files with 15,150 additions and 75 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
-Name
-changes

--------------
Sep 22, 2023
Name: Qimen Xu, Ziao Tang, Yu Zhang
Changes: (eigenSolver.c, electronicGroundState.c, initialization.c, occupation.c, orbitalElecDensInit.c, printing.c, readfiles.c, isddft.h, readfiles.h, utils/)
1. Add band structure calculation feature.
2. Add `readDens_cube` routine for reading input density file.
3. Fix memory leak issues:
(a) when ixc[2] is nonzero, countPotentialCalculate is not initialized,
(b) EigenFilename is not initialized on processes with rank > 0.
4. Add a python script in `utils/` for processing `.eigen` files and visualizing the band structure of a given system.

--------------
Sep 18, 2023
Name: Xin Jing
Expand Down
153 changes: 153 additions & 0 deletions doc/.LaTeX/BandStructure.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks,c]{} \label{BandStructure}

\begin{center}
\Huge \textbf{Band structure}
\end{center}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{BAND\_STRUCTURE}} \label{BAND_STRUCTURE}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
Integer
\end{block}

\begin{block}{Default}
0
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{BAND\_STRUCTURE}: 1
\end{block}
\end{columns}

\begin{block}{Description}
Flag for calculation of the band structure.
\end{block}

%\begin{block}{Remark}
%\end{block}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{KPT\_PATHS}} \label{KPT_PATHS}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
Double
\end{block}

\begin{block}{Default}
None
\end{block}

\column{0.5\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{KPT\_PATHS: 2\\}
0.0 0.0 0.0 \# Gamma\\
0.5 0.5 0.5 \# A\\
0.5 0.5 0.5 \# A\\
0.5 0.5 0.0 \# M
\end{block}
\end{columns}

\begin{block}{Description}
The k-point paths (high-symmetry lines) for band structure calculations. It starts with the total number of high-symmetry lines, followed by fractional coordinates indicating the start and end points of each line.
\end{block}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{KPT\_PER\_LINE}} \label{KPT_PER_LINE}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
Integer
\end{block}

\begin{block}{Default}
10
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{KPT\_PER\_LINE}: 15
\end{block}
\end{columns}

\begin{block}{Description}
The number of k-points on each high-symmetry line.
\end{block}

\begin{block}{Remark}
This value accounts for both endpoints of the high-symmetry line.
\end{block}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{INPUT\_DENS\_FILE}} \label{INPUT_DENS_FILE}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
String
\end{block}

\begin{block}{Default}
None
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{INPUT\_DENS\_FILE}: Si.dens Si.densUp Si.densDwn
\end{block}
\end{columns}

\begin{block}{Description}
The name of the input density file(s) in cube format.
\end{block}

\begin{block}{Remark}
For spin-unpolarized systems, only the total density file is required. For spin-polarized systems, three density files are required, which are the total electron density, spin-up density, and spin-down density, respectively.
\end{block}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 changes: 8 additions & 0 deletions doc/.LaTeX/Introduction.tex
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@
\hyperlink{FIRE_MAXMOV}{\texttt{FIRE\_MAXMOV}} $\vert$
\hyperlink{RESTART_FLAG}{\texttt{RESTART\_FLAG}}
\end{block}

\vspace{-2mm}
\begin{block}{Band structure}
\hyperlink{BAND_STRUCTURE}{\texttt{BAND\_STRUCTURE}} $\vert$
\hyperlink{KPT_PATHS}{\texttt{KPT\_PATHS}} $\vert$
\hyperlink{KPT_PER_LINE}{\texttt{KPT\_PER\_LINE}} $\vert$
\hyperlink{INPUT_DENS_FILE}{\texttt{INPUT\_DENS\_FILE}}
\end{block}

\begin{block}{Print options}
\hyperlink{PRINT_ATOMS}{\texttt{PRINT\_ATOMS}} $\vert$
Expand Down
1 change: 1 addition & 0 deletions doc/.LaTeX/Manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
\include{Stress}
\include{MD}
\include{Optimization}
\include{BandStructure}
\include{Print}
\include{Paral}
\include{SQ}
Expand Down
4 changes: 2 additions & 2 deletions doc/.LaTeX/SCF.tex
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
\end{block}

\begin{block}{Default}
4 or 6
4, 6, or 10
\end{block}

\column{0.4\linewidth}
Expand All @@ -105,7 +105,7 @@

\begin{block}{Remark}
Values smaller than the default value of 4 can result in a significant increase in the number of SCF
iterations. Larger values can sometimes reduce the number of SCF iterations. For non-collinear spin calculation, default is 6 otherwise 4.
iterations. Larger values can sometimes reduce the number of SCF iterations. For non-collinear spin calculation, default is 6 otherwise 4. For band structure calculations, default is 10.
\end{block}

\end{frame}
Expand Down
Binary file modified doc/Manual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/eigenSolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2385,4 +2385,4 @@ void Chol_orth(double *A, const int *descA, double *z, const int *descz, const i
pdpotrf_("U", n, z, &ONE, &ONE, descz, &info);
pdtrsm_("R", "U", "N", "N", m, n, &alpha, z, &ONE, &ONE, descz, A, &ONE, &ONE, descA);
#endif //(#ifdef USE_MKL)
}
}
2 changes: 1 addition & 1 deletion src/electronicGroundState.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ void Transfer_Veff_loc(SPARC_OBJ *pSPARC, double *Veff_phi_domain, double *Veff_
if (rank == 0) printf("---Transfer Veff_loc: mpi_bcast (count = %d) to all bandcomms took %.3f ms\n",pSPARC->Nd_d_dmcomm,(t2-t1)*1e3);
#endif

if ((pSPARC->countPotentialCalculate > 1) && (pSPARC->ixc[2]))
if ((pSPARC->ixc[2]) && (pSPARC->countPotentialCalculate > 1))
Transfer_vxcMGGA3_phi_psi(pSPARC, pSPARC->vxcMGGA3, pSPARC->vxcMGGA3_loc_dmcomm); // only transfer the potential they are going to use
}

Expand Down
25 changes: 24 additions & 1 deletion src/include/isddft.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#define L_STRING 512
#define L_ATMTYPE 8
#define L_QMASS 60

// max length of kpoint set
#define L_kpoint 512

// TO PRINT IN COLOR
#define RED "\x1B[31m"
Expand Down Expand Up @@ -972,6 +973,18 @@ typedef struct _SPARC_OBJ{

/* EigenValue problem*/
int StandardEigenFlag;

/* Band structure plot*/
int n_kpt_line;
double kredx[L_kpoint],kredy[L_kpoint],kredz[L_kpoint];
double k1_inpt_kpt[L_kpoint],k2_inpt_kpt[L_kpoint],k3_inpt_kpt[L_kpoint];
int BandStructFlag;
int kpt_per_line;
char InDensTCubFilename[L_STRING];
char InDensUCubFilename[L_STRING];
char InDensDCubFilename[L_STRING];
int densfilecount;

}SPARC_OBJ;


Expand Down Expand Up @@ -1229,6 +1242,16 @@ typedef struct _SPARC_INPUT_OBJ{

char SPARCROOT[L_STRING]; // SPARC root directory


/* Band structure plot*/
int n_kpt_line;
double kredx[L_kpoint],kredy[L_kpoint],kredz[L_kpoint];
int BandStructFlag;
int kpt_per_line;
char InDensTCubFilename[L_STRING];
char InDensUCubFilename[L_STRING];
char InDensDCubFilename[L_STRING];
int densfilecount;
}SPARC_INPUT_OBJ;


Expand Down
22 changes: 22 additions & 0 deletions src/include/readfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ void read_ion(SPARC_INPUT_OBJ *pSPARC_Input, SPARC_OBJ *pSPARC);
void read_pseudopotential_PSP(SPARC_INPUT_OBJ *pSPARC_Input, SPARC_OBJ *pSPARC);


/**
* @brief Read density in cube format.
*
* @param filename Name of the density file in cube format.
* @param dens_gridsizes (OUTPUT) Grid sizes (in 3-dim) of the density read.
* @param dens_latvecs (OUTPUT) Lattice vectors (scaled) read.
* @return double* (OUTPUT) Density array.
*/
double* readDens_cube(char *filename, int dens_gridsizes[3], double dens_latvecs[9]);


/**
* @brief Read data from cube file and check if the lattice vectors
* and the grid sizes match with the input lattice and grid.
*
* @param pSPARC
* @param filename File name of the cube file.
* @return double* Data from file, allocated within this function.
*/
double* read_vec_cube(SPARC_OBJ *pSPARC, char *filename);


#endif // READFILES_H


25 changes: 25 additions & 0 deletions src/include/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ int strcmpi(const char *p1, const char *p2);
void simplifyPath(char* path, char *newpath, size_t newlen);



/**
* @brief Exact file path from a file name.
*
* @param filename File name.
* @param path (OUTPUT) Path (relative or absolute) where the file is located.
* @param maxlen Maximum length of the path.
*/
void extract_path_from_file(const char *filename, char *path, int maxlen);


/**
* @brief Combine a path and a file name and simplify the path.
*
* If the file name is already provided in the absolute path form, then
* path is ignored. Otherwise, the new file name would be a simplified path
* equivalent to "path/fname".
*
* @param path The path relative to which fname is given.
* @param fname The name provided relative to path.
* @param newfname (OUTPUT) The new file name.
*/
void combine_path_filename(const char *path, const char *fname, char *newfname, int maxlen);


/**
* @brief The following code for factorizing an integer is copied from Rosetta Code
* https://rosettacode.org/wiki/Factors_of_an_integer#C . It is only used when
Expand Down
Loading

0 comments on commit e128382

Please sign in to comment.