13 #ifndef QMCPLUSPLUS_SPOSET_SCANNER_H 14 #define QMCPLUSPLUS_SPOSET_SCANNER_H 28 using PtclPool = std::map<std::string, const std::unique_ptr<ParticleSet>>;
38 std::complex<T>
myfabs(std::complex<T>&
s)
59 void put(xmlNodePtr cur)
61 app_log() <<
"Entering the SPO set scanner!" << std::endl;
63 std::string sourcePtcl(
"ion0");
65 aAttrib.
add(sourcePtcl,
"source");
69 app_log() <<
"Source particle set not found. Can not be used as reference point." << std::endl;
74 xmlNodePtr cur_save = cur;
75 for (
const auto& [name, sposet] :
sposets)
77 app_log() <<
" Processing SPO " << sposet->getName() << std::endl;
79 cur = cur_save->children;
82 std::string trace_name(
"no name");
84 aAttrib.
add(trace_name,
"name");
87 std::string prefix(sposet->getName() +
"_" + cname +
"_" + trace_name);
90 app_log() <<
" Scanning a " << cname <<
" called " << trace_name <<
" and writing to " 91 << prefix +
"_v/g/l/report.dat" << std::endl;
92 auto spo = sposet->makeClone();
97 if (cname !=
"text" && cname !=
"comment")
98 app_log() <<
" Unknown type of scanning " << cname << std::endl;
103 app_log() <<
"Exiting the SPO set scanner!" << std::endl << std::endl;
109 std::string file_name;
110 file_name = prefix +
"_v.dat";
111 std::ofstream output_v(file_name.c_str());
112 file_name = prefix +
"_g.dat";
113 std::ofstream output_g(file_name.c_str());
114 file_name = prefix +
"_l.dat";
115 std::ofstream output_l(file_name.c_str());
116 file_name = prefix +
"_report.dat";
117 std::ofstream output_report(file_name.c_str());
126 aAttrib.
add(nknots,
"nknots");
127 aAttrib.
add(from_atom,
"from_atom");
128 aAttrib.
add(to_atom,
"to_atom");
129 aAttrib.
add(from_pos,
"from_pos");
130 aAttrib.
add(to_pos,
"to_pos");
139 if (from_atom >= 0 && from_atom < ions->R.size())
140 from_pos =
ions->
R[from_atom];
141 if (to_atom >= 0 && to_atom < ions->R.size())
142 to_pos =
ions->
R[to_atom];
148 int OrbitalSize(sposet.
size());
149 SPO_v.resize(OrbitalSize);
150 SPO_g.resize(OrbitalSize);
151 SPO_l.resize(OrbitalSize);
152 SPO_v_avg.resize(OrbitalSize);
153 SPO_g_avg.resize(OrbitalSize);
154 SPO_l_avg.resize(OrbitalSize);
158 double Delta = 1.0 / (nknots - 1);
159 int elec_count =
target.
R.size();
162 for (
int icount = 0, ind = 0; icount < nknots; icount++, ind++)
164 if (ind == elec_count)
166 target.
R[ind][0] = (to_pos[0] - from_pos[0]) * Delta * icount + from_pos[0];
167 target.
R[ind][1] = (to_pos[1] - from_pos[1]) * Delta * icount + from_pos[1];
168 target.
R[ind][2] = (to_pos[2] - from_pos[2]) * Delta * icount + from_pos[2];
171 std::ostringstream o;
172 o <<
"x_y_z " << std::fixed << std::setprecision(7) <<
target.
R[ind][0] <<
" " <<
target.
R[ind][1] <<
" " 174 output_v << o.str() <<
" : " << std::scientific << std::setprecision(12);
175 output_g << o.str() <<
" : " << std::scientific << std::setprecision(12);
176 output_l << o.str() <<
" : " << std::scientific << std::setprecision(12);
177 for (
int iorb = 0; iorb < OrbitalSize; iorb++)
179 SPO_v_avg[iorb] +=
myfabs(SPO_v[iorb]);
180 SPO_g_avg[iorb] +=
myfabs(SPO_g[iorb]);
181 SPO_l_avg[iorb] +=
myfabs(SPO_l[iorb]);
182 output_v << SPO_v[iorb] <<
" ";
183 output_g << SPO_g[iorb][0] <<
" " << SPO_g[iorb][1] <<
" " << SPO_g[iorb][2] <<
" ";
184 output_l << SPO_l[iorb] <<
" ";
186 output_v << std::endl;
187 output_g << std::endl;
188 output_l << std::endl;
194 output_report <<
"# Report: Orb Value_avg I/R Gradients_avg Laplacian_avg" << std::endl;
196 output_report <<
"# Report: Orb Value_avg Gradients_avg Laplacian_avg" << std::endl;
198 for (
int iorb = 0; iorb < OrbitalSize; iorb++)
199 output_report <<
"\t" << iorb <<
" " << std::scientific
200 << SPO_v_avg[iorb] * static_cast<RealType>(1.0 / nknots) <<
" " 202 << SPO_v_avg[iorb].imag() / SPO_v_avg[iorb].real() <<
" " 204 << SPO_g_avg[iorb][0] *
static_cast<RealType>(1.0 / nknots) <<
" " 205 << SPO_g_avg[iorb][1] * static_cast<RealType>(1.0 / nknots) <<
" " 206 << SPO_g_avg[iorb][2] *
static_cast<RealType>(1.0 / nknots) <<
" " 207 << SPO_l_avg[iorb] * static_cast<RealType>(1.0 / nknots) << std::fixed << std::endl;
211 output_report.close();
base class for Single-particle orbital sets
OrbitalSetTraits< ValueType >::ValueVector ValueVector
RealType myfabs(RealType s)
helper functions for EinsplineSetBuilder
QTBase::RealType RealType
const SPOSetMap & sposets
QMCTraits::RealType RealType
bool put(xmlNodePtr cur)
assign attributes to the set
QMCTraits::ValueType ValueType
OrbitalSetTraits< ValueType >::HessVector HessVector
int size() const
return the size of the orbital set Ye: this needs to be replaced by getOrbitalSetSize(); ...
void update(bool skipSK=false)
update the internal data
TinyVector< T, OHMMS_DIM > myfabs(TinyVector< T, OHMMS_DIM > &s)
Specialized paritlce class for atomistic simulations.
const PtclPool & ptcl_pool_
QTBase::ValueType ValueType
class to handle a set of attributes of an xmlNode
void scan_path(xmlNodePtr cur, SPOSet &sposet, std::string prefix)
a scanner for all the SPO sets.
virtual void evaluateVGL(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi)=0
evaluate the values, gradients and laplacians of this single-particle orbital set ...
std::map< std::string, const std::unique_ptr< ParticleSet > > PtclPool
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
OrbitalSetTraits< ValueType >::GradVector GradVector
std::map< std::string, const std::unique_ptr< const SPOSet > > SPOMap
SPOSetScanner(const SPOSetMap &sposets_in, ParticleSet &targetPtcl, const PtclPool &psets)
trait class to handel a set of Orbitals
bool get(std::ostream &os) const override
dummy. For satisfying OhmmsElementBase.
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
std::string getNodeName(xmlNodePtr cur)
std::complex< T > myfabs(std::complex< T > &s)