Commit 0dd7ba26 authored by Steve Plimpton's avatar Steve Plimpton Committed by GitHub
Browse files

Merge pull request #672 from akohlmey/phana-w-tricubic

Streamline compilation of "phana" tool for fix phonon
parents 7a90eef5 4c71beb0
Loading
Loading
Loading
Loading
+23 −11
Original line number Diff line number Diff line
.SUFFIXES : .o .cpp
# compiler and flags
CC     = g++ -Wno-unused-result
LINK   = $(CC) -static
CC     = g++ -Wall
LINK   = $(CC)
CFLAGS = -O3 $(DEBUG) $(UFLAG)
#
OFLAGS = -O3 $(DEBUG)
@@ -9,18 +9,17 @@ INC = $(LPKINC) $(TCINC) $(SPGINC)
LIB    = $(LPKLIB) $(TCLIB) $(SPGLIB)
#
# cLapack library needed
LPKINC = -I/opt/libs/clapack/3.2.1/include
LPKLIB = -L/opt/libs/clapack/3.2.1/lib -lclapack -lblas -lf2c #-lm
LPKINC = 
LPKLIB =-llapack
#
# Tricubic library needed
TCINC = -I/opt/libs/tricubic/1.0/include
TCLIB = -L/opt/libs/tricubic/1.0/lib -ltricubic
#
# spglib 1.8.2, used to get the irreducible q-points
# if UFLAG is not set, spglib won't be used.
UFLAG  = -DUseSPG
SPGINC = -I/opt/libs/spglib/1.8.2/include
SPGLIB = -L/opt/libs/spglib/1.8.2/lib -lsymspg

# UFLAG  = -DUseSPG
# SPGINC = -I/opt/libs/spglib/1.8.2/include
# SPGLIB = -L/opt/libs/spglib/1.8.2/lib -lsymspg

# if spglib other than version 1.8.2 is used, please 
# modify file phonon.cpp, instruction can be found by searching 1.8.2

@@ -36,7 +35,7 @@ SRC = $(wildcard *.cpp)
OBJ = $(SRC:.cpp=.o)

#====================================================================
all:  ver ${EXE}
all:  ${EXE}

${EXE}: $(OBJ)
	$(LINK) $(OFLAGS) $(OBJ) $(LIB) -o $@
@@ -59,3 +58,16 @@ ver:
	$(CC) $(CFLAGS) -c $<
.cpp.o:
	$(CC) $(CFLAGS) $(INC) -c $<

#====================================================================
# dependencies
disp.o: disp.cpp phonon.h dynmat.h memory.h interpolate.h green.h timer.h \
 global.h
dynmat.o: dynmat.cpp dynmat.h memory.h interpolate.h version.h global.h
green.o: green.cpp green.h memory.h global.h
interpolate.o: interpolate.cpp interpolate.h memory.h global.h
main.o: main.cpp dynmat.h memory.h interpolate.h phonon.h
memory.o: memory.cpp memory.h
phonon.o: phonon.cpp phonon.h dynmat.h memory.h interpolate.h green.h \
 timer.h global.h
timer.o: timer.cpp timer.h
+3 −9
Original line number Diff line number Diff line
@@ -5,15 +5,9 @@
   analyse the phonon related information.
#-------------------------------------------------------------------------------
1. Dependencies
   The clapack library is needed to solve the eigen problems,
   which could be downloaded from:
   http://www.netlib.org/clapack/
   
   The tricubic library is also needed to do tricubic interpolations,
   which could be obtained from:
      http://orca.princeton.edu/francois/software/tricubic/
   or
      http://1drv.ms/1J2WFYk
   The LAPACK library is needed to solve the eigen problems.
   http://www.netlib.org/lapack/
   Intel MKL can be used as well.
   
   The spglib is optionally needed, enabling one to evaluate the
   phonon density of states or vibrational thermal properties
+4 −3
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@ void Phonon::pdisp()
{
  // ask the output file name and write the header.
  char str[MAXLINE];
  for (int ii = 0; ii < 80; ++ii) printf("="); printf("\n");
  for (int ii = 0; ii < 80; ++ii) printf("=");
  printf("\n");
#ifdef UseSPG
  // ask method to generate q-lines
  int method = 2;
@@ -53,7 +54,6 @@ void Phonon::pdisp()
    while (1){
      for (int i = 0; i < 3; ++i) qstr[i] = qend[i];
  
      int quit = 0;
      printf("\nPlease input the start q-point in unit of B1->B3, q to exit [%g %g %g]: ", qstr[0], qstr[1], qstr[2]);
      int n = count_words(fgets(str, MAXLINE, stdin));
      ptr = strtok(str, " \t\n\r\f");
@@ -2844,7 +2844,8 @@ void Phonon::pdisp()
    printf("\nPhonon dispersion data are written to: %s, you can visualize the results\n", fname);
    printf("by invoking: `gnuplot pdisp.gnuplot; gv pdisp.eps`\n");
  }
  for (int ii = 0; ii < 80; ++ii) printf("="); printf("\n");
  for (int ii = 0; ii < 80; ++ii) printf("=");
  printf("\n");

  delete []fname;
  nodes.clear();
+19 −11
Original line number Diff line number Diff line
@@ -3,6 +3,11 @@
#include "version.h"
#include "global.h"

extern "C" void zheevd_(char *, char *, long int *, doublecomplex *,
                       long int *, double *, doublecomplex *,
                       long int *, double *, long int *, long int *,
                       long int *, long int *);

// to initialize the class
DynMat::DynMat(int narg, char **arg)
{
@@ -81,7 +86,8 @@ DynMat::DynMat(int narg, char **arg)
  printf("Number of atoms per unit cell     : %d\n", nucell);
  printf("System dimension                  : %d\n", sysdim);
  printf("Boltzmann constant in used units  : %g\n", boltz);
  for (int i = 0; i < 80; ++i) printf("="); printf("\n");
  for (int i = 0; i < 80; ++i) printf("=");
  printf("\n");
  if (sysdim < 1||sysdim > 3||nx < 1||ny < 1||nz < 1||nucell < 1){
    printf("Wrong values read from header of file: %s, please check the binary file!\n", binfile);
    fclose(fp); exit(3);
@@ -117,11 +123,11 @@ DynMat::DynMat(int narg, char **arg)
  memory->create(attyp, nucell,         "DynMat:attyp");
  memory->create(M_inv_sqrt, nucell,    "DynMat:M_inv_sqrt");
  
  if ( fread(&Tmeasure,      sizeof(double), 1,      fp) != 1     ){printf("\nError while reading temperature from file: %s\n",   binfile); fclose(fp); exit(3);}
  if ( fread(&basevec[0],    sizeof(double), 9,      fp) != 9     ){printf("\nError while reading lattice info from file: %s\n",  binfile); fclose(fp); exit(3);}
  if ( fread(basis[0],       sizeof(double), fftdim, fp) != fftdim){printf("\nError while reading basis info from file: %s\n",    binfile); fclose(fp); exit(3);}
  if ( fread(&attyp[0],      sizeof(int),    nucell, fp) != nucell){printf("\nError while reading atom types from file: %s\n",    binfile); fclose(fp); exit(3);}
  if ( fread(&M_inv_sqrt[0], sizeof(double), nucell, fp) != nucell){printf("\nError while reading atomic masses from file: %s\n", binfile); fclose(fp); exit(3);}
  if ( (int) fread(&Tmeasure,      sizeof(double), 1,      fp) != 1     ){printf("\nError while reading temperature from file: %s\n",   binfile); fclose(fp); exit(3);}
  if ( (int) fread(&basevec[0],    sizeof(double), 9,      fp) != 9     ){printf("\nError while reading lattice info from file: %s\n",  binfile); fclose(fp); exit(3);}
  if ( (int) fread(basis[0],       sizeof(double), fftdim, fp) != fftdim){printf("\nError while reading basis info from file: %s\n",    binfile); fclose(fp); exit(3);}
  if ( (int) fread(&attyp[0],      sizeof(int),    nucell, fp) != nucell){printf("\nError while reading atom types from file: %s\n",    binfile); fclose(fp); exit(3);}
  if ( (int) fread(&M_inv_sqrt[0], sizeof(double), nucell, fp) != nucell){printf("\nError while reading atomic masses from file: %s\n", binfile); fclose(fp); exit(3);}
  fclose(fp);

  car2dir();
@@ -229,9 +235,9 @@ return;
int DynMat::geteigen(double *egv, int flag)
{
  char jobz, uplo;
  integer n, lda, lwork, lrwork, *iwork, liwork, info;
  long int n, lda, lwork, lrwork, *iwork, liwork, info;
  doublecomplex *work;
  doublereal *w = &egv[0], *rwork;
  double *w = &egv[0], *rwork;

  n     = fftdim;
  if (flag) jobz = 'V';
@@ -338,7 +344,8 @@ void DynMat::EnforceASR()
  char *ptr = strtok(str," \t\n\r\f");
  if (ptr) nasr = atoi(ptr);
  if (nasr < 1){
    for (int i=0; i<80; i++) printf("="); printf("\n");
    for (int i=0; i<80; i++) printf("=");
    printf("\n");
    return;
  }

@@ -404,7 +411,8 @@ void DynMat::EnforceASR()
    if (i == 99){ printf("...... (%d more skiped)", fftdim-100); break;}
  }
  printf("\n");
  for (int i = 0; i < 80; ++i) printf("="); printf("\n\n");
  for (int i = 0; i < 80; ++i) printf("=");
  printf("\n\n");

return;
}
@@ -456,7 +464,7 @@ return;
 * --------------------------------------------------------------------*/
void DynMat::GaussJordan(int n, double *Mat)
{
  int i,icol,irow,j,k,l,ll,idr,idc;
  int i,icol=0,irow=0,j,k,l,ll,idr,idc;
  int *indxc,*indxr,*ipiv;
  double big, nmjk;
  double dum, pivinv;
+0 −5
Original line number Diff line number Diff line
@@ -7,11 +7,6 @@
#include "memory.h"
#include "interpolate.h"

extern "C"{
#include "f2c.h"
#include "clapack.h"
}

using namespace std;

class DynMat {
Loading