QMCPACK
SHOSetBuilder Struct Reference
+ Inheritance diagram for SHOSetBuilder:
+ Collaboration diagram for SHOSetBuilder:

Public Member Functions

 SHOSetBuilder (ParticleSet &P, Communicate *comm)
 
 ~SHOSetBuilder () override
 
void reset ()
 
std::unique_ptr< SPOSet > createSPOSetFromXML (xmlNodePtr cur) override
 create an sposet from xml (legacy) More...
 
std::unique_ptr< SPOSet > createSPOSet (xmlNodePtr cur, SPOSetInputInfo &input) override
 create an sposet from a general xml request More...
 
void update_basis_states (int smax)
 
void report (const std::string &pad="")
 
- Public Member Functions inherited from SPOSetBuilder
 SPOSetBuilder (const std::string &type_name, Communicate *comm)
 
virtual ~SPOSetBuilder ()
 
void reserve_states (int nsets=1)
 reserve space for states (usually only one set, multiple for e.g. spin dependent einspline) More...
 
void modify_states (int index=0)
 allow modification of state information More...
 
void clear_states (int index=0)
 clear state information More...
 
std::unique_ptr< SPOSet > createSPOSet (xmlNodePtr cur)
 create an sposet from xml and save the resulting SPOSet More...
 
std::unique_ptr< SPOSet > createRotatedSPOSet (xmlNodePtr cur)
 create orbital rotation transformation from xml and save the resulting SPOSet More...
 
const std::string & getTypeName () const
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
Communicate * getCommunicator () const
 return myComm More...
 
Communicate & getCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Public Attributes

ParticleSet & Ps
 
RealType length
 
RealType mass
 
RealType energy
 
PosType center
 
int nstates
 
int nmax
 
TinyVector< int, DIM > ind_dims
 
SPOSetInfoSimple< SHOState > basis_states
 
- Public Attributes inherited from SPOSetBuilder
bool legacy
 whether implementation conforms only to legacy standard More...
 
std::vector< std::unique_ptr< SPOSetInfo > > states
 state info of all possible states available in the basis More...
 

Additional Inherited Members

- Public Types inherited from SPOSetBuilder
using indices_t = std::vector< int >
 
using energies_t = std::vector< RealType >
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 
- Protected Attributes inherited from SPOSetBuilder
const std::string type_name_
 type name of the SPO objects built by this builder. More...
 
- Protected Attributes inherited from MPIObjectBase
Communicate * myComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Detailed Description

Definition at line 23 of file SHOSetBuilder.h.

Constructor & Destructor Documentation

◆ SHOSetBuilder()

SHOSetBuilder ( ParticleSet &  P,
Communicate *  comm 
)

Definition at line 23 of file SHOSetBuilder.cpp.

References qmcplusplus::app_log(), MPIObjectBase::ClassName, SPOSetBuilder::legacy, and SHOSetBuilder::reset().

23  : SPOSetBuilder("SHO", comm), Ps(P)
24 {
25  ClassName = "SHOSetBuilder";
26  legacy = false;
27  app_log() << "Constructing SHOSetBuilder" << std::endl;
28  reset();
29 }
std::ostream & app_log()
Definition: OutputManager.h:65
SPOSetBuilder(const std::string &type_name, Communicate *comm)
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
bool legacy
whether implementation conforms only to legacy standard
Definition: SPOSetBuilder.h:54

◆ ~SHOSetBuilder()

~SHOSetBuilder ( )
override

Definition at line 32 of file SHOSetBuilder.cpp.

32 {}

Member Function Documentation

◆ createSPOSet()

std::unique_ptr< SPOSet > createSPOSet ( xmlNodePtr  cur,
SPOSetInputInfo &  input_info 
)
overridevirtual

create an sposet from a general xml request

Reimplemented from SPOSetBuilder.

Definition at line 57 of file SHOSetBuilder.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, qmcplusplus::app_log(), SHOSetBuilder::basis_states, qmcplusplus::ceil(), SHOSetBuilder::center, SHOSetBuilder::energy, SHOSetBuilder::length, SHOSetBuilder::mass, SHOSetBuilder::nstates, OhmmsAttributeSet::put(), SHOSetBuilder::reset(), qmcplusplus::sqrt(), SPOSetBuilder::states, and SHOSetBuilder::update_basis_states().

Referenced by SHOSetBuilder::createSPOSetFromXML().

58 {
59  app_log() << "SHOSetBuilder::createSHOSet(indices) " << std::endl;
60 
61  using std::ceil;
62  using std::sqrt;
63 
64  reset();
65 
66  // read parameters
67  std::string spo_name = "sho";
68  OhmmsAttributeSet attrib;
69  attrib.add(spo_name, "name");
70  attrib.add(spo_name, "id");
71  attrib.add(mass, "mass");
72  attrib.add(energy, "energy");
73  attrib.add(energy, "frequency");
74  attrib.add(length, "length");
75  attrib.add(center, "center");
76  attrib.add(nstates, "size");
77  attrib.put(cur);
78 
79  if (energy < 0.0)
80  energy = 1.0;
81  if (mass < 0.0 && length < 0.0)
82  length = 1.0;
83  if (mass < 0.0)
84  mass = 1.0 / (energy * length * length);
85  else if (length < 0.0)
86  length = 1.0 / sqrt(mass * energy);
87 
88  // initialize states and/or adjust basis
89  int smax = -1;
90  if (input.has_index_info)
91  smax = std::max(smax, input.max_index());
92  if (input.has_energy_info)
93  {
94  smax = std::max(smax, (int)ceil(input.max_energy() / energy));
95  }
96  if (smax < 0)
97  APP_ABORT("SHOSetBuilder::Initialize\n invalid basis size");
98  update_basis_states(smax);
99 
100  // create sho state request
101  indices_t& indices = input.get_indices(states);
102  std::vector<SHOState*> sho_states;
103  for (int i = 0; i < indices.size(); ++i)
104  sho_states.push_back(basis_states[indices[i]]);
105 
106  // make the sposet
107  auto sho = std::make_unique<SHOSet>(spo_name, length, center, sho_states);
108 
109  sho->report(" ");
110  //sho->test_derivatives();
111  //sho->test_overlap();
112  //APP_ABORT("SHOSetBuilder check");
113 
114  return sho;
115 }
std::vector< int > indices_t
Definition: SPOSetBuilder.h:50
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
void update_basis_states(int smax)
SPOSetInfoSimple< SHOState > basis_states
Definition: SHOSetBuilder.h:38
std::vector< std::unique_ptr< SPOSetInfo > > states
state info of all possible states available in the basis
Definition: SPOSetBuilder.h:57
MakeReturn< UnaryNode< FnCeil, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t ceil(const Vector< T1, C1 > &l)
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
testing::ValidSpinDensityInput input
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

◆ createSPOSetFromXML()

std::unique_ptr< SPOSet > createSPOSetFromXML ( xmlNodePtr  cur)
overridevirtual

create an sposet from xml (legacy)

Implements SPOSetBuilder.

Definition at line 45 of file SHOSetBuilder.cpp.

References APP_ABORT, qmcplusplus::app_log(), and SHOSetBuilder::createSPOSet().

46 {
47  APP_ABORT("SHOSetBuilder::createSPOSetFromXML SHOSetBuilder should not use legacy interface");
48 
49  app_log() << "SHOSetBuilder::createSHOSet(xml) " << std::endl;
50 
51  SPOSetInputInfo input(cur);
52 
53  return createSPOSet(cur, input);
54 }
std::ostream & app_log()
Definition: OutputManager.h:65
std::unique_ptr< SPOSet > createSPOSet(xmlNodePtr cur, SPOSetInputInfo &input) override
create an sposet from a general xml request
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
testing::ValidSpinDensityInput input

◆ report()

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

Definition at line 197 of file SHOSetBuilder.cpp.

References qmcplusplus::app_log(), SHOSetBuilder::basis_states, SHOSetBuilder::center, QMCTraits::DIM, SHOSetBuilder::energy, SHOSetBuilder::ind_dims, qmcplusplus::int2string(), SHOSetBuilder::length, SHOSetBuilder::mass, SHOSetBuilder::nmax, SHOSetBuilder::nstates, and qmcplusplus::Units::time::s.

198 {
199  app_log() << pad << "SHOSetBuilder report" << std::endl;
200  app_log() << pad << " dimension = " << DIM << std::endl;
201  app_log() << pad << " mass = " << mass << std::endl;
202  app_log() << pad << " frequency = " << energy << std::endl;
203  app_log() << pad << " energy = " << energy << std::endl;
204  app_log() << pad << " length = " << length << std::endl;
205  app_log() << pad << " center = " << center << std::endl;
206  app_log() << pad << " nstates = " << nstates << std::endl;
207  app_log() << pad << " nmax = " << nmax << std::endl;
208  app_log() << pad << " ind_dims = " << ind_dims << std::endl;
209  app_log() << pad << " # basis states = " << basis_states.size() << std::endl;
210  app_log() << pad << " basis_states" << std::endl;
211  for (int s = 0; s < basis_states.size(); ++s)
212  basis_states[s]->report(pad + " " + int2string(s) + " ");
213  app_log() << pad << "end SHOSetBuilder report" << std::endl;
214  app_log().flush();
215 }
std::ostream & app_log()
Definition: OutputManager.h:65
TinyVector< int, DIM > ind_dims
Definition: SHOSetBuilder.h:36
std::string int2string(const int &i)
Definition: string_utils.h:119
SPOSetInfoSimple< SHOState > basis_states
Definition: SHOSetBuilder.h:38
void report(const std::string &pad="")

◆ reset()

◆ update_basis_states()

void update_basis_states ( int  smax)

Definition at line 118 of file SHOSetBuilder.cpp.

References APP_ABORT, SHOSetBuilder::basis_states, qmcplusplus::ceil(), SPOSetBuilder::clear_states(), QMCTraits::DIM, qmcplusplus::Units::charge::e, SHOSetBuilder::energy, SPOInfo::energy, qmcplusplus::exp(), SHOSetBuilder::ind_dims, qmcplusplus::log(), qmcplusplus::Units::distance::m, qmcplusplus::Units::force::N, qmcplusplus::n, SHOSetBuilder::nmax, qmcplusplus::pow(), SHOState::quantum_number, qmcplusplus::Units::time::s, SHOState::set(), qmcplusplus::sqrt(), and SPOSetBuilder::states.

Referenced by SHOSetBuilder::createSPOSet().

119 {
120  using std::ceil;
121  using std::exp;
122  using std::log;
123  using std::sort;
124  using std::sqrt;
125 
126  int states_required = smax - basis_states.size() + 1;
127  if (states_required > 0)
128  {
129  RealType N = smax + 1;
130  if (DIM == 1)
131  nmax = smax;
132  else if (DIM == 2)
133  nmax = ceil(.5 * sqrt(8. * N + 1.) - 1.5);
134  else if (DIM == 3)
135  {
136  RealType f = exp(1.0 / 3.0 * log(81. * N + 3. * sqrt(729. * N * N - 3.)));
137  nmax = ceil(f / 3. + 1. / f - 2.);
138  }
139  else
140  APP_ABORT("SHOSetBuilder::update_basis_states dimensions other than 1, 2, or 3 are not supported");
141  int ndim = nmax + 1;
142  ind_dims[DIM - 1] = 1;
143  for (int d = DIM - 2; d > -1; --d)
144  ind_dims[d] = ind_dims[d + 1] * ndim;
145  int s = 0;
146  int ntot = pow(ndim, DIM);
147  TinyVector<int, DIM> qnumber;
148  for (int m = 0; m < ntot; ++m)
149  {
150  int n = 0; // principal quantum number
151  int nrem = m;
152  for (int d = 0; d < DIM; ++d)
153  {
154  int i = nrem / ind_dims[d];
155  nrem -= i * ind_dims[d];
156  qnumber[d] = i;
157  n += i;
158  }
159  if (n <= nmax)
160  {
161  SHOState* st;
162  if (s < basis_states.size())
163  st = basis_states[s];
164  else
165  {
166  st = new SHOState();
167  basis_states.add(st);
168  }
169  RealType e = energy * (n + .5 * DIM);
170  st->set(qnumber, e);
171  s++;
172  }
173  }
174  basis_states.energy_sort(1e-6, true);
175  }
176 
177  // reset energy scale even if no states need to be added
178  for (int i = 0; i < basis_states.size(); ++i)
179  {
180  SHOState& state = *basis_states[i];
181  const TinyVector<int, DIM>& qnumber = state.quantum_number;
182  int n = 0;
183  for (int d = 0; d < DIM; ++d)
184  n += qnumber[d];
185  state.energy = energy * (n + .5 * DIM);
186  }
187 
188  //somewhat redundant, but necessary
189  clear_states(0);
190  states[0]->finish(basis_states.states);
191 
192  if (basis_states.size() <= smax)
193  APP_ABORT("SHOSetBuilder::update_basis_states failed to make enough states");
194 }
TinyVector< int, DIM > ind_dims
Definition: SHOSetBuilder.h:36
SPOSetInfoSimple< SHOState > basis_states
Definition: SHOSetBuilder.h:38
std::vector< std::unique_ptr< SPOSetInfo > > states
state info of all possible states available in the basis
Definition: SPOSetBuilder.h:57
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)
MakeReturn< UnaryNode< FnCeil, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t ceil(const Vector< T1, C1 > &l)
void clear_states(int index=0)
clear state information
Definition: SPOSetBuilder.h:69
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType

Member Data Documentation

◆ basis_states

◆ center

◆ energy

◆ ind_dims

TinyVector<int, DIM> ind_dims

Definition at line 36 of file SHOSetBuilder.h.

Referenced by SHOSetBuilder::report(), and SHOSetBuilder::update_basis_states().

◆ length

◆ mass

◆ nmax

int nmax

Definition at line 35 of file SHOSetBuilder.h.

Referenced by SHOSetBuilder::report(), and SHOSetBuilder::update_basis_states().

◆ nstates

int nstates

◆ Ps

Definition at line 27 of file SHOSetBuilder.h.


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