Exemplo n.º 1
0
    system.part.add(id=i, pos=np.random.random(3) * system.box_l)

system.analysis.dist_to(0)

print(
    "Simulate {} particles in a cubic simulation box {} at density {}.".format(
        n_part, box_l, density).strip())
print("Interactions:\n")
act_min_dist = system.analysis.min_dist()
print("Start with minimal distance {}".format(act_min_dist))

system.cell_system.max_num_cells = 2744

# Switch between openGl/Mayavi
#visualizer = visualization.mayaviLive(system)
visualizer = visualization.openGLLive(system)

#############################################################
#  Warmup Integration                                       #
#############################################################

print("""
Start warmup integration:
At maximum {} times {} steps
Stop if minimal distance is larger than {}
""".strip().format(warm_n_times, warm_steps, min_dist))

# set LJ cap
lj_cap = 20
system.force_cap = lj_cap
print(system.non_bonded_inter[0, 0].lennard_jones)
Exemplo n.º 2
0
system = espressomd.System(box_l=[box_l] * 3)
system.set_random_state_PRNG()
np.random.seed(seed=system.seed)

system.time_step = 0.01
system.cell_system.skin = 0.4
system.thermostat.set_langevin(kT=0.1, gamma=20.0, seed=42)

system.non_bonded_inter[0, 0].lennard_jones.set_params(
    epsilon=0, sigma=1, cutoff=2, shift="auto")
system.bonded_inter[0] = HarmonicBond(k=0.5, r_0=1.0)

for i in range(n_part):
    system.part.add(id=i, pos=np.random.random(3) * system.box_l)

for i in range(n_part - 1):
    system.part[i].add_bond((system.bonded_inter[0], system.part[i + 1].id))

# Select visualizer
if args.visualizer == "mayavi":
    visualizer = visualization.mayaviLive(system)
else:
    visualizer = visualization.openGLLive(system, bond_type_radius=[0.3])

system.minimize_energy.init(
    f_max=10, gamma=50.0, max_steps=1000, max_displacement=0.2)
system.minimize_energy.minimize()

visualizer.run(1)
Exemplo n.º 3
0
from espressomd.minimize_energy import steepest_descent
from espressomd import electrostatics
from espressomd import electrostatic_extensions
from espressomd import visualization

required_features = ["P3M", "WCA"]
espressomd.assert_features(required_features)

box_l = 20
elc_gap = 10
potential_diff = -3.
system = espressomd.System(box_l=[box_l, box_l, box_l + elc_gap])
np.random.seed(seed=42)
visualizer = visualization.openGLLive(system,
                                      background_color=[1, 1, 1],
                                      constraint_type_colors=[[0, 0, 0]],
                                      camera_position=[70, 10, 15],
                                      camera_right=[0, 0, -1])

system.time_step = 0.02
system.cell_system.skin = 0.4
system.periodicity = [1, 1, 1]

qion = 1
for i in range(300):
    rpos = np.random.random(3) * box_l
    system.part.add(pos=rpos, type=0, q=qion)
    qion *= -1

system.constraints.add(shape=espressomd.shapes.Wall(dist=0, normal=[0, 0, 1]),
                       particle_type=1)
system.non_bonded_inter[0,0].lennard_jones.set_params(
    epsilon=0, sigma=1,
    cutoff=2, shift="auto")
system.bonded_inter[0] = HarmonicBond(k=1.0,r_0=1.0)
system.bonded_inter[1] = HarmonicBond(k=1.0,r_0=1.0)

for i in range(n_part):
  system.part.add(id=i, pos=numpy.random.random(3) * system.box_l)

for i in range(n_part/2):
  system.part[i].add_bond((system.bonded_inter[0], system.part[i+1].id))
for i in range(n_part/2,n_part-1):
  system.part[i].add_bond((system.bonded_inter[1], system.part[i+1].id))

#visualizer = visualization.mayaviLive(system)
visualizer = visualization.openGLLive(system, {'bond_type_radius': [0.1]})

def main():
    for i in range(0,int_n_times):
        print(i)
        integrate.integrate(int_steps)
        visualizer.update()

#Start simulation in seperate thread
t = Thread(target=main)
t.daemon = True
t.start()

visualizer.start()
Exemplo n.º 5
0
import espressomd
import espressomd.shapes
from espressomd import electrostatics
from espressomd import visualization

required_features = ["ELECTROSTATICS", "WCA"]
espressomd.assert_features(required_features)

box_l = 20
system = espressomd.System(box_l=[box_l] * 3)
system.set_random_state_PRNG()
np.random.seed(seed=system.seed)
visualizer = visualization.openGLLive(
    system,
    constraint_type_colors=[[1, 1, 1]],
    camera_position=[50, 15, 15],
    camera_right=[0, 0, -1])

system.time_step = 0.02
system.cell_system.skin = 0.4
system.cell_system.set_layered(n_layers=5, use_verlet_lists=False)
system.periodicity = [1, 1, 0]

qion = 1
for i in range(300):
    rpos = np.random.random(3) * box_l
    system.part.add(pos=rpos, type=0, q=qion)
    qion *= -1

system.constraints.add(shape=espressomd.shapes.Wall(
Exemplo n.º 6
0
  Numpad 5: Shoot''')

# ESPRESSO
system = espressomd.System(box_l=[1.0, 1.0, 1.0])
table_dim = [2.24, 1.12]
system.box_l = [table_dim[0], 3, table_dim[1]]

visualizer = openGLLive(
    system,
    ext_force_arrows=True,
    ext_force_arrows_type_scale=[0.02],
    ext_force_arrows_type_radii=[0.01],
    background_color=[0.5, 0.4, 0.5],
    drag_enabled=False,
    particle_type_materials=['medium', 'bright', 'bright', 'medium'],
    particle_type_colors=[[1, 1, 1], [0.5, 0.1, 0.1], [0.1, 0.2, 0.4],
                          [0.2, 0.2, 0.2]],
    constraint_type_materials=['dark'],
    constraint_type_colors=[[0.1, 0.424, 0.011], [0.1, 0.1, 0.1]],
    camera_position=[1.12, 2.8, 0.56],
    window_size=[1000, 600],
    draw_axis=False,
    light_pos=[table_dim[0] * 0.5, 1.0, table_dim[1] * 0.5],
    light_colors=[[0.8, 0.8, 0.8], [0.9, 0.9, 0.9], [1.0, 1.0, 1.0]],
    light_brightness=1.0)


class Billiards:
    def __init__(self):
        self.stopped = True
        self.angle = np.pi * 0.5
        self.impulse = 10.0
Exemplo n.º 7
0
                                                       sigma=1,
                                                       cutoff=2,
                                                       shift="auto")
system.bonded_inter[0] = HarmonicBond(k=1.0, r_0=1.0)
system.bonded_inter[1] = HarmonicBond(k=1.0, r_0=1.0)

for i in range(n_part):
    system.part.add(id=i, pos=numpy.random.random(3) * system.box_l)

for i in range(n_part / 2):
    system.part[i].add_bond((system.bonded_inter[0], system.part[i + 1].id))
for i in range(n_part / 2, n_part - 1):
    system.part[i].add_bond((system.bonded_inter[1], system.part[i + 1].id))

#visualizer = visualization.mayaviLive(system)
visualizer = visualization.openGLLive(system, {'bond_type_radius': [0.1]})


def main():
    for i in range(0, int_n_times):
        print(i)
        integrate.integrate(int_steps)
        visualizer.update()


#Start simulation in seperate thread
t = Thread(target=main)
t.daemon = True
t.start()

visualizer.start()