From 2f301c8a7a96da01df7a0be26a3f82a71e01bf61 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 5 Dec 2024 21:33:10 -0500 Subject: [PATCH] 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