Commit 215891e4 by Tobias WEBER

### space group test

parent 8c97e82d
 /** * finds a matching space group * @author Tobias Weber * @date jan-2020 * @license GPLv3, see 'LICENSE' file */ #include "../structfact/loadcif.h" #include "libs/_cxx20/math_algos.h" #include #include #include using t_real = double; using t_vec = std::vector; using t_mat = m::mat; constexpr t_real g_eps = 1e-6; constexpr int g_prec = 6; /** * find matching spacegroup */ std::vector>> find_sgs( const std::vector& vecInit, const std::vector& vecFinal) { return find_matching_sgs(vecInit, vecFinal); } /** * entry point */ int main(int argc, char** argv) { // TODO: read input data // test data std::vector vecInit {{ m::create({ 0.1, 0.1, 0.1}), m::create({ 0.4, -0.1, -0.4}), m::create({-0.1, -0.4, 0.4}), m::create({-0.4, 0.4, -0.1}), }}; std::vector vecFinal {{ m::create({ 0.1, 0.1, 0.1}), m::create({ 0.4, -0.1, -0.4}), m::create({-0.1, -0.4, 0.4}), m::create({-0.4, 0.4, -0.1}), }}; std::cout << "Full set of positions to match:\n"; std::size_t ctr = 1; for(const auto& pos : vecFinal) std::cout << "\t(" << ctr++ << ") " << pos << "\n"; std::cout << std::endl; while(1) { std::cout << "\n--------------------------------------------------------------------------------\n"; std::cout << "Base set of positions:\n"; ctr = 1; for(const auto& pos : vecInit) std::cout << "\t(" << ctr++ << ") " << pos << "\n"; std::cout << std::endl; auto matchingSGs = find_sgs(vecInit, vecFinal); std::cout << "Matching space groups:\n"; ctr = 1; for(const auto& sg : matchingSGs) std::cout << "\t(" << ctr++ << ") " << std::get<1>(sg) << "\n"; std::cout << "--------------------------------------------------------------------------------\n"; std::cout << std::endl; vecInit.pop_back(); if(vecInit.size() == 0) break; } return 0; }
 ... ... @@ -21,7 +21,7 @@ find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL) set(CMAKE_AUTOUIC TRUE) set(CMAKE_AUTOMOC TRUE) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 17) add_definitions(-std=c++2a -fconcepts) add_definitions(\${Boost_CXX_FLAGS}) add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_ERROR_CODE_HEADER_ONLY) ... ...
 ... ... @@ -264,7 +264,11 @@ load_cif(const std::string& filename, t_real eps=1e-6) * gets space group description strings and symmetry operations */ template std::vector>> std::vector // symops >> get_sgs(bool bAddNr=true, bool bAddHall=true) { std::vector>> sgs; ... ... @@ -302,4 +306,54 @@ get_sgs(bool bAddNr=true, bool bAddHall=true) } /** * finds all space groups which transform the initial positions into the final ones */ template std::vector // symops >> find_matching_sgs( const std::vector& posInit, const std::vector& _posFinal, t_real eps=1e-6) { std::vector posFinal = m::keep_atoms_in_uc(_posFinal); std::vector>> matchingSGs; auto sgs = get_sgs(); // iterate spacegroups for(const auto& [sgNum, sgName, sgOps] : sgs) { // generate symmetry-equivalent positions std::vector generatedpos; for(const t_vec& pos : posInit) { std::vector newpos = m::apply_ops_hom(pos, sgOps, eps); generatedpos.insert(generatedpos.end(), newpos.begin(), newpos.end()); } //for(const auto& thepos : generatedpos) // std::cout << thepos << std::endl; // filter multiple occupancies in generatedpos generatedpos = m::remove_duplicates(generatedpos, eps); // no match if(!m::equals_all(generatedpos, posFinal, eps, 3)) continue; matchingSGs.emplace_back(std::make_tuple(sgNum, sgName, sgOps)); } return matchingSGs; } #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!