44 bool lattice_defined =
false;
45 bool bconds_defined =
false;
51 cur = cur->xmlChildrenNode;
54 std::string cname((
const char*)cur->name);
55 if (cname ==
"parameter")
62 else if (aname ==
"lattice")
65 if (!units_prop.empty() && units_prop !=
"bohr")
67 std::ostringstream err_msg;
68 err_msg <<
"LatticeParser::put. Only atomic units (bohr) supported for lattice units. Input file uses: " 74 lattice_defined =
true;
77 else if (aname ==
"bconds")
80 bconds_defined =
true;
81 for (
int idir = 0; idir <
DIM; idir++)
83 char b = bconds[idir][0];
84 if (b ==
'n' || b ==
'N')
88 else if (b ==
'p' || b ==
'P')
95 std::ostringstream err_msg;
96 err_msg <<
"LatticeParser::put. Unknown label '" + bconds[idir] +
97 "' used for periodicity. Only 'p', 'P', 'n' and 'N' are valid!";
104 std::ostringstream err_msg;
106 <<
"LatticeParser::put. In \"bconds\", non periodic directions must be placed after the periodic ones.";
111 else if (aname ==
"vacuum")
115 else if (aname ==
"LR_dim_cutoff")
119 else if (aname ==
"ewald_grid")
123 else if (aname ==
"LR_handler")
125 std::string handler_type(
"opt_breakup");
129 if (handler_type ==
"ewald")
131 else if (handler_type ==
"opt_breakup")
133 else if (handler_type ==
"opt_breakup_original")
135 else if (handler_type ==
"ewald_strict2d")
140 else if (handler_type ==
"ewald_quasi2d")
145 else if (aname ==
"LR_tol")
149 else if (aname ==
"rs")
151 lattice_defined =
true;
153 rAttrib.
add(nptcl,
"condition");
154 rAttrib.
add(pol,
"polarized");
155 rAttrib.
add(nsh,
"shell");
159 else if (aname ==
"nparticles")
172 app_log() <<
" Lattice is specified but boundary conditions are not. Assuming PBC." << std::endl;
176 else if (boxsum == 0)
177 app_log() <<
" Lattice is not specified for the Open BC. Add a huge box." << std::endl;
179 throw UniformCommunicateError(
"LatticeParser::put. Mixed boundary is supported only when a lattice is specified!");
204 app_log() <<
"\n number of up particles = " << nptcl / 2 <<
"\n number of dn particles = " << nptcl / 2;
208 app_log() <<
"\n number of up particles = " << nptcl;
210 app_log() <<
"\n filled kshells = " << nsh <<
"\n lattice constant = " << acubic <<
" bohr" 213 for (
int idim = 0; idim <
DIM; idim++)
214 lattice_in(idim, idim) = acubic;
225 throw UniformCommunicateError(
"LatticeParser::put. Quasi 2D Ewald only works with boundary condition 'p p n'!");
230 std::string unit_name =
"bohr";
236 return lattice_defined;
242 os <<
"<unitcell>" << std::endl;
243 os << R
"(<parameter name="lattice" datatype="tensor">)" << std::endl; 244 os << ref_.R << "</parameter>" << std::endl;
245 os <<
"<parameter name=\"bconds\">";
247 for (
int idir = 0; idir <
DIM; idir++)
254 os <<
"</parameter>" << std::endl;
255 os <<
"</unitcell>" << std::endl;
261 xmlNodePtr cur = xmlNewNode(NULL, (
const xmlChar*)
"unitcell");
262 std::ostringstream l;
263 l.setf(std::ios_base::scientific);
266 xmlNodePtr p = xmlNewTextChild(cur, NULL, (
const xmlChar*)
"parameter", (
const xmlChar*)l.str().c_str());
267 xmlNewProp(p, (
const xmlChar*)
"name", (
const xmlChar*)
"lattice");
void set(const Tensor< TT, D > &lat)
set the lattice vector from the command-line options
int SuperCellEnum
supercell enumeration
const ParticleLayout & ref_
helper functions for EinsplineSetBuilder
std::ostream & app_summary()
bool put(xmlNodePtr cur)
assign attributes to the set
int getShellIndex(int nkpt) const
T VacuumScale
The scale factor for adding vacuum.
bool get(std::ostream &) const
TinyVector< int, D > BoxBConds
The boundary condition in each direction.
Tensor<T,D> class for D by D tensor.
class to handle a set of attributes of an xmlNode
This a subclass for runtime errors that will occur on all ranks.
std::string lowerCase(const std::string_view s)
++17
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...
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
Define a LRHandler with two template parameters.
Scalar_t SimulationCellRadius
simulation cell radii
int getNumberOfKpoints(int nsh) const
Scalar_t WignerSeitzRadius
Wigner-Seitz cell radius.
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Tensor_t R
Real-space unit vectors. R(i,j) i=vector and j=x,y,z.
static lr_type this_lr_type
static bool isQuasi2D()
return true if quasi 2D is selected
T getCellLength(int nptcl, T rs_in) const
return the cell size for the number of particles and rs
TinyVector< int, D > SingleParticleIndex
the type of a D-dimensional index vector
T Scalar_t
the type of scalar