RMPCDMD
test_particle_system_0.f90
Go to the documentation of this file.
1 ! This file is part of RMPCDMD
2 ! Copyright (c) 2015-2016 Pierre de Buyl and contributors
3 ! License: BSD 3-clause (see file LICENSE)
4 
7  use mt19937ar_module
8  use threefry_module
9  use iso_c_binding
10  use tester
11  implicit none
12 
13  type(particle_system_t) :: p
14  integer, parameter :: N = 3000
15  type(mt19937ar_t), target :: mt
16  type(tester_t) :: test
17 
18  type(threefry_rng_t) :: state(1)
19  integer :: clock, i
20  double precision :: L(3), x(3)
21 
22  call system_clock(count=clock)
23  call init_genrand(mt, int(clock, c_long))
24  write(*,*) clock
25  call test% init(tolerance64=12*epsilon(1.d0))
26 
27  call threefry_rng_init(state, int(clock, c_int64_t))
28 
29  call p% init(n)
30  l = [ 1.d0, 20.d0, 5.d0 ]
31  call p% random_placement(l, state=state(1))
32  p% pos_old = p% pos
33 
34  ! Pick particle i and a random vector of norm <= sqrt(3)
35  i = modulo(int(genrand_int31(mt)), n) + 1
36  x = [ genrand_real1(mt), genrand_real1(mt), genrand_real1(mt) ]
37  write(*,*) 'i', i
38  write(*,*) 'x', x
39  write(*,*) 'pos(:,i)', p% pos(:,i)
40  p% pos(:,i) = p% pos(:,i) + x
41  write(*,*) 'pos(:,i)', p% pos(:,i)
42  call test% assert_positive( sqrt(3.d0) - p% maximum_displacement() )
43 
44  ! Restore particle i
45  p% pos(:,i) = p% pos(:,i) - x
46  write(*,*) 'pos(:,i)', p% pos(:,i)
47  call test% assert_close( p% maximum_displacement(), 0.d0 )
48 
49  call test% print()
50 
51 end program test_particle_system_0
program test_particle_system_0
Data for particles.