QMCPACK
ECPComponentBuilder.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 // 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 /** @file
16  * @brief Declaration of a builder class for an ECP component for an ionic type
17  */
18 #ifndef QMCPLUSPLUS_ECPCOMPONENT_BUILDER_H
19 #define QMCPLUSPLUS_ECPCOMPONENT_BUILDER_H
20 #include "Particle/DistanceTable.h"
25 
26 namespace qmcplusplus
27 {
29 {
34 
37  int NumSO; //The number of spin-orbit channels.
38  int LmaxSO; //The maximum angular momentum of spin-orbit channels.
42  std::string Species;
43  std::unique_ptr<mGridType> grid_global;
44  std::map<std::string, std::unique_ptr<mGridType>> grid_inp;
45  std::unique_ptr<RadialPotentialType> pp_loc;
46  std::unique_ptr<NonLocalECPComponent> pp_nonloc;
47  std::unique_ptr<SOECPComponent> pp_so; //Spin-orbit potential component.
48  std::unique_ptr<L2RadialPotential> pp_L2;
49  std::map<std::string, int> angMon;
50 
51  /** constructor
52  * spin grid used for numerical integration. use 0 for exact integration.
53  */
54  ECPComponentBuilder(const std::string& aname, Communicate* c, int nrule = -1, int llocal = -1, int srule = 8);
55 
56  bool parse(const std::string& fname, xmlNodePtr cur);
57  bool put(xmlNodePtr cur);
58  void addSemiLocal(xmlNodePtr cur);
59  void buildLocal(xmlNodePtr cur);
60  void buildSemiLocalAndLocal(std::vector<xmlNodePtr>& semiPtr);
61  void buildL2(xmlNodePtr cur);
62 
63  bool parseCasino(const std::string& fname, xmlNodePtr cur); //std::string& fname, RealType rc);
64  //bool parseCasino(std::string& fname, RealType rc);
65  // This sets the spherical quadrature rule used to apply the
66  // projection operators. rule can be 1 to 7. See
67  // J. Chem. Phys. 95 (3467) (1991)
68  // Rule # points lexact
69  // 1 1 0
70  // 2 4 2
71  // 3 6 3
72  // 4 12 5
73  // 5 18 5
74  // 6 26 7
75  // 7 50 11
76  void SetQuadratureRule(int rule);
77 
78  std::unique_ptr<mGridType> createGrid(xmlNodePtr cur, bool useLinear = false);
79  RadialPotentialType* createVrWithBasisGroup(xmlNodePtr cur, mGridType* agrid);
80 
81  void doBreakUp(const std::vector<int>& angList,
82  const Matrix<mRealType>& vnn,
83  RealType rmax,
84  mRealType Vprefactor = 1.0);
85 
86  /** brief buildSO - takes the previously parsed angular momenta and spin-orbit tabulated potentials and uses
87  ** them to construct SOECPComponent* pp_so. This is called in "doBreakUp".
88  **
89  ** param std::vector<int>& angList The angular momentum for each SO potential.
90  ** param Matrix<mRealType>& vnnso (npot x ngrid) matrix storing all tabulated SO potentials.
91  ** param RealType rmax max r on the specified grid.
92  ** param mRealType Vprefactor optional scale factor.
93  **
94  ** return void
95  **
96  **/
97  void buildSO(const std::vector<int>& angList,
98  const Matrix<mRealType>& vnnso,
99  RealType rmax,
100  mRealType Vprefactor = 1.0);
101 
102  void printECPTable();
103  bool read_pp_file(const std::string& fname);
104 };
105 
106 // Read a file into a memory buffer.
107 // Under MPI, it reads the file with one node and broadcasts the contents to all the other nodes.
108 
110 {
111  char* cbuffer;
112  std::ifstream* fin;
114  int get_file_length(std::ifstream* f) const;
115 
116 public:
117  bool is_open;
118  int length;
119  ReadFileBuffer(Communicate* c) : cbuffer(NULL), fin(NULL), myComm(c), is_open(false), length(0) {}
120  bool open_file(const std::string& fname);
121  bool read_contents();
122  char* contents() { return cbuffer; }
123  void reset();
124 
126  {
127  delete[] cbuffer;
128  if (fin)
129  delete fin;
130  }
131 };
132 
133 
134 } // namespace qmcplusplus
135 #endif
void buildLocal(xmlNodePtr cur)
build a Local Pseudopotential
Base class for any object which needs to know about a MPI communicator.
Definition: MPIObjectBase.h:26
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::RealType RealType
Definition: Configuration.h:58
std::map< std::string, int > angMon
ECPComponentBuilder(const std::string &aname, Communicate *c, int nrule=-1, int llocal=-1, int srule=8)
constructor spin grid used for numerical integration.
OneDimGridBase< RealType > GridType
std::unique_ptr< NonLocalECPComponent > pp_nonloc
An abstract base class to implement a One-Dimensional grid.
Wrapping information on parallelism.
Definition: Communicate.h:68
bool open_file(const std::string &fname)
std::unique_ptr< mGridType > grid_global
std::unique_ptr< SOECPComponent > pp_so
std::map< std::string, std::unique_ptr< mGridType > > grid_inp
bool parseCasino(const std::string &fname, xmlNodePtr cur)
std::unique_ptr< RadialPotentialType > pp_loc
OneDimCubicSpline< RealType > RadialPotentialType
bool parse(const std::string &fname, xmlNodePtr cur)
bool read_pp_file(const std::string &fname)
std::unique_ptr< L2RadialPotential > pp_L2
void buildSemiLocalAndLocal(std::vector< xmlNodePtr > &semiPtr)
int get_file_length(std::ifstream *f) const
void doBreakUp(const std::vector< int > &angList, const Matrix< mRealType > &vnn, RealType rmax, mRealType Vprefactor=1.0)
Separate local from non-local potentials.
traits for QMC variables
Definition: Configuration.h:49
void buildSO(const std::vector< int > &angList, const Matrix< mRealType > &vnnso, RealType rmax, mRealType Vprefactor=1.0)
brief buildSO - takes the previously parsed angular momenta and spin-orbit tabulated potentials and u...
RadialPotentialType * createVrWithBasisGroup(xmlNodePtr cur, mGridType *agrid)
std::unique_ptr< mGridType > createGrid(xmlNodePtr cur, bool useLinear=false)