45#include "lattice/shapedLattice.hpp"
49#include "brains/Register.hpp"
55 shapedLattice::shapedLattice(RealType latticeConstant,
string latticeType) :
56 latticeConstant_(latticeConstant), latticeType_(latticeType) {
58 simpleLattice_ = LatticeFactory::getInstance().createLattice(latticeType);
59 if (simpleLattice_ == NULL) {
60 std::cerr <<
"shapedLattice:: Error creating lattice" << std::endl;
65 std::vector<RealType> lc;
66 lc.push_back(latticeConstant_);
67 simpleLattice_->setLatticeConstant(lc);
68 sitesComputed_ =
false;
71 void shapedLattice::setGridDimension(
Vector3d dimension) {
72 dimension_ = dimension;
74 beginNx_ = -(int)ceil(0.5 * dimension_[0] / latticeConstant_);
75 beginNy_ = -(int)ceil(0.5 * dimension_[1] / latticeConstant_);
76 beginNz_ = -(int)ceil(0.5 * dimension_[2] / latticeConstant_);
77 endNx_ = (int)ceil(0.5 * dimension_[0] / latticeConstant_);
78 endNy_ = (int)ceil(0.5 * dimension_[1] / latticeConstant_);
79 endNz_ = (int)ceil(0.5 * dimension_[2] / latticeConstant_);
80 sitesComputed_ =
false;
83 void shapedLattice::setOrigin(
Vector3d origin) {
85 simpleLattice_->setOrigin(origin_);
86 sitesComputed_ =
false;
89 void shapedLattice::findSites() {
91 orientations_.clear();
93 std::vector<Vector3d> latticePos;
94 std::vector<Vector3d> pointsOrt = simpleLattice_->getLatticePointsOrt();
95 int numMolPerCell = simpleLattice_->getNumSitesPerCell();
97 for (
int i = beginNx_; i <= endNx_; i++) {
98 for (
int j = beginNy_; j <= endNy_; j++) {
99 for (
int k = beginNz_; k <= endNz_; k++) {
101 simpleLattice_->getLatticePointsPos(latticePos, i, j, k);
102 for (
int l = 0; l < numMolPerCell; l++) {
103 if (isInterior(latticePos[l])) {
104 Vector3d myPoint = latticePos[l];
105 Vector3d myOrt = pointsOrt[l];
106 sites_.push_back(myPoint);
107 orientations_.push_back(myOrt);
113 sitesComputed_ =
true;
116 std::vector<Vector3d> shapedLattice::getSites() {
117 if (!sitesComputed_) { findSites(); }
121 std::vector<Vector3d> shapedLattice::getOrientations() {
122 if (!sitesComputed_) { findSites(); }
123 return orientations_;
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
void registerLattice()
Register all lattice.