Repository navigation
Expand file tree
/
Copy pathdynamics.f90
More file actions
64 lines (47 loc) · 1.77 KB
/
Copy pathdynamics.f90
File metadata and controls
64 lines (47 loc) · 1.77 KB
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
module dynamics
use constants, only : dp
use parameters
use boxes, only : update_boxes
implicit none
private
public :: verlet
interface
subroutine Tforces(x,F,U,virial)
use constants, only : dp
real(dp), dimension(:,:), intent(in) :: x
real(dp), dimension(:,:), intent(out) :: F
real(dp), intent(out) :: U
real(dp), intent(out) :: virial
end subroutine Tforces
end interface
contains
subroutine verlet(x,v,x1,v1,U,virial,dt,forces)
real(dp), dimension(:,:), intent(in) :: x, v
real(dp), dimension(:,:), intent(out) :: x1, v1
real(dp), intent(out) :: U
real(dp), intent(out) :: virial
real(dp), intent(in) :: dt
procedure(Tforces) :: forces
real(dp), dimension(:,:), allocatable :: F, F1
integer :: err
allocate(F(3,Natoms), stat=err)
allocate(F1(3,Natoms), stat=err)
if (err.ne.0) STOP 'ALLOCATION ERROR'
!print*,'x0max=',maxval(x(1,:)),maxval(x(2,:)),maxval(x(3,:))
!print*,'x0min=',minval(x(1,:)),minval(x(2,:)),minval(x(3,:))
!print*,'v0max=',maxval(v(1,:)),maxval(v(2,:)),maxval(v(3,:))
!print*,'v0min=',minval(v(1,:)),minval(v(2,:)),minval(v(3,:))
call forces(x,F,U,virial) ! ALGORITMO VERLET !
!print*,'F:',minval(F),maxval(F)
x1 = x + v * dt + 0.5d0*dt*dt*F/Mass
!call update_boxes(x,x1)
!print*,'x1max=',maxval(x1(1,:)),maxval(x1(2,:)),maxval(x1(3,:))
!print*,'x1min=',minval(x1(1,:)),minval(x1(2,:)),minval(x1(3,:))
call forces(x1,F1,U,virial)
!print*,'F1:',minval(F1),maxval(F1)
v1 = v + 0.5d0 * (F+F1)/Mass * dt
!print*,'v1max=',maxval(v1(1,:)),maxval(v1(2,:)),maxval(v1(3,:))
!print*,'v1min=',minval(v1(1,:)),minval(v1(2,:)),minval(v1(3,:))
deallocate(F,F1)
end subroutine verlet
end module dynamics