Coverage for examples/bcc_lattice.py: 100%
12 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
1""" Example of a BCC lattice simulation with Lennard-Jones potential.
3This example demonstrates how to set up a different lattice than the default FCC lattice.
4Note more lattices are available, or you can define your own lattice.
6"""
8import gamdpy as gp
10# Setup configuration. BCC Lattice
11configuration = gp.Configuration(D=3)
12configuration.make_lattice(unit_cell=gp.unit_cells.BCC, cells=[8, 8, 8], rho=1.0)
14# Setup masses and velocities
15configuration['m'] = 1.0 # Set all masses to 1.0
16configuration.randomize_velocities(temperature=0.7)
18# Setup pair potential: Single component 12-6 Lennard-Jones
19pair_func = gp.apply_shifted_force_cutoff(gp.LJ_12_6_sigma_epsilon)
20sig, eps, cut = 1.0, 1.0, 2.5
21pair_pot = gp.PairPotential(pair_func, params=[sig, eps, cut], max_num_nbs=1000)
23# Setup integrator
24integrator = gp.integrators.NVT(temperature=0.7, tau=0.2, dt=0.005)
26# Setup runtime actions, i.e. actions performed during simulation of timeblocks
27runtime_actions = [gp.TrajectorySaver(),
28 gp.ScalarSaver(),
29 gp.MomentumReset(100)]
31# Setup Simulation.
32sim = gp.Simulation(configuration, [pair_pot, ], integrator, runtime_actions,
33 num_timeblocks=32, steps_per_timeblock=1024,
34 storage='memory')
36# Run simulation
37sim.run()