Ase.optimize with BFGS for a collection of molecules

I have a collection of one type of a molecule. They have a difference in a special torsional angle. I need to optimize all of them with

from ase.optimize import BFGS

My target is to plot minimization energies vs torsional angles.
E1234 is the energies which would be saved in a list “list1234” as follow:

from ase import Atoms
from ase.optimize import BFGS
from ase.calculators.emt import EMT
import numpy as np
E1234=[]
for E1 in list1234:

    BFGS(atoms=E1, trajectory='E1234.traj').run(fmax=1e-4)
    E1234.append(E1.get_potential_energy())

The collection is included 73 molecules.
A loop has constructed their z-matrix as inputs.

In manual, there is a command: steps=100000000 which I have removed it in my code (as the above shown) and fmax is 1e-4.

BFGS(atoms=E1, trajectory=‘E1234.traj’).run(fmax=1e-4)

So, let me ask a question,
As I told I have 73 optimizations, for any molecule there is a optimization.

Some of optimization go ahead well and finished below 100 iterations(=step).
For example, for the first molecule the output has finished (reaxed) (after 48 iterations=step):

  Step     Time          Energy         fmax

BFGS: 0 14:30:03 -6449.620074 0.0702
BFGS: 1 14:30:03 -6449.620430 0.0350
BFGS: 2 14:30:03 -6449.620618 0.0229
BFGS: 3 14:30:03 -6449.620661 0.0170
BFGS: 4 14:30:03 -6449.620738 0.0152
BFGS: 5 14:30:04 -6449.620791 0.0160
BFGS: 6 14:30:04 -6449.620835 0.0148
BFGS: 7 14:30:04 -6449.620858 0.0123
BFGS: 8 14:30:04 -6449.620883 0.0109
BFGS: 9 14:30:04 -6449.620913 0.0155
BFGS: 10 14:30:04 -6449.620946 0.0190
BFGS: 11 14:30:04 -6449.620971 0.0152
BFGS: 12 14:30:04 -6449.620988 0.0124
BFGS: 13 14:30:04 -6449.620997 0.0078
BFGS: 14 14:30:04 -6449.621004 0.0050
BFGS: 15 14:30:04 -6449.621008 0.0044
BFGS: 16 14:30:05 -6449.621011 0.0038
BFGS: 17 14:30:05 -6449.621013 0.0032
BFGS: 18 14:30:05 -6449.621015 0.0030
BFGS: 19 14:30:05 -6449.621016 0.0020
BFGS: 20 14:30:05 -6449.621016 0.0016
BFGS: 21 14:30:05 -6449.621016 0.0011
BFGS: 22 14:30:05 -6449.621017 0.0009
BFGS: 23 14:30:05 -6449.621017 0.0010
BFGS: 24 14:30:05 -6449.621017 0.0013
BFGS: 25 14:30:05 -6449.621017 0.0014
BFGS: 26 14:30:05 -6449.621017 0.0012
BFGS: 27 14:30:05 -6449.621018 0.0012
BFGS: 28 14:30:06 -6449.621018 0.0015
BFGS: 29 14:30:06 -6449.621018 0.0019
BFGS: 30 14:30:06 -6449.621019 0.0019
BFGS: 31 14:30:06 -6449.621019 0.0020
BFGS: 32 14:30:06 -6449.621020 0.0021
BFGS: 33 14:30:06 -6449.621021 0.0020
BFGS: 34 14:30:06 -6449.621022 0.0026
BFGS: 35 14:30:06 -6449.621023 0.0024
BFGS: 36 14:30:06 -6449.621024 0.0023
BFGS: 37 14:30:07 -6449.621024 0.0018
BFGS: 38 14:30:07 -6449.621024 0.0012
BFGS: 39 14:30:07 -6449.621025 0.0010
BFGS: 40 14:30:07 -6449.621025 0.0015
BFGS: 41 14:30:07 -6449.621025 0.0015
BFGS: 42 14:30:07 -6449.621025 0.0008
BFGS: 43 14:30:07 -6449.621025 0.0003
BFGS: 44 14:30:07 -6449.621025 0.0003
BFGS: 45 14:30:07 -6449.621025 0.0003
BFGS: 46 14:30:07 -6449.621025 0.0003
BFGS: 47 14:30:07 -6449.621025 0.0001
BFGS: 48 14:30:08 -6449.621025 0.0001

But for some molecules the iterations cannot be finished even after 100000 step, for example:

  Step     Time          Energy         fmax

BFGS: 0 14:30:08 -6449.598580 0.2911
BFGS: 1 14:30:08 -6449.600903 0.2649
BFGS: 2 14:30:08 -6449.609992 0.1837
BFGS: 3 14:30:08 -6449.612493 0.1623
BFGS: 4 14:30:08 -6449.615372 0.1038
BFGS: 5 14:30:09 -6449.616011 0.0785
BFGS: 6 14:30:09 -6449.616460 0.0780
BFGS: 7 14:30:09 -6449.617002 0.0869
BFGS: 8 14:30:09 -6449.617729 0.0810
BFGS: 9 14:30:09 -6449.618245 0.0459
BFGS: 10 14:30:09 -6449.618463 0.0318
BFGS: 11 14:30:09 -6449.618550 0.0277
BFGS: 12 14:30:09 -6449.618612 0.0197
BFGS: 13 14:30:09 -6449.618661 0.0131
BFGS: 14 14:30:10 -6449.618688 0.0105
BFGS: 15 14:30:10 -6449.618701 0.0084
BFGS: 16 14:30:10 -6449.618707 0.0057
BFGS: 17 14:30:10 -6449.618711 0.0038
BFGS: 18 14:30:10 -6449.618714 0.0042
.
.
.
.
BFGS: 123562 19:39:29 -6449.491052 0.0007
BFGS: 123563 19:39:30 -6449.491052 0.0007
BFGS: 123564 19:39:30 -6449.491052 0.0007
BFGS: 123565 19:39:31 -6449.491052 0.0007
BFGS: 123566 19:39:31 -6449.491052 0.0007
BFGS: 123567 19:39:31 -6449.491052 0.0007
BFGS: 123568 19:39:31 -6449.491052 0.0007
BFGS: 123569 19:39:32 -6449.491052 0.0007
BFGS: 123570 19:39:32 -6449.491052 0.0007
BFGS: 123571 19:39:32 -6449.491052 0.0007
BFGS: 123572 19:39:32 -6449.491052 0.0007
BFGS: 123573 19:39:32 -6449.491052 0.0007
BFGS: 123574 19:39:33 -6449.491052 0.0007
BFGS: 123575 19:39:33 -6449.491052 0.0007
BFGS: 123576 19:39:33 -6449.491052 0.0007
BFGS: 123577 19:39:34 -6449.491052 0.0007
BFGS: 123578 19:39:34 -6449.491052 0.0007
BFGS: 123579 19:39:34 -6449.491052 0.0007

Here the fmax is 0.0007 (after 123579 iterations=step) and cannot reach to 1e-4.

Let me know how I can resolve these problem?
The main problem is unfinished a relaxation even after 100000 iterations!
Is BFGS the same algorithm used in Gaussian?
It is yes, we should know Gaussian has 64 max cycle of SCF.
What is the iterations meaning here?
I think the 10000, 100000 or 100000000 are more large!
Anyway, please answer my all questions.

I can send my codes, inputs, outputs to developers of ASE.

Dear Muhammad_Shadman_ASE,

I believe the ‘steps’ you metioned is the optimization steps for relaxation, but not the steps for SCF cycles. I haven’t use Gaussian codes, however, according to your discription, the BFGS algorithm is used in Gaussian to minimize the wavefuntions in order to complete SCF and to get energy, which is different from the BFGS you imported from ase.optimizer. In the latter case, BFGS algorithm is used as an optimizer to relax your structure which assumes the system energy is known before BFGS is invoked.

Different algorithms can be implemented for one type of task, for example, in CP2K, one has diagonalization or orbital transformation to minimize the wavefunctions and one also has BFGS, CG or LBFGS to relax the structures.

The problems you encountered should be unable to converge relaxations of some molecules, which is affected by many factors. For this kind of problems, I suggest you could consider to get more accurate atomic forces and try to tune the optimizer. Since the calculator for atoms doesn’t present, maybe you could use more accurate programs (Gaussian, I guess) to calculate the atomic forces.

Best,
Youmu

Dear Youmu
Thanks so much
I was busy and saw your answer
I will think again and reply to you ASAP.
Best,
Muhammad