-
Notifications
You must be signed in to change notification settings - Fork 135
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
FreeOrbital SPOSet #4084
Changes from 27 commits
7335258
e58fb64
9e4a4d7
28bb034
b137c6b
9af84e4
406b5f1
c0eb5ce
a6c02e0
c6d95e6
fa6aacd
d83e24e
a7f2c18
b1ec05e
53318ec
e78c3ce
5ad23b1
4a1fb17
557f73b
9845e2b
cdb7b0e
4af8496
8cfb2ae
4fdd530
1229433
60df854
199bb85
bbde8ff
98ad010
16ebc8b
ad592eb
bf73840
fc38389
f4ed10d
2ee528c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,16 +72,21 @@ class KContainer : public QMCTraits | |
* @param kc cutoff radius in the K | ||
* @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, PosType twist, bool useSphere); | ||
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. Please document 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. @Paul-St-Young did you miss this one? |
||
|
||
/** K-vector in Cartesian coordinates in SoA layout | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
|
||
namespace qmcplusplus | ||
{ | ||
|
||
class KContainer; | ||
/** @ingroup longrange | ||
*\brief Calculates the structure-factor for a particle set | ||
|
@@ -71,6 +70,9 @@ class StructFact : public QMCTraits | |
/// accessor of StorePerParticle | ||
bool isStorePerParticle() const { return StorePerParticle; } | ||
|
||
/// accessor of k_lists_ | ||
const KContainer getKLists() const { return k_lists_; } | ||
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 incorrect. "const KContainer&" |
||
|
||
private: | ||
/// Compute all rhok elements from the start | ||
void computeRhok(const ParticleSet& P); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
#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 == 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 == klists.kpts_cart[ik][ldim]); | ||
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. CI failure are from missing Approx. Please double check all the CHECK. Also this file seems needing clang-format. |
||
} | ||
} | ||
} | ||
|
||
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])); | ||
} | ||
|
||
} // qmcplusplus |
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.