/** * @file AtomsGenerator.cpp * @author jun * @brief AtomsGenerator definitions * @version 0.1 * @date 2023-08-05 * * Copyright (c) 2023 jun * */ #include #include "AtomsGenerator.hpp" std::vector generateFCCAtoms(double latticeConstant, std::size_t numberOfCells) { // Check for invalid lattice constants if (latticeConstant <= 0) throw std::invalid_argument("Lattice constant must be positive"); std::vector atoms; // Generate atoms in FCC lattice for (std::size_t i = 0; i < numberOfCells; i++) for (std::size_t j = 0; j < numberOfCells; j++) for (std::size_t k = 0; k < numberOfCells; k++) { atoms.push_back(Atom(i * latticeConstant, j * latticeConstant, k * latticeConstant)); atoms.push_back( Atom((i + 0.5) * latticeConstant, (j + 0.5) * latticeConstant, k * latticeConstant)); atoms.push_back( Atom((i + 0.5) * latticeConstant, j * latticeConstant, (k + 0.5) * latticeConstant)); atoms.push_back( Atom(i * latticeConstant, (j + 0.5) * latticeConstant, (k + 0.5) * latticeConstant)); } // Use std::move to move the vector to the caller return std::move(atoms); } void offsetAtoms(std::vector &atoms, double x, double y, double z) { for (auto &atom : atoms) { atom.x += x; atom.y += y; atom.z += z; } }