QMCPACK
Pade2ndOrderFunctor< T > Struct Template Reference

Pade function of

\[ u(r) = \frac{a*r+c*r^2}{1+b*r} \]

. More...

+ Inheritance diagram for Pade2ndOrderFunctor< T >:
+ Collaboration diagram for Pade2ndOrderFunctor< T >:

Public Member Functions

 Pade2ndOrderFunctor (const std::string &my_name, real_type a=1.0, real_type b=1.0, real_type c=1.0)
 constructor More...
 
OptimizableFunctorBasemakeClone () const override
 create a clone of this object More...
 
void reset () override
 reset the internal variables. More...
 
real_type evaluate (real_type r) const
 
real_type evaluate (real_type r, real_type &dudr, real_type &d2udr2) const
 evaluate the value at r More...
 
real_type evaluate (real_type r, real_type &dudr, real_type &d2udr2, real_type &d3udr3) const
 
real_type evaluateV (const int iat, const int iStart, const int iEnd, const T *restrict _distArray, T *restrict distArrayCompressed) const
 
void evaluateVGL (const int iat, const int iStart, const int iEnd, const T *distArray, T *restrict valArray, T *restrict gradArray, T *restrict laplArray, T *restrict distArrayCompressed, int *restrict distIndices) const
 
real_type f (real_type r) override
 evaluate the value at r More...
 
real_type df (real_type r) override
 evaluate the first derivative More...
 
bool evaluateDerivatives (real_type r, std::vector< TinyVector< real_type, 3 >> &derivs) override
 
bool evaluateDerivatives (real_type r, std::vector< real_type > &derivs) override
 
bool put (xmlNodePtr cur) override
 process input xml node More...
 
void checkInVariablesExclusive (opt_variables_type &active) override
 check in variational parameters to the global list of parameters used by the optimizer. More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out variational optimizable variables More...
 
void resetParametersExclusive (const opt_variables_type &active) override
 reset the parameters during optimizations. More...
 
- Public Member Functions inherited from OptimizableFunctorBase
 OptimizableFunctorBase (const std::string &name="")
 default constructor More...
 
virtual ~OptimizableFunctorBase ()=default
 virtual destrutor More...
 
void getIndex (const opt_variables_type &active)
 
virtual void setDensity (real_type n)
 empty virtual function to help builder classes More...
 
virtual void setCusp (real_type cusp)
 empty virtual function to help builder classes More...
 
virtual void setPeriodic (bool periodic)
 empty virtual function to help builder classes More...
 
virtual void setGridManager (bool willmanage)
 
virtual void checkInVariablesExclusive (opt_variables_type &active)=0
 check in variational parameters to the global list of parameters used by the optimizer. More...
 
virtual void resetParametersExclusive (const opt_variables_type &active)=0
 reset the parameters during optimizations More...
 
- Public Member Functions inherited from OptimizableObject
 OptimizableObject (const std::string &name)
 
const std::string & getName () const
 
bool isOptimized () const
 
virtual void reportStatus (std::ostream &os)
 print the state, e.g., optimizables More...
 
void setOptimization (bool state)
 
virtual void writeVariationalParameters (hdf_archive &hout)
 Write the variational parameters for this object to the VP HDF file. More...
 
virtual void readVariationalParameters (hdf_archive &hin)
 Read the variational parameters for this object from the VP HDF file. More...
 

Static Public Member Functions

static void mw_evaluateV (const int num_groups, const Pade2ndOrderFunctor *const functors[], const int n_src, const int *grp_ids, const int num_pairs, const int *ref_at, const T *mw_dist, const int dist_stride, T *mw_vals, Vector< char, OffloadPinnedAllocator< char >> &transfer_buffer)
 evaluate sum of the pair potentials FIXME More...
 

Public Attributes

real_type A
 coefficients More...
 
real_type B
 
real_type C
 
real_type C2
 
bool Opt_A
 
bool Opt_B
 
bool Opt_C
 
std::string ID_A
 id for A More...
 
std::string ID_B
 id for B More...
 
std::string ID_C
 id for C More...
 
- Public Attributes inherited from OptimizableFunctorBase
real_type cutoff_radius = 0.0
 maximum cutoff More...
 
opt_variables_type myVars
 set of variables to be optimized More...
 

Additional Inherited Members

- Public Types inherited from OptimizableFunctorBase
using real_type = optimize::VariableSet::real_type
 typedef for real values More...
 
using opt_variables_type = optimize::VariableSet
 typedef for variableset: this is going to be replaced More...
 

Detailed Description

template<class T>
struct qmcplusplus::Pade2ndOrderFunctor< T >

Pade function of

\[ u(r) = \frac{a*r+c*r^2}{1+b*r} \]

.

Prototype of the template parameter of TwoBodyJastrow and OneBodyJastrow

Definition at line 324 of file PadeFunctors.h.

Constructor & Destructor Documentation

◆ Pade2ndOrderFunctor()

Pade2ndOrderFunctor ( const std::string &  my_name,
real_type  a = 1.0,
real_type  b = 1.0,
real_type  c = 1.0 
)
inline

constructor

Definition at line 337 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::reset().

Referenced by Pade2ndOrderFunctor< T >::makeClone().

338  : OptimizableFunctorBase(my_name), A(a), B(b), C(c), ID_A("0"), ID_B("0"), ID_C("0")
339  {
340  reset();
341  }
real_type A
coefficients
Definition: PadeFunctors.h:327
OptimizableFunctorBase(const std::string &name="")
default constructor
void reset() override
reset the internal variables.
Definition: PadeFunctors.h:347

Member Function Documentation

◆ checkInVariablesExclusive()

void checkInVariablesExclusive ( opt_variables_type active)
inlineoverridevirtual

check in variational parameters to the global list of parameters used by the optimizer.

Parameters
activea super set of optimizable variables

The existing checkInVariables implementation in WFC/SPO/.. are inclusive and it calls checkInVariables of its members class A: public SPOSet {} class B: public WFC { A objA; checkInVariables() { objA.checkInVariables(); } };

With OptimizableObject, class A: public OptimizableObject {} class B: public OptimizableObject { A objA; checkInVariablesExclusive() { // should not call objA.checkInVariablesExclusive() if objA has been extracted; } }; A vector of OptimizableObject, will be created by calling extractOptimizableObjects(). All the checkInVariablesExclusive() will be called through this vector and thus checkInVariablesExclusive implementation should only handle non-OptimizableObject members.

Implements OptimizableObject.

Definition at line 591 of file PadeFunctors.h.

References VariableSet::insertFrom(), and OptimizableFunctorBase::myVars.

591 { active.insertFrom(myVars); }
opt_variables_type myVars
set of variables to be optimized

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
inlineoverridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Implements OptimizableFunctorBase.

Definition at line 593 of file PadeFunctors.h.

References VariableSet::getIndex(), and OptimizableFunctorBase::myVars.

593 { myVars.getIndex(active); }
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
opt_variables_type myVars
set of variables to be optimized

◆ df()

real_type df ( real_type  r)
inlineoverridevirtual

evaluate the first derivative

Parameters
rdistance

virtual function necessary for a transformation to a numerical functor

Implements OptimizableFunctorBase.

Definition at line 452 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::evaluate().

453  {
454  real_type dudr, d2udr2;
455  real_type res = evaluate(r, dudr, d2udr2);
456  return dudr;
457  }
real_type evaluate(real_type r) const
Definition: PadeFunctors.h:357
OHMMS_PRECISION real_type

◆ evaluate() [1/3]

real_type evaluate ( real_type  r) const
inline
Parameters
rthe distance
Returns
$ u(r) = \frac{a*r+c*r^2}{1+b*r} $

Definition at line 357 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::A, Pade2ndOrderFunctor< T >::B, and Pade2ndOrderFunctor< T >::C.

Referenced by Pade2ndOrderFunctor< T >::df(), Pade2ndOrderFunctor< T >::evaluateV(), Pade2ndOrderFunctor< T >::evaluateVGL(), Pade2ndOrderFunctor< T >::f(), and qmcplusplus::TEST_CASE().

358  {
359  real_type u = 1.0 / (1.0 + B * r);
360  real_type v = A * r + C * r * r;
361  return u * v;
362  }
real_type A
coefficients
Definition: PadeFunctors.h:327
OHMMS_PRECISION real_type

◆ evaluate() [2/3]

real_type evaluate ( real_type  r,
real_type dudr,
real_type d2udr2 
) const
inline

evaluate the value at r

Parameters
rthe distance
dudrreturn value $ du/dr = a/(1+br)^2 $
d2udr2return value $ d^2u/dr^2 = -2ab/(1+br)^3 $
Returns
$ u(r) = \frac{a*r+c*r^2}{1+b*r} $

Definition at line 370 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::A, Pade2ndOrderFunctor< T >::B, Pade2ndOrderFunctor< T >::C, and Pade2ndOrderFunctor< T >::C2.

371  {
372  real_type u = 1.0 / (1.0 + B * r);
373  real_type v = A * r + C * r * r;
374  real_type w = A + C2 * r;
375  dudr = u * (w - B * u * v);
376  d2udr2 = 2.0 * u * u * u * (C - B * A);
377  return u * v;
378  }
real_type A
coefficients
Definition: PadeFunctors.h:327
OHMMS_PRECISION real_type

◆ evaluate() [3/3]

real_type evaluate ( real_type  r,
real_type dudr,
real_type d2udr2,
real_type d3udr3 
) const
inline

Definition at line 380 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::A, Pade2ndOrderFunctor< T >::B, Pade2ndOrderFunctor< T >::C, and Pade2ndOrderFunctor< T >::C2.

381  {
382  real_type u = 1.0 / (1.0 + B * r);
383  real_type v = A * r + C * r * r;
384  real_type w = A + C2 * r;
385  dudr = u * (w - B * u * v);
386  d2udr2 = 2.0 * u * u * u * (C - B * A);
387  std::cerr << "Third derivative not imlemented for Pade functor.\n";
388  return u * v;
389  }
real_type A
coefficients
Definition: PadeFunctors.h:327
OHMMS_PRECISION real_type

◆ evaluateDerivatives() [1/2]

bool evaluateDerivatives ( real_type  r,
std::vector< TinyVector< real_type, 3 >> &  derivs 
)
inlineoverridevirtual

Reimplemented from OptimizableFunctorBase.

Definition at line 459 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::A, Pade2ndOrderFunctor< T >::B, Pade2ndOrderFunctor< T >::C, Pade2ndOrderFunctor< T >::Opt_A, Pade2ndOrderFunctor< T >::Opt_B, and Pade2ndOrderFunctor< T >::Opt_C.

460  {
461  real_type u = 1.0 / (1.0 + B * r);
462  real_type u2 = u * u;
463  real_type u3 = u * u * u;
464  real_type u4 = u * u * u * u;
465  int i = 0;
466  if (Opt_A)
467  {
468  derivs[i][0] = r * u;
469  derivs[i][1] = u2;
470  derivs[i][2] = -2.0 * B * u3;
471  i++;
472  }
473 
474  if (Opt_B)
475  {
476  derivs[i][0] = -r * r * (A + C * r) * u2;
477  derivs[i][1] = -r * (2.0 * A + C * r * (3.0 + B * r)) * u3;
478  derivs[i][2] = -2.0 * u4 * (A - 2.0 * A * B * r + 3.0 * C * r);
479  i++;
480  }
481 
482  if (Opt_C)
483  {
484  derivs[i][0] = r * r * u;
485  derivs[i][1] = r * (2.0 + B * r) * u2;
486  derivs[i][2] = 2.0 * u3;
487  i++;
488  }
489  return true;
490  }
real_type A
coefficients
Definition: PadeFunctors.h:327
OHMMS_PRECISION real_type

◆ evaluateDerivatives() [2/2]

bool evaluateDerivatives ( real_type  r,
std::vector< real_type > &  derivs 
)
inlineoverridevirtual

Reimplemented from OptimizableFunctorBase.

Definition at line 493 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::A, Pade2ndOrderFunctor< T >::B, Pade2ndOrderFunctor< T >::C, Pade2ndOrderFunctor< T >::Opt_A, Pade2ndOrderFunctor< T >::Opt_B, and Pade2ndOrderFunctor< T >::Opt_C.

494  {
495  real_type u = 1.0 / (1.0 + B * r);
496  int i = 0;
497  if (Opt_A)
498  {
499  derivs[i] = r * u;
500  i++;
501  }
502  if (Opt_B)
503  {
504  derivs[i] = -r * r * (A + C * r) * u * u;
505  i++;
506  }
507  if (Opt_C)
508  {
509  derivs[i] = r * r * u;
510  i++;
511  }
512  return true;
513  }
real_type A
coefficients
Definition: PadeFunctors.h:327
OHMMS_PRECISION real_type

◆ evaluateV()

real_type evaluateV ( const int  iat,
const int  iStart,
const int  iEnd,
const T *restrict  _distArray,
T *restrict  distArrayCompressed 
) const
inline

Definition at line 391 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::evaluate().

396  {
397  real_type sum(0);
398  for (int idx = iStart; idx < iEnd; idx++)
399  if (idx != iat)
400  sum += evaluate(_distArray[idx]);
401  return sum;
402  }
real_type evaluate(real_type r) const
Definition: PadeFunctors.h:357
OHMMS_PRECISION real_type

◆ evaluateVGL()

void evaluateVGL ( const int  iat,
const int  iStart,
const int  iEnd,
const T *  distArray,
T *restrict  valArray,
T *restrict  gradArray,
T *restrict  laplArray,
T *restrict  distArrayCompressed,
int *restrict  distIndices 
) const
inline

Definition at line 431 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::evaluate().

440  {
441  for (int idx = iStart; idx < iEnd; idx++)
442  {
443  valArray[idx] = evaluate(distArray[idx], gradArray[idx], laplArray[idx]);
444  gradArray[idx] /= distArray[idx];
445  }
446  if (iat >= iStart && iat < iEnd)
447  valArray[iat] = gradArray[iat] = laplArray[iat] = T(0);
448  }
real_type evaluate(real_type r) const
Definition: PadeFunctors.h:357

◆ f()

real_type f ( real_type  r)
inlineoverridevirtual

evaluate the value at r

Parameters
rdistance

virtual function necessary for a transformation to a numerical functor

Implements OptimizableFunctorBase.

Definition at line 450 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::evaluate().

450 { return evaluate(r); }
real_type evaluate(real_type r) const
Definition: PadeFunctors.h:357

◆ makeClone()

OptimizableFunctorBase* makeClone ( ) const
inlineoverridevirtual

create a clone of this object

Implements OptimizableFunctorBase.

Definition at line 343 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::Pade2ndOrderFunctor().

343 { return new Pade2ndOrderFunctor(*this); }
Pade2ndOrderFunctor(const std::string &my_name, real_type a=1.0, real_type b=1.0, real_type c=1.0)
constructor
Definition: PadeFunctors.h:337

◆ mw_evaluateV()

static void mw_evaluateV ( const int  num_groups,
const Pade2ndOrderFunctor< T > *const  functors[],
const int  n_src,
const int *  grp_ids,
const int  num_pairs,
const int *  ref_at,
const T *  mw_dist,
const int  dist_stride,
T *  mw_vals,
Vector< char, OffloadPinnedAllocator< char >> &  transfer_buffer 
)
inlinestatic

evaluate sum of the pair potentials FIXME

Returns
$\sum u(r_j)$ for r_j < cutoff_radius

Definition at line 407 of file PadeFunctors.h.

417  {
418  for (int ip = 0; ip < num_pairs; ip++)
419  {
420  mw_vals[ip] = 0;
421  for (int j = 0; j < n_src; j++)
422  {
423  const int ig = grp_ids[j];
424  auto& functor(*functors[ig]);
425  if (j != ref_at[ip])
426  mw_vals[ip] += functor.evaluate(mw_dist[ip * dist_stride + j]);
427  }
428  }
429  }

◆ put()

bool put ( xmlNodePtr  cur)
inlineoverridevirtual

process input xml node

Parameters
curcurrent xmlNode from which the data members are reset

Read in the Pade parameters from the xml input file.

Implements OptimizableFunctorBase.

Definition at line 521 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::A, OhmmsAttributeSet::add(), qmcplusplus::app_log(), Pade2ndOrderFunctor< T >::B, Pade2ndOrderFunctor< T >::C, VariableSet::clear(), Pade2ndOrderFunctor< T >::ID_A, Pade2ndOrderFunctor< T >::ID_B, Pade2ndOrderFunctor< T >::ID_C, VariableSet::insert(), optimize::LOGLINEAR_P, OptimizableFunctorBase::myVars, Pade2ndOrderFunctor< T >::Opt_A, Pade2ndOrderFunctor< T >::Opt_B, Pade2ndOrderFunctor< T >::Opt_C, optimize::OTHER_P, VariableSet::print(), OhmmsAttributeSet::put(), putContent(), and Pade2ndOrderFunctor< T >::reset().

522  {
523  real_type Atemp, Btemp, Ctemp;
524  //jastrow[iab]->put(cur->xmlChildrenNode,wfs_ref.RealVars);
525  xmlNodePtr tcur = cur->xmlChildrenNode;
526  bool renewed = false;
527  while (tcur != NULL)
528  {
529  std::string cname((const char*)(tcur->name));
530  if (cname == "parameter")
531  {
532  throw std::runtime_error(
533  "Keyword 'parameter' has been replaced by 'var' in the 'correlation' of pade2 Jastrow!");
534  }
535  else if (cname == "var" || cname == "Var")
536  {
537  std::string doopt("yes");
538  std::string id_in("0");
539  std::string p_name("B");
540  OhmmsAttributeSet rAttrib;
541  rAttrib.add(id_in, "id");
542  rAttrib.add(p_name, "name");
543  rAttrib.add(doopt, "optimize");
544  rAttrib.put(tcur);
545  if (p_name == "A")
546  {
547  ID_A = id_in;
548  Opt_A = (doopt != "no");
549  putContent(Atemp, tcur);
550  renewed = true;
551  }
552  else if (p_name == "B")
553  {
554  ID_B = id_in;
555  Opt_B = (doopt != "no");
556  putContent(Btemp, tcur);
557  renewed = true;
558  }
559  else if (p_name == "C")
560  {
561  ID_C = id_in;
562  Opt_C = (doopt != "no");
563  putContent(Ctemp, tcur);
564  renewed = true;
565  }
566  }
567  tcur = tcur->next;
568  }
569  if (renewed)
570  {
571  A = Atemp;
572  B = Btemp;
573  C = Ctemp;
574  reset();
575  //these are always active
576  myVars.clear();
577  if (Opt_A)
579  if (Opt_B)
581  if (Opt_C)
583  }
584  int left_pad_space = 5;
585  app_log() << std::endl;
586  myVars.print(app_log(), left_pad_space, true);
587  //LOGMSG("Jastrow (A*r+C*r*r)/(1+Br) = (" << A << "," << B << "," << C << ")")
588  return true;
589  }
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
real_type A
coefficients
Definition: PadeFunctors.h:327
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
Definition: VariableSet.h:133
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
void clear()
clear the variable set
Definition: VariableSet.cpp:28
bool putContent(T &a, xmlNodePtr cur)
replaces a&#39;s value with the first "element" in the "string" returned by XMLNodeString{cur}.
Definition: libxmldefs.h:88
OHMMS_PRECISION real_type
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
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const
opt_variables_type myVars
set of variables to be optimized
void reset() override
reset the internal variables.
Definition: PadeFunctors.h:347

◆ reset()

void reset ( )
inlineoverridevirtual

reset the internal variables.

Implements OptimizableFunctorBase.

Definition at line 347 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::C, Pade2ndOrderFunctor< T >::C2, and OptimizableFunctorBase::cutoff_radius.

Referenced by Pade2ndOrderFunctor< T >::Pade2ndOrderFunctor(), Pade2ndOrderFunctor< T >::put(), and qmcplusplus::TEST_CASE().

348  {
349  // A = a; B=b; C = c;
350  cutoff_radius = 1.0e4; //some big range
351  C2 = 2.0 * C;
352  }

◆ resetParametersExclusive()

void resetParametersExclusive ( const opt_variables_type active)
inlineoverridevirtual

reset the parameters during optimizations.

Exclusive, see checkInVariablesExclusive

Implements OptimizableObject.

Definition at line 594 of file PadeFunctors.h.

References Pade2ndOrderFunctor< T >::A, Pade2ndOrderFunctor< T >::B, Pade2ndOrderFunctor< T >::C, Pade2ndOrderFunctor< T >::C2, Pade2ndOrderFunctor< T >::ID_A, Pade2ndOrderFunctor< T >::ID_B, Pade2ndOrderFunctor< T >::ID_C, OptimizableFunctorBase::myVars, and VariableSet::where().

595  {
596  int i = 0;
597  if (ID_A != "0")
598  {
599  int ia = myVars.where(i);
600  if (ia > -1)
601  A = std::real(myVars[i] = active[ia]);
602  i++;
603  }
604  if (ID_B != "0")
605  {
606  int ib = myVars.where(i);
607  if (ib > -1)
608  B = std::real(myVars[i] = active[ib]);
609  i++;
610  }
611  if (ID_C != "0")
612  {
613  int ic = myVars.where(i);
614  if (ic > -1)
615  C = std::real(myVars[i] = active[ic]);
616  i++;
617  }
618  C2 = 2.0 * C;
619  }
QMCTraits::RealType real
real_type A
coefficients
Definition: PadeFunctors.h:327
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
opt_variables_type myVars
set of variables to be optimized

Member Data Documentation

◆ A

◆ B

◆ C

◆ C2

◆ ID_A

std::string ID_A

◆ ID_B

std::string ID_B

◆ ID_C

std::string ID_C

◆ Opt_A

bool Opt_A

◆ Opt_B

bool Opt_B

◆ Opt_C

bool Opt_C

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