Certainly! Here is a simple Python program that uses the Metropolis algorithm to compute the radial distribution function (RDF) for a system of identical hard spheres in a cubic box with periodic boundary conditions:
```
import numpy as np
def compute_rdf(positions, box_length, cutoff):
n_particles = positions.shape[0]
bins = np.linspace(0, box_length/2, 100)
hist = np.zeros_like(bins)
norm = 4/3 * np.pi * (bins[1:]**3 - bins[:-1]**3)
for i in range(n_particles):
delta_pos = positions[i] - positions[(i+1):]
delta_pos = delta_pos - np.rint(delta_pos/box_length) * box_length
dist = np.sqrt(np.sum(delta_pos**2, axis=1))
dist = dist[dist < cutoff]
bin_indices = np.digitize(dist, bins)
np.add.at(hist, bin_indices, 1)
rdf = hist / (n_particles * norm)
return rdf, bins
# Example usage:
n_particles = 100
box_length = 10
cutoff = 2.5
positions = np.random.uniform(low=0, high=box_length, size=(n_particles, 3))
rdf, bins = compute_rdf(positions, box_length, cutoff)
```
This program uses NumPy to generate a set of random particle positions within the box, and then uses the `compute_rdf` function to compute the RDF using the Metropolis algorithm. The RDF is returned as a numpy array, and the `bins` variable contains the bin edges for plotting.
Note that this is just a minimalist example, and you would need to modify the program to suit your specific needs, such as adjusting the number of particles, the box length, and the cutoff distance. Additionally, you would need to plot the RDF using a suitable plotting library such as Matplotlib.