Skip to content

Commit

Permalink
Merged in DOSbugFix (pull request #581)
Browse files Browse the repository at this point in the history
In dos.cc, different upperBoundEpsilon and lowerBoundEpsilon across ranks issue fixed

Approved-by: Sambit Das
Approved-by: Phani Motamarri
  • Loading branch information
nandis99 authored and phanimotamarri committed Apr 24, 2024
2 parents 9ce5c91 + fc31b96 commit 903f4a6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
48 changes: 46 additions & 2 deletions src/dft/dos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,24 @@ namespace dftfe
const double totalEigenValues = eigenValuesAllkPoints.size();
const double intervalSize = 0.001;
const double sigma = C_kb * d_dftParamsPtr->TVal;
const double lowerBoundEpsilon = 1.5 * eigenValuesAllkPoints[0];
const double upperBoundEpsilon =
double lowerBoundEpsilon = 1.5 * eigenValuesAllkPoints[0];
double upperBoundEpsilon =
eigenValuesAllkPoints[totalEigenValues - 1] * 1.5;

MPI_Allreduce(MPI_IN_PLACE,
&lowerBoundEpsilon,
1,
dataTypes::mpi_type_id(&lowerBoundEpsilon),
MPI_MIN,
interpoolcomm);

MPI_Allreduce(MPI_IN_PLACE,
&upperBoundEpsilon,
1,
dataTypes::mpi_type_id(&upperBoundEpsilon),
MPI_MAX,
interpoolcomm);

const unsigned int numberIntervals =
std::ceil((upperBoundEpsilon - lowerBoundEpsilon) / intervalSize);

Expand Down Expand Up @@ -386,6 +401,21 @@ namespace dftfe
double lowerBoundEpsilon = 1.5 * eigenValuesAllkPoints[0];
double upperBoundEpsilon =
eigenValuesAllkPoints[totalEigenValues - 1] * 1.5;

MPI_Allreduce(MPI_IN_PLACE,
&lowerBoundEpsilon,
1,
dataTypes::mpi_type_id(&lowerBoundEpsilon),
MPI_MIN,
interpoolcomm);

MPI_Allreduce(MPI_IN_PLACE,
&upperBoundEpsilon,
1,
dataTypes::mpi_type_id(&upperBoundEpsilon),
MPI_MAX,
interpoolcomm);

unsigned int numberIntervals =
std::ceil((upperBoundEpsilon - lowerBoundEpsilon) / intervalSize);
unsigned int numberGlobalAtoms = atomLocations.size();
Expand Down Expand Up @@ -967,6 +997,20 @@ namespace dftfe
double upperBoundEpsilon =
eigenValuesAllkPoints[totalEigenValues - 1] * 1.5;

MPI_Allreduce(MPI_IN_PLACE,
&lowerBoundEpsilon,
1,
dataTypes::mpi_type_id(&lowerBoundEpsilon),
MPI_MIN,
interpoolcomm);

MPI_Allreduce(MPI_IN_PLACE,
&upperBoundEpsilon,
1,
dataTypes::mpi_type_id(&upperBoundEpsilon),
MPI_MAX,
interpoolcomm);

unsigned int numberIntervals =
std::ceil((upperBoundEpsilon - lowerBoundEpsilon) / intervalSize);
std::vector<double> partialDensityOfStates;
Expand Down
7 changes: 2 additions & 5 deletions src/dft/kohnShamEigenSolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1023,15 +1023,12 @@ namespace dftfe
if (factor <= 0.0)
{
double temp2 = 1.0 / (1.0 + exp(factor));
functionValue = (2.0 - d_dftParamsPtr->spinPolarized) *
d_kPointWeights[kPoint] * temp2;
functionValue = (2.0 - d_dftParamsPtr->spinPolarized)*temp2;
}
else
{
double temp2 = 1.0 / (1.0 + exp(-factor));
functionValue = (2.0 - d_dftParamsPtr->spinPolarized) *
d_kPointWeights[kPoint] * exp(-factor) *
temp2;
functionValue = (2.0 - d_dftParamsPtr->spinPolarized) * exp(-factor) * temp2;
}
if (functionValue > 1e-3)
highestOccupiedState = i;
Expand Down

0 comments on commit 903f4a6

Please sign in to comment.