40 hasNonLocalPot(false),
62 std::string ecpFormat;
63 std::string NLPP_algo;
67 std::string physicalSO;
68 std::string spin_integrator;
71 pAttrib.
add(ecpFormat,
"format", {
"table",
"xml"});
72 pAttrib.
add(NLPP_algo,
"algorithm", {
"batched",
"non-batched"});
73 pAttrib.
add(use_DLA,
"DLA", {
"no",
"yes"});
74 pAttrib.
add(pbc,
"pbc", {
"yes",
"no"});
75 pAttrib.
add(forces,
"forces", {
"no",
"yes"});
76 pAttrib.
add(physicalSO,
"physicalSO", {
"yes",
"no"});
77 pAttrib.
add(spin_integrator,
"spin_integrator", {
"exact",
"simpson"});
80 bool doForces = (forces ==
"yes") || (forces ==
"true");
82 app_log() <<
" Using determinant localization approximation (DLA)" << std::endl;
85 if (ecpFormat ==
"xml")
102 std::unique_ptr<LocalECPotential> apot = std::make_unique<LocalECPotential>(
IonConfig,
targetPtcl);
103 for (
int i = 0; i <
localPot.size(); i++)
111 app_log() <<
" Will compute forces in CoulombPBCAB.\n" << std::endl;
112 std::unique_ptr<CoulombPBCAB> apot = std::make_unique<CoulombPBCAB>(
IonConfig,
targetPtcl, doForces);
113 for (
int i = 0; i <
localPot.size(); i++)
116 apot->add(i, std::move(
localPot[i]));
123 std::unique_ptr<NonLocalECPotential> apot =
132 nknot_max = std::max(nknot_max,
nonLocalPot[i]->getNknot());
133 if (NLPP_algo ==
"batched")
138 app_log() <<
"\n Using NonLocalECP potential \n" 139 <<
" Maximum grid on a sphere for NonLocalECPotential: " << nknot_max << std::endl;
140 if (NLPP_algo ==
"batched")
141 app_log() <<
" Using batched ratio computing in NonLocalECP" << std::endl;
148 APP_ABORT(
"SOECPotential evaluations require complex build. Rebuild with -D QMC_COMPLEX=1\n");
150 if (physicalSO ==
"yes")
151 app_log() <<
" Spin-Orbit potential included in local energy" << std::endl;
152 else if (physicalSO ==
"no")
153 app_log() <<
" Spin-Orbit potential is not included in local energy" << std::endl;
155 APP_ABORT(
"physicalSO must be set to yes/no. Unknown option given\n");
160 for (
int i = 0; i <
soPot.size(); i++)
164 nknot_max = std::max(nknot_max,
soPot[i]->getNknot());
165 sknot_max = std::max(sknot_max,
soPot[i]->getSknot());
166 if (NLPP_algo ==
"batched")
168 apot->addComponent(i, std::move(
soPot[i]));
171 app_log() <<
"\n Using SOECP potential \n" 172 <<
" Maximum grid on a sphere for SOECPotential: " << nknot_max << std::endl;
174 app_log() <<
" Using fast SOECP evaluation. Spin integration is exact" << std::endl;
176 app_log() <<
" Maximum grid for Simpson's rule for spin integral: " << sknot_max << std::endl;
177 if (NLPP_algo ==
"batched")
178 app_log() <<
" Using batched ratio computing in SOECP potential" << std::endl;
179 if (physicalSO ==
"yes")
187 for (
int i = 0; i <
L2Pot.size(); i++)
189 apot->add(i, std::move(
L2Pot[i]));
190 app_log() <<
"\n Using L2 potential" << std::endl;
203 std::string cname((
const char*)cur->name);
204 if (cname ==
"pseudo")
206 std::string href(
"none");
207 std::string ionName(
"none");
208 std::string format(
"xml");
211 bool disable_randomize_grid;
214 hAttrib.
add(href,
"href");
215 hAttrib.
add(ionName,
"elementType");
216 hAttrib.
add(ionName,
"symbol");
217 hAttrib.
add(format,
"format");
218 hAttrib.
add(nrule,
"nrule");
219 hAttrib.
add(llocal,
"l-local");
220 hAttrib.
add(disable_randomize_grid,
"disable_randomize_grid", {
false,
true});
224 int speciesIndex = ion_species.
findSpecies(ionName);
225 int chargeIndex = ion_species.findAttribute(
"charge");
226 int AtomicNumberIndex = ion_species.findAttribute(
"atomicnumber");
227 if (AtomicNumberIndex == -1)
228 AtomicNumberIndex = ion_species.findAttribute(
"atomic_number");
229 bool success =
false;
230 if (speciesIndex < ion_species.getTotalNum())
232 app_log() << std::endl <<
" Adding pseudopotential for " << ionName << std::endl;
241 success = ecp.
put(cur);
245 success = ecp.
parse(href, cur);
248 else if (format ==
"casino")
265 if (disable_randomize_grid)
266 app_warning() <<
"NLPP grid randomization is turned off. This setting should only be used for testing." 268 ecp.
pp_nonloc->set_randomize_grid(!disable_randomize_grid);
282 if (chargeIndex == -1)
284 app_error() <<
" Ion species " << ionName <<
" needs parameter \'charge\'" << std::endl;
289 RealType ion_charge = ion_species(chargeIndex, speciesIndex);
290 if (std::fabs(ion_charge - ecp.
Zeff) > 1
e-4)
292 app_error() <<
" Ion species " << ionName <<
" charge " << ion_charge <<
" pseudopotential charge " 293 << ecp.
Zeff <<
" mismatch!" << std::endl;
297 if (AtomicNumberIndex == -1)
299 app_error() <<
" Ion species " << ionName <<
" needs parameter \'atomicnumber\'" << std::endl;
304 int atomic_number = ion_species(AtomicNumberIndex, speciesIndex);
307 app_error() <<
" Ion species " << ionName <<
" atomicnumber " << atomic_number
308 <<
" pseudopotential atomic-number " << ecp.
AtomicNumber <<
" mismatch!" << std::endl;
316 app_error() <<
" Ion species " << ionName <<
" is not found." << std::endl;
320 app_error() <<
" Failed to add pseudopotential for element " << ionName << std::endl;
333 int ng(Species.getTotalNum());
334 int icharge(Species.addAttribute(
"charge"));
335 for (
int ig = 0; ig < ng; ig++)
337 std::vector<RealType> grid_temp, pp_temp;
338 std::string species(Species.speciesName[ig]);
339 std::string fname = species +
".psf";
340 std::ifstream fin(fname.c_str(), std::ios_base::in);
343 ERRORMSG(
"Could not open file " << fname)
352 app_log() <<
" ECPotential for " << species << std::endl;
353 std::unique_ptr<NonLocalECPComponent> mynnloc;
355 for (
int ij = 0; ij < npotentials; ij++)
358 fin >> angmom >> npoints;
360 inFunc.
put(npoints, fin);
364 RealType zinv = -1.0 / Species(icharge, ig);
365 int ng = npoints - 1;
367 ng =
static_cast<int>(rf * 100) + 1;
368 auto agrid = std::make_unique<LinearGrid<RealType>>();
369 agrid->set(0, rf, ng);
370 std::vector<RealType> pp_temp(ng);
372 for (
int j = 1; j < ng; j++)
375 pp_temp[j] = r * zinv * inFunc.
splint(r);
377 pp_temp[ng - 1] = 1.0;
378 auto app = std::make_unique<RadialPotentialType>(std::move(agrid), pp_temp);
381 app_log() <<
" LocalECP l=" << angmom << std::endl;
382 app_log() <<
" Linear grid=[0," << rf <<
"] npts=" << ng << std::endl;
389 mynnloc = std::make_unique<NonLocalECPComponent>();
391 auto agrid = std::make_unique<LinearGrid<RealType>>();
392 int ng =
static_cast<int>(rf * 100) + 1;
393 agrid->set(0.0, rf, ng);
394 app_log() <<
" NonLocalECP l=" << angmom <<
" rmax = " << rf << std::endl;
395 app_log() <<
" Linear grid=[0," << rf <<
"] npts=" << ng << std::endl;
396 std::vector<RealType> pp_temp(ng);
398 pp_temp[0] = inFunc(0);
399 for (
int j = 1; j < ng; j++)
401 pp_temp[j] = inFunc.
splint((*agrid)[j]);
405 mynnloc->add(angmom, app);
406 lmax = std::max(lmax, angmom);
407 rmax = std::max(rmax, rf);
412 mynnloc->setLmax(lmax);
413 mynnloc->setRmax(rmax);
414 app_log() <<
" Maximum cutoff of NonLocalECP " << rmax << std::endl;
421 std::string fname = species +
".sgr";
422 std::ifstream fin(fname.c_str(), std::ios_base::in);
425 app_error() <<
"Could not open file " << fname << std::endl;
430 while (fin >> xyz >> weight)
432 mynnloc->addknot(xyz, weight);
436 mynnloc->resize_warrays(numsgridpts, numnonloc, lmax);
std::ostream & app_warning()
Base class for any object which needs to know about a MPI communicator.
helper functions for EinsplineSetBuilder
void addOperator(std::unique_ptr< OperatorBase > &&h, const std::string &aname, bool physical=true)
add an operator
bool put(xmlNodePtr cur)
assign attributes to the set
std::ostream & app_error()
Collection of Local Energy Operators.
Communicate * Controller
Global Communicator for a process.
std::vector< std::unique_ptr< SOECPComponent > > soPot
std::unique_ptr< NonLocalECPComponent > pp_nonloc
int getTotalNum() const
return the number of species
Wrapping information on parallelism.
Specialized paritlce class for atomistic simulations.
LocalECPotential::RadialPotentialType RadialPotentialType
std::unique_ptr< SOECPComponent > pp_so
Communicate * myComm
pointer to Communicate
Declaration of a builder class for an ECP component for an ionic type.
class to handle a set of attributes of an xmlNode
bool parseCasino(const std::string &fname, xmlNodePtr cur)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
ECPotentialBuilder(QMCHamiltonian &h, ParticleSet &ions, ParticleSet &els, TrialWaveFunction &psi, Communicate *c)
constructor
std::unique_ptr< RadialPotentialType > pp_loc
std::vector< std::unique_ptr< RadialPotentialType > > localPot
void put(int npoints, std::istream &fin)
bool parse(const std::string &fname, xmlNodePtr cur)
std::vector< RealType > localZeff
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void useSimpleTableFormat()
reimplement simple table format used by NonLocalPPotential
adaptor class to handle a temporary OneDimCubicSpline on a numerical grid.
std::vector< std::unique_ptr< NonLocalECPComponent > > nonLocalPot
std::unique_ptr< L2RadialPotential > pp_L2
Class to represent a many-body trial wave function.
const auto & getLattice() const
std::vector< std::unique_ptr< L2RadialPotential > > L2Pot
Custom container for set of attributes for a set of species.
int findSpecies(const std::string &name) const
if the input species is not found, add a new species
void useXmlFormat(xmlNodePtr cur)
void barrier_and_abort(const std::string &msg) const
int rank() const
return the rank of the communicator
TrialWaveFunction & targetPsi
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition of OneDimNumGridFunctor.
Declaration of QMCHamiltonian.