QMCPACK
PadeTwo2ndOrderFunctor< T > Struct Template Reference

Pade function of

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

. More...

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

Public Member Functions

 PadeTwo2ndOrderFunctor (real_type a=1.0, real_type b=1.0, real_type c=1.0, real_type d=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)
 
real_type evaluate (real_type r, real_type &dudr, real_type &d2udr2)
 
real_type evaluate (real_type r, real_type &dudr, real_type &d2udr2, real_type &d3udr3)
 
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)
 
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...
 

Public Attributes

real_type A
 coefficients More...
 
real_type B
 
real_type C
 
real_type D
 
bool Opt_A
 
bool Opt_B
 
bool Opt_C
 
bool Opt_D
 
std::string ID_A
 id for A More...
 
std::string ID_B
 id for B More...
 
std::string ID_C
 id for C More...
 
std::string ID_D
 id for D 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::PadeTwo2ndOrderFunctor< T >

Pade function of

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

.

Prototype of the template parameter of TwoBodyJastrow and OneBodyJastrow

Definition at line 627 of file PadeFunctors.h.

Constructor & Destructor Documentation

◆ PadeTwo2ndOrderFunctor()

PadeTwo2ndOrderFunctor ( real_type  a = 1.0,
real_type  b = 1.0,
real_type  c = 1.0,
real_type  d = 1.0 
)
inline

constructor

Definition at line 642 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::reset().

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

643  : A(a),
644  B(b),
645  C(c),
646  D(d),
647  Opt_A(false),
648  Opt_B(false),
649  Opt_C(false),
650  Opt_D(false),
651  ID_A("0"),
652  ID_B("0"),
653  ID_C("0"),
654  ID_D("0")
655  {
656  reset();
657  }
void reset() override
reset the internal variables.
Definition: PadeFunctors.h:663

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 916 of file PadeFunctors.h.

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

916 { 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 918 of file PadeFunctors.h.

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

918 { 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 728 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::evaluate().

729  {
730  real_type dudr, d2udr2;
731  real_type res = evaluate(r, dudr, d2udr2);
732  return dudr;
733  }
real_type evaluate(real_type r)
Definition: PadeFunctors.h:668
OHMMS_PRECISION real_type

◆ evaluate() [1/3]

◆ evaluate() [2/3]

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

Definition at line 675 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::A, PadeTwo2ndOrderFunctor< T >::B, PadeTwo2ndOrderFunctor< T >::C, and PadeTwo2ndOrderFunctor< T >::D.

676  {
677  real_type ar(A * r);
678  real_type br(B * r);
679  real_type cr(C * r);
680  real_type dr(D * r);
681  real_type bttm(1.0 / (1.0 + C * cr + dr * dr));
682  dudr = (A - A * dr * dr + br * (2.0 + C * cr)) * bttm * bttm;
683  d2udr2 = -2.0 * (A * (C * C + 3.0 * dr * D - dr * dr * dr * D) + B * (-1.0 + dr * dr * (3.0 + C * cr))) * bttm *
684  bttm * bttm;
685  return (A * r + br * r) * bttm;
686  }
OHMMS_PRECISION real_type

◆ evaluate() [3/3]

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

Definition at line 688 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::evaluate().

689  {
690  d3udr3 = 0;
691  return evaluate(r, dudr, d2udr2);
692  }
real_type evaluate(real_type r)
Definition: PadeFunctors.h:668

◆ evaluateDerivatives() [1/2]

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

Reimplemented from OptimizableFunctorBase.

Definition at line 735 of file PadeFunctors.h.

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

736  {
737  real_type ar(A * r);
738  real_type br(B * r);
739  real_type cr(C * r);
740  real_type dr(D * r);
741  real_type r2(r * r);
742  real_type dr2(D * r2);
743  real_type d2r2(dr * dr);
744  real_type c2(C * C);
745  real_type c2r(c2 * r);
746  real_type bttm(1.0 / (1.0 + c2r + d2r2));
747  real_type tp(A * r + br * r);
748  real_type c2r2(cr * cr);
749  real_type d4r4(d2r2 * d2r2);
750  real_type bttm2(bttm * bttm);
751  real_type bttm3(bttm * bttm2);
752  real_type bttm4(bttm2 * bttm2);
753  int i = 0;
754  if (Opt_A)
755  {
756  derivs[i][0] = r2 * bttm;
757  derivs[i][1] = r * (2.0 + c2r) * bttm2;
758  derivs[i][2] = (2.0 - 2.0 * d2r2 * (3.0 + c2r)) * bttm3;
759  i++;
760  }
761 
762  if (Opt_B)
763  {
764  derivs[i][0] = -2.0 * cr * tp * bttm2;
765  derivs[i][1] = -2 * cr * (A * (2.0 - 2.0 * d2r2) + br * (3.0 + c2r - d2r2)) * bttm3;
766  derivs[i][2] = 4.0 * C *
767  (A * (-1.0 + 2.0 * c2r + 8.0 * d2r2 - 3.0 * d4r4) + br * (-3.0 - d4r4 + 2.0 * d2r2 * (4.0 + c2r))) * bttm4;
768  i++;
769  }
770 
771  if (Opt_C)
772  {
773  derivs[i][0] = -2.0 * dr2 * tp * bttm2;
774  derivs[i][1] = -2.0 * dr2 * (2.0 * br * (2.0 + c2r) + A * (3.0 + c2r - d2r2)) * bttm3;
775  derivs[i][2] = -4.0 * dr *
776  (br * (6.0 + 4.0 * c2r + c2 * c2r2 - 6.0 * d2r2 - 2.0 * c2r * d2r2) +
777  A * (3.0 + d4r4 - 2.0 * d2r2 * (4.0 + c2r))) *
778  bttm4;
779  i++;
780  }
781  return true;
782  }
OHMMS_PRECISION real_type

◆ evaluateDerivatives() [2/2]

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

Reimplemented from OptimizableFunctorBase.

Definition at line 785 of file PadeFunctors.h.

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

786  {
787  real_type ar(A * r);
788  real_type br(B * r);
789  real_type cr(C * r);
790  real_type dr(D * r);
791  real_type r2(r * r);
792  real_type dr2(D * r2);
793  real_type d2r2(dr * dr);
794  real_type c2(C * C);
795  real_type c2r(c2 * r);
796  real_type bttm(1.0 / (1.0 + c2r + d2r2));
797  real_type tp(A * r + br * r);
798  real_type c2r2(cr * cr);
799  real_type d4r4(d2r2 * d2r2);
800  real_type bttm2(bttm * bttm);
801  int i = 0;
802  if (Opt_A)
803  {
804  derivs[i] = r2 * bttm;
805  i++;
806  }
807 
808  if (Opt_B)
809  {
810  derivs[i] = -2.0 * cr * tp * bttm2;
811  i++;
812  }
813 
814  if (Opt_C)
815  {
816  derivs[i] = -2.0 * dr2 * tp * bttm2;
817  i++;
818  }
819  return true;
820  }
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 694 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::evaluate().

699  {
700  real_type sum(0);
701  for (int idx = iStart; idx < iEnd; idx++)
702  if (idx != iat)
703  sum += evaluate(_distArray[idx]);
704  return sum;
705  }
real_type evaluate(real_type r)
Definition: PadeFunctors.h:668
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 707 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::evaluate().

716  {
717  for (int idx = iStart; idx < iEnd; idx++)
718  {
719  valArray[idx] = evaluate(distArray[idx], gradArray[idx], laplArray[idx]);
720  gradArray[idx] /= distArray[idx];
721  }
722  if (iat >= iStart && iat < iEnd)
723  valArray[iat] = gradArray[iat] = laplArray[iat] = T(0);
724  }
real_type evaluate(real_type r)
Definition: PadeFunctors.h:668

◆ 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 726 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::evaluate().

726 { return evaluate(r); }
real_type evaluate(real_type r)
Definition: PadeFunctors.h:668

◆ makeClone()

OptimizableFunctorBase* makeClone ( ) const
inlineoverridevirtual

create a clone of this object

Implements OptimizableFunctorBase.

Definition at line 659 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::PadeTwo2ndOrderFunctor().

659 { return new PadeTwo2ndOrderFunctor(*this); }
PadeTwo2ndOrderFunctor(real_type a=1.0, real_type b=1.0, real_type c=1.0, real_type d=1.0)
constructor
Definition: PadeFunctors.h:642

◆ 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 828 of file PadeFunctors.h.

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

829  {
830  std::string fcup("yes");
832  p.add(fcup, "fixcusp");
833  p.put(cur);
834  if (fcup == "true")
835  fcup = "yes";
836  // if (fcup=="yes") app_log()<<" fixing cusp conditions"<< std::endl;
837  real_type Atemp = A, Btemp = B, Ctemp = C, Dtemp = D;
838  //jastrow[iab]->put(cur->xmlChildrenNode,wfs_ref.RealVars);
839  xmlNodePtr tcur = cur->xmlChildrenNode;
840  bool renewed = false;
841  while (tcur != NULL)
842  {
843  std::string cname((const char*)(tcur->name));
844  if (cname == "parameter")
845  {
846  throw std::runtime_error(
847  "Keyword 'parameter' has been replaced by 'var' in the 'correlation' of pade2 Jastrow!");
848  }
849  else if (cname == "var" || cname == "Var")
850  {
851  std::string id_in("0");
852  std::string p_name("B");
853  std::string doopt("yes");
854  OhmmsAttributeSet rAttrib;
855  rAttrib.add(id_in, "id");
856  rAttrib.add(p_name, "name");
857  rAttrib.add(doopt, "optimize");
858  rAttrib.put(tcur);
859  if (p_name == "A")
860  {
861  ID_A = id_in;
862  Opt_A = (doopt != "no");
863  putContent(Atemp, tcur);
864  renewed = true;
865  }
866  else if (p_name == "B")
867  {
868  ID_B = id_in;
869  Opt_B = (doopt != "no");
870  putContent(Btemp, tcur);
871  renewed = true;
872  }
873  else if (p_name == "C")
874  {
875  ID_C = id_in;
876  Opt_C = (doopt != "no");
877  putContent(Ctemp, tcur);
878  renewed = true;
879  }
880  else if (p_name == "D")
881  {
882  ID_D = id_in;
883  Opt_D = (doopt != "no");
884  putContent(Dtemp, tcur);
885  renewed = true;
886  }
887  }
888  tcur = tcur->next;
889  }
890  if (renewed)
891  {
892  A = Atemp;
893  B = Btemp;
894  C = Ctemp;
895  D = Dtemp;
896  reset();
897  //these are always active
898  myVars.clear();
899  if (Opt_A)
901  if (Opt_B)
903  if (Opt_C)
905  if (Opt_D)
907  //myVars.insert(ID_A,A,fcup!="yes");
908  }
909  int left_pad_space = 5;
910  app_log() << std::endl;
911  myVars.print(app_log(), left_pad_space, true);
912  //LOGMSG("Jastrow (A*r+C*r*r)/(1+Br) = (" << A << "," << B << "," << C << ")")
913  return true;
914  }
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
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 reset() override
reset the internal variables.
Definition: PadeFunctors.h:663
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

◆ reset()

void reset ( )
inlineoverridevirtual

reset the internal variables.

Implements OptimizableFunctorBase.

Definition at line 663 of file PadeFunctors.h.

Referenced by PadeTwo2ndOrderFunctor< T >::PadeTwo2ndOrderFunctor(), PadeTwo2ndOrderFunctor< T >::put(), and PadeTwo2ndOrderFunctor< T >::resetParametersExclusive().

664  {
665  // A = a; B=b; C = c;
666  }

◆ resetParametersExclusive()

void resetParametersExclusive ( const opt_variables_type active)
inlineoverridevirtual

reset the parameters during optimizations.

Exclusive, see checkInVariablesExclusive

Implements OptimizableObject.

Definition at line 919 of file PadeFunctors.h.

References PadeTwo2ndOrderFunctor< T >::A, PadeTwo2ndOrderFunctor< T >::B, PadeTwo2ndOrderFunctor< T >::C, PadeTwo2ndOrderFunctor< T >::D, OptimizableFunctorBase::myVars, PadeTwo2ndOrderFunctor< T >::Opt_A, PadeTwo2ndOrderFunctor< T >::Opt_B, PadeTwo2ndOrderFunctor< T >::Opt_C, PadeTwo2ndOrderFunctor< T >::Opt_D, PadeTwo2ndOrderFunctor< T >::reset(), VariableSet::size(), and VariableSet::where().

920  {
921  if (myVars.size() == 0)
922  return;
923 
924  int ia = myVars.where(0);
925  if (ia < 0)
926  return;
927 
928  int i = 0;
929  if (Opt_A)
930  A = std::real(myVars[i++] = active[ia++]);
931  if (Opt_B)
932  B = std::real(myVars[i++] = active[ia++]);
933  if (Opt_C)
934  C = std::real(myVars[i++] = active[ia++]);
935  if (Opt_D)
936  D = std::real(myVars[i++] = active[ia++]);
937 
938  reset();
939  }
QMCTraits::RealType real
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
void reset() override
reset the internal variables.
Definition: PadeFunctors.h:663
opt_variables_type myVars
set of variables to be optimized

Member Data Documentation

◆ A

◆ B

◆ C

◆ D

◆ ID_A

std::string ID_A

id for A

Definition at line 633 of file PadeFunctors.h.

Referenced by PadeTwo2ndOrderFunctor< T >::put().

◆ ID_B

std::string ID_B

id for B

Definition at line 635 of file PadeFunctors.h.

Referenced by PadeTwo2ndOrderFunctor< T >::put().

◆ ID_C

std::string ID_C

id for C

Definition at line 637 of file PadeFunctors.h.

Referenced by PadeTwo2ndOrderFunctor< T >::put().

◆ ID_D

std::string ID_D

id for D

Definition at line 639 of file PadeFunctors.h.

Referenced by PadeTwo2ndOrderFunctor< T >::put().

◆ Opt_A

◆ Opt_B

◆ Opt_C

◆ Opt_D


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