Skip to content

Commit

Permalink
Merge pull request #309 from QuantumPackage/dev-stable
Browse files Browse the repository at this point in the history
Dev stable
  • Loading branch information
scemama authored Nov 8, 2023
2 parents 2eab7ed + ea55dc8 commit 0f320db
Show file tree
Hide file tree
Showing 288 changed files with 230 additions and 41 deletions.
4 changes: 4 additions & 0 deletions bin/python
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

exec python3 $@

1 change: 1 addition & 0 deletions bin/qp_plugins
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def main(arguments):
l_repository = list(d_tmp.keys())
if l_repository == []:
l_result = []
l_plugins = []
else:
m_instance = ModuleHandler(l_repository)
l_plugins = [module for module in m_instance.l_module]
Expand Down
3 changes: 2 additions & 1 deletion bin/qpsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

export QP_ROOT=$(dirname "$(readlink -f "$0")")/..
REALPATH=$( cd "$(dirname "$0")" ; pwd -P )
export QP_ROOT=${REALPATH}/..

bash --init-file <(cat << EOF
[[ -f /etc/bashrc ]] && source /etc/bashrc
Expand Down
23 changes: 23 additions & 0 deletions bin/zcat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# On Darwin: try gzcat if available, otherwise use Python

if [[ $(uname -s) = Darwin ]] ; then
which gzcat &> /dev/null
if [[ $? -eq 0 ]] ; then
exec gzcat $@
else

exec python3 << EOF
import sys
import gzip
with gzip.open("$1", "rt") as f:
print(f.read())
EOF
fi
else
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
command=$(which -a zcat | grep -v "$SCRIPTPATH/" | head -1)
exec $command $@
fi

2 changes: 1 addition & 1 deletion config/gfortran.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
#
[COMMON]
FC : gfortran -g -ffree-line-length-none -I . -fPIC -march=native
FC : gfortran -g -ffree-line-length-none -I . -fPIC -march=native -std=legacy
LAPACK_LIB : -lblas -llapack
IRPF90 : irpf90
IRPF90_FLAGS : --ninja --align=32 --assert -DSET_NESTED
Expand Down
2 changes: 1 addition & 1 deletion config/gfortran_armpl.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
#
[COMMON]
FC : gfortran -g -ffree-line-length-none -I . -fPIC -march=native
FC : gfortran -g -ffree-line-length-none -I . -fPIC -march=native -std=legacy
LAPACK_LIB : -larmpl_lp64_mp
IRPF90 : irpf90
IRPF90_FLAGS : --ninja --align=32 --assert -DSET_NESTED
Expand Down
2 changes: 1 addition & 1 deletion config/gfortran_avx.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
#
[COMMON]
FC : gfortran -ffree-line-length-none -I . -mavx -g -fPIC
FC : gfortran -ffree-line-length-none -I . -mavx -g -fPIC -std=legacy
LAPACK_LIB : -llapack -lblas
IRPF90 : irpf90
IRPF90_FLAGS : --ninja --align=32 -DSET_NESTED
Expand Down
2 changes: 1 addition & 1 deletion config/gfortran_debug.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
#
[COMMON]
FC : gfortran -g -ffree-line-length-none -I . -fPIC
FC : gfortran -g -ffree-line-length-none -I . -fPIC -std=legacy
LAPACK_LIB : -lblas -llapack
IRPF90 : irpf90
IRPF90_FLAGS : --ninja --align=32 --assert -DSET_NESTED
Expand Down
62 changes: 62 additions & 0 deletions config/gfortran_macos.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Common flags
##############
#
# -ffree-line-length-none : Needed for IRPF90 which produces long lines
# -lblas -llapack : Link with libblas and liblapack libraries provided by the system
# -I . : Include the curent directory (Mandatory)
#
# --ninja : Allow the utilisation of ninja. (Mandatory)
# --align=32 : Align all provided arrays on a 32-byte boundary
#
#
[COMMON]
FC : gfortran -ffree-line-length-none -I . -g -fPIC -std=legacy
LAPACK_LIB : -llapack -lblas
IRPF90 : irpf90
IRPF90_FLAGS : --ninja --align=32 -DSET_NESTED -DMACOS

# Global options
################
#
# 1 : Activate
# 0 : Deactivate
#
[OPTION]
MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below
CACHE : 0 ; Enable cache_compile.py
OPENMP : 1 ; Append OpenMP flags

# Optimization flags
####################
#
# -Ofast : Disregard strict standards compliance. Enables all -O3 optimizations.
# It also enables optimizations that are not valid
# for all standard-compliant programs. It turns on
# -ffast-math and the Fortran-specific
# -fno-protect-parens and -fstack-arrays.
[OPT]
FCFLAGS : -Ofast -march=native

# Profiling flags
#################
#
[PROFILE]
FC : -p -g
FCFLAGS : -Ofast

# Debugging flags
#################
#
# -fcheck=all : Checks uninitialized variables, array subscripts, etc...
# -g : Extra debugging information
#
[DEBUG]
FCFLAGS : -fcheck=all -g

# OpenMP flags
#################
#
[OPENMP]
FC : -fopenmp
IRPF90_FLAGS : --openmp

2 changes: 1 addition & 1 deletion config/gfortran_mpi.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
#
[COMMON]
FC : mpif90 -ffree-line-length-none -I . -g -fPIC
FC : mpif90 -ffree-line-length-none -I . -g -fPIC -std=legacy
LAPACK_LIB : -lblas -llapack
IRPF90 : irpf90
IRPF90_FLAGS : --ninja --align=32 -DMPI -DSET_NESTED
Expand Down
2 changes: 1 addition & 1 deletion config/gfortran_openblas.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
#
[COMMON]
FC : gfortran -g -ffree-line-length-none -I . -fPIC -march=native
FC : gfortran -g -ffree-line-length-none -I . -fPIC -march=native -std=legacy
LAPACK_LIB : -lopenblas
IRPF90 : irpf90
IRPF90_FLAGS : --ninja --align=32 --assert -DSET_NESTED
Expand Down
19 changes: 12 additions & 7 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ git submodule init
git submodule update

# Update ARM or x86 dependencies
ARCHITECTURE=$(uname -m)
SYSTEM=$(uname -s)
if [[ $SYSTEM = "Linux" ]] ; then
SYSTEM=""
fi
ARCHITECTURE=$(uname -m)$SYSTEM
cd ${QP_ROOT}/external/qp2-dependencies
git checkout master
git pull
Expand Down Expand Up @@ -191,7 +195,7 @@ if [[ "${PACKAGES}.x" != ".x" ]] ; then
fi

if [[ ${PACKAGES} = all ]] ; then
PACKAGES="zlib ninja zeromq f77zmq gmp ocaml docopt resultsFile bats trexio qmckl"
PACKAGES="zlib ninja zeromq f77zmq gmp ocaml docopt resultsFile bats trexio"
fi


Expand Down Expand Up @@ -275,6 +279,7 @@ EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file qp2-dependencies/zeromq-4.2.5.tar.gz
cd zeromq-*
[[ "${SYSTEM}" = "Darwin" ]] && ./autogen.sh
./configure --prefix="\$QP_ROOT" --without-libsodium --enable-libunwind=no
make -j 8
make install
Expand Down Expand Up @@ -397,11 +402,11 @@ if [[ ${TREXIO} = $(not_found) ]] ; then
fail
fi

QMCKL=$(find_lib -lqmckl)
if [[ ${QMCKL} = $(not_found) ]] ; then
error "QMCkl (qmckl | qmckl-intel) is not installed."
fail
fi
#QMCKL=$(find_lib -lqmckl)
#if [[ ${QMCKL} = $(not_found) ]] ; then
# error "QMCkl (qmckl | qmckl-intel) is not installed."
# fail
#fi

F77ZMQ=$(find_lib -lzmq -lf77zmq -lpthread)
if [[ ${F77ZMQ} = $(not_found) ]] ; then
Expand Down
2 changes: 1 addition & 1 deletion etc/paths.rc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export PYTHONPATH=$(qp_prepend_export "PYTHONPATH" "${QP_EZFIO}/Python":"${QP_PY

export PATH=$(qp_prepend_export "PATH" "${QP_PYTHON}":"${QP_ROOT}"/bin:"${QP_ROOT}"/ocaml)

export LD_LIBRARY_PATH=$(qp_prepend_export "LD_LIBRARY_PATH" "${QP_ROOT}"/lib)
export LD_LIBRARY_PATH=$(qp_prepend_export "LD_LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64)

export LIBRARY_PATH=$(qp_prepend_export "LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64)

Expand Down
1 change: 0 additions & 1 deletion plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ cd $StartDir

############################################################################
#### EXAMPLE OF SCRIPT TO RUN A CIPSI CALCULATION ON 5 STATES ON THE Ne^+ CATION
#### USING NATURAL ORBITALS OF A SMALL CIPSI AS MOS
#### USING NATURAL ORBITALS OF A SMALL CIPSI AS MOS
#### ALL STATES WILL HAVE THE SAME SPIN SIMETRY : A DOUBLET

####### YOU PUT THE PATH TO YOUR
####### YOU PUT THE PATH TO YOUR
QP_ROOT=/home_lct/eginer/programs/qp2
source ${QP_ROOT}/quantum_package.rc
####### YOU LOAD SOME LIBRARIES
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ subroutine grad1_j12_mu(r1, r2, grad)
stop

endif
grad = -grad

return
end subroutine grad1_j12_mu
Expand Down Expand Up @@ -486,6 +487,13 @@ subroutine mu_r_val_and_grad(r1, r2, mu_val, mu_der)
!!!!!!!!! rho1,rho2,rho1+rho2
call get_all_rho_grad_rho(r1,r2,rho1,rho2,grad_rho1)
rho_tot = rho1 + rho2
! if(rho_tot.lt.1.d-10)rho_tot = 1.d-10
if(rho_tot.lt.1.d-10)then
mu_val = mu_erf
mu_der = 0.d0
return
endif

if(rho_tot.lt.1.d-10)rho_tot = 1.d-10
inv_rho_tot = 1.d0/rho_tot
! f(rho) = mu_r_ct * rho**beta_rho_power + mu_erf
Expand All @@ -506,18 +514,26 @@ subroutine mu_r_val_and_grad(r1, r2, mu_val, mu_der)
! d/dx1 f[rho(r1)] = [0.5 alpha / sqrt(rho(r1)) ] (d rho(r1) / dx1)
!
! d/dx1 (rho(r1) f[rho(r1)] = rho(r1) * d/dx1 f[rho(r1)] + f[rho(r1)] * d/dx1 rho(r1)

!!!!!!!!! rho1,rho2,rho1+rho2
call get_all_rho_grad_rho(r1,r2,rho1,rho2,grad_rho1)
rho_tot = rho1 + rho2
! if(rho_tot.lt.1.d-10)rho_tot = 1.d-10
if(rho_tot.lt.1.d-10)then
mu_val = mu_erf
mu_der = 0.d0
return
endif

if(rho_tot.lt.1.d-10)rho_tot = 1.d-10
inv_rho_tot = 1.d0/rho_tot
! f(rho) = mu_r_ct * rho**beta_rho_power + mu_erf
call get_all_f_rho_simple(rho1,rho2,mu_r_ct,mu_erf,beta_rho_power,f_rho1,d_drho_f_rho1,f_rho2)
! f(rho) = (mu_r_ct* rho)**beta_rho_power * erf(zeta_erf_mu_of_r * rho) + mu_eff * (1 - erf(zeta_erf_mu_of_r*rho))
call get_all_f_rho_erf(rho1,rho2,mu_r_ct,beta_rho_power,mu_erf,zeta_erf_mu_of_r,f_rho1,d_drho_f_rho1,f_rho2)
d_dx1_f_rho1(1:3) = d_drho_f_rho1 * grad_rho1(1:3)
d_dx_rho_f_rho(1:3) = rho1 * d_dx1_f_rho1(1:3) + f_rho1 * grad_rho1(1:3)
mu_val = 0.5d0 * ( f_rho1 + f_rho2)
mu_der(1:3) = d_dx_rho_f_rho(1:3)
nume = rho1 * f_rho1 + rho2 * f_rho2
mu_val = nume * inv_rho_tot
mu_der(1:3) = inv_rho_tot*inv_rho_tot * (rho_tot * d_dx_rho_f_rho(1:3) - grad_rho1(1:3) * nume)

else
print *, ' j1b_type = ', j1b_type, 'not implemented yet'
stop
Expand Down Expand Up @@ -676,8 +692,17 @@ subroutine get_all_f_rho_simple(rho1,rho2,alpha,mu0,beta,f_rho1,d_drho_f_rho1,f_
double precision, intent(in) :: rho1,rho2,alpha,mu0,beta
double precision, intent(out):: f_rho1,d_drho_f_rho1,f_rho2
double precision :: tmp
call f_mu_and_deriv_mu_simple(rho1,alpha,mu0,beta,f_rho1,d_drho_f_rho1)
call f_mu_and_deriv_mu_simple(rho2,alpha,mu0,beta,f_rho2,tmp)
if(rho1.lt.1.d-10)then
f_rho1 = 0.d0
d_drho_f_rho1 = 0.d0
else
call f_mu_and_deriv_mu_simple(rho1,alpha,mu0,beta,f_rho1,d_drho_f_rho1)
endif
if(rho2.lt.1.d-10)then
f_rho2 = 0.d0
else
call f_mu_and_deriv_mu_simple(rho2,alpha,mu0,beta,f_rho2,tmp)
endif
end

subroutine f_mu_and_deriv_mu_simple(rho,alpha,mu0,beta,f_mu,d_drho_f_mu)
Expand All @@ -691,10 +716,53 @@ subroutine f_mu_and_deriv_mu_simple(rho,alpha,mu0,beta,f_mu,d_drho_f_mu)
END_DOC
double precision, intent(in) :: rho,alpha,mu0,beta
double precision, intent(out) :: f_mu,d_drho_f_mu
f_mu = alpha * (rho)**beta + mu0
d_drho_f_mu = alpha * beta * rho**(beta-1.d0)
f_mu = alpha**beta * (rho)**beta + mu0
d_drho_f_mu = alpha**beta * beta * rho**(beta-1.d0)

end

! ---

subroutine f_mu_and_deriv_mu_erf(rho,alpha,zeta,mu0,beta,f_mu,d_drho_f_mu)
implicit none
include 'constants.include.F'
BEGIN_DOC
! function giving mu as a function of rho
!
! f_mu = (alpha * rho)**zeta * erf(beta * rho) + mu0 * (1 - erf(beta*rho))
!
! and its derivative with respect to rho d_drho_f_mu
!
! d_drho_f_mu = 2 beta/sqrt(pi) * exp(-(beta*rho)**2) * ( (alpha*rho)**zeta - mu0)
! + alpha * zeta * (alpha *rho)**(zeta-1) * erf(beta*rho)
END_DOC
double precision, intent(in) :: rho,alpha,mu0,beta,zeta
double precision, intent(out) :: f_mu,d_drho_f_mu
f_mu = (alpha * rho)**zeta * derf(beta * rho) + mu0 * (1.d0 - derf(beta*rho))
d_drho_f_mu = 2.d0 * beta * inv_sq_pi * dexp(-(beta*rho)**2) * ( (alpha*rho)**zeta - mu0) &
+ alpha * zeta * (alpha *rho)**(zeta-1) * derf(beta*rho)

end


subroutine get_all_f_rho_erf(rho1,rho2,alpha,zeta,mu0,beta,f_rho1,d_drho_f_rho1,f_rho2)
implicit none
BEGIN_DOC
! returns the values f(mu(r1)), f(mu(r2)) and d/drho(1) f(mu(r1))
! with f_mu = (alpha * rho)**zeta * erf(beta * rho) + mu0 * (1 - erf(beta*rho))
END_DOC
double precision, intent(in) :: rho1,rho2,alpha,mu0,beta,zeta
double precision, intent(out):: f_rho1,d_drho_f_rho1,f_rho2
double precision :: tmp
if(rho1.lt.1.d-10)then
f_rho1 = mu_erf
d_drho_f_rho1 = 0.d0
else
call f_mu_and_deriv_mu_erf(rho1,alpha,zeta,mu0,beta,f_rho1,d_drho_f_rho1)
endif
if(rho2.lt.1.d-10)then
f_rho2 = mu_erf
else
call f_mu_and_deriv_mu_erf(rho2,alpha,zeta,mu0,beta,f_rho2,tmp)
endif
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ subroutine routine_print
integer :: i_unit_output,getUnitAndOpen
output=trim(ezfio_filename)//'.mu_of_r'
i_unit_output = getUnitAndOpen(output,'w')
integer :: ipoint,nx
double precision :: xmax,xmin,r(3),dx
double precision :: mu_val, mu_der(3),dm_a,dm_b,grad
integer :: ipoint,nx,i
double precision :: xmax,xmin,r(3),dx,sigma
double precision :: mu_val, mu_der(3),dm_a,dm_b,grad,grad_dm_a(3), grad_dm_b(3)
xmax = 5.D0
xmin = -5.D0
nx = 10000
Expand All @@ -24,10 +24,15 @@ subroutine routine_print
r(1) = xmin
do ipoint = 1, nx
call mu_r_val_and_grad(r, r, mu_val, mu_der)
call dm_dft_alpha_beta_at_r(r,dm_a,dm_b)
call density_and_grad_alpha_beta(r,dm_a,dm_b, grad_dm_a, grad_dm_b)
sigma = 0.d0
do i = 1,3
sigma += grad_dm_a(i)**2
enddo
sigma=dsqrt(sigma)
grad = mu_der(1)**2 + mu_der(2)**2 + mu_der(3)**2
grad = dsqrt(grad)
write(i_unit_output,'(100(F16.7,X))')r(1),mu_val,dm_a+dm_b,grad
write(i_unit_output,'(100(F16.7,X))')r(1),mu_val,dm_a+dm_b,grad,sigma/dm_a
r(1) += dx
enddo
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0f320db

Please sign in to comment.