CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigIOStrain.hh
Go to the documentation of this file.
1 #ifndef CONFIGIOSTRAIN_HH
2 #define CONFIGIOSTRAIN_HH
3 
5 #include "casm/clex/PrimClex.hh"
8 
9 namespace CASM {
10 
11 class Configuration;
12 
13 namespace ConfigIO {
14 
32 class RelaxationStrain : public VectorXdAttribute<Configuration> {
33  public:
36  "relaxation_strain",
37  "The strain of the configuration due to relaxation, measured "
38  "relative to ideal lattice vectors."
39  "Ordered as [E(0,0), E(1,1), E(2,2), E(1,2), E(0,2), E(0,1)]. "
40  "Accepts strain convention as first argument ('GL' "
41  "[Green-Lagrange, Default], 'EA' [Euler-Almansi],"
42  "'B' [Biot], 'H' [Hencky], or 'U' [stretch tensor]). Accepts index "
43  "as second argument on interval [0,5]. Accepts calctype as third "
44  "argument."),
45  m_straincalc("GL"){};
46 
47  // --- Required implementations -----------
48 
49  std::unique_ptr<RelaxationStrain> clone() const {
50  return std::unique_ptr<RelaxationStrain>(this->_clone());
51  }
52 
53  Eigen::VectorXd evaluate(const Configuration &_config) const override;
54 
55  // --- Specialized implementation -----------
56 
57  bool init(const Configuration &_tmplt) const override;
58 
59  bool validate(const Configuration &_config) const override;
60 
61  std::string short_header(const Configuration &_config) const override;
62 
63  std::vector<std::string> col_header(
64  const Configuration &_config) const override;
65  /*
66  void inject(const Configuration &_config, DataStream &_stream, Index)
67  const override;
68 
69  void print(const Configuration &_config, std::ostream &_stream, Index)
70  const override;
71 
72  jsonParser &to_json(const Configuration &_config, jsonParser &json)const
73  override;
74  */
75  bool parse_args(const std::string &args) override;
76 
77  protected:
79  mutable std::string m_metric_name;
80  mutable std::string m_calctype;
81 
82  private:
84  RelaxationStrain *_clone() const override {
85  return new RelaxationStrain(*this);
86  }
87 };
88 
105 class DoFStrain : public VectorXdAttribute<Configuration> {
106  public:
107  DoFStrain(std::string _metric = "GL")
109  "dof_strain",
110  "The imposed strain of the configuration due to relaxation, "
111  "measured relative to ideal lattice vectors. Ordered as"
112  "[E(0,0), E(1,1), E(2,2), E(1,2), E(0,2), E(0,1)]. Accepts strain "
113  "convention as first argument ('GL' [Green-Lagrange, Default], "
114  "'EA' [Euler-Almansi],"
115  "'B' [Biot], 'H' [Hencky], or 'U' [stretch tensor]). Accepts index "
116  "as second argument on interval [0,5]."),
117  m_straincalc(_metric),
118  m_metric_name(_metric){};
119 
120  // --- Required implementations -----------
121 
122  std::unique_ptr<DoFStrain> clone() const {
123  return std::unique_ptr<DoFStrain>(this->_clone());
124  }
125 
126  Eigen::VectorXd evaluate(const Configuration &_config) const override;
127 
128  // --- Specialized implementation -----------
129 
130  bool init(const Configuration &_tmplt) const override;
131 
132  std::string short_header(const Configuration &_config) const override;
133 
134  std::vector<std::string> col_header(
135  const Configuration &_config) const override;
136  /*
137  void inject(const Configuration &_config, DataStream &_stream, Index)
138  const override;
139 
140  void print(const Configuration &_config, std::ostream &_stream, Index)
141  const override;
142 
143  jsonParser &to_json(const Configuration &_config, jsonParser &json)const
144  override;
145  */
146  bool parse_args(const std::string &args) override;
147 
148  protected:
150  mutable std::string m_metric_name;
151 
152  // Hold a StrainConverter set to the prim's strain metric
154 
155  // Hold a shared_ptr to the prim referred to by m_prim_straincalc
156  mutable std::shared_ptr<Structure const> m_shared_prim;
157 
158  // Hold the strain dof key for m_shared_prim
159  mutable DoFKey m_dof_key;
160 
161  private:
163  DoFStrain *_clone() const override { return new DoFStrain(*this); }
164 };
165 
166 } // namespace ConfigIO
167 } // namespace CASM
168 #endif
Abstract base class for creating 1D DatumFormatter.
The strain DoF value of the configuration.
StrainConverter m_straincalc
std::unique_ptr< DoFStrain > clone() const
std::vector< std::string > col_header(const Configuration &_config) const override
bool init(const Configuration &_tmplt) const override
notstd::cloneable_ptr< StrainConverter > m_prim_straincalc
Eigen::VectorXd evaluate(const Configuration &_config) const override
bool parse_args(const std::string &args) override
Default implementation calls _parse_index_expression.
std::string short_header(const Configuration &_config) const override
DoFStrain(std::string _metric="GL")
DoFStrain * _clone() const override
Clone.
std::shared_ptr< Structure const > m_shared_prim
The strain of the configuration due to relaxation, measured relative to ideal lattice vectors.
bool parse_args(const std::string &args) override
Default implementation calls _parse_index_expression.
std::unique_ptr< RelaxationStrain > clone() const
std::string short_header(const Configuration &_config) const override
RelaxationStrain * _clone() const override
Clone.
bool validate(const Configuration &_config) const override
Eigen::VectorXd evaluate(const Configuration &_config) const override
std::vector< std::string > col_header(const Configuration &_config) const override
bool init(const Configuration &_tmplt) const override
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
Main CASM namespace.
Definition: APICommand.hh:8
std::string DoFKey
Definition: DoFDecl.hh:7
Eigen::VectorXd VectorXd