Commit 04924b21 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

started with space groups

parent 1ef8a369
...@@ -196,4 +196,46 @@ load_cif(const std::string& filename) ...@@ -196,4 +196,46 @@ load_cif(const std::string& filename)
return std::make_tuple(nullptr, atoms, generatedatoms, atomnames, latt); return std::make_tuple(nullptr, atoms, generatedatoms, atomnames, latt);
} }
/**
* gets space group description strings and symmetry operations
*/
template<class t_mat, class t_real = typename t_mat::value_type>
std::vector<std::tuple<int, std::string, std::vector<t_mat>>>
get_sgs()
{
std::vector<std::tuple<int, std::string, std::vector<t_mat>>> sgs;
for(const auto &sg : gemmi::spacegroup_tables::main)
{
std::ostringstream ostrDescr;
ostrDescr << "#" << sg.number << ": " << sg.hm << " (" << sg.hall << ")";
std::vector<t_mat> ops;
for(const auto &op : sg.operations().all_ops_sorted())
{
auto M = op.float_seitz();
t_mat mat = m::create<t_mat>({
std::get<0>(std::get<0>(M)), std::get<1>(std::get<0>(M)), std::get<2>(std::get<0>(M)), std::get<3>(std::get<0>(M)),
std::get<0>(std::get<1>(M)), std::get<1>(std::get<1>(M)), std::get<2>(std::get<1>(M)), std::get<3>(std::get<1>(M)),
std::get<0>(std::get<2>(M)), std::get<1>(std::get<2>(M)), std::get<2>(std::get<2>(M)), std::get<3>(std::get<2>(M)),
std::get<0>(std::get<3>(M)), std::get<1>(std::get<3>(M)), std::get<2>(std::get<3>(M)), std::get<3>(std::get<3>(M)) });
ops.emplace_back(std::move(mat));
}
sgs.emplace_back(std::make_tuple(sg.number, ostrDescr.str(), ops));
}
std::stable_sort(sgs.begin(), sgs.end(), [](const auto& sg1, const auto& sg2) -> bool
{
return std::get<0>(sg1) < std::get<0>(sg2);
});
return sgs;
}
#endif #endif
...@@ -116,6 +116,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -116,6 +116,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
QToolButton *pTabBtnSave = new QToolButton(m_nucleipanel); QToolButton *pTabBtnSave = new QToolButton(m_nucleipanel);
QToolButton *pTabBtnImportCIF = new QToolButton(m_nucleipanel); QToolButton *pTabBtnImportCIF = new QToolButton(m_nucleipanel);
QToolButton *pTabBtn3DView = new QToolButton(m_nucleipanel); QToolButton *pTabBtn3DView = new QToolButton(m_nucleipanel);
QToolButton *pTabBtnSG = new QToolButton(m_nucleipanel);
m_nuclei->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Expanding}); m_nuclei->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Expanding});
pTabBtnAdd->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed}); pTabBtnAdd->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
...@@ -126,6 +127,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -126,6 +127,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
pTabBtnSave->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed}); pTabBtnSave->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnImportCIF->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed}); pTabBtnImportCIF->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtn3DView->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed}); pTabBtn3DView->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnSG->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnAdd->setText("Add Nucleus"); pTabBtnAdd->setText("Add Nucleus");
pTabBtnDel->setText("Delete Nuclei"); pTabBtnDel->setText("Delete Nuclei");
...@@ -135,6 +137,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -135,6 +137,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
pTabBtnSave->setText("Save..."); pTabBtnSave->setText("Save...");
pTabBtnImportCIF->setText("Import CIF..."); pTabBtnImportCIF->setText("Import CIF...");
pTabBtn3DView->setText("3D View..."); pTabBtn3DView->setText("3D View...");
pTabBtnSG->setText("Generate");
m_editA = new QLineEdit("5", m_nucleipanel); m_editA = new QLineEdit("5", m_nucleipanel);
...@@ -144,6 +147,15 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -144,6 +147,15 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
m_editBeta = new QLineEdit("90", m_nucleipanel); m_editBeta = new QLineEdit("90", m_nucleipanel);
m_editGamma = new QLineEdit("90", m_nucleipanel); m_editGamma = new QLineEdit("90", m_nucleipanel);
m_comboSG = new QComboBox(m_nucleipanel);
// get space groups and symops
for(auto [sgnum, descr, ops] : get_sgs<t_mat>())
{
m_comboSG->addItem(descr.c_str(), m_comboSG->count());
}
auto pTabGrid = new QGridLayout(m_nucleipanel); auto pTabGrid = new QGridLayout(m_nucleipanel);
pTabGrid->setSpacing(2); pTabGrid->setSpacing(2);
...@@ -160,6 +172,11 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -160,6 +172,11 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
pTabGrid->addWidget(pTabBtnImportCIF, y,2,1,1); pTabGrid->addWidget(pTabBtnImportCIF, y,2,1,1);
pTabGrid->addWidget(pTabBtn3DView, y,3,1,1); pTabGrid->addWidget(pTabBtn3DView, y,3,1,1);
pTabGrid->addWidget(new QLabel("Space Groups:"), ++y,0,1,1);
pTabGrid->addWidget(m_comboSG, y,1,1,2);
pTabGrid->addWidget(pTabBtnSG, y,3,1,1);
auto sep1 = new QFrame(m_nucleipanel); sep1->setFrameStyle(QFrame::HLine); auto sep1 = new QFrame(m_nucleipanel); sep1->setFrameStyle(QFrame::HLine);
pTabGrid->addWidget(sep1, ++y,0, 1,4); pTabGrid->addWidget(sep1, ++y,0, 1,4);
...@@ -199,6 +216,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -199,6 +216,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
connect(pTabBtnLoad, &QToolButton::clicked, this, &StructFactDlg::Load); connect(pTabBtnLoad, &QToolButton::clicked, this, &StructFactDlg::Load);
connect(pTabBtnSave, &QToolButton::clicked, this, &StructFactDlg::Save); connect(pTabBtnSave, &QToolButton::clicked, this, &StructFactDlg::Save);
connect(pTabBtnImportCIF, &QToolButton::clicked, this, &StructFactDlg::ImportCIF); connect(pTabBtnImportCIF, &QToolButton::clicked, this, &StructFactDlg::ImportCIF);
connect(pTabBtnSG, &QToolButton::clicked, this, &StructFactDlg::GenerateFromSG);
connect(pTabBtn3DView, &QToolButton::clicked, this, [this]() connect(pTabBtn3DView, &QToolButton::clicked, this, [this]()
{ {
// plot widget // plot widget
...@@ -881,6 +899,14 @@ void StructFactDlg::ImportCIF() ...@@ -881,6 +899,14 @@ void StructFactDlg::ImportCIF()
/**
* generate symmetric nuclei from space group
*/
void StructFactDlg::GenerateFromSG()
{
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** /**
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <QtWidgets/QSpinBox> #include <QtWidgets/QSpinBox>
#include <QtWidgets/QMenu> #include <QtWidgets/QMenu>
#include <QtWidgets/QLabel> #include <QtWidgets/QLabel>
#include <QtWidgets/QComboBox>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <vector> #include <vector>
...@@ -96,6 +97,8 @@ protected: ...@@ -96,6 +97,8 @@ protected:
QLineEdit *m_editBeta = nullptr; QLineEdit *m_editBeta = nullptr;
QLineEdit *m_editGamma = nullptr; QLineEdit *m_editGamma = nullptr;
QComboBox *m_comboSG = nullptr;
QSpinBox *m_maxBZ = nullptr; QSpinBox *m_maxBZ = nullptr;
QMenu *m_pTabContextMenu = nullptr; // menu in case a nucleus is selected QMenu *m_pTabContextMenu = nullptr; // menu in case a nucleus is selected
...@@ -119,6 +122,7 @@ protected: ...@@ -119,6 +122,7 @@ protected:
void Load(); void Load();
void Save(); void Save();
void ImportCIF(); void ImportCIF();
void GenerateFromSG();
std::vector<NuclPos> GetNuclei() const; std::vector<NuclPos> GetNuclei() const;
void Calc(); void Calc();
......
...@@ -87,7 +87,7 @@ int main(int argc, char** argv) ...@@ -87,7 +87,7 @@ int main(int argc, char** argv)
for(std::size_t row=0; row<colSym.length(); ++row) for(std::size_t row=0; row<colSym.length(); ++row)
std::cout << colSym[row] << ": " << colX[row] << ", " << colY[row] << ", " << colZ[row] << std::endl; std::cout << colSym[row] << ": " << colX[row] << ", " << colY[row] << ", " << colZ[row] << std::endl;
} }
std::cout << std::endl; std::cout << std::endl;
......
/**
* space group test
* @author Tobias Weber <tweber@ill.fr>
* @date jan-19
* @license GPLv3, see 'LICENSE' file
*
* clang++ -std=c++17 -o sg sg.cpp -I../../ext/gemmi/include/gemmi -I../../ext/gemmi/third_party
*/
#include <string>
#include <iostream>
#include <symmetry.hpp>
int main()
{
// testing space group
for(const auto &sg : gemmi::spacegroup_tables::main)
{
auto ops = sg.operations().all_ops_sorted();
std::cout << "SG #" << sg.number << ", HM: " << sg.hm << ", Hall: " << sg.hall
<< ", Qualifier: " << sg.qualifier << ", Ext: " << sg.ext
<< ", Op count: " << ops.size() << std::endl;
/*for(const auto &op : ops)
{
auto M = op.float_seitz();
}*/
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment