Skip to content

Continue a simulation ​

Load a saved GSD configuration into a ParticleSystem, then supply the forces, dynamics, and output schedule for the next run.

julia
system = ParticleSystem.from_gsd("trajectory.gsd")  # last saved frame
all = Group(:all, AllSelection())

forces = Force[
    LennardJones(epsilon=1.0, sigma=1.0, cutoff=2.5, pairs=:neighborlist,
                 neighborlist=ClusterPairList(buffer=0.2)),
]
if (elec = electrostatics_from_gsd("trajectory.gsd")) !== nothing
    push!(forces, elec)
end
if (disp = dispersion_from_gsd("trajectory.gsd")) !== nothing
    push!(forces, disp)
end

sim = Simulation(system;
    groups=Groups(all),
    integrator=Integrator(
        dt=0.002,
        forces=forces,
        methods=[ConstantVolume(all)],
    ),
    writers=[GSDWriter("continued.gsd"; every=1_000, mode=:replace)],
)
run!(sim, Stage(:continued, steps=10_000))

Use the interactions, units, precision, and timestep of your original model. Loading a configuration restores particle state and recorded metadata, but does not reconstruct arbitrary runtime choices or an uninterrupted PRNG history.

What is restored ​

  • ParticleSystem.from_gsd(path; frame=nothing, step=nothing) reads periodic box geometry, positions, particle types, masses, velocities, charges, and topology (bonds, angles, dihedrals, impropers, exclusions) stored in the frame.

  • electrostatics_from_gsd(path) returns the saved PME, PPPM, or ESP descriptor (including recorded exceptions), or nothing if no electrostatics metadata was written.

  • dispersion_from_gsd(path) returns the saved DispersionESP or DispersionPME descriptor, or nothing when absent.

  • For pressure-controlled runs, prepare the simulation with the same barostat settings and restore its saved state from log/barostat/state:

julia
prepare!(sim)
restore_barostat!(sim, read_gsd_log("trajectory.gsd", "log/barostat/state"))

See Constant-pressure NPT for barostat configuration details.

Low-level GSD frame inspection ​

For low-level SimulationState workflows or custom host analysis, read_gsd_frame!(path) returns a ParticleDynamics.Writers.GSDFrameData container exposing step, N, box, positions, velocities, forces, virials, charges, and ParticleDynamics.Writers.GSDTopology metadata:

julia
frame = read_gsd_frame!("trajectory.gsd")
@show frame.step frame.N frame.box

Keep or extend existing output ​

A new output filename keeps the continuation separate and easy to inspect. To append to an existing file across separate Simulation objects, use mode=:append. Step numbering is controlled explicitly through reset_step! if you want a continuous output timeline.

Full restart and GSD I/O signatures are listed in the I/O & Initial Configurations API reference.

ParticleDynamics v1.2.0 · GPU-native molecular dynamics in pure Julia · MIT License