QMCPACK
ForceCeperley.cpp
Go to the documentation of this file.
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: John R. Gergely, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
11 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
12 //
13 // File created by: John R. Gergely, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #include "ForceCeperley.h"
18 #include "Particle/DistanceTable.h"
19 #include "Message/Communicate.h"
23 #include "OhmmsData/ParameterSet.h"
24 #include "OhmmsData/AttributeSet.h"
25 
26 namespace qmcplusplus
27 {
29  : ForceBase(ions, elns), d_aa_ID(ions.addTable(ions)), d_ei_ID(elns.addTable(ions))
30 {
31  ReportEngine PRE("ForceCeperley", "ForceCeperley");
32  name_ = "Ceperley_Force_Base";
33  prefix_ = "HFCep";
34  // Defaults
35  Rcut = 0.4;
36  m_exp = 2;
37  N_basis = 4;
38  forces_ = 0.0;
39  ///////////////////////////////////////////////////////////////
40  ions.update();
42 }
43 
45 {
46  forces = 0.0;
47  const auto& d_aa(ions_.getDistTableAA(d_aa_ID));
48  const ParticleScalar* restrict Zat = ions_.Z.first_address();
49  for (size_t ipart = 1; ipart < n_nuc_; ipart++)
50  {
51  const auto& dist = d_aa.getDistRow(ipart);
52  const auto& displ = d_aa.getDisplRow(ipart);
53  for (size_t jpart = 0; jpart < ipart; ++jpart)
54  {
55  RealType rinv = 1.0 / dist[jpart];
56  RealType r3zz = Zat[jpart] * Zat[ipart] * rinv * rinv * rinv;
57  forces[jpart] += r3zz * displ[jpart];
58  forces[ipart] -= r3zz * displ[jpart];
59  }
60  }
61 }
62 
64 {
66  h.resize(N_basis);
67  c.resize(N_basis);
68  for (int k = 0; k < N_basis; k++)
69  {
70  h[k] = std::pow(Rcut, (k + 2)) / static_cast<RealType>(k + 2);
71  for (int j = 0; j < N_basis; j++)
72  {
73  Sinv(k, j) = std::pow(Rcut, (m_exp + k + j + 3)) / static_cast<RealType>(m_exp + k + j + 3);
74  }
75  }
76  // in Numerics/DeterminantOperators.h
77  invert_matrix(Sinv, false);
78  // in Numerics/MatrixOperators.h
80 }
81 
83 {
84  if (add_ion_ion_ == true)
86  else
87  forces_ = 0.0;
88  const auto& d_ab = P.getDistTableAB(d_ei_ID);
89  const ParticleScalar* restrict Zat = ions_.Z.first_address();
90  const ParticleScalar* restrict Qat = P.Z.first_address();
91  for (int jat = 0; jat < n_el_; jat++)
92  {
93  const auto& dist = d_ab.getDistRow(jat);
94  const auto& displ = d_ab.getDisplRow(jat);
95  for (int iat = 0; iat < n_nuc_; iat++)
96  {
97  // electron contribution (special treatment if distance is inside cutoff!)
98  RealType r = dist[iat];
99  RealType zoverr3 = Qat[jat] * Zat[iat] / (r * r * r);
100  if (r >= Rcut)
101  {
102  forces_[iat] += zoverr3 * displ[iat];
103  }
104  else
105  {
106  RealType g_q = 0.0;
107  for (int q = 0; q < N_basis; q++)
108  {
109  g_q += c[q] * std::pow(r, m_exp + q + 1);
110  }
111  g_q *= zoverr3;
112  // negative sign accounts for definition of target as electrons
113  forces_[iat] += g_q * displ[iat];
114  }
115  }
116  }
117  return 0.0;
118 }
119 
120 bool ForceCeperley::put(xmlNodePtr cur)
121 {
122  std::string ionionforce("yes");
123  OhmmsAttributeSet attr;
124  attr.add(prefix_, "name");
125  attr.add(ionionforce, "add_ion_ion_");
126  attr.put(cur);
127  add_ion_ion_ = (ionionforce == "yes") || (ionionforce == "true");
128  app_log() << "ionionforce = " << ionionforce << std::endl;
129  app_log() << "add_ion_ion_=" << add_ion_ion_ << std::endl;
130  app_log() << "first_time_= " << first_time_ << std::endl;
131  ParameterSet fcep_param_set;
132  fcep_param_set.add(Rcut, "rcut");
133  fcep_param_set.add(N_basis, "nbasis");
134  fcep_param_set.add(m_exp, "weight_exp");
135  fcep_param_set.put(cur);
136  app_log() << " ForceCeperley Parameters" << std::endl;
137  app_log() << " ForceCeperley::Rcut=" << Rcut << std::endl;
138  app_log() << " ForceCeperley::N_basis=" << N_basis << std::endl;
139  app_log() << " ForceCeperley::m_exp=" << m_exp << std::endl;
140  InitMatrix();
141  return true;
142 }
143 
144 std::unique_ptr<OperatorBase> ForceCeperley::makeClone(ParticleSet& qp, TrialWaveFunction& psi)
145 {
146  return std::make_unique<ForceCeperley>(*this);
147 }
148 } // namespace qmcplusplus
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
MatrixA::value_type invert_matrix(MatrixA &M, bool getdet=true)
invert a matrix
ForceCeperley(ParticleSet &ions, ParticleSet &elns)
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
const DistanceTableAA & getDistTableAA(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAA
QTBase::RealType RealType
Definition: Configuration.h:58
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
Matrix< FullPrecRealType > Sinv
Definition: ForceCeperley.h:38
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
void update(bool skipSK=false)
update the internal data
Attaches a unit to a Vector for IO.
std::string prefix_
Definition: ForceBase.h:96
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
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)
std::string name_
name of this object
Definition: OperatorBase.h:527
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
class to handle a set of parameters
Definition: ParameterSet.h:27
bool add_ion_ion_
Determines if ion-ion force will be added to electron-ion force in derived force estimators. If false, forces_ion_ion_=0.0.
Definition: ForceBase.h:84
void product(const Matrix< T > &A, const Matrix< T > &B, Matrix< T > &C)
static function to perform C=AB for real matrices
Final class and should not be derived.
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.
declaration of ProgressReportEngine
ParticleScalar Z
charge of each particle
Definition: ParticleSet.h:89
ParticleSet::Scalar_t ParticleScalar
typedef for the ParticleScalar
Definition: OperatorBase.h:81
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Define determinant operators.
Class to represent a many-body trial wave function.
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) final
Vector< FullPrecRealType > h
Definition: ForceCeperley.h:39
void evaluate_IonIon(ParticleSet::ParticlePos &forces) const
ParticleSet::ParticlePos forces_ion_ion_
Definition: ForceBase.h:88
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
Vector< FullPrecRealType > c
Definition: ForceCeperley.h:40
ParticleSet & ions_
Definition: ForceBase.h:86
bool put(xmlNodePtr cur) override
Read the input parameter.