16 type(tester_t) :: test
23 integer,
parameter :: rho = 20
24 integer :: N_solvent, N_colloids
27 integer :: i, j, n_neigh
28 integer :: neighbor_list_size
30 double precision :: xij(3), dist_sq, cutoff
32 type(threefry_rng_t) :: state(1)
33 integer :: seed_size, clock
34 integer,
allocatable :: seed(:)
38 call random_seed(
size = seed_size)
39 allocate(seed(seed_size))
40 call system_clock(count=clock)
41 seed = clock + 37 * [ (i - 1, i = 1, seed_size) ]
42 call random_seed(put = seed)
45 call threefry_rng_init(state, int(clock, c_int64_t))
48 n_solvent = l(1)*l(2)*l(3)*rho
51 call solvent% init(n_solvent)
52 call colloids% init(n_colloids)
54 call solvent_cells%init(l, 1.d0)
58 call solvent% random_placement(l*1.d0, state=state(1))
59 call colloids% random_placement(l*1.d0, state=state(1))
61 call solvent% sort(solvent_cells)
64 neighbor_list_size = rho * 6 * int(cutoff**3)
66 call neigh% init(colloids% Nmax, neighbor_list_size)
68 call neigh% make_stencil(solvent_cells, cutoff)
70 call neigh% update_list(colloids, solvent, cutoff*0.8, solvent_cells)
72 do i = 1, colloids% Nmax
74 do j = 1, solvent% Nmax
75 xij =
rel_pos(colloids% pos(:, i), solvent% pos(:, j), solvent_cells% edges)
77 if (dist_sq < cutoff**2)
then 78 call test% assert_equal(
is_in_list(j, neigh% list(1:n_neigh,i)), .true. )
88 integer,
intent(in) :: idx
89 integer,
intent(in) :: list(:)
93 l = ( minval( abs(list - idx) ) == 0 )
Derived type and routines for neighbor listing.
logical function is_in_list(idx, list)
Compute compact Hilbert indices.
program test_neighbor_list
pure double precision function, dimension(3), public rel_pos(x, y, L)
Return x-y distance with minimum image convention.