9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-06-01 10:15:18 +02:00
qp2/src/hartree_fock/scf.irp.f

89 lines
2.5 KiB
Fortran
Raw Normal View History

2019-01-25 11:39:31 +01:00
program scf
BEGIN_DOC
2020-11-11 01:12:52 +01:00
!
2019-01-25 11:39:31 +01:00
! The :ref:`scf` program performs *Restricted* Hartree-Fock
! calculations (the spatial part of the |MOs| is common for alpha and beta
! spinorbitals).
2020-11-11 01:12:52 +01:00
!
2019-01-25 11:39:31 +01:00
! It performs the following actions:
2020-11-11 01:12:52 +01:00
!
2019-01-25 11:39:31 +01:00
! #. Compute/Read all the one- and two-electron integrals, and store them
! in memory
! #. Check in the |EZFIO| database if there is a set of |MOs|.
! If there is, it will read them as initial guess. Otherwise, it will
! create a guess.
! #. Perform the |SCF| iterations
2020-11-11 01:12:52 +01:00
!
2019-01-25 11:39:31 +01:00
! For the keywords related to the |SCF| procedure, see the ``scf_utils``
! directory where you will find all options.
2020-11-11 01:12:52 +01:00
!
2019-01-25 11:39:31 +01:00
! At each iteration, the |MOs| are saved in the |EZFIO| database. Hence,
! if the calculation crashes for any unexpected reason, the calculation
! can be restarted by running again the |SCF| with the same |EZFIO|
! database.
2020-11-11 01:12:52 +01:00
!
2019-01-25 11:39:31 +01:00
! To start again a fresh |SCF| calculation, the |MOs| can be reset by
! running the :ref:`qp_reset` command.
2020-11-11 01:12:52 +01:00
!
! The `DIIS`_ algorithm is implemented, as well as the `level-shifting`_
2019-01-25 11:39:31 +01:00
! method. If the |SCF| does not converge, try again with a higher value of
! :option:`level_shift`.
2020-11-11 01:12:52 +01:00
!
2019-01-25 11:39:31 +01:00
! .. _DIIS: https://en.wikipedia.org/w/index.php?title=DIIS
! .. _level-shifting: https://doi.org/10.1002/qua.560070407
!
END_DOC
call create_guess
call orthonormalize_mos
call run
end
subroutine create_guess
implicit none
BEGIN_DOC
! Create a MO guess if no MOs are present in the EZFIO directory
END_DOC
logical :: exists
PROVIDE ezfio_filename
call ezfio_has_mo_basis_mo_coef(exists)
if (.not.exists) then
2020-11-11 10:26:36 +01:00
mo_label = 'Guess'
2019-01-25 11:39:31 +01:00
if (mo_guess_type == "HCore") then
2020-11-11 15:51:19 +01:00
call restore_symmetry(ao_num,mo_num,mo_coef,size(mo_coef,1),1.d-10)
2019-01-25 11:39:31 +01:00
TOUCH mo_coef
call mo_as_eigvectors_of_mo_matrix(mo_one_e_integrals, &
size(mo_one_e_integrals,1), &
size(mo_one_e_integrals,2), &
mo_label,1,.false.)
2020-11-11 15:51:19 +01:00
call restore_symmetry(ao_num,mo_num,mo_coef,size(mo_coef,1),1.d-10)
2020-11-11 10:26:36 +01:00
SOFT_TOUCH mo_coef
2019-01-25 11:39:31 +01:00
else if (mo_guess_type == "Huckel") then
call huckel_guess
else
print *, 'Unrecognized MO guess type : '//mo_guess_type
stop 1
endif
2020-11-11 10:26:36 +01:00
SOFT_TOUCH mo_label
2019-01-25 11:39:31 +01:00
endif
end
subroutine run
BEGIN_DOC
! Run SCF calculation
END_DOC
use bitmasks
implicit none
integer :: i_it, i, j, k
2020-11-11 16:27:22 +01:00
mo_label = 'Orthonormalized'
2019-01-25 11:39:31 +01:00
call Roothaan_Hall_SCF
call ezfio_set_hartree_fock_energy(SCF_energy)
end