17 #include "Numerics/Transform2GridFunctor.h" 24 std::unique_ptr<mGridType> grid_semilocal;
29 std::string cname((
const char*)cur->name);
33 rmax = grid_semilocal->rmax();
35 else if (cname ==
"vps")
40 xmlNodePtr cur1 = cur->children;
43 std::string cname1((
const char*)cur1->name);
44 if (cname1 ==
"basisGroup")
67 while (ignore && rout > agrid->
rmax())
69 ignore = (
std::abs(a.f(rout)) < eps);
73 app_log() <<
" cutoff for non-local pseudopotential = " << agrid->
rmax() << std::endl;
74 app_log() <<
" calculated cutoff for " << eps <<
" = " << rout << std::endl;
75 int ng = agrid->
size();
77 std::unique_ptr<GridType> agrid_new;
82 agrid_new = std::make_unique<LinearGrid<RealType>>();
83 agrid_new->set(ri, rf, ng);
84 app_log() <<
" Reset the grid for SemiLocal component to a LinearGrid. " << std::endl;
86 std::vector<RealType> v(ng);
87 for (
int ig = 0; ig < ng; ig++)
89 v[ig] = a.f((*agrid_new)[ig]);
109 std::string vFormat(
"V");
114 int vPowerCorrection = 1;
115 if (vFormat ==
"r*V")
117 app_log() <<
" Local pseudopotential format = r*V" << std::endl;
118 vPowerCorrection = 0;
122 app_log() <<
" Local pseudopotential format = V" << std::endl;
125 std::unique_ptr<GridType> grid_local;
126 std::unique_ptr<mGridType> grid_local_inp;
128 bool bareCoulomb =
true;
132 std::string cname((
const char*)cur->name);
137 else if (cname ==
"basisGroup")
139 vr.putBasisGroup(cur, vPowerCorrection);
144 if (grid_local_inp ==
nullptr)
148 grid_local = std::make_unique<LinearGrid<RealType>>();
153 grid_local = std::make_unique<LinearGrid<RealType>>();
154 grid_local->set(grid_local_inp->rmin(), grid_local_inp->rmax(), grid_local_inp->size());
157 myComm->
barrier_and_abort(
"ECPComponentBuilder::buildLocal Custom grid is used. Need to recast to the linear grid");
160 std::vector<RealType> v;
163 app_log() <<
" Bare Coulomb potential is used." << std::endl;
164 grid_local->set(0.0, 1., 3);
166 for (
int ig = 0; ig < 3; ig++)
168 pp_loc = std::make_unique<RadialPotentialType>(std::move(grid_local), v);
169 pp_loc->spline(0, 0.0, 2, 0.0);
173 app_log() <<
" Guassian basisGroup is used: base power " << vr.basePower << std::endl;
178 int last = grid_local->size() - 1;
179 while (ignore && last)
181 r = (*grid_local)[last];
182 ignore = (
std::abs(zinv * vr.f(r)) < eps);
188 int ng =
static_cast<int>(r / 1
e-3) + 1;
189 app_log() <<
" Use a Linear Grid: [0," << r <<
"] Number of points = " << ng << std::endl;
190 grid_local->set(0.0, r, ng);
192 for (
int ig = 1; ig < ng - 1; ig++)
194 double r = (*grid_local)[ig];
195 v[ig] = 1.0 - zinv * vr.f(r);
197 v[0] = 2.0 * v[1] - v[2];
199 pp_loc = std::make_unique<RadialPotentialType>(std::move(grid_local), v);
213 std::string gridType(
"log");
214 std::string gridID(
"global");
216 radAttrib.
add(gridType,
"type");
217 radAttrib.
add(gridID,
"grid_id");
218 radAttrib.
add(gridID,
"grid_def");
219 radAttrib.
add(gridID,
"name");
220 radAttrib.
add(gridID,
"id");
221 radAttrib.
add(npts,
"npts");
222 radAttrib.
add(ri,
"ri");
223 radAttrib.
add(rf,
"rf");
224 radAttrib.
add(ascale,
"ascale");
225 radAttrib.
add(astep,
"astep");
226 radAttrib.
add(ascale,
"scale");
227 radAttrib.
add(astep,
"step");
232 return (*git).second->makeClone();
240 std::unique_ptr<mGridType> agrid;
241 if (gridType ==
"log")
245 app_log() <<
" Log grid scale=" << ascale <<
" step=" << astep <<
" npts=" << npts << std::endl;
246 agrid = std::make_unique<LogGridZero<mRealType>>();
247 agrid->set(astep, ascale, npts);
251 if (ri < std::numeric_limits<mRealType>::epsilon())
253 ri = std::numeric_limits<mRealType>::epsilon();
255 agrid = std::make_unique<LogGrid<mRealType>>();
256 agrid->set(ri, rf, npts);
259 else if (gridType ==
"linear")
261 agrid = std::make_unique<LinearGrid<mRealType>>();
264 npts =
static_cast<int>((rf - ri) / astep) + 1;
266 agrid->set(ri, rf, npts);
267 app_log() <<
" Linear grid ri=" << ri <<
" rf=" << rf <<
" npts = " << npts << std::endl;
272 xmlNodePtr cur1 = cur->children;
275 std::string cname((
const char*)cur1->name);
278 std::vector<double> gIn(npts);
280 agrid = std::make_unique<NumericalGrid<mRealType>>(gIn);
281 app_log() <<
" Numerical grid npts = " << gIn.size() << std::endl;
void buildLocal(xmlNodePtr cur)
build a Local Pseudopotential
helper functions for EinsplineSetBuilder
QTBase::RealType RealType
std::map< std::string, int > angMon
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
bool put(xmlNodePtr cur)
assign attributes to the set
bool putBasisGroup(xmlNodePtr cur, int baseOff=0)
process cur xmlnode
void spline(int imin, value_type yp1, int imax, value_type ypn) override
Evaluate the 2nd derivative on the grid points.
std::unique_ptr< NonLocalECPComponent > pp_nonloc
An abstract base class to implement a One-Dimensional grid.
void addSemiLocal(xmlNodePtr cur)
std::unique_ptr< mGridType > grid_global
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
std::map< std::string, std::unique_ptr< mGridType > > grid_inp
std::unique_ptr< RadialPotentialType > pp_loc
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...
LocalECPotential::RadialPotentialType RadialPotentialType
ParticleSet::Scalar_t mRealType
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
int size() const
returns the size of the grid
T rmax() const
return the last grid point
void barrier_and_abort(const std::string &msg) const
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
RadialPotentialType * createVrWithBasisGroup(xmlNodePtr cur, mGridType *agrid)
std::unique_ptr< mGridType > createGrid(xmlNodePtr cur, bool useLinear=false)