MRChemSoft / mrchem

MultiResolution Chemistry
GNU Lesser General Public License v3.0
27 stars 21 forks source link

Print information about the external environments #408

Closed Brakjen closed 2 years ago

Brakjen commented 2 years ago

In response to #406.

During input parsing, now a short summary label is generated and displayed in the SCF solver table. It indicates whether an implicit solvent is being used, and if a finite external electric is applied. For example, if both are active:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Calculation             : Optimize ground state orbitals
 Method                  : Hartree-Fock
 Relativity              : None
 Environment             : PCM ; Electric field (0.0, 0.0, 0.01)
 Checkpointing           : Off
 Max iterations          : 5
 KAIN solver             : 3
 Localization            : Off
 Diagonalization         : First two iterations
 Start precision         : 1.00000e-03
 Final precision         : 1.00000e-03
 Helmholtz precision     : Dynamic
 Energy threshold        : Off
 Orbital threshold       : 1.00000e-02
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A more detailed table is also printed earlier showing some key settings for the implicit solvent. For example:

===========================================================================
                      Self-Consistent Reaction Field
---------------------------------------------------------------------------
 Dielectric constant (inside)     :                            1.00000e+00
 Dielectric constant (outside)    :                            2.00000e+00
 Max number of micro-ierations    :                                  100.0
 Accelerate with KAIN             :                                   true
 Algorithm                        :                                   scrf
 Density type                     :                                  total
 Convergence criterion            :                                dynamic
===========================================================================

To allow for the rather long names left of the :, some tweaks to print_utils were needed. A txtBuffer option was added that lets a developer give more room if needed (defaults to 0). Also, an option for right-aligning print_utils::text was added, but a left-aligned table is perhaps aesthetically more pleasing...?

Should a table similar to the geometry one be printed for the cavity?

codecov[bot] commented 2 years ago

Codecov Report

Merging #408 (bd52a5b) into master (2d0f602) will increase coverage by 0.15%. The diff coverage is 82.35%.

@@            Coverage Diff             @@
##           master     #408      +/-   ##
==========================================
+ Coverage   68.04%   68.20%   +0.15%     
==========================================
  Files         182      183       +1     
  Lines       15208    15453     +245     
==========================================
+ Hits        10349    10540     +191     
- Misses       4859     4913      +54     
Impacted Files Coverage Δ
src/chemistry/Molecule.cpp 52.66% <0.00%> (-14.26%) :arrow_down:
src/chemistry/Molecule.h 83.33% <ø> (-2.88%) :arrow_down:
src/chemistry/PhysicalConstants.cpp 40.00% <0.00%> (-10.00%) :arrow_down:
src/parallel.cpp 80.43% <ø> (ø)
src/qmoperators/one_electron/ZoraOperator.h 100.00% <ø> (ø)
src/qmoperators/two_electron/ReactionPotential.h 100.00% <ø> (ø)
...c/qmoperators/two_electron/ExchangePotentialD2.cpp 45.00% <33.33%> (ø)
...rc/qmoperators/two_electron/CoulombPotentialD1.cpp 50.00% <50.00%> (ø)
...rc/qmoperators/two_electron/CoulombPotentialD2.cpp 53.84% <50.00%> (ø)
src/tensor/RankZeroOperator.cpp 64.46% <50.00%> (ø)
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2d0f602...bd52a5b. Read the comment docs.

Brakjen commented 2 years ago

Where is the appropriate place to print information about SCRF and the cavity? Now I am printing in driver.cpp when setting up ReactionOperator, since this block only gets executed if a reaction field is requested.


if (json_fock.contains("reaction_operator")) {

        // preparing Reaction Operator
        (...)

        mol.printCavity();
        V_R->getHelper()->printParameters();
    }
stigrj commented 2 years ago

printCavity() can perhaps be done at the same time as printGeometry(), after initCavity() in the molecule? But what happens here if we're not doing solvent, do we still get a cavity?

stigrj commented 2 years ago

Ok, we need to fix this, there should not be any cavity_coords input section in the molecule when we don't have any solvent. This needs to be screened out in the Python part.

Brakjen commented 2 years ago

Ok, we need to fix this, there should not be any cavity_coords input section in the molecule when we don't have any solvent. This needs to be screened out in the Python part.

This will interfere a bit with PR #404, since the molecule and cavity validation has been abstracted to its own validator class. How best proceed? (which PR will be merged first?:P)

stigrj commented 2 years ago

Yes, I see the JSON printer was also introduced in the other PR, so let's finish that one first. Can you move the final version of the JSON printer over to #404, then I can have a look at the Cavity stuff after lunch. Not sure where to put it yet

stigrj commented 2 years ago

If you first squash these into a single commit, then a rebase on the new upstream will result in only trivial conflicts.

stigrj commented 2 years ago

We should also fix some of the solvent related printouts:

stigrj commented 2 years ago

Now printCavity() can be put in driver::init_molecule, after the cavity has been initialized (and move printGeometry() above the cavity block).

Not sure where the SCRF output should be though, but these are "parameters" of the calculation and not "program output", so the SCRF print should be enclosed in

~~~~~~~

~~~~~~~

and not

========

========

Actually, the "Physical Constants" should perhaps also be ~

Brakjen commented 2 years ago

If you first squash these into a single commit, then a rebase on the new upstream will result in only trivial conflicts.

Before I mess everything up: Is this what I should do?

First do a

git rebase -i 8ae9f19d

and change pick to squash for all commits except the top one in the commit file?

And then do a

git rebase upstream/master

and resolve conflicts?

And then a

git push --force

?

stigrj commented 2 years ago

Sounds about right, starting with a git fetch upstream. Could be a good idea to make a backup branch with the current state in case something :boom: in your face :smile_cat:

Brakjen commented 2 years ago

I'll give it a 10% chance that I did the rebase correctly...

stigrj commented 2 years ago

Looks like the print_utils::json got duplicated

Brakjen commented 2 years ago

Is it okay to just fix this "manually" by adding new commits.

Brakjen commented 2 years ago

The physical constants printouts should look like this

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 angstrom2bohrs            :                            1.8897261246257702 
 dipmom_au2debye           :                            2.5417464739297717 
 electron_g_factor         :                             -2.00231930436256 
 fine_structure_constant   :                               0.0072973525693 
 hartree2ev                :                               27.211386245988 
 hartree2kcalmol           :                             627.5094740630558 
 hartree2kjmol             :                            2625.4996394798254 
 hartree2simagnetizability :                                    78.9451185 
 hartree2wavenumbers       :                                219474.6313632 
 light_speed               :                                 137.035999084 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

or with a headline

***************************************************************************
***                                                                     ***
***                           Physical Constants                        ***
***                                                                     ***
***************************************************************************

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 angstrom2bohrs            :                            1.8897261246257702 
 dipmom_au2debye           :                            2.5417464739297717 
 electron_g_factor         :                             -2.00231930436256 
 fine_structure_constant   :                               0.0072973525693 
 hartree2ev                :                               27.211386245988 
 hartree2kcalmol           :                             627.5094740630558 
 hartree2kjmol             :                            2625.4996394798254 
 hartree2simagnetizability :                                    78.9451185 
 hartree2wavenumbers       :                                219474.6313632 
 light_speed               :                                 137.035999084 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stigrj commented 2 years ago

Sorry, I dropped out a bit here :slightly_smiling_face: I think a headline is perhaps a bit excessive?

Brakjen commented 2 years ago

I checked, and the PCM part is not active during the initial guess.

Since the parameters for the SCF and for the SCRF perhaps should be printed next to each other, it might be clearer to indicate what the tables contain. So something like this? (trying to keep the tilde-style for parameters more or less consistent):

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           Self-Consistent Field
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Calculation             : Optimize ground state orbitals
 Method                  : DFT (PBE0)
 Relativity              : None
 Environment             : PCM
 Checkpointing           : Off
 Max iterations          : 100
 KAIN solver             : 5
 Localization            : Off
 Diagonalization         : First two iterations
 Start precision         : 1.00000e-03
 Final precision         : 1.00000e-03
 Helmholtz precision     : Dynamic
 Energy threshold        : Off
 Orbital threshold       : 1.00000e-01
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                      Self-Consistent Reaction Field
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Accelerate with KAIN    : true 
 Algorithm               : scrf 
 Convergence criterion   : dynamic 
 Density type            : total 
 Dielec. const. (in)     : 1.0 
 Dielec. const. (out)    : 2.0 
 Max. iterations         : 100 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Brakjen commented 2 years ago

@stigrj

  • I don't like the final reaction energy print

What exactly should be improved? :)

stigrj commented 2 years ago

We now get many new energy contributions that are printed in the end even if they are not relevant. Same with the upcoming PBC addition. We should be printing only non-zero terms, at least for the non standard contributions.

stigrj commented 2 years ago

I like the new parameter output :+1: I wonder if the dielectric constants rather belong in the cavity part of the output? The problem is, they are not immediately connected in the code. We have the Cavity which is a pure geometric thing, which is combined with the dielectric constants into a physical Permittivity, which is then used to build the ReactionPotential in the SCRF.

Perhaps it's the Permittivity that should be printed, which would contain a Cavity, the dielectric constants and the "formulation" ("exponential" seems to be the only one implemented, but could still be stated in the output). And then we can print this Permittivity together with the SCRF optimization parameters just after their construction, before we start the ground-state SCF (instead of printing the Cavity up front together with the molecular geometry).

Brakjen commented 2 years ago

@stigrj:

Perhaps it's the Permittivity that should be printed, which would contain a Cavity, the dielectric constants and the "formulation" ("exponential" seems to be the only one implemented, but could still be stated in the output). And then we can print this Permittivity together with the SCRF optimization parameters just after their construction, before we start the ground-state SCF (instead of printing the Cavity up front together with the molecular geometry).

I have moved the printing to Permittivity.cpp, and the table now looks like this:

===========================================================================
                             Solvation Cavity
---------------------------------------------------------------------------
 Cavity width            :                                        0.500000
 Dielec. Const. (in)     :                                        1.000000
 Dielec. Const. (out)    :                                        2.000000
 Formulation             :                                     exponential
---------------------------------------------------------------------------
    N      Radius        :               x               y               z
---------------------------------------------------------------------------
    0    4.000000        :        0.000000        0.000000        0.000000
===========================================================================

But when printing these just after construction, which would be in driver::build_fock_operator, their placement in the output file does not seem optimal to me. For example, the Li test output looks like this:

Output file: Parameters printed in `driver::build_fock_operator` ``` *************************************************************************** *** *** *** *** *** __ __ ____ ____ _ *** *** | \/ | _ \ / ___| |__ ___ _ __ ___ *** *** | |\/| | |_) | | | '_ \ / _ \ '_ ` _ \ *** *** | | | | _ <| |___| | | | __/ | | | | | *** *** |_| |_|_| \_\\____|_| |_|\___|_| |_| |_| *** *** *** *** VERSION 1.1.0-alpha *** *** *** *** Git branch solvent-printouts *** *** Git commit hash fecdbe0524a548a8600b-dirty *** *** Git commit author Anders Brakestad *** *** Git commit date Tue May 10 10:24:30 2022 +0200 *** *** *** *** Contact: luca.frediani@uit.no *** *** *** *** Radovan Bast Magnar Bjorgve *** *** Roberto Di Remigio Antoine Durdek *** *** Luca Frediani Gabriel Gerez *** *** Stig Rune Jensen Jonas Juselius *** *** Rune Monstad Peter Wind *** *** *** *************************************************************************** --------------------------------------------------------------------------- MPI processes : (no bank) 1 OpenMP threads : 1 Total cores : 1 --------------------------------------------------------------------------- XCFun DFT library Copyright 2009-2020 Ulf Ekstrom and contributors. See http://dftlibs.org/xcfun/ for more information. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details see the documentation. Scientific users of this library should cite U. Ekstrom, L. Visscher, R. Bast, A. J. Thorvaldsen and K. Ruud; J.Chem.Theor.Comp. 2010, DOI: 10.1021/ct100117s --------------------------------------------------------------------------- MRCPP version : 1.4.0-alpha Git branch : HEAD Git commit hash : 2797a7a18efb69942a6e Git commit author : Stig Rune Jensen Git commit date : Fri Mar 12 12:48:07 2021 +0100 Linear algebra : EIGEN v3.3.7 Parallelization : NONE --------------------------------------------------------------------------- =========================================================================== MultiResolution Analysis --------------------------------------------------------------------------- polynomial order : 5 polynomial type : Interpolating --------------------------------------------------------------------------- total boxes : 8 boxes : [ 2 2 2 ] unit lengths : [ 16.00000 16.00000 16.00000 ] scaling factor : [ 1.00000 1.00000 1.00000 ] lower bounds : [ -16.00000 -16.00000 -16.00000 ] upper bounds : [ 16.00000 16.00000 16.00000 ] total length : [ 32.00000 32.00000 32.00000 ] =========================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Physical Constants ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ angstrom2bohrs : 1.8897261246257702 dipmom_au2debye : 2.5417464739297717 electron_g_factor : -2.00231930436256 fine_structure_constant : 0.0072973525693 hartree2ev : 27.211386245988 hartree2kcalmol : 627.5094740630558 hartree2kjmol : 2625.4996394798254 hartree2simagnetizability : 78.9451185 hartree2wavenumbers : 219474.6313632 light_speed : 137.035999084 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *************************************************************************** *** *** *** Initializing Molecule *** *** *** *************************************************************************** =========================================================================== Molecule --------------------------------------------------------------------------- Charge : 1 Multiplicity : 1 --------------------------------------------------------------------------- N Atom : x y z --------------------------------------------------------------------------- 0 Li : 0.000000 0.000000 0.000000 --------------------------------------------------------------------------- Center of mass : 0.000000 0.000000 0.000000 =========================================================================== *************************************************************************** *** *** *** Computing Ground State Wavefunction *** *** *** *************************************************************************** =========================================================================== Solvation Cavity --------------------------------------------------------------------------- Cavity width : 0.500000 Dielec. Const. (in) : 1.000000 Dielec. Const. (out) : 2.000000 Formulation : exponential --------------------------------------------------------------------------- N Radius : x y z --------------------------------------------------------------------------- 0 4.000000 : 0.000000 0.000000 0.000000 =========================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Self-Consistent Reaction Field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Accelerate with KAIN : true Algorithm : scrf Convergence criterion : dynamic Density type : total Dielec. const. (in) : 1.0 Dielec. const. (out) : 2.0 Max. iterations : 100 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Calculation : Compute initial orbitals Method : Diagonalize SAD Hamiltonian Precision : 1.00000e-03 Screening : 1.20000e+01 StdDev Restricted : True Functional : LDA (SVWN5) AO basis : Hydrogenic orbitals Zeta quality : 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =========================================================================== Molecular Orbitals --------------------------------------------------------------------------- Alpha electrons : 1 Beta electrons : 1 Total electrons : 2 --------------------------------------------------------------------------- n Occ Spin : Norm --------------------------------------------------------------------------- 0 2 p : 1.000000000000e+00 =========================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Calculation : Compute initial energy Method : DFT (PBE0) Relativity : None Precision : 1.00000e-03 Localization : Off ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =========================================================================== Molecular Energy (initial) --------------------------------------------------------------------------- Kinetic energy : (au) 7.675564301900 E-N energy : (au) -16.530755287695 Coulomb energy : (au) 3.332799383894 Exchange energy : (au) -0.416484495318 X-C energy : (au) -1.283772997761 Ext. field (el) : (au) 0.000000000000 --------------------------------------------------------------------------- N-N energy : (au) 0.000000000000 Ext. field (nuc) : (au) 0.000000000000 Tot. Reac. Energy : (au) 0.000000000000 El. Reac. Energy : (au) 0.000000000000 Nuc. Reac. Energy : (au) 0.000000000000 --------------------------------------------------------------------------- Electronic energy : (au) -7.222649094979 Nuclear energy : (au) 0.000000000000 --------------------------------------------------------------------------- Total energy : (au) -7.222649094979e+00 : (kcal/mol) -4.532280734932e+03 : (kJ/mol) -1.896306259496e+04 : (eV) -1.965382942427e+02 =========================================================================== =========================================================================== Orbital Energies (initial) --------------------------------------------------------------------------- n Occ Spin : Epsilon --------------------------------------------------------------------------- 0 2 p : (au) -2.332093141176 --------------------------------------------------------------------------- Sum occupied : (au) -4.664186282352 =========================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Self-Consistent Field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Calculation : Optimize ground state orbitals Method : DFT (PBE0) Relativity : None Environment : PCM Checkpointing : Off Max iterations : 100 KAIN solver : 5 Localization : Off Diagonalization : First two iterations Start precision : 1.00000e-03 Final precision : 1.00000e-03 Helmholtz precision : Dynamic Energy threshold : Off Orbital threshold : 1.00000e-01 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =========================================================================== Iter MO residual Total energy Update --------------------------------------------------------------------------- 0 1.000000e+00 -7.222649094979 -7.222649e+00 1 6.037085e-02 -7.320075664302 -9.742657e-02 --------------------------------------------------------------------------- SCF converged in 1 iterations! =========================================================================== *************************************************************************** *** *** *** Printing Molecular Properties *** *** *** *************************************************************************** =========================================================================== Molecule --------------------------------------------------------------------------- Charge : 1 Multiplicity : 1 --------------------------------------------------------------------------- N Atom : x y z --------------------------------------------------------------------------- 0 Li : 0.000000 0.000000 0.000000 --------------------------------------------------------------------------- Center of mass : 0.000000 0.000000 0.000000 =========================================================================== =========================================================================== Molecular Energy (final) --------------------------------------------------------------------------- Kinetic energy : (au) 7.584212118792 E-N energy : (au) -16.491476051686 Coulomb energy : (au) 3.357678874268 Exchange energy : (au) -0.419594145537 X-C energy : (au) -1.286849061623 Ext. field (el) : (au) 0.000000000000 --------------------------------------------------------------------------- N-N energy : (au) 0.000000000000 Ext. field (nuc) : (au) 0.000000000000 Tot. Reac. Energy : (au) -0.064047398516 El. Reac. Energy : (au) 0.128081335378 Nuc. Reac. Energy : (au) -0.192128733894 --------------------------------------------------------------------------- Electronic energy : (au) -7.127946930408 Nuclear energy : (au) -0.192128733894 --------------------------------------------------------------------------- Total energy : (au) -7.320075664302e+00 : (kcal/mol) -4.593416830208e+03 : (kJ/mol) -1.921885601759e+04 : (eV) -1.991894062512e+02 =========================================================================== =========================================================================== Orbital Energies (final) --------------------------------------------------------------------------- n Occ Spin : Epsilon --------------------------------------------------------------------------- 0 2 p : (au) -2.210659505993 --------------------------------------------------------------------------- Sum occupied : (au) -4.421319011986 =========================================================================== =========================================================================== Dipole Moment (dip-1) --------------------------------------------------------------------------- r_O : 0.000000 0.000000 0.000000 --------------------------------------------------------------------------- Electronic vector : -0.000000 0.000000 -0.000000 Magnitude : (au) 0.000000 : (Debye) 0.000000 --------------------------------------------------------------------------- Nuclear vector : 0.000000 0.000000 0.000000 Magnitude : (au) 0.000000 : (Debye) 0.000000 --------------------------------------------------------------------------- Total vector : 0.000000 0.000000 0.000000 Magnitude : (au) 0.000000 : (Debye) 0.000000 =========================================================================== *************************************************************************** *** *** *** Exiting MRChem *** *** *** *** Wall time : 0h 0m 45s *** *** *** *************************************************************************** ```

It is not completely clear in this output that the SCRF parameters are irrelevant for the initial guess, and that the solvent algorithms are only used for the subsequent SCF. Also, if the SCF::run keyword is set to false, the headline is still printed along with the (now completely irrelevant) SCRF and cavity parameters.

If I move the SCRF and cavity printouts to GroundStateSolver::optimize, and slightly modify the headlines in driver::scf::run, the output becomes:

Output file: Parameters printed in `GroundStateSolver::optimize` ``` *************************************************************************** *** *** *** *** *** __ __ ____ ____ _ *** *** | \/ | _ \ / ___| |__ ___ _ __ ___ *** *** | |\/| | |_) | | | '_ \ / _ \ '_ ` _ \ *** *** | | | | _ <| |___| | | | __/ | | | | | *** *** |_| |_|_| \_\\____|_| |_|\___|_| |_| |_| *** *** *** *** VERSION 1.1.0-alpha *** *** *** *** Git branch solvent-printouts *** *** Git commit hash fecdbe0524a548a8600b-dirty *** *** Git commit author Anders Brakestad *** *** Git commit date Tue May 10 10:24:30 2022 +0200 *** *** *** *** Contact: luca.frediani@uit.no *** *** *** *** Radovan Bast Magnar Bjorgve *** *** Roberto Di Remigio Antoine Durdek *** *** Luca Frediani Gabriel Gerez *** *** Stig Rune Jensen Jonas Juselius *** *** Rune Monstad Peter Wind *** *** *** *************************************************************************** --------------------------------------------------------------------------- MPI processes : (no bank) 1 OpenMP threads : 1 Total cores : 1 --------------------------------------------------------------------------- XCFun DFT library Copyright 2009-2020 Ulf Ekstrom and contributors. See http://dftlibs.org/xcfun/ for more information. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details see the documentation. Scientific users of this library should cite U. Ekstrom, L. Visscher, R. Bast, A. J. Thorvaldsen and K. Ruud; J.Chem.Theor.Comp. 2010, DOI: 10.1021/ct100117s --------------------------------------------------------------------------- MRCPP version : 1.4.0-alpha Git branch : HEAD Git commit hash : 2797a7a18efb69942a6e Git commit author : Stig Rune Jensen Git commit date : Fri Mar 12 12:48:07 2021 +0100 Linear algebra : EIGEN v3.3.7 Parallelization : NONE --------------------------------------------------------------------------- =========================================================================== MultiResolution Analysis --------------------------------------------------------------------------- polynomial order : 5 polynomial type : Interpolating --------------------------------------------------------------------------- total boxes : 8 boxes : [ 2 2 2 ] unit lengths : [ 16.00000 16.00000 16.00000 ] scaling factor : [ 1.00000 1.00000 1.00000 ] lower bounds : [ -16.00000 -16.00000 -16.00000 ] upper bounds : [ 16.00000 16.00000 16.00000 ] total length : [ 32.00000 32.00000 32.00000 ] =========================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Physical Constants ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ angstrom2bohrs : 1.8897261246257702 dipmom_au2debye : 2.5417464739297717 electron_g_factor : -2.00231930436256 fine_structure_constant : 0.0072973525693 hartree2ev : 27.211386245988 hartree2kcalmol : 627.5094740630558 hartree2kjmol : 2625.4996394798254 hartree2simagnetizability : 78.9451185 hartree2wavenumbers : 219474.6313632 light_speed : 137.035999084 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *************************************************************************** *** *** *** Initializing Molecule *** *** *** *************************************************************************** =========================================================================== Molecule --------------------------------------------------------------------------- Charge : 1 Multiplicity : 1 --------------------------------------------------------------------------- N Atom : x y z --------------------------------------------------------------------------- 0 Li : 0.000000 0.000000 0.000000 --------------------------------------------------------------------------- Center of mass : 0.000000 0.000000 0.000000 =========================================================================== *************************************************************************** *** *** *** Computing Initial Guess Wavefunction *** *** *** *************************************************************************** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Calculation : Compute initial orbitals Method : Diagonalize SAD Hamiltonian Precision : 1.00000e-03 Screening : 1.20000e+01 StdDev Restricted : True Functional : LDA (SVWN5) AO basis : Hydrogenic orbitals Zeta quality : 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =========================================================================== Molecular Orbitals --------------------------------------------------------------------------- Alpha electrons : 1 Beta electrons : 1 Total electrons : 2 --------------------------------------------------------------------------- n Occ Spin : Norm --------------------------------------------------------------------------- 0 2 p : 1.000000000000e+00 =========================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Calculation : Compute initial energy Method : DFT (PBE0) Relativity : None Precision : 1.00000e-03 Localization : Off ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =========================================================================== Molecular Energy (initial) --------------------------------------------------------------------------- Kinetic energy : (au) 7.675564301900 E-N energy : (au) -16.530755287695 Coulomb energy : (au) 3.332799383894 Exchange energy : (au) -0.416484495318 X-C energy : (au) -1.283772997761 Ext. field (el) : (au) 0.000000000000 --------------------------------------------------------------------------- N-N energy : (au) 0.000000000000 Ext. field (nuc) : (au) 0.000000000000 Tot. Reac. Energy : (au) 0.000000000000 El. Reac. Energy : (au) 0.000000000000 Nuc. Reac. Energy : (au) 0.000000000000 --------------------------------------------------------------------------- Electronic energy : (au) -7.222649094979 Nuclear energy : (au) 0.000000000000 --------------------------------------------------------------------------- Total energy : (au) -7.222649094979e+00 : (kcal/mol) -4.532280734932e+03 : (kJ/mol) -1.896306259496e+04 : (eV) -1.965382942427e+02 =========================================================================== =========================================================================== Orbital Energies (initial) --------------------------------------------------------------------------- n Occ Spin : Epsilon --------------------------------------------------------------------------- 0 2 p : (au) -2.332093141176 --------------------------------------------------------------------------- Sum occupied : (au) -4.664186282352 =========================================================================== *************************************************************************** *** *** *** Computing Ground State Wavefunction *** *** *** *************************************************************************** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Self-Consistent Field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Calculation : Optimize ground state orbitals Method : DFT (PBE0) Relativity : None Environment : PCM Checkpointing : Off Max iterations : 100 KAIN solver : 5 Localization : Off Diagonalization : First two iterations Start precision : 1.00000e-03 Final precision : 1.00000e-03 Helmholtz precision : Dynamic Energy threshold : Off Orbital threshold : 1.00000e-01 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Self-Consistent Reaction Field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Accelerate with KAIN : true Algorithm : scrf Convergence criterion : dynamic Density type : total Dielec. const. (in) : 1.0 Dielec. const. (out) : 2.0 Max. iterations : 100 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =========================================================================== Solvation Cavity --------------------------------------------------------------------------- Cavity width : 0.500000 Dielec. Const. (in) : 1.000000 Dielec. Const. (out) : 2.000000 Formulation : exponential --------------------------------------------------------------------------- N Radius : x y z --------------------------------------------------------------------------- 0 4.000000 : 0.000000 0.000000 0.000000 =========================================================================== =========================================================================== Iter MO residual Total energy Update --------------------------------------------------------------------------- 0 1.000000e+00 -7.222649094979 -7.222649e+00 1 6.037085e-02 -7.320075664302 -9.742657e-02 --------------------------------------------------------------------------- SCF converged in 1 iterations! =========================================================================== *************************************************************************** *** *** *** Printing Molecular Properties *** *** *** *************************************************************************** =========================================================================== Molecule --------------------------------------------------------------------------- Charge : 1 Multiplicity : 1 --------------------------------------------------------------------------- N Atom : x y z --------------------------------------------------------------------------- 0 Li : 0.000000 0.000000 0.000000 --------------------------------------------------------------------------- Center of mass : 0.000000 0.000000 0.000000 =========================================================================== =========================================================================== Molecular Energy (final) --------------------------------------------------------------------------- Kinetic energy : (au) 7.584212118792 E-N energy : (au) -16.491476051686 Coulomb energy : (au) 3.357678874268 Exchange energy : (au) -0.419594145537 X-C energy : (au) -1.286849061623 Ext. field (el) : (au) 0.000000000000 --------------------------------------------------------------------------- N-N energy : (au) 0.000000000000 Ext. field (nuc) : (au) 0.000000000000 Tot. Reac. Energy : (au) -0.064047398516 El. Reac. Energy : (au) 0.128081335378 Nuc. Reac. Energy : (au) -0.192128733894 --------------------------------------------------------------------------- Electronic energy : (au) -7.127946930408 Nuclear energy : (au) -0.192128733894 --------------------------------------------------------------------------- Total energy : (au) -7.320075664302e+00 : (kcal/mol) -4.593416830208e+03 : (kJ/mol) -1.921885601759e+04 : (eV) -1.991894062512e+02 =========================================================================== =========================================================================== Orbital Energies (final) --------------------------------------------------------------------------- n Occ Spin : Epsilon --------------------------------------------------------------------------- 0 2 p : (au) -2.210659505993 --------------------------------------------------------------------------- Sum occupied : (au) -4.421319011986 =========================================================================== =========================================================================== Dipole Moment (dip-1) --------------------------------------------------------------------------- r_O : 0.000000 0.000000 0.000000 --------------------------------------------------------------------------- Electronic vector : -0.000000 0.000000 -0.000000 Magnitude : (au) 0.000000 : (Debye) 0.000000 --------------------------------------------------------------------------- Nuclear vector : 0.000000 0.000000 0.000000 Magnitude : (au) 0.000000 : (Debye) 0.000000 --------------------------------------------------------------------------- Total vector : 0.000000 0.000000 0.000000 Magnitude : (au) 0.000000 : (Debye) 0.000000 =========================================================================== *************************************************************************** *** *** *** Exiting MRChem *** *** *** *** Wall time : 0h 0m 46s *** *** *** *************************************************************************** ```

This also plays well with higher print levels, since the parameters are printed right after the headline before any output from the calculation is printed.

stigrj commented 2 years ago

Kind of forgot about this. What's the status here? I agree your latter example looks better

stigrj commented 2 years ago

Actually, after looking more closely on this today, I think the correct thing is to print the Permittivity/Cavity information up front, and at the same time include solvent effect in the initial guess energy. This would be more in line with the rest of the terms.

For the initial guess, the orbitals are always "given" by the chosen method (previous mw calculation, sad guess, gto guess, etc), i.e. the solvent is not included (and should not be) when computing these initial orbitals. However, the initial energy should be computed with the "correct" electronic method using these given orbitals, i.e. solvent effects should be included here.

@Gabrielgerez why did we disable solvent effects on the first_iteration when setting up the ReactionPotential? I guess it had to do with some convergence issue with a poor guess density, but I don't see how it would make a difference to postpone the first SCRF from the initial guess and into the first SCF calculation. The first SCRF convergence should be much the same, no?

I will add some of these changes to this branch tomorrow.

stigrj commented 2 years ago

For now the solvent effect is not added to the initial energy, but I will make a follow-up PR where I suggest to change this.

Bottom line:

stigrj commented 2 years ago

Also rearranged the molecular energy output to this, with a similar block for external field terms:

===========================================================================
                         Molecular Energy (final)
---------------------------------------------------------------------------
 Kinetic energy          :            (au)                 88.754508805409
 E-N energy              :            (au)               -250.283910448742
 Coulomb energy          :            (au)                 62.007501412212
 Exchange energy         :            (au)                  0.000000000000
 X-C energy              :            (au)                -11.030631380367
 N-N energy              :            (au)                 19.012380172434
---------------------------------------------------------------------------
 Reaction energy (el)    :            (au)                  0.792270103652
 Reaction energy (nuc)   :            (au)                 -2.209027911782
 Reaction energy (tot)   :            (au)                 -1.416757808129
---------------------------------------------------------------------------
 Electronic energy       :            (au)               -109.760261507836
 Nuclear energy          :            (au)                 16.803352260652
---------------------------------------------------------------------------
 Total energy            :            (au)             -9.295690924718e+01
                         :      (kcal/mol)             -5.833134123223e+04
                         :        (kJ/mol)             -2.440583317156e+05
                         :            (eV)             -2.529486361758e+03
===========================================================================