Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable rotation in initial guess #486

Merged
merged 9 commits into from
May 30, 2024
1 change: 1 addition & 0 deletions doc/users/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"zeta": int, # Zeta quality for AO basis
"method": string, # Name of method for initial energy
"localize": bool, # Use localized orbitals
"rotate": bool, # Rotate orbitals in initial guess
"restricted": bool, # Use spin restricted orbitals
"relativity": string, # Name of relativistic method
"screen": float, # Screening used in GTO evaluations
Expand Down
1 change: 1 addition & 0 deletions doc/users/user_inp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ The ``core`` and ``sad`` guesses are fully specified with the following keywords
guess_prec = 1.0e-3 # Numerical precision used in guess
guess_type = sad_gto # Type of inital guess (chk, mw, cube, core_XX, sad_XX)
guess_screen = 12.0 # Number of StdDev before a GTO is set to zero (sad_gto)
guess_rotate = true # Localize/Diagonalize guess orbitals before calculating the initial guess energy
}

Checkpointing
Expand Down
18 changes: 12 additions & 6 deletions doc/users/user_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ User input reference

**Default** ``-1``

:omp_threads: Force the number of OpenMP threads.

:omp_threads: Force the number of omp threads (leave default is better).
**Type** ``int``

**Default** ``-1``

:Basis: Define polynomial basis.
:Basis: Define polynomial basis.

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

:guess_rotate: Localize/Diagonalize the initial guess orbitals before calculating the initial guess energy.

**Type** ``bool``

**Default** ``True``

: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.

**Type** ``bool``
Expand Down Expand Up @@ -12209,4 +12215,4 @@ User input reference
**Type** ``float``

**Default** ``0.00011186082063``


7 changes: 5 additions & 2 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ To run the script:

```bash
$ cd python/mrchem
$ rm -r input_parser/plumbing/pyparser
$ python update_input_parser.py
```

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

```bash
$ cd python
$ cd python/mrchem
$ python update_input_parser.py -h
```

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

```bash
$ cd python
$ cd python/mrchem
$ rm -r input_parser/plumbing/pyparser
$ python update_input_parser --skip-template
```

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

```bash
$ cd python
$ rm -r mrchem/input_parser/plumbing/pyparser
$ parselglossy generate --template template.yml --docfile user_ref.rst --doc-header="User input reference" --target="mrchem/input_parser"
$ cp mrchem/input_parser/docs/user_ref.rst ../doc/users/user_ref.rst
```
1 change: 1 addition & 0 deletions python/mrchem/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def write_scf_guess(user_dict, wf_dict):
"external_field": wf_dict["external_name"],
"screen": scf_dict["guess_screen"],
"localize": scf_dict["localize"],
"rotate": scf_dict["guess_rotate"],
"restricted": user_dict["WaveFunction"]["restricted"],
"file_chk": f"{scf_dict['path_checkpoint']}/phi_scf",
"file_basis": file_dict["guess_basis"],
Expand Down
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This file was automatically generated by parselglossy on 2024-01-29
This file was automatically generated by parselglossy on 2024-05-14
Editing is *STRONGLY DISCOURAGED*
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-01-29
# This file was automatically generated by parselglossy on 2024-05-14
# Editing is *STRONGLY DISCOURAGED*
5 changes: 4 additions & 1 deletion python/mrchem/input_parser/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-02-08
# This file was automatically generated by parselglossy on 2024-05-14
# Editing is *STRONGLY DISCOURAGED*

from copy import deepcopy
Expand Down Expand Up @@ -510,6 +510,9 @@ def stencil() -> JSONDict:
'name': 'path_orbitals',
'predicates': ["value[-1] != '/'"],
'type': 'str'},
{ 'default': True,
'name': 'guess_rotate',
'type': 'bool'},
{ 'default': "user['GeometryOptimizer']['use_previous_guess']",
'name': 'write_orbitals',
'type': 'bool'},
Expand Down
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-01-29
# This file was automatically generated by parselglossy on 2024-05-14
# Editing is *STRONGLY DISCOURAGED*

import argparse
Expand Down
12 changes: 12 additions & 0 deletions python/mrchem/input_parser/docs/user_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ User input reference

**Default** ``-1``

:omp_threads: Force the number of omp threads (leave default is better).

**Type** ``int``

**Default** ``-1``

:Basis: Define polynomial basis.

:red:`Keywords`
Expand Down Expand Up @@ -716,6 +722,12 @@ User input reference
**Predicates**
- ``value[-1] != '/'``

:guess_rotate: Localize/Diagonalize the initial guess orbitals before calculating the initial guess energy.

**Type** ``bool``

**Default** ``True``

: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.

**Type** ``bool``
Expand Down
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/plumbing/lexer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-01-29
# This file was automatically generated by parselglossy on 2024-05-14
# Editing is *STRONGLY DISCOURAGED*

import json
Expand Down
5 changes: 5 additions & 0 deletions python/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,11 @@ sections:
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".
- name: guess_rotate
type: bool
default: true
docstring: |
Localize/Diagonalize the initial guess orbitals before calculating the initial guess energy.
- name: Response
docstring: |
Includes parameters related to the response SCF optimization.
Expand Down
5 changes: 3 additions & 2 deletions src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ bool driver::scf::guess_energy(const json &json_guess, Molecule &mol, FockBuilde
auto environment = json_guess["environment"];
auto external_field = json_guess["external_field"];
auto localize = json_guess["localize"];
auto rotate = json_guess["rotate"];

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

F_mat = ComplexMatrix::Zero(Phi.size(), Phi.size());
if (localize) orbital::localize(prec, Phi, F_mat);
if (localize && rotate) orbital::localize(prec, Phi, F_mat);

F.setup(prec);
F_mat = F(Phi, Phi);
mol.getSCFEnergy() = F.trace(Phi, nucs);
F.clear();

if (not localize) orbital::diagonalize(prec, Phi, F_mat);
if (not localize && rotate) orbital::diagonalize(prec, Phi, F_mat);
if (plevel == 1) mrcpp::print::footer(1, t_scf, 2);

Timer t_eps;
Expand Down
Loading