CASM  1.1.0
A Clusters Approach to Statistical Mechanics
MagSpinDoFTraits.cc
Go to the documentation of this file.
2 
8 #include "casm/clex/ClexBasis.hh"
15 
16 namespace CASM {
17 namespace DoF_impl {
21  Structure const &_prim,
22  std::vector<Orbit<PrimPeriodicSymCompare<IntegralCluster> > > &_asym_unit,
23  BasisFunctionSpecs const &_basis_function_specs) const {
24  std::vector<BasisSet> result(_prim.basis().size());
25 
26  auto const &mag_spin_dof_specs =
27  get<MagSpinDoFSpecs>(name(), _basis_function_specs);
28 
29  for (Index b = 0; b < _prim.basis().size(); b++) {
30  if (!_prim.basis()[b].has_dof(name())) continue;
31  BasisSet tresult;
32  CASM::DoFSet adapted_dofset =
34  _prim.basis()[b].dof(name()),
35  _prim.site_dof_symrep_IDs()[b].at(name()), b);
36  tresult.set_variable_basis(adapted_dofset);
37  Array<BasisSet const *> tsubs(1, &tresult);
38  result[b].construct_harmonic_polynomials(
39  tsubs, mag_spin_dof_specs.max_poly_order, 1, false);
40  result[b].get_symmetry_representation(_prim.factor_group());
41 
42  result[b].set_name(name() + "_site_func");
43  // std::cout << "+:+:+:+Created variable set for site " << b << ", size " <<
44  // result[b].size() << "\n";
45  }
46  return result;
47 }
48 
50  Structure const &prim) const {
51  fs::path dof_specs_path{"dof_specs"};
52  fs::path subpath = dof_specs_path / this->name();
53  auto subparser = parser.subparse<MagSpinDoFSpecs>(subpath, prim);
54  if (subparser->value) {
55  parser.value->dof_specs.push_back(std::move(subparser->value));
56  }
57 }
58 
60  const BasisFunctionSpecs &basis_function_specs, jsonParser &json,
61  Structure const &prim) const {
62  MagSpinDoFSpecs const &magspin_dof_specs =
63  get<MagSpinDoFSpecs>(this->name(), basis_function_specs);
64  CASM::to_json(magspin_dof_specs, json["dof_specs"][this->name()]);
65 }
66 
67 } // namespace DoF_impl
68 
69 namespace DoFType {
70 
71 DoF_impl::MagSpinDoFTraits magspin(std::string const &flavor_name) {
72  return DoF_impl::MagSpinDoFTraits(flavor_name);
73 }
74 
75 std::unique_ptr<DoFSpecs> magspin_bfuncs(std::string const &flavor_name,
76  Index max_poly_order = -1) {
77  return notstd::make_unique<DoF_impl::MagSpinDoFSpecs>(flavor_name,
78  max_poly_order);
79 }
80 
81 } // namespace DoFType
82 
83 // -- MagSpinDoFSpecs IO --
84 
86  const Structure &prim) {
87  std::string full_name = parser.name();
88  std::string flavor_name = full_name.substr(0, full_name.find("magspin"));
89  Index max_poly_order;
90  parser.optional_else<Index>(max_poly_order, "max_poly_order", -1);
91  if (parser.valid()) {
92  parser.value = notstd::make_unique<DoF_impl::MagSpinDoFSpecs>(
93  flavor_name, max_poly_order);
94  }
95 }
96 
97 void to_json(const DoF_impl::MagSpinDoFSpecs &magspin_dof_specs,
98  jsonParser &json) {
99  json.put_obj();
100  json["max_poly_order"] = magspin_dof_specs.max_poly_order;
101 }
102 
103 } // namespace CASM
Basic std::vector like container (deprecated)
Definition: Array.hh:45
void set_variable_basis(const DoFSet &_dof_set)
Define the basis set to contain only variables (e.g., x,y,z)
Definition: BasisSet.cc:322
void parse_dof_specs(InputParser< BasisFunctionSpecs > &parser, Structure const &prim) const override
std::vector< BasisSet > construct_site_bases(Structure const &_prim, std::vector< Orbit< PrimPeriodicSymCompare< IntegralCluster > > > &_asym_unit, BasisFunctionSpecs const &_basis_function_specs) const override
Construct the site basis (if DOF_MODE is LOCAL) for a DoF, given its site.
void dof_specs_to_json(BasisFunctionSpecs const &basis_function_specs, jsonParser &json, Structure const &prim) const override
Output DoF-specific basis function specs to json. Default does nothing.
std::string const & name() const
Definition: DoFTraits.hh:69
RequiredType optional_else(fs::path option, const RequiredType &_default, Args &&... args)
std::shared_ptr< InputParser< RequiredType > > subparse(fs::path option, Args &&... args)
std::unique_ptr< T > value
Definition: InputParser.hh:234
An Orbit of Element.
Definition: Orbit.hh:43
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:30
std::vector< std::map< DoFKey, SymGroupRepID > > site_dof_symrep_IDs() const
Definition: Structure.cc:132
const std::vector< xtal::Site > & basis() const
Definition: Structure.hh:102
const MasterSymGroup & factor_group() const
Definition: Structure.cc:107
jsonParser & put_obj()
Puts new empty JSON object.
Definition: jsonParser.hh:354
DoF_impl::MagSpinDoFTraits magspin(std::string const &flavor_name)
std::unique_ptr< DoFSpecs > magspin_bfuncs(std::string const &flavor_name, Index max_poly_order=-1)
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
void parse(InputParser< ConfigEnumOptions > &parser, std::string method_name, PrimClex const &primclex, DataFormatterDictionary< Configuration > const &dict)
Specify how to construct basis functions.
std::string name() const
Name of this->self, equivalent to this->path.filename().string()
Definition: InputParser.cc:42
bool valid() const
Return true if this and and all subparsers are valid.
Definition: InputParser.cc:56