Hi Joshua,
That was so very helpful! Thank you.
I was also reading the paper in Scipy 2020 (
http://conference.scipy.org/proceedings/scipy2020/pdfs/brandon_butler.pdf) and from there I thought of a different way to achieve my second question: assigning just the particle position. I thought it could be faster, because I do not build the simulation at each step. I also thought it was more clear in my case, as I change the parameters once before reading the trajectory. My attempt is the following:
new_energy = []
# configure the Simulation
sim = hoomd.Simulation(device=cpu)
sim.create_state_from_gsd(filename='trajectory.gsd', frame=0)
# set up the LJ liquid MD operations
integrator = hoomd.md.Integrator(dt=0.005)
cell = hoomd.md.nlist.Cell()
lj = hoomd.md.pair.LJ(nlist=cell)
lj.params[('A', 'A')] = dict(epsilon=1.0, sigma=1)
lj.r_cut[('A', 'A')] = 2.5
integrator.forces.append(lj)
sim.operations.integrator = integrator
snap = sim.state.snapshot
# compute the system energy
thermo = hoomd.md.compute.ThermodynamicQuantities(filter=hoomd.filter.All())
sim.operations.computes.append(thermo)
with gsd.hoomd.open('trajectory.gsd') as f:
for frame in f:
snap.particles.position[:,:] = frame.particles.position
sim.state.snapshot = snap
# prepare the computation, but don't actually run any time steps
sim.run(1)
# get the potential energy
new_energy.append(thermo.potential_energy)
It seems to work, but I have some doubts. First, I need to run 1 step because with sim.run(0) the calculated energies are all those of the first frame. Why?
And second, if I set sim.run(1) I get the warning:
*Warning*: integrate.mode_standard: No integration methods are set, continuing anyways.
In fact, it seems that no steps are run, as the energy is the same as the one from the GSD file. Still, I would like to remove this warning and have a nicer code.
All the best,
Ramon
El dia divendres, 16 d’octubre de 2020 a les 15:01:36 UTC+2, Joshua A. Anderson va escriure: