-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeOrbital SPOSet #4084
Merged
Merged
FreeOrbital SPOSet #4084
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
7335258
add free particle orbitals
Paul-St-Young e58fb64
update heg tests
Paul-St-Young 9e4a4d7
transfer old header
Paul-St-Young 28bb034
remove ElectronGasOrbital and its Complex
Paul-St-Young b137c6b
occupy half sphere of kvecs in real code
Paul-St-Young 9af84e4
add twist to KContainer
Paul-St-Young 406b5f1
use twist in free-particle orbitals
Paul-St-Young c0eb5ce
cut down HEGGrid
Paul-St-Young a6c02e0
cut HEG some more
Paul-St-Young c6d95e6
improve backflow tests
Paul-St-Young fa6aacd
mark makeClone as override
Paul-St-Young d83e24e
document free SPOSet
Paul-St-Young a7f2c18
override createSPOSetFromXML
Paul-St-Young b1ec05e
fix cmake for heg test
Paul-St-Young 53318ec
remove twist test in real code
Paul-St-Young e78c3ce
add batch driver tests
Paul-St-Young 5ad23b1
rename FreeParticle to FreeOrbital
Paul-St-Young 4a1fb17
rename test file
Paul-St-Young 557f73b
default twist
Paul-St-Young 9845e2b
throw runtime_error
Paul-St-Young cdb7b0e
start KContainer tests
Paul-St-Young 4af8496
kvecs in 2D
Paul-St-Young 8cfb2ae
const klist
Paul-St-Young 4fdd530
twist 2D
Paul-St-Young 1229433
twist in 3D
Paul-St-Young 60df854
run KContainer tests
Paul-St-Young 199bb85
clang format
Paul-St-Young bbde8ff
getter return const reference
Paul-St-Young 98ad010
fix missing Approx
Paul-St-Young 16ebc8b
fewer parenthesis
Paul-St-Young ad592eb
add license header
Paul-St-Young bf73840
Ewald2D license headers
Paul-St-Young fc38389
clang format
Paul-St-Young f4ed10d
one more missed Approx
Paul-St-Young 2ee528c
Merge branch 'develop' into fporb
prckent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,18 +70,24 @@ class KContainer : public QMCTraits | |
/** update k-vectors | ||
* @param sc supercell | ||
* @param kc cutoff radius in the K | ||
* @param twist shifts the center of the grid of k-vectors | ||
* @param useSphere if true, use the |K| | ||
*/ | ||
void updateKLists(const ParticleLayout& lattice, RealType kc, unsigned ndim, bool useSphere = true); | ||
void updateKLists(const ParticleLayout& lattice, | ||
RealType kc, | ||
unsigned ndim, | ||
const PosType& twist = PosType(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still missing documentation for twist. Say something about how twist affects KLists. |
||
bool useSphere = true); | ||
|
||
const auto& get_kpts_cart_soa() const { return kpts_cart_soa_; } | ||
|
||
private: | ||
/** compute approximate parallelpiped that surrounds kc | ||
* @param lattice supercell | ||
*/ | ||
void findApproxMMax(const ParticleLayout& lattice, unsigned ndim); | ||
/** construct the container for k-vectors */ | ||
void BuildKLists(const ParticleLayout& lattice, bool useSphere); | ||
void BuildKLists(const ParticleLayout& lattice, const PosType& twist, bool useSphere); | ||
|
||
/** K-vector in Cartesian coordinates in SoA layout | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
////////////////////////////////////////////////////////////////////////////////////// | ||
// This file is distributed under the University of Illinois/NCSA Open Source License. | ||
// See LICENSE file in top directory for details. | ||
// | ||
// Copyright (c) 2022 QMCPACK developers. | ||
// | ||
// File developed by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, CCQ @ Flatiron | ||
// | ||
// File created by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, CCQ @ Flatiron | ||
////////////////////////////////////////////////////////////////////////////////////// | ||
#include "catch.hpp" | ||
|
||
#include "Particle/LongRange/KContainer.h" | ||
#include "OhmmsPETE/TinyVector.h" | ||
|
||
namespace qmcplusplus | ||
{ | ||
using PosType = TinyVector<double, 3>; | ||
|
||
TEST_CASE("kcontainer at gamma in 3D", "[longrange]") | ||
{ | ||
const int ndim = 3; | ||
const double alat = 1.0; | ||
const double blat = 2 * M_PI / alat; | ||
|
||
// check first 3 shells of kvectors | ||
const std::vector<double> kcs = {blat, std::sqrt(2) * blat, std::sqrt(3) * blat}; | ||
const std::vector<int> nks = {6, 18, 26}; | ||
|
||
CrystalLattice<OHMMS_PRECISION, OHMMS_DIM> lattice; | ||
lattice.R.diagonal(1.0); | ||
lattice.set(lattice.R); // compute Rv and Gv from R | ||
|
||
KContainer klists; | ||
for (int ik = 0; ik < kcs.size(); ik++) | ||
{ | ||
const double kc = kcs[ik] + 1e-6; | ||
klists.updateKLists(lattice, kc, ndim); | ||
CHECK(klists.kpts.size() == nks[ik]); | ||
} | ||
const int mxk = klists.kpts.size(); | ||
int gvecs[26][3] = {{-1, 0, 0}, {0, -1, 0}, {0, 0, -1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {-1, -1, 0}, | ||
{-1, 0, -1}, {-1, 0, 1}, {-1, 1, 0}, {0, -1, -1}, {0, -1, 1}, {0, 1, -1}, {0, 1, 1}, | ||
{1, -1, 0}, {1, 0, -1}, {1, 0, 1}, {1, 1, 0}, {-1, -1, -1}, {-1, -1, 1}, {-1, 1, -1}, | ||
{-1, 1, 1}, {1, -1, -1}, {1, -1, 1}, {1, 1, -1}, {1, 1, 1}}; | ||
|
||
for (int ik = 0; ik < mxk; ik++) | ||
{ | ||
for (int ldim = 0; ldim < ndim; ldim++) | ||
{ | ||
CHECK(klists.kpts[ik][ldim] == gvecs[ik][ldim]); | ||
CHECK(klists.kpts[ik][ldim] * blat == Approx(klists.kpts_cart[ik][ldim])); | ||
} | ||
} | ||
} | ||
|
||
TEST_CASE("kcontainer at twist in 3D", "[longrange]") | ||
{ | ||
const int ndim = 3; | ||
const double alat = 1.0; | ||
const double blat = 2 * M_PI / alat; | ||
|
||
// twist one shell of kvectors | ||
const double kc = blat + 1e-6; | ||
|
||
CrystalLattice<OHMMS_PRECISION, OHMMS_DIM> lattice; | ||
lattice.R.diagonal(1.0); | ||
lattice.set(lattice.R); // compute Rv and Gv from R | ||
|
||
KContainer klists; | ||
|
||
PosType twist; | ||
twist[0] = 0.1; | ||
klists.updateKLists(lattice, kc, ndim, twist); | ||
CHECK(klists.kpts.size() == 1); | ||
CHECK(klists.kpts_cart[0][0] == Approx(blat * (twist[0] - 1))); | ||
|
||
twist = {-0.5, 0, 0.5}; | ||
klists.updateKLists(lattice, kc, ndim, twist); | ||
int gvecs[3][3] = {{0, 0, -1}, {1, 0, -1}, {1, 0, 0}}; | ||
CHECK(klists.kpts.size() == 3); | ||
for (int ik = 0; ik < klists.kpts.size(); ik++) | ||
for (int ldim = 0; ldim < ndim; ldim++) | ||
CHECK(klists.kpts_cart[ik][ldim] == Approx(blat * (twist[ldim] + gvecs[ik][ldim]))); | ||
} | ||
|
||
TEST_CASE("kcontainer at gamma in 2D", "[longrange]") | ||
{ | ||
const int ndim = 2; | ||
const double alat = 1.0; | ||
const double blat = 2 * M_PI / alat; | ||
|
||
// check first 3 shells of kvectors | ||
const std::vector<double> kcs = {blat, std::sqrt(2) * blat, 2 * blat}; | ||
const std::vector<int> nks = {4, 8, 12}; | ||
|
||
CrystalLattice<OHMMS_PRECISION, OHMMS_DIM> lattice; | ||
lattice.R.diagonal(1.0); | ||
lattice.set(lattice.R); // compute Rv and Gv from R | ||
|
||
KContainer klists; | ||
for (int ik = 0; ik < kcs.size(); ik++) | ||
{ | ||
const double kc = kcs[ik] + 1e-6; | ||
klists.updateKLists(lattice, kc, ndim); | ||
CHECK(klists.kpts.size() == nks[ik]); | ||
} | ||
const int mxk = klists.kpts.size(); | ||
int gvecs[12][3] = { | ||
{-1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {1, 0, 0}, {-1, -1, 0}, {-1, 1, 0}, | ||
{1, -1, 0}, {1, 1, 0}, {-2, 0, 0}, {0, -2, 0}, {0, 2, 0}, {2, 0, 0}, | ||
}; | ||
|
||
for (int ik = 0; ik < mxk; ik++) | ||
{ | ||
for (int ldim = 0; ldim < ndim; ldim++) | ||
{ | ||
CHECK(klists.kpts[ik][ldim] == gvecs[ik][ldim]); | ||
CHECK(klists.kpts[ik][ldim] * blat == Approx(klists.kpts_cart[ik][ldim])); | ||
} | ||
} | ||
} | ||
|
||
TEST_CASE("kcontainer at twist in 2D", "[longrange]") | ||
{ | ||
const int ndim = 2; | ||
const double alat = 1.0; | ||
const double blat = 2 * M_PI / alat; | ||
|
||
// twist one shell of kvectors | ||
const double kc = blat + 1e-6; | ||
|
||
CrystalLattice<OHMMS_PRECISION, OHMMS_DIM> lattice; | ||
lattice.R.diagonal(1.0); | ||
lattice.set(lattice.R); // compute Rv and Gv from R | ||
|
||
KContainer klists; | ||
|
||
PosType twist; | ||
twist[0] = 0.1; | ||
klists.updateKLists(lattice, kc, ndim, twist); | ||
CHECK(klists.kpts.size() == 1); | ||
CHECK(klists.kpts_cart[0][0] == Approx(blat * (twist[0] - 1))); | ||
|
||
twist[1] = 0.1; | ||
klists.updateKLists(lattice, kc, ndim, twist); | ||
CHECK(klists.kpts.size() == 2); | ||
CHECK(klists.kpts_cart[0][0] == Approx(blat * (twist[0] - 1))); | ||
CHECK(klists.kpts_cart[0][1] == Approx(blat * twist[1])); | ||
CHECK(klists.kpts_cart[1][0] == Approx(blat * (twist[0]))); | ||
CHECK(klists.kpts_cart[1][1] == Approx(blat * (twist[1] - 1))); | ||
|
||
twist = {-0.5, 0.5, 0}; | ||
klists.updateKLists(lattice, kc, ndim, twist); | ||
CHECK(klists.kpts.size() == 3); | ||
//for (int ik=0;ik<3;ik++) | ||
// app_log() << klists.kpts_cart[ik] << std::endl; | ||
CHECK(klists.kpts_cart[0][0] == Approx(blat * (twist[0] - 0))); | ||
CHECK(klists.kpts_cart[0][1] == Approx(blat * (twist[1] - 1))); | ||
CHECK(klists.kpts_cart[1][0] == Approx(blat * (twist[0] + 1))); | ||
CHECK(klists.kpts_cart[1][1] == Approx(blat * (twist[1] - 1))); | ||
CHECK(klists.kpts_cart[2][0] == Approx(blat * (twist[0] + 1))); | ||
CHECK(klists.kpts_cart[2][1] == Approx(blat * twist[1])); | ||
} | ||
|
||
} // namespace qmcplusplus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Kcontainer correct when the twist isn't 0? I don't know there isn't any unit testing. Please write some or direct me too it. Since this class is becoming a more used piece of infrastructure it needs some testing. Deterministic tests are not a substitute.
This class seems like it would be very straight forward to write tests.