16 #ifndef QMCPLUSPLUS_RADIAL_NUMERICALGRIDORBITALBUILDER_H 17 #define QMCPLUSPLUS_RADIAL_NUMERICALGRIDORBITALBUILDER_H 24 #include "Numerics/Transform2GridFunctor.h" 54 template<
typename T,
typename FnIn>
67 Transform2GridFunctor<FnIn, spline_type> transform(*
m_ref, radorb);
68 transform.generate(agrid.
rmin(), agrid.
rmax(), agrid.
size());
83 template<
typename COT>
84 class RadialOrbitalSetBuilder :
public MPIObjectBase
110 int radial_grid_size = 1001);
113 bool addGrid(xmlNodePtr cur,
const std::string& rad_type);
132 template<
typename Fin,
typename T>
149 std::vector<std::unique_ptr<TransformerBase<RealType>>>
radTemp;
154 template<
typename COT>
156 :
MPIObjectBase(
comm), Normalized(true), m_orbitals(aos), radial_grid_size_(radial_grid_size), m_rcut(-1.0)
159 template<
typename COT>
162 if (rad_type ==
"Numerical")
177 template<
typename COT>
180 app_log() <<
" Grid is created by the input parameters in h5" << std::endl;
182 std::string gridtype;
183 if (myComm->rank() == 0)
185 hin.
read(gridtype,
"grid_type");
187 myComm->bcast(gridtype);
190 RealType ri = 0.0, rf = 10.0, rmax_safe = 10;
191 if (myComm->rank() == 0)
194 hin.
read(tt,
"grid_ri");
196 hin.
read(tt,
"grid_rf");
201 hin.
read(npts,
"grid_npts");
205 myComm->bcast(rmax_safe);
208 if (gridtype.empty())
209 myComm->barrier_and_abort(
"Grid type is not specified.");
211 if (gridtype ==
"log")
213 app_log() <<
" Using log grid ri = " << ri <<
" rf = " << rf <<
" npts = " << npts << std::endl;
214 input_grid = std::make_unique<LogGrid<RealType>>();
216 else if (gridtype ==
"linear")
218 app_log() <<
" Using linear grid ri = " << ri <<
" rf = " << rf <<
" npts = " << npts << std::endl;
219 input_grid = std::make_unique<LinearGrid<RealType>>();
222 input_grid->set(ri, rf, npts);
236 template<
typename COT>
238 const std::string& m_infunctype,
241 std::string radtype(m_infunctype);
242 std::string dsname(
"0");
244 aAttrib.
add(radtype,
"type");
245 aAttrib.
add(m_rcut,
"rmax");
246 aAttrib.
add(dsname,
"ds");
249 if (radtype ==
"Gaussian" || radtype ==
"GTO")
251 else if (radtype ==
"Slater" || radtype ==
"STO")
254 myComm->barrier_and_abort(
"Purely numerical atomic orbitals are not supported any longer.");
258 template<
typename COT>
260 const std::string& radtype_atomicBasisSet,
263 std::string dsname(
"0");
264 std::string radtype(radtype_atomicBasisSet);
265 if (myComm->rank() == 0)
266 hin.
read(radtype,
"type");
267 myComm->bcast(radtype);
270 if (radtype ==
"Gaussian" || radtype ==
"GTO")
272 else if (radtype ==
"Slater" || radtype ==
"STO")
274 myComm->barrier_and_abort(
275 " RadType: Slater. Any type other than Gaussian not implemented in H5 format. Please contact developers.");
277 myComm->barrier_and_abort(
278 " RadType: Numerical. Any type other than Gaussian not implemented in H5 format. Please contact developers.");
283 template<
typename COT>
288 auto gset = std::make_unique<gto_type>(L, Normalized);
291 RealType r0 = find_cutoff(*gset, 100.);
292 m_rcut_safe = std::max(m_rcut_safe, r0);
294 m_orbitals.RnlID.push_back(m_nlms);
298 template<
typename COT>
303 auto gset = std::make_unique<gto_type>(L, Normalized);
310 RealType r0 = find_cutoff(*gset, 100.);
311 m_rcut_safe = 6 * std::max(m_rcut_safe, r0);
313 m_orbitals.RnlID.push_back(m_nlms);
327 template<
typename COT>
333 std::unique_ptr<OneDimGridBase<OHMMS_PRECISION_FULL>> grid_prec;
334 grid_prec = std::make_unique<LogGrid<OHMMS_PRECISION_FULL>>();
336 grid_prec->set(1.
e-6, m_rcut_safe, 1001);
338 auto& multiset = m_orbitals.MultiRnl;
339 const int norbs = radTemp.size();
340 multiset.initialize(*grid_prec, norbs);
342 for (
int ib = 0; ib < norbs; ++ib)
343 radTemp[ib]->
convert(*grid_prec, multiset, ib, 5);
347 app_log() <<
" Setting cutoff radius " << m_rcut_safe << std::endl << std::endl;
348 m_orbitals.setRmax(static_cast<RealType>(m_rcut_safe));
351 template<
typename COT>
355 auto gset = std::make_unique<sto_type>(m_nlms[1], Normalized);
360 m_rcut_safe = std::max(m_rcut_safe, static_cast<RealType>(100));
362 m_orbitals.RnlID.push_back(m_nlms);
369 template<
typename COT>
370 template<
typename Fin,
typename T>
375 const OHMMS_PRECISION_FULL eps = 1
e-6;
376 bool too_small =
true;
378 int i = radial_grid_size_ - 1;
380 while (too_small && i > 0)
386 return static_cast<OHMMS_PRECISION_FULL
>(r);
typename COT::RadialOrbital_t RadialOrbitalType
multivalue implementation for OneDimQuintic Real valued only calling any eval method with r >= r_max ...
void addGaussianH5(hdf_archive &hin)
T rmin() const
return the first grid point
A2NTransformer(std::unique_ptr< FnIn > in)
void set(T ri, T rf, int n)
Base class for any object which needs to know about a MPI communicator.
QuantumNumberType m_nlms
the quantum number of this node
helper functions for EinsplineSetBuilder
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
void convert(const PL &lat, const PV &pin, PV &pout)
static std::unique_ptr< GridType > createGrid(xmlNodePtr cur)
return a GridType*
bool put(xmlNodePtr cur)
assign attributes to the set
Build a set of radial orbitals at the origin.
T find_cutoff(Fin &in, T rmax)
compute the safe cutoff radius of a radial functor
declaration of MPIObjectBase
void addGaussian(xmlNodePtr cur)
virtual void convert(grid_type &agrid, FnOut &multiset, int ispline, int order)=0
convert input 1D functor to the multi set
Define a base class for one-dimensional functions with optimizable variables.
typename COT::GridType GridType
std::vector< std::unique_ptr< TransformerBase< RealType > > > radTemp
radial functors to be finalized
bool addGrid(xmlNodePtr cur, const std::string &rad_type)
add a grid
RealType m_rcut
maximum cutoff for an orbital, could come from XML always set to -1 by constructor ...
An abstract base class to implement a One-Dimensional grid.
Wrapping information on parallelism.
void addSlater(xmlNodePtr cur)
virtual ~TransformerBase()
bool addGridH5(hdf_archive &hin)
abstract class to defer generation of spline functors
void finalize()
This is when the radial orbitals are actually created.
class to handle a set of attributes of an xmlNode
bool addRadialOrbital(xmlNodePtr cur, const std::string &m_infunctype, const QuantumNumberType &nlms)
add a radial functor
bool putBasisGroup(xmlNodePtr cur)
bool putBasisGroupH5(hdf_archive &hin, Communicate &myComm)
RealType m_rcut_safe
safe common cutoff radius
hdf_archive hin
hdf file only for numerical basis h5 file generated by SQD
std::tuple< int, double, double > grid_param_in
QMCTraits::RealType RealType
GridType
The different types of grids that we currently allow.
void add_spline(int ispline, OneDimQuinticSpline< T1 > &in)
int size() const
returns the size of the grid
typename COT::RealType RealType
bool putBasisGroup(xmlNodePtr cur)
T rmax() const
return the last grid point
virtual std::unique_ptr< OneDimGridBase< T, CT > > makeClone() const =0
COT & m_orbitals
the atomic orbitals
RadialOrbitalSetBuilder(Communicate *comm, COT &aos, int radial_grid_size=1001)
constructor
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
std::unique_ptr< FnIn > m_ref
void convert(grid_type &agrid, FnOut &multiset, int ispline, int order) override
convert input 1D functor to the multi set
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
bool Normalized
true, if the RadialOrbitalType is normalized
bool addRadialOrbitalH5(hdf_archive &hin, const std::string &radtype, const QuantumNumberType &nlms)
std::unique_ptr< GridType > input_grid
input grid in case transform is needed
int radial_grid_size_
Number of grid points.
Assume that coeffs.D1 and the LogLightGrid r_values.size() are equal Therefore r must be < r_max...