void CState::makeAtoms(ivec3 N, vec3 L, mat r, double sites_per_cell, string atomType) { cout << "CState::makeAtoms" << endl; vec3 cellPos; atoms = vector<CAtom*>(); atoms.reserve(nAtoms); // don't want resize, since we're using "push_back" to add item for (int ix = 0; ix < N(0); ix++) { for (int iy = 0; iy < N(1); iy++) { for (int iz = 0; iz < N(2); iz++) { for (int i = 0; i < sites_per_cell; i++) { CAtom* atom = new CAtom; cellPos << L(0)*ix << L(1)*iy << L(2)*iz; atom->setPosition(cellPos + r.row(i).t()); atom->setAtomType(atomType); if (atom->matrixAtom) { nMatrixAtoms++; atoms.push_back(atom); } else { nMovingAtoms++; movingAtoms.push_back(atom); atoms.push_back(atom); } } } } } cout << "Exiting CState::makeAtoms" << endl; }