GFN-FF returns an energy of 0

I believe this to be a bug with Avogadro / the interface to xtb.

Environment Information

Avogadro version: 1.98.1
Operating system and version: macOS 13.6.1 on arm64
xtb-python 22.1
xtb 6.5.1

Expected Behavior

A non-zero energy is returned.

Actual Behavior

An energy of 0 is returned. This also means that, for example, a geometry optimisation using GFN-FF does nothing.

Steps to Reproduce

Create a small molecule (e.g., methane), set the force field to GFN-FF. Select calculate energy. Dialogue box returns “ENERGY = GFN-FF 0”

I’ve managed to get a simple energy calculation using the same xtb-python to run via an interactive Python session. Using an alternate FF (e.g., UFF from openbabel) seems to work as expected.

Hmm. Can you try optimizing with GFN-FF? Does that work?

Attempting to optimise with GFN-FF doesn’t appear to do anything visually. I captured the following terminal output:

initial 0 gradNorm: 0
maxSteps 250 steps 50
optimize 0 0 gradNorm: 0
optimize 1 0 gradNorm: 0
optimize 2 0 gradNorm: 0
optimize 3 0 gradNorm: 0
optimize 4 0 gradNorm: 0
optimize 5 0 gradNorm: 0

And so on. It seems like Avogadro is not reading the information from XTB correctly?

Hmm, okay. I’ll take a look soon. I guess for you this shows up on any molecule.

It appears that way. I’ve tried building a few different molecules in Avogadro and reading in xyz files with the same result.

In case it helps with tracking down the problem, I’ve tried “running” gfnff.py interactively from a Python prompt using a cjson that I saved from Avogadro. I got the following from the energy print:

print(“AvogadroEnergy:”, res.get_energy())
AvogadroEnergy: -4.023242598995136

And the gradient:

output = np.array2string(grad)
output = output.replace(“[”, “”).replace(“]”, “”)
print(output)
1.23482693e+02 1.63271872e+02 4.52863949e-15
-2.01513785e+02 2.34551324e+00 1.61309947e-15
-6.86537104e+01 -3.25911997e+00 -1.81615081e-15
5.67926280e+01 6.91183037e+01 -1.30994734e+02
1.49487976e+01 -4.56896142e+01 2.93592541e+00
-4.32408865e+01 -3.31148853e+00 6.53865092e+00
1.47711289e+01 2.14105220e+01 4.07063114e+01
5.67926280e+01 6.91183037e+01 1.30994734e+02
-4.32408865e+01 -3.31148853e+00 -6.53865092e+00
1.49487976e+01 -4.56896142e+01 -2.93592541e+00
1.47711289e+01 2.14105220e+01 -4.07063114e+01
7.32753905e+01 -1.84108759e+02 4.92535202e-15
2.13044953e+01 -6.51958520e+01 -4.53453288e-15
1.40490862e+02 2.10384510e+00 -2.10126640e-18
-1.75233093e+02 -2.45232549e-02 -1.09510862e+02
6.90802570e+01 -2.35829890e-01 -2.12030390e+01
6.90802570e+01 -2.35829890e-01 2.12030390e+01
-1.75233093e+02 -2.45232549e-02 1.09510862e+02
-1.65180152e+01 8.85432776e-01 4.45714864e+01
3.52062104e+01 2.68447718e-01 1.30025821e+01
3.52062104e+01 2.68447718e-01 -1.30025821e+01
-1.65180152e+01 8.85432776e-01 -4.45714864e+01

A warning, possibly benign, that was generated as I was playing around came from

coordinates[i] = np.fromstring(input())

Which gave:

DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead

EDIT: changing np.fromstring to np.frombuffer did not help.

You might try this, which gets rid of that warning.

            coordinates[i] = np.fromstring(input(), sep=' ')

I’m still a bit mystified at the bug. For example, I’m able to successfully optimize caffeine:

 maxSteps 250  steps  50
 optimize  0 -4.66618  gradNorm:  490.312
 optimize  1 -4.67067  gradNorm:  305.669
 optimize  2 -4.67761  gradNorm:  31.6003
 optimize  3 -4.67783  gradNorm:  21.3193
 optimize  4 -4.6779  gradNorm:  18.9278
…

But then as you say, when I ask for the energy command, I get 0.0. :thinking:

Seems like even though I’ve requested “MUTED” the gfn calculator is giving me output from the SCF calculations:

          ==================== Thresholds ====================\n          CN  :   150.00000\n          rep :   500.00000\n          disp:  2500.00000\n          HB1 :   250.00000\n

I’ll tinker with the Python script a bit more. Seems like there are some ways to redirect the output.

Okay, I got it working… (units would be helpful)

I needed to send the GFN-FF messages to a black hole. Feel free to just grab the updated script:

I can confirm this works for me - thanks for tracking it down and fixing!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.