Skip to content

Commit

Permalink
Merge branch 'master' into Schwenke_numerical
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas authored Mar 11, 2024
2 parents de057a3 + 2b6a0b3 commit 431080d
Show file tree
Hide file tree
Showing 11 changed files with 1,661 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .fprettify.rc
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ enable-decl=True
disable-fypp=True

case=[1,1,1,2]
exclude=[random.F90,fftw3.F90,force_cp2k.F90, h2o_schwenke.f]
exclude=[random.F90,fftw3.F90,force_cp2k.F90, h2o_schwenke.f, h2o_cvrqd.f]
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
gha-dependencies:
patterns:
- '*'
67 changes: 30 additions & 37 deletions .github/workflows/gfortran.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ env:
ABIN_FFLAGS: -O0 -fopenmp --coverage -fprofile-abs-path -ffpe-trap=invalid,zero,overflow,denormal -fimplicit-none -Wall -Wno-integer-division -Wno-maybe-uninitialized
ABIN_LDLIBS: --coverage
OPTIMIZED_FFLAGS: -O3 -fopenmp -fimplicit-none -Wall -Wno-integer-division
# Even for public builds, it is apparently useful to use CODECOV_TOKEN
# to minimize failed uploads, see:
# https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
# NOTE: This breaks CI on PRs from forks. We might need to change this if it becomes an issue.
# NOTE: It would be safer to only pass the secret token to the codecov-upload action,
# but the impact of this token leaking is small anyway.
# NOTE: It appears that even with this token there are issues,
Expand Down Expand Up @@ -85,11 +81,12 @@ jobs:
# pFUnit library is used to build and run unit tests
- name: pFUnit build Cache
id: pfunit-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/pfunit/build/installed
# To force a pFUnit rebuild (bust the cache), make a change to install_pfunit.sh
key: ${{ runner.os }}-ubuntu20.04-pfunit-gfortran${{ env.GCC_V }}-${{ hashFiles('dev_scripts/install_pfunit.sh') }}
save-always: true

- name: Download and build pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
Expand All @@ -105,23 +102,21 @@ jobs:
run: make unittest

- name: Codecov upload unit tests
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
flags: unittests
gcov: true
fail_ci_if_error: false
fail_ci_if_error: true

- name: Run End-to-End tests
if: always()
run: make e2etest

- name: Codecov upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
fail_ci_if_error: false
gcov: true
fail_ci_if_error: true

intel_build:
name: Intel OneAPI build
Expand Down Expand Up @@ -181,7 +176,7 @@ jobs:

- name: TCBP build cache
id: tcpb-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/tcpb-cpp/lib
# To force a rebuild (bust the cache), make a change to install_tcpb.sh
Expand All @@ -201,11 +196,10 @@ jobs:
run: make e2etest

- name: Codecov upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: tcpb
fail_ci_if_error: false
gcov: true
fail_ci_if_error: true


optimized_build:
Expand Down Expand Up @@ -233,10 +227,11 @@ jobs:
- name: pFUnit build Cache
id: pfunit-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/pfunit/build/installed
key: ${{ runner.os }}-ubuntu22.04-pfunit-gfortran${{ env.GCC_V }}-${{ hashFiles('dev_scripts/install_pfunit.sh') }}
save-always: true

- name: Download and build pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -271,10 +266,11 @@ jobs:

- name: pFUnit build Cache
id: pfunit-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/pfunit/build/installed
key: ${{ runner.os }}-ubuntu22.04-pfunit-gfortran-default-${{ hashFiles('dev_scripts/install_pfunit.sh') }}
save-always: true

- name: Download and build pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
Expand All @@ -290,21 +286,19 @@ jobs:
run: make unittest

- name: Codecov upload unit tests
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
flags: unittests
gcov: true

- name: Run End-to-End tests
run: make e2etest

- name: Codecov upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
fail_ci_if_error: false
gcov: true
fail_ci_if_error: true

mpich_build:
name: MPICH build
Expand Down Expand Up @@ -341,10 +335,11 @@ jobs:
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
- name: MPICH build Cache
id: mpich-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/mpich/${{ env.MPICH_V }}/install
key: ${{runner.os}}-ubuntu20.04-mpich${{ env.MPICH_V }}-gfortran${{ env.GCC_V }}-${{hashFiles('dev_scripts/install_mpich.sh')}}
save-always: true

- name: Build and Install MPICH
if: steps.mpich-cache.outputs.cache-hit != 'true'
Expand All @@ -369,11 +364,10 @@ jobs:
- name: test ABIN
run: make test
- name: Codecov upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
fail_ci_if_error: false
gcov: true
fail_ci_if_error: true

openmpi_build:
name: OpenMPI build
Expand All @@ -395,10 +389,11 @@ jobs:
fetch-depth: 2
- name: OpenMPI build cache
id: openmpi-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/openmpi/${{ env.OPENMPI_V }}/install
key: ${{runner.os}}-ubuntu20.04-openmpi${{ env.OPENMPI_V }}-gfortran-default-${{hashFiles('dev_scripts/install_openmpi.sh')}}
save-always: true

- name: Build and Install OpenMPI
if: steps.openmpi-cache.outputs.cache-hit != 'true'
Expand All @@ -412,11 +407,10 @@ jobs:
- name: test ABIN
run: make test
- name: Codecov upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
fail_ci_if_error: false
gcov: true
fail_ci_if_error: true

plumed_build:
name: PLUMED build
Expand All @@ -440,18 +434,19 @@ jobs:
fetch-depth: 2
- name: Plumed build cache
id: plumed-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/plumed/${{ env.PLUMED_V }}/install
key: ${{runner.os}}-ubuntu20.04-plumed${{env.PLUMED_V}}-gcc-default-${{hashFiles('dev_scripts/install_plumed.sh')}}
save-always: true

- name: Build and Install PLUMED
if: steps.plumed-cache.outputs.cache-hit != 'true'
run: ./dev_scripts/install_plumed.sh ${HOME}/plumed ${PLUMED_V}

- name: pFUnit build Cache
id: pfunit-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/pfunit/build/installed
key: ${{ runner.os }}-ubuntu20.04-pfunit-gfortran-default-${{ hashFiles('dev_scripts/install_pfunit.sh') }}
Expand All @@ -473,18 +468,16 @@ jobs:
run: make unittest

- name: Codecov upload unit tests
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
flags: unittests
gcov: true

- name: Run End-to-End tests
run: make e2etest

- name: Codecov upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{env.CODECOV_NAME}}
fail_ci_if_error: false
gcov: true
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
F_OBJS := constants.o fortran_interfaces.o error.o modules.o mpi_wrapper.o files.o utils.o io.o random.o arrays.o qmmm.o fftw_interface.o \
shake.o nosehoover.o gle.o transform.o potentials.o force_spline.o estimators.o ekin.o vinit.o plumed.o \
remd.o force_bound.o water.o h2o_schwenke.o force_h2o.o force_cp2k.o sh_integ.o surfacehop.o landau_zener.o\
remd.o force_bound.o water.o h2o_schwenke.o h2o_cvrqd.o force_h2o.o force_cp2k.o sh_integ.o surfacehop.o landau_zener.o\
force_mm.o tera_mpi_api.o force_abin.o force_tcpb.o force_tera.o force_terash.o en_restraint.o analyze_ext_template.o geom_analysis.o analysis.o \
minimizer.o mdstep.o forces.o cmdline.o init.o

Expand Down
36 changes: 36 additions & 0 deletions src/force_h2o.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ subroutine force_h2o(x, y, z, fx, fy, fz, eclas, natom, nbeads)
! TODO: Use function pointers to select the potential and pass it down
if (h2opot == 'schwenke') then
call force_h2o_schwenke(x, y, z, fx, fy, fz, eclas, natom, nbeads)
else if (h2opot == 'cvrqd') then
call force_h2o_cvrqd(x, y, z, fx, fy, fz, eclas, natom, nbeads)
call fatal_error(__FILE__, __LINE__, 'Numerical forces not yet implemented!')
else
call fatal_error(__FILE__, __LINE__, 'Potential '//trim(h2opot)//' not implemented')
end if
Expand Down Expand Up @@ -96,6 +99,39 @@ subroutine force_h2o_schwenke(x, y, z, fx, fy, fz, Eclas, natom, nbeads)

end subroutine force_h2o_schwenke

subroutine force_h2o_cvrqd(x, y, z, fx, fy, fz, Eclas, natom, nbeads)
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
real(DP), intent(inout) :: fx(:, :), fy(:, :), fz(:, :)
real(DP), intent(inout) :: Eclas
integer, intent(in) :: natom, nbeads
! Internal water coordinates
real(DP) :: rOH1, rOH2, aHOH_rad
real(DP) :: E
integer :: iw
real(DP) :: mH, mO

! TODO: Pass in the actual masses
! What should be these set to? Should we set pure isotopes?
mH = 1.008D0
mO = 15.999D0

Eclas = 0.0D0
! The H2O potentials are evaluated in internal coordinates, but ABIN works in cartesians
do iw = 1, nbeads
call get_internal_coords(x, y, z, iw, rOH1, rOH2, aHOH_rad)

call h2o_pot_cvrqd(E, rOH1, rOH2, aHOH_rad, mO, mH)

Eclas = Eclas + E
end do
Eclas = Eclas / nbeads

! TODO: Given the small difference between the Schwenke potential,
! we might not need to implement numerical forces here.
! call numerical_forces(x, y, z, fx, fy, fz, Epot, natom, nbeads)

end subroutine force_h2o_cvrqd

! TODO: Implement numerical forces generally for all potentials
! For now, they can be implemented here and hardcoded for a specific H2O potential
subroutine numerical_forces(x, y, z, fx, fy, fz, Epot, natom, nbeads)
Expand Down
11 changes: 9 additions & 2 deletions src/fortran_interfaces.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,21 @@ function usleep(useconds) bind(c, name='usleep')
integer(kind=C_INT) :: usleep
end function usleep

! Returns a potential energy of a water molecule
! Computes potential energy of a water molecule
! using Schwenke potential, see h2o_schwenke.f
subroutine h2o_pot_schwenke(rij, v, n)
import :: DP
integer, intent(in) :: n
real(DP) :: rij(n, 3), v(n)
real(DP), intent(in) :: rij(n, 3)
real(DP), intent(out) :: v(n)
end subroutine h2o_pot_schwenke

subroutine h2o_pot_cvrqd(V, rOH1, rOH2, aHOH, mH, mO)
import :: DP
real(DP), intent(out) :: V
real(DP), intent(in) :: rOH1, rOH2, aHOH, mH, mO
end subroutine h2o_pot_cvrqd

end interface

end module mod_interfaces
Loading

0 comments on commit 431080d

Please sign in to comment.