QMCPACK
SPOSetInfo Class Reference

collection of orbital info for SPOSet instance or builder More...

+ Collaboration diagram for SPOSetInfo:

Public Types

using RealType = QMCTraits::RealType
 
using states_t = std::vector< SPOInfo * >
 
using orderings = spoinfo::orderings
 

Public Member Functions

 SPOSetInfo ()
 
 ~SPOSetInfo ()
 
void add (SPOInfo &state)
 
void add (SPOInfo *state)
 
void add (std::vector< SPOInfo *> &state_vector)
 
void add (SPOSetInfo &other)
 
void finish (orderings ord=spoinfo::no_order, RealType tol=1e-6)
 renders collection immutable, must be called at end of initialization More...
 
bool complete () const
 
bool partial () const
 
bool has_indices () const
 
bool has_energies () const
 
int size () const
 
const SPOInfooperator[] (int s) const
 
const SPOInfooperator[] (int s)
 
int min_index () const
 
int max_index () const
 
RealType energy_tolerance () const
 
bool contiguous () const
 
bool unordered () const
 
bool index_ordered () const
 
bool energy_ordered () const
 
void report (const std::string &pad="")
 
template<typename SPOI >
void finish (std::vector< SPOI *> &state_vector, orderings ord=spoinfo::no_order, RealType tol=1e-6)
 
template<typename SPOI >
void finish (std::vector< int > &subset, std::vector< SPOI *> &state_vector, orderings ord=spoinfo::no_order, RealType tol=1e-6)
 

Private Member Functions

void index_sort ()
 sort states by index More...
 
void energy_sort (RealType tol)
 sort states by energy More...
 
void count_degeneracies ()
 count energetic degeneracy of states More...
 
void determine_order (RealType tol)
 determine the ordering of the states, if any More...
 
void modify ()
 render collection mutable More...
 
void clear ()
 empty collection and render mutable More...
 

Private Attributes

bool is_complete
 whether initialization is complete and SPOSetInfo is ready for use More...
 
bool indices_present
 whether all states have an index assigned More...
 
bool energies_present
 whether all states have an energy assigned More...
 
orderings order
 enum for how states are ordered More...
 
RealType energy_tol
 tolerance used to sort energies More...
 
int index_min
 minimum orbital index in the set (w.r.t the full set) More...
 
int index_max
 maximum orbital index in the set (w.r.t the full set) More...
 
std::vector< SPOInfo * > states
 collection of SPOInfo More...
 

Friends

class SPOSetBuilder
 

Detailed Description

collection of orbital info for SPOSet instance or builder

Definition at line 25 of file SPOSetInfo.h.

Member Typedef Documentation

◆ orderings

Definition at line 30 of file SPOSetInfo.h.

◆ RealType

Definition at line 28 of file SPOSetInfo.h.

◆ states_t

using states_t = std::vector<SPOInfo*>

Definition at line 29 of file SPOSetInfo.h.

Constructor & Destructor Documentation

◆ SPOSetInfo()

Definition at line 28 of file SPOSetInfo.cpp.

28 { modify(); }
void modify()
render collection mutable
Definition: SPOSetInfo.cpp:230

◆ ~SPOSetInfo()

~SPOSetInfo ( )

Definition at line 30 of file SPOSetInfo.cpp.

References qmcplusplus::delete_iter().

30 { delete_iter(states.begin(), states.end()); }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
void delete_iter(IT first, IT last)
delete the pointers in [first,last)

Member Function Documentation

◆ add() [1/4]

void add ( SPOInfo state)

Definition at line 34 of file SPOSetInfo.cpp.

References SPOInfo::copy().

Referenced by SPOSetInfo::finish(), and BsplineReader::initialize_spo2band().

34 { states.push_back(state.copy()); }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112

◆ add() [2/4]

void add ( SPOInfo state)

Definition at line 36 of file SPOSetInfo.cpp.

References SPOInfo::copy().

36 { states.push_back(state->copy()); }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112

◆ add() [3/4]

void add ( std::vector< SPOInfo *> &  state_vector)

Definition at line 38 of file SPOSetInfo.cpp.

References qmcplusplus::simd::add().

39 {
40  for (int i = 0; i < state_vector.size(); ++i)
41  add(state_vector[i]);
42 }
void add(SPOInfo &state)
Definition: SPOSetInfo.cpp:34

◆ add() [4/4]

void add ( SPOSetInfo other)

Definition at line 44 of file SPOSetInfo.cpp.

References qmcplusplus::simd::add(), and SPOSetInfo::states.

45 {
46  states_t::iterator so = other.states.begin(), so_end = other.states.end();
47  for (; so != so_end; ++so)
48  add((*so));
49 }
void add(SPOInfo &state)
Definition: SPOSetInfo.cpp:34

◆ clear()

void clear ( )
private

empty collection and render mutable

Definition at line 241 of file SPOSetInfo.cpp.

References qmcplusplus::delete_iter().

242 {
243  delete_iter(states.begin(), states.end());
244  states.clear();
245  modify();
246 }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
void delete_iter(IT first, IT last)
delete the pointers in [first,last)
void modify()
render collection mutable
Definition: SPOSetInfo.cpp:230

◆ complete()

bool complete ( ) const

Definition at line 83 of file SPOSetInfo.cpp.

83 { return is_complete; }
bool is_complete
whether initialization is complete and SPOSetInfo is ready for use
Definition: SPOSetInfo.h:91

◆ contiguous()

bool contiguous ( ) const

Definition at line 109 of file SPOSetInfo.cpp.

109 { return index_max - index_min == size() - 1; }
int index_min
minimum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:106
int index_max
maximum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:109

◆ count_degeneracies()

void count_degeneracies ( )
private

count energetic degeneracy of states

Definition at line 166 of file SPOSetInfo.cpp.

References qmcplusplus::abs(), qmcplusplus::spoinfo::energy_ordered, qmcplusplus::n, and qmcplusplus::Units::time::s.

167 {
168  if (energy_ordered())
169  {
170  states_t::iterator stmp, s = states.begin(), s_end = states.end();
171  while (s != s_end)
172  {
173  int g = 1;
174  stmp = s;
175  ++stmp;
176  // look ahead to count
177  while (stmp != s_end && std::abs((*stmp)->energy - (*s)->energy) < energy_tol)
178  {
179  g++;
180  ++stmp;
181  }
182  (*s)->degeneracy = g;
183  //(*s)->degeneracy_index = g-1;
184  // run over degenerate states to assign
185  for (int n = 0; n < g; ++n)
186  {
187  (*s)->degeneracy = g;
188  //(*s)->degeneracy_index = g-1-n;
189  ++s;
190  }
191  }
192  }
193 }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
bool energy_ordered() const
Definition: SPOSetInfo.cpp:115
RealType energy_tol
tolerance used to sort energies
Definition: SPOSetInfo.h:103

◆ determine_order()

void determine_order ( RealType  tol)
private

determine the ordering of the states, if any

Definition at line 195 of file SPOSetInfo.cpp.

References qmcplusplus::spoinfo::energy_and_index_ordered, qmcplusplus::spoinfo::energy_ordered, qmcplusplus::spoinfo::index_order(), qmcplusplus::spoinfo::index_ordered, qmcplusplus::Units::time::s, and qmcplusplus::spoinfo::unordered.

196 {
197  bool index_ord = false;
198  bool energy_ord = false;
199  states_t::iterator s_prev, s;
200  s = states.begin();
201  for (int i = 1; i < size(); ++i)
202  {
203  s_prev = s;
204  ++s;
205  index_ord &= index_order(*s_prev, *s);
206  }
207  if (has_energies())
208  {
209  energy_tol = tol;
210  EnergyOrder energy_order(energy_tol);
211  s = states.begin();
212  for (int i = 1; i < size(); ++i)
213  {
214  s_prev = s;
215  ++s;
216  energy_ord &= energy_order(*s_prev, *s);
217  }
218  }
219  if (index_ord && energy_ord)
221  else if (index_ord)
223  else if (energy_ord)
225  else
228 }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
bool index_order(const SPOInfo *left, const SPOInfo *right)
comparison function for sorting SPOInfo based on orbital index
Definition: SPOInfo.h:78
void count_degeneracies()
count energetic degeneracy of states
Definition: SPOSetInfo.cpp:166
bool has_energies() const
Definition: SPOSetInfo.cpp:89
RealType energy_tol
tolerance used to sort energies
Definition: SPOSetInfo.h:103
orderings order
enum for how states are ordered
Definition: SPOSetInfo.h:100

◆ energy_ordered()

◆ energy_sort()

void energy_sort ( RealType  tol)
private

sort states by energy

Definition at line 155 of file SPOSetInfo.cpp.

References APP_ABORT, and qmcplusplus::spoinfo::energy_ordered.

156 {
157  if (!has_energies())
158  APP_ABORT("SHOSetInfo::energy_sort not all states have an energy assigned");
159  energy_tol = tol;
160  EnergyOrder energy_order(energy_tol);
161  sort(states.begin(), states.end(), energy_order);
164 }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
void count_degeneracies()
count energetic degeneracy of states
Definition: SPOSetInfo.cpp:166
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
bool has_energies() const
Definition: SPOSetInfo.cpp:89
RealType energy_tol
tolerance used to sort energies
Definition: SPOSetInfo.h:103
orderings order
enum for how states are ordered
Definition: SPOSetInfo.h:100

◆ energy_tolerance()

RealType energy_tolerance ( ) const

Definition at line 105 of file SPOSetInfo.cpp.

105 { return energy_tol; }
RealType energy_tol
tolerance used to sort energies
Definition: SPOSetInfo.h:103

◆ finish() [1/3]

void finish ( orderings  ord = spoinfo::no_order,
RealType  tol = 1e-6 
)

renders collection immutable, must be called at end of initialization

Definition at line 51 of file SPOSetInfo.cpp.

References APP_ABORT, qmcplusplus::spoinfo::energy_ordered, qmcplusplus::spoinfo::index_ordered, omptarget::min(), and qmcplusplus::Units::time::s.

Referenced by SPOSetInfo::finish().

52 {
53  if (!complete())
54  {
55  index_min = std::numeric_limits<int>::max();
57  indices_present = true;
58  energies_present = true;
59  states_t::iterator i = states.begin(), i_end = states.end();
60  for (; i != i_end; ++i)
61  {
62  SPOInfo& s = **i;
63  index_min = std::min(s.index, index_min);
64  index_max = std::max(s.index, index_max);
65  indices_present &= s.has_index();
66  energies_present &= s.has_energy();
67  }
68  if (!has_indices())
69  APP_ABORT(
70  "SPOSetInfo::finish\n indices have not been assigned to states as required\n this is a developer error");
71  if (ord == spoinfo::index_ordered)
72  index_sort();
73  else if (ord == spoinfo::energy_ordered)
74  energy_sort(tol);
75  else
76  determine_order(tol);
77  is_complete = true;
78  }
79 }
void index_sort()
sort states by index
Definition: SPOSetInfo.cpp:149
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
bool has_indices() const
Definition: SPOSetInfo.cpp:87
void determine_order(RealType tol)
determine the ordering of the states, if any
Definition: SPOSetInfo.cpp:195
T min(T a, T b)
bool energies_present
whether all states have an energy assigned
Definition: SPOSetInfo.h:97
int index_min
minimum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:106
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
int index_max
maximum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:109
void energy_sort(RealType tol)
sort states by energy
Definition: SPOSetInfo.cpp:155
bool is_complete
whether initialization is complete and SPOSetInfo is ready for use
Definition: SPOSetInfo.h:91
bool indices_present
whether all states have an index assigned
Definition: SPOSetInfo.h:94

◆ finish() [2/3]

void finish ( std::vector< SPOI *> &  state_vector,
orderings  ord = spoinfo::no_order,
RealType  tol = 1e-6 
)
inline

Definition at line 71 of file SPOSetInfo.h.

References SPOSetInfo::add(), and SPOSetInfo::finish().

72  {
73  for (int i = 0; i < state_vector.size(); ++i)
74  add(state_vector[i]);
75  finish(ord, tol);
76  }
void add(SPOInfo &state)
Definition: SPOSetInfo.cpp:34
void finish(orderings ord=spoinfo::no_order, RealType tol=1e-6)
renders collection immutable, must be called at end of initialization
Definition: SPOSetInfo.cpp:51

◆ finish() [3/3]

void finish ( std::vector< int > &  subset,
std::vector< SPOI *> &  state_vector,
orderings  ord = spoinfo::no_order,
RealType  tol = 1e-6 
)
inline

Definition at line 79 of file SPOSetInfo.h.

References SPOSetInfo::add(), and SPOSetInfo::finish().

83  {
84  for (int i = 0; i < subset.size(); ++i)
85  add(state_vector[subset[i]]);
86  finish(ord, tol);
87  }
void add(SPOInfo &state)
Definition: SPOSetInfo.cpp:34
void finish(orderings ord=spoinfo::no_order, RealType tol=1e-6)
renders collection immutable, must be called at end of initialization
Definition: SPOSetInfo.cpp:51

◆ has_energies()

bool has_energies ( ) const

Definition at line 89 of file SPOSetInfo.cpp.

Referenced by SPOSetInputInfo::get_indices().

89 { return energies_present; }
bool energies_present
whether all states have an energy assigned
Definition: SPOSetInfo.h:97

◆ has_indices()

bool has_indices ( ) const

Definition at line 87 of file SPOSetInfo.cpp.

Referenced by SPOSetInputInfo::get_indices().

87 { return indices_present; }
bool indices_present
whether all states have an index assigned
Definition: SPOSetInfo.h:94

◆ index_ordered()

◆ index_sort()

void index_sort ( )
private

sort states by index

Definition at line 149 of file SPOSetInfo.cpp.

References qmcplusplus::spoinfo::index_order(), and qmcplusplus::spoinfo::index_ordered.

150 {
151  sort(states.begin(), states.end(), index_order);
153 }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
bool index_order(const SPOInfo *left, const SPOInfo *right)
comparison function for sorting SPOInfo based on orbital index
Definition: SPOInfo.h:78
orderings order
enum for how states are ordered
Definition: SPOSetInfo.h:100

◆ max_index()

int max_index ( ) const

Definition at line 103 of file SPOSetInfo.cpp.

103 { return index_max; }
int index_max
maximum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:109

◆ min_index()

int min_index ( ) const

Definition at line 101 of file SPOSetInfo.cpp.

101 { return index_min; }
int index_min
minimum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:106

◆ modify()

void modify ( )
private

render collection mutable

Definition at line 230 of file SPOSetInfo.cpp.

References qmcplusplus::no_energy_tol, qmcplusplus::no_index, and qmcplusplus::spoinfo::no_order.

231 {
232  is_complete = false;
233  order = no_order;
234  indices_present = false;
235  energies_present = false;
239 }
constexpr int no_index
Definition: SPOSetInfo.cpp:24
bool energies_present
whether all states have an energy assigned
Definition: SPOSetInfo.h:97
int index_min
minimum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:106
int index_max
maximum orbital index in the set (w.r.t the full set)
Definition: SPOSetInfo.h:109
bool is_complete
whether initialization is complete and SPOSetInfo is ready for use
Definition: SPOSetInfo.h:91
bool indices_present
whether all states have an index assigned
Definition: SPOSetInfo.h:94
RealType energy_tol
tolerance used to sort energies
Definition: SPOSetInfo.h:103
constexpr RealType no_energy_tol
Definition: SPOSetInfo.cpp:23
orderings order
enum for how states are ordered
Definition: SPOSetInfo.h:100

◆ operator[]() [1/2]

const SPOInfo * operator[] ( int  s) const

Definition at line 95 of file SPOSetInfo.cpp.

References qmcplusplus::Units::time::s.

95 { return states[s]; }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112

◆ operator[]() [2/2]

const SPOInfo * operator[] ( int  s)

Definition at line 97 of file SPOSetInfo.cpp.

References qmcplusplus::Units::time::s.

97 { return states[s]; }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112

◆ partial()

bool partial ( ) const

Definition at line 85 of file SPOSetInfo.cpp.

Referenced by SPOSetInputInfo::get_indices().

85 { return size() > 0 && !complete(); }

◆ report()

void report ( const std::string &  pad = "")

Definition at line 122 of file SPOSetInfo.cpp.

References qmcplusplus::app_log(), qmcplusplus::spoinfo::energy_ordered, qmcplusplus::Units::time::ns, and qmcplusplus::Units::time::s.

123 {
124  app_log() << pad << "complete = " << complete() << std::endl;
125  if (complete())
126  {
127  app_log() << pad << "min_index = " << min_index() << std::endl;
128  app_log() << pad << "max_index = " << max_index() << std::endl;
129  app_log() << pad << "contiguous = " << contiguous() << std::endl;
130  app_log() << pad << "has_energies = " << has_energies() << std::endl;
131  app_log() << pad << "energy_ordered = " << energy_ordered() << std::endl;
132  if (energy_ordered())
133  app_log() << pad << "energy_tolerance = " << energy_tolerance() << std::endl;
134  app_log() << pad << "# of states = " << size() << std::endl;
135  app_log() << pad << "state information:" << std::endl;
136  states_t::iterator s = states.begin(), s_end = states.end();
137  std::string pad2 = pad + " ";
138  int ns = 0;
139  for (; s != s_end; ++s, ++ns)
140  {
141  app_log() << pad << " state " << ns << std::endl;
142  (*s)->report(pad2);
143  }
144  }
145  app_log().flush();
146 }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112
std::ostream & app_log()
Definition: OutputManager.h:65
bool energy_ordered() const
Definition: SPOSetInfo.cpp:115
bool has_energies() const
Definition: SPOSetInfo.cpp:89
RealType energy_tolerance() const
Definition: SPOSetInfo.cpp:105

◆ size()

int size ( void  ) const

Definition at line 93 of file SPOSetInfo.cpp.

Referenced by SPOSetInputInfo::get_indices(), SPOSetInputInfo::occupy_ecut(), SPOSetInputInfo::occupy_energies(), and SPOSetInputInfo::occupy_energy_range().

93 { return states.size(); }
std::vector< SPOInfo * > states
collection of SPOInfo
Definition: SPOSetInfo.h:112

◆ unordered()

bool unordered ( ) const

Definition at line 111 of file SPOSetInfo.cpp.

References qmcplusplus::spoinfo::unordered.

111 { return order == spoinfo::unordered; }
orderings order
enum for how states are ordered
Definition: SPOSetInfo.h:100

Friends And Related Function Documentation

◆ SPOSetBuilder

friend class SPOSetBuilder
friend

Definition at line 132 of file SPOSetInfo.h.

Member Data Documentation

◆ energies_present

bool energies_present
private

whether all states have an energy assigned

Definition at line 97 of file SPOSetInfo.h.

◆ energy_tol

RealType energy_tol
private

tolerance used to sort energies

Definition at line 103 of file SPOSetInfo.h.

◆ index_max

int index_max
private

maximum orbital index in the set (w.r.t the full set)

Definition at line 109 of file SPOSetInfo.h.

◆ index_min

int index_min
private

minimum orbital index in the set (w.r.t the full set)

Definition at line 106 of file SPOSetInfo.h.

◆ indices_present

bool indices_present
private

whether all states have an index assigned

Definition at line 94 of file SPOSetInfo.h.

◆ is_complete

bool is_complete
private

whether initialization is complete and SPOSetInfo is ready for use

Definition at line 91 of file SPOSetInfo.h.

◆ order

orderings order
private

enum for how states are ordered

Definition at line 100 of file SPOSetInfo.h.

◆ states

std::vector<SPOInfo*> states
private

collection of SPOInfo

Definition at line 112 of file SPOSetInfo.h.

Referenced by SPOSetInfo::add().


The documentation for this class was generated from the following files: