QMCPACK
FreeOrbitalBuilder Class Reference
+ Inheritance diagram for FreeOrbitalBuilder:
+ Collaboration diagram for FreeOrbitalBuilder:

Public Member Functions

 FreeOrbitalBuilder (ParticleSet &els, Communicate *comm, xmlNodePtr cur)
 
 ~FreeOrbitalBuilder ()
 
std::unique_ptr< SPOSet > createSPOSetFromXML (xmlNodePtr cur) override
 create an sposet from xml (legacy) More...
 
- 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)
 

Private Member Functions

bool in_list (const int j, const std::vector< int > l)
 

Private Attributes

ParticleSet & targetPtcl
 

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
 
- 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...
 
- Protected Member Functions inherited from SPOSetBuilder
virtual std::unique_ptr< SPOSet > createSPOSet (xmlNodePtr cur, SPOSetInputInfo &input_info)
 create an sposet from a general xml request More...
 
- 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 8 of file FreeOrbitalBuilder.h.

Constructor & Destructor Documentation

◆ FreeOrbitalBuilder()

FreeOrbitalBuilder ( ParticleSet &  els,
Communicate *  comm,
xmlNodePtr  cur 
)

Definition at line 9 of file FreeOrbitalBuilder.cpp.

10  : SPOSetBuilder("PW", comm), targetPtcl(els)
11 {}
SPOSetBuilder(const std::string &type_name, Communicate *comm)

◆ ~FreeOrbitalBuilder()

~FreeOrbitalBuilder ( )
inline

Definition at line 12 of file FreeOrbitalBuilder.h.

12 {}

Member Function Documentation

◆ createSPOSetFromXML()

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

create an sposet from xml (legacy)

Implements SPOSetBuilder.

Definition at line 13 of file FreeOrbitalBuilder.cpp.

References qmcplusplus::abs(), OhmmsAttributeSet::add(), qmcplusplus::app_log(), qmcplusplus::ceil(), qmcplusplus::Units::charge::e, ParticleSet::getLattice(), FreeOrbitalBuilder::in_list(), KContainer::kpts, KContainer::kpts_cart, qmcplusplus::lattice, KContainer::minusk, OhmmsAttributeSet::put(), ParticleSet::setTwist(), TinyVector< T, D >::size(), FreeOrbitalBuilder::targetPtcl, and KContainer::updateKLists().

14 {
15  int norb = -1;
16  std::string spo_object_name;
17  PosType twist(0.0);
18  OhmmsAttributeSet attrib;
19  attrib.add(norb, "size");
20  attrib.add(twist, "twist");
21  attrib.add(spo_object_name, "name");
22  attrib.put(cur);
23 
24  if (norb < 0)
25  throw std::runtime_error("free orbital SPO set require the \"size\" input");
26 
27  auto lattice = targetPtcl.getLattice();
28 
29  PosType tvec = lattice.k_cart(twist);
30 #ifdef QMC_COMPLEX
31  const int npw = norb;
32  targetPtcl.setTwist(twist);
33  app_log() << "twist fraction = " << twist << std::endl;
34  app_log() << "twist cartesian = " << tvec << std::endl;
35 #else
36  const int npw = std::ceil((norb + 1.0) / 2);
37  if (2 * npw - 1 != norb)
38  {
39  std::ostringstream msg;
40  msg << "norb = " << norb << " npw = " << npw;
41  msg << " cannot be ran in real PWs (sin, cos)" << std::endl;
42  msg << "either use complex build or change the size of SPO set" << std::endl;
43  msg << "ideally, set size to a closed shell of PWs." << std::endl;
44  throw std::runtime_error(msg.str());
45  }
46  for (int ldim = 0; ldim < twist.size(); ldim++)
47  {
48  if (std::abs(twist[ldim]) > 1e-16)
49  throw std::runtime_error("no twist for real orbitals");
50  }
51 #endif
52 
53  // extract npw k-points from container
54  // kpts_cart is sorted by magnitude
55  std::vector<PosType> kpts(npw);
56  KContainer klists;
57  RealType kcut = lattice.LR_kc; // to-do: reduce kcut to >~ kf
58  klists.updateKLists(lattice, kcut, lattice.ndim, twist);
59 
60  // k0 is not in kpts_cart
61  kpts[0] = tvec;
62 #ifdef QMC_COMPLEX
63  for (int ik = 1; ik < npw; ik++)
64  {
65  kpts[ik] = klists.kpts_cart[ik - 1];
66  }
67 #else
68  const int nktot = klists.kpts.size();
69  std::vector<int> mkidx(npw, 0);
70  int ik = 1;
71  for (int jk = 0; jk < nktot; jk++)
72  {
73  // check if -k is already chosen
74  const int jmk = klists.minusk[jk];
75  if (in_list(jk, mkidx))
76  continue;
77  // if not, then add this kpoint
78  kpts[ik] = klists.kpts_cart[jk];
79  mkidx[ik] = jmk; // keep track of its minus
80  ik++;
81  if (ik >= npw)
82  break;
83  }
84 #endif
85  auto sposet = std::make_unique<FreeOrbital>(spo_object_name, kpts);
86  sposet->report(" ");
87  return sposet;
88 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
bool in_list(const int j, const std::vector< int > l)
QMCTraits::PosType PosType
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
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
void setTwist(const SingleParticlePos &t)
Definition: ParticleSet.h:481
QMCTraits::RealType RealType
const auto & getLattice() const
Definition: ParticleSet.h:251
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

◆ in_list()

bool in_list ( const int  j,
const std::vector< int >  l 
)
private

Definition at line 90 of file FreeOrbitalBuilder.cpp.

Referenced by FreeOrbitalBuilder::createSPOSetFromXML().

91 {
92  for (int i = 0; i < l.size(); i++)
93  {
94  if (j == l[i])
95  return true;
96  }
97  return false;
98 }

Member Data Documentation

◆ targetPtcl

ParticleSet& targetPtcl
private

Definition at line 17 of file FreeOrbitalBuilder.h.

Referenced by FreeOrbitalBuilder::createSPOSetFromXML().


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