apply clang-tidy fixes

This commit is contained in:
Axel Kohlmeyer 2024-02-09 06:29:08 -05:00
parent f8885cb266
commit a2ae9dce64
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
11 changed files with 36 additions and 137 deletions

View File

@ -53,7 +53,7 @@ void Phonon::pdisp()
#ifdef UseSPG
if (method == 1){
#endif
while (1){
while (true){
for (int i = 0; i < 3; ++i) qstr[i] = qend[i];
printf("\nPlease input the start q-point in unit of B1->B3, q to exit [%g %g %g]: ", qstr[0], qstr[1], qstr[2]);
@ -67,7 +67,7 @@ void Phonon::pdisp()
qstr[2] = atof(strtok(NULL, " \t\n\r\f"));
}
while ( 1 ){
while ( true ){
printf("Please input the end q-point in unit of B1->B3: ");
input->read_stdin(str);
if (count_words(str) >= 3) break;
@ -166,8 +166,6 @@ void Phonon::pdisp()
delete []fname;
delete qnodes;
return;
}
/*----------------------------------------------------------------------------*/

View File

@ -200,8 +200,6 @@ DynMat::DynMat(int narg, char **arg)
// ask for the interpolation method
interpolate->set_method();
return;
}
@ -222,8 +220,6 @@ DynMat::~DynMat()
memory->destroy(DM_all);
memory->destroy(M_inv_sqrt);
delete memory;
return;
}
/* ----------------------------------------------------------------------------
@ -234,10 +230,10 @@ void DynMat::writeDMq(double *q)
FILE *fp;
// only ask for file name for the first time
// other calls will append the result to the file.
if (dmfile == NULL){
if (dmfile == nullptr){
char str[MAXLINE], *ptr;
printf("\n");
while ( 1 ){
while ( true ){
printf("Please input the filename to output the DM at selected q: ");
input->read_stdin(str);
ptr = strtok(str, " \r\t\n\f");
@ -260,8 +256,6 @@ void DynMat::writeDMq(double *q)
}
fprintf(fp,"\n");
fclose(fp);
return;
}
/* ----------------------------------------------------------------------------
@ -275,7 +269,6 @@ void DynMat::writeDMq(double *q, const double qr, FILE *fp)
for (int j = 0; j < fftdim; ++j) fprintf(fp,"%lg %lg\t", DM_q[i][j].r, DM_q[i][j].i);
fprintf(fp,"\n");
return;
}
/* ----------------------------------------------------------------------------
@ -327,8 +320,6 @@ int DynMat::geteigen(double *egv, int flag)
void DynMat::getDMq(double *q)
{
interpolate->execute(q, DM_q[0]);
return;
}
/* ----------------------------------------------------------------------------
@ -339,7 +330,6 @@ void DynMat::getDMq(double *q, double *wt)
interpolate->execute(q, DM_q[0]);
if (flag_skip && interpolate->UseGamma ) wt[0] = 0.;
return;
}
/* ----------------------------------------------------------------------------
@ -359,8 +349,7 @@ void DynMat::car2dir()
basis[i][idim] = x[0]*mat[idim] + x[1]*mat[3+idim] + x[2]*mat[6+idim];
}
return;
}
}
/* ----------------------------------------------------------------------------
* private method to enforce the acoustic sum rule on force constant matrix at G
@ -463,7 +452,6 @@ void DynMat::EnforceASR()
}
delete[] egvs;
puts("\n================================================================================\n");
return;
}
/* ----------------------------------------------------------------------------
@ -501,7 +489,6 @@ void DynMat::real2rec()
for (int j = 0; j < sysdim; ++j) printf("%8.4f ", ibasevec[i*3+j]);
}
puts("\n================================================================================");
return;
}
/* ----------------------------------------------------------------------
@ -590,8 +577,6 @@ void DynMat::GaussJordan(int n, double *Mat)
delete []indxr;
delete []indxc;
delete []ipiv;
return;
}
/* ----------------------------------------------------------------------------
@ -600,8 +585,6 @@ void DynMat::GaussJordan(int n, double *Mat)
void DynMat::reset_interp_method()
{
interpolate->set_method();
return;
}
/* ----------------------------------------------------------------------------
@ -644,8 +627,6 @@ void DynMat::ShowVersion()
printf(" (__) (_) (_)(__)(__)(_)\\_)(__)(__)\n");
printf("\nPHonon ANAlyzer for Fix-Phonon, version 2.%02d, compiled on %s.\n", VERSION, __DATE__);
printf("Reference: https://doi.org/10.1016/j.cpc.2011.04.019\n");
return;
}
/* ----------------------------------------------------------------------------
@ -696,8 +677,7 @@ void DynMat::Define_Conversion_Factor()
printf("sqrt(E/ML^2)/(2*pi) into THz, instead, I set it to 1; you should check the unit\nused by LAMMPS.\n");
eml2f = eml2fc = 1.;
}
return;
}
}
/* ----------------------------------------------------------------------------
* Private method to output the information read
@ -711,6 +691,5 @@ void DynMat::ShowInfo()
printf("System dimension : %d\n", sysdim);
printf("Boltzmann constant in used units : %g\n", boltz);
puts("================================================================================");
return;
}
/* --------------------------------------------------------------------*/

View File

@ -65,8 +65,6 @@ Green::Green(const int ntm, const int sdim, const int niter, const double min, c
// Get the inverser of the treated hessian by continued fractional method
Recursion();
return;
}
/*------------------------------------------------------------------------------
@ -74,14 +72,12 @@ Green::Green(const int ntm, const int sdim, const int niter, const double min, c
*----------------------------------------------------------------------------*/
Green::~Green()
{
H = NULL;
ldos = NULL;
H = nullptr;
ldos = nullptr;
memory->destroy(alpha);
memory->destroy(beta);
delete memory;
return;
}
/*------------------------------------------------------------------------------
@ -134,8 +130,6 @@ void Green::Lanczos()
delete []vp;
delete []v;
delete []w;
return;
}
/*------------------------------------------------------------------------------
@ -211,8 +205,6 @@ void Green::Recursion()
delete []beta_inf;
delete []xmin;
delete []xmax;
return;
}
/*------------------------------------------------------------------------------
@ -239,7 +231,6 @@ void Green::recursion()
}
w += dw;
}
return;
}
}
/*------------------------------------------------------------------------------*/

View File

@ -7,10 +7,8 @@
* ---------------------------------------------------------------- */
UserInput::UserInput(int flag)
{
fp = NULL;
fp = nullptr;
if (flag) fp = fopen("script.inp", "w");
return;
}
/* -------------------------------------------------------------------
@ -19,7 +17,7 @@ UserInput::UserInput(int flag)
UserInput::~UserInput()
{
if (fp) fclose(fp);
fp = NULL;
fp = nullptr;
}
/* -------------------------------------------------------------------
@ -29,7 +27,5 @@ void UserInput::read_stdin(char *str)
{
fgets(str, MAXLINE, stdin);
if (fp) fprintf(fp, "%s", str);
return;
}
/* ---------------------------------------------------------------- */

View File

@ -28,8 +28,6 @@ Interpolate::Interpolate(int nx, int ny, int nz, int ndm, doublecomplex **DM)
Dfdx = Dfdy = Dfdz = D2fdxdy = D2fdxdz = D2fdydz = D3fdxdydz = NULL;
flag_reset_gamma = flag_allocated_dfs = 0;
input = NULL;
return;
}
/* ----------------------------------------------------------------------------
@ -106,8 +104,7 @@ void Interpolate::tricubic_init()
}
n++;
}
return;
}
}
/* ----------------------------------------------------------------------------
* Deconstructor used to free memory
@ -123,8 +120,6 @@ Interpolate::~Interpolate()
memory->destroy(D2fdydz);
memory->destroy(D3fdxdydz);
delete memory;
return;
}
/* ----------------------------------------------------------------------------
@ -184,8 +179,7 @@ void Interpolate::tricubic(double *qin, doublecomplex *DMq)
tricubic_get_coeff(&a[0],&f[0],&dfdx[0],&dfdy[0],&dfdz[0],&d2fdxdy[0],&d2fdxdz[0],&d2fdydz[0],&d3fdxdydz[0]);
DMq[idim].i = tricubic_eval(&a[0],x,y,z);
}
return;
}
}
/* ----------------------------------------------------------------------------
* method to interpolate the DM at an arbitrary q point;
@ -250,8 +244,7 @@ void Interpolate::trilinear(double *qin, doublecomplex *DMq)
}
}
return;
}
}
/* ----------------------------------------------------------------------------
* To invoke the interpolation
@ -263,8 +256,6 @@ void Interpolate::execute(double *qin, doublecomplex *DMq)
tricubic(qin, DMq);
else // otherwise: trilinear
trilinear(qin, DMq);
return;
}
/* ----------------------------------------------------------------------------
@ -274,7 +265,7 @@ void Interpolate::set_method()
{
char str[MAXLINE];
int im = 1;
if (input == NULL) input = new UserInput(0);
if (input == nullptr) input = new UserInput(0);
puts("\n================================================================================");
printf("Which interpolation method would you like to use?\n");
@ -289,8 +280,6 @@ void Interpolate::set_method()
puts("================================================================================\n");
if (which == 1) tricubic_init();
return;
}
/* ----------------------------------------------------------------------------
@ -316,6 +305,5 @@ void Interpolate::reset_gamma()
+ (data[im1][idim].r + data[ip1][idim].r) * two3;
}
return;
}
}
/* ---------------------------------------------------------------------------- */

View File

@ -64,7 +64,6 @@ kPath::kPath(DynMat *dm, QNodes *qn)
for (int j = 0; j < 3; ++j) pos[i][j] = atpos[i][j];
spgnum = spg_get_international(symbol, latvec, (double (*)[3])pos, attyp, num_atom, symprec);
memory->destroy(pos);
return;
}
/* ----------------------------------------------------------------------------
@ -89,7 +88,6 @@ void kPath::show_info()
printf("The space group number of your unit cell is: %d => %s\n", spgnum, symbol);
puts("--------------------------------------------------------------------------------");
return;
}
/* ----------------------------------------------------------------------------
@ -102,8 +100,6 @@ kPath::~kPath( )
delete memory;
dynmat = NULL;
q = NULL;
return;
}
/* ----------------------------------------------------------------------------
@ -2764,15 +2760,14 @@ void kPath::kpath( )
q->nqbin.push_back(nqpt);
}
return;
}
}
/* ----------------------------------------------------------------------------
* Show the k-path info
* ---------------------------------------------------------------------------- */
void kPath::show_path()
{
if (q == NULL) return;
if (q == nullptr) return;
int nbin = q->ndstr.size();
if (nbin > 0){
puts("\n--------------------------------------------------------------------------------");
@ -2787,7 +2782,6 @@ void kPath::show_path()
puts("--------------------------------------------------------------------------------");
}
return;
}
}
/* ---------------------------------------------------------------------------- */
#endif

View File

@ -96,15 +96,14 @@ Phonon::Phonon(DynMat *dm)
else if (job ==-1) dynmat->reset_interp_method();
else break;
}
return;
}
}
/* ----------------------------------------------------------------------------
* Deconstructor to free memory
* ---------------------------------------------------------------------------- */
Phonon::~Phonon()
{
dynmat = NULL;
dynmat = nullptr;
memory->destroy(wt);
memory->destroy(qpts);
@ -120,8 +119,6 @@ Phonon::~Phonon()
memory->destroy(atpos);
#endif
delete memory;
return;
}
/* ----------------------------------------------------------------------------
@ -191,8 +188,6 @@ void Phonon::pdos()
// output DOS
writeDOS();
return;
}
/* ----------------------------------------------------------------------------
@ -200,7 +195,7 @@ void Phonon::pdos()
* ---------------------------------------------------------------------------- */
void Phonon::writeDOS()
{
if (dos == NULL) return;
if (dos == nullptr) return;
char str[MAXLINE];
// now to output the phonon DOS
@ -231,8 +226,6 @@ void Phonon::writeDOS()
fclose(fp);
fname = NULL;
return;
}
/* ----------------------------------------------------------------------------
@ -265,8 +258,7 @@ void Phonon::writeLDOS()
fclose(fp);
}
return;
}
}
/* ----------------------------------------------------------------------------
* Private method to calculate the local phonon DOS via the real space Green's
@ -303,7 +295,7 @@ void Phonon::ldos_rsgf()
int ik = 0, nit = MAX(ndim*0.1, MIN(ndim,50));
double eps = 12.; // for Cu with 1000+ atoms, 12 is enough; for small system, eps should be large.
while (1) {
while (true) {
int istr, iend, iinc;
// ask for relevant info
printf("\nThere are %d atoms in each unit cell of your lattice.\n", dynmat->nucell);
@ -401,8 +393,6 @@ void Phonon::ldos_rsgf()
}
memory->destroy(Hessian);
return;
}
/* ----------------------------------------------------------------------------
@ -412,19 +402,17 @@ void Phonon::dmanyq()
{
char str[MAXLINE];
double q[3];
while ( 1 ){
while ( true ){
printf("Please input the q-point to output the dynamical matrix: ");
input->read_stdin(str);
if (count_words(str) >= 3) break;
}
q[0] = atof(strtok(str," \t\n\r\f"));
q[1] = atof(strtok(NULL," \t\n\r\f"));
q[2] = atof(strtok(NULL," \t\n\r\f"));
q[1] = atof(strtok(nullptr," \t\n\r\f"));
q[2] = atof(strtok(nullptr," \t\n\r\f"));
dynmat->getDMq(q);
dynmat->writeDMq(q);
return;
}
/* ----------------------------------------------------------------------------
@ -436,7 +424,7 @@ void Phonon::vfanyq()
double q[3];
double *egvs = new double[ndim];
while ( 1 ){
while ( true ){
printf("Please input the q-point to compute the frequencies, q to exit: ");
input->read_stdin(str);
if (count_words(str) < 3) break;
@ -454,7 +442,6 @@ void Phonon::vfanyq()
}
delete[] egvs;
return;
}
/* ----------------------------------------------------------------------------
@ -471,7 +458,7 @@ void Phonon::vecanyq()
if (count_words(str) < 1) strcpy(str,"eigvec.dat");
FILE *fp = fopen(strtok(str," \t\n\r\f"), "w");
while ( 1 ){
while ( true ){
printf("Please input the q-point to compute the frequencies, q to exit: ");
input->read_stdin(str);
if (count_words(str) < 3) break;
@ -504,7 +491,6 @@ void Phonon::vecanyq()
fclose(fp);
delete[] egvs;
eigvec = NULL;
return;
}
/* ----------------------------------------------------------------------------
@ -528,7 +514,7 @@ void Phonon::DMdisp()
int nq = MAX(MAX(dynmat->nx,dynmat->ny),dynmat->nz)/2;
qend[0] = qend[1] = qend[2] = 0.;
while ( 1 ){
while ( true ){
for (int i = 0; i < 3; ++i) qstr[i] = qend[i];
printf("\nPlease input the start q-point in unit of B1->B3, q to exit [%g %g %g]: ", qstr[0], qstr[1], qstr[2]);
@ -542,7 +528,7 @@ void Phonon::DMdisp()
qstr[2] = atof(strtok(NULL," \t\n\r\f"));
}
while ( 1 ){
while ( true ){
printf("Please input the end q-point in unit of B1->B3: ");
input->read_stdin(str);
if (count_words(str) >= 3) break;
@ -569,8 +555,6 @@ void Phonon::DMdisp()
qr -= dq;
}
fclose(fp);
return;
}
/* ----------------------------------------------------------------------------
@ -605,8 +589,6 @@ void Phonon::smooth(double *array, const int npt)
memory->destroy(tmp);
memory->destroy(table);
return;
}
/* ----------------------------------------------------------------------------
@ -671,8 +653,6 @@ void Phonon::therm()
} while (T > 0.);
fclose(fp);
return;
}
/* ----------------------------------------------------------------------------
@ -707,7 +687,7 @@ void Phonon::local_therm()
// constants J.s J/K J
const double h = 6.62606896e-34, Kb = 1.380658e-23, eV = 1.60217733e-19;
double T = dynmat->Tmeasure;
while ( 1 ){
while ( true ){
printf("\nPlease input the temperature at which to evaluate the local vibrational\n");
printf("thermal properties, non-positive number to exit [%g]: ", T);
input->read_stdin(str);
@ -789,8 +769,6 @@ void Phonon::local_therm()
}
}
fclose(fp);
return;
}
/* ----------------------------------------------------------------------------
@ -935,8 +913,6 @@ void Phonon::QMesh()
}
#endif
printf("Your new q-mesh size would be: %d x %d x %d => %d points\n", nx,ny,nz,nq);
return;
}
/* ----------------------------------------------------------------------------
@ -1055,8 +1031,6 @@ void Phonon::ldos_egv()
// evaluate the local vibrational thermal properties optionally
local_therm();
return;
}
/* ----------------------------------------------------------------------------
@ -1078,8 +1052,6 @@ void Phonon::ShowCell()
for (int i = 0; i < dynmat->nucell; ++i)
printf("%4d %12.8f %12.8f %12.8f\n", dynmat->attyp[i], dynmat->basis[i][0], dynmat->basis[i][1], dynmat->basis[i][2]);
puts("================================================================================");
return;
}
/* ----------------------------------------------------------------------------
@ -1112,8 +1084,7 @@ void Phonon::Normalize()
}
}
return;
}
}
/* ----------------------------------------------------------------------------
* Private method to calculate vibrational frequencies for all q-points
@ -1138,8 +1109,6 @@ void Phonon::ComputeAll()
}
printf("Done!\n");
time->stop(); time->print(); delete time;
return;
}
/*------------------------------------------------------------------------------

View File

@ -60,8 +60,6 @@ Phonopy::Phonopy(DynMat *dynmat)
phonopy();
return;
}
/* ----------------------------------------------------------------------------
@ -72,8 +70,7 @@ Phonopy::~Phonopy()
memory->destroy(mass);
memory->destroy(FC_all);
delete memory;
dm = NULL;
return;
dm = nullptr;
}
/* ----------------------------------------------------------------------------
@ -111,7 +108,6 @@ void Phonopy::write(int flag)
} else if (flag == 5){
puts("================================================================================");
}
return;
}
/* ----------------------------------------------------------------------------
@ -141,7 +137,6 @@ void Phonopy::get_my_FC()
}
++ipt;
}
return;
}
/* ----------------------------------------------------------------------------
@ -304,7 +299,6 @@ void Phonopy::phonopy()
write(5);
delete[] type_id;
delete[] num_type;
return;
}
/*------------------------------------------------------------------------------

View File

@ -11,8 +11,6 @@ QNodes::QNodes()
qs.clear();
qe.clear();
nqbin.clear();
return;
}
/* ----------------------------------------------------------------------------
@ -25,6 +23,4 @@ QNodes::~QNodes()
qs.clear();
qe.clear();
nqbin.clear();
return;
}

View File

@ -9,8 +9,6 @@ Timer::Timer()
{
flag = 0;
start();
return;
}
/* -----------------------------------------------------------------------------
@ -20,7 +18,6 @@ void Timer::start()
{
t1 = clock();
flag |= 1;
return;
}
/* -----------------------------------------------------------------------------
@ -32,8 +29,7 @@ void Timer::stop()
t2 = clock();
flag |= 2;
}
return;
}
}
/* -----------------------------------------------------------------------------
* public function, print the total time used after timer stops
@ -44,8 +40,6 @@ void Timer::print()
double cpu_time_used = ((double) (t2 - t1)) / CLOCKS_PER_SEC;
printf("Total CPU time used: %g seconds.\n", cpu_time_used);
return;
}
/* -----------------------------------------------------------------------------

View File

@ -90,7 +90,7 @@ static void point2xyz(int p, int *x, int *y, int *z) {
}
}
const char *tricubic_version(void) {
const char *tricubic_version() {
return(tricubic_version_stored);
}