38 std::string target(
"e"), source(
"i"), volume(
"no");
40 hAttrib.
add(target,
"target");
41 hAttrib.
add(source,
"source");
42 hAttrib.
add(volume,
"use_volume");
47 ERRORMSG(
"No target particle " << target <<
" exists.")
53 ERRORMSG(
"No source particle " << source <<
" exists.")
57 app_log() <<
"<init source=\"" << source <<
"\" target=\"" << target <<
"\">" << std::endl;
65 els->
spins *= 2 * M_PI;
67 app_log() <<
"</init>" << std::endl;
82 els->
R[items] = ions->
R[0] + q * chi[items];
100 const int d_ii_ID = ions->
addTable(*ions);
105 std::vector<int> Qtot(Centers), Qcore(Centers), Qval(Centers, 0);
107 int icharge = Species.addAttribute(
"charge");
109 for (
int iat = 0; iat < Centers; iat++)
110 Qtot[iat] = static_cast<int>(Species(icharge, grID[iat]));
117 const int numUp = els->
last(0);
119 const int numDown = els->
last(els->
groups() > 1 ? 1 : 0) - els->
first(0);
121 int random_number_counter = 0;
122 int nup_tot = 0, ndown_tot = numUp;
123 std::vector<LoneElectron> loneQ;
129 for (
size_t iat = 0; iat < Centers; iat++)
132 for (
size_t jat = iat + 1; jat < Centers; ++jat)
134 rmin =
std::min(rmin, dist[jat][iat]);
138 int v2 = Qtot[iat] / 2;
139 if (Qtot[iat] > v2 * 2)
143 for (
int k = 0; k < v2; k++)
147 els->
R[nup_tot++] = ions->
R[iat] + sep * chi[random_number_counter++];
148 if (ndown_tot < numDown)
149 els->
R[ndown_tot++] = ions->
R[iat] + sep * chi[random_number_counter++];
158 std::vector<LoneElectron>::iterator it(loneQ.begin());
159 std::vector<LoneElectron>::iterator it_end(loneQ.end());
160 while (it != it_end && nup_tot != numUp && ndown_tot != numDown)
164 els->
R[nup_tot++] = ions->
R[(*it).ID] + (*it).BondLength * chi[random_number_counter++];
167 if (ndown_tot < numDown && it != it_end)
169 els->
R[ndown_tot++] = ions->
R[(*it).ID] + (*it).BondLength * chi[random_number_counter++];
180 while (nup_tot < numUp)
181 els->
R[nup_tot++] = cm + sep * chi[random_number_counter++];
182 if (ndown_tot < numDown)
183 while (ndown_tot < numDown)
184 els->
R[ndown_tot++] = cm + sep * chi[random_number_counter++];
187 if (random_number_counter != chi.size())
188 throw std::runtime_error(
"initMolecule unexpected random number consumption. Please report a bug!");
210 return TinyVector<T, 3>(std::max(a[0], b[0]), std::max(a[1], b[1]), std::max(a[2], b[2]));
222 for (
int iat = 0; iat < Ru.size(); iat++)
232 for (
int idim = 0; idim <
OHMMS_DIM; ++idim)
243 start[idim] = std::max((
RealType)0.0, (start[idim] - buffer_r));
245 shift[idim] = start[idim] * ions->
getLattice().Length[idim];
246 if (
std::abs(end[idim] = start[idim]) < buffer)
248 start[idim] = std::max(0.0, start[idim] - buffer_r / 2.0);
249 end[idim] =
std::min(1.0, end[idim] + buffer_r / 2.0);
252 newbox(idim, idim) = (end[idim] - start[idim]) * ions->
getLattice().Length[idim];
257 slattice.
set(newbox);
259 app_log() <<
" InitMolecularSystem::initWithVolume " << std::endl;
260 app_log() <<
" Effective Lattice shifted by " << shift << std::endl;
261 app_log() << newbox << std::endl;
265 for (
int iat = 0; iat < Ru.size(); ++iat)
266 els->
R[iat] = slattice.toCart(Ru[iat]) + shift;
void set(const Tensor< TT, D > &lat)
set the lattice vector from the command-line options
a class that defines a supercell in D-dimensional Euclean space.
void makeUniformRandom(ParticleAttrib< TinyVector< T, D >> &a)
helper functions for EinsplineSetBuilder
const DistanceTableAA & getDistTableAA(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAA
ParticleScalar spins
internal spin variables for dynamical spin calculations
QTBase::RealType RealType
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
bool put(xmlNodePtr cur)
assign attributes to the set
void applyBC(const ParticlePos &pin, ParticlePos &pout)
int first(int igroup) const
return the first index of a group i
void update(bool skipSK=false)
update the internal data
Attaches a unit to a Vector for IO.
TinyVector< T, 3 > lower_bound(const TinyVector< T, 3 > &a, const TinyVector< T, 3 > &b)
helper function to determine the lower bound of a domain (need to move up)
ParticleIndex GroupID
Species ID.
LoneElectron(int id, RealType bl)
int groups() const
return the number of groups
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
Specialized paritlce class for atomistic simulations.
void makeSphereRandom(ParticleAttrib< TinyVector< T, 3 >> &a)
Tensor<T,D> class for D by D tensor.
Declaration of InitMolecularSystem.
Abstract class to provide xml-compatible I/O interfaces for the derived classes.
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
void makeGaussRandom(std::vector< TinyVector< T, D >> &a)
class to handle a set of attributes of an xmlNode
void initWithVolume(ParticleSet *ions, ParticleSet *els)
initialize els for the systems with a mixed boundary
Manage a collection of ParticleSet objects.
int last(int igroup) const
return the last index of a group i
TinyVector< T, 3 > upper_bound(const TinyVector< T, 3 > &a, const TinyVector< T, 3 > &b)
helper function to determine the upper bound of a domain (need to move up)
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
void initAtom(ParticleSet *ions, ParticleSet *els)
initialize els for an atom
void reset() override
reset member data
void initMolecule(ParticleSet *ions, ParticleSet *els)
initialize els position for a molecule
const std::vector< DistRow > & getDistances() const
return full table distances
InitMolecularSystem(ParticleSetPool &pset, const char *aname="mosystem")
bool get(std::ostream &os) const override
write to a std::ostream
const auto & getLattice() const
Custom container for set of attributes for a set of species.
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
ParticleSetPool & ptclPool
pointer to ParticleSetPool
bool put(std::istream &is) override
read from std::istream
Declaration of ParticleSetPool.