29 #ifndef QMCPLUSPLUS_USERFUNCTOR_H 30 #define QMCPLUSPLUS_USERFUNCTOR_H 92 dudr = -
A *
B * r / ((
B * r + 1) * (
B * r + 1)) +
A / (
B * r + 1);
93 d2udr2 = 2 *
A *
B * (
B * r / (
B * r + 1) - 1) / ((
B * r + 1) * (
B * r + 1));
94 return A * r / (
B * r + 1) -
A /
B;
102 dudr = -
A *
B * r / ((
B * r + 1) * (
B * r + 1)) +
A / (
B * r + 1);
103 d2udr2 = 2 *
A *
B * (
B * r / (
B * r + 1) - 1) / ((
B * r + 1) * (
B * r + 1));
104 d3udr3 = 6 *
A * ((
B) * (
B)) * (-
B * r / (
B * r + 1) + 1) /
std::pow(
B * r + 1, 3);
105 return A * r / (
B * r + 1) -
A /
B;
112 const T* restrict _distArray,
113 T* restrict distArrayCompressed)
const 117 for (
int idx = iStart; idx < iEnd; idx++)
133 const int dist_stride,
137 for (
int ip = 0; ip < num_pairs; ip++)
140 for (
int j = 0; j < n_src; j++)
142 const int ig = grp_ids[j];
143 auto& functor(*functors[ig]);
145 mw_vals[ip] += functor.evaluate(mw_dist[ip * dist_stride + j]);
154 T* restrict valArray,
155 T* restrict gradArray,
156 T* restrict laplArray,
157 T* restrict distArrayCompressed,
158 int* restrict distIndices)
const 161 for (
int idx = iStart; idx < iEnd; idx++)
163 valArray[idx] =
evaluate(distArray[idx], gradArray[idx], laplArray[idx]);
164 gradArray[idx] /= distArray[idx];
166 if (iat >= iStart && iat < iEnd)
167 valArray[iat] = gradArray[iat] = laplArray[iat] = T(0);
171 const int num_groups,
182 throw std::runtime_error(
"UserFunctor mw_evaluateVGL not implemented!");
195 const std::vector<bool>& isAccepted,
196 const int num_groups,
208 throw std::runtime_error(
"UserFunctor mw_updateVGL not implemented!");
219 derivs[i][0] = r / (
B * r + 1) - 1 /
B;
220 derivs[i][1] = -
B * r / ((
B * r + 1) * (
B * r + 1)) + 1.0 / (
B * r + 1);
221 derivs[i][2] = 2 *
B * (
B * r / (
B * r + 1) - 1) / ((
B * r + 1) * (
B * r + 1));
227 derivs[i][0] = -
A * ((r) * (r)) / ((
B * r + 1) * (
B * r + 1)) +
A / ((
B) * (
B));
228 derivs[i][1] = 2 *
A *
B * ((r) * (r)) /
std::pow(
B * r + 1, 3) - 2 *
A * r / ((
B * r + 1) * (
B * r + 1));
229 derivs[i][2] = -4 *
A *
B * r * (
B * r / (
B * r + 1) - 1) /
std::pow(
B * r + 1, 3) +
230 2 *
A *
B * (-
B * ((r) * (r)) / ((
B * r + 1) * (
B * r + 1)) + r / (
B * r + 1)) / ((
B * r + 1) * (
B * r + 1)) +
231 2 *
A * (
B * r / (
B * r + 1) - 1) / ((
B * r + 1) * (
B * r + 1));
246 derivs[i] = r / (
B * r + 1) - 1 /
B;
252 derivs[i] = -
A * ((r) * (r)) / ((
B * r + 1) * (
B * r + 1)) +
A / ((
B) * (
B));
263 bool put(xmlNodePtr cur)
override 265 cur = cur->xmlChildrenNode;
268 std::string cname((
const char*)(cur->name));
274 rAttrib.
add(id_in,
"id");
275 rAttrib.
add(p_name,
"name");
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
helper functions for EinsplineSetBuilder
bool put(xmlNodePtr cur) override
process xmlnode and registers variables to optimize
static void mw_evaluateV(const int num_groups, const UserFunctor *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
static void mw_updateVGL(const int iat, const std::vector< bool > &isAccepted, const int num_groups, const UserFunctor *const functors[], const int n_src, const int *grp_ids, const int nw, T *mw_vgl, const int n_padded, const T *mw_dist, T *mw_allUat, T *mw_cur_allu, Vector< char, OffloadPinnedAllocator< char >> &transfer_buffer)
void checkInVariablesExclusive(opt_variables_type &active) override
check in variational parameters to the global list of parameters used by the optimizer.
bool put(xmlNodePtr cur)
assign attributes to the set
void setCusp(real_type cusp) override
empty virtual function to help builder classes
real_type evaluate(real_type r, real_type &dudr, real_type &d2udr2, real_type &d3udr3) const
std::string ID_A
Id in XML input.
Define a base class for one-dimensional functions with optimizable variables.
bool Opt_A
Is optimizable.
real_type f(real_type r) override
evaluate the value at r
bool Opt_B
Is optimizable.
real_type evaluate(real_type r, real_type &dudr, real_type &d2udr2) const
static void mw_evaluateVGL(const int iat, const int num_groups, const UserFunctor *const functors[], const int n_src, const int *grp_ids, const int nw, T *mw_vgl, const int n_padded, const T *mw_dist, T *mw_cur_allu, Vector< char, OffloadPinnedAllocator< char >> &transfer_buffer)
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)
Implements the function f = A*r/(B*r + 1) - A/B.
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
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
OptimizableFunctorBase * makeClone() const override
create a clone of this object
class to handle a set of attributes of an xmlNode
void resetParametersExclusive(const opt_variables_type &active) override
reset the parameters during optimizations.
class to handle a set of variables that can be modified during optimizations
int where(int i) const
return the locator of the i-th Index
real_type evaluateV(const int iat, const int iStart, const int iEnd, const T *restrict _distArray, T *restrict distArrayCompressed) const
OMPallocator is an allocator with fused device and dualspace allocator functionality.
void clear()
clear the variable set
size_type size() const
return the size
Base class for any functor with optimizable parameters.
bool evaluateDerivatives(real_type r, std::vector< real_type > &derivs) override
compute derivatives with respect to variational parameters
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
std::string ID_B
Id in XML input.
UserFunctor(const std::string &my_name)
default constructor
void reset() override
reset function
bool evaluateDerivatives(real_type r, std::vector< TinyVector< real_type, 3 >> &derivs) override
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
real_type df(real_type r) override
evaluate the first derivative
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
optimize::VariableSet::real_type real_type
typedef for real values
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
real_type evaluate(real_type r) const
opt_variables_type myVars
set of variables to be optimized