Skip to content

Commit

Permalink
Simplify and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrack committed May 10, 2021
1 parent ce862d2 commit b7d9803
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
54 changes: 17 additions & 37 deletions src/qs_scf_post_se.F
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
!> \par History
!> Started printing preliminary stuff for MO_CUBES and MO requires some
!> more work to complete all other functionalities
!> - Revise MO information printout (10.05.2021, MK)
!> \author Teodoro Laino (07.2008)
! **************************************************************************************************
MODULE qs_scf_post_se
!

USE ai_moments, ONLY: moment
USE atomic_kind_types, ONLY: atomic_kind_type,&
get_atomic_kind
Expand Down Expand Up @@ -56,10 +57,10 @@ MODULE qs_scf_post_se
qs_kind_type
USE qs_ks_methods, ONLY: qs_ks_update_qs_env
USE qs_ks_types, ONLY: qs_ks_did_change
USE qs_mo_io, ONLY: write_mo_set
USE qs_mo_types, ONLY: mo_set_p_type
USE qs_rho_types, ONLY: qs_rho_get,&
qs_rho_type
USE qs_scf_output, ONLY: qs_scf_write_mos
USE qs_scf_types, ONLY: qs_scf_env_type
USE qs_subsys_types, ONLY: qs_subsys_get,&
qs_subsys_type
USE semi_empirical_types, ONLY: get_se_param,&
Expand Down Expand Up @@ -99,8 +100,6 @@ SUBROUTINE scf_post_calculation_se(qs_env)
LOGICAL :: explicit, my_localized_wfn
TYPE(cp_logger_type), POINTER :: logger
TYPE(cp_para_env_type), POINTER :: para_env
TYPE(dft_control_type), POINTER :: dft_control
TYPE(mo_set_p_type), DIMENSION(:), POINTER :: mos
TYPE(particle_list_type), POINTER :: particles
TYPE(qs_rho_type), POINTER :: rho
TYPE(qs_subsys_type), POINTER :: subsys
Expand All @@ -112,17 +111,14 @@ SUBROUTINE scf_post_calculation_se(qs_env)
CALL write_available_results(qs_env)

my_localized_wfn = .FALSE.
NULLIFY (dft_control, mos, rho, &
subsys, particles, input, print_key, para_env)
NULLIFY (rho, subsys, particles, input, print_key, para_env)

logger => cp_get_default_logger()
output_unit = cp_logger_get_default_io_unit(logger)

CPASSERT(ASSOCIATED(qs_env))
! Here we start with data that needs a postprocessing...
CALL get_qs_env(qs_env, &
dft_control=dft_control, &
mos=mos, &
rho=rho, &
input=input, &
subsys=subsys, &
Expand Down Expand Up @@ -322,7 +318,7 @@ SUBROUTINE qs_scf_post_moments(input, logger, qs_env)
dggamma(j) = dggamma(j)*zeta + ggamma(j)*dzeta
ggamma(j) = ggamma(j)*zeta
END DO
ENDDO
END DO
END DO
dggamma = dggamma*zphase + ggamma*dzphase
ggamma = ggamma*zphase
Expand Down Expand Up @@ -458,8 +454,7 @@ END SUBROUTINE atomic_moments
!> \param rho ...
!> \param para_env ...
! **************************************************************************************************
SUBROUTINE qs_scf_post_charges(input, logger, qs_env, rho, &
para_env)
SUBROUTINE qs_scf_post_charges(input, logger, qs_env, rho, para_env)
TYPE(section_vals_type), POINTER :: input
TYPE(cp_logger_type), POINTER :: logger
TYPE(qs_environment_type), POINTER :: qs_env
Expand Down Expand Up @@ -600,60 +595,45 @@ SUBROUTINE write_available_results(qs_env)

INTEGER :: after, handle, ispin, iw, output_unit
LOGICAL :: omit_headers
TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
TYPE(cell_type), POINTER :: cell
TYPE(cp_logger_type), POINTER :: logger
TYPE(cp_para_env_type), POINTER :: para_env
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, rho_ao
TYPE(dft_control_type), POINTER :: dft_control
TYPE(mo_set_p_type), DIMENSION(:), POINTER :: mos
TYPE(particle_list_type), POINTER :: particles
TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
TYPE(qs_rho_type), POINTER :: rho
TYPE(qs_scf_env_type), POINTER :: scf_env
TYPE(qs_subsys_type), POINTER :: subsys
TYPE(section_vals_type), POINTER :: dft_section, input

CALL timeset(routineN, handle)
NULLIFY (cell, dft_control, mos, atomic_kind_set, particle_set, rho, &
ks_rmpv, dft_section, input, &
NULLIFY (dft_control, particle_set, rho, ks_rmpv, dft_section, input, &
particles, subsys, para_env, rho_ao)
logger => cp_get_default_logger()
output_unit = cp_logger_get_default_io_unit(logger)

CPASSERT(ASSOCIATED(qs_env))
CALL get_qs_env(qs_env, &
dft_control=dft_control, &
mos=mos, &
atomic_kind_set=atomic_kind_set, &
qs_kind_set=qs_kind_set, &
particle_set=particle_set, &
rho=rho, &
matrix_ks=ks_rmpv, &
input=input, &
cell=cell, &
subsys=subsys, &
scf_env=scf_env, &
para_env=para_env)
CALL qs_subsys_get(subsys, particles=particles)

CALL qs_rho_get(rho, rho_ao=rho_ao)

! Print MO information if requested
dft_section => section_vals_get_subs_vals(input, "DFT")
IF (dft_control%nspins == 2) THEN
CALL write_mo_set(mos(1)%mo_set, atomic_kind_set, qs_kind_set, particle_set, &
dft_section, 4, 0, final_mos=.TRUE., spin="ALPHA")
CALL write_mo_set(mos(2)%mo_set, atomic_kind_set, qs_kind_set, particle_set, &
dft_section, 4, 0, final_mos=.TRUE., spin="BETA")
ELSE
CALL write_mo_set(mos(1)%mo_set, atomic_kind_set, qs_kind_set, particle_set, &
dft_section, 4, 0, final_mos=.TRUE.)
END IF
CALL qs_scf_write_mos(qs_env, scf_env, final_mos=.TRUE.)

! *** at the end of scf print out the projected dos per kind
! Aat the end of SCF printout the projected DOS for each atomic kind
dft_section => section_vals_get_subs_vals(input, "DFT")
IF (BTEST(cp_print_key_should_output(logger%iter_info, dft_section, "PRINT%PDOS") &
, cp_p_file)) THEN
CPWARN("PDOS not implemented for Semi-Empirical calculations!!")
ENDIF
END IF

! Print the total density (electronic + core charge)
IF (BTEST(cp_print_key_should_output(logger%iter_info, input, &
Expand Down Expand Up @@ -683,13 +663,13 @@ SUBROUTINE write_available_results(qs_env)
IF (BTEST(cp_print_key_should_output(logger%iter_info, input, &
"DFT%PRINT%V_HARTREE_CUBE"), cp_p_file)) THEN
CPWARN("V_HARTREE_CUBE not implemented for Semi-Empirical calculations!!")
ENDIF
END IF

! Print the XC potential
IF (BTEST(cp_print_key_should_output(logger%iter_info, input, &
"DFT%PRINT%V_XC_CUBE"), cp_p_file)) THEN
CPWARN("V_XC_CUBE not available for Semi-Empirical calculations!!")
ENDIF
END IF

! Write the density matrix
CALL section_vals_val_get(input, "DFT%PRINT%AO_MATRICES%OMIT_HEADERS", l_val=omit_headers)
Expand Down
1 change: 1 addition & 0 deletions src/qs_scf_post_tb.F
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
!> \brief Does all kind of post scf calculations for DFTB
!> \par History
!> Started as a copy from the GPW file
!> - Revise MO information printout (10.05.2021, MK)
!> \author JHU (03.2013)
! **************************************************************************************************
MODULE qs_scf_post_tb
Expand Down

0 comments on commit b7d9803

Please sign in to comment.