QMCPACK
SlaterDetBuilder.h
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: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef QMCPLUSPLUS_LCORBITALSETBUILDER_H
17 #define QMCPLUSPLUS_LCORBITALSETBUILDER_H
18 
19 #include <vector>
20 #include "Configuration.h"
22 #include <hdf/hdf_archive.h>
23 
24 namespace qmcplusplus
25 {
26 class TrialWaveFunction;
27 class BackflowTransformation;
28 class DiracDeterminantBase;
29 class MultiSlaterDetTableMethod;
30 struct CSFData;
31 class SPOSet;
32 class SPOSetBuilder;
33 class SPOSetBuilderFactory;
34 struct ci_configuration;
35 
36 /** derived class from WaveFunctionComponentBuilder
37  *
38  * Builder SlaterDeterminant with LCOrbitalSet
39  */
41 {
42 public:
43  /** constructor
44  * \param els reference to the electrons
45  * \param psi reference to the wavefunction
46  * \param ions reference to the ions
47  */
49  SPOSetBuilderFactory& factory,
50  ParticleSet& els,
51  TrialWaveFunction& psi,
52  const PSetMap& psets);
53 
54  /** initialize the Antisymmetric wave function for electrons
55  *@param cur the current xml node
56  *
57  */
58  std::unique_ptr<WaveFunctionComponent> buildComponent(xmlNodePtr cur) override;
59 
60 private:
61  /// reference to the sposet_builder_factory, should be const once the legacy input style is removed
63  ///reference to TrialWaveFunction, should go away as the CUDA code.
65  ///reference to a PSetMap
66  const PSetMap& ptclPool;
67 
68  /** process a determinant element
69  * @param cur xml node
70  * @param spin_group the spin group of the created determinant
71  * @return legacy_input_sposet_builder an sposet builder to handle legacy input
72  * @return BFTrans backflow transformations
73  */
74  std::unique_ptr<DiracDeterminantBase> putDeterminant(
75  xmlNodePtr cur,
76  int spin_group,
77  const std::unique_ptr<SPOSetBuilder>& legacy_input_sposet_builder,
78  const std::unique_ptr<BackflowTransformation>& BFTrans);
79 
80  std::unique_ptr<MultiSlaterDetTableMethod> createMSDFast(xmlNodePtr cur,
81  ParticleSet& target_ptcl,
82  std::vector<std::unique_ptr<SPOSet>>&& spo_clones,
83  const bool spinor,
84  const bool use_precompute) const;
85 
86 
87  bool readDetList(xmlNodePtr cur,
88  std::vector<std::vector<ci_configuration>>& uniqueConfgs,
89  std::vector<std::vector<size_t>>& C2nodes,
90  std::vector<std::string>& CItags,
91  std::vector<ValueType>& coeff,
92  bool& optimizeCI,
93  std::vector<int>& nptcls,
94  std::unique_ptr<CSFData>& csf_data_ptr) const;
95 
96  bool readDetListH5(xmlNodePtr cur,
97  std::vector<std::vector<ci_configuration>>& uniqueConfgs,
98  std::vector<std::vector<size_t>>& C2nodes,
99  std::vector<std::string>& CItags,
100  std::vector<ValueType>& coeff,
101  bool& optimizeCI,
102  std::vector<int>& nptcls) const;
103 
104  template<typename VT,
105  std::enable_if_t<(std::is_same<VT, ValueType>::value) && (std::is_floating_point<VT>::value), int> = 0>
106  void readCoeffs(hdf_archive& hin, std::vector<VT>& ci_coeff, size_t n_dets, int ext_level) const
107  {
108  ///Determinant coeffs are stored in Coeff for the ground state and Coeff_N
109  ///for the Nth excited state.
110  ///The Ground State is always stored in Coeff
111  ///Backward compatibility is insured
112  std::string extVar;
113  if (ext_level == 0)
114  extVar = "Coeff";
115  else
116  extVar = "Coeff_" + std::to_string(ext_level);
117 
118  hin.read(ci_coeff, extVar);
119  }
120 
121  template<typename VT,
122  std::enable_if_t<(std::is_same<VT, ValueType>::value) &&
123  (std::is_same<VT, std::complex<typename VT::value_type>>::value),
124  int> = 0>
125  void readCoeffs(hdf_archive& hin, std::vector<VT>& ci_coeff, size_t n_dets, int ext_level) const
126  {
127  std::string extVar;
128  std::vector<double> CIcoeff_real;
129  std::vector<double> CIcoeff_imag;
130  CIcoeff_imag.resize(n_dets);
131  CIcoeff_real.resize(n_dets);
132  fill(CIcoeff_imag.begin(), CIcoeff_imag.end(), 0.0);
133  ///Determinant coeffs are stored in Coeff_N where N is Nth excited state.
134  ///The Ground State is always stored in Coeff.
135  ///Backward compatibility is insured
136 
137  std::string ext_var;
138  if (ext_level == 0)
139  extVar = "Coeff";
140  else
141  extVar = "Coeff_" + std::to_string(ext_level);
142 
143 
144  hin.read(CIcoeff_real, extVar);
145 
146  extVar = extVar + "_imag";
147  if (!hin.readEntry(CIcoeff_imag, extVar))
148  app_log() << "Coeff_imag not found in h5. Set to zero." << std::endl;
149 
150  for (size_t i = 0; i < n_dets; i++)
151  ci_coeff[i] = VT(CIcoeff_real[i], CIcoeff_imag[i]);
152  }
153 };
154 
155 } // namespace qmcplusplus
156 #endif
std::unique_ptr< MultiSlaterDetTableMethod > createMSDFast(xmlNodePtr cur, ParticleSet &target_ptcl, std::vector< std::unique_ptr< SPOSet >> &&spo_clones, const bool spinor, const bool use_precompute) const
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
initialize the Antisymmetric wave function for electrons
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
An abstract class for wave function builders.
std::ostream & app_log()
Definition: OutputManager.h:65
std::unique_ptr< DiracDeterminantBase > putDeterminant(xmlNodePtr cur, int spin_group, const std::unique_ptr< SPOSetBuilder > &legacy_input_sposet_builder, const std::unique_ptr< BackflowTransformation > &BFTrans)
process a determinant element
class to handle hdf file
Definition: hdf_archive.h:51
bool is_same(const xmlChar *a, const char *b)
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
Wrapping information on parallelism.
Definition: Communicate.h:68
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
SlaterDetBuilder(Communicate *comm, SPOSetBuilderFactory &factory, ParticleSet &els, TrialWaveFunction &psi, const PSetMap &psets)
constructor
void readCoeffs(hdf_archive &hin, std::vector< VT > &ci_coeff, size_t n_dets, int ext_level) const
Class to represent a many-body trial wave function.
void readCoeffs(hdf_archive &hin, std::vector< VT > &ci_coeff, size_t n_dets, int ext_level) const
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
Definition: hdf_archive.h:306
bool readDetList(xmlNodePtr cur, std::vector< std::vector< ci_configuration >> &uniqueConfgs, std::vector< std::vector< size_t >> &C2nodes, std::vector< std::string > &CItags, std::vector< ValueType > &coeff, bool &optimizeCI, std::vector< int > &nptcls, std::unique_ptr< CSFData > &csf_data_ptr) const
bool readEntry(T &data, const std::string &aname)
read the data from the group aname and return status use read() for inbuilt error checking ...
Definition: hdf_archive.h:293
SPOSetBuilderFactory & sposet_builder_factory_
reference to the sposet_builder_factory, should be const once the legacy input style is removed ...
bool readDetListH5(xmlNodePtr cur, std::vector< std::vector< ci_configuration >> &uniqueConfgs, std::vector< std::vector< size_t >> &C2nodes, std::vector< std::string > &CItags, std::vector< ValueType > &coeff, bool &optimizeCI, std::vector< int > &nptcls) const
const PSetMap & ptclPool
reference to a PSetMap
derived class from WaveFunctionComponentBuilder
declaration of the base class for many-body wavefunction.
TrialWaveFunction & targetPsi
reference to TrialWaveFunction, should go away as the CUDA code.