Skip to content

Commit

Permalink
...EJB
Browse files Browse the repository at this point in the history
  • Loading branch information
ebylaska committed Nov 28, 2023
1 parent 5c959ef commit 1641264
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 144 deletions.
7 changes: 6 additions & 1 deletion Nwpw/band/cpsd/band_cpsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int band_cpsd(MPI_Comm comm_world0, std::string &rtdbstring)
{
Parallel myparallel(comm_world0);

int version, nfft[3], ne[2], ispin, nbrillq;
int version, nfft[3], ne[2], ispin, nbrillq, nbrillouin;
int i, ii, ia, nn, ngrid[3], matype, nelem, icount, done;
char date[26];
double sum1, sum2, ev, zv;
Expand Down Expand Up @@ -115,6 +115,7 @@ int band_cpsd(MPI_Comm comm_world0, std::string &rtdbstring)
Cneb mygrid(&myparallel, &mylattice, control, control.ispin(),control.ne_ptr(),&mybrillouin);

/* initialize psi1 and psi2 */
nbrillouin = mygrid.nbrillouin;
ispin = control.ispin(); ne[0] = mygrid.ne[0]; ne[1] = mygrid.ne[1]; nbrillq = mygrid.nbrillq;
psi1 = mygrid.g_allocate_nbrillq_all();
psi2 = mygrid.g_allocate_nbrillq_all();
Expand All @@ -128,6 +129,7 @@ int band_cpsd(MPI_Comm comm_world0, std::string &rtdbstring)

// psi_read(&mygrid,&version,nfft,unita,&ispin,ne,nbrill,psi2,control.input_movecs_filename());
bool newpsi = cpsi_read(&mygrid,control.input_movecs_filename(),control.input_movecs_initialize(),psi2,std::cout);
mygrid.gg_copy(psi2,psi1);
MPI_Barrier(comm_world0);

/* setup structure factor */
Expand Down Expand Up @@ -295,6 +297,9 @@ int band_cpsd(MPI_Comm comm_world0, std::string &rtdbstring)

MPI_Barrier(comm_world0);

// write wavefunctions
//cpsi_write(&mygrid,&version,nfft,unita,&ispin,ne,&nbrillouin,psi1,control.output_movecs_filename(),std::cout);


/* deallocate memory */
std::cout << "deallocate memory, taskid=" << myparallel.taskid()
Expand Down
23 changes: 15 additions & 8 deletions Nwpw/band/lib/cpsi/cpsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void cwvfnc_expander(Cneb *mycneb, char *filename, std::ostream &coutput)

bool lprint = myparall->base_stdio_print;

int version, ispin, occupation, nfft[3], dnfft[3], ne[2];
int version, ispin, occupation, nfft[3], dnfft[3], ne[2], nbrillouin;
double unita[9], dunita[9];
char tmpfilename[256];
strcpy(tmpfilename, filename);
Expand All @@ -129,6 +129,7 @@ static void cwvfnc_expander(Cneb *mycneb, char *filename, std::ostream &coutput)
dread(4, unita, 9);
iread(4, &ispin, 1);
iread(4, ne, 2);
iread(4, &nbrillouin, 1);
iread(4, &occupation, 1);

dnfft[0] = mycneb->nx;
Expand All @@ -150,6 +151,7 @@ static void cwvfnc_expander(Cneb *mycneb, char *filename, std::ostream &coutput)
dwrite(6, dunita, 9);
iwrite(6, &ispin, 1);
iwrite(6, ne, 2);
iwrite(6, &nbrillouin, 1);
iwrite(6, &occupation, 1);

int n2ft3d = (nfft[0] + 2) * nfft[1] * nfft[2];
Expand Down Expand Up @@ -191,7 +193,7 @@ static void cwvfnc_expander(Cneb *mycneb, char *filename, std::ostream &coutput)
* *
*****************************************************/
void cpsi_get_header(Parallel *myparall, int *version, int nfft[],
double unita[], int *ispin, int ne[], char *filename)
double unita[], int *ispin, int ne[], int *nbrillouin, char *filename)
{
if (myparall->is_master())
{
Expand All @@ -202,6 +204,7 @@ void cpsi_get_header(Parallel *myparall, int *version, int nfft[],
dread(4, unita, 9);
iread(4, ispin, 1);
iread(4, ne, 2);
iread(4, nbrillouin, 1);
closefile(4);
}
myparall->Brdcst_iValue(0, 0, version);
Expand All @@ -219,11 +222,11 @@ void cpsi_get_header(Parallel *myparall, int *version, int nfft[],
static bool cpsi_check_convert(Cneb *mycneb, char *filename, std::ostream &coutput)
{
Parallel *myparall = mycneb->c3db::parall;
int version0, ispin0, nfft0[3], ne0[2];
int version0, ispin0, nfft0[3], ne0[2], nbrillouin0;
double unita0[9];
bool converted = false;

cpsi_get_header(myparall, &version0, nfft0, unita0, &ispin0, ne0, filename);
cpsi_get_header(myparall, &version0, nfft0, unita0, &ispin0, ne0, &nbrillouin0, filename);
if ((nfft0[0] != mycneb->nx) || (nfft0[1] != mycneb->ny) || (nfft0[2] != mycneb->nz))
{
if (myparall->base_stdio_print)
Expand All @@ -249,7 +252,7 @@ static bool cpsi_check_convert(Cneb *mycneb, char *filename, std::ostream &coutp
*/
void cpsi_read0(Cneb *mycneb, int *version, int nfft[], double unita[],
int *ispin, int ne[], double *psi, char *filename)
int *ispin, int ne[], int *nbrillouin, double *psi, char *filename)
{
int occupation;

Expand All @@ -263,13 +266,15 @@ void cpsi_read0(Cneb *mycneb, int *version, int nfft[], double unita[],
dread(4, unita, 9);
iread(4, ispin, 1);
iread(4, ne, 2);
iread(4, nbrillouin, 1);
iread(4, &occupation, 1);
}
myparall->Brdcst_iValue(0, 0, version);
myparall->Brdcst_iValues(0, 0, 3, nfft);
myparall->Brdcst_Values(0, 0, 9, unita);
myparall->Brdcst_iValue(0, 0, ispin);
myparall->Brdcst_iValues(0, 0, 2, ne);
myparall->Brdcst_iValue(0, 0, nbrillouin);

/* reads in c format and automatically packs the result to g format */
//mycneb->g_read(4,ispin,psi);
Expand Down Expand Up @@ -300,7 +305,7 @@ void cpsi_read0(Cneb *mycneb, int *version, int nfft[], double unita[],
bool cpsi_read(Cneb *mycneb, char *filename, bool wvfnc_initialize, double *psi2, std::ostream &coutput)
{
nwpw_timing_function ftimer(50);
int version, ispin, nfft[3], ne[2];
int version, ispin, nfft[3], ne[2],nbrillouin;
double unita[9];
Parallel *myparall = mycneb->c3db::parall;
bool newpsi = true;
Expand All @@ -313,7 +318,7 @@ bool cpsi_read(Cneb *mycneb, char *filename, bool wvfnc_initialize, double *psi2
if (myparall->base_stdio_print)
coutput << " input psi exists, reading from file: " << filename << std::endl;

cpsi_read0(mycneb, &version, nfft, unita, &ispin, ne, psi2, filename);
cpsi_read0(mycneb, &version, nfft, unita, &ispin, ne, &nbrillouin, psi2, filename);
}

/* generate new psi */
Expand All @@ -323,6 +328,7 @@ bool cpsi_read(Cneb *mycneb, char *filename, bool wvfnc_initialize, double *psi2
mycneb->g_generate_random(psi2);
}
newpsi = newpsi || (ispin != mycneb->ispin)
|| (nbrillouin != mycneb->nbrillouin)
|| (ne[0] != mycneb->ne[0])
|| (ne[1] != mycneb->ne[1])
|| (std::abs(unita[0] - mycneb->lattice->unita1d(0)) > 1.0e-4)
Expand Down Expand Up @@ -363,7 +369,7 @@ bool cpsi_read(Cneb *mycneb, char *filename, bool wvfnc_initialize, double *psi2
* *
*****************************************************/
void cpsi_write(Cneb *mycneb, int *version, int nfft[], double unita[],
int *ispin, int ne[], double *psi, char *filename,
int *ispin, int ne[], int *nbrillouin, double *psi, char *filename,
std::ostream &coutput)
{
nwpw_timing_function ftimer(50);
Expand All @@ -382,6 +388,7 @@ void cpsi_write(Cneb *mycneb, int *version, int nfft[], double unita[],
dwrite(6, unita, 9);
iwrite(6, ispin, 1);
iwrite(6, ne, 2);
iwrite(6, nbrillouin, 1);
iwrite(6, &occupation, 1);
}

Expand Down
6 changes: 3 additions & 3 deletions Nwpw/band/lib/cpsi/cpsi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

namespace pwdft {

extern void cpsi_get_header(Parallel *, int *, int *, double *, int *, int *, char *);
extern void cpsi_get_header(Parallel *, int *, int *, double *, int *, int *, int *, char *);

extern void cpsi_read0(Cneb *, int *, int *, double *, int *, int *, double *, char *);
extern void cpsi_read0(Cneb *, int *, int *, double *, int *, int *, int *, double *, char *);
extern bool cpsi_read(Cneb *, char *, bool, double *, std::ostream &);

extern void cpsi_write(Cneb *, int *, int *, double *, int *, int *, double *, char *, std::ostream &);
extern void cpsi_write(Cneb *, int *, int *, double *, int *, int *, int *, double *, char *, std::ostream &);
extern bool cpsi_filefind(Cneb *, char *);

// extern void v_psi_read(Pneb *, int *, int *, double *, int *, int *,double
Expand Down
Loading

0 comments on commit 1641264

Please sign in to comment.