Skip to content

Commit 42df598

Browse files
authored
Merge branch 'master' into node_xc
2 parents 2199167 + b94438c commit 42df598

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5680
-904
lines changed

doc/users/geometry_optimization.rst

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
-------------------------------
2+
Running a geometry optimization
3+
-------------------------------
4+
In the following we will assume to have a valid user input file for the water
5+
molecule called ``h2o.inp``, e.g. like this
6+
7+
.. include:: h2o_geopt.inp
8+
:literal:
9+
10+
A geometry optimization can be run by adding ``GeometryOptimizer`` section to any normal ``.inp`` file and setting the run keyword to ``true``:
11+
12+
.. include:: geopt_section.inp
13+
:literal:
14+
15+
This will start a geometry optimization with the default settings.
16+
17+
Obtaining accurate forces
18+
-------------------------
19+
20+
In the above H_2O input example the ``world_prec`` parameter is chosen really small. This is necessary to get accurate forces.
21+
If a looser precision it is chosen, the geometry optimization may not converge. Pay attention to the warning::
22+
23+
WARNING: Noise in force is larger than 0.2 times the larges force component!!!
24+
25+
Geometry optimization onvergence cannot be guaranteed!!!
26+
27+
This is printed when the noise level is too high. Usually, geometry optimizations will not converge when this warning is printed.
28+
In that case, either tighten the ``world_prec``, ``orb_thrs`` (or both) _or_ loosen the convergence criterion of the geometry optimization.
29+
30+
31+
Pre-relax input geometries
32+
--------------------------
33+
34+
Running high precision multi resolution wavelet calculations is computationally expensive.
35+
It is therefore not advisable to use an input geometry with high forces, a small ``world_prec`` and start the simulation.
36+
An optimized workflow would look something like this:
37+
38+
1. Optimize the geometry with a gaussian basis set. This can be done with a number of gaussian basis set codes
39+
2. Use inaccurate forces (``world_prec`` ~ 1e-4) and a rather loose convergence criterion (``max_force_component`` ~ 1e-2) for the
40+
geometry optimization for a pre-relaxation with MRChem.
41+
3. Do a tight geometry optimization (``max_force_component`` ~ 5e-4) and with an accurate MRChem calculation (``world_prec`` ~ 1e-6)
42+
43+
44+
Reuse orbitals
45+
--------------
46+
47+
For tight geometry optimizations where the input structure is already close to the local minimum (using cheaper pre-relaxations), it makes sense
48+
to use the orbitals from the geometry optimization iteration *i* for the start of iteration *i+1*. This feature can be enabled by setting::
49+
50+
use_previous_guess = true
51+
52+
53+
Choosing an initial step size
54+
-----------------------------
55+
56+
If there are some problems in the first couple of geometry optimization iterations (energy and force norm increasing) the initial step size should be chosen
57+
manually. If a conservative choice (``init_step_size`` ~ 0.8 ) does not solve the problem, the problem is usually in the input
58+
geometry (wrong units, unphysical, ...) or in the potential energy surface (too much noise, error in the DFT input section, ...).
59+
60+
Convergence problem can be analyzed by visualizing the optimization trajectory and plots of the energy and force norm versus the geometry optimization iterations.

doc/users/geopt_section.inp

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GeometryOptimizer{
2+
run = true
3+
}

doc/users/h2o_geopt.inp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
world_prec = 1.0e-6
2+
world_unit = angstrom
3+
4+
WaveFunction {
5+
method = lda
6+
}
7+
8+
Molecule {
9+
$coords
10+
O 0.00000 0.00000 0.11779
11+
H 0.00000 0.75545 -0.47116
12+
H 0.00000 -0.75545 -0.47116
13+
$end
14+
}

doc/users/manual.rst

+1
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ in more detail in the sections below.
4242
user_ref
4343
qcengine
4444
program_json
45+
geometry_optimization.rst

doc/users/user_ref.rst

+73-22
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,9 @@ User input reference
427427
**Type** ``bool``
428428

429429
**Default** ``False``
430-
431-
:geometric_derivative: Compute geometric derivative.
432-
433-
**Type** ``bool``
434-
435-
**Default** ``False``
436-
437-
:plot_density: Plot converged electron density.
438-
430+
431+
:plot_density: Plot converged electron density.
432+
439433
**Type** ``bool``
440434

441435
**Default** ``False``
@@ -445,8 +439,14 @@ User input reference
445439
**Type** ``List[int]``
446440

447441
**Default** ``[]``
448-
449-
:ExternalFields: Define external electromagnetic fields.
442+
443+
:geometric_derivative: Compute geometric derivative.
444+
445+
**Type** ``bool``
446+
447+
**Default** ``user['GeometryOptimizer']['run']``
448+
449+
:ExternalFields: Define external electromagnetic fields.
450450

451451
:red:`Keywords`
452452
:electric_field: Strength of external electric field.
@@ -712,23 +712,23 @@ User input reference
712712

713713
**Predicates**
714714
- ``value[-1] != '/'``
715-
716-
:write_orbitals: Write final orbitals to disk, file name ``<path_orbitals>/phi_<p/a/b>_scf_idx_<0..Np/Na/Nb>``. Can be used as ``mw`` initial guess in subsequent calculations.
717-
718-
**Type** ``bool``
719-
720-
**Default** ``False``
721-
722-
:path_orbitals: Path to where converged orbitals will be written in connection with the ``write_orbitals`` keyword. Note: must be given in quotes if there are slashes in the path "path/to/orbitals".
723-
715+
716+
:path_orbitals: Path to where converged orbitals will be written in connection with the ``write_orbitals`` keyword. Note: must be given in quotes if there are slashes in the path "path/to/orbitals".
717+
724718
**Type** ``str``
725719

726720
**Default** ``orbitals``
727721

728722
**Predicates**
729723
- ``value[-1] != '/'``
730-
731-
:orbital_thrs: Convergence threshold for orbital residuals.
724+
725+
:write_orbitals: Write final orbitals to disk, file name ``<path_orbitals>/phi_<p/a/b>_scf_idx_<0..Np/Na/Nb>``. Can be used as ``mw`` initial guess in subsequent calculations.
726+
727+
**Type** ``bool``
728+
729+
**Default** ``user['GeometryOptimizer']['use_previous_guess']``
730+
731+
:orbital_thrs: Convergence threshold for orbital residuals.
732732

733733
**Type** ``float``
734734

@@ -943,6 +943,57 @@ User input reference
943943

944944
**Default** ``user['PCM']['Permittivity']['epsilon_out']['static']``
945945

946+
:GeometryOptimizer: Includes parameters related to the internal geometry optimization using the SQNM (Stabilized Quasi-Newton Method) for noisy PES.
947+
948+
:red:`Keywords`
949+
:run: Run optimizer. Otherwise single point energy/properties are computed.
950+
951+
**Type** ``bool``
952+
953+
**Default** ``False``
954+
955+
:use_previous_guess: Start each SCF from the converged orbitals from the previous geometry step. The guess_type will change to "mw" after the first iteration, and the intermediate orbitals will be stored in the "orbitals" directory. If toggled off, start over using the same initial guess method as in the first iteration.
956+
957+
**Type** ``bool``
958+
959+
**Default** ``False``
960+
961+
:init_step_size: Initial step size.
962+
963+
**Type** ``float``
964+
965+
**Default** ``-0.5``
966+
967+
:minimal_step_size: Minimal step size.
968+
969+
**Type** ``float``
970+
971+
**Default** ``0.01``
972+
973+
:max_history_length: Maximum length of history.
974+
975+
**Type** ``int``
976+
977+
**Default** ``10``
978+
979+
:subspace_tolerance: Subspace tolerance.
980+
981+
**Type** ``float``
982+
983+
**Default** ``0.001``
984+
985+
:max_iter: Maximum number of iterations.
986+
987+
**Type** ``int``
988+
989+
**Default** ``100``
990+
991+
:max_force_component: Maximum force component.
992+
993+
**Type** ``float``
994+
995+
**Default** ``0.005``
996+
946997
:Constants: Physical and mathematical constants used by MRChem
947998

948999
:red:`Keywords`

python/mrchem/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def translate_input(user_dict):
6262
"molecule": mol_dict,
6363
"scf_calculation": scf_dict,
6464
"rsp_calculations": rsp_dict,
65+
"geom_opt": user_dict['GeometryOptimizer'],
6566
"constants": user_dict["Constants"],
6667
}
6768
return program_dict

python/mrchem/input_parser/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
This file was automatically generated by parselglossy on 2023-11-22
1+
This file was automatically generated by parselglossy on 2024-01-29
22
Editing is *STRONGLY DISCOURAGED*
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
22

3-
# This file was automatically generated by parselglossy on 2023-11-22
3+
# This file was automatically generated by parselglossy on 2024-01-29
44
# Editing is *STRONGLY DISCOURAGED*

python/mrchem/input_parser/api.py

+33-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# This file was automatically generated by parselglossy on 2023-11-22
3+
# This file was automatically generated by parselglossy on 2024-01-29
44
# Editing is *STRONGLY DISCOURAGED*
55

66
from copy import deepcopy
@@ -351,15 +351,15 @@ def stencil() -> JSONDict:
351351
{ 'default': False,
352352
'name': 'nmr_shielding',
353353
'type': 'bool'},
354-
{ 'default': False,
355-
'name': 'geometric_derivative',
356-
'type': 'bool'},
357354
{ 'default': False,
358355
'name': 'plot_density',
359356
'type': 'bool'},
360357
{ 'default': [],
361358
'name': 'plot_orbitals',
362-
'type': 'List[int]'}],
359+
'type': 'List[int]'},
360+
{ 'default': "user['GeometryOptimizer']['run']",
361+
'name': 'geometric_derivative',
362+
'type': 'bool'}],
363363
'name': 'Properties'},
364364
{ 'keywords': [ { 'default': [],
365365
'name': 'electric_field',
@@ -504,13 +504,13 @@ def stencil() -> JSONDict:
504504
'name': 'path_checkpoint',
505505
'predicates': ["value[-1] != '/'"],
506506
'type': 'str'},
507-
{ 'default': False,
508-
'name': 'write_orbitals',
509-
'type': 'bool'},
510507
{ 'default': 'orbitals',
511508
'name': 'path_orbitals',
512509
'predicates': ["value[-1] != '/'"],
513510
'type': 'str'},
511+
{ 'default': "user['GeometryOptimizer']['use_previous_guess']",
512+
'name': 'write_orbitals',
513+
'type': 'bool'},
514514
{ 'default': '10 * '
515515
"user['world_prec']",
516516
'name': 'orbital_thrs',
@@ -627,6 +627,31 @@ def stencil() -> JSONDict:
627627
'name': 'dynamic',
628628
'type': 'float'}],
629629
'name': 'epsilon_out'}]}]},
630+
{ 'keywords': [ { 'default': False,
631+
'name': 'run',
632+
'type': 'bool'},
633+
{ 'default': False,
634+
'name': 'use_previous_guess',
635+
'type': 'bool'},
636+
{ 'default': -0.5,
637+
'name': 'init_step_size',
638+
'type': 'float'},
639+
{ 'default': 0.01,
640+
'name': 'minimal_step_size',
641+
'type': 'float'},
642+
{ 'default': 10,
643+
'name': 'max_history_length',
644+
'type': 'int'},
645+
{ 'default': 0.001,
646+
'name': 'subspace_tolerance',
647+
'type': 'float'},
648+
{ 'default': 100,
649+
'name': 'max_iter',
650+
'type': 'int'},
651+
{ 'default': 0.005,
652+
'name': 'max_force_component',
653+
'type': 'float'}],
654+
'name': 'GeometryOptimizer'},
630655
{ 'keywords': [ { 'default': 78.9451185,
631656
'name': 'hartree2simagnetizability',
632657
'type': 'float'},

python/mrchem/input_parser/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# This file was automatically generated by parselglossy on 2023-11-22
3+
# This file was automatically generated by parselglossy on 2024-01-29
44
# Editing is *STRONGLY DISCOURAGED*
55

66
import argparse

0 commit comments

Comments
 (0)