CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigDoFValues.cc
Go to the documentation of this file.
2 
3 namespace CASM {
4 
6  Index _n_sublat, Index _n_vol)
7  : m_type(_traits.name()), m_n_sublat(_n_sublat), m_n_vol(_n_vol) {}
8 
9 std::string const &ConfigDoFValues::type_name() const { return m_type; }
10 
12 
14 
16  DoF::BasicTraits const &_traits, Index _n_sublat, Index _n_vol,
17  std::vector<SymGroupRepID> const &_symrep_IDs)
18  : ConfigDoFValues(_traits, _n_sublat, _n_vol),
19  m_vals(Eigen::VectorXi::Zero(_n_sublat * _n_vol)),
20  m_symrep_IDs(_symrep_IDs) {}
21 
24 
31  Eigen::Ref<ValueType const> const &_values) {
32  _throw_if_invalid_size(_values);
33  m_vals = _values;
34 }
35 
38 
41 Eigen::VectorXi const &LocalDiscreteConfigDoFValues::values() const {
42  return m_vals;
43 }
44 
48  return m_vals.segment(b * n_vol(), n_vol());
49 }
50 
54  return m_vals.segment(b * n_vol(), n_vol());
55 }
56 
59 std::vector<SymGroupRepID> const &LocalDiscreteConfigDoFValues::symrep_IDs()
60  const {
61  return m_symrep_IDs;
62 }
63 
65  Eigen::Ref<ValueType const> const &_values) const {
66  if (_values.size() != n_vol() * n_sublat()) {
67  std::stringstream msg;
68  msg << "Invalid size in LocalDiscreteConfigDoFValues: "
69  << "Expected size=" << n_vol() * n_sublat()
70  << ", received size=" << _values.size();
71  throw std::runtime_error(msg.str());
72  }
73 }
74 
77  std::vector<DoFSetInfo> const &_info) {
78  Index dim = 0;
79  for (auto const &_dof_set_info : _info) {
80  dim = max(dim, _dof_set_info.dim());
81  }
82  return dim;
83 }
84 
86  DoF::BasicTraits const &_traits, Index _n_sublat, Index _n_vol,
87  std::vector<DoFSetInfo> const &_info)
88  : ConfigDoFValues(_traits, _n_sublat, _n_vol),
89  m_dim(matrix_dim(_info)),
90  m_info(_info),
91  m_vals(Eigen::MatrixXd::Zero(m_dim, _n_sublat * _n_vol)) {
93 }
94 
97 
114  Eigen::Ref<const ValueType> const &_values) {
115  _throw_if_invalid_size(_values);
116  m_vals = _values;
117 }
118 
121 
137  return m_vals;
138 }
139 
147  Eigen::Ref<const Eigen::MatrixXd> const &_standard_values) {
148  if (_standard_values.rows() != info().front().basis().rows() ||
149  _standard_values.cols() != n_vol() * n_sublat()) {
150  std::stringstream msg;
151  msg << "Invalid standard values input size in "
152  "LocalContinuousConfigDoFValues: "
153  << "Expected rows=" << info().front().basis().rows()
154  << ", received rows=" << _standard_values.rows()
155  << ", expected cols=" << n_vol() * n_sublat()
156  << ", received cols=" << _standard_values.cols();
157  throw std::runtime_error(msg.str());
158  }
159  for (Index b = 0; b < n_sublat(); ++b)
160  sublat(b).topRows(info()[b].dim()) =
161  info()[b].inv_basis() *
162  _standard_values.block(0, b * n_vol(), m_vals.rows(), n_vol());
163 }
164 
172  Index rows = m_info.front().basis().rows();
173  Eigen::MatrixXd result(rows, m_vals.cols());
174  for (Index b = 0; b < n_sublat(); ++b) {
175  result.block(0, b * n_vol(), rows, n_vol()) =
176  info()[b].basis() * sublat(b).topRows(info()[b].dim());
177  }
178  return result;
179 }
180 
192  return m_vals.col(l);
193 }
194 
206  return m_vals.col(l);
207 }
208 
212  return m_vals.block(0, b * n_vol(), m_vals.rows(), n_vol());
213 }
214 
218  return m_vals.block(0, b * n_vol(), m_vals.rows(), n_vol());
219 }
220 
222 std::vector<DoFSetInfo> const &LocalContinuousConfigDoFValues::info() const {
223  return m_info;
224 }
225 
227  Eigen::Ref<ValueType const> const &_values) const {
228  if (_values.rows() != dim() || _values.cols() != n_vol() * n_sublat()) {
229  std::stringstream msg;
230  msg << "Invalid size in LocalContinuousConfigDoFValues: "
231  << "Expected rows=" << dim() << ", received rows=" << _values.rows()
232  << ", expected cols=" << n_vol() * n_sublat()
233  << ", received cols=" << _values.cols();
234  throw std::runtime_error(msg.str());
235  }
236 }
237 
239  DoF::BasicTraits const &_traits, Index _n_sublat, Index _n_vol,
240  DoFSetInfo const &_info)
241  : ConfigDoFValues(_traits, _n_sublat, _n_vol),
242  m_info(_info),
243  m_vals(Eigen::VectorXd::Zero(m_info.dim())) {
245 }
246 
249 
255  Eigen::Ref<const Eigen::MatrixXd> const &_values) {
256  _throw_if_invalid_size(_values);
257  m_vals = _values;
258 }
259 
262 
265  return m_vals;
266 }
267 
275  Eigen::Ref<const Eigen::MatrixXd> const &_standard_values) {
276  if (_standard_values.size() != m_info.basis().rows()) {
277  std::stringstream msg;
278  msg << "Invalid standard values input size in "
279  "GlobalContinuousConfigDoFValues: "
280  << "Expected size=" << m_info.basis().rows()
281  << ", received size=" << _standard_values.size();
282  throw std::runtime_error(msg.str());
283  }
284  m_vals = info().inv_basis() * _standard_values;
285 }
286 
295  return m_info.basis() * m_vals;
296 }
297 
300  return m_info;
301 }
302 
304  Eigen::Ref<ValueType const> const &_values) const {
305  if (_values.size() != m_info.basis().cols()) {
306  std::stringstream msg;
307  msg << "Invalid size in LocalContinuousConfigDoFValues: "
308  << "Expected size=" << m_info.basis().cols()
309  << ", received size=" << _values.size();
310  throw std::runtime_error(msg.str());
311  }
312 }
313 
314 } // namespace CASM
Specifies traits of (possibly) anisotropic crystal properties.
std::string const & type_name() const
ConfigDoFValues(DoF::BasicTraits const &_traits, Index _n_sublat, Index _n_vol)
Eigen::MatrixXd standard_values() const
Get global DoF values as standard DoF values.
GlobalContinuousConfigDoFValues(DoF::BasicTraits const &_traits, Index _n_sublat, Index _n_vol, DoFSetInfo const &_info)
void from_standard_values(Eigen::Ref< const Eigen::MatrixXd > const &_standard_values)
Set global DoF values from standard DoF values.
void _throw_if_invalid_size(Eigen::Ref< ValueType const > const &_values) const
Eigen::VectorXd const & values() const
Const access global DoF values.
Index dim() const
Global DoF vector representation dimension.
void setZero()
Set DoF values to zero.
DoFSetInfo const & info() const
DoFSetInfo provides the basis and symmetry representations for values
void set_values(Eigen::Ref< const Eigen::MatrixXd > const &_values)
Set global DoF values.
std::vector< DoFSetInfo > const & info() const
DoFSetInfo provides the basis and symmetry representations for values
SiteReference site_value(Index l)
Access site DoF value vector.
Index dim() const
maximum DoF vector representation size (max of DoFSetInfo::dim())
const Eigen::Block< const ValueType > ConstSublatReference
static Index matrix_dim(std::vector< DoFSetInfo > const &_info)
local continuous DoF values matrix has #rows == max( DoFSetInfo::dim() )
void from_standard_values(Eigen::Ref< const Eigen::MatrixXd > const &_standard_values)
Set local DoF values from standard DoF values.
std::vector< DoFSetInfo > m_info
void _throw_if_invalid_size(Eigen::Ref< ValueType const > const &_values) const
Eigen::Block< ValueType > SublatReference
LocalContinuousConfigDoFValues(DoF::BasicTraits const &_traits, Index _n_sublat, Index _n_vol, std::vector< DoFSetInfo > const &_info)
const ValueType::ConstColXpr ConstSiteReference
void set_values(Eigen::Ref< const ValueType > const &_values)
Access site DoF values (prim DoF basis, matrix representing all sites)
SublatReference sublat(Index b)
Access matrix block of values for all sites on one sublattice.
Eigen::MatrixXd const & values() const
Const access DoF values (prim DoF basis, matrix representing all sites)
void setZero()
Set DoF values to zero.
Eigen::MatrixXd standard_values() const
Get local DoF values as standard DoF values.
std::vector< SymGroupRepID > const & symrep_IDs() const
ValueType::ConstSegmentReturnType ConstSublatReference
int & occ(Index i)
Reference occupation value on site i.
std::vector< SymGroupRepID > m_symrep_IDs
LocalDiscreteConfigDoFValues(DoF::BasicTraits const &_traits, Index _n_sublat, Index _n_vol, std::vector< SymGroupRepID > const &_symrep_IDs)
Eigen::VectorXi const & values() const
SublatReference sublat(Index b)
Access vector block of values for all sites on one sublattice.
void _throw_if_invalid_size(Eigen::Ref< ValueType const > const &_values) const
ValueType::SegmentReturnType SublatReference
void set_values(Eigen::Ref< ValueType const > const &_values)
Set occupation values (values are indices into Site::occupant_dof())
void setZero()
Set occupation values to zero.
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
GenericDatumFormatter< std::string, DataObject > name()
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd
T max(const T &A, const T &B)
Definition: CASM_math.hh:95
Eigen::MatrixXd const & inv_basis() const
Definition: DoFSet.hh:107
Eigen::MatrixXd const & basis() const
Definition: DoFSet.hh:72