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

Switch to L-BFGS and fixup GFN-FF parsing #1401

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion avogadro/qtplugins/forcefield/forcefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@
bool isInteractive = m_molecule->undoMolecule()->isInteractive();
m_molecule->undoMolecule()->setInteractive(true);

cppoptlib::ConjugatedGradientDescentSolver<EnergyCalculator> solver;
cppoptlib::LbfgsSolver<EnergyCalculator> solver;
// cppoptlib::ConjugatedGradientDescentSolver<EnergyCalculator> solver;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

int n = m_molecule->atomCount();

Expand Down
8 changes: 5 additions & 3 deletions avogadro/qtplugins/forcefield/scriptenergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ Real ScriptEnergy::value(const Eigen::VectorXd& x)
double energy = 0.0;
for (auto line : lines) {
if (line.startsWith("AvogadroEnergy:")) {
QStringList items = line.split(" ");
if (items.size() > 1)
QStringList items = line.split(" ", QString::SkipEmptyParts);
if (items.size() > 1) {
energy = items[1].toDouble();
break;
}
}
}

Expand Down Expand Up @@ -163,7 +165,7 @@ void ScriptEnergy::gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad)
}

if (readingGrad) {
QStringList items = line.split(" ");
QStringList items = line.split(" ", QString::SkipEmptyParts);
if (items.size() == 3) {
grad[i] = items[0].toDouble();
grad[i + 1] = items[1].toDouble();
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/forcefield/scripts/gfn1.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run(filename):
while(True):
# read new coordinates from stdin
for i in range(len(atoms)):
coordinates[i] = np.fromstring(input(), sep=" ")
coordinates[i] = np.fromstring(input())
# .. convert from Angstrom to Bohr
coordinates /= 0.52917721067

Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/forcefield/scripts/gfn2.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run(filename):
while(True):
# read new coordinates from stdin
for i in range(len(atoms)):
coordinates[i] = np.fromstring(input(), sep=" ")
coordinates[i] = np.fromstring(input())
# .. convert from Angstrom to Bohr
coordinates /= 0.52917721067

Expand Down
4 changes: 2 additions & 2 deletions avogadro/qtplugins/forcefield/scripts/gfnff.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def run(filename):
while True:
# read new coordinates from stdin
for i in range(len(atoms)):
coordinates[i] = np.fromstring(input(), sep=" ")
coordinates[i] = np.fromstring(input())
# .. convert from Angstrom to Bohr
coordinates /= 0.52917721067

Expand All @@ -80,7 +80,7 @@ def run(filename):
# now print the gradient
# .. we don't want the "[]" in the output
print("AvogadroGradient:")
grad = res.get_gradient() * 496100.475 # convert units
grad = res.get_gradient() * 4961.475 # convert units
output = np.array2string(grad)
output = output.replace("[", "").replace("]", "")
print(output)
Expand Down
Loading