QMCPACK
NonLocalTOperator Struct Reference
+ Collaboration diagram for NonLocalTOperator:

Public Types

using RealType = NonLocalData::RealType
 
using PosType = NonLocalData::PosType
 

Public Member Functions

 NonLocalTOperator ()
 
int thingsThatShouldBeInMyConstructor (const std::string &non_local_move_option, const double tau, const double alpha, const double gamma)
 replacement for put because wouldn't it be cool to know what the classes configuration actually is. More...
 
int put (xmlNodePtr cur)
 initialize the parameters More...
 
const NonLocalDataselectMove (RealType prob, const std::vector< NonLocalData > &txy)
 select the move for a given probability More...
 
const NonLocalDataselectMove (RealType prob, int iel)
 select the move for a given probability using internal txy_by_elec_ More...
 
void groupByElectron (size_t num_elec, const std::vector< NonLocalData > &txy)
 sort all the Txy elements by electron More...
 

Private Attributes

RealType tau_
 
RealType alpha_
 
RealType gamma_
 
RealType plusFactor
 factor applied on >0 weight More...
 
RealType minusFactor
 factor applied on <=0 weight More...
 
std::vector< RealTypetxy_scan_
 
std::vector< std::vector< NonLocalData > > txy_by_elec_
 

Detailed Description

Definition at line 37 of file NonLocalTOperator.h.

Member Typedef Documentation

◆ PosType

Definition at line 40 of file NonLocalTOperator.h.

◆ RealType

Definition at line 39 of file NonLocalTOperator.h.

Constructor & Destructor Documentation

◆ NonLocalTOperator()

Member Function Documentation

◆ groupByElectron()

void groupByElectron ( size_t  num_elec,
const std::vector< NonLocalData > &  txy 
)

sort all the Txy elements by electron

Definition at line 124 of file NonLocalTOperator.cpp.

References NonLocalTOperator::txy_by_elec_.

Referenced by NonLocalECPotential::makeNonLocalMovesPbyP(), and qmcplusplus::TEST_CASE().

125 {
126  txy_by_elec_.resize(num_elec);
127  for (int i = 0; i < num_elec; i++)
128  txy_by_elec_[i].clear();
129 
130  for (int i = 0; i < txy.size(); i++)
131  {
132  assert(txy[i].PID >= 0 && txy[i].PID < num_elec);
133  txy_by_elec_[txy[i].PID].push_back(txy[i]);
134  }
135 }
std::vector< std::vector< NonLocalData > > txy_by_elec_

◆ put()

int put ( xmlNodePtr  cur)

initialize the parameters

process options related to TMoves

Returns
Tmove version Turns out this wants the NodePtr to the entire driver block.

Definition at line 30 of file NonLocalTOperator.cpp.

References ParameterSet::add(), NonLocalTOperator::alpha_, qmcplusplus::app_log(), NonLocalTOperator::gamma_, NonLocalTOperator::minusFactor, NonLocalTOperator::plusFactor, ParameterSet::put(), NonLocalTOperator::tau_, qmcplusplus::TMOVE_OFF, qmcplusplus::TMOVE_V0, qmcplusplus::TMOVE_V1, and qmcplusplus::TMOVE_V3.

Referenced by NonLocalECPotential::setNonLocalMoves().

31 {
32  std::string use_tmove = "no";
33  ParameterSet m_param;
34  m_param.add(tau_, "timeStep");
35  m_param.add(tau_, "timestep");
36  m_param.add(tau_, "Tau");
37  m_param.add(tau_, "tau");
38  m_param.add(alpha_, "alpha");
39  m_param.add(gamma_, "gamma");
40  m_param.add(use_tmove, "nonlocalmove");
41  m_param.add(use_tmove, "nonlocalmoves");
42  bool success = m_param.put(cur);
44  minusFactor = -tau_ * (1.0 - alpha_ * (1.0 + gamma_));
45  int v_tmove = TMOVE_OFF;
46  std::ostringstream o;
47  if (use_tmove == "no")
48  {
49  v_tmove = TMOVE_OFF;
50  o << " Using Locality Approximation";
51  }
52  else if (use_tmove == "yes" || use_tmove == "v0")
53  {
54  v_tmove = TMOVE_V0;
55  o << " Using Non-local T-moves v0, M. Casula, PRB 74, 161102(R) (2006)";
56  }
57  else if (use_tmove == "v1")
58  {
59  v_tmove = TMOVE_V1;
60  o << " Using Non-local T-moves v1, M. Casula et al., JCP 132, 154113 (2010)";
61  }
62  else if (use_tmove == "v3")
63  {
64  v_tmove = TMOVE_V3;
65  o << " Using Non-local T-moves v3, an approximation to v1";
66  }
67  else
68  throw std::runtime_error("NonLocalTOperator::put unknown nonlocalmove option " + use_tmove);
69 
70 #pragma omp master
71  app_log() << o.str() << std::endl;
72 
73  return v_tmove;
74 }
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
class to handle a set of parameters
Definition: ParameterSet.h:27
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
RealType plusFactor
factor applied on >0 weight
RealType minusFactor
factor applied on <=0 weight

◆ selectMove() [1/2]

const NonLocalData * selectMove ( RealType  prob,
const std::vector< NonLocalData > &  txy 
)

select the move for a given probability

Parameters
probvalue [0,1)
txya given Txy collection
Returns
pointer to NonLocalData

Definition at line 101 of file NonLocalTOperator.cpp.

References NonLocalTOperator::minusFactor, NonLocalTOperator::plusFactor, and NonLocalTOperator::txy_scan_.

Referenced by NonLocalECPotential::makeNonLocalMovesPbyP(), and qmcplusplus::TEST_CASE().

102 {
103  // txy_scan_[0] = 1.0, txy_scan_[i>0] = txy_scan_[i-1] + txy[i-1].Weight (modified)
104  txy_scan_.resize(txy.size());
105  RealType wgt_t = 1.0;
106  for (int i = 0; i < txy.size(); i++)
107  {
108  txy_scan_[i] = wgt_t;
109  if (txy[i].Weight > 0)
110  wgt_t += txy[i].Weight * plusFactor;
111  else
112  wgt_t += txy[i].Weight * minusFactor;
113  }
114 
115  const RealType target = prob * wgt_t;
116  // find ibar which satisify txy_scan_[ibar-1] <= target < txy_scan_[ibar]
117  int ibar = 0;
118  while (ibar < txy_scan_.size() && txy_scan_[ibar] <= target)
119  ibar++;
120 
121  return ibar > 0 ? &(txy[ibar - 1]) : nullptr;
122 }
std::vector< RealType > txy_scan_
QMCTraits::RealType RealType
RealType plusFactor
factor applied on >0 weight
RealType minusFactor
factor applied on <=0 weight

◆ selectMove() [2/2]

const NonLocalData* selectMove ( RealType  prob,
int  iel 
)
inline

select the move for a given probability using internal txy_by_elec_

Parameters
probvalue [0,1)
ielreference electron
Returns
pointer to NonLocalData

Definition at line 66 of file NonLocalTOperator.h.

References NonLocalTOperator::selectMove(), and NonLocalTOperator::txy_by_elec_.

Referenced by NonLocalTOperator::selectMove().

66 { return selectMove(prob, txy_by_elec_[iel]); }
std::vector< std::vector< NonLocalData > > txy_by_elec_
const NonLocalData * selectMove(RealType prob, const std::vector< NonLocalData > &txy)
select the move for a given probability

◆ thingsThatShouldBeInMyConstructor()

int thingsThatShouldBeInMyConstructor ( const std::string &  non_local_move_option,
const double  tau,
const double  alpha,
const double  gamma 
)

replacement for put because wouldn't it be cool to know what the classes configuration actually is.

Definition at line 76 of file NonLocalTOperator.cpp.

References NonLocalTOperator::alpha_, NonLocalTOperator::gamma_, NonLocalTOperator::minusFactor, NonLocalTOperator::plusFactor, NonLocalTOperator::tau_, qmcplusplus::TMOVE_OFF, qmcplusplus::TMOVE_V0, qmcplusplus::TMOVE_V1, and qmcplusplus::TMOVE_V3.

Referenced by NonLocalECPotential::setNonLocalMoves(), and qmcplusplus::TEST_CASE().

80 {
81  tau_ = tau;
82  alpha_ = alpha;
83  gamma_ = gamma;
85  minusFactor = -tau_ * (1.0 - alpha_ * (1.0 + gamma_));
86  int v_tmove = TMOVE_OFF;
87 
88  if (non_local_move_option == "no")
89  v_tmove = TMOVE_OFF;
90  else if (non_local_move_option == "yes" || non_local_move_option == "v0")
91  v_tmove = TMOVE_V0;
92  else if (non_local_move_option == "v1")
93  v_tmove = TMOVE_V1;
94  else if (non_local_move_option == "v3")
95  v_tmove = TMOVE_V3;
96  else
97  throw std::runtime_error("NonLocalTOperator::put unknown nonlocalmove option " + non_local_move_option);
98  return v_tmove;
99 }
RealType plusFactor
factor applied on >0 weight
RealType minusFactor
factor applied on <=0 weight

Member Data Documentation

◆ alpha_

◆ gamma_

◆ minusFactor

RealType minusFactor
private

◆ plusFactor

RealType plusFactor
private

◆ tau_

◆ txy_by_elec_

std::vector<std::vector<NonLocalData> > txy_by_elec_
private

◆ txy_scan_

std::vector<RealType> txy_scan_
private

Definition at line 80 of file NonLocalTOperator.h.

Referenced by NonLocalTOperator::selectMove().


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