59 std::map<std::string, Eigen::MatrixXd>
const &values)
const {
60 std::pair<Eigen::MatrixXd, std::set<std::string> > result;
61 for (
auto const &val : values) {
63 result.first = val.second;
64 result.second.insert(val.first);
68 throw std::runtime_error(
69 "Could not identify DoF values for DoF '" + (this->
name()) +
70 "' from provided list of tabulated structure properties.");
77 _out.
basis().isIdentity()) {
79 for (
Index i = 0; i < _out.
dim(); ++i) {
80 if (_out[i].var_name() !=
val_traits().standard_var_names()[i]) {
90 _json[
"axes"] = _out.
basis().transpose();
92 for (
Index i = 0; i < _out.
dim(); ++i) {
93 _json[
"axis_names"].
push_back(_out[i].var_name());
120 std::map<
UnitCellCoord, std::set<UnitCellCoord> >
const &_nhood,
122 std::string
const &indent)
const {
123 std::stringstream ss;
125 ss << indent <<
" if(m_params.eval_mode(m_" <<
name()
126 <<
"_var_param_key) != ParamPack::READ) {\n";
128 ss << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_" <<
name()
129 <<
"_var_param_key, " << a <<
", eval_" <<
name() <<
"_var(" << a
132 ss << indent <<
" }\n";
136 <<
"_param_key) != ParamPack::READ) {\n";
137 for (
Index f = 0; f < site_bases[0].size(); f++) {
138 ss << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_"
142 ss << indent <<
" }\n";
145 ss << indent <<
"switch(nlist_ind) {\n";
146 for (
auto const &nbor : _nhood) {
147 std::stringstream ssvar, ssfunc;
148 ss << indent <<
"case " << _nlist.
neighbor_index(nbor.first) <<
":\n";
153 std::map<Index, std::set<Index> > sublat_nhood;
154 for (
auto const &ucc : nbor.second) {
155 sublat_nhood[ucc.sublattice()].insert(_nlist.
neighbor_index(ucc));
160 for (
auto const &sublat : sublat_nhood) {
161 Index b = sublat.first;
162 for (
Index n : sublat.second) {
163 if (!_prim.
basis()[b].has_dof(
name()))
continue;
166 ssvar << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_"
167 <<
name() <<
"_var_param_key, " << a <<
", " << n <<
", eval_"
168 <<
name() <<
"_var_" << b <<
"_" << a <<
"(" << n <<
"));\n";
172 for (
Index f = 0; f < site_bases[b].size(); f++) {
173 ssfunc << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_"
176 <<
"<Scalar>(" << n <<
"));\n";
182 ss << indent <<
" if(m_params.eval_mode(m_" <<
name()
183 <<
"_var_param_key) != ParamPack::READ) {\n"
184 << ssvar.str() << indent <<
" }\n";
188 <<
"_param_key) != ParamPack::READ) {\n"
189 << ssfunc.str() << indent <<
" }\n";
191 ss << indent <<
" break;\n";
193 ss << indent <<
"}\n";
202 std::map<
UnitCellCoord, std::set<UnitCellCoord> >
const &_nhood,
204 std::string
const &indent)
const {
205 std::stringstream ss;
208 ss << indent <<
" if(m_params.eval_mode(m_" <<
name()
209 <<
"_var_param_key) != ParamPack::READ) {\n";
211 ss << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_" <<
name()
212 <<
"_var_param_key, " << a <<
", eval_" <<
name() <<
"_var(" << a
215 ss << indent <<
" }\n";
219 <<
"_param_key) != ParamPack::READ) {\n";
220 for (
Index f = 0; f < site_bases[0].size(); f++) {
221 ss << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_"
225 ss << indent <<
" }\n";
228 std::map<Index, std::set<Index> > tot_nhood;
229 for (
auto const &nbor : _nhood)
230 for (
auto const &ucc : nbor.second)
233 std::stringstream ssvar, ssfunc;
235 for (
auto const &nbor : tot_nhood) {
236 Index b = nbor.first;
237 for (
Index n : nbor.second) {
238 if (!_prim.
basis()[b].has_dof(
name()))
continue;
241 ssvar << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_"
242 <<
name() <<
"_var_param_key, " << a <<
", " << n <<
", eval_"
243 <<
name() <<
"_var_" << b <<
"_" << a <<
"(" << n <<
"));\n";
247 for (
Index f = 0; f < site_bases[b].size(); f++) {
248 ssfunc << indent <<
" ParamPack::Val<Scalar>::set(m_params, m_"
251 <<
"<Scalar>(" << n <<
"));\n";
256 ss << indent <<
" if(m_params.eval_mode(m_" <<
name()
257 <<
"_var_param_key) != ParamPack::READ) {\n"
258 << ssvar.str() << indent <<
" }\n";
261 <<
"_param_key) != ParamPack::READ) {\n"
262 << ssfunc.str() << indent <<
" }\n";
270 Structure const &_prim, std::vector<BasisSet>
const &_site_bases,
271 std::string
const &indent)
const {
272 std::stringstream stream;
273 std::vector<Orbit<PrimPeriodicSymCompare<IntegralCluster> > > asym_unit;
274 std::ostream nullstream(0);
281 std::shared_ptr<const Structure>(&_prim, [](
const Structure *) {});
282 make_prim_periodic_asymmetric_unit(_prim_ptr,
284 std::back_inserter(asym_unit), nullstream);
308 Structure const &_prim, std::vector<BasisSet>
const &_site_bases,
309 const std::string &indent)
const {
316 Structure const &_prim, std::vector<BasisSet>
const &site_bases,
317 std::string
const &indent)
const {
324 Structure const &_prim, std::vector<BasisSet>
const &site_bases,
325 std::string
const &indent)
const {
332 Structure const &_prim, std::vector<BasisSet>
const &_site_bases,
333 const std::string &indent)
const {
335 std::stringstream stream;
339 stream << indent <<
"double eval_" <<
name()
340 <<
"_var(const int &ind) const {\n"
341 << indent <<
" return m_global_dof_ptrs[m_" <<
name()
342 <<
"_var_param_key.index()]->values()[ind];\n"
343 << indent <<
"}\n\n";
345 stream << indent <<
"template<typename Scalar>\n"
346 << indent <<
"Scalar const &" <<
name()
347 <<
"_var(const int &ind) const {\n"
348 << indent <<
" return "
349 <<
"ParamPack::Val<Scalar>::get(m_params, m_" <<
name()
350 <<
"_var_param_key, ind);\n"
355 BasisSet site_basis = _site_bases[0];
356 for (
auto const &vis : visitors) site_basis.
accept(*vis);
358 for (
Index f = 0; f < site_basis.
size(); f++) {
359 stream << indent <<
"template<typename Scalar>\n"
362 << indent <<
" return " << site_basis[f]->formula() <<
";\n"
363 << indent <<
"}\n\n";
369 std::vector<Orbit<PrimPeriodicSymCompare<IntegralCluster> > > asym_unit;
370 std::ostream nullstream(0);
377 std::shared_ptr<const Structure>(&_prim, [](
const Structure *) {});
378 make_prim_periodic_asymmetric_unit(_prim_ptr,
380 std::back_inserter(asym_unit), nullstream);
384 for (
Index no = 0; no < asym_unit.size(); no++) {
385 Index nb = asym_unit[no][0][0].sublattice();
386 if (_site_bases[nb].size() == 0)
continue;
388 for (
Index ne = 0; ne < asym_unit[no].size(); ne++) {
389 nb = asym_unit[no][ne][0].sublattice();
390 if (!_prim.
basis()[nb].has_dof(
name()))
continue;
391 stream << indent <<
"// " <<
name()
392 <<
" evaluators and accessors for basis site " << nb <<
":\n";
393 max_na =
max(max_na, _prim.
basis()[nb].dof(
name()).dim());
395 stream << indent <<
"double eval_" <<
name() <<
"_var_" << nb <<
'_'
396 << a <<
"(const int &nlist_ind) const {\n"
397 << indent <<
" return m_local_dof_ptrs[m_" <<
name()
398 <<
"_var_param_key.index()]->site_value(_l(nlist_ind))[" << a
400 << indent <<
"}\n\n";
404 max_nf =
max(max_nf, _site_bases[nb].size());
406 BasisSet site_basis = _site_bases[nb];
407 for (
auto const &vis : visitors) site_basis.
accept(*vis);
409 for (
Index f = 0; f < site_basis.
size(); f++) {
410 stream << indent <<
"template<typename Scalar>\n"
412 <<
'_' << f <<
"(const int &nlist_ind) const {\n"
413 << indent <<
" return " << site_basis[f]->formula() <<
";\n"
414 << indent <<
"}\n\n";
420 for (
Index a = 0; a < max_na; ++a) {
421 stream << indent <<
"template<typename Scalar>\n"
422 << indent <<
"Scalar const &" <<
name() <<
"_var_" << a
423 <<
"(const int &nlist_ind) const {\n"
424 << indent <<
" return "
425 <<
"ParamPack::Val<Scalar>::get(m_params, m_" <<
name()
426 <<
"_var_param_key, " << a <<
", nlist_ind);\n"
429 for (
Index f = 0; f < max_nf; ++f) {
430 stream << indent <<
"template<typename Scalar>\n"
432 <<
"(const int &nlist_ind) const {\n"
433 << indent <<
" return "
435 <<
"_param_key, " << f <<
", nlist_ind);\n"
444 Structure const &_prim, std::vector<BasisSet>
const &_bases)
const {
445 std::vector<ParamAllocation> result;
449 _bases[0].size(),
Index(1),
true));
453 Index NB = 0, NV = 0;
454 bool basis_allocation =
false;
455 for (
BasisSet const &basis : _bases) {
456 NB =
max(basis.size(), NB);
457 for (
Index f = 0; f < basis.size() && !basis_allocation; ++f) {
458 if (basis[f] && basis[f]->
type_name() !=
"Variable")
459 basis_allocation =
true;
464 if (site.has_dof(
name())) NV =
max(NV, site.dof(
name()).dim());
470 if (basis_allocation)
480 Structure const &_prim, std::vector<BasisSet>
const &_site_bases,
481 const std::string &indent)
const {
482 std::stringstream stream;
483 stream.flags(std::ios::showpoint | std::ios::fixed | std::ios::right);
484 stream.precision(10);
486 std::ostream nullstream(0);
492 std::string
const &nlist_specifier)
const {
493 std::vector<std::unique_ptr<FunctionVisitor> > result;
495 name(),
"%p_var_%f<Scalar>(" + nlist_specifier +
")")));
501 std::vector<std::unique_ptr<FunctionVisitor> > result;
503 result.push_back(std::unique_ptr<FunctionVisitor>(
511 result.push_back(std::unique_ptr<FunctionVisitor>(
518 Index site_ix)
const {
519 return std::string();
Specifies traits of (possibly) anisotropic crystal properties.
static std::string name_suffix(std::string const &_name, char delim='_')
bool accept(const FunctionVisitor &visitor)
GlobalContinuousConfigDoFValues const & global_dof(DoFKey const &_key) const
LocalContinuousConfigDoFValues const & local_dof(DoFKey const &_key) const
Index dim() const
Dimension of the DoFSet, equivalent to basis().cols()
Eigen::MatrixXd const & basis() const
Collection of all the traits specific to a DoF type.
AnisoValTraits const & val_traits() const
virtual std::string clexulator_private_method_definitions_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
virtual jsonParser dof_to_json(ConfigDoF const &_dof, BasicStructure const &_reference) const
Serialize type-specific DoF values from ConfigDoF.
virtual std::string clexulator_global_prepare_string(Structure const &_prim, std::map< UnitCellCoord, std::set< UnitCellCoord > > const &_nhood, PrimNeighborList &_nlist, std::vector< BasisSet > const &site_bases, std::string const &indent) const
virtual std::string clexulator_public_method_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
virtual void apply_dof(ConfigDoF const &_dof, BasicStructure const &_reference, SimpleStructure &_struc) const
Transforms SimpleSructure.
virtual std::pair< Eigen::MatrixXd, std::set< std::string > > find_values(std::map< std::string, Eigen::MatrixXd > const &values) const
Retrieve the standard values for a DoF from dictionary of properties from properties....
virtual std::string clexulator_private_method_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
virtual std::string clexulator_member_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
virtual std::string clexulator_point_prepare_string(Structure const &_prim, std::map< UnitCellCoord, std::set< UnitCellCoord > > const &_nhood, PrimNeighborList &_nlist, std::vector< BasisSet > const &site_bases, std::string const &indent) const
virtual std::string site_basis_description(BasisSet site_bset, Site site, Index site_ix) const
virtual std::string clexulator_public_method_definitions_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
bool requires_site_basis() const
virtual std::vector< ParamAllocation > param_pack_allocation(Structure const &_prim, std::vector< BasisSet > const &_bases) const
virtual void to_json(DoFSet const &_out, jsonParser &_json) const
Output.
virtual std::vector< std::unique_ptr< FunctionVisitor > > clust_function_visitors() const
virtual std::vector< std::unique_ptr< FunctionVisitor > > site_function_visitors(std::string const &nlist_specifier="%n") const
std::string site_basis_name() const
virtual std::string clexulator_constructor_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
std::string const & name() const
Eigen::MatrixXd standard_values() const
Get global DoF values as standard DoF values.
Eigen::MatrixXd standard_values() const
Get local DoF values as standard DoF values.
Parsing dictionary for obtaining the correct MoleculeAttribute given a name.
T const & lookup(const key_type &_name) const
Equivalent to find, but set 'home' and throws error with suggestion if.
std::pair< iterator, bool > insert(const value_type &value)
Insert single value.
The PrimNeighborList gives the coordinates of UnitCell that are neighbors of the origin UnitCell.
Scalar neighbor_index(UnitCellCoord const &_ucc)
Get neighborlist index of UnitCellCoord.
Structure specifies the lattice and atomic basis of a crystal.
const xtal::BasicStructure & structure() const
const std::vector< xtal::Site > & basis() const
jsonParser & put_obj()
Puts new empty JSON object.
jsonParser & put_array()
Puts new empty JSON array.
BasicStructure specifies the lattice and atomic basis of a crystal.
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
jsonParser & push_back(const T &value, Args &&... args)
void register_traits(Traits const &_traits)
Insert new DoFType::Traits into the global dictionary.
DoF_impl::DisplacementDoFTraits displacement()
DoF_impl::StrainDoFTraits GLstrain()
DoF_impl::StrainDoFTraits Hstrain()
DoF_impl::OccupationDoFTraits occupation()
TraitsDictionary & traits_dict()
DoF_impl::MagSpinDoFTraits magspin(std::string const &flavor_name)
Traits const & traits(std::string const &dof_key)
Lookup DoFType::Traits in the global dictionary.
DoF::BasicTraits const & basic_traits(std::string const &dof_key)
Access DoF::BasicTraits for a given DoF type.
DoF_impl::StrainDoFTraits EAstrain()
INDEX_TYPE Index
For long integer indexing:
T max(const T &A, const T &B)
N-nary function that behaves as a constant (i.e. transform(arg1,arg2,...) == constant is true)