Hi,
GSD file:
import numpy as np
import gsd.hoomd
import hoomd
import hoomd.md
hoomd.context.initialize("--mode=cpu")
s = gsd.hoomd.Snapshot()
s.particles.N = 2961
s.particles.typeid = [0]*2940 + [1]*21
s.particles.types = ['A','B']
s.particles.diameter = [4.0]*2940 + [150.0]*21
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.charge = [+1]*2940 + [-140]*21
s.particles.position = result
with gsd.hoomd.open(name='file.gsd', mode='wb') as f:
f.append(s)
Simulation code:
import hoomd
import freud
import gsd.hoomd
import numpy as np
import matplotlib.pyplot as plt
import hoomd
from hoomd import md
hoomd.context.initialize('--mode=cpu')
system = hoomd.init.read_gsd('file.gsd')
nl = hoomd.md.nlist.tree()
# NVT integration
groupB = hoomd.group.type(type ='B', name= 'mic', update= False);
hoomd.md.integrate.mode_standard (dt = 0.005)
nvt = hoomd.md.integrate.nvt (group = groupB, kT = 1.2, tau = 1.0)
nvt.randomize_velocities (seed = 1)
pppm = hoomd.md.charge.pppm(groupB, nl)
pppm.set_params(Nx=64, Ny=64, Nz=64, order=6, rcut=400.0, alpha= 0.007066536138444733)
# run the simulation
hoomd.run (500)
rdf = freud.density.RDF(bins=200, r_max=100)
w6 = freud.order.Steinhardt(l=6, wl=True)
def calc_rdf(timestep):
hoomd.util.quiet_status()
snap = system.take_snapshot()
hoomd.util.unquiet_status()
rdf.compute(system=snap, reset=False)
def calc_W6(timestep):
hoomd.util.quiet_status()
snap = system.take_snapshot()
hoomd.util.unquiet_status()
w6.compute(system=snap, neighbors={'num_neighbors': 21})
return np.mean(w6.particle_order)
# Equilibrate the system a bit before accumulating the RDF.
hoomd.run(500)
hoomd.analyze.callback(calc_rdf, period=100)
logger = hoomd.analyze.log(filename='output.log',
quantities=['w6'],
period=100,
header_prefix='#',
overwrite=True)
logger.register_callback('w6', calc_W6)
hoomd.run(500)
# Store the computed RDF in a file
np.savetxt('rdf.csv', np.vstack((rdf.bin_centers, rdf.rdf)).T,
delimiter=',', header='r, g(r)')
rdf_data = np.genfromtxt('rdf.csv', delimiter=',')
plt.plot(rdf_data[:, 0], rdf_data[:, 1])
plt.title('Radial Distribution Function')
plt.xlabel('$r$')
plt.ylabel('$g(r)$')
plt.show()
w6_data = np.genfromtxt('output.log')
plt.plot(w6_data[:, 0], w6_data[:, 1])
plt.title('$w_6$ Order Parameter')
plt.xlabel('$t$')
plt.ylabel('$w_6(t)$')
plt.show()
Best,
Elsaid