Skip to content

Commit f77816b

Browse files
committed
added option to disable rotation of orbitals before calculating the initial guess energy
1 parent d5805a3 commit f77816b

File tree

12 files changed

+47
-15
lines changed

12 files changed

+47
-15
lines changed

doc/users/user_inp.rst

+1
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ The ``core`` and ``sad`` guesses are fully specified with the following keywords
449449
guess_prec = 1.0e-3 # Numerical precision used in guess
450450
guess_type = sad_gto # Type of inital guess (chk, mw, cube, core_XX, sad_XX)
451451
guess_screen = 12.0 # Number of StdDev before a GTO is set to zero (sad_gto)
452+
guess_rotate = true # Localize/Diagonalize guess orbitals before calculating the initial guess energy
452453
}
453454
454455
Checkpointing

doc/users/user_ref.rst

+12-6
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ User input reference
231231

232232
**Default** ``-1``
233233

234-
:omp_threads: Force the number of OpenMP threads.
235-
234+
:omp_threads: Force the number of omp threads (leave default is better).
235+
236236
**Type** ``int``
237-
237+
238238
**Default** ``-1``
239-
240-
:Basis: Define polynomial basis.
239+
240+
:Basis: Define polynomial basis.
241241

242242
:red:`Keywords`
243243
:order: Polynomial order of multiwavelet basis. Negative value means it will be set automatically based on the world precision.
@@ -722,6 +722,12 @@ User input reference
722722
**Predicates**
723723
- ``value[-1] != '/'``
724724

725+
:guess_rotate: Localize/Diagonalize the initial guess orbitals before calculating the initial guess energy.
726+
727+
**Type** ``bool``
728+
729+
**Default** ``True``
730+
725731
: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.
726732

727733
**Type** ``bool``
@@ -12209,4 +12215,4 @@ User input reference
1220912215
**Type** ``float``
1221012216

1221112217
**Default** ``0.00011186082063``
12212-
12218+

python/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ To run the script:
1212

1313
```bash
1414
$ cd python/mrchem
15+
$ rm -r input_parser/plumbing/pyparser
1516
$ python update_input_parser.py
1617
```
1718

@@ -24,7 +25,7 @@ This does three things:
2425
Each of these steps can be deactivated by appropriate flags. For help on running the script, run
2526

2627
```bash
27-
$ cd python
28+
$ cd python/mrchem
2829
$ python update_input_parser.py -h
2930
```
3031

@@ -33,7 +34,8 @@ If the `Constants` and `Elements` input sections are unchanged, you can update t
3334
The utility script can also do this, by specifying the flag `--skip-template`:
3435

3536
```bash
36-
$ cd python
37+
$ cd python/mrchem
38+
$ rm -r input_parser/plumbing/pyparser
3739
$ python update_input_parser --skip-template
3840
```
3941

@@ -43,6 +45,7 @@ You can also perform these steps manually without using the utility script:
4345

4446
```bash
4547
$ cd python
48+
$ rm -r mrchem/input_parser/plumbing/pyparser
4649
$ parselglossy generate --template template.yml --docfile user_ref.rst --doc-header="User input reference" --target="mrchem/input_parser"
4750
$ cp mrchem/input_parser/docs/user_ref.rst ../doc/users/user_ref.rst
4851
```

python/mrchem/helpers.py

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def write_scf_guess(user_dict, wf_dict):
224224
"external_field": wf_dict["external_name"],
225225
"screen": scf_dict["guess_screen"],
226226
"localize": scf_dict["localize"],
227+
"rotate": scf_dict["guess_rotate"],
227228
"restricted": user_dict["WaveFunction"]["restricted"],
228229
"file_chk": f"{scf_dict['path_checkpoint']}/phi_scf",
229230
"file_basis": file_dict["guess_basis"],

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 2024-01-29
1+
This file was automatically generated by parselglossy on 2024-05-14
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 2024-01-29
3+
# This file was automatically generated by parselglossy on 2024-05-14
44
# Editing is *STRONGLY DISCOURAGED*

python/mrchem/input_parser/api.py

+4-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 2024-02-08
3+
# This file was automatically generated by parselglossy on 2024-05-14
44
# Editing is *STRONGLY DISCOURAGED*
55

66
from copy import deepcopy
@@ -510,6 +510,9 @@ def stencil() -> JSONDict:
510510
'name': 'path_orbitals',
511511
'predicates': ["value[-1] != '/'"],
512512
'type': 'str'},
513+
{ 'default': True,
514+
'name': 'guess_rotate',
515+
'type': 'bool'},
513516
{ 'default': "user['GeometryOptimizer']['use_previous_guess']",
514517
'name': 'write_orbitals',
515518
'type': 'bool'},

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 2024-01-29
3+
# This file was automatically generated by parselglossy on 2024-05-14
44
# Editing is *STRONGLY DISCOURAGED*
55

66
import argparse

python/mrchem/input_parser/docs/user_ref.rst

+12
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ User input reference
231231

232232
**Default** ``-1``
233233

234+
:omp_threads: Force the number of omp threads (leave default is better).
235+
236+
**Type** ``int``
237+
238+
**Default** ``-1``
239+
234240
:Basis: Define polynomial basis.
235241

236242
:red:`Keywords`
@@ -716,6 +722,12 @@ User input reference
716722
**Predicates**
717723
- ``value[-1] != '/'``
718724

725+
:guess_rotate: Localize/Diagonalize the initial guess orbitals before calculating the initial guess energy.
726+
727+
**Type** ``bool``
728+
729+
**Default** ``True``
730+
719731
: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.
720732

721733
**Type** ``bool``

python/mrchem/input_parser/plumbing/lexer.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 2024-01-29
3+
# This file was automatically generated by parselglossy on 2024-05-14
44
# Editing is *STRONGLY DISCOURAGED*
55

66
import json

python/template.yml

+5
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,11 @@ sections:
711711
Path to where converged orbitals will be written in connection with
712712
the ``write_orbitals`` keyword. Note: must be given in quotes if
713713
there are slashes in the path "path/to/orbitals".
714+
- name: guess_rotate
715+
type: bool
716+
default: true
717+
docstring: |
718+
Localiez/Diagonalize the initial guess orbitals before calculating the initial guess energy.
714719
- name: Response
715720
docstring: |
716721
Includes parameters related to the response SCF optimization.

src/driver.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ bool driver::scf::guess_energy(const json &json_guess, Molecule &mol, FockBuilde
405405
auto environment = json_guess["environment"];
406406
auto external_field = json_guess["external_field"];
407407
auto localize = json_guess["localize"];
408+
auto rotate = json_guess["rotate"];
408409

409410
mrcpp::print::separator(0, '~');
410411
print_utils::text(0, "Calculation ", "Compute initial energy");
@@ -425,14 +426,14 @@ bool driver::scf::guess_energy(const json &json_guess, Molecule &mol, FockBuilde
425426
auto &F_mat = mol.getFockMatrix();
426427

427428
F_mat = ComplexMatrix::Zero(Phi.size(), Phi.size());
428-
if (localize) orbital::localize(prec, Phi, F_mat);
429+
if (localize && rotate) orbital::localize(prec, Phi, F_mat);
429430

430431
F.setup(prec);
431432
F_mat = F(Phi, Phi);
432433
mol.getSCFEnergy() = F.trace(Phi, nucs);
433434
F.clear();
434435

435-
if (not localize) orbital::diagonalize(prec, Phi, F_mat);
436+
if (not localize && rotate) orbital::diagonalize(prec, Phi, F_mat);
436437
if (plevel == 1) mrcpp::print::footer(1, t_scf, 2);
437438

438439
Timer t_eps;

0 commit comments

Comments
 (0)