import argparse parser = argparse.ArgumentParser(epilog=__doc__) group = parser.add_mutually_exclusive_group() group.add_argument('--ft', action='store_true', help='Use FT approximation') group.add_argument('--fts', action='store_true', help='Use FTS approximation') args = parser.parse_args() if args.ft: print("Using FT approximation method") sd_method = "ft" else: print("Using FTS approximation method") sd_method = "fts" espressomd.assert_features("STOKESIAN_DYNAMICS") system = espressomd.System(box_l=[10, 10, 10]) system.time_step = 1.5 system.cell_system.skin = 0.4 system.periodicity = [False, False, False] system.integrator.set_stokesian_dynamics(viscosity=1.0, radii={0: 1.0}, approximation_method=sd_method) system.part.add(pos=[-5, 0, 0], rotation=[1, 1, 1]) system.part.add(pos=[0, 0, 0], rotation=[1, 1, 1]) system.part.add(pos=[7, 0, 0], rotation=[1, 1, 1]) gravity = espressomd.constraints.Gravity(g=[0, -1, 0])
# along with this program. If not, see <http://www.gnu.org/licenses/>. # """ Client part of the Gibbs ensemble simulation. This script handles the simulation boxes and communicates the energies to the host. The Monte-Carlo part of the simulation is done by the :file:`gibbs_ensemble_socket.py` script. """ import espressomd import socket import numpy as np import pickle import struct import argparse espressomd.assert_features("LENNARD_JONES") seed = None init_box_l = None particle_number = None lj_epsilon = None lj_sigma = None lj_cutoff = None lj_shift = None HOST = 'localhost' PORT = 31415 # Message identifiers MSG_START = 0
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import espressomd from espressomd import assert_features, electrostatics, electrostatic_extensions from espressomd.shapes import Wall from espressomd.minimize_energy import steepest_descent from espressomd import visualization_opengl import numpy from threading import Thread assert_features(["ELECTROSTATICS", "MASS", "LENNARD_JONES"]) system = espressomd.System(box_l=[1.0, 1.0, 1.0]) numpy.random.seed(seed=42) print("\n--->Setup system") # System parameters n_part = 1000 n_ionpairs = n_part / 2 density = 1.1138 time_step = 0.001823 temp = 1198.3 gamma = 50 #l_bjerrum = 0.885^2 * e^2/(4*pi*epsilon_0*k_B*T) l_bjerrum = 130878.0 / temp
################################################################################ # # # Active Matter: Swimmer Flow Field Tutorial # # # ########################################################################## from __future__ import print_function import numpy as np import os import sys import espressomd from espressomd import assert_features, lb assert_features(["ENGINE", "LB_GPU", "MASS", "ROTATION", "ROTATIONAL_INERTIA"]) # Read in the hydrodynamic type (pusher/puller) and position if len(sys.argv) != 3: print("Usage:", sys.argv[0], "<type> <pos>") exit() mode = sys.argv[1] pos = float(sys.argv[2]) ########################################################################## outdir = "./RESULTS_FLOW_FIELD/T_{}_P_{}/".format(mode, pos) try: os.makedirs(outdir)
# (at your option) any later version. # # ESPResSo is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging import numpy as np logging.basicConfig(level=logging.INFO) import espressomd espressomd.assert_features(['LENNARD_JONES']) import espressomd.accumulators import espressomd.observables import espressomd.polymer # Setup constant TIME_STEP = 0.01 LOOPS = 5000 STEPS = 100 # System setup system = espressomd.System(box_l=[32.0, 32.0, 32.0]) system.cell_system.skin = 0.4 # Lennard-Jones interaction system.non_bonded_inter[0, 0].lennard_jones.set_params(epsilon=1.0,
################################################################################ # # # Active Matter: Rectification System Setup # # # ########################################################################## from __future__ import print_function from math import cos, pi, sin import numpy as np import os import sys import espressomd espressomd.assert_features(["LB_GPU", "LB_BOUNDARIES_GPU"]) from espressomd import lb from espressomd.lbboundaries import LBBoundary from espressomd.shapes import Cylinder, Wall, HollowCone # Setup constants outdir = "./RESULTS_RECTIFICATION" try: os.makedirs(outdir) except: print("INFO: Directory \"{}\" exists".format(outdir)) # Setup the box (we pad the diameter to ensure that the LB boundaries # and therefore the constraints, are away from the edge of the box)
# ESPResSo is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ Demonstrates the construction of a rigid object by means of the VIRTUAL_SITES_RELATIVE feature. """ from __future__ import print_function import espressomd espressomd.assert_features(["VIRTUAL_SITES_RELATIVE"]) from espressomd import thermostat from espressomd import integrate from espressomd.virtual_sites import VirtualSitesRelative import numpy as np required_features = ["VIRTUAL_SITES_RELATIVE", "MASS", "ROTATIONAL_INERTIA"] espressomd.assert_features(required_features) box_l = 100 system = espressomd.System(box_l=[box_l, box_l, box_l]) system.set_random_state_PRNG() system.seed = system.cell_system.get_state()['n_nodes'] * [1234] system.time_step = 0.01
# along with this program. If not, see <http://www.gnu.org/licenses/>. # # # ################################################################################ # # # Active Matter: Swimmer Flow Field Tutorial # # # ########################################################################## import numpy as np import os import sys import espressomd from espressomd import assert_features, lb assert_features(["ENGINE", "CUDA", "MASS", "ROTATION", "ROTATIONAL_INERTIA"]) # Read in the hydrodynamic type (pusher/puller) and position if len(sys.argv) != 3: print("Usage:", sys.argv[0], "<type> <pos>") exit() mode = sys.argv[1] pos = float(sys.argv[2]) ########################################################################## outdir = "./RESULTS_FLOW_FIELD/T_{}_P_{}/".format(mode, pos) try: os.makedirs(outdir) except:
# # ########################################################################## from __future__ import print_function from math import cos, pi, sin import numpy as np import os import sys import espressomd from espressomd import assert_features from espressomd.shapes import Cylinder, Wall, HollowCone assert_features(["ENGINE", "CONSTRAINTS", "LENNARD_JONES", "ROTATION", "MASS"]) # Quaternion procedure def a2quat(phi, theta): q1w = cos(theta / 2.0) q1x = 0 q1y = sin(theta / 2.0) q1z = 0 q2w = cos(phi / 2.0) q2x = 0 q2y = 0 q2z = sin(phi / 2.0)
phase diagram differ from the long range uncut LJ-potential. The phase diagram of the used potential can be found in 'B. Smit, J. Chem. Phys. 96 (11), 1992, Phase diagrams of Lennard-Jones fluids'. """ import socket import numpy as np import pickle import subprocess import struct import random import matplotlib.pyplot as plt import argparse from espressomd import assert_features assert_features("LENNARD_JONES") parser = argparse.ArgumentParser() parser.add_argument('-s', '--seed', type=int, nargs=1) parser.add_argument('-S', '--steps', type=int, nargs=1) parser.add_argument('-w', '--warm_up_steps', type=int, nargs=1) parser.add_argument('-E', '--espresso-executable', nargs=1) parser.add_argument('-C', '--client-script', nargs=1) parser.add_argument('-n', '--number-of-particles', type=int, nargs=1) parser.add_argument('-l', '--box-length', type=float, nargs=1) parser.add_argument('-T', '--temperature', type=float, nargs=1) args = parser.parse_args() # system parameters seed = None
# Active Matter: Enhanced Diffusion Tutorial # ########################################################################## import numpy as np import os import sys import argparse import time import espressomd from espressomd import assert_features from espressomd.observables import ParticlePositions, ParticleVelocities, ParticleAngularVelocities from espressomd.accumulators import Correlator espressomd.assert_features( ["ENGINE", "ROTATION", "MASS", "ROTATIONAL_INERTIA"]) # create an output folder outdir = "./RESULTS_ENHANCED_DIFFUSION/" os.makedirs(outdir, exist_ok=True) ########################################################################## # Read in the active velocity from the command prompt parser = argparse.ArgumentParser() parser.add_argument('vel', type=float, help='Velocity of active particle.') args = parser.parse_args() vel = args.vel
import random import os import numpy as np from itertools import product from espressomd.io.writer import vtf from espressomd.virtual_sites import VirtualSitesRelative from espressomd import lb from espressomd import interactions import espressomd espressomd.assert_features([ "ROTATION", "ROTATIONAL_INERTIA", "EXTERNAL_FORCES", "MASS", "VIRTUAL_SITES_RELATIVE", "LENNARD_JONES" ]) # System parameters ############################################################# box_l = 40. # size of the simulation box skin = 3 # Skin parameter for the Verlet lists time_step = 0.001 eq_tstep = 0.001 n_cycle = 1000 # 100 integ_steps = 150 # Interaction parameters (Lennard-Jones for raspberry) ############################################################# # the subscript c is for colloid and s is for salt (also used for the surface beads) agrid = 1 eps_ss = 1 # LJ epsilon between the colloid's surface particles.
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # ESPResSo is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import math import numpy as np import espressomd espressomd.assert_features(["MASS"]) import espressomd.shapes from espressomd.visualization_opengl import openGLLive box_l = 50 system = espressomd.System(box_l=[box_l, 15, box_l]) system.set_random_state_PRNG() #system.seed = system.cell_system.get_state()['n_nodes'] * [1234] np.random.seed(seed=system.seed) yoff = 3 # cup cup_top_circ = 21 cup_bot_circ = 15 cup_height = 6
########################################################################## from __future__ import print_function import numpy as np import os import sys import time import espressomd from espressomd import assert_features from espressomd.observables import ParticlePositions, ParticleVelocities, ParticleAngularVelocities from espressomd.accumulators import Correlator required_features = ["ENGINE", "ROTATION"] assert_features(required_features) # create an output folder outdir = "./RESULTS_ENHANCED_DIFFUSION/" try: os.makedirs(outdir) except: print("INFO: Directory \"{}\" exists".format(outdir)) ########################################################################## # Read in the active velocity from the command prompt if len(sys.argv) != 2: print("Usage:", sys.argv[0], "<vel> (0 <= vel < 10.0)") exit()
# # ESPResSo is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import espressomd from espressomd import assert_features, electrostatics from espressomd.observables import RDF from espressomd.accumulators import MeanVarianceCalculator import numpy assert_features(["ELECTROSTATICS", "WCA"]) print("\n--->Setup system") # System parameters n_part = 200 n_ionpairs = n_part / 2 density = 0.5 time_step = 0.01 temp = 1.0 gamma = 1.0 l_bjerrum = 7.0 num_steps_equilibration = 1000 num_configs = 100 integ_steps_per_config = 1000
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # """ This sample sets up a polymer and tests the available cell systems. """ from __future__ import print_function import time import numpy as np import espressomd espressomd.assert_features(["LENNARD_JONES"]) from espressomd import polymer from espressomd import interactions def profile(): cs.skin = skin ti = time.time() system.integrator.run(n_steps) tf = time.time() print("\t with skin={} ran {:d} steps in {:f} seconds. steps/sec:{:f} ". format(skin, n_steps, tf - ti, n_steps * 1. / (tf - ti))) system = espressomd.System(box_l=[100, 100, 100]) system.set_random_state_PRNG()
# Active Matter: Rectification System Setup # # # ################################################################################ from __future__ import print_function from math import cos, pi, sin import numpy as np import os import sys from espressomd import assert_features, lb from espressomd.lbboundaries import LBBoundary from espressomd.shapes import Cylinder, Wall, HollowCone assert_features(["LB_GPU", "LB_BOUNDARIES_GPU"]) # Setup constants outdir = "./RESULTS_RECTIFICATION_GEOMETRY/" try: os.makedirs(outdir) except: print("INFO: Directory \"{}\" exists".format(outdir)) # Setup the box (we pad the diameter to ensure that the LB boundaries # and therefore the constraints, are away from the edge of the box) length = 100 diameter = 20 dt = 0.01
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # ESPResSo is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # """ This sample sets up a diamond-structured polymer network. """ import espressomd espressomd.assert_features(["WCA"]) from espressomd import thermostat from espressomd import interactions from espressomd import diamond from espressomd.io.writer import vtf # pylint: disable=import-error import numpy as np # System parameters ############################################################# system = espressomd.System(box_l=[1.0, 1.0, 1.0]) system.set_random_state_PRNG() system.seed = system.cell_system.get_state()['n_nodes'] * [1234] np.seed = system.seed system.time_step = 0.01
# Active Matter: Enhanced Diffusion Tutorial # # # ################################################################################ from __future__ import print_function import numpy as np import os import sys import time from espressomd import assert_features from espressomd.observables import ParticlePositions, ParticleVelocities, ParticleAngularVelocities from espressomd.correlators import Correlator assert_features(["ENGINE", "ROTATION"]) # create an output folder outdir = "./RESULTS_ENHANCED_DIFFUSION/" try: os.makedirs(outdir) except: print("INFO: Directory \"{}\" exists".format(outdir)) ################################################################################ # Read in the active velocity from the command prompt if len(sys.argv) != 2: print("Usage:", sys.argv[0], "<vel> (0 <= vel < 10.0)")