1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 //                    Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //                    Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #include "SkPot.h"
16 #include "Utilities/IteratorUtility.h"
17 #include "OhmmsData/AttributeSet.h"
18 
19 namespace qmcplusplus
20 {
SkPot(ParticleSet & source)21 SkPot::SkPot(ParticleSet& source)
22 {
23   sourcePtcl = &source;
24   NumSpecies = source.getSpeciesSet().getTotalNum();
25   NumK       = source.SK->KLists.numk;
26   OneOverN   = 1.0 / static_cast<RealType>(source.getTotalNum());
27   Kshell     = source.SK->KLists.kshell;
28   MaxKshell  = Kshell.size() - 1;
29   RhokTot.resize(NumK);
30   Fk.resize(NumK);
31   Kmag.resize(MaxKshell);
32   OneOverDnk.resize(MaxKshell);
33   for (int ks = 0; ks < MaxKshell; ks++)
34   {
35     Kmag[ks]       = std::sqrt(source.SK->KLists.ksq[Kshell[ks]]);
36     OneOverDnk[ks] = 1.0 / static_cast<RealType>(Kshell[ks + 1] - Kshell[ks]);
37   }
38 }
39 
resetTargetParticleSet(ParticleSet & P)40 void SkPot::resetTargetParticleSet(ParticleSet& P) { sourcePtcl = &P; }
41 
evaluate(ParticleSet & P)42 SkPot::Return_t SkPot::evaluate(ParticleSet& P)
43 {
44 #if defined(USE_REAL_STRUCT_FACTOR)
45   APP_ABORT("SkPot::evaluate(ParticleSet& P)");
46 #else
47   //sum over species
48   copy(P.SK->rhok[0], P.SK->rhok[0] + NumK, RhokTot.begin());
49   for (int i = 1; i < NumSpecies; ++i)
50     accumulate_elements(P.SK->rhok[i], P.SK->rhok[i] + NumK, RhokTot.begin());
51   Vector<ComplexType>::const_iterator iit(RhokTot.begin()), iit_end(RhokTot.end());
52   Value = 0.0;
53   for (int i = 0; iit != iit_end; ++iit, ++i)
54     Value += Fk[i] * ((*iit).real() * (*iit).real() + (*iit).imag() * (*iit).imag());
55 #endif
56   return Value;
57 }
58 
put(xmlNodePtr cur)59 bool SkPot::put(xmlNodePtr cur)
60 {
61   OhmmsAttributeSet Tattrib;
62   Tattrib.add(K_0, "k0");
63   Tattrib.add(V_0, "v0");
64   Tattrib.put(cur);
65   app_log() << "KSpacePot parameters" << std::endl;
66   app_log() << "  k0: " << K_0 << std::endl;
67   app_log() << "  v0: " << V_0 << std::endl;
68   FillFk();
69   return true;
70 }
71 
72 
get(std::ostream & os) const73 bool SkPot::get(std::ostream& os) const { return true; }
74 
makeClone(ParticleSet & qp,TrialWaveFunction & psi)75 OperatorBase* SkPot::makeClone(ParticleSet& qp, TrialWaveFunction& psi)
76 {
77   SkPot* myclone = new SkPot(*this);
78   myclone->FillFk();
79   return myclone;
80 }
81 } // namespace qmcplusplus
82