Skip to content

Commit

Permalink
Work in progress to integrate MatterSim model
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 6, 2024
1 parent ea0679b commit 2f301c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions avogadro/qtplugins/forcefield/forcefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,12 @@ void Forcefield::refreshScripts()
qDeleteAll(m_scripts);
m_scripts.clear();

qDebug() << " refresh scripts";

QMultiMap<QString, QString> 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);
Expand Down
6 changes: 5 additions & 1 deletion avogadro/qtplugins/forcefield/scriptenergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -260,6 +263,7 @@ void ScriptEnergy::readMetaData()
.arg(scriptFilePath())
<< "\n"
<< parseError.errorString();
qWarning() << output;
return;
}

Expand Down Expand Up @@ -325,7 +329,7 @@ void ScriptEnergy::readMetaData()
m_inputFormat = inputFormatTmp;

// check ions, radicals, unit cells
/*
/* e.g.,
"unitCell": False,
"gradients": True,
"ion": False,
Expand Down
6 changes: 3 additions & 3 deletions avogadro/qtplugins/forcefield/scriptenergy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit 2f301c8

@github-actions
Copy link

Choose a reason for hiding this comment

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

ERROR: clang-format-diff detected formatting issues. See the artifact for a patch or run clang-format on your branch.

Please sign in to comment.