Beispiel #1
0
import sys
if (len(sys.argv) != 2):
    print('Usage: build_scattering.py [model_dir]')
    exit(0)

model_dir = sys.argv[1]

with hoomd.htf.tfcompute(model_dir, _mock_mode=False,
                         write_tensorboard=False) as tfcompute:
    hoomd.context.initialize("")
    N = 8 * 8
    NN = N - 1
    r_cut = 1
    hoomd.init.create_lattice(unitcell=hoomd.lattice.sc(a=1.0), n=4)
    nlist = hoomd.md.nlist.cell(check_period=5)
    lj = hoomd.md.pair.lj(r_cut=r_cut, nlist=nlist)
    lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
    hoomd.md.integrate.mode_standard(dt=0.005)
    all = hoomd.group.all()
    hoomd.md.integrate.langevin(group=all, kT=0.2, seed=42)
    tfcompute.attach(nlist, r_cut=r_cut, force_mode='ignore')
    hoomd.analyze.log(filename='scattering.log',
                      quantities=['momentum', 'temperature'],
                      period=10,
                      overwrite=True)
    hoomd.dump.gsd("trajectory.gsd", period=2e3, group=all, overwrite=True)
    hoomd.run(100)
    positions_array = tfcompute.get_positions_array()
    tfcompute.get_nlist_array()
    # print('positions array is {}'.format(positions_array))
Beispiel #2
0
    hoomd.context.initialize('--mode={}'.format(mode_string))
    rcut = 3.0
    sqrt_N = int(sqrt(N))

    system = hoomd.init.create_lattice(unitcell=hoomd.lattice.sq(a=2.0),
                                       n=[sqrt_N, sqrt_N])
    nlist = hoomd.md.nlist.cell(check_period=1)
    # basic LJ forces from HOOMD
    lj = hoomd.md.pair.lj(rcut, nlist)
    lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
    hoomd.md.integrate.mode_standard(dt=0.005)
    hoomd.md.integrate.langevin(group=hoomd.group.all(), kT=1.0, seed=42)
    # equilibrate for 4k steps first
    hoomd.run(4000)
    # now attach the LJ force model
    tfcompute.attach(nlist, r_cut=rcut, save_period=100, period=100)
    # train on 5k timesteps
    hoomd.run(50000)
    # train on 5k timesteps and benchmark with 20 repeats
    benchmark_results = hoomd.benchmark.series(warmup=6000,
                                               repeat=5,
                                               steps=50000,
                                               limit_hours=2)

# write results
with open('{}-particles_{}_time.txt'.format(N, mode_string), 'w+') as f:
    f.write('Elapsed time with {} particles: {}'.format(
        N, str(benchmark_results)))

print('Elapsed time with {} particles: {}'.format(N, str(benchmark_results)))
Beispiel #3
0
    hoomd.context.initialize('--mode=gpu')
    rcut = 3.0
    sqrt_N = int(sqrt(N))

    system = hoomd.init.create_lattice(unitcell=hoomd.lattice.sq(a=2.0),
                                       n=[sqrt_N, sqrt_N])
    nlist = hoomd.md.nlist.cell(check_period=1)
    lj = hoomd.md.pair.lj(rcut, nlist)  # basic LJ forces from HOOMD
    lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
    hoomd.md.integrate.mode_standard(dt=0.005)
    hoomd.md.integrate.langevin(group=hoomd.group.all(), kT=1.0, seed=42)
    # equilibrate for 4k steps first
    hoomd.run(4000)
    # now attach the trainable model
    tfcompute.attach(nlist,
                     r_cut=rcut,
                     save_period=100,
                     period=100,
                     feed_dict=dict({'keep_prob:0': 0.8}))
    # train on 5k timesteps
    hoomd.run(50000)  #, profile=True)
    # train on 5k timesteps and benchmark with 20 repeats
    benchmark_results = hoomd.benchmark.series(warmup=6000,
                                               repeat=5,
                                               steps=50000,
                                               limit_hours=2)

with open('{}-particles_{}_xla_time.txt'.format(N, use_xla), 'w+') as f:
    f.write('Elapsed time with {} particles: {}'.format(
        N, str(benchmark_results)))
Beispiel #4
0
    hoomd_ff.angle_coeffs(frame, param_sys)
    # set-up dihedrals
    hoomd_ff.dihedral_coeffs(frame, param_sys)
    # free particles from rigid bodies since rigid doesn't quite work for us
    for i in range(frame.particles.N):
        system.particles[i].body = -1
    all = hoomd.group.all()
    kT = 1.9872 / 1000
    fire = hoomd.md.integrate.mode_minimize_fire(dt=0.5 / 48.9,
                                                 ftol=1e-4,
                                                 Etol=1e-8)
    nve = hoomd.md.integrate.nve(group=all)
    for i in range(5):
        if not (fire.has_converged()):
            hoomd.run(100)
    nve.disable()
    # Now NVT
    hoomd.md.integrate.mode_standard(dt=2 / 48.9)
    nvt = hoomd.md.integrate.nvt(group=all, kT=298 * kT, tau=100 / 48.9)
    nvt.randomize_velocities(1234)
    tfcompute.attach(nlist, r_cut=r_cut, period=1)
    # hoomd.analyze.log(filename='scattering.log',
    #                  quantities=['momentum', 'temperature'],
    #                  period=10,
    #                  overwrite=True)
    hoomd.dump.gsd("trajectory.gsd", period=10, group=all, overwrite=True)
    hoomd.run(1e4)
    positions_array = tfcompute.get_positions_array()
    tfcompute.get_nlist_array()
    # print('positions array is {}'.format(positions_array))
Beispiel #5
0
    exit(0)
N = int(argv[1])
training_dir = argv[2]
with hoomd.htf.tfcompute(bootstrap=training_dir) as tfcompute:
    hoomd.context.initialize('--gpu_error_checking')
    sqrt_N = int(sqrt(N))  # MAKE SURE THIS IS A WHOLE NUMBER???
    rcut = 3.0
    system = hoomd.init.create_lattice(unitcell=hoomd.lattice.sq(a=2.0),
                                       n=[sqrt_N, sqrt_N])
    nlist = hoomd.md.nlist.cell(check_period=1)
    # we're loading forces now, so no HOOMD calculation
    hoomd.md.integrate.mode_standard(dt=0.005)
    hoomd.md.integrate.langevin(group=hoomd.group.all(), kT=0.2, seed=42)
    hoomd.md.constrain.oneD(group=hoomd.group.all(),
                            constraint_vector=[1, 1, 0])
    # equilibrate for 4k steps first
    hoomd.run(4000)
    tfcompute.attach(nlist,
                     r_cut=rcut,
                     feed_func=lambda x: {'keep_prob:0': 0.5})
    hoomd.analyze.log(filename='INFERENCE_log.log',
                      quantities=['potential_energy', 'temperature'],
                      period=10,
                      overwrite=True)
    hoomd.dump.gsd(filename='INFERENCE_trajectory.gsd',
                   period=10,
                   group=hoomd.group.all(),
                   overwrite=True)
    # run for 5k steps with dumped trajectory and logged PE and T
    hoomd.run(5000)
Beispiel #6
0
hoomd.context.initialize('--mode={}'.format(mode_string))
rcut = 3.0
sqrt_N = int(sqrt(N))

system = hoomd.init.create_lattice(unitcell=hoomd.lattice.sq(a=2.0),
                                   n=[sqrt_N, sqrt_N])
nlist = hoomd.md.nlist.cell(check_period=1)
# basic LJ forces from Hoomd
lj = hoomd.md.pair.lj(rcut, nlist)
lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
hoomd.md.integrate.mode_standard(dt=0.005)
hoomd.md.integrate.langevin(group=hoomd.group.all(), kT=1.0, seed=42)
# equilibrate for 4k steps first
hoomd.run(4000)
# now attach the LJ force model
tfcompute.attach(nlist, r_cut=rcut)

# train on 5k timesteps
hoomd.run(5000)
# train on 5k timesteps and benchmark with 20 repeats
benchmark_results = hoomd.benchmark.series(warmup=6000,
                                           repeat=5,
                                           steps=50000,
                                           limit_hours=2)

# write results
with open('{}-particles_{}_time.txt'.format(N, mode_string), 'w+') as f:
    f.write('Elapsed time with {} particles: {}'.format(
        N, str(benchmark_results)))

print('Elapsed time with {} particles: {}'.format(N, str(benchmark_results)))