def langevin_init_N_108_l_box_6(box_size, n_particles):
    n_dim = len(box_size)
    q_0 = q_opt
    v_0 = np.zeros((n_particles, n_dim))
    return q_0, v_0


test_config = es.SimuConfig(l_box=(6., 6., 6.),
                            PBC=True,
                            neighbor_list=False,
                            particle_info=[0] * 108,
                            n_steps=8000,
                            timestep=0.001,
                            temp=0.5,
                            phys_world=dummy_world)
test_md = es.MD(test_config, random_initiliazer, es.step_runners.MMC(step=0.1))
test_md.add_potential(
    es.potentials.LJ(test_config, switch_start=2.5, cutoff=3.5))

test_md.run_all()
print("simu_done")
qs = test_md.traj.get_qs()
#np.save("optimized.npy",qs[-1])

Gr = es.observables.RadDistFunc(test_config, 40, [108, 0, 0])
g_r, radii = Gr.calc_radial_dist(qs, 500, 1)

import matplotlib.pyplot as plt
for _ in range(7):
    plt.plot(radii, g_r[_])
plt.show()
Example #2
0
    return pot_func, force_func


def StupidInitializer3(box_size, n_particles):
    # need to return a tuple of four vectors
    # masses, charges, q_0 and p_0
    q_0 = np.array([[0., 0.], [0., 1.]]) + box_size / 2
    #v_0 = np.array([[0.5, 0.866], [-0.8, 0.6]])
    v_0 = np.array([[0., 0.], [0., 0.]])
    return q_0, v_0


test_config = es.SimuConfig(l_box=(8., 8.),
                            PBC=True,
                            particle_info=[0, 0],
                            n_steps=10000,
                            timestep=0.001,
                            temp=30,
                            phys_world=dummy_world)
test_md = es.MD(test_config, StupidInitializer3,
                es.step_runners.Langevin(damping=0.01))
test_md.add_potential(HarmonicTrap(test_config, 100., [4., 4.]))
#test_md.add_potential(es.potentials.LJ(test_config, switch_start=2.5, cutoff=3.5))
test_md.run_all()
#print(test_md.traj.get_qs())
qs = test_md.traj.get_qs() % 8.
plt.plot(qs[:, 0, 0], qs[:, 0, 1])
plt.plot(qs[:, 1, 0], qs[:, 1, 1])
plt.show()
Example #3
0
    # 3.104 is for correct liquid water density at 300 K
    l_box = 7. * np.array([2 * n, n, n])
    grid=_grid([n, n, n])
    q_0 = 7. * grid
    #init_directions = []
    q = (q_0[:, None, :] + water_shape[None, :, :]).reshape(-1, 3)
    v = np.zeros((3 * n_mol, n_dim))
    mol_list = []
    for i in range(n_mol):
        mol_list.append((0, [3 * i, 3 * i + 1, 3 * i + 2]))
    particle_info = np.tile([1, 2, 2], n_mol)
    return q, v, particle_info, l_box, mol_list

q, v, particle_info, l_box, mol_list = _intializer_WaterBox(3)
steps = 5000
test_config = es.SimuConfig(l_box=l_box, PBC=True, neighbor_list=False, particle_info=particle_info, mol_list=mol_list, n_steps=steps, timestep=1e-3, temp=500)
init = lambda x,y: (q, v)
test_md = es.MD(test_config, init, es.step_runners.GradientDescent())
test_md.add_potential(es.potentials.Water(test_config))
test_md.add_potential(es.potentials.LJ(test_config, switch_start=5., cutoff=7.))
test_md.add_potential(es.potentials.Coulomb(test_config))
print(es.potentials.Coulomb(test_config))
#test_md.add_potential(HarmonicTrap(test_config, 100., [4., 4.]))
#test_md.add_potential(es.potentials.LJ(test_config, switch_start=2.5, cutoff=3.5))
test_md.run_all()
#print(test_md.traj.get_qs())
qs = test_md.traj.get_qs()
pdb = es.observables.PdbWriter(test_config, 'water_opt2.pdb')
for i in range(int(steps/100)):
   pdb.write_frame(qs[i * 100])
Example #4
0
import matplotlib.pyplot as plt
from .dummies import dummy_world


def random_initiliazer(box_size, n_particles):
    n_dim = len(box_size)
    q_0 = np.random.uniform(0.1, 7, (n_particles, n_dim))
    v_0 = np.zeros((n_particles, n_dim))
    return q_0, v_0


test_config = es.SimuConfig(
    l_box=(8., 8., 8.),
    PBC=True,
    particle_info=[0] * 40,
    n_steps=2000,
    timestep=0.001,
    temp=30,
    phys_world=dummy_world,
)
test_md = es.MD(test_config, random_initiliazer,
                es.step_runners.Langevin(damping=0.01))
test_md.add_potential(
    es.potentials.LJ(test_config, switch_start=2.5, cutoff=3.5))
test_md.run_all()

qs = test_md.traj.get_qs() % 8.
plt.plot(qs[:, 0, 0], qs[:, 0, 1])
plt.plot(qs[:, 1, 0], qs[:, 1, 1])
plt.show()
Example #5
0
    v_0 = np.array([[0., 0.]] * 9)
    return masses, charges, q_0, v_0 * masses[:, None]

N_particles = 9
l_box = (8., 8.)
test_config = es.SimuConfig(n_dim = 2,
                            l_box = l_box,
                            n_particles = N_particles,
                            n_steps = 3000,
                            timestep = 0.001,
                            temp = 100,
                            PBC = True,
                            neighbour = False,
                            lj_flag = True,
                            )
test_md = es.MD(es.PhysWorld(), test_config, grid_initializer_2d, es.step_runners.Langevin(damping=0.1))
#test_md.add_global_potential(HarmonicPotential(1.))
test_md.run_all()
#print(test_md.traj.get_qs())
qs = test_md.traj.get_qs()
#plt.plot(qs[:, 0, 0]%3., qs[:, 0, 1]%3.)
#plt.plot(qs[:, 1, 0]%3., qs[:, 1, 1]%3.)
#plt.show()

import matplotlib.animation as manimation

FFMpegWriter = manimation.writers['ffmpeg']
metadata = dict(title='Movie Test', artist='Matplotlib',
                comment='Movie support!')
writer = FFMpegWriter(fps=20, metadata=metadata)
Example #6
0
    mol_list = []
    for i in range(n_mol):
        mol_list.append((0, [3 * i, 3 * i + 1, 3 * i + 2]))
    particle_info = np.tile([1, 2, 2], n_mol)
    return q, v, particle_info, l_box, mol_list


q, v, particle_info, l_box, mol_list = _intializer_WaterBox(6)
steps = 2000
test_config = es.SimuConfig(l_box=l_box,
                            PBC=True,
                            particle_info=particle_info,
                            mol_list=mol_list,
                            n_steps=steps,
                            timestep=0.01,
                            temp=500)
init = lambda x, y: (q, v)
test_md = es.MD(test_config, init, es.step_runners.Langevin(damping=0.05))
test_md.add_potential(es.potentials.Water(test_config))
test_md.add_potential(es.potentials.LJ(test_config, switch_start=5.,
                                       cutoff=7.))
test_md.add_potential(es.potentials.Coulomb(test_config))
#test_md.add_potential(HarmonicTrap(test_config, 100., [4., 4.]))
#test_md.add_potential(es.potentials.LJ(test_config, switch_start=2.5, cutoff=3.5))
test_md.run_all()
#print(test_md.traj.get_qs())
qs = test_md.traj.get_qs()
pdb = es.observables.PdbWriter(test_config, 'water_gas.pdb')
for i in range(int(steps / 10)):
    pdb.write_frame(qs[i * 10])
Example #7
0
    return pot_func, force_func


def StupidInitializer3(box_size, n_particles):
    # need to return a tuple of four vectors
    # masses, charges, q_0 and p_0
    q_0 = np.array([[0., 0.], [0., 1.]]) + box_size / 2
    #v_0 = np.array([[0.5, 0.866], [-0.8, 0.6]])
    v_0 = np.array([[0., 0.], [0., 0.]])
    return q_0, v_0


test_config = es.SimuConfig(l_box=(8., 8.),
                            PBC=True,
                            particle_info=[0, 0],
                            n_steps=10000,
                            timestep=0.001,
                            temp=100,
                            phys_world=dummy_world)

test_md = es.MD(test_config, StupidInitializer3,
                es.step_runners.MMC(step=0.05))
test_md.add_potential(HarmonicTrap(test_config, 1000., [4., 4.]))
test_md.add_potential(
    es.potentials.LJ(test_config, switch_start=2.5, cutoff=3.5))
test_md.run_all()
qs = test_md.traj.get_qs()
plt.plot(qs[:, 0, 0], qs[:, 0, 1])
plt.plot(qs[:, 1, 0], qs[:, 1, 1])
plt.show()