Skip to content
Permalink
Browse files

Merge branch 'python' into fix-3476

  • Loading branch information
kodiakhq committed Feb 13, 2020
2 parents b302c32 + aa8ac8c commit cad96d6ff0c1242e3873fe762b364eaf2deca652
@@ -202,7 +202,7 @@ Setting up polymer chains
~~~~~~~~~~~~~~~~~~~~~~~~~

If you want to have polymers in your system, you can use the function
:func:`espressomd.polymer.positions()` to determine suitable positions.
:func:`espressomd.polymer.linear_polymer_positions()` to determine suitable positions.

Required arguments are the desired number of polymers ``n_polymers``, the
number of monomers per polymer chain ``beads_per_chain``, and the parameter
@@ -212,17 +212,17 @@ Determining suitable particle positions pseudo-randomly requires the use of
a pseudo-random number generator, which has to be seeded. This ``seed``
is therefore also a mandatory parameter.

The function :func:`espressomd.polymer.positions()` returns a
The function :func:`espressomd.polymer.linear_polymer_positions()` returns a
three-dimensional numpy array, namely a list of polymers containing the
positions of monomers (x, y, z). A quick example of how to set up polymers::

import espressomd
from espressomd import polymer

system = espressomd.System([50, 50, 50])
polymers = polymer.positions(n_polymers=10,
beads_per_chain=25,
bond_length=0.9, seed=23)
polymers = polymer.linear_polymer_positions(n_polymers=10,
beads_per_chain=25,
bond_length=0.9, seed=23)
for p in polymers:
for i, m in enumerate(p):
id = len(system.part)
@@ -258,29 +258,29 @@ with internal constraints, using Lagrange multipliers.
Setting up diamond polymer networks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

from espressomd import diamond

Creates a diamond-structured polymer network with 8 tetra-functional nodes
connected by :math:`2*8` polymer chains of length (MPC) in a unit cell
of length :math:`a`. The diamond command creates 16*MPC+8 many particles
:func:`espressomd.polymer.setup_diamond_polymer()` creates a diamond-structured
polymer network with 8 tetra-functional nodes
connected by :math:`2*8` polymer chains of length ``MPC`` with the system box as
the unit cell. The box therefore has to be cubic.
The diamond command creates ``16*MPC+8`` many particles
which are connected via the provided bond type (the term plus 8 stems from adding 8 nodes which are connecting the chains).
Chain monomers are placed at a mutual distance along the
vector connecting network nodes. The polymer is created starting from
particle ID 0. Nodes are assigned type 0, monomers (both charged and
uncharged) are type 1 and counterions type 2. For inter-particle bonds
interaction :math:`0` is taken which must be a two-particle bond.
Chain monomers are placed at constant distance to each other
along the vector connecting network nodes. The distance between monomers is
``system.box_l[0]*(0.25 * sqrt(3))/(MPC + 1)``, which should be taken into account
when choosing the connecting bond.
The starting particle id, the charges of monomers, the frequency
of charged monomers in the chains as well as the types of the node particles,
the charged and the uncharged chain particles can be set via keyword arguments, see :func:`espressomd.polymer.setup_diamond_polymer()`.

.. _diamond:
.. figure:: figures/diamond.png
:alt: Diamond-like polymer network with MPC=15.
:align: center
:height: 6.00000cm

Diamond-like polymer network with MPC=15.

See :class:`espressomd.diamond.Diamond` for more details. For simulating compressed or stretched gels the function
Diamond-like polymer network with ``MPC=15``.
For simulating compressed or stretched gels the function
:meth:`espressomd.system.System.change_volume_and_rescale_particles` may be used.


@@ -42,10 +42,10 @@
"monomers of a chain, *e.g.*:\n",
"\n",
"```python\n",
"positions = espressomd.polymer.positions(n_polymers=1,\n",
" beads_per_chain=10,\n",
" bond_length=1, seed=5642,\n",
" min_distance=0.9)\n",
"positions = espressomd.polymer.linear_polymer_positions(n_polymers=1,\n",
" beads_per_chain=10,\n",
" bond_length=1, seed=5642,\n",
" min_distance=0.9)\n",
"```\n",
"\n",
"which would create positions for a single polymer with 10 monomers. Please check the documentation for a more detailed description.\n",
@@ -99,10 +99,10 @@
"\n",
"\n",
"# Setup polymer of part_id 0 with fene bond\n",
"positions = espressomd.polymer.positions(n_polymers=1,\n",
" beads_per_chain=N_MONOMERS,\n",
" bond_length=1, seed=5642,\n",
" min_distance=0.9)\n",
"positions = espressomd.polymer.linear_polymer_positions(n_polymers=1,\n",
" beads_per_chain=N_MONOMERS,\n",
" bond_length=1, seed=5642,\n",
" min_distance=0.9)\n",
"for i, pos in enumerate(positions[0]):\n",
" id = len(system.part)\n",
" system.part.add(id=id, pos=pos)\n",
@@ -186,7 +186,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.6.9"
}
},
"nbformat": 4,
@@ -55,10 +55,10 @@
system.actors.clear()
system.auto_update_accumulators.clear()
# Setup polymer of part_id 0 with fene bond
positions = espressomd.polymer.positions(n_polymers=1,
beads_per_chain=N,
bond_length=1, seed=5642,
min_distance=0.9)
positions = espressomd.polymer.linear_polymer_positions(n_polymers=1,
beads_per_chain=N,
bond_length=1, seed=5642,
min_distance=0.9)
for i, pos in enumerate(positions[0]):
pid = len(system.part)
system.part.add(id=pid, pos=pos)
@@ -105,7 +105,7 @@ def a2quat(phi, theta):
cylinder = Cylinder(
center=0.5 * BOX_L,
axis=[1, 0, 0], radius=DIAMETER / 2.0, length=LENGTH, direction=-1)
#system.constraints.add(shape=cylinder, particle_type=1)
system.constraints.add(shape=cylinder, particle_type=1)

# Setup walls
wall = Wall(dist=PADDING, normal=[1, 0, 0])
@@ -218,9 +218,9 @@
"system.bonded_inter.add(hb)\n",
"\n",
"# create the polymer composed of ionizable acid groups, initially in the ionized state\n",
"polymers = polymer.positions(n_polymers=1,\n",
" beads_per_chain=N_acid,\n",
" bond_length=0.9, seed=23)\n",
"polymers = polymer.linear_polymer_positions(n_polymers=1,\n",
" beads_per_chain=N_acid,\n",
" bond_length=0.9, seed=23)\n",
"for polymer in polymers:\n",
" for index, position in enumerate(polymer):\n",
" id = len(system.part)\n",
@@ -677,7 +677,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.9"
}
},
"nbformat": 4,
@@ -71,12 +71,12 @@
# start it next to the wall to test it!
start = np.array([1, 1, 1 + wall_offset])

# polymer.positions will avoid violating the constraints
# polymer.linear_polymer_positions will avoid violating the constraints

positions = polymer.positions(n_polymers=1, beads_per_chain=50,
bond_length=1.0, seed=1234,
min_distance=0.9,
respect_constraints=True)
positions = polymer.linear_polymer_positions(n_polymers=1, beads_per_chain=50,
bond_length=1.0, seed=1234,
min_distance=0.9,
respect_constraints=True)
for i, pos in enumerate(positions[0]):
id = len(system.part)
system.part.add(id=id, pos=pos)
@@ -76,8 +76,8 @@

# create monomer beads and bonds
##########################################################################
init_polymer_pos = espressomd.polymer.positions(n_polymers=1, beads_per_chain=N_MONOMERS, bond_length=2.0,
seed=2, bond_angle=np.pi, min_distance=1.8, start_positions=np.array([system.box_l / 2.0]))
init_polymer_pos = espressomd.polymer.linear_polymer_positions(n_polymers=1, beads_per_chain=N_MONOMERS, bond_length=2.0,
seed=2, bond_angle=np.pi, min_distance=1.8, start_positions=np.array([system.box_l / 2.0]))

system.part.add(pos=init_polymer_pos[0], q=-np.ones(N_MONOMERS))

@@ -34,10 +34,10 @@
fene = interactions.FeneBond(k=10, d_r_max=2)
system.bonded_inter.add(fene)

positions = polymer.positions(n_polymers=5,
beads_per_chain=50,
bond_length=1.0,
seed=1234)
positions = polymer.linear_polymer_positions(n_polymers=5,
beads_per_chain=50,
bond_length=1.0,
seed=1234)
for polymer in positions:
for i, pos in enumerate(polymer):
id = len(system.part)
@@ -21,8 +21,7 @@
"""
import espressomd
espressomd.assert_features(["WCA"])
from espressomd import interactions
from espressomd import diamond
from espressomd import interactions, polymer
from espressomd.io.writer import vtf # pylint: disable=import-error

import numpy as np
@@ -67,8 +66,7 @@
print("box now at ", system.box_l)

# We can now call diamond to place the monomers, crosslinks and bonds.
diamond.Diamond(a=a, bond_length=bond_length, MPC=MPC)

polymer.setup_diamond_polymer(system=system, bond=fene, MPC=MPC)

#############################################################
# Warmup #
@@ -45,10 +45,10 @@
system.bonded_inter.add(fene)


positions = polymer.positions(n_polymers=1,
beads_per_chain=50,
bond_length=1.0,
seed=3210)
positions = polymer.linear_polymer_positions(n_polymers=1,
beads_per_chain=50,
bond_length=1.0,
seed=3210)
for i, pos in enumerate(positions[0]):
id = len(system.part)
system.part.add(id=id, pos=pos)
@@ -6,7 +6,6 @@ set(EspressoCore_SRC
communication.cpp
constraints.cpp
debug.cpp
diamond.cpp
domain_decomposition.cpp
dpd.cpp
energy.cpp

This file was deleted.

0 comments on commit cad96d6

Please sign in to comment.
You can’t perform that action at this time.