12 #ifndef QMCPLUSPLUS_GAUSSIAN_FUNCTOR_H 13 #define QMCPLUSPLUS_GAUSSIAN_FUNCTOR_H 86 for(
auto it =
opt_A.begin(); it !=
opt_A.end(); ++it)
88 for(
auto it =
opt_B.begin(); it !=
opt_B.end(); ++it)
92 A(0,0) =
A(1,1) =
A(2,2) = -1.0*alpha;
93 A(0,1) =
A(1,0) =
A(0,2) =
A(2,0) =
A(1,2) =
A(2,1) = 0;
218 os <<
" type: CountingGaussian" << std::endl;
219 os <<
" id: " <<
id << std::endl;
225 std::unique_ptr<CountingGaussian>
makeClone(std::string fid)
const 227 auto rptr = std::make_unique<CountingGaussian>(fid);
228 for (
int i = 0; i <
A.
size(); ++i)
233 rptr->opt_A.resize(
opt_A.size());
234 rptr->opt_B.resize(
opt_B.size());
235 for (
int i = 0; i <
opt_A.size(); ++i)
236 rptr->opt_A[i] =
opt_A[i];
237 for (
int i = 0; i <
opt_B.size(); ++i)
238 rptr->opt_B[i] =
opt_B[i];
247 auto it = triang.begin();
248 for (
int i = 0; i < 3; ++i)
249 for (
int j = i; j < 3; ++j)
251 matrix(i, j) = matrix(j, i) = *it;
263 bool put_A =
false, put_B =
false, put_C =
false, put_D =
false, put_K =
false;
265 std::array<RealType, 6> A_triang;
268 cur = cur->xmlChildrenNode;
271 std::string cname((
const char*)(cur->name));
274 std::string opt =
"false";
275 std::string name =
"none";
277 rAttrib.
add(name,
"name");
278 rAttrib.
add(opt,
"opt");
279 rAttrib.
add(opt,
"opt_bits");
282 bool is_bitstr = std::all_of(opt.begin(), opt.end(), [&](
char c) {
return c ==
'0' || c ==
'1'; });
283 std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))std::tolower);
284 std::transform(name.begin(), name.end(), name.begin(), (int (*)(int))std::tolower);
288 if (opt.size() == 6 && is_bitstr)
289 std::transform(opt.begin(), opt.end(),
opt_A.begin(), [&](
char c) {
return (c ==
'1'); });
292 std::fill(
opt_A.begin(),
opt_A.end(), (opt ==
"true"));
293 put_A =
putContent(A_triang.begin(), A_triang.end(), cur);
300 if (opt.size() == 3 && is_bitstr)
301 std::transform(opt.begin(), opt.end(),
opt_B.begin(), [&](
char c) {
return (c ==
'1'); });
304 std::fill(
opt_B.begin(),
opt_B.end(), (opt ==
"true"));
310 if (opt.size() == 3 && is_bitstr)
311 std::transform(opt.begin(), opt.end(),
opt_B.begin(), [&](
char c) {
return (c ==
'1'); });
313 std::fill(
opt_B.begin(),
opt_B.end(), (opt ==
"true"));
318 opt_C = (opt ==
"true");
323 opt_C = (opt ==
"true");
331 APP_ABORT(
"CountingGaussian::put: overdetermined: both B and D are specified");
333 APP_ABORT(
"CountingGaussian::put: overdetermined: both C and K are specified");
340 if (!(put_A && (put_B || put_D) && (put_C || put_K)))
342 std::ostringstream err;
343 err <<
"CountingGaussian::put: required variable unspecified: ";
344 err <<
"put_A: " << put_A <<
", put_B: " << put_B <<
", put_C: " << put_C <<
", put_D: " << put_D
345 <<
", put_K: " << put_K << std::endl;
366 fgrad = 2 * (Ar -
B) * fval;
367 flap = 4 *
dot(Ar -
B, Ar -
B) * fval + 2 *
trace(
A) * fval;
373 lval =
dot(Ar - 2 *
B, r) +
C;
374 lgrad = 2 * (Ar -
B);
405 dxval = 2 * r[
X] * r[
Y];
411 dxval = 2 * r[
X] * r[
Z];
417 dxval = 2 * r[
Y] * r[
Z];
421 dfval =
Fval * dxval;
448 dfval =
Fval * dxval;
454 std::vector<RealType>& dfval,
455 std::vector<GradType>& dfgrad,
456 std::vector<RealType>& dflap)
516 std::vector<RealType>& dlval,
517 std::vector<GradType>& dlgrad,
518 std::vector<RealType>& dllap)
523 dlval[p] = r[
X] * r[
X];
530 dlval[p] = 2 * r[
X] * r[
Y];
537 dlval[p] = 2 * r[
X] * r[
Z];
544 dlval[p] = r[
Y] * r[
Y];
551 dlval[p] = 2 * r[
Y] * r[
Z];
558 dlval[p] = r[
Z] * r[
Z];
565 dlval[p] = -2 * r[
X];
572 dlval[p] = -2 * r[
Y];
579 dlval[p] = -2 * r[
Z];
598 dlval[p] = r[
X] * r[
X];
603 dlval[p] = 2 * r[
X] * r[
Y];
608 dlval[p] = 2 * r[
X] * r[
Z];
613 dlval[p] = r[
Y] * r[
Y];
618 dlval[p] = 2 * r[
Y] * r[
Z];
623 dlval[p] = r[
Z] * r[
Z];
628 dlval[p] = -2 * r[
X];
633 dlval[p] = -2 * r[
Y];
638 dlval[p] = -2 * r[
Z];
651 std::vector<PosType> r_vec;
652 std::vector<PosType> Ar_vec;
653 std::vector<RealType> x_vec;
654 std::vector<RealType> fval_vec;
655 std::vector<GradType> fgrad_vec;
656 std::vector<RealType> flap_vec;
660 for (
auto it = P.
R.begin(); it != P.
R.end(); ++it)
664 x =
dot(Ar - 2 *
B, r) +
C;
666 fgrad = 2 * (Ar -
B) * fval;
667 flap = 4 *
dot(Ar -
B, Ar -
B) * fval + 2 *
trace(
A) * fval;
670 Ar_vec.push_back(Ar);
672 fval_vec.push_back(fval);
673 fgrad_vec.push_back(fgrad);
674 flap_vec.push_back(flap);
676 os <<
"CountingGaussian::evaluate_print: id: " <<
id << std::endl;
678 std::copy(r_vec.begin(), r_vec.end(), std::ostream_iterator<PosType>(os,
", "));
679 os << std::endl <<
"Ar: ";
680 std::copy(Ar_vec.begin(), Ar_vec.end(), std::ostream_iterator<PosType>(os,
", "));
681 os << std::endl <<
"x: ";
682 std::copy(x_vec.begin(), x_vec.end(), std::ostream_iterator<RealType>(os,
", "));
683 os << std::endl <<
"fval: ";
684 std::copy(fval_vec.begin(), fval_vec.end(), std::ostream_iterator<RealType>(os,
", "));
685 os << std::endl <<
"fgrad: ";
686 std::copy(fgrad_vec.begin(), fgrad_vec.end(), std::ostream_iterator<GradType>(os,
", "));
687 os << std::endl <<
"flap: ";
688 std::copy(flap_vec.begin(), flap_vec.end(), std::ostream_iterator<RealType>(os,
", "));
helper functions for EinsplineSetBuilder
QTBase::RealType RealType
void evaluate_print(std::ostream &os, const ParticleSet &P)
void evaluateDerivatives(PosType r, std::vector< RealType > &dfval, std::vector< GradType > &dfgrad, std::vector< RealType > &dflap)
void k_to_c(const RealType &k, const TensorType &a, const PosType &d, RealType &c)
void evaluateDerivative_B(B_vars q, PosType r, RealType &dfval, GradType &dfgrad, RealType &dflap)
bool put(xmlNodePtr cur)
assign attributes to the set
void d_to_b(const PosType &d, const TensorType &a, PosType &b)
int getLoc(const std::string &vname) const
void evaluateDerivative_A(A_vars q, PosType r, RealType &dfval, GradType &dfgrad, RealType &dflap)
void checkOutVariables(const opt_variables_type &active)
std::vector< bool > opt_A
opt_variables_type myVars
QMCTraits::PosType GradType
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Specialized paritlce class for atomistic simulations.
void evaluateLogDerivatives(PosType r, std::vector< RealType > &dlval, std::vector< GradType > &dlgrad, std::vector< RealType > &dllap)
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
class to handle a set of attributes of an xmlNode
void resetParameters(const opt_variables_type &active)
class to handle a set of variables that can be modified during optimizations
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
void evaluateLog(PosType r, RealType &lval, GradType &lgrad, RealType &llap)
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
CountingGaussian(std::string fid)
void triang_to_matrix(const std::array< RealType, 6 > &triang, TensorType &matrix)
std::unique_ptr< CountingGaussian > makeClone(std::string fid) const
int size() const
return the size
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
void evaluate(PosType r, RealType &fval, GradType &fgrad, RealType &flap)
CountingGaussian(std::string fid, RealType alpha, PosType r, bool opt)
QMCTraits::RealType RealType
qmcplusplus::QMCTraits::RealType real_type
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
void divide_eq(const CountingGaussian *rhs)
void reportStatus(std::ostream &os)
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
void evaluateLogTempDerivatives(PosType r, std::vector< RealType > &dlval)
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
QTBase::TensorType TensorType
T trace(const AntiSymTensor< T, D > &)
void checkInVariables(opt_variables_type &active)
std::vector< bool > opt_B
optimize::VariableSet::real_type real_type
void initialize(CountingGaussian *ref)