12 #ifndef QMCPLUSPLUS_NORMALIZED_GAUSSIAN_REGION_H 13 #define QMCPLUSPLUS_NORMALIZED_GAUSSIAN_REGION_H 36 std::vector<std::unique_ptr<CountingGaussian>>
C;
42 std::unique_ptr<CountingGaussian>
Cref;
49 std::vector<std::string>
C_id;
53 std::vector<RealType>
sum;
56 std::vector<RealType>
Nval;
62 std::vector<RealType>
Lmax;
90 for(
int I = 0;
I <
C.size(); ++
I)
97 auto comp = [](
const auto& a,
const auto& b) {
return a->myVars.size_of_active() < b->myVars.size_of_active(); };
98 auto& Cmax = *(std::max_element(
C.begin(),
C.end(), comp));
99 return Cmax->myVars.size();
107 void addFunc(std::unique_ptr<CountingGaussian> func, std::string fid)
110 C.push_back(std::move(func));
140 for(
int I = 0;
I <
C.size(); ++
I)
141 C[
I]->myVars.resetIndex();
146 for (
auto it =
C.begin(); it !=
C.end(); ++it)
147 (*it)->checkInVariables(active);
151 for (
auto it =
C.begin(); it !=
C.end(); ++it)
152 (*it)->checkOutVariables(active);
156 for (
auto it =
C.begin(); it !=
C.end(); ++it)
157 (*it)->resetParameters(active);
179 for (
int I = 0;
I <
C.size(); ++
I)
186 os <<
" Region type: CountingGaussianRegion" << std::endl;
187 os <<
" Region optimizable parameters: " <<
total_num_derivs() << std::endl << std::endl;
188 os <<
" Counting Functions: " << std::endl;
189 for (
int I = 0;
I <
C.size(); ++
I)
196 auto cr = std::make_unique<CountingGaussianRegion>(
num_els);
197 for (
int i = 0; i <
C.size(); ++i)
199 auto Ci =
C[i]->makeClone(
C_id[i]);
200 cr->addFunc(std::move(Ci),
C_id[i]);
205 int ref_index = std::distance(
C_id.begin(), C_id_it);
207 cr->Cref = cr->C[ref_index]->makeClone(
Cref_id +
"_ref");
208 for(
auto& ptr : cr->C)
209 ptr->initialize(cr->Cref.get());
223 int ref_index = std::distance(
C_id.begin(), C_id_it);
224 if (C_id_it ==
C_id.end())
225 APP_ABORT(
"CountingGaussianRegion::put: reference function not found:" +
226 (
Cref_id ==
"none" ?
" Cref not specified" :
"\"" +
Cref_id +
"\""));
231 ptr->initialize(
Cref.get());
241 std::fill(
sum.begin(),
sum.end(), 0);
242 std::fill(
grad.begin(),
grad.end(), 0);
247 std::fill(
Nval.begin(),
Nval.end(), 0);
248 std::fill(
Lmax.begin(),
Lmax.end(), 0);
250 for (
int i = 0; i <
num_els; ++i)
291 for (
auto it =
C.begin(); it !=
C.end(); ++it)
292 (*it)->evaluate_print(os, P);
293 os <<
"CountingGaussianRegions::evaluate_print" << std::endl;
296 os << std::endl <<
"sum: ";
297 std::copy(
sum.begin(),
sum.end(), std::ostream_iterator<RealType>(os,
", "));
298 os << std::endl <<
"grad: ";
300 os << std::endl <<
"lap: ";
302 os << std::endl <<
"Nval: ";
304 os << std::endl <<
"Lmax: ";
362 os <<
"CountingGaussianRegion::evaluateTemp_print" << std::endl;
365 os << std::endl <<
"sum_t: ";
367 os << std::endl <<
"grad_t: ";
369 os << std::endl <<
"lap_t: ";
371 os << std::endl <<
"Nval_t: " <<
Nval_t;
372 os << std::endl <<
"Lmax_t: " <<
Lmax_t;
386 static std::vector<RealType> dLval_t;
393 for (
int p = 0; p < num_derivs; ++p)
408 std::vector<RealType>& dNFNggsum)
411 static std::vector<RealType> dLval;
412 static std::vector<PosType> dLgrad;
413 static std::vector<RealType> dLlap;
420 for (
int i = 0; i <
num_els; ++i)
423 C[
I]->evaluateLogDerivatives(P.
R[i], dLval, dLgrad, dLlap);
426 for (
int p = 0; p < num_derivs; ++p)
432 grad(
J, i) * dLval[p] * val_Ii +
val(
J, i) * dLgrad[p] * val_Ii -
val(
J, i) * dLval[p] *
grad(
I, i);
440 dNsum(
J, p) += dNval;
441 dNggsum(
J, p) +=
dot(dNgrad, grad_i);
442 dNlapsum(
J, p) += dNlap;
443 dNFNggsum[p] +=
dot(dNgrad, FCgrad(
J, i));
Container_t::iterator begin()
std::vector< RealType > _dLval_saved
RealType & dLval_saved(int I, int p, int i)
helper functions for EinsplineSetBuilder
void checkOutVariables(const opt_variables_type &active)
QTBase::RealType RealType
int max_num_derivs() const
void resetParameters(const opt_variables_type &active)
size_t getTotalNum() const
bool put(xmlNodePtr cur)
assign attributes to the set
void addFunc(std::unique_ptr< CountingGaussian > func, std::string fid)
std::vector< RealType > Lmax
void resize(size_type n, size_type m)
Resize the container.
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
std::vector< std::unique_ptr< CountingGaussian > > C
const PosType & getActivePos() const
Specialized paritlce class for atomistic simulations.
void reportStatus(std::ostream &os)
void evaluate_print(std::ostream &os, const ParticleSet &P)
std::vector< RealType > val_t
QMCTraits::RealType RealType
class to handle a set of attributes of an xmlNode
ParticleGradient G
gradients of the particles
class to handle a set of variables that can be modified during optimizations
optimize::VariableSet::real_type real_type
std::vector< std::string > C_id
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
int size_of_active() const
return the number of active variables
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
std::vector< PosType > grad_t
size_type size() const
return the size
std::vector< RealType > Lval_t
void evaluateTemp_print(std::ostream &os, const ParticleSet &P)
void evaluateTempDerivatives(ParticleSet &P, const int I, int iat, Matrix< RealType > &dNdiff)
void checkInVariables(opt_variables_type &active)
std::vector< RealType > sum_t
CountingGaussianRegion(int n)
void evaluateTemp(const ParticleSet &P, int iat)
const opt_variables_type & getVars(int I)
qmcplusplus::QMCTraits::RealType real_type
std::vector< RealType > Nval
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
CountingGaussianRegion(ParticleSet &P)
Container_t::iterator end()
std::vector< RealType > sum
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
void acceptMove(ParticleSet &P, int iat)
QTBase::TensorType TensorType
std::unique_ptr< CountingGaussianRegion > makeClone()
std::unique_ptr< CountingGaussian > Cref
std::vector< RealType > lap_t
void evaluate(const ParticleSet &P)
void evaluateDerivatives(ParticleSet &P, int I, Matrix< PosType > &FCgrad, Matrix< RealType > &dNsum, Matrix< RealType > &dNggsum, Matrix< RealType > &dNlapsum, std::vector< RealType > &dNFNggsum)
std::vector< PosType > Lgrad_t
std::vector< RealType > Llap_t