# import espressomd from espressomd import assert_features, electrostatics from espressomd import visualization_opengl import numpy from threading import Thread from time import sleep assert_features(["ELECTROSTATICS", "MASS", "LENNARD_JONES"]) system = espressomd.System(box_l=[1.0, 1.0, 1.0]) system.seed = system.cell_system.get_state()['n_nodes'] * [1234] numpy.random.seed(system.seed) visualizer = visualization_opengl.openGLLive(system, drag_force=5 * 298, background_color=[1, 1, 1], light_pos=[30, 30, 30]) # Callbacks to control temperature temperature = 298.0 def increaseTemp(): global temperature temperature += 10 system.thermostat.set_langevin(kT=temperature, gamma=1.0) print("T = {:.0f} K".format(temperature)) def decreaseTemp(): global temperature
from espressomd import thermostat from espressomd import integrate import numpy as np from threading import Thread from espressomd import visualization_opengl required_features = [] espressomd.assert_features(required_features) print("Press u/j to change temperature") box_l = 10.0 system = espressomd.System(box_l=[box_l] * 3) system.set_random_state_PRNG() visualizer = visualization_opengl.openGLLive(system, drag_enabled=True, drag_force=100) system.time_step = 0.00001 system.cell_system.skin = 3.0 N = 50 for i in range(N): system.part.add(pos=[0, 0, 0]) system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42) # Callback for particle positions/velocities def spin():
box_l = (n_ionpairs * sum(masses.values()) / density)**(1. / 3.) box_z = box_l + 2.0 * (lj_sigmas["Electrode"]) box_volume = box_l * box_l * box_z elc_gap = box_z * 0.15 system.box_l = [box_l, box_l, box_z + elc_gap] system.periodicity = [1, 1, 1] system.time_step = time_step system.cell_system.skin = 0.3 system.thermostat.set_langevin(kT=temp, gamma=gamma, seed=42) # Visualizer visualizer = visualization_opengl.openGLLive( system, camera_position=[-3 * box_l, box_l * 0.5, box_l * 0.5], camera_right=[0, 0, 1], drag_force=5 * 298, background_color=[1, 1, 1], light_pos=[30, 30, 30], ext_force_arrows_type_scale=[0.0001], ext_force_arrows=False) # Walls system.constraints.add(shape=Wall(dist=0, normal=[0, 0, 1]), particle_type=types["Electrode"]) system.constraints.add(shape=Wall(dist=-box_z, normal=[0, 0, -1]), particle_type=types["Electrode"]) # Place particles for i in range(int(n_ionpairs)): p = numpy.random.random(3) * box_l p[2] += lj_sigmas["Electrode"]
temp_change_inc_type = 4 temp_change_dec_type = 5 dtemp = 1000.0 # VISUALIZER zoom = 10 visualizer = openGLLive(system, window_size=[800, 600], draw_axis=False, particle_sizes=[ snake_head_sigma * 0.5, snake_bead_sigma * 0.5, cylinder_sigma, bubble_sigma * 0.5, temp_change_radius, temp_change_radius ], particle_type_colors=[[1, 1, 0], [1, 0, 1], [0, 0, 1], [0, 1, 1], [0, 1, 0], [1, 0, 0], [0.5, 0, 1]], constraint_type_colors=[[1, 1, 1]], camera_position=[ snake_startpos[0], snake_startpos[1], system.box_l[2] * zoom ], camera_target=snake_startpos) # JOYPAD CONTROL if has_pygame: pygame.init() pygame.joystick.init() # CHECK FOR JOYSTICKS
for i in range(3): system.non_bonded_inter[i, 2].lennard_jones.set_params( epsilon=lj_eps, sigma=lj_sig, cutoff=lj_cut, shift="auto") visualizer = openGLLive( system, background_color=[0.2, 0.2, 0.3], camera_position=[box_l / 2.0, box_l / 4.0, 20 * 3], particle_sizes=[0.6, 0.75, 0.9, 0.2], particle_type_materials=['bright', 'bright', 'plastic', 'chrome'], particle_type_colors=[[0.2, 0.2, 0.8, 1], [0.8, 0.2, 0.2, 1], [1, 1, 1, 1], [0.8, 0.8, 0.8, 1]], bond_type_materials=['chrome'], bond_type_colors=[[0.2, 0.2, 0.2, 0.5]], bond_type_radius=[0.1], constraint_type_colors=[[1, 1, 1, 0.5]], constraint_type_materials=['chrome'], spotlight_brightness=5.0, spotlight_focus=100, spotlight_angle=60, light_brightness=1.0, ext_force_arrows=False, draw_axis=False, draw_box=False, drag_enabled=True) def rotate(): visualizer.camera.rotateSystemXL()
""" Visualization sample for charged particles. Simulates a pool of particles with various charges, LJ parameters and masses. """ import espressomd from espressomd.visualization_opengl import openGLLive from espressomd import electrostatics import numpy as np required_features = ["ELECTROSTATICS", "LENNARD_JONES", "MASS"] espressomd.assert_features(required_features) box = [40, 40, 40] system = espressomd.System(box_l=box) system.cell_system.set_domain_decomposition(use_verlet_lists=True) visualizer = openGLLive(system, background_color=[ 1, 1, 1], drag_enabled=True, drag_force=10) system.set_random_state_PRNG() # TIMESTEP time_step_fs = 1.0 system.time_step = time_step_fs * 1.0e-2 system.cell_system.skin = 1.2 # TEMPERATURE SI_temperature = 400.0 kb_kjmol = 0.0083145 temperature = SI_temperature * kb_kjmol # COULOMB PREFACTOR (elementary charge)^2 / (4*pi*epsilon_0) in Angstrom * kJ/mol epsilon_r = 4.0
required_features = ["LB_BOUNDARIES"] espressomd.assert_features(required_features) system = espressomd.System(box_l=[10.0, 10.0, 5.0]) system.set_random_state_PRNG() system.time_step = 0.01 system.cell_system.skin = 0.4 lb_fluid = espressomd.lb.LBFluid( agrid=1.0, dens=1.0, visc=1.0, tau=0.01, ext_force_density=[0, 0, 0.15]) system.actors.add(lb_fluid) cylinder_shape = espressomd.shapes.Cylinder( center=[5.0, 5.0, 5.0], axis=[0, 0, 1], direction=-1, radius=4.0, length=20.0) cylinder_boundary = espressomd.lbboundaries.LBBoundary(shape=cylinder_shape) system.lbboundaries.add(cylinder_boundary) visualizer = visualization_opengl.openGLLive( system, background_color=[1, 1, 1], camera_position=[5, 5, 25], LB_draw_boundaries=True, LB_draw_nodes=True, LB_draw_node_boundaries=True) visualizer.run(1)
""" import espressomd from espressomd.visualization_opengl import openGLLive import numpy as np required_features = ["LENNARD_JONES"] espressomd.assert_features(required_features) box = [40, 30, 20] system = espressomd.System(box_l=box) system.set_random_state_PRNG() visualizer = openGLLive(system, window_size=[800, 800], background_color=[0, 0, 0], camera_position=[20, 15, 80], particle_coloring='node', draw_nodes=True, draw_cells=True) system.time_step = 0.0005 system.cell_system.set_domain_decomposition(use_verlet_lists=True) system.cell_system.skin = 0.4 for i in range(100): system.part.add(pos=box * np.random.random(3)) system.non_bonded_inter[0, 0].lennard_jones.set_params(epsilon=100.0, sigma=1.0, cutoff=3.0, shift="auto")
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