CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ClexBasis.cc
Go to the documentation of this file.
11 #include "casm/global/eigen.hh"
12 
13 namespace CASM {
14 
15 template void
16  ClexBasis::generate<std::vector<AperiodicIntegralClusterOrbit>::iterator>(
17  std::vector<AperiodicIntegralClusterOrbit>::iterator,
18  std::vector<AperiodicIntegralClusterOrbit>::iterator);
19 
20 template void ClexBasis::generate<
21  std::vector<PrimPeriodicIntegralClusterOrbit>::iterator>(
22  std::vector<PrimPeriodicIntegralClusterOrbit>::iterator,
23  std::vector<PrimPeriodicIntegralClusterOrbit>::iterator);
24 
25 template BasisSet
26 ClexBasis::_construct_prototype_basis<AperiodicIntegralClusterOrbit>(
27  AperiodicIntegralClusterOrbit const &_orbit,
28  std::vector<DoFKey> const &local_keys,
29  std::vector<DoFKey> const &global_keys, Index max_poly_order) const;
30 
32  ClexBasisSpecs const &_basis_set_specs,
33  ParsingDictionary<DoFType::Traits> const *_dof_dict)
34  : m_prim_ptr(_prim_ptr),
35  m_basis_set_specs(_basis_set_specs),
36  m_dof_dict(_dof_dict),
37  m_basis_builder(std::unique_ptr<ClexBasisBuilder>(
38  new InvariantPolyBasisBuilder("invariant_poly"))) {
40 }
41 
42 //********************************************************************
43 
44 Index print_clust_basis(std::ostream &stream, BasisSet _clust_basis,
45  IntegralCluster const &_prototype, Index func_ind,
46  int space, char delim) {
47  for (Index np = 0; np < _prototype.size(); np++) {
48  stream << std::string(space, ' ');
49 
50  stream.setf(std::ios::showpoint, std::ios_base::fixed);
51  stream.precision(5);
52  stream.width(9);
53  _prototype.coordinate(np).print(stream);
54  if (delim) stream << delim;
55  }
56  stream << "\n"
57  << " Basis Functions:\n";
58 
59  _clust_basis.set_dof_IDs(sequence<Index>(0, _prototype.size() - 1));
60  _clust_basis.accept(OccFuncLabeler("\\phi_{%b,%f}(s_{%n})"));
61  Index i;
62  for (i = 0; i < _clust_basis.size(); i++) {
63  stream << " \\Phi_{" << func_ind + i
64  << "} = " << _clust_basis[i]->tex_formula() << std::endl;
65  }
66  return _clust_basis.size();
67 }
68 
69 //************************************************************
70 
71 const ClexBasis::PrimType &ClexBasis::prim() const { return *m_prim_ptr; }
72 
74 
76  return m_basis_set_specs;
77 }
78 
80  return m_dof_dict;
81 }
82 
84  std::string const &key) const {
85  // return DoFType::traits(key);
86  return this->dof_dict()->lookup(key);
87 }
88 
90 Index ClexBasis::n_sublat() const { return prim().basis().size(); }
91 
93 Index ClexBasis::n_orbits() const { return m_bset_tree.size(); }
94 
97  Index nf = 0;
98 
99  for (auto const &bo : m_bset_tree) {
100  if (bo.size()) nf += bo[0].size();
101  }
102  return nf;
103 }
104 
105 //********************************************************************
106 
108  std::vector<Orbit<PrimPeriodicSymCompare<IntegralCluster> > > asym_unit;
109  std::ostream nullstream(0);
110  make_prim_periodic_asymmetric_unit(shared_prim(),
112  std::back_inserter(asym_unit), nullstream);
113 
114  for (DoFKey const &dof_type : xtal::all_local_dof_types(prim())) {
115  m_site_bases[dof_type] =
117  prim(), asym_unit, basis_set_specs().basis_function_specs);
118  }
119  for (DoFKey const &dof_type : xtal::global_dof_types(prim())) {
120  std::vector<BasisSet> tbasis =
122  prim(), asym_unit, basis_set_specs().basis_function_specs);
123  if (tbasis.empty()) {
124  throw std::runtime_error(
125  "In ClexBasis::_populate_site_bases(), unable to lookup global DoF "
126  "type " +
127  dof_type);
128  }
129  m_global_bases[dof_type] = tbasis;
130  }
131 }
132 
133 //********************************************************************
134 
135 namespace ClexBasis_impl {}
136 
137 } // namespace CASM
Index size() const
Definition: Array.hh:131
void set_dof_IDs(const std::vector< Index > &new_IDs)
Definition: BasisSet.cc:344
bool accept(const FunctionVisitor &visitor)
Definition: BasisSet.cc:234
std::map< DoFKey, std::vector< BasisSet > > m_global_bases
Dictionary of all global BasisSets, initialized.
Definition: ClexBasis.hh:143
std::shared_ptr< const Structure > PrimType_ptr
Definition: ClexBasis.hh:37
std::map< DoFKey, std::vector< BasisSet > > m_site_bases
Dictionary of all site BasisSets, initialized on construction m_site_basis[DOF][b] gives site basis f...
Definition: ClexBasis.hh:140
Index n_orbits() const
Total number of BasisSet orbits.
Definition: ClexBasis.cc:93
void generate(OrbitIterType _begin, OrbitIterType _end)
generate clust_basis for all equivalent clusters in
PrimType_ptr m_prim_ptr
Definition: ClexBasis.hh:122
PrimType_ptr shared_prim() const
Definition: ClexBasis.cc:73
ClexBasis(PrimType_ptr _prim_ptr, ClexBasisSpecs const &_basis_set_specs, ParsingDictionary< DoFType::Traits > const *_dof_dict)
Definition: ClexBasis.cc:31
ParsingDictionary< DoFType::Traits > const * dof_dict() const
Definition: ClexBasis.cc:79
ParsingDictionary< DoFType::Traits > const * m_dof_dict
Definition: ClexBasis.hh:126
Index n_sublat() const
Total number of basis sites in primitive cell.
Definition: ClexBasis.cc:90
std::vector< BSetOrbit > m_bset_tree
Collection of all cluster orbits (are we keeping this?)
Definition: ClexBasis.hh:135
void _populate_site_bases()
Performs heavy lifting for populating site bases in m_site_bases.
Definition: ClexBasis.cc:107
PrimType const & prim() const
Definition: ClexBasis.cc:71
Index n_functions() const
Total number of basis functions.
Definition: ClexBasis.cc:96
ClexBasisSpecs const & basis_set_specs() const
Definition: ClexBasis.cc:75
DoFType::Traits const & lookup_dof_type_traits(std::string const &key) const
Definition: ClexBasis.cc:83
ClexBasisSpecs m_basis_set_specs
Definition: ClexBasis.hh:124
Collection of all the traits specific to a DoF type.
Definition: DoFTraits.hh:59
virtual std::vector< BasisSet > construct_site_bases(Structure const &_prim, std::vector< Orbit< PrimPeriodicSymCompare< IntegralCluster > > > &_asym_unit, BasisFunctionSpecs const &_basis_function_specs) const =0
Construct the site basis (if DOF_MODE is LOCAL) for a DoF, given its site.
size_type size() const
Number of elements in the cluster.
xtal::Coordinate coordinate(size_type i) const
Return the coordinate corresponding to element(i)
Parsing dictionary for obtaining the correct MoleculeAttribute given a name.
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:30
const std::vector< xtal::Site > & basis() const
Definition: Structure.hh:102
void print(std::ostream &stream, COORD_TYPE mode, char term=0, Eigen::IOFormat format=Eigen::IOFormat(7, 12)) const
Definition: Coordinate.cc:121
std::vector< DoFKey > all_local_dof_types(BasicStructure const &_struc)
std::vector< DoFKey > global_dof_types(BasicStructure const &_struc)
Main CASM namespace.
Definition: APICommand.hh:8
const double TOL
Definition: definitions.hh:30
std::string DoFKey
Definition: DoFDecl.hh:7
Index print_clust_basis(std::ostream &stream, BasisSet _clust_basis, IntegralCluster const &_prototype, Index func_ind=0, int space=18, char delim='\n')
Definition: ClexBasis.cc:44
AperiodicOrbit< IntegralCluster > AperiodicIntegralClusterOrbit
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Definition: stream_io.hh:24
N-nary function that behaves as a constant (i.e. transform(arg1,arg2,...) == constant is true)
Definition: CASM_TMP.hh:92
Provides parameters for constructing a cluster expansion basis (ClexBasis)