About gamdpy#
The gamdpy package implements molecular dynamics on GPU’s in Python, relying heavily on the numba package (https://numba.pydata.org/) which does JIT (Just-In-Time) compilation both to CPU and GPU (cuda). The package being pure Python (letting numba do the heavy lifting of generating fast code) results in an extremely extendable package: simply by interjecting Python functions in the right places, the (experienced) user can extend most aspect of the code, including: new integrators, new pair-potentials, new properties to be calculated during simulation, new particle properties, etc.
Here is an example of a script that runs a simple Lennard-Jones simulation ( minimal.py):
""" Minimal example of a running an simulation using gamdpy
Simulation of a Lennard-Jones crystal in the NVT ensemble.
"""
import gamdpy as gp
# Setup configuration: FCC Lattice
configuration = gp.Configuration(D=3)
configuration.make_lattice(gp.unit_cells.FCC, cells=[8, 8, 8], rho=0.973)
configuration['m'] = 1.0
configuration.randomize_velocities(temperature=0.7)
# Setup pair potential: Single component 12-6 Lennard-Jones
pair_func = gp.apply_shifted_potential_cutoff(gp.LJ_12_6_sigma_epsilon)
sig, eps, cut = 1.0, 1.0, 2.5
pair_pot = gp.PairPotential(pair_func, params=[sig, eps, cut], max_num_nbs=1000)
# Setup integrator: NVT
integrator = gp.integrators.NVT(temperature=0.7, tau=0.2, dt=0.005)
# Setup runtime actions, i.e., actions performed during simulation of timeblocks
runtime_actions = [gp.TrajectorySaver(),
gp.ScalarSaver(),
gp.RestartSaver(),
gp.MomentumReset(100)]
# Setup Simulation.
sim = gp.Simulation(configuration, [pair_pot], integrator, runtime_actions,
num_timeblocks=32, steps_per_timeblock=1*1024,
storage='LJ_T0.70.h5')
# Run simulation
for timeblock in sim.run_timeblocks():
print(sim.status(per_particle=True))
print(sim.summary())
# Print current status of configuration
print(configuration)
# Do analysis from the commandline (like computing MSD) with something like,
# python -m gamdpy.tools.calc_dynamics -f 4 -o msd.pdf LJ_T*.h5
# or with a Python script. See examples.