Skip to content

Commit

Permalink
Better leverage mathconstants module.
Browse files Browse the repository at this point in the history
  • Loading branch information
hfp committed Apr 19, 2024
1 parent c9a98bc commit c9bffc1
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
7 changes: 4 additions & 3 deletions src/aobasis/ai_onecenter.F
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ MODULE ai_onecenter
fac,&
gamma0,&
gamma1,&
pi
pi,&
rootpi
#include "../base/base_uses.f90"

IMPLICIT NONE
Expand Down Expand Up @@ -74,7 +75,7 @@ SUBROUTINE sg_overlap(smat, l, pa, pb)

CPASSERT(.NOT. (n > SIZE(smat, 1) .OR. m > SIZE(smat, 2)))

spi = SQRT(pi)/2.0_dp**(l + 2)*dfac(2*l + 1)
spi = rootpi/2.0_dp**(l + 2)*dfac(2*l + 1)
el = REAL(l, dp) + 1.5_dp

DO iq = 1, m
Expand Down Expand Up @@ -111,7 +112,7 @@ SUBROUTINE sg_kinetic(kmat, l, pa, pb)

CPASSERT(.NOT. (n > SIZE(kmat, 1) .OR. m > SIZE(kmat, 2)))

spi = dfac(2*l + 3)*SQRT(pi)/2.0_dp**(l + 2)
spi = dfac(2*l + 3)*rootpi/2.0_dp**(l + 2)
DO iq = 1, m
DO ip = 1, n
kmat(ip, iq) = spi*pa(ip)*pb(iq)/(pa(ip) + pb(iq))**(l + 2.5_dp)
Expand Down
5 changes: 3 additions & 2 deletions src/atom_energy.F
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ MODULE atom_energy
dp
USE mathconstants, ONLY: dfac,&
gamma1,&
pi
pi,&
rootpi
USE periodic_table, ONLY: nelem,&
ptable
USE physcon, ONLY: bohr
Expand Down Expand Up @@ -583,7 +584,7 @@ SUBROUTINE atom_response_basis(atom, delta, nder, iw)
WRITE (iw, '(/,A,I0,A,I0,A)') " Exponent Coef.(Quickstep Normalization), first ", &
n - nder, " valence ", nder, " response"
expzet = 0.25_dp*REAL(2*l + 3, dp)
prefac = SQRT(SQRT(pi)/2._dp**(l + 2)*dfac(2*l + 1))
prefac = SQRT(rootpi/2._dp**(l + 2)*dfac(2*l + 1))
DO i = 1, m
zeta = (2._dp*atom%basis%am(i, l))**expzet
WRITE (iw, '(4X,F20.10,4X,15ES20.6)') atom%basis%am(i, l), ((prefac*rbasis(i, k, l)/zeta), k=1, n)
Expand Down
8 changes: 4 additions & 4 deletions src/atom_grb.F
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ MODULE atom_grb
dp
USE lapack, ONLY: lapack_ssygv
USE mathconstants, ONLY: dfac,&
pi
rootpi
USE orbital_pointers, ONLY: deallocate_orbital_pointers,&
init_orbital_pointers
USE orbital_transformation_matrices, ONLY: deallocate_spherical_harmonics,&
Expand Down Expand Up @@ -322,7 +322,7 @@ SUBROUTINE atom_grb_construction(atom_info, atom_section, iw)

! Quickstep normalization
expzet = 0.25_dp*REAL(2*l + 3, dp)
prefac = SQRT(SQRT(pi)/2._dp**(l + 2)*dfac(2*l + 1))
prefac = SQRT(rootpi/2._dp**(l + 2)*dfac(2*l + 1))
DO i = 1, m
zeta = (2._dp*atom%basis%am(i, l))**expzet
qbasis(i, 1:n, l) = rbasis(i, 1:n, l)*prefac/zeta
Expand Down Expand Up @@ -630,7 +630,7 @@ SUBROUTINE atom_grb_construction(atom_info, atom_section, iw)
! Quickstep normalization polarization basis
DO l = 0, 7
expzet = 0.25_dp*REAL(2*l + 3, dp)
prefac = SQRT(SQRT(pi)/2._dp**(l + 2)*dfac(2*l + 1))
prefac = SQRT(rootpi/2._dp**(l + 2)*dfac(2*l + 1))
DO i = 1, num_pol
zeta = (2._dp*alp(i))**expzet
pbasis(i, 1:num_pol, l) = pbasis(i, 1:num_pol, l)*prefac/zeta
Expand All @@ -639,7 +639,7 @@ SUBROUTINE atom_grb_construction(atom_info, atom_section, iw)
! Quickstep normalization extended basis
DO l = 0, lmat
expzet = 0.25_dp*REAL(2*l + 3, dp)
prefac = SQRT(SQRT(pi)/2._dp**(l + 2)*dfac(2*l + 1))
prefac = SQRT(rootpi/2._dp**(l + 2)*dfac(2*l + 1))
DO i = 1, next_prim(l)
zeta = (2._dp*ale(i))**expzet
ebasis(i, 1:next_bas(l), l) = ebasis(i, 1:next_bas(l), l)*prefac/zeta
Expand Down
5 changes: 3 additions & 2 deletions src/atom_output.F
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ MODULE atom_output
USE kinds, ONLY: default_string_length,&
dp
USE mathconstants, ONLY: dfac,&
pi
pi,&
rootpi
USE periodic_table, ONLY: ptable
USE physcon, ONLY: evolt
USE xc_derivatives, ONLY: xc_functional_get_info
Expand Down Expand Up @@ -472,7 +473,7 @@ SUBROUTINE atom_print_basis_file(atom_basis, wfn)
WRITE (iw, '(T3,A,I3)') "L Quantum Number:", l
! Quickstep normalization
expzet = 0.25_dp*REAL(2*l + 3, dp)
prefac = SQRT(SQRT(pi)/2._dp**(l + 2)*dfac(2*l + 1))
prefac = SQRT(rootpi/2._dp**(l + 2)*dfac(2*l + 1))
DO i = 1, atom_basis%nbas(l)
zeta = (2._dp*atom_basis%am(i, l))**expzet
WRITE (iw, '(T5,F14.8,2x,6F12.8)') atom_basis%am(i, l), wfn(i, 1:im, l)*prefac/zeta
Expand Down
2 changes: 1 addition & 1 deletion src/atom_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ SUBROUTINE read_basis_set(element_symbol, basis, basis_set_name, basis_set_file,
! Normalization
DO j = 0, lmat
expzet = 0.25_dp*REAL(2*j + 3, dp)
prefac = SQRT(SQRT(pi)/2._dp**(j + 2)*dfac(2*j + 1))
prefac = SQRT(rootpi/2._dp**(j + 2)*dfac(2*j + 1))
DO ipgf = 1, basis%nprim(j)
DO ii = 1, basis%nbas(j)
gcca = basis%cm(ipgf, ii, j)
Expand Down
7 changes: 4 additions & 3 deletions src/lri_environment_init.F
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ MODULE lri_environment_init
lri_env_create,&
lri_environment_type
USE mathconstants, ONLY: fac,&
pi
pi,&
rootpi
USE mathlib, ONLY: invert_matrix
USE qs_environment_types, ONLY: get_qs_env,&
qs_environment_type
Expand Down Expand Up @@ -474,7 +475,7 @@ SUBROUTINE basis_norm_radial(basis, norm)
DO ishell = 1, basis%nshell(iset)
l = basis%l(ishell, iset)
expa = 0.5_dp*REAL(2*l + 3, dp)
ppl = fac(2*l + 2)*SQRT(pi)/2._dp**REAL(2*l + 3, dp)/fac(l + 1)
ppl = fac(2*l + 2)*rootpi/2._dp**REAL(2*l + 3, dp)/fac(l + 1)
DO isgf = basis%first_sgf(ishell, iset), basis%last_sgf(ishell, iset)
DO ipgf = 1, basis%npgf(iset)
cci = basis%gcc(ipgf, ishell, iset)
Expand Down Expand Up @@ -561,7 +562,7 @@ SUBROUTINE basis_ovlp(basis, ovlp, norm)
IF (li == lj) THEN
l = li
expa = 0.5_dp*REAL(2*l + 3, dp)
ppl = fac(2*l + 2)*SQRT(pi)/2._dp**REAL(2*l + 3, dp)/fac(l + 1)
ppl = fac(2*l + 2)*rootpi/2._dp**REAL(2*l + 3, dp)/fac(l + 1)
DO isgf = basis%first_sgf(ishell, iset), basis%last_sgf(ishell, iset)
m_i = basis%m(isgf)
DO jsgf = basis%first_sgf(jshell, jset), basis%last_sgf(jshell, jset)
Expand Down
5 changes: 3 additions & 2 deletions src/qs_dispersion_nonloc.F
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ MODULE qs_dispersion_nonloc
xc_vdw_fun_nonloc
USE kinds, ONLY: default_string_length,&
dp
USE mathconstants, ONLY: pi
USE mathconstants, ONLY: pi,&
rootpi
USE message_passing, ONLY: mp_para_env_type
USE pw_grid_types, ONLY: HALFSPACE,&
pw_grid_type
Expand Down Expand Up @@ -211,7 +212,7 @@ SUBROUTINE calculate_dispersion_nonloc(vxc_rho, rho_r, rho_g, edispersion, &
beta = 0.03125_dp*(3.0_dp/(b_value**2.0_dp))**0.75_dp
nspin = SIZE(rho_r)
const = 1.0_dp/(3.0_dp*SQRT(pi)*b_value**1.5_dp)/(pi**0.75_dp)
const = 1.0_dp/(3.0_dp*rootpi*b_value**1.5_dp)/(pi**0.75_dp)
! temporary arrays for FFT
CALL pw_pool%create_pw(tmp_g)
Expand Down
5 changes: 3 additions & 2 deletions src/xc/xc_xpbe_hole_t_c_lr.F
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ MODULE xc_xpbe_hole_t_c_lr
section_vals_val_get
USE kinds, ONLY: dp
USE mathconstants, ONLY: euler,&
pi
pi,&
rootpi
USE xc_derivative_desc, ONLY: deriv_norm_drho,&
deriv_norm_drhoa,&
deriv_norm_drhob,&
Expand Down Expand Up @@ -537,7 +538,7 @@ ELEMENTAL SUBROUTINE xpbe_hole_t_c_lr_lda_calc_1(e_0, e_rho, e_ndrho, &
t61 = D**2
t64 = D*t21
t65 = t34*B
t69 = SQRT(pi)
t69 = rootpi
t71 = F1*t21
t73 = t71*t34 + F2
t77 = C*(1 + t73*t12*t13)
Expand Down

0 comments on commit c9bffc1

Please sign in to comment.