Skip to content

Commit

Permalink
Integrate the Schwenke potential
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jan 25, 2024
1 parent cee8338 commit d2130db
Show file tree
Hide file tree
Showing 9 changed files with 559 additions and 6 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]
exclude=[random.F90,fftw3.F90,force_cp2k.F90, h2o_schwenke.f]
File renamed without changes.
5 changes: 4 additions & 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 force_cp2k.o sh_integ.o surfacehop.o landau_zener.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\
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 All @@ -27,5 +27,8 @@ clean:
%.o: %.F90
$(FC) $(FFLAGS) $(DFLAGS) -c $<

%.o: %.f
$(FC) $(FFLAGS) $(DFLAGS) -c $<

%.o: %.cpp
$(CXX) $(CXXFLAGS) $(DFLAGS) -c $<
4 changes: 2 additions & 2 deletions src/force_abin.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
! The basic workflow is very simple:
! 1. ABIN writes current geometry into file geom.dat
! in a XYZ format without the header.
! 2. ABIN launches the shell script POT/r.pot
! 2. ABIN launches the shell script <POT>/r.<pot>
! 3. The shellscript does a few things:
! i) Takes the input geometry and prepares the input file
! ii) Launches the QM program
Expand All @@ -15,7 +15,7 @@
!
! NOTE: We append bead index to every file name so that we can
! call the interface in parallel in PIMD simulations.
! NOTE: Interface for Surface Hopping is a bit more complicated,
! NOTE: The interface for Surface Hopping is a bit more complicated,
! see interfaces/MOLPRO-SH/r.molpro-sh
module mod_shell_interface_private
use mod_const, only: DP, ANG
Expand Down
53 changes: 53 additions & 0 deletions src/force_h2o.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
! This is invoked via pot='_h2o_'
module mod_h2o_pes
use mod_const, only: DP
use mod_error, only: fatal_error
implicit none
private
public :: force_h2o_schwenke
save
contains

subroutine force_h2o_schwenke(x, y, z, fx, fy, fz, eclas, natom, walkmax)

Check warning on line 11 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L11

Added line #L11 was not covered by tests
use mod_utils, only: get_distance, get_angle
use mod_const, only: PI
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :)
real(DP), intent(inout) :: fx(:, :), fy(:, :), fz(:, :)
real(DP), intent(inout) :: eclas
integer, intent(in) :: natom, walkmax
! Internal water coordinates
real(DP) :: rOH1, rOH2, aHOH_deg, aHOH_rad
real(DP) :: rij(walkmax, 3)
real(DP) :: Epot(walkmax)

Check warning on line 21 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L20-L21

Added lines #L20 - L21 were not covered by tests
integer :: iw

! TODO: Check atom names
if (natom /= 3) then
call fatal_error(__FILE__, __LINE__, "This is not a water molecule!")

Check warning on line 26 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L26

Added line #L26 was not covered by tests
end if

! Compute internal coordinates from cartesians
! OH distances in bohrs, HOH angle in radians
do iw = 1, walkmax
rOH1 = get_distance(x, y, z, 1, 2, iw)
rOH2 = get_distance(x, y, z, 1, 3, iw)
aHOH_deg = get_angle(x, y, z, 2, 1, 3, iw)
aHOH_rad = aHOH_deg * PI / 180.0D0
print*, 'Angle = ', aHOH_deg, aHOH_rad
rij(iw, 1) = rOH1
rij(iw, 2) = rOH2
rij(iw, 3) = aHOH_rad

Check warning on line 39 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L31-L39

Added lines #L31 - L39 were not covered by tests
end do

call pes_h2o_schwenke(rij, Epot, walkmax)

Check warning on line 42 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L42

Added line #L42 was not covered by tests

! TODO: Implement numerical forces
fx = 0.0D0; fy = 0.0D0; fz = 0.0D0

Check warning on line 45 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L45

Added line #L45 was not covered by tests

do iw = 1, walkmax
eclas = eclas + Epot(iw)

Check warning on line 48 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L47-L48

Added lines #L47 - L48 were not covered by tests
end do
eclas = eclas / walkmax
end subroutine force_h2o_schwenke

Check warning on line 51 in src/force_h2o.F90

View check run for this annotation

Codecov / codecov/patch

src/force_h2o.F90#L50-L51

Added lines #L50 - L51 were not covered by tests

end module mod_h2o_pes
3 changes: 3 additions & 0 deletions src/forces.F90
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ subroutine force_wrapper(x, y, z, fx, fy, fz, e_pot, chpot, walkmax)
use mod_const, only: DP
use mod_general, only: natom, ipimd
use mod_water, only: watpot
use mod_h2o_pes, only: force_h2o_schwenke
use mod_force_mm, only: force_mm
use mod_sbc, only: force_sbc, isbc
use mod_plumed, only: iplumed, force_plumed
Expand Down Expand Up @@ -155,6 +156,8 @@ subroutine force_wrapper(x, y, z, fx, fy, fz, e_pot, chpot, walkmax)
call force_mm(x, y, z, fx, fy, fz, eclas, walkmax)
case ("_mmwater_")
call force_water(x, y, z, fx, fy, fz, eclas, natom, walkmax, watpot)
case ("_h2o_")
call force_h2o_schwenke(x, y, z, fx, fy, fz, eclas, natom, walkmax)

Check warning on line 160 in src/forces.F90

View check run for this annotation

Codecov / codecov/patch

src/forces.F90#L160

Added line #L160 was not covered by tests
case ("_splined_grid_")
! Only 1D spline grid supported at the moment
call force_splined_grid(x, fx, eclas, walkmax)
Expand Down
8 changes: 8 additions & 0 deletions src/fortran_interfaces.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ function usleep(useconds) bind(c, name='usleep')
integer(kind=C_INT) :: usleep
end function usleep

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

end interface

end module mod_interfaces
Loading

0 comments on commit d2130db

Please sign in to comment.