From ea0679beeb62461b5cdef7b8c2bff2fbcf83a9a7 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 5 Dec 2024 21:32:52 -0500 Subject: [PATCH 1/3] Make sure Lennard Jones is always available Signed-off-by: Geoff Hutchison --- avogadro/calc/lennardjones.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avogadro/calc/lennardjones.h b/avogadro/calc/lennardjones.h index ca31279113..821b6827a4 100644 --- a/avogadro/calc/lennardjones.h +++ b/avogadro/calc/lennardjones.h @@ -35,6 +35,8 @@ class AVOGADROCALC_EXPORT LennardJones : public EnergyCalculator return "Universal Lennard-Jones potential"; } + bool acceptsIons() const override { return true; } + bool acceptsRadicals() const override { return true; } bool acceptsUnitCell() const override { return true; } Core::Molecule::ElementMask elements() const override { return (m_elements); } From 2f301c8a7a96da01df7a0be26a3f82a71e01bf61 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 5 Dec 2024 21:33:10 -0500 Subject: [PATCH 2/3] Work in progress to integrate MatterSim model Signed-off-by: Geoff Hutchison --- avogadro/qtplugins/forcefield/forcefield.cpp | 3 +++ avogadro/qtplugins/forcefield/scriptenergy.cpp | 6 +++++- avogadro/qtplugins/forcefield/scriptenergy.h | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/avogadro/qtplugins/forcefield/forcefield.cpp b/avogadro/qtplugins/forcefield/forcefield.cpp index 70bf78172f..588686aeeb 100644 --- a/avogadro/qtplugins/forcefield/forcefield.cpp +++ b/avogadro/qtplugins/forcefield/forcefield.cpp @@ -492,9 +492,12 @@ void Forcefield::refreshScripts() qDeleteAll(m_scripts); m_scripts.clear(); + qDebug() << " refresh scripts"; + QMultiMap scriptPaths = QtGui::ScriptLoader::scriptList("energy"); foreach (const QString& filePath, scriptPaths) { + qDebug() << "Loading script: " << filePath; auto* model = new ScriptEnergy(filePath); if (model->isValid()) m_scripts.push_back(model); diff --git a/avogadro/qtplugins/forcefield/scriptenergy.cpp b/avogadro/qtplugins/forcefield/scriptenergy.cpp index 293d1cac02..18ada9f171 100644 --- a/avogadro/qtplugins/forcefield/scriptenergy.cpp +++ b/avogadro/qtplugins/forcefield/scriptenergy.cpp @@ -122,8 +122,11 @@ Real ScriptEnergy::value(const Eigen::VectorXd& x) QString::number(x[i + 1]).toUtf8() + " " + QString::number(x[i + 2]).toUtf8() + "\n"; } + qDebug() << " wrote coords "; QByteArray result = m_interpreter->asyncWriteAndResponse(input); + qDebug() << " got result " << result; + // go through lines in result until we see "AvogadroEnergy: " QStringList lines = QString(result).remove('\r').split('\n'); double energy = 0.0; @@ -260,6 +263,7 @@ void ScriptEnergy::readMetaData() .arg(scriptFilePath()) << "\n" << parseError.errorString(); + qWarning() << output; return; } @@ -325,7 +329,7 @@ void ScriptEnergy::readMetaData() m_inputFormat = inputFormatTmp; // check ions, radicals, unit cells - /* + /* e.g., "unitCell": False, "gradients": True, "ion": False, diff --git a/avogadro/qtplugins/forcefield/scriptenergy.h b/avogadro/qtplugins/forcefield/scriptenergy.h index 9aab7bf0a1..3c4a6d5db2 100644 --- a/avogadro/qtplugins/forcefield/scriptenergy.h +++ b/avogadro/qtplugins/forcefield/scriptenergy.h @@ -61,9 +61,9 @@ class ScriptEnergy : public Avogadro::Calc::EnergyCalculator Core::Molecule::ElementMask elements() const override { return m_elements; } bool supportsGradients() const { return m_gradients; } - bool supportsIons() const { return m_ions; } - bool supportsRadicals() const { return m_radicals; } - bool supportsUnitCells() const { return m_unitCells; } + bool acceptsIons() const override { return m_ions; } + bool acceptsRadicals() const override { return m_radicals; } + bool acceptsUnitCell() const override { return m_unitCells; } // This will check if the molecule is valid for this script // and then start the external process From 7921a2ea0d5e943ab51b3bde12df37054867f3b0 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 19 Dec 2024 15:33:10 -0500 Subject: [PATCH 3/3] Remove debugging statements for now Signed-off-by: Geoff Hutchison --- avogadro/qtplugins/forcefield/forcefield.cpp | 3 --- avogadro/qtplugins/forcefield/scriptenergy.cpp | 6 ++---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/avogadro/qtplugins/forcefield/forcefield.cpp b/avogadro/qtplugins/forcefield/forcefield.cpp index 588686aeeb..70bf78172f 100644 --- a/avogadro/qtplugins/forcefield/forcefield.cpp +++ b/avogadro/qtplugins/forcefield/forcefield.cpp @@ -492,12 +492,9 @@ void Forcefield::refreshScripts() qDeleteAll(m_scripts); m_scripts.clear(); - qDebug() << " refresh scripts"; - QMultiMap scriptPaths = QtGui::ScriptLoader::scriptList("energy"); foreach (const QString& filePath, scriptPaths) { - qDebug() << "Loading script: " << filePath; auto* model = new ScriptEnergy(filePath); if (model->isValid()) m_scripts.push_back(model); diff --git a/avogadro/qtplugins/forcefield/scriptenergy.cpp b/avogadro/qtplugins/forcefield/scriptenergy.cpp index 18ada9f171..1a117b94a2 100644 --- a/avogadro/qtplugins/forcefield/scriptenergy.cpp +++ b/avogadro/qtplugins/forcefield/scriptenergy.cpp @@ -122,10 +122,9 @@ Real ScriptEnergy::value(const Eigen::VectorXd& x) QString::number(x[i + 1]).toUtf8() + " " + QString::number(x[i + 2]).toUtf8() + "\n"; } - qDebug() << " wrote coords "; + // qDebug() << " wrote coords "; QByteArray result = m_interpreter->asyncWriteAndResponse(input); - - qDebug() << " got result " << result; + // qDebug() << " got result " << result; // go through lines in result until we see "AvogadroEnergy: " QStringList lines = QString(result).remove('\r').split('\n'); @@ -263,7 +262,6 @@ void ScriptEnergy::readMetaData() .arg(scriptFilePath()) << "\n" << parseError.errorString(); - qWarning() << output; return; }