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

REVISED: Implementation of the density tight-binding (PTB) method #963

Merged
merged 131 commits into from
Feb 16, 2024

Conversation

marcelmbn
Copy link
Member

This pull request contains the full implementation of the PTB method as described in: J. Chem. Phys. 158, 124111 (2023) The implementation is based on infrastructure and standard routines provided by tblite. Thus, PTB is only available if WITH_TBLITE is true; in other cases, the program is terminated. A key design principle in this implementation was that the code is located in the xtb source code but (except for printouts and similar things) does not rely on xtb infrastructure but on more modern tblite, mctc-lib, multicharge routines. All empirical parameters are included in the source code, so no parameter file is necessary/possible. This includes also the vDZP basis set, as published with the ωB97X-3c method.

A reference stand-alone implementation is provided in grimme-lab/ptb. The results should be similar, however, the reference implementation partially uses single-precision while the present implementation is (currently) based on double precision matrices throughout. That's why the differences can be at the level of 10⁻⁵ (charges) up to 10⁻¹ (polarizabilities).

A typical calculation is invoked via xtb <struc_file> --ptb. Additionally, the run type --alpha is new and refers to the calculation of the polarizability tensor via PTB (not (yet) possible with GFNn-xTB/FF). The mixed vibrational spectra are accessible with xtb <struc_file> --ptb --hess [--alpha].

The procedure that is undergone after the command above is the following:

  • Setup of a new calculator type in src/main/setup.f90 and src/ptb/calculator.F90.
  • Add basis set, coordination number and EEQ model.
  • Enter singlepoint routine in src/ptb/calculator.F90 and add a new tblite wavefunction. Doing it earlier in the code would be possible but restarting PTB is not possible anyway, which is why I decided against it.
  • Entering the central twostepscf procedure (src/ptb/twostepscf.F90), which is designed not as a two-fold iterative cycle but as a one-shot procedure containing two diagonalizations. The reason for this design decision is mainly that the similarity between the first and the second iteration is limited – the employed routines are the same but the parameters entering and some adaptions to the variables are different for many contributions.
  • twostepscf works only as a wrapper module for collecting the distinct Hamiltonian contribution. Since PTB works differently compared to GFNn-xTB (many variables are re-used several times), all required overlap matrices and coordination numbers are calculated at the beginning of the actual procedure. Then, the approximated effective core potential (ECP), the shell levels, and the EEQ guess charges are calculated.
    After setting up the EEQ guess and the initial Coulomb matrix, the first iteration starts. Within both iterations, H0 is collected and added onto the (constant) V_ECP. After that, the different density-dependent potentials (2nd and 3rd-order electrostatics, Pauli-XC, DFT+U, and (if present) an external electric field are added. Each iteration ends with diagonalizing the full H matrix and calculating the mixed Mulliken-Löwdin charges.
  • twostepscf provides a complete wavefunction including the density and atomic/shell charges. Additionally, the dipole and quadrupole moments, all required integrals, and the bond orders are stored.
  • The tblite wavefunction type is then copied onto the xtb wavefunction type to be able to use xtb property evaluation and printout routines down the road.
  • In a polarizability calculation (--alpha), numgrad_polarizability is called after the twostepscf. It is a "modified" numerical differentiation of the dipole moment with respect to an infinitesimally small external electric field, in which not the standard twostepscf but a single diagonalization-variant in onestepscf is called. The principle in the construction of the effective Hamiltonian is the same, however.
  • Within the singlepoint routine, almost no results are printed except for a "Setup" block similar to what GFN-xTB does.
  • For printing out properties, a mixture of xtb and special (new) PTB routines is invoked (see ptb_property and main_ptb_json).

A noteworthy addition within this PR is the functionality of mixing GFNn-xTB/FF frequencies with PTB dipole moment derivatives or polarizability derivatives to obtain higher-quality IR and Raman spectra. Currently, this is limited to the combination of GFN2-xTB+PTB as shown in the PTB publication, but principle-wise this could be handled also generally in the future.
Furthermore, the correct Raman activities and absolute differential Raman scattering cross-sections (in m^2/sr) are implemented into src/hessian.F90 and src/freq/io.f90. In this course, also the vibspectrum file was updated.

The implementation comes with tests for the full Hamiltonian including the response approximation and the polarizability itself. It should work with both meson and CMake.

Moreover, some files were reformatted via fprettify and the following settings:
--- formatting changes were deleted from the present PR ---

Signed-off-by: Marcel Müller <[email protected]>
…t with scaled HO overlap from ptb

Signed-off-by: Marcel Müller <[email protected]>
Signed-off-by: Marcel Müller <[email protected]>
…ock; correct formattings.

Signed-off-by: Marcel Mueller <[email protected]>
Signed-off-by: Marcel Müller <[email protected]>
awvwgk
awvwgk previously requested changes Feb 13, 2024
Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR applies formatting changes to many files, I recommend to split applying the formatter fprettify first in a separate and then add the new features.

@marcelmbn
Copy link
Member Author

This PR applies formatting changes to many files, I recommend to split applying the formatter fprettify first in a separate and then add the new features.

Done. Thank you for the advice, this makes life way easier. 👍

@marcelmbn marcelmbn requested a review from awvwgk February 13, 2024 11:28
Signed-off-by: albert <[email protected]>
Signed-off-by: Albert Katbashev <[email protected]>
Copy link
Member

@Albkat Albkat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of the CLI options is missing (5d3648f).

Copy link
Member

@Albkat Albkat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why you consider fnv for PTB as a special case?
I tested this locally and it seems to work properly.

@Albkat Albkat removed the request for review from awvwgk February 16, 2024 15:32
Albkat
Albkat previously approved these changes Feb 16, 2024
@Albkat Albkat dismissed awvwgk’s stale review February 16, 2024 15:34

it is already done

@marcelmbn marcelmbn merged commit e183f2b into grimme-lab:main Feb 16, 2024
11 checks passed
gorges97 pushed a commit to gorges97/xtb that referenced this pull request Mar 27, 2024
…imme-lab#963)

* initial PTB files and directories

Signed-off-by: Marcel Müller <[email protected]>

* add citation and initial variables for parameter files

Signed-off-by: Marcel Müller <[email protected]>

* reformat code of main.F90 via fprettify

Signed-off-by: Marcel Müller <[email protected]>

* prepared technical environment for setup of PTB parameters and calculator

Signed-off-by: Marcel Müller <[email protected]>

* removed last xtb parts in PTB files, adapted to missing parameter file

Signed-off-by: Marcel Müller <[email protected]>

* initial inclusion of PTB parameters

Signed-off-by: Marcel Müller <[email protected]>

* prepared vDZP basis setup

Signed-off-by: Marcel Müller <[email protected]>

* coefficients and exponents of vDZP initialized

Signed-off-by: Marcel Müller <[email protected]>

* full relevant vDZP data included; only incorporation into tblite basis type required now

Signed-off-by: Marcel Müller <[email protected]>

* pre-processing options activated

Signed-off-by: Marcel Müller <[email protected]>

* add vDZP basis set in principle completed

Signed-off-by: Marcel Müller <[email protected]>

* correct errors in vDZP setup and remove deprecated code

Signed-off-by: Marcel Müller <[email protected]>

* overlap corresponds to PTB overlap

Signed-off-by: Marcel Müller <[email protected]>

* move overlaps with scaled exponents in separate subroutines, agreement with scaled HO overlap from ptb

Signed-off-by: Marcel Müller <[email protected]>

* all three overlap matrices present and correct; start for ML-pop analysis implementation

Signed-off-by: Marcel Müller <[email protected]>

* correct formatting for overlaps routine

Signed-off-by: Marcel Müller <[email protected]>

* format some files correctly

Signed-off-by: Marcel Müller <[email protected]>

* Mixed Mulliken/Loewdin population analyses overlap matrices

Signed-off-by: Marcel Müller <[email protected]>

* Clean up calculator module use, implement coordination numbers

Signed-off-by: Marcel Müller <[email protected]>

* Include EEQ model and corresponding parameters

Signed-off-by: Marcel Müller <[email protected]>

* initial PTB tests, code formatting and float type assignments for DIPRO and CPX

Signed-off-by: Marcel Mueller <[email protected]>

* added tests for EEQ, basis and ML-pop scheme; added molecule to molstock; correct formattings.

Signed-off-by: Marcel Mueller <[email protected]>

* Initial implementation of PTB core basis

Signed-off-by: Marcel Müller <[email protected]>

* Core valence overlap matrix finalized; better structure type translation

Signed-off-by: Marcel Mueller <[email protected]>

* Started implementation of V_ECP

Signed-off-by: Marcel Mueller <[email protected]>

* Vecp working, no tests yet

Signed-off-by: Marcel Müller <[email protected]>

* V_ECP test working, commented print statements out

Signed-off-by: Marcel Müller <[email protected]>

* V_ECP fully implemented, removed DEV print statements

Signed-off-by: Marcel Müller <[email protected]>

* preparation for modularization of parameter data

Signed-off-by: Marcel Mueller <[email protected]>

* Finalized modularization of ECP parameters

Signed-off-by: Marcel Müller <[email protected]>

* Modularize EEQ parameters and remove not required public parameters

Signed-off-by: Marcel Müller <[email protected]>

* initialize wavefunction and rename core_basis function

Signed-off-by: Marcel Mueller <[email protected]>

* initial steps for Hamiltonian setup for PTB

Signed-off-by: Marcel Mueller <[email protected]>

* self-energy parameterization complete and self-energies matching

Signed-off-by: Marcel Müller <[email protected]>

* completed self-energy and added test

Signed-off-by: Marcel Müller <[email protected]>

* remove wrong Vecp allocation

Signed-off-by: Marcel Müller <[email protected]>

* prepare H0 setup and remove unnecessary variables in tests

Signed-off-by: Marcel Müller <[email protected]>

* early implementation of H0, removal of highest_elem variable, move vDZP globals to vDZP module

Signed-off-by: Marcel Müller <[email protected]>

* final H0 implementation for off-center terms

Signed-off-by: Marcel Müller <[email protected]>

* H0 implementation complete

Signed-off-by: Marcel Müller <[email protected]>

* EEQ charges for initial shell population, removal of unnecessary data statements

Signed-off-by: Marcel Müller <[email protected]>

* prepared h0 unit test

Signed-off-by: Marcel Müller <[email protected]>

* Implement Pauli XC contribution

Signed-off-by: Marcel Mueller <[email protected]>

* add Vxc test; moved some parameters to data types, deallocate H0

Signed-off-by: Marcel Mueller <[email protected]>

* new formatting guidelines

Signed-off-by: Marcel Mueller <[email protected]>

* refactored integrals in general and specifically overlap handling and prepared potential add-on to H0

Signed-off-by: Marcel Mueller <[email protected]>

* prepared potential for adding density-dependent terms

Signed-off-by: Marcel Mueller <[email protected]>

* Include Hubbard parameter and corresponding test

Signed-off-by: Marcel Mueller <[email protected]>

* prepared Hubbard parameter, coulomb matrix and potential setup

Signed-off-by: Marcel Mueller <[email protected]>

* effective gamma shellwise and modified test

Signed-off-by: Marcel Müller <[email protected]>

* tests for Hubbard matrix

Signed-off-by: Marcel Müller <[email protected]>

* Coulomb matrix implemented

Signed-off-by: Marcel Müller <[email protected]>

* Coulomb potential added onto effective Hamiltonian together with charges complete

Signed-off-by: Marcel Müller <[email protected]>

* third-order electrostatics included; H matrix for first iteration fully complete and correct; TESTS missing

Signed-off-by: Marcel Müller <[email protected]>

* H0 test included

Signed-off-by: Marcel Müller <[email protected]>

* removed dummy routine for hamiltonian and refer directly to H0 (now get_hamiltonian)

Signed-off-by: Marcel Müller <[email protected]>

* put overlap routine in own fast and parallel routine instead of standard tblite call

Signed-off-by: Marcel Müller <[email protected]>

* included dipole integrals in a fast way and renamed everything from overlap to integrals and neglect '_scaled'

Signed-off-by: Marcel Müller <[email protected]>

* integrated test for Coulomb potential and renamed integral module; minor changes

Signed-off-by: Marcel Müller <[email protected]>

* Solve and get density after 1st iteration

Signed-off-by: Marcel Müller <[email protected]>

* parallelization for get_hamiltonian; removed useless variables

Signed-off-by: Marcel Müller <[email protected]>

* parallelize coulomb potential

Signed-off-by: Marcel Müller <[email protected]>

* shell populations and charges after first iteration

Signed-off-by: Marcel Müller <[email protected]>

* transformed basis set from id-specific to atom-specific to setup overlap_h0 ('S^S') for second iteration

Signed-off-by: Marcel Müller <[email protected]>

* H0, VECP and VXC in second iteration

Signed-off-by: Marcel Müller <[email protected]>

* Coulomb potential in second and third order implemented also for second iteration

Signed-off-by: Marcel Müller <[email protected]>

* self energies of +U matrix working

Signed-off-by: Marcel Müller <[email protected]>

* Interatomic damping matrix for +U contribution

Signed-off-by: Marcel Müller <[email protected]>

* final H mat complete, +U potential complete

Signed-off-by: Marcel Müller <[email protected]>

* add potentials directly onto wfn%coeff

Signed-off-by: Marcel Müller <[email protected]>

* final density matrix correct, epsilon scaling implemented

Signed-off-by: Marcel Müller <[email protected]>

* shell pops and atomic charges correct

Signed-off-by: Marcel Müller <[email protected]>

* correct error in +U potential, better dev printout, correct error in dipole integral calculation, removed unnecessary prints

Signed-off-by: Marcel Müller <[email protected]>

* Dipole moment working

Signed-off-by: Marcel Müller <[email protected]>

* Wiberg bond orders working and parts of printout implemented

Signed-off-by: Marcel Müller <[email protected]>

* Basic printout complete.

Signed-off-by: Marcel Müller <[email protected]>

* Electric field implemented and better printout

Signed-off-by: Marcel Müller <[email protected]>

* total charge printout

Signed-off-by: Marcel Müller <[email protected]>

* started response implementation

Signed-off-by: Marcel Müller <[email protected]>

* correct ifort error since naming of subroutine and module cannot be the same

Signed-off-by: Marcel Mueller <[email protected]>

* H0 of response one-scf complete

Signed-off-by: Marcel Müller <[email protected]>

* shift calculation of elements to shell level and not re-do it in every AO iteration

Signed-off-by: Marcel Müller <[email protected]>

* Pauli XC and ES potential in onescf working (TO-part of ES not tested yet)

Signed-off-by: Marcel Müller <[email protected]>

* final H matrix of onescf complete

Signed-off-by: Marcel Müller <[email protected]>

* removal of unnecessary code trash

Signed-off-by: Marcel Müller <[email protected]>

* electric field addition also working

Signed-off-by: Marcel Müller <[email protected]>

* dipole moment after perturbation correct

Signed-off-by: Marcel Müller <[email protected]>

* polarizability fully working with printout

Signed-off-by: Marcel Müller <[email protected]>

* better error management, removal of unnecessary printouts, better print-out

Signed-off-by: Marcel Müller <[email protected]>

* extend moments to quadrupole moments. CAUTION: No analog in ref. implementation, so no direct check possible. Correct print-out missing.

Signed-off-by: Marcel Müller <[email protected]>

* Quadrupole tensor output

Signed-off-by: Marcel Müller <[email protected]>

* remove old xtb code snippets

Signed-off-by: Marcel Müller <[email protected]>

* test for +U potential and removed unnecessary printouts

Signed-off-by: Marcel Müller <[email protected]>

* test of final PTB results (qat, psh, wbo)

Signed-off-by: Marcel Müller <[email protected]>

* add test for charged species

Signed-off-by: Marcel Müller <[email protected]>

* included some more tests

Signed-off-by: Marcel Müller <[email protected]>

* modified finite-field-step for alpha to make it more robust in presence of an external field

Signed-off-by: Marcel Müller <[email protected]>

* polarizability test included

Signed-off-by: Marcel Müller <[email protected]>

* remove old code snippets

Signed-off-by: Marcel Müller <[email protected]>

* refactored electric property setup, calculator without mol. struc., initial IR implementation

Signed-off-by: Marcel Müller <[email protected]>

* completed Raman and IR implementation for PTB

Signed-off-by: Marcel Müller <[email protected]>

* reformat convert.f90

Signed-off-by: Marcel Müller <[email protected]>

* implement actual Raman intensities

Signed-off-by: Marcel Müller <[email protected]>

* restructure vibspectrum printout

Signed-off-by: Marcel Müller <[email protected]>

* correct typo in intensity calculation

Signed-off-by: Marcel Müller <[email protected]>

* reformat freq io.90

Signed-off-by: Marcel Müller <[email protected]>

* reformat json.f90 and prepare PTB JSON output

Signed-off-by: Marcel Müller <[email protected]>

* adapted JSON output to PTB

Signed-off-by: Marcel Müller <[email protected]>

* adapt JSON output to match PTB better

Signed-off-by: Marcel Müller <[email protected]>

* add bond order and shell charges to JSON printout

Signed-off-by: Marcel Müller <[email protected]>

* JSON output for Raman activities

Signed-off-by: Marcel Müller <[email protected]>

* make xtb with PTB compilable also with switched-off tblite dependency (then without PTB support)

Signed-off-by: Marcel Müller <[email protected]>

* CMake preparation improved

Signed-off-by: Marcel Müller <[email protected]>

* minor corrections for the compile process

Signed-off-by: Marcel Müller <[email protected]>

* reformat indentations

Signed-off-by: albert <[email protected]>

* small changes

Signed-off-by: albert <[email protected]>

* resolved last merge conflicts with periodic GFN-FF

Signed-off-by: Marcel Müller <[email protected]>

* reformat files consistent to formatting in main

Signed-off-by: Marcel Müller <[email protected]>

* preprocessor free main

Signed-off-by: albert <[email protected]>
Signed-off-by: Albert Katbashev <[email protected]>

* update man-page and usage instructions

* unify efield for PTB and GFN-FF

Signed-off-by: albert <[email protected]>

* remove the hardcoded etemp for xtb and ptb calc

Signed-off-by: albert <[email protected]>

* make the presence of param_ptb.txt non-critical

Signed-off-by: albert <[email protected]>

* update help and man pages for ptb- and Raman/polarizability-related options

Signed-off-by: Marcel Müller <[email protected]>

* Update src/prog/main.F90

* Update src/prog/main.F90

* Update src/prog/main.F90

* add debug mode for dev write statements

Signed-off-by: albert <[email protected]>

* remove parameters from shared variables in OMP statement

Signed-off-by: Marcel Müller <[email protected]>

---------

Signed-off-by: Marcel Müller <[email protected]>
Signed-off-by: Marcel Mueller <[email protected]>
Signed-off-by: albert <[email protected]>
Signed-off-by: Albert Katbashev <[email protected]>
Co-authored-by: albert <[email protected]>
Co-authored-by: Albert Katbashev <[email protected]>
Signed-off-by: Johannes Gorges <[email protected]>
@marcelmbn marcelmbn mentioned this pull request Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request method: PTB One of the possible run types in the xtb program package. Performs a PTB calculation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants