integrate CMake build procedure for tools/phonon

This commit is contained in:
Axel Kohlmeyer
2023-04-29 02:59:04 -04:00
parent 41a0196874
commit 478058119b
34 changed files with 1260 additions and 591 deletions

View File

@ -1,10 +1,18 @@
#include "string.h"
#include "qnodes.h"
#include "global.h"
#include "phonon.h"
#include "green.h"
#include "timer.h"
#include "dynmat.h"
#include "global.h"
#include "input.h"
#include "kpath.h"
#include "qnodes.h"
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
/*------------------------------------------------------------------------------
* Private method to evaluate the phonon dispersion curves
@ -13,19 +21,22 @@ 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");
puts("================================================================================");
#ifdef UseSPG
// ask method to generate q-lines
int method = 2;
printf("Please select your method to generate the phonon dispersion:\n");
printf(" 1. Manual, should always work;\n");
printf(" 2. Automatic, works only for 3D crystals (CMS49-299).\nYour choice [2]: ");
if (count_words(fgets(str,MAXLINE,stdin)) > 0) method = atoi(strtok(str," \t\n\r\f"));
input->read_stdin(str);
if (count_words(str) > 0) method = atoi(strtok(str," \t\n\r\f"));
method = 2 - method%2;
printf("Your selection: %d\n", method);
#endif
printf("\nPlease input the filename to output the dispersion data [pdisp.dat]:");
if (count_words(fgets(str,MAXLINE,stdin)) < 1) strcpy(str, "pdisp.dat");
input->read_stdin(str);
if (count_words(str) < 1) strcpy(str, "pdisp.dat");
char *ptr = strtok(str," \t\n\r\f");
char *fname = new char[strlen(ptr)+1];
strcpy(fname,ptr);
@ -45,9 +56,9 @@ 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));
input->read_stdin(str);
int n = count_words(str);
ptr = strtok(str, " \t\n\r\f");
if ((n == 1) && (strcmp(ptr,"q") == 0)) break;
else if (n >= 3){
@ -56,14 +67,18 @@ void Phonon::pdisp()
qstr[2] = atof(strtok(NULL, " \t\n\r\f"));
}
do printf("Please input the end q-point in unit of B1->B3: ");
while (count_words(fgets(str, MAXLINE, stdin)) < 3);
while ( 1 ){
printf("Please input the end q-point in unit of B1->B3: ");
input->read_stdin(str);
if (count_words(str) >= 3) break;
}
qend[0] = atof(strtok(str, " \t\n\r\f"));
qend[1] = atof(strtok(NULL, " \t\n\r\f"));
qend[2] = atof(strtok(NULL, " \t\n\r\f"));
printf("Please input the # of points along the line [%d]: ", nq);
if (count_words(fgets(str, MAXLINE, stdin)) > 0) nq = atoi(strtok(str," \t\n\r\f"));
input->read_stdin(str);
if (count_words(str) > 0) nq = atoi(strtok(str," \t\n\r\f"));
nq = MAX(nq,2);
double *qtmp = new double [3];
@ -147,7 +162,7 @@ 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");
puts("================================================================================");
delete []fname;
delete qnodes;