Skip to content

Add interface to MiMiC #9

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions configure/MIMIC-LINUX-GCC
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
IRAT=2
FC='mpif90'
CC='mpicc'
LD='mpif90'
CPP='cpp -P -traditional'
CPPFLAGS=' -D__Linux -D__HAS_FFT_FFTW3 -D__PARALLEL -D__HAS_SIZEOF '
if [ $debug ]; then
FFLAGS=' -g -pg -Og -ffree-line-length-none '
CFLAGS=' -g -pg -Og '
else
FFLAGS=' -O3 -march=native -mtune=native '
CFLAGS=' -O3 -march=native -mtune=native '
fi
if [ $omp ]; then
FFLAGS=${FFLAGS}' -fopenmp '
OMP3_DISABLED='false'
LIBS=' -L/usr/lib64 -llapack -lopenblaso -lfftw3_omp -lfftw3 -lm '
else
LIBS=' -L/usr/lib64 -llapack -lopenblas -lfftw3 -lm '
fi
LFLAGS=${LIBS}
FFLAGS=${FFLAGS}" -I/usr/include -fallow-argument-mismatch -ffree-line-length-none"
LFLAGS=${LFLAGS}" -L/usr/lib64 "
25 changes: 25 additions & 0 deletions configure/MIMIC-LINUX-INTEL
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
IRAT=2
FC='mpiifort'
CC='mpiicc'
LD='mpiifort'
CPP='fpp'
CPPFLAGS=' -D__Linux -D__HAS_FFT_FFTW3 -D__PARALLEL -D__HAS_SIZEOF -D__HAS_BF_STREAM_IO '
AR='xiar -r'
RANLIB='ranlib'
if [ $debug ]; then
FFLAGS=' -g -O0 -check all -warn all -traceback '
CFLAGS=' -g -O0 -check all -warn all -traceback '
else
FFLAGS=' -xHost -O3 '
CFLAGS=' -xHost -O3 '
fi
if [ $omp ]; then
FFLAGS=${FFLAGS}' -qopenmp '
OMP3_DISABLED='false'
LIBS=' -qmkl=parallel -lm '
else
LIBS=' -qmkl=sequential -lm '
fi
LFLAGS=${LIBS}
FFLAGS=${FFLAGS}" -I/usr/include "
LFLAGS=${LFLAGS}" -L/usr/lib64 "
175 changes: 170 additions & 5 deletions doc/manual/manual.tex

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ Description of options:
-verbose (-v) Display the name of files for the dependencies
-coverage (-c) With GCC compiler only, allows for specific configuration files,
to generate the code coverage/profiling during an execution
-qmmm Generates a makefile for QMMM
-mimic Enable interface to MiMiC (requires MPI and that MiMiC is available)
-qmmm Generates a makefile for QMMM
-iphigenie Support for external interface to iphigenie
-omp Enables the use of OMP instructions (if the config file allows that)
OMP3 is in general triggered by the config keyword OMP3_DISABLED,
Expand Down Expand Up @@ -130,6 +131,10 @@ do
-disable_omp3)
omp3=0
;;
-mimic|-m)
mimic=1
echo "** Enabling MiMiC interface (if MiMiC is available)" >&2
;;
-qmmm|-q)
qmmm=1
echo "** Enabling QM/MM (if Gromos and MM_Interface modules will be available)" >&2
Expand Down Expand Up @@ -241,6 +246,25 @@ fi

CPPFLAGS_GROMOS='-DEWALD -DEWATCUT -DHAT_SHAPE -DUNPACKED_GRID'

if [ $mimic ]; then
mkdir mimic_test
cd mimic_test
echo "program test" > test.f90
echo "use mimic_main" >> test.f90
echo "end program test" >> test.f90
${FC} test.f90 ${FFLAGS} ${LFLAGS} -lmimic -lmimiccommf -lmimiccomm
if [ $? != 0 ]
then
cd ..
rm -r mimic_test
echo "MiMiC was not found on your system!" >&2
exit 1
fi
cd ..
rm -r mimic_test
CPPFLAGS=${CPPFLAGS}' -D__MIMIC'
LFLAGS=${LFLAGS}' -lmimic -lmimiccommf -lmimiccomm -lstdc++ '
fi
#QM/MM compilation setup
if [ $qmmm ]; then
if [ -f ${MOD_DIR}/QMMM_SOURCES ]; then
Expand Down Expand Up @@ -852,6 +876,11 @@ do
SkipInclude["mpi"] = 0;
SkipInclude["rhjsx.inc"] = 0;
SkipInclude["uhjsx.inc"] = 0;
SkipInclude["mimic_precision"] = 0;
SkipInclude["mimic_constants"] = 0;
SkipInclude["mimic_types"] = 0;
SkipInclude["mimic_tensors"] = 0;
SkipInclude["mimic_main"] = 0;
if (qmmm != 1) {
SkipInclude["coordsz"] = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ SRC_MODULES = kinds.mod.F90 machine.mod.F90 timer.mod.F90 error_handling.mod.F90
meta_colvar_inp_utils.mod.F90 meta_exlagr_methods.mod.F90 meta_cv_utils.mod.F90 \
meta_cv_qmmm_utils.mod.F90 tst2min_utils.mod.F90 tst2min_inp_utils.mod.F90 chain_dr_utils.mod.F90 meta_cell_utils.mod.F90 \
meta_exl_mult_utils.mod.F90 meta_ex_mul_util_utils.mod.F90 meta_localizespin_utils.mod.F90 meta_colvar_util_utils.mod.F90 \
setbsstate_utils.mod.F90 io_utils.mod.F90 atoms_utils.mod.F90 dynit_utils.mod.F90 shake_utils.mod.F90 \
rattle_utils.mod.F90 resetac_utils.mod.F90 dispp_utils.mod.F90 \
setbsstate_utils.mod.F90 io_utils.mod.F90 atoms_utils.mod.F90 dynit_utils.mod.F90 constraint.mod.F90 constraint_utils.mod.F90 \
shake_utils.mod.F90 rattle_utils.mod.F90 resetac_utils.mod.F90 dispp_utils.mod.F90 \
noseinit_utils.mod.F90 nospinit_utils.mod.F90 noseng_utils.mod.F90 nosepa_utils.mod.F90 noseup_utils.mod.F90 \
enosmove_utils.mod.F90 pnosmove_utils.mod.F90 \
vdw_utils.mod.F90 chksym_utils.mod.F90 symtrz_utils.mod.F90 multtb_utils.mod.F90 molsym_utils.mod.F90 \
Expand Down Expand Up @@ -269,4 +269,4 @@ SRC_MODULES = kinds.mod.F90 machine.mod.F90 timer.mod.F90 error_handling.mod.F90
bicanonicalCpmd.mod.F90 bicanonicalConfig.mod.F90 bicanonicalInputReader.mod.F90 bicanonicalCalculationConfig.mod.F90 bicanonicalCalculation.mod.F90 \
pi_prpt_utils.mod.F90 pi_npt_cpmd_utils.mod.F90 pi_stress_utils.mod.F90 pi_npt_bomd_utils.mod.F90 \
nvml_interfaces.mod.F90 nvml_types.mod.F90 nvml_utils.mod.F90 mts_utils.mod.F90 interface_utils.mod.F90 \
dftd3_driver.mod.F90
dftd3_driver.mod.F90 mimic_wrapper.mod.F90
50 changes: 40 additions & 10 deletions src/anneal_utils.mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MODULE anneal_utils
s_ekinpp
USE ions, ONLY: ions1
USE kinds, ONLY: real_8
USE mimic_wrapper, ONLY: mimic_control
USE nose, ONLY: glib
USE parac, ONLY: paral
USE pimd, ONLY: ipcurr,&
Expand Down Expand Up @@ -51,19 +52,48 @@ SUBROUTINE anneal(velp,cm,nstate,htvel)
! == ANNEALING (IONS) Fixed rescaling factor (anner) ==
! ==--------------------------------------------------------------==
IF (cntl%annei.AND.(.NOT.skipanic)) THEN
alfap=cntr%anneri**(0.25_real_8)
IF (cntl%anneal_dual) THEN
alfap = cntr%anneal_factors(1)**(0.25_real_8)
#if defined(__VECTOR)
!$omp parallel do private(I,IS,IA)
!$omp parallel do private(I,IS,IA)
#else
!$omp parallel do private(I,IS,IA) schedule(static)
!$omp parallel do private(I,IS,IA) schedule(static)
#endif
DO i=1,ions1%nat
ia=iatpt(1,i)
is=iatpt(2,i)
velp(1,ia,is)=alfap*velp(1,ia,is)
velp(2,ia,is)=alfap*velp(2,ia,is)
velp(3,ia,is)=alfap*velp(3,ia,is)
ENDDO
DO i = 1, mimic_control%num_quantum_atoms
ia = iatpt(1,i)
is = iatpt(2,i)
velp(1,ia,is) = alfap * velp(1,ia,is)
velp(2,ia,is) = alfap * velp(2,ia,is)
velp(3,ia,is) = alfap * velp(3,ia,is)
ENDDO
alfap = cntr%anneal_factors(2)**(0.25_real_8)
#if defined(__VECTOR)
!$omp parallel do private(I,IS,IA)
#else
!$omp parallel do private(I,IS,IA) schedule(static)
#endif
DO i = mimic_control%num_quantum_atoms + 1, mimic_control%num_atoms
ia = iatpt(1,i)
is = iatpt(2,i)
velp(1,ia,is) = alfap * velp(1,ia,is)
velp(2,ia,is) = alfap * velp(2,ia,is)
velp(3,ia,is) = alfap * velp(3,ia,is)
ENDDO
ELSE
alfap=cntr%anneri**(0.25_real_8)
#if defined(__VECTOR)
!$omp parallel do private(I,IS,IA)
#else
!$omp parallel do private(I,IS,IA) schedule(static)
#endif
DO i=1,ions1%nat
ia=iatpt(1,i)
is=iatpt(2,i)
velp(1,ia,is)=alfap*velp(1,ia,is)
velp(2,ia,is)=alfap*velp(2,ia,is)
velp(3,ia,is)=alfap*velp(3,ia,is)
ENDDO
END IF
ENDIF
! ==--------------------------------------------------------------==
! == ANNEALING (ELECTRONS) Fixed rescaling factor (anner) ==
Expand Down
126 changes: 126 additions & 0 deletions src/constraint.mod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
module constraint
USE kinds, ONLY: real_8

implicit none

!> Type used to store sparse constraint matrix
!> @author V. Bolnykh - RWTH Aachen/Cyprus Institute
type constraint_matrix
! Values stored in a sparse matrix
real(real_8), dimension(:), allocatable :: vals
! Number of non-zero elements of the current row
integer, dimension(:), allocatable :: nz_row
! Index of a non-zero element in the row
integer, dimension(:), allocatable :: r_index
! IDs of atoms in a constraint
integer, dimension(:, :), allocatable :: atom_id
! Species and atom IDs in the constraint (needed for TAU
! mapping)
integer, dimension(:, :, :), allocatable :: tau_map
! Reference value for a constraint
real(real_8), dimension(:), allocatable :: ref

contains
procedure :: mat_vec
generic :: operator(*) => mat_vec
end type constraint_matrix

!> Interface of the constraint_matrix constructor
interface constraint_matrix
module procedure new_matrix
end interface

contains

!> Matrix-vector multiplication
function mat_vec(m, v) result(r)

!> input matrix
class(constraint_matrix), intent(in) :: m
!> input vector
real(real_8), dimension(:), intent(in) :: v

!> resulting vector
real(real_8), dimension(:), allocatable :: r

integer :: i, j

allocate(r(size(v)))

r = 0.0_real_8

!$OMP PARALLEL DO PRIVATE(i, j)
do i = 1, size(m%nz_row) - 1
do j = m%nz_row(i - 1) + 1, m%nz_row(i)
r(i) = r(i) + m%vals(j) * v(m%r_index(j))
end do
end do
!$OMP END PARALLEL DO

end function

!> Constructor of the sparse matrix
function new_matrix(vals, nz_row, r_index, atom_id, tau_map, ref)

real(real_8), dimension(:), intent(in) :: vals
integer, dimension(0:), intent(in) :: nz_row
integer, dimension(:), intent(in) :: r_index
integer, dimension(:,:), intent(in) :: atom_id
integer, dimension(:,:,:), intent(in) :: tau_map
real(real_8), dimension(:), intent(in) :: ref

type(constraint_matrix) :: new_matrix

integer :: i, j

allocate(new_matrix%vals(size(vals)))
allocate(new_matrix%nz_row(0:size(nz_row) - 1))
allocate(new_matrix%r_index(size(r_index)))
allocate(new_matrix%atom_id(size(atom_id, 1), size(atom_id, 2)))
allocate(new_matrix%tau_map(size(tau_map, 1), size(tau_map, 2), &
size(tau_map, 3)))
allocate(new_matrix%ref(size(ref)))

!$OMP PARALLEL PRIVATE(i, j)
!$OMP DO
do i = 1, size(vals)
new_matrix%vals(i) = vals(i)
end do
!$OMP END DO

!$OMP DO
do i = 0, size(nz_row) - 1
new_matrix%nz_row(i) = nz_row(i)
end do
!$OMP END DO

!$OMP DO
do i = 1, size(r_index)
new_matrix%r_index(i) = r_index(i)
end do
!$OMP END DO

!$OMP DO
do i = 1, size(atom_id, 2)
new_matrix%atom_id(:, i) = atom_id(:, i)
end do
!$OMP END DO

!$OMP DO
do i = 1, size(tau_map, 3)
do j = 1, size(tau_map, 2)
new_matrix%tau_map(:, j, i) = tau_map(:, j, i)
end do
end do
!$OMP END DO

!$OMP DO
do i = 1, size(ref)
new_matrix%ref(i) = ref(i)
end do
!$OMP END DO
!$OMP END PARALLEL

end function

end module constraint
Loading