Skip to content

Commit

Permalink
Merge branch 'develop' into nonlocaloutput
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-luo authored Feb 2, 2022
2 parents c2bbf4f + 630f904 commit 4928a86
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 496 deletions.
6 changes: 3 additions & 3 deletions src/Estimators/MomentumDistribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ MomentumDistribution::MomentumDistribution(MomentumDistributionInput&& mdi,
for (int k = -kgrid; k < (kgrid + 1); k++)
{
PosType ikpt, kpt;
ikpt[0] = i - twist[0];
ikpt[1] = j - twist[1];
ikpt[2] = k - twist[2];
ikpt[0] = i + twist[0];
ikpt[1] = j + twist[1];
ikpt[2] = k + twist[2];
//convert to Cartesian: note that 2Pi is multiplied
kpt = Lattice.k_cart(ikpt);
bool not_recorded = true;
Expand Down
6 changes: 3 additions & 3 deletions src/QMCHamiltonians/MomentumEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ bool MomentumEstimator::putSpecial(xmlNodePtr cur, ParticleSet& elns, bool rootN
for (int k = -kgrid; k < (kgrid + 1); k++)
{
PosType ikpt, kpt;
ikpt[0] = i - twist[0];
ikpt[1] = j - twist[1];
ikpt[2] = k - twist[2];
ikpt[0] = i + twist[0];
ikpt[1] = j + twist[1];
ikpt[2] = k + twist[2];
//convert to Cartesian: note that 2Pi is multiplied
kpt = lattice_.k_cart(ikpt);
bool not_recorded = true;
Expand Down
5 changes: 2 additions & 3 deletions src/QMCWaveFunctions/BsplineFactory/BsplineReaderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct BsplineReaderBase
for (int iorb = 0; iorb < N; iorb++)
{
int ti = cur_bands[iorb].TwistIndex;
bspline->kPoints[iorb] = mybuilder->PrimCell.k_cart(mybuilder->TwistAngles[ti]); //twist);
bspline->kPoints[iorb] = mybuilder->PrimCell.k_cart(-mybuilder->TwistAngles[ti]);
bspline->MakeTwoCopies[iorb] = (num < (numOrbs - 1)) && cur_bands[iorb].MakeTwoCopies;
num += bspline->MakeTwoCopies[iorb] ? 2 : 1;
}
Expand All @@ -125,7 +125,6 @@ struct BsplineReaderBase
if (!bspline->is_complex)
{
//no k-point folding, single special k point (G, L ...)
//TinyVector<double,3> twist0 = mybuilder->TwistAngles[cur_bands[0].TwistIndex];
TinyVector<double, 3> twist0 = mybuilder->TwistAngles[bandgroup.TwistIndex];
for (int i = 0; i < 3; i++)
if (bconds[i] && ((std::abs(std::abs(twist0[i]) - 0.5) < 1.0e-8)))
Expand Down Expand Up @@ -191,7 +190,7 @@ struct BsplineReaderBase

/** export the MultiSpline to the old class EinsplineSetExtended for the GPU calculation*/
virtual std::unique_ptr<multi_UBspline_3d_z> export_MultiSplineComplexDouble() = 0;
virtual std::unique_ptr<multi_UBspline_3d_d> export_MultiSplineDouble() = 0;
virtual std::unique_ptr<multi_UBspline_3d_d> export_MultiSplineDouble() = 0;
};

} // namespace qmcplusplus
Expand Down
5 changes: 4 additions & 1 deletion src/QMCWaveFunctions/BsplineFactory/BsplineSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class BsplineSet : public SPOSet
TinyVector<int, D> HalfG;
///flags to unpack sin/cos
std::vector<bool> MakeTwoCopies;
///kpoints for each unique orbitals
/** kpoints for each unique orbitals.
* Note: for historic reason, this sign is opposite to what was used in DFT when orbitals were generated.
* Changing the sign requires updating all the evaluation code.
*/
std::vector<SPOSet::PosType> kPoints;
///remap splines to orbitals
aligned_vector<int> BandIndexMap;
Expand Down
5 changes: 4 additions & 1 deletion src/QMCWaveFunctions/EinsplineSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ class EinsplineSetExtended : public EinsplineSet

// True if we should unpack this orbital into two copies
std::vector<bool> MakeTwoCopies;
// k-points for each orbital
/** kpoints for each unique orbitals.
* Note: for historic reason, this sign is opposite to what was used in DFT when orbitals were generated.
* Changing the sign requires updating all the evaluation code.
*/
Vector<TinyVector<double, OHMMS_DIM>> kPoints;

///////////////////
Expand Down
118 changes: 0 additions & 118 deletions src/QMCWaveFunctions/EinsplineSetBuilderCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,124 +633,6 @@ void EinsplineSetBuilder::AnalyzeTwists2()
}


// This function analyzes the twist vectors to see if they lay on a
// valid k-point mesh. It flags errors an aborts if they do not.
// As a side-effect, it sets up TwistMap, which maps [ix,iy,iz] into
// a single integer twist index.
/* seems legacy. Ye Luo
void
EinsplineSetBuilder::AnalyzeTwists()
{
PosType minTwist(TwistAngles[0]), maxTwist(TwistAngles[0]);
for (int ti=0; ti<NumTwists; ti++)
for (int i=0; i<3; i++)
{
minTwist[i] = std::min(TwistAngles[ti][i], minTwist[i]);
maxTwist[i] = std::max(TwistAngles[ti][i], maxTwist[i]);
}
// The difference between maxTwist and minTwist should be of the
// form (n-1)/n. Therefore, we determine n by
PosType nf;
nf[0] = -1.0/((maxTwist[0]-minTwist[0]) -1.0);
nf[1] = -1.0/((maxTwist[1]-minTwist[1]) -1.0);
nf[2] = -1.0/((maxTwist[2]-minTwist[2]) -1.0);
bool meshOK = true;
// Make sure they are close to integers
meshOK = meshOK && (std::abs(nf[0] - round(nf[0]))<1.0e-6);
meshOK = meshOK && (std::abs(nf[1] - round(nf[1]))<1.0e-6);
meshOK = meshOK && (std::abs(nf[2] - round(nf[2]))<1.0e-6);
if (!meshOK)
{
app_error() << "It appears that the twist angles in file "
<< H5FileName << " do not form a valid mesh. Aborting.\n";
APP_ABORT("EinsplineSetBuilder::AnalyzeTwists()");
}
TinyVector<int,3> n((int)round(nf[0]), (int)round(nf[1]), (int)round(nf[2]));
TwistMesh = n;
// Now, make sure we have all the k-points in the lattice
PosType twist;
for (int ix=0; ix<n[0]; ix++)
for (int iy=0; iy<n[1]; iy++)
for (int iz=0; iz<n[2]; iz++)
{
twist[0] =
minTwist[0] + (double)ix/(double)(n[0]-1)*(maxTwist[0]-minTwist[0]);
twist[1] =
minTwist[1] + (double)iy/(double)(n[1]-1)*(maxTwist[1]-minTwist[1]);
twist[2] =
minTwist[2] + (double)iz/(double)(n[2]-1)*(maxTwist[2]-minTwist[2]);
bool twistFound = false;
for (int ti=0; ti<NumTwists; ti++)
{
PosType diff = TwistAngles[ti]-twist;
if (dot(diff,diff)<1.0e-8)
{
twistFound = true;
TinyVector<int,3> tindex (ix, iy, iz);
TwistMap[tindex] = ti;
}
}
if (!twistFound)
{
fprintf (stderr, "Missing twist vector (%8.4f, %8.4f, %8.4f) "
"in CheckkPointMesh.\n", twist[0], twist[1], twist[2]);
abort();
}
}
// If we got this far, we have a valid twist mesh. Now check to
// see if the mesh is commensurate with the tiling factor
if (((TwistMesh[0] % TileFactor[0]) != 0) ||
((TwistMesh[1] % TileFactor[1]) != 0) ||
((TwistMesh[2] % TileFactor[2]) != 0))
{
app_error() << "The tiling factor, "
<< TileFactor[0] << "x" << TileFactor[1] << "x" << TileFactor[2]
<< " is not commensurate with the k-point mesh, "
<< TwistMesh[0] << "x" << TwistMesh[1] << "x" << TwistMesh[2] << ".\n";
abort();
}
TinyVector<int,3> untiledMesh (TwistMesh[0]/TileFactor[0],
TwistMesh[1]/TileFactor[1],
TwistMesh[2]/TileFactor[2]);
// Finally, let's decide which twist vectors we're supposed to
// read
fprintf (stderr, " After untiling by %dx%dx%d, we are left with a %dx%dx%d k-point mesh.\n",
TileFactor[0], TileFactor[1], TileFactor[2],
untiledMesh[0], untiledMesh[1], untiledMesh[2]);
TinyVector<int,3> offset;
offset[0] = TwistNum/(untiledMesh[2]*untiledMesh[1]);
offset[1] = (TwistNum%(untiledMesh[2]*untiledMesh[1])) / untiledMesh[1];
offset[2] = (TwistNum%(untiledMesh[2]*untiledMesh[1])) % untiledMesh[1];
// std::map<TinyVector<int,3>, int>::iterator iter;
// for (iter = TwistMap.begin(); iter!=TwistMap.end(); iter++)
// std::cerr << "TwistMap = " << (*iter).first
// << ", " << (*iter).second << std::endl;
app_log() << " Including twist vectors:\n";
UseTwists.clear();
for (int tx=0; tx<TileFactor[0]; tx++)
for (int ty=0; ty<TileFactor[1]; ty++)
for (int tz=0; tz<TileFactor[2]; tz++)
{
TinyVector<int,3> tIndex;
tIndex = offset;
tIndex[0] += tx*untiledMesh[0];
tIndex[1] += ty*untiledMesh[1];
tIndex[2] += tz*untiledMesh[2];
UseTwists.push_back(tIndex);
int ti = TwistMap[tIndex];
app_log() << "tIndex = (" << tIndex[0] << ", " << tIndex[1] << ", "
<< tIndex[2] << ")\n";
// fprintf (stderr, "tIndex = (%d, %d, %d) ti = %d\n",
// tIndex[0], tIndex[1], tIndex[2], ti);
char buff[100];
snprintf (buff, 100, " (%6.3f %6.3f %6.3f)\n",
TwistAngles[ti][0], TwistAngles[ti][1], TwistAngles[ti][2]);
app_log() << buff;
}
}
*/


void EinsplineSetBuilder::OccupyBands(int spin, int sortBands, int numOrbs, bool skipChecks)
{
if (myComm->rank() != 0)
Expand Down
Loading

0 comments on commit 4928a86

Please sign in to comment.