"Maximum dynamic_level reached"

Hi,
I am trying to optimize this structure:

C -0.772191 -1.116645 0.080280
C -1.403991 0.111671 -0.112749
N -2.816532 0.197230 -0.221534
C -0.573443 1.232083 -0.190826
N -1.147955 2.518080 -0.386874
C 0.792997 1.118523 -0.081870
N 1.618518 2.259836 -0.162821
C 1.371959 -0.113940 0.107981
N 2.784679 -0.184794 0.214953
C 0.581278 -1.257865 0.191689
N 1.172484 -2.531297 0.387361
H -2.384224 -2.470036 -0.495415
H -1.433310 -2.933263 0.931882
H -3.399124 0.829344 0.361427
H -3.300150 -0.397406 -0.915112
H -1.715984 3.005787 0.365447
H -1.034816 3.043833 -1.288650
H 2.276628 2.412628 -0.955082
H 1.560204 2.966626 0.599791
H 3.421350 0.316898 -0.441591
H 3.235260 -0.750304 0.966116
H 1.334208 -3.115140 -0.456124
H 1.441151 -2.882921 1.341144

I tried to use both PBE0 and B3LYP and for both of them:

  1. I get this error:
 Caught AlgError exception


	 Current algorithm/dynamic_level is 0.


	 Alternative approaches are not available or turned on.

Maximum dynamic_level reached.
	A critical optimization-specific error has occured.
	Resetting all optimization options for potential queued jobs.

Error caught:Maximum dynamic_level reached.
Traceback (most recent call last):
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 68, in optimize
    dq = opt_object.take_step(fq, H, energy, return_str=False)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 231, in take_step
    achieved_dq, returned_str = self.opt_method.take_step(fq, H, energy, return_str=True)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/stepAlgorithms.py", line 412, in take_step
    return super().take_step(fq, H, energy, return_str)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/stepAlgorithms.py", line 186, in take_step
    raise AlgError("opt.py: Step is far too large.")
optking.exceptions.AlgError: opt.py: Step is far too large.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 73, in optimize
    opt_object.alg_error_handler(AF)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 370, in alg_error_handler
    raise OptError("Maximum dynamic_level reached.")
optking.exceptions.OptError: Maximum dynamic_level reached.
  1. Despite the error message, the output xyz file is generated anyway. It’s apparently ok for B3LYP, but physically meaningless for PBE0 (opening the structure with a visualization software, there are some fluctuating H atoms).

With PBE0 (which is the method that I actually need to use, I did the calculation with B3LYP just for testing), I tried to modify the dynamic_level, setting it to 1 and 2, with this syntax:

 psi4.set_options({"basis":self.basis_set,
                    "geom_maxiter":1000,
                    "MAXITER":1000,
                    "G_CONVERGENCE": "GAU",
                    "D_CONVERGENCE": 6,
                    "DYNAMIC_LEVEL": 1,   
                    "E_CONVERGENCE": 6})

but I get this error:

 Caught AlgError exception

'NoneType' object has no attribute 'frag_mode'
        A non-optimization-specific error has occurred.

        Resetting all optimization options for potential queued jobs.

Error Type:  <class 'AttributeError'>
Traceback (most recent call last):
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 67, in optimize
    H, fq, energy = opt_object.start_step(H)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 186, in start_step
    make_internal_coords(self.molsys)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 568, in make_internal_coords
    if params.frag_mode == "SINGLE":
AttributeError: 'NoneType' object has no attribute 'frag_mode'
Error caught:'NoneType' object has no attribute 'frag_mode'
Traceback (most recent call last):
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 67, in optimize
    H, fq, energy = opt_object.start_step(H)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 186, in start_step
    make_internal_coords(self.molsys)
  File "/home/lg1u22/.conda/envs/dev-cspy/lib//python3.8/site-packages/optking/optimize.py", line 568, in make_internal_coords
    if params.frag_mode == "SINGLE":
AttributeError: 'NoneType' object has no attribute 'frag_mode'

The last desperate trial I did was that of adding this:

psi4.set_options({"basis":self.basis_set,
                    "geom_maxiter":1000,
                    "MAXITER":1000,
                    "G_CONVERGENCE": "GAU",
                    "D_CONVERGENCE": 6,
                    "DYNAMIC_LEVEL": 1,   
                    "FRAG_MODE": "SINGLE",    
                    "E_CONVERGENCE": 6})

And again I got the same error.

What could I do to fix it?

Kind regards,
Lucia

Are you sure this geometry is correct? You seem to be missing a nitrogen from hexaaminobenzene. If you really do mean to be missing a nitrogen, please provide a minimal reproducible example, as there are some settings missing.

Sorry, you’right, I’ve lost a nitrogen while formatting the question. This is my initial structure:

N -1.608998 -2.258929 0.160576
C -0.772191 -1.116645 0.080280
C -1.403991 0.111671 -0.112749
N -2.816532 0.197230 -0.221534
C -0.573443 1.232083 -0.190826
N -1.147955 2.518080 -0.386874
C 0.792997 1.118523 -0.081870
N 1.618518 2.259836 -0.162821
C 1.371959 -0.113940 0.107981
N 2.784679 -0.184794 0.214953
C 0.581278 -1.257865 0.191689
N 1.172484 -2.531297 0.387361
H -2.384224 -2.470036 -0.495415
H -1.433310 -2.933263 0.931882
H -3.399124 0.829344 0.361427
H -3.300150 -0.397406 -0.915112
H -1.715984 3.005787 0.365447
H -1.034816 3.043833 -1.288650
H 2.276628 2.412628 -0.955082
H 1.560204 2.966626 0.599791
H 3.421350 0.316898 -0.441591
H 3.235260 -0.750304 0.966116
H 1.334208 -3.115140 -0.456124
H 1.441151 -2.882921 1.341144

Pinging @AlexanderH.

I can converge this geometry locally, but the number of iterations it takes is obscene. I have set

psi4.set_options({"basis": "dzp",
                   "geom_maxiter":1000,
                   "MAXITER":1000,
                   "G_CONVERGENCE": "GAU",
                   "D_CONVERGENCE": 6,
                   "DYNAMIC_LEVEL": 1,    
                   "E_CONVERGENCE": 6})

optimize("pbe0")

Greetings. I tried out your test case with the latest and greatest psi4/optking releases. Here was my simple input file:

import psi4
hab = psi4.geometry("""
 ( your geometry )
""")
psi4.set_output_file("hab.output.dat")
psi4.set_options({
    "basis": "dzp",
    "geom_maxiter": 30
 })
psi4.optimize("pbe0")

This default attempt lowered the energy by 60 kcal/mol but did fail to compute a step at step #22. I took the last geometry and restarted a new optimization, and convergence was achieved in 13 more steps. The most recent geometry can be found under “Next Geometry in Ang” in the output file.

If we take a look at how the steps evolved initially, we see good progress but a bad step at 13 and 20.

$ grep '~' hab.output.log 
	     1    -563.75279902   -5.64e+02      4.63e-02      1.45e-02 o    1.06e-01      4.20e-02 o  ~
	     2    -563.78359847   -3.08e-02      9.30e-03      2.43e-03 o    2.63e-01      7.27e-02 o  ~
	     3    -563.79706337   -1.35e-02      5.80e-03      2.10e-03 o    3.26e-01      9.11e-02 o  ~
	     4    -563.81225181   -1.52e-02      4.96e-03      1.91e-03 o    2.70e-01      8.84e-02 o  ~
	     5    -563.82493231   -1.27e-02      1.07e-02      2.59e-03 o    2.72e-01      7.92e-02 o  ~
	     6    -563.83225846   -7.33e-03      1.01e-02      2.64e-03 o    2.03e-01      4.66e-02 o  ~
	     7    -563.83466492   -2.41e-03      7.70e-03      1.90e-03 o    1.52e-01      3.82e-02 o  ~
	     8    -563.83613667   -1.47e-03      8.11e-03      1.98e-03 o    2.64e-01      5.63e-02 o  ~
	     9    -563.83854952   -2.41e-03      8.36e-03      2.23e-03 o    2.77e-01      5.58e-02 o  ~
	    10    -563.84107412   -2.52e-03      1.42e-02      2.52e-03 o    3.34e-01      5.63e-02 o  ~
	    11    -563.84188886   -8.15e-04      1.09e-02      2.99e-03 o    1.46e-01      3.64e-02 o  ~
	    12    -563.84322936   -1.34e-03      6.77e-03      1.66e-03 o    3.19e-01      5.67e-02 o  ~
	    13    -563.84172359    1.51e-03      7.65e-03      2.33e-03 o    1.12e-01      2.40e-02 o  ~
	    14    -563.84403756   -2.31e-03      3.99e-03      9.61e-04 o    6.56e-02      1.67e-02 o  ~
	    15    -563.84432915   -2.92e-04      1.83e-03      4.89e-04 o    9.08e-02      2.29e-02 o  ~
	    16    -563.84437135   -4.22e-05      2.97e-03      8.15e-04 o    4.74e-02      1.25e-02 o  ~
	    17    -563.84466356   -2.92e-04      2.13e-03      4.76e-04 o    3.46e-01      7.16e-02 o  ~
	    18    -563.84555102   -8.87e-04      9.93e-03      1.79e-03 o    2.43e-01      4.82e-02 o  ~
	    19    -563.84599362   -4.43e-04      1.07e-02      1.94e-03 o    2.00e-01      4.62e-02 o  ~
	    20    -563.84408201    1.91e-03      2.01e-02      3.89e-03 o    7.29e-02      2.20e-02 o  ~
	    21    -563.84738526   -3.30e-03      2.73e-03      7.11e-04 o    2.60e-01      5.84e-02 o  ~

This is due to the dynamic trust radius getting too large; the algorithm is getting over its skis so to speak. I tried rerunning the initial optimization with:

    "geom_maxiter": 50,
    "intrafrag_step_limit_max": 0.25 # default is 1.00

and then success is achieved in a single calculation (but 46 iterations) were required. Generally if you wish for a more robust optimization (lower tolerance for failures) then reducing the maximum step size is helpful.

We’ll keep working to improve this code, but we do have to continually balance robustness (in successful optimization) with efficiency (fewer steps), for well-behaved and not so-well-behaved systems.

Thank you all for your help.
I wanted to add that I tried to run this and other similar calculations after updating psi4 (i.e. using 1.7 version). The majority of them converged quickly, while for a couple of them, I solved the problem by changing the dynamic level.

Best regards,
Lucia

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