-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add Schwenke's gas phase H2O analytical potential #166
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cee8338
WIP: Add Schwenke s gas phase H2O potential
danielhollas d2130db
Integrate the Schwenke potential
danielhollas 517f8ed
Remove print statement
danielhollas 4b88ef1
GHA: Setup python-3.11 for autoformat
danielhollas cef431f
No cache
danielhollas 2d3d0a7
Use default
danielhollas 78176e7
Whoops
danielhollas 5063ac3
what is the default python version?
danielhollas e682532
Py3.11
danielhollas 64147ea
Generalize and refactor
danielhollas 2d67d77
Tiny fix
danielhollas 7e15435
Merge branch 'master' into schwenke-water-potential
danielhollas 0c39f45
Add dummy test
danielhollas 4b82367
Reorder for test coverage
danielhollas dc12eb6
Actually test
danielhollas f339338
Remove original file
danielhollas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
! Interface to analytical H2O (single water molecule) potentials. | ||
! This is invoked via pot='_h2o_', and the potential is selected via | ||
! h2opot='schwenke' | ||
module mod_force_h2o | ||
use mod_const, only: DP | ||
use mod_files, only: stdout, stderr | ||
use mod_error, only: fatal_error | ||
use mod_interfaces, only: h2o_pot_schwenke | ||
implicit none | ||
private | ||
public :: initialize_h2o_pot, force_h2o, h2opot | ||
character(len=20) :: h2opot = 'schwenke' | ||
save | ||
contains | ||
|
||
! Perform some basic validation | ||
subroutine initialize_h2o_pot(natom, atom_names) | ||
integer, intent(in) :: natom | ||
character(len=2), intent(in) :: atom_names(natom) | ||
|
||
if (natom /= 3) then | ||
call fatal_error(__FILE__, __LINE__, "This is not a water molecule!") | ||
end if | ||
|
||
if (atom_names(1) /= 'O' .or. atom_names(2) /= 'H' .or. atom_names(3) /= 'H') then | ||
write (stderr, *) 'ERROR: Bad element type.' | ||
write (stderr, *) 'Water atoms must be ordered as "O H H"' | ||
call fatal_error(__FILE__, __LINE__, "This is not a water molecule!") | ||
end if | ||
end subroutine initialize_h2o_pot | ||
|
||
! Compute internal coordinates from cartesians | ||
! OH distances in bohrs, HOH angle in radians | ||
subroutine get_internal_coords(x, y, z, iw, rOH1, rOH2, aHOH_rad) | ||
use mod_const, only: PI | ||
use mod_utils, only: get_distance, get_angle | ||
real(DP), intent(in) :: x(:, :), y(:, :), z(:, :) | ||
integer, intent(in) :: iw | ||
real(DP), intent(out) :: rOH1, rOH2, aHOH_rad | ||
real(DP) :: aHOH_deg | ||
|
||
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 | ||
end subroutine get_internal_coords | ||
|
||
! This is just a wrapper function that selects the H2O potential | ||
! based on user input. For now only h2opot="schwenke" is supported | ||
subroutine force_h2o(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 | ||
|
||
! 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 | ||
call fatal_error(__FILE__, __LINE__, 'Potential '//trim(h2opot)//' not implemented') | ||
end if | ||
end subroutine force_h2o | ||
|
||
subroutine force_h2o_schwenke(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) :: rij(nbeads, 3) | ||
real(DP) :: Epot(nbeads) | ||
integer :: iw | ||
|
||
! 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) | ||
rij(iw, 1) = rOH1 | ||
rij(iw, 2) = rOH2 | ||
rij(iw, 3) = aHOH_rad | ||
end do | ||
|
||
! Calculated the potential for all PI beads at once | ||
call h2o_pot_schwenke(rij, Epot, nbeads) | ||
! For Path Integrals, the final energy of the PI necklace | ||
! is an average over all beads. | ||
! TODO: Forces need to be appropriately scaled as well! | ||
do iw = 1, nbeads | ||
Eclas = Eclas + Epot(iw) | ||
end do | ||
Eclas = Eclas / nbeads | ||
|
||
call numerical_forces(x, y, z, fx, fy, fz, Epot, natom, nbeads) | ||
|
||
end subroutine force_h2o_schwenke | ||
|
||
! 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, Epot, fx, fy, fz, natom, nbeads) | ||
real(DP), intent(in) :: x(natom, nbeads) | ||
real(DP), intent(in) :: y(natom, nbeads) | ||
real(DP), intent(in) :: z(natom, nbeads) | ||
real(DP), intent(inout) :: fx(natom, nbeads) | ||
real(DP), intent(inout) :: fy(natom, nbeads) | ||
real(DP), intent(inout) :: fz(natom, nbeads) | ||
! This is the energy for the currrent geometry that has already been calculated | ||
real(DP), intent(in) :: Epot(nbeads) | ||
integer, intent(in) :: natom, nbeads | ||
|
||
! Need to implement numerical forces first | ||
call fatal_error(__FILE__, __LINE__, 'Numerical forces not yet implemented!') | ||
end subroutine numerical_forces | ||
|
||
end module mod_force_h2o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbarnfield63 Here's where you can start with your implementation.
Ultimately we'll want to have the implementation of numerical forces generalized and in a separate module, but that's not important at this stage.