7 #include "einspline/bspline_eval_d.h" 14 : skparser(NULL), ptclPool(NULL), myRcut(0.0), myConst(0.0), P(NULL), h(0.0), sphericalgrid(0)
18 app_log() <<
"Building spherical grid. n_theta x n_phi = " <<
mtheta <<
" x " <<
mphi << std::endl;
24 : skparser(skparser_i), ptclPool(NULL), myRcut(0.0), myConst(0.0), P(NULL), h(0.0), sphericalgrid(0)
38 RealType Mt = int(std::round(M_PI / d));
42 for (
int m = 0;
m < Mt;
m++)
46 for (
int n = 0;
n < Mp;
n++)
61 xmlXPathContextPtr m_context =
xml_doc_stack_.top()->getXPathContext();
66 std::string cname((
const char*)cur->name);
67 if (cname ==
"particleset")
71 else if (cname ==
"wavefunction")
75 else if (cname ==
"include")
78 const xmlChar* a = xmlGetProp(cur, (
const xmlChar*)
"href");
86 else if (cname ==
"qmcsystem")
94 app_log() <<
"=========================================================\n";
95 app_log() <<
" Summary of QMC systems \n";
96 app_log() <<
"=========================================================\n";
104 std::string id(
"psi0"), target(
"e"), role(
"extra");
106 pAttrib.
add(
id,
"id");
107 pAttrib.
add(
id,
"name");
108 pAttrib.
add(target,
"target");
109 pAttrib.
add(target,
"ref");
110 pAttrib.
add(role,
"role");
115 throw std::runtime_error(
"target particle set named '" + target +
"' not found");
123 bool inputnode =
true;
125 xmlNodePtr cur_root = cur;
129 std::string cname((
const char*)cur->name);
130 if (cname ==
"simulationcell")
132 else if (cname ==
"particleset")
134 else if (cname ==
"wavefunction")
144 app_log() <<
"=========================================================\n";
145 app_log() <<
" Initializing Long Range Breakup (Esler) \n";
146 app_log() <<
"=========================================================\n";
152 myGrid.set(0,
myRcut, ng);
175 double kc =
AA->get_kc();
176 double kcutsq = kc * kc;
210 std::vector<FullPrecRealType> sk_fp(sk.begin(), sk.end());
211 UBspline_3d_d* spline = create_UBspline_3d_d(esgridx, esgridy, esgridz, bcx, bcy, bcz, sk_fp.data());
218 symmatelem.resize(6);
229 eval_UBspline_3d_d(spline, disp_lat[0], disp_lat[1], disp_lat[2], &sx);
235 eval_UBspline_3d_d(spline, disp_lat[0], disp_lat[1], disp_lat[2], &sy);
241 eval_UBspline_3d_d(spline, disp_lat[0], disp_lat[1], disp_lat[2], &sz);
247 eval_UBspline_3d_d(spline, disp_lat[0], disp_lat[1], disp_lat[2], &sxy);
253 eval_UBspline_3d_d(spline, disp_lat[0], disp_lat[1], disp_lat[2], &sxz);
259 eval_UBspline_3d_d(spline, disp_lat[0], disp_lat[1], disp_lat[2], &syz);
264 symmatelem[3] = 0.5 *
RealType(sxy - sx - sy) / h2;
265 symmatelem[4] = 0.5 *
RealType(sxz - sx - sz) / h2;
266 symmatelem[5] = 0.5 *
RealType(syz - sy - sz) / h2;
287 if (!(inx & iny & inz))
291 eval_UBspline_3d_d(spline, kvec[0], kvec[1], kvec[2], &val);
300 std::vector<RealType>& vals,
305 std::vector<FullPrecRealType> grid_fp(grid.begin(), grid.end());
308 lingrid.
set(grid_fp[0], grid_fp.back(), grid_fp.size());
309 Ugrid esgrid = lingrid.einspline_grid();
317 std::vector<FullPrecRealType> vals_fp(vals.begin(), vals.end());
318 return create_UBspline_1d_d(esgrid, xBC, vals_fp.data());
330 std::cerr <<
"Warning in integrate_spline: N must be even!\n";
338 for (
int i = 1; i <
N / 2; i++)
340 xi = a + (2 * i - 2) * eps;
341 eval_UBspline_1d_d(spline, xi, &tmp);
344 xi = a + (2 * i - 1) * eps;
345 eval_UBspline_1d_d(spline, xi, &tmp);
348 xi = a + (2 * i) * eps;
349 eval_UBspline_1d_d(spline, xi, &tmp);
353 return (eps / 3.0) * sum;
371 std::cout <<
"Grid computed.\n";
381 for (
int ks = 0; ks <
Klist.
kshell.size() - 1; ks++)
401 app_log() <<
"\nSpherically averaged raw S(k):\n";
402 app_log() << std::setw(12) <<
"k" << std::setw(12) <<
"S(k)" << std::setw(12) <<
"vk" 404 for (
int ks = 0; ks <
Klist.
kshell.size() - 1; ks++)
407 << std::setprecision(8) << vsk_1d[ks] << std::setw(12) << std::setprecision(8) <<
AA->Fk_symm[ks] <<
'\n';
412 app_log() <<
"####################################################################\n";
413 app_log() <<
"WARNING: The S(k) in the largest kshell is less than 0.99\n";
414 app_log() <<
" This code assumes the S(k) is converged to 1.0 at large k\n";
415 app_log() <<
" You may need to rerun with a larger LR_dim_cutoff\n";
416 app_log() <<
"####################################################################\n";
422 std::vector<RealType> Amat;
425 app_log() <<
"\n=========================================================\n";
427 app_log() <<
"=========================================================\n";
428 app_log() <<
"S(k) anisotropy near k=0\n";
429 app_log() <<
"------------------------\n";
430 app_log() <<
" a_xx = " << Amat[0] << std::endl;
431 app_log() <<
" a_yy = " << Amat[1] << std::endl;
432 app_log() <<
" a_zz = " << Amat[2] << std::endl;
433 app_log() <<
" a_xy = " << Amat[3] << std::endl;
434 app_log() <<
" a_xz = " << Amat[4] << std::endl;
435 app_log() <<
" a_yz = " << Amat[5] << std::endl;
436 app_log() <<
"------------------------\n";
438 RealType b = (Amat[0] + Amat[1] + Amat[2]) / 3.0;
440 app_log() <<
"Spherically averaged S(k) near k=0\n";
441 app_log() <<
"S(k)=b*k^2 b = " << b << std::endl;
442 app_log() <<
"------------------------\n";
449 app_log() <<
"\nSpherically averaged splined S(k):\n";
450 app_log() << std::setw(12) <<
"k" << std::setw(12) <<
"S(k)" 452 for (
int k = 0; k < nk; k++)
455 app_log() << std::setw(12) << std::setprecision(8) << kval << std::setw(12) << std::setprecision(8)
468 auto spline = std::unique_ptr<UBspline_3d_d, void (*)(void*)>{
getSkSpline(sk), destroy_Bspline};
473 std::vector<RealType> unigrid1d, k2vksk;
476 unigrid1d.push_back(0.0);
477 k2vksk.push_back(0.0);
478 for (
int i = 1; i < ngrid; i++)
481 unigrid1d.push_back(kval);
483 RealType k2vk = kval * kval *
AA->evaluate_vlr_k(kval);
484 k2vksk.push_back(0.5 * k2vk * skavg);
487 k2vksk.push_back(0.0);
488 unigrid1d.push_back(kmax);
491 std::unique_ptr<UBspline_1d_d, void (*)(void*)>{
spline_clamped(unigrid1d, k2vksk, 0.0, 0.0), destroy_Bspline};
498 return intnorm * integratedval;
504 std::vector<RealType> vsums, vints;
509 #pragma omp parallel for 512 std::vector<RealType> newSK_raw(
SK_raw.size());
513 for (
int j = 0; j <
SK_raw.size(); j++)
521 std::vector<RealType> newSK(
SK.size());
522 for (
int j = 0; j <
SK.size(); j++)
526 newSK[j] =
SK[j] +
SKerr[j] * chi;
546 #pragma omp parallel for 549 std::vector<RealType> newSK(
SK.size());
550 for (
int j = 0; j <
SK.size(); j++)
554 newSK[j] =
SK[j] +
SKerr[j] * chi;
557 std::vector<RealType> Amat;
559 bs[i] = (Amat[0] + Amat[1] + Amat[2]) / 3.0;
574 app_log() <<
"\n=========================================================\n";
575 app_log() <<
" Finite Size Corrections:\n";
576 app_log() <<
"=========================================================\n";
577 app_log() <<
" System summary:\n";
579 app_log() <<
" Nelec = " << std::setw(12) <<
Ne <<
"\n";
580 app_log() <<
" Vol = " << std::setw(12) << std::setprecision(8) <<
Vol <<
" [a0^3]\n";
581 app_log() <<
" Ne/V = " << std::setw(12) << std::setprecision(8) <<
rho <<
" [1/a0^3]\n";
582 app_log() <<
" rs/a0 = " << std::setw(12) << std::setprecision(8) <<
rs <<
"\n";
584 app_log() <<
" Leading Order Corrections:\n";
585 app_log() <<
" V_LO / electron = " << std::setw(12) << std::setprecision(8) <<
vlo <<
" +/- " <<
vloerr 586 <<
" [Ha/electron]\n";
587 app_log() <<
" V_LO = " << std::setw(12) << std::setprecision(8) <<
vlo *
Ne <<
" +/- " <<
vloerr *
Ne 589 app_log() <<
" T_LO / electron = " << std::setw(12) << std::setprecision(8) <<
tlo <<
" +/- " <<
tloerr 590 <<
" [Ha/electron]\n";
591 app_log() <<
" T_LO = " << std::setw(12) << std::setprecision(8) <<
tlo *
Ne <<
" +/- " <<
tloerr *
Ne 593 app_log() <<
" NB: This is a crude estimate of the kinetic energy correction!\n";
595 app_log() <<
" Beyond Leading Order (Integrated corrections):\n";
596 app_log() <<
" V_Int / electron = " << std::setw(12) << std::setprecision(8) <<
Vfs <<
" +/- " <<
Vfserr 597 <<
" [Ha/electron]\n";
598 app_log() <<
" V_Int = " << std::setw(12) << std::setprecision(8) <<
Vfs *
Ne <<
" +/- " <<
Vfserr *
Ne 610 for (
int i = 0; i <
SK_raw.size(); i++)
std::unique_ptr< LRHandlerType > AA
std::vector< TinyVector< int, OHMMS_DIM > > kpts
bool validateXML() override
validate the input file
void get_sk(std::vector< RealType > &sk, std::vector< RealType > &skerr)
void set(T ri, T rf, int n) override
Set the grid given the parameters.
helper functions for EinsplineSetBuilder
RealType integrate_spline(UBspline_1d_d *spline, RealType a, RealType b, IndexType N)
bool put(xmlNodePtr cur)
process an xml element
static std::unique_ptr< RadFunctorType > createSpline4RbyVs(const LRHandlerType *aLR, mRealType rcut, const GridType &agrid)
create a linear spline function
QMCTraits::RealType RealType
size_t getTotalNum() const
UBspline_3d_d * getSkSpline(std::vector< RealType > sk, RealType limit=1.0)
std::vector< RealType > SKerr
bool put(xmlNodePtr cur)
assign attributes to the set
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
void build_spherical_grid(IndexType mtheta, IndexType mphi)
std::vector< RealType > get_skerr_raw()
RealType sphericalAvgSk(UBspline_3d_d *spline, RealType k)
void wfnPut(xmlNodePtr cur)
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
const auto & getSimulationCell() const
bool get(std::ostream &os) const
Specialized paritlce class for atomistic simulations.
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
RealType calcPotentialInt(std::vector< RealType > sk)
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
class to handle a set of attributes of an xmlNode
void printSkRawSphAvg(const std::vector< RealType > &sk)
void getSkInfo(UBspline_3d_d *spline, std::vector< RealType > &symmatelem)
bool pushDocument(const std::string &infile)
open a new document
std::vector< PosType > sphericalgrid
OHMMS_INDEXTYPE IndexType
define other types
std::vector< RealType > SK
std::vector< int > kshell
kpts which belong to the ith-shell [kshell[i], kshell[i+1])
bool readSimulationCellXML(xmlNodePtr cur)
initialize the supercell shared by all the particle sets
void calcPotentialCorrection()
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
std::vector< RealType > ksq
squre of kpts in Cartesian coordniates
bool processPWH(xmlNodePtr cur)
void getStats(const std::vector< RealType > &vals, RealType &avg, RealType &err, int start)
Simpleaverage and error estimate.
void printSkSplineSphAvg(UBspline_3d_d *spline)
static std::unique_ptr< LRHandlerType > getHandler(ParticleSet &ref)
This returns an energy optimized LR handler. If non existent, it creates one.
UBspline_1d_d * spline_clamped(std::vector< RealType > &grid, std::vector< RealType > &vals, RealType lVal, RealType rVal)
const auto & getLattice() const
void get_grid(Grid_t &xgrid, Grid_t &ygrid, Grid_t &zgrid)
std::vector< RealType > get_sk_raw()
std::unique_ptr< RadFunctorType > rVs
std::vector< RealType > SK_raw
void set_grid(const std::vector< PosType > &gridpoints)
QTFull::RealType FullPrecRealType
void popDocument()
close the current document
bool execute() override
execute the main function
std::vector< TinyVector< int, DIM > > kpts
K-vector in reduced coordinates.
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Declare a global Random Number Generator.
std::vector< RealType > SKerr_raw
std::stack< Libxml2Document * > xml_doc_stack_
stack of xml document
void calcLeadingOrderCorrections()
declaration of the base class for many-body wavefunction.
Base class for Sk parser.
RealType calcPotentialDiscrete(std::vector< RealType > sk)