QMCPACK
BandInfo.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: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 /** @file BandInfo.cpp
15  */
16 #include "BandInfo.h"
18 namespace qmcplusplus
19 {
20 BandInfoGroup::BandInfoGroup() : FirstSPO(0), NumSPOs(0), FirstBand(0) {}
21 
22 void BandInfoGroup::selectBands(const std::vector<BandInfo>& bigspace, double emin, double emax)
23 {
24  myBands.clear();
25  if (emin > emax)
26  return;
27 
28  int iorb = 0;
29  int N = bigspace.size();
30  int n_lower = 0;
31  do
32  {
33  if (bigspace[iorb].Energy >= emin)
34  break;
35  n_lower += (bigspace[iorb].MakeTwoCopies) ? 2 : 1;
36  ++iorb;
37  } while (iorb < N);
38 
39  if (iorb >= N)
40  {
41  APP_ABORT("BandInfoGroup::selectBands failed due to iorb>=N");
42  }
43 
44  FirstSPO = n_lower;
45  FirstBand = iorb;
46  NumSPOs = 0;
47  while (iorb < N)
48  {
49  if (bigspace[iorb].Energy >= emax)
50  break;
51  myBands.push_back(bigspace[iorb]);
52  NumSPOs += (bigspace[iorb].MakeTwoCopies) ? 2 : 1;
53  ++iorb;
54  }
55 
56  app_log() << "BandInfoGroup::selectBands using energy [" << emin << "," << emax << ")" << std::endl;
57  app_log() << " Number of distinct bands " << myBands.size() << std::endl;
58  app_log() << " First Band index " << FirstBand << std::endl;
59  app_log() << " First SPO index " << FirstSPO << std::endl;
60  app_log() << " Size of SPOs " << NumSPOs << std::endl;
61 
62  //for(int i=0; i<myBands.size(); ++i)
63  // app_log() << myBands[i].TwistIndex << " " << myBands[i].Energy << std::endl;
64  app_log().flush();
65 }
66 
67 void BandInfoGroup::selectBands(const std::vector<BandInfo>& bigspace, int first_orb, int num_spos, bool relative)
68 {
69  app_log() << "BandInfoGroup::selectBands bigspace has " << bigspace.size() << " distinct orbitals " << std::endl;
70  myBands.clear();
71 
72  int iorb = 0;
73  int N = bigspace.size();
74  int n_lower = 0;
75  do
76  {
77  if (iorb >= first_orb)
78  break;
79  n_lower += (bigspace[iorb].MakeTwoCopies) ? 2 : 1;
80  ++iorb;
81  } while (iorb < N);
82 
83  if (iorb >= N)
84  {
85  APP_ABORT("BandInfoGroup::selectBands failed due to iorb>=N");
86  }
87 
88  FirstSPO = (relative) ? n_lower : 0;
89  FirstBand = iorb;
90  NumSPOs = 0;
91  int ns_max = num_spos - 1;
92  while (iorb < N && NumSPOs < num_spos)
93  {
94  //if(myBands.size()>=num_orbs) break;
95  myBands.push_back(bigspace[iorb]);
96  NumSPOs += (NumSPOs < ns_max && bigspace[iorb].MakeTwoCopies) ? 2 : 1;
97  ++iorb;
98  }
99 
100  app_log() << "BandInfoGroup::selectBands using distinct orbitals [" << first_orb << "," << iorb << ")" << std::endl;
101  app_log() << " Number of distinct bands " << myBands.size() << std::endl;
102  app_log() << " First Band index " << FirstBand << std::endl;
103  app_log() << " First SPO index " << FirstSPO << std::endl;
104  app_log() << " Size of SPOs " << NumSPOs << std::endl;
105 }
106 
107 // void BandInfoGroup::selectBands(const std::vector<BandInfo>& bigspace, int first_orb, int last_orb)
108 // {
109 // app_log() << "BandInfoGroup::selectBands bigspace has " << bigspace.size() << " distinct orbitals " << std::endl;
110 // myBands.clear();
111 //
112 // int iorb=0;
113 // int N=bigspace.size();
114 // bool skipit=true;
115 // int n_lower=0;
116 // do
117 // {
118 // if(iorb>=first_orb) break;
119 // n_lower += (bigspace[iorb].MakeTwoCopies)?2:1;
120 // ++iorb;
121 // } while(iorb<N);
122 //
123 // if(iorb>=N)
124 // {
125 // APP_ABORT("BandInfoGroup::selectBands failed due to iorb>=N");
126 // }
127 //
128 // if(first_orb != iorb)
129 // {
130 // APP_ABORT("Cannot locate the first SPO ");
131 // }
132 //
133 // int num_orbs=last_orb-first_orb;
134 // if(num_orbs<=0)
135 // {
136 // APP_ABORT("BandInfoGroup::selectBands(bigspace,first_orb,last_orb) Illegal range ");
137 // }
138 //
139 // FirstSPO=n_lower;
140 // FirstBand=iorb;
141 // NumSPOs=0;
142 // while(iorb<N)
143 // {
144 // if(myBands.size()>=num_orbs) break;
145 // myBands.push_back(bigspace[iorb]);
146 // NumSPOs += (bigspace[iorb].MakeTwoCopies)?2:1;
147 // ++iorb;
148 // }
149 //
150 // //for(int i=0; i<myBands.size(); ++i)
151 // // app_log() << myBands[i].TwistIndex << " " << myBands[i].Energy << std::endl;
152 //
153 // app_log().flush();
154 // }
155 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::ostream & app_log()
Definition: OutputManager.h:65
BandInfoGroup()
constructor
Definition: BandInfo.cpp:20
Define helper class to sort bands according to the band and twist and functions.
void selectBands(const std::vector< BandInfo > &bigspace, double emin, double emax)
select the bands within an energy range [emin,emax)
Definition: BandInfo.cpp:22
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
int FirstBand
starting band
Definition: BandInfo.h:75
int NumSPOs
number of SPOs handled by this object
Definition: BandInfo.h:73
std::vector< BandInfo > myBands
Bands that belong to this group.
Definition: BandInfo.h:79
int FirstSPO
starting SPO
Definition: BandInfo.h:71