Skip to content

Commit

Permalink
Merge pull request #3799 from ye-luo/change-twist-precedence
Browse files Browse the repository at this point in the history
Make twist attribute taking precedence over twistnum.
  • Loading branch information
prckent authored Feb 4, 2022
2 parents e90deb7 + 1b9e722 commit 08d9943
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 128 deletions.
4 changes: 2 additions & 2 deletions docs/hamiltonianobservable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ Additional information:
:caption: Example ``sposet`` initialization for density matrix use. Occupied and virtual orbital sets are created separately, then joined (``basis="spo_u spo_uv"``).
:name: Listing 39
<sposet_builder type="bspline" href="../dft/pwscf_output/pwscf.pwscf.h5" tilematrix="1 0 0 0 1 0 0 0 1" twistnum="0" meshfactor="1.0" gpu="no" precision="single">
<sposet_builder type="bspline" href="../dft/pwscf_output/pwscf.pwscf.h5" tilematrix="1 0 0 0 1 0 0 0 1" meshfactor="1.0" gpu="no" precision="single">
<sposet type="bspline" name="spo_u" group="0" size="4"/>
<sposet type="bspline" name="spo_d" group="0" size="2"/>
<sposet type="bspline" name="spo_uv" group="0" index_min="4" index_max="10"/>
Expand All @@ -1692,7 +1692,7 @@ Additional information:
:caption: Example ``sposet`` initialization for density matrix use. Density matrix orbital basis created separately (``basis="dm_basis"``).
:name: Listing 40
<sposet_builder type="bspline" href="../dft/pwscf_output/pwscf.pwscf.h5" tilematrix="1 0 0 0 1 0 0 0 1" twistnum="0" meshfactor="1.0" gpu="no" precision="single">
<sposet_builder type="bspline" href="../dft/pwscf_output/pwscf.pwscf.h5" tilematrix="1 0 0 0 1 0 0 0 1" meshfactor="1.0" gpu="no" precision="single">
<sposet type="bspline" name="spo_u" group="0" size="4"/>
<sposet type="bspline" name="spo_d" group="0" size="2"/>
<sposet type="bspline" name="dm_basis" size="50" spindataset="0"/>
Expand Down
20 changes: 13 additions & 7 deletions docs/intro_wavefunction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ determinants.
:caption: Deprecated input style.
:name: spo.singledet.old.xml
<determinantset type="einspline" href="pwscf.pwscf.h5" tilematrix="2 0 0 0 1 0 0 0 1" twistnum="0" source="ion0" meshfactor="1.0" precision="double">
<determinantset type="einspline" href="pwscf.pwscf.h5" tilematrix="2 0 0 0 1 0 0 0 1" source="ion0" meshfactor="1.0" precision="double">
<slaterdeterminant>
<determinant id="updet" size="8">
<occupation mode="ground" spindataset="0"/>
Expand All @@ -142,7 +142,7 @@ After updating the input style.
:name: spo.singledet.xml
<!-- all the attributes are moved from determinantset.-->
<sposet_collection type="einspline" href="pwscf.pwscf.h5" tilematrix="2 0 0 0 1 0 0 0 1" twistnum="0" source="ion0" meshfactor="1.0" precision="double">
<sposet_collection type="einspline" href="pwscf.pwscf.h5" tilematrix="2 0 0 0 1 0 0 0 1" source="ion0" meshfactor="1.0" precision="double">
<!-- all the attributes and contents are moved from determinant. Change 'id' tag to 'name' tag.
Need only one sposet for unpolarized calculation.-->
<sposet name="spo-ud" size="8">
Expand Down Expand Up @@ -221,7 +221,7 @@ The input xml block for the spline SPOs is given in :ref:`spline.spo.xml`. A lis
:name: spline.spo.xml
<sposet_collection type="bspline" source="i" href="pwscf.h5"
tilematrix="1 1 3 1 2 -1 -2 1 0" twistnum="-1" gpu="yes" meshfactor="0.8"
tilematrix="1 1 3 1 2 -1 -2 1 0" gpu="yes" meshfactor="0.8"
twist="0 0 0" precision="double">
<sposet name="spo-up" size="208">
<occupation mode="ground" spindataset="0"/>
Expand Down Expand Up @@ -297,9 +297,15 @@ Additional information:
calculations. Use with caution!

- twistnum
If positive, it is the index. We recommend not taking
this way since the indexing might show some uncertainty. If negative,
the super twist is referred by ``twist``.
We recommend not using it in the input because the ordering of orbitals
depends on how they are being stored in the h5 file. ``twistnum`` gets
ignored if ``twist`` exists in the input. If positive, it is the index.
If negative, the super twist is referred by ``twist``. This input
parameter is kept only for keeping old input files working.

- twist
The twist angle. If neither ``twist`` nor ``twistnum`` is provided,
Take Gamma point, (0, 0, 0).

- save_coefs
If yes, dump the real-space B-spline coefficient
Expand Down Expand Up @@ -637,7 +643,7 @@ To enable hybrid orbital representation, the input XML needs to see the tag ``hy
:name: Listing 6
<sposet_collection type="bspline" source="i" href="pwscf.h5"
tilematrix="1 1 3 1 2 -1 -2 1 0" twistnum="-1" gpu="yes" meshfactor="0.8"
tilematrix="1 1 3 1 2 -1 -2 1 0" gpu="yes" meshfactor="0.8"
twist="0 0 0" precision="single" hybridrep="yes">
...
</sposet_collection>
Expand Down
6 changes: 3 additions & 3 deletions src/QMCWaveFunctions/BsplineFactory/BsplineReaderBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ std::unique_ptr<SPOSet> BsplineReaderBase::create_spline_set(int spin, xmlNodePt
BandInfoGroup vals;
vals.TwistIndex = fullband[0].TwistIndex;
vals.GroupID = 0;
vals.myName = make_bandgroup_name(mybuilder->getName(), spin, mybuilder->TwistNum, mybuilder->TileMatrix, 0, ns);
vals.myName = make_bandgroup_name(mybuilder->getName(), spin, mybuilder->twist_num_, mybuilder->TileMatrix, 0, ns);
vals.selectBands(fullband, 0, ns, false);

return create_spline_set(spin, vals);
Expand All @@ -151,7 +151,7 @@ std::unique_ptr<SPOSet> BsplineReaderBase::create_spline_set(int spin, xmlNodePt
BandInfoGroup vals;
vals.TwistIndex = fullband[0].TwistIndex;
vals.GroupID = 0;
vals.myName = make_bandgroup_name(mybuilder->getName(), spin, mybuilder->TwistNum, mybuilder->TileMatrix,
vals.myName = make_bandgroup_name(mybuilder->getName(), spin, mybuilder->twist_num_, mybuilder->TileMatrix,
input_info.min_index(), input_info.max_index());
vals.selectBands(fullband, spo2band[spin][input_info.min_index()], input_info.max_index() - input_info.min_index(),
false);
Expand Down Expand Up @@ -193,7 +193,7 @@ void BsplineReaderBase::initialize_spo2band(int spin,
if (comm->rank())
return;

std::string aname = make_bandinfo_filename(mybuilder->getName(), spin, mybuilder->TwistNum, mybuilder->TileMatrix,
std::string aname = make_bandinfo_filename(mybuilder->getName(), spin, mybuilder->twist_num_, mybuilder->TileMatrix,
comm->getGroupID());
aname += ".bandinfo.dat";

Expand Down
32 changes: 22 additions & 10 deletions src/QMCWaveFunctions/EinsplineSetBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,6 @@ class EinsplineSetBuilder : public SPOSetBuilder
*/
std::unique_ptr<SPOSet> createSPOSetFromXML(xmlNodePtr cur) override;

/** a specific but clean code path in createSPOSetFromXML, for PBC, double, ESHDF
* @param cur the current xml node
*/
void set_metadata(int numOrbs, int TwistNum_inp, bool skipChecks = false);

/** initialize with the existing SPOSet */
std::unique_ptr<SPOSet> createSPOSet(xmlNodePtr cur, SPOSetInputInfo& input_info) override;

Expand Down Expand Up @@ -218,9 +213,8 @@ class EinsplineSetBuilder : public SPOSetBuilder
/////////////////////////////
// Twist angle information //
/////////////////////////////
// This stores which "true" twist number I am using
int TwistNum;
TinyVector<double, OHMMS_DIM> givenTwist;
// The "true" twist number after analyzing twistnum, twist XML input and h5
int twist_num_;
std::vector<TinyVector<double, OHMMS_DIM>> TwistAngles;
// integer index of sym operation from the irreducible brillion zone
std::vector<int> TwistSymmetry;
Expand All @@ -244,8 +238,6 @@ class EinsplineSetBuilder : public SPOSetBuilder
inline bool TwistPair(PosType a, PosType b);
// This maps a 3-integer twist index into the twist number in the file
std::map<TinyVector<int, OHMMS_DIM>, int, Int3less> TwistMap;
//void AnalyzeTwists();
void AnalyzeTwists2();
void TileIons();
void OccupyBands(int spin, int sortBands, int numOrbs, bool skipChecks = false);
void OccupyBands_ESHDF(int spin, int sortBands, int numOrbs);
Expand Down Expand Up @@ -306,12 +298,32 @@ class EinsplineSetBuilder : public SPOSetBuilder
int particle_hole_pairs;
bool makeRotations;

protected:
/** broadcast SortBands
* @param N number of state
* @param root true if it is the i/o node
* @return true, if core is found
*/
bool bcastSortBands(int splin, int N, bool root);

/** a specific but clean code path in createSPOSetFromXML, for PBC, double, ESHDF
* @param cur the current xml node
*/
void set_metadata(int numOrbs,
int twist_num_inp,
const TinyVector<double, OHMMS_DIM>& twist_inp,
bool skipChecks = false);

/** analyze twists of orbitals in h5 and determinine twist_num_
* @param twist_num_inp twistnum XML input
* @param twist_inp twst XML input
*/
void AnalyzeTwists2(const int twist_num_inp, const TinyVector<double, OHMMS_DIM>& twist_inp);

/// twistnum_inp == -9999 to indicate no given input after parsing XML
static constexpr int TWISTNUM_NO_INPUT = -9999;
/// twist_inp[i] <= -9999 to indicate no given input after parsing XML
static constexpr double TWIST_NO_INPUT = -9999;
};

} // namespace qmcplusplus
Expand Down
Loading

0 comments on commit 08d9943

Please sign in to comment.