19 type(threefry_rng_t),
target,
allocatable :: state(:)
26 type(h5md_file_t) :: datafile
27 type(h5md_element_t) :: elem
28 type(h5md_element_t) :: e_solvent, e_solvent_v, e_solvent_spec, e_solvent_id
29 type(h5md_element_t) :: e_solvent_image
30 integer(HID_T) :: box_group, solvent_group
32 integer :: rho, N, L(3)
34 integer :: error, clock, n_threads
36 double precision,
parameter :: tau=1.d0
37 double precision :: bulk_rate
38 double precision :: v_com(3)
40 integer,
parameter :: n_species = 2
41 integer,
dimension(n_species) :: n_solvent
42 type(h5md_element_t) :: n_solvent_el
44 n_threads = omp_get_max_threads()
45 allocate(state(n_threads))
46 call threefry_rng_init(state, -4881001983349061041_c_int64_t)
53 n = rho*l(1)*l(2)*l(3)
55 call solvent% init(n, n_species)
58 solvent% vel(1,i) = threefry_normal(state(1))
59 solvent% vel(2,i) = threefry_normal(state(1))
60 solvent% vel(3,i) = threefry_normal(state(1))
62 v_com = sum(solvent% vel,
dim=2) /
size(solvent% vel,
dim=2)
63 solvent% vel = solvent% vel - spread(v_com,
dim=2, ncopies=
size(solvent% vel,
dim=2))
67 call solvent% random_placement(l*1.d0, state=state(1))
69 call solvent_cells%init(l, 1.d0)
70 solvent_cells%is_reac = .true.
72 call solvent_cells%count_particles(solvent% pos)
74 call datafile% create(
'bulk_decay.h5',
'RMPCDMD:setup_bulk_decay',
'N/A',
'Pierre de Buyl')
76 call tz% init(0.d0, solvent_cells% edges(3), l(3))
78 call h5gcreate_f(datafile% particles,
'solvent', solvent_group, error)
79 call h5gcreate_f(solvent_group,
'box', box_group, error)
80 call h5md_write_attribute(box_group,
'dimension', 3)
81 call h5md_write_attribute(box_group,
'boundary', [
'periodic',
'periodic',
'periodic'])
82 call elem% create_fixed(box_group,
'edges', l*1.d0)
83 call h5gclose_f(box_group, error)
85 call e_solvent% create_time(solvent_group,
'position', solvent% pos, ior(h5md_time, h5md_store_time))
86 call e_solvent_v% create_time(solvent_group,
'velocity', solvent% vel, ior(h5md_time, h5md_store_time))
87 call e_solvent_spec% create_time(solvent_group,
'species', solvent% species, ior(h5md_time, h5md_store_time))
88 call e_solvent_id% create_time(solvent_group,
'id', solvent% id, ior(h5md_time, h5md_store_time))
89 call e_solvent_image% create_time(solvent_group,
'image', solvent% image, ior(h5md_time, h5md_store_time))
91 call n_solvent_el%create_time(datafile%observables,
'n_solvent', &
92 n_solvent, h5md_linear, step=1, time=tau)
94 call solvent% sort(solvent_cells)
95 solvent_cells% origin(1) = threefry_double(state(1)) - 1
96 solvent_cells% origin(2) = threefry_double(state(1)) - 1
97 solvent_cells% origin(3) = threefry_double(state(1)) - 1
102 solvent_cells% origin(1) = threefry_double(state(1)) - 1
103 solvent_cells% origin(2) = threefry_double(state(1)) - 1
104 solvent_cells% origin(3) = threefry_double(state(1)) - 1
105 call solvent% sort(solvent_cells)
114 v_com = sum(solvent% vel,
dim=2) /
size(solvent% vel,
dim=2)
118 solvent_cells% origin(1) = threefry_double(state(1)) - 1
119 solvent_cells% origin(2) = threefry_double(state(1)) - 1
120 solvent_cells% origin(3) = threefry_double(state(1)) - 1
121 call solvent% sort(solvent_cells)
123 call bulk_reaction(solvent, solvent_cells, 2, 1, bulk_rate, tau, state)
127 call e_solvent% append(solvent% pos, i, i*tau)
128 call e_solvent_image% append(solvent% image, i, i*tau)
129 call e_solvent_v% append(solvent% vel, i, i*tau)
130 call e_solvent_spec% append(solvent% species, i, i*tau)
131 call e_solvent_id% append(solvent% id, i, i*tau)
134 write(13,*)
compute_temperature(solvent, solvent_cells, tz), sum(solvent% vel**2)/(3*solvent% Nmax), v_com
139 do i = 1 , solvent_cells% N
140 if ( solvent_cells% cell_count(i) > 0 ) clock = clock + 1
142 write(*,*) clock,
'filled cells' 143 write(*,*) l(1)*l(2)*l(3),
'actual cells' 145 call e_solvent% close()
146 call e_solvent_v% close()
147 call n_solvent_el%close()
149 call h5gclose_f(solvent_group, error)
152 call elem% create_fixed(datafile% observables,
'tz', tz% data)
153 call elem% create_fixed(datafile% observables,
'tz_count', tz% count)
155 call h5gclose_f(datafile% observables, error)
157 call datafile% close()
159 call h5close_f(error)
165 do k = 1, solvent%Nmax
166 j = solvent%species(k)
168 n_solvent(j) = n_solvent(j) + 1
170 call n_solvent_el%append(n_solvent)
double precision function, public compute_temperature(particles, cells, tz)
Compute the temperature of a mpcd solvent.
subroutine, public mpcd_stream_periodic(particles, cells, dt)
Stream MPCD particles in a periodic system.
subroutine, public simple_mpcd_step(particles, cells, state, alpha, thermostat, T, hydro)
Perform a collision.
subroutine, public bulk_reaction(p, c, from, to, rate, tau, state)
Apply a bulk unimolecular RMPCD reaction.
subroutine update_n_solvent
Compute compact Hilbert indices.
Container for a profile, e.g. v(x)
Routines to perform MPCD dynamics.
Lennard-Jones potential definition.