| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
It links to the Open Babel library, which is released under the GNU GPL v2. |
| 5 |
******************************************************************************/ |
| 6 |
|
| 7 |
#ifndef AVOGADRO_QTPLUGINS_OBENERGY_H |
| 8 |
#define AVOGADRO_QTPLUGINS_OBENERGY_H |
| 9 |
|
| 10 |
#include <avogadro/calc/energycalculator.h> |
| 11 |
|
| 12 |
#include <avogadro/core/avogadrocore.h> |
| 13 |
|
| 14 |
#include <QtCore/QCoreApplication> |
| 15 |
#include <QtCore/QString> |
| 16 |
|
| 17 |
namespace Avogadro { |
| 18 |
|
| 19 |
namespace QtPlugins { |
| 20 |
|
| 21 |
class OBEnergy : public Avogadro::Calc::EnergyCalculator |
| 22 |
{ |
| 23 |
Q_DECLARE_TR_FUNCTIONS(OBEnergy) |
| 24 |
|
| 25 |
public: |
| 26 |
OBEnergy(const std::string& method = ""); |
| 27 |
~OBEnergy() override; |
| 28 |
|
| 29 |
std::string method() const { return m_identifier; } |
| 30 |
void setupProcess(); |
| 31 |
|
| 32 |
Calc::EnergyCalculator* newInstance() const override; |
| 33 |
|
| 34 |
std::string identifier() const override { return m_identifier; } |
| 35 |
std::string name() const override { return m_name; } |
| 36 |
std::string description() const override |
| 37 |
{ |
| 38 |
return m_description.toStdString(); |
| 39 |
} |
| 40 |
|
| 41 |
Core::Molecule::ElementMask elements() const override { return (m_elements); } |
| 42 |
|
| 43 |
// This will check if the molecule is valid for this script |
| 44 |
// and then start the external process |
| 45 |
void setMolecule(Core::Molecule* mol) override; |
| 46 |
// energy |
| 47 |
Real value(const Eigen::VectorXd& x) override; |
| 48 |
// gradient (which may be unsupported and fall back to numeric) |
| 49 |
void gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad) override; |
| 50 |
Real evaluate(const Eigen::VectorXd& x, Eigen::VectorXd* grad) override; |
| 51 |
|
| 52 |
bool acceptsIons() const override { return true; } |
| 53 |
// UFF can handle radicals |
| 54 |
bool acceptsRadicals() const override; |
| 55 |
|
| 56 |
private: |
| 57 |
class Private; |
| 58 |
|
| 59 |
Core::Molecule* m_molecule; |
| 60 |
Private* d; |
| 61 |
|
| 62 |
Core::Molecule::ElementMask m_elements; |
| 63 |
std::string m_identifier; |
| 64 |
std::string m_name; |
| 65 |
QString m_description; |
| 66 |
}; |
| 67 |
|
| 68 |
} // namespace QtPlugins |
| 69 |
} // namespace Avogadro |
| 70 |
|
| 71 |
#endif // AVOGADRO_QTPLUGINS_OBENERGY_H |