Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added yaehmop with band structure calc #339

Merged
merged 19 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion avogadro/core/avospglib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C" {
namespace Avogadro {
namespace Core {

unsigned short AvoSpglib::getHallNumber(const Molecule& mol, double cartTol)
unsigned short AvoSpglib::getHallNumber(Molecule& mol, double cartTol)
{
if (!mol.unitCell())
return 0;
Expand Down Expand Up @@ -80,6 +80,7 @@ unsigned short AvoSpglib::getHallNumber(const Molecule& mol, double cartTol)
delete[] positions;
delete[] types;

mol.setHallNumber(hallNumber);
return hallNumber;
}

Expand Down Expand Up @@ -175,6 +176,9 @@ bool AvoSpglib::standardizeCell(Molecule& mol, double cartTol, bool toPrimitive,

// Set the new molecule
mol = newMol;

// Set the space group in the molecule
getHallNumber(mol, cartTol);
return true;
}

Expand Down
10 changes: 9 additions & 1 deletion avogadro/core/avospglib.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ class AVOGADROCORE_EXPORT AvoSpglib
* Use spglib to find the Hall number for a crystal. If the unit cell does not
* exist or if the algorithm fails, 0 will be returned.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be handled.
* @param cartTol The cartesian tolerance for spglib.
* @return The Hall number for the crystal.
*/
static unsigned short getHallNumber(const Molecule& mol,
static unsigned short getHallNumber(Molecule& mol,
double cartTol = 1e-5);

/**
* Use spglib to reduce the crystal to a primitive cell. Unless the molecule
* is missing its unit cell, it will be edited by spglib. Positions are
* not idealized.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be reduced to its primitive cell.
* @param cartTol The cartesian tolerance for spglib.
* @return False if the molecule has no unit cell or if the
Expand All @@ -62,6 +66,8 @@ class AVOGADROCORE_EXPORT AvoSpglib
* molecule is missing its unit cell, it will be edited by spglib. Positions
* are idealized.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be conventionalized.
* @param cartTol The cartesian tolerance for spglib.
* @return False if the molecule has no unit cell or if the
Expand All @@ -74,6 +80,8 @@ class AVOGADROCORE_EXPORT AvoSpglib
* its unit cell, it will be edited by spglib. It will be reduced
* to its primitive form, and positions will be idealized.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be conventionalized.
* @param cartTol The cartesian tolerance for spglib.
* @return False if the molecule has no unit cell or if the
Expand Down
12 changes: 12 additions & 0 deletions avogadro/core/molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,15 @@ class AVOGADROCORE_EXPORT Molecule
const UnitCell* unitCell() const { return m_unitCell; }
/** @} */

/**
* The space group for this molecule. It is updated after every
* space group operation.
* @{
*/
void setHallNumber(unsigned short hallNumber) { m_hallNumber = hallNumber; }
unsigned short hallNumber() const { return m_hallNumber; }
/** @} */

Array<double> vibrationFrequencies() const;
void setVibrationFrequencies(const Array<double>& freq);
Array<double> vibrationIntensities() const;
Expand Down Expand Up @@ -676,6 +685,9 @@ class AVOGADROCORE_EXPORT Molecule
UnitCell* m_unitCell;
Array<Residue> m_residues;

// This will be stored from the last space group operation
unsigned short m_hallNumber = 0;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cryos
What do you think about initializing class members at their declaration like this?

Personally, I think it is a nice addition in C++11, since it allows for a default value for all constructors that can be overridden (if desired) by a constructor's member initializer list.


/** Update the graph to correspond to the current molecule. */
void updateGraph() const;
};
Expand Down
4 changes: 4 additions & 0 deletions avogadro/qtplugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ add_subdirectory(surfaces)
add_subdirectory(spectra)
add_subdirectory(vrml)

# Plugins that require VTK
if(USE_VTK)
add_subdirectory(plotpdf)
add_subdirectory(plotrmsd)
add_subdirectory(plotxrd)
if(BUILD_YAEHMOP_PLUGIN)
add_subdirectory(yaehmop)
endif()
add_subdirectory(coloropacitymap)
endif()

Expand Down
22 changes: 22 additions & 0 deletions avogadro/qtplugins/yaehmop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

set(yaehmop_srcs
banddialog.cpp
specialkpoints.cpp
yaehmop.cpp
yaehmopout.cpp
)

set(yaehmop_uis
banddialog.ui
)

avogadro_plugin(Yaehmop
"Use yaehmop to perform extended Hückel calculations."
ExtensionPlugin
yaehmop.h
Yaehmop
"${yaehmop_srcs}"
"${yaehmop_uis}"
)

target_link_libraries(Yaehmop LINK_PRIVATE AvogadroVtk)
71 changes: 71 additions & 0 deletions avogadro/qtplugins/yaehmop/banddialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/******************************************************************************

This source file is part of the Avogadro project.

Copyright 2018 Kitware, Inc.

This source code is released under the New BSD License, (the "License").

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

******************************************************************************/

#include "banddialog.h"
#include "ui_banddialog.h"

#include <QSettings>

namespace Avogadro {
namespace QtPlugins {

BandDialog::BandDialog(QWidget* aParent, YaehmopSettings& yaehmopSettings)
: QDialog(aParent), m_ui(new Ui::BandDialog),
m_yaehmopSettings(yaehmopSettings)
{
m_ui->setupUi(this);
}

BandDialog::~BandDialog() = default;

int BandDialog::exec()
{
// Load the settings then exec
m_ui->spin_numKPoints->setValue(m_yaehmopSettings.numBandKPoints);
m_ui->edit_specialKPoints->setText(m_yaehmopSettings.specialKPoints);
m_ui->cb_displayYaehmopInput->setChecked(
m_yaehmopSettings.displayYaehmopInput);
m_ui->cb_limitY->setChecked(m_yaehmopSettings.limitY);
m_ui->spin_minY->setValue(m_yaehmopSettings.minY);
m_ui->spin_maxY->setValue(m_yaehmopSettings.maxY);
m_ui->cb_plotFermi->setChecked(m_yaehmopSettings.plotFermi);
m_ui->spin_fermi->setValue(m_yaehmopSettings.fermi);
m_ui->cb_zeroFermi->setChecked(m_yaehmopSettings.zeroFermi);
m_ui->spin_numDim->setValue(m_yaehmopSettings.numDim);

return QDialog::exec();
}

void BandDialog::accept()
{
// Save the settings and accept
m_yaehmopSettings.numBandKPoints = m_ui->spin_numKPoints->value();
m_yaehmopSettings.specialKPoints = m_ui->edit_specialKPoints->toPlainText();
m_yaehmopSettings.displayYaehmopInput =
m_ui->cb_displayYaehmopInput->isChecked();
m_yaehmopSettings.limitY = m_ui->cb_limitY->isChecked();
m_yaehmopSettings.minY = m_ui->spin_minY->value();
m_yaehmopSettings.maxY = m_ui->spin_maxY->value();
m_yaehmopSettings.plotFermi = m_ui->cb_plotFermi->isChecked();
m_yaehmopSettings.fermi = m_ui->spin_fermi->value();
m_yaehmopSettings.zeroFermi = m_ui->cb_zeroFermi->isChecked();
m_yaehmopSettings.numDim = m_ui->spin_numDim->value();

QDialog::accept();
}

} // namespace QtPlugins
} // namespace Avogadro
57 changes: 57 additions & 0 deletions avogadro/qtplugins/yaehmop/banddialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/******************************************************************************

This source file is part of the Avogadro project.

Copyright 2018 Kitware, Inc.

This source code is released under the New BSD License, (the "License").

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

******************************************************************************/

#ifndef AVOGADRO_QTPLUGINS_YAEHMOPBANDDIALOG_H
#define AVOGADRO_QTPLUGINS_YAEHMOPBANDDIALOG_H

#include <memory>

#include <QDialog>

#include "yaehmopsettings.h"

namespace Avogadro {
namespace QtPlugins {

namespace Ui {
class BandDialog;
}

/**
* @brief Dialog to perform a band structure calculation with yaehmop.
*/
class BandDialog : public QDialog
{
Q_OBJECT

public:
explicit BandDialog(QWidget* parent, YaehmopSettings& yaehmopSettings);
~BandDialog();

public slots:
int exec() override;

protected slots:
void accept() override;

private:
std::unique_ptr<Ui::BandDialog> m_ui;
YaehmopSettings& m_yaehmopSettings;
};

} // namespace QtPlugins
} // namespace Avogadro
#endif // AVOGADRO_QTPLUGINS_YAEHMOPBANDDIALOG_H
Loading