25 Lattice2D::Lattice2D(
const NodeMeta& meta, 
const std::vector<double>& PValues)
 
   26     : 
INode(meta, PValues)
 
   30 Lattice2D::Lattice2D(
double xi) : m_xi(xi)
 
   32     registerParameter(
"Xi", &m_xi).setUnit(
"rad");
 
   37     const double sinalpha = std::sin(latticeAngle());
 
   38     const double ainv = M_TWOPI / length1() / sinalpha;
 
   39     const double binv = M_TWOPI / length2() / sinalpha;
 
   40     const double xi = rotationAngle();
 
   41     const double xialpha = xi + latticeAngle();
 
   43     return {+ainv * std::sin(xialpha), -ainv * std::cos(xialpha), -binv * std::sin(xi),
 
   44             +binv * std::cos(xi)};
 
   53 void Lattice2D::setRotationEnabled(
bool enabled) 
 
   58         registerParameter(
"Xi", &m_xi).setUnit(
"rad");
 
   60         removeParameter(
"Xi");
 
   68 BasicLattice::BasicLattice(
double length1, 
double length2, 
double angle, 
double xi)
 
   69     : 
Lattice2D(xi), m_length1(length1), m_length2(length2), m_angle(angle)
 
   71     if (m_length1 <= 0.0 || m_length2 <= 0.0)
 
   72         throw std::runtime_error(
"BasicLattice::BasicLattice() -> Error. Lattice length can't be " 
   75     setName(
"BasicLattice");
 
   76     registerParameter(
"LatticeLength1", &m_length1).setUnit(
"nm").setPositive();
 
   77     registerParameter(
"LatticeLength2", &m_length2).setUnit(
"nm").setPositive();
 
   78     registerParameter(
"Alpha", &m_angle).setUnit(
"rad");
 
   83     return new BasicLattice(m_length1, m_length2, m_angle, m_xi);
 
   86 double BasicLattice::unitCellArea()
 const 
   88     return std::abs(m_length1 * m_length2 * std::sin(m_angle));
 
   95 SquareLattice::SquareLattice(
double length, 
double xi) : 
Lattice2D(xi), m_length(length)
 
   98         throw std::runtime_error(
"SquareLattice::SquareLattice() -> Error. Lattice length can't be " 
  101     setName(
"SquareLattice");
 
  102     registerParameter(
"LatticeLength", &m_length).setUnit(
"nm").setPositive();
 
  110 double SquareLattice::latticeAngle()
 const 
  115 double SquareLattice::unitCellArea()
 const 
  117     return std::abs(m_length * m_length);
 
  124 HexagonalLattice::HexagonalLattice(
double length, 
double xi) : 
Lattice2D(xi), m_length(length)
 
  127         throw std::runtime_error(
"HexagonalLattice::HexagonalLattice() -> Error. " 
  128                                  "Lattice length can't be negative or zero.");
 
  130     setName(
"HexagonalLattice");
 
  131     registerParameter(
"LatticeLength", &m_length).setUnit(
"nm").setPositive();
 
  139 double HexagonalLattice::latticeAngle()
 const 
  141     return M_TWOPI / 3.0;
 
  144 double HexagonalLattice::unitCellArea()
 const 
  146     static const double sinval = std::sin(latticeAngle());
 
  147     return std::abs(m_length * m_length * sinval);
 
Defines classes of Lattice2D family.
 
Defines M_PI and some more mathematical constants.
 
Defines class ParameterPool.
 
Defines class RealParameter.
 
Base class for tree-like structures containing parameterized objects.
 
RealParameter * parameter(const std::string &name) const
Returns parameter with given 'name'.
 
virtual void onChange()
Action to be taken in inherited class when a parameter has changed.
 
virtual void onChange()
Action to be taken in inherited class when a parameter has changed.