forked from Allen-Tildesley/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lrc_lj_module.f90
96 lines (71 loc) · 4.5 KB
/
lrc_lj_module.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
! lrc_lj_module.f90
! Long-range and delta corrections for potential energy and pressure
MODULE lrc_module
!------------------------------------------------------------------------------------------------!
! This software was written in 2016/17 !
! by Michael P. Allen <[email protected]>/<[email protected]> !
! and Dominic J. Tildesley <[email protected]> ("the authors"), !
! to accompany the book "Computer Simulation of Liquids", second edition, 2017 ("the text"), !
! published by Oxford University Press ("the publishers"). !
! !
! LICENCE !
! Creative Commons CC0 Public Domain Dedication. !
! To the extent possible under law, the authors have dedicated all copyright and related !
! and neighboring rights to this software to the PUBLIC domain worldwide. !
! This software is distributed without any warranty. !
! You should have received a copy of the CC0 Public Domain Dedication along with this software. !
! If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. !
! !
! DISCLAIMER !
! The authors and publishers make no warranties about the software, and disclaim liability !
! for all uses of the software, to the fullest extent permitted by applicable law. !
! The authors and publishers do not recommend use of this software for any purpose. !
! It is made freely available, solely to clarify points made in the text. When using or citing !
! the software, you should not imply endorsement by the authors or publishers. !
!------------------------------------------------------------------------------------------------!
! The purpose of this module is simply to gather in one place the common
! functions for long-range and delta corrections for the Lennard-Jones potential.
! If a different potential is used in the simulation, a different file
! (with the same module name) containing different expressions should be substituted
IMPLICIT NONE
PRIVATE
! Public routines
PUBLIC :: potential_lrc, pressure_lrc, pressure_delta
! Private data
REAL, PARAMETER :: pi = 4.0 * ATAN(1.0)
CONTAINS
FUNCTION potential_lrc ( density, r_cut )
IMPLICIT NONE
REAL :: potential_lrc ! Returns long-range correction to potential/atom
REAL, INTENT(in) :: density ! Number density N/V
REAL, INTENT(in) :: r_cut ! Cutoff distance
! Calculates long-range correction for Lennard-Jones potential per atom
! density, r_cut, and the results, are in LJ units where sigma = 1, epsilon = 1
REAL :: sr3
sr3 = 1.0 / r_cut**3
potential_lrc = pi * ( (8.0/9.0) * sr3**3 - (8.0/3.0) * sr3 ) * density
END FUNCTION potential_lrc
FUNCTION pressure_lrc ( density, r_cut )
IMPLICIT NONE
REAL :: pressure_lrc ! Returns long-range correction to pressure
REAL, INTENT(in) :: density ! Number density N/V
REAL, INTENT(in) :: r_cut ! Cutoff distance
! Calculates long-range correction for Lennard-Jones pressure
! density, r_cut, and the results, are in LJ units where sigma = 1, epsilon = 1
REAL :: sr3
sr3 = 1.0 / r_cut**3
pressure_lrc = pi * ( (32.0/9.0) * sr3**3 - (16.0/3.0) * sr3 ) * density**2
END FUNCTION pressure_lrc
FUNCTION pressure_delta ( density, r_cut )
IMPLICIT NONE
REAL :: pressure_delta ! Returns delta correction to pressure
REAL, INTENT(in) :: density ! Number density N/V
REAL, INTENT(in) :: r_cut ! Cutoff distance
! Calculates correction for Lennard-Jones pressure
! due to discontinuity in the potential at r_cut
! density, r_cut, and the results, are in LJ units where sigma = 1, epsilon = 1
REAL :: sr3
sr3 = 1.0 / r_cut**3
pressure_delta = pi * (8.0/3.0) * ( sr3**3 - sr3 ) * density**2
END FUNCTION pressure_delta
END MODULE lrc_module