コード例 #1
0
ファイル: polymer_diamond.py プロジェクト: xiuru-yan/espresso
 def setUp(self):
     bond = interactions.HarmonicBond(k=1.5, r_0=self.bond_length, r_cut=3)
     self.system.bonded_inter.add(bond)
     polymer.setup_diamond_polymer(system=self.system,
                                   bond=bond,
                                   **self.diamond_params)
     self.system.time_step = 0.1
     self.node_parts = self.system.part.select(
         type=self.diamond_params['type_nodes'])
     self.charged_mono = self.system.part.select(
         type=self.diamond_params['type_cM'])
     self.noncharged_mono = self.system.part.select(
         type=self.diamond_params['type_nM'])
コード例 #2
0
np.random.seed(seed=system.seed)
system.box_l = [box_l, box_l, box_l]
system.cell_system.skin = skin
system.periodicity = [1, 1, 1]

#the LJ potential with the central bead keeps all the beads from simply collapsing into the center
system.non_bonded_inter[1, 0].lennard_jones.set_params(
    epsilon=eps_cs, sigma=sig_cs,
    cutoff=sig_cs*np.power(2.,1./6.), shift=c_shift)
#the LJ potential (WCA potential) between surface beads causes them to be roughly equidistant on the colloid surface
system.non_bonded_inter[1, 1].lennard_jones.set_params(
    epsilon=eps_ss, sigma=sig_ss,
    cutoff=sig_ss*np.power(2.,1./6.), shift=c_shift)

#the harmonic potential pulls surface beads towards the central colloid bead
system.bonded_inter[0] = interactions.HarmonicBond(k=3000., r_0=harmonic_radius)

#for the warmup we use a Langevin thermostat with an extremely low temperature and high friction coefficient such that the trajectories roughly follow 
#the gradient of the potential while not accelerating too much
system.thermostat.set_langevin(kT=0.00001, gamma=40.)

print("# Creating raspberry")
center = box_l/2
colPos = np.ones(3)*center

q_col = 40 # note the charge on the colloid is actually negative
n_col_part = int(4*np.pi*np.power(radius_col,2) + 1) # Number of particles making up the raspberry (surface particles + the central particle).

# Place the central particle 
system.part.add(id=0, pos=colPos, type=0, q=-q_col, fix=(1,1,1),rotation=(1,1,1)) # Create central particle
コード例 #3
0
ファイル: electrophoresis.py プロジェクト: reinaual/espresso
###############################################################
# WCA between monomers
system.non_bonded_inter[0, 0].wca.set_params(epsilon=1, sigma=1)

# WCA counter-ions - polymer
system.non_bonded_inter[0, 1].wca.set_params(epsilon=1, sigma=1)

# WCA ions - polymer
system.non_bonded_inter[0, 2].wca.set_params(epsilon=1, sigma=1)

# WCA between ions
system.non_bonded_inter[1, 2].wca.set_params(epsilon=1, sigma=1)

# bonded interactions
################################################################
harmonic_bond = interactions.HarmonicBond(k=10, r_0=2)
angle_harmonic_bond = interactions.AngleHarmonic(bend=10, phi0=np.pi)
system.bonded_inter.add(harmonic_bond)
system.bonded_inter.add(angle_harmonic_bond)

# create monomer beads and bonds
##########################################################################
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]))
コード例 #4
0
ファイル: store_bonds.py プロジェクト: opichals/espresso
# 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 illustrates how bond information can be stored.
"""

from __future__ import print_function
import espressomd
from espressomd import interactions

system = espressomd.System(box_l=[10.0, 10.0, 10.0])
f = interactions.FeneBond(k=1, d_r_max=1)
f2 = interactions.FeneBond(k=2, d_r_max=1.5)
h = interactions.HarmonicBond(r_0=0, k=1)

# Pickle data
###########################################################
try:
    import cPickle as pickle
except ImportError:
    import pickle

system.bonded_inter.add(f)
system.bonded_inter.add(f2)
system.bonded_inter.add(h)

output_filename = "bonded_inter_save.pkl"

with open(output_filename, "wb") as bonded_ia_save:
コード例 #5
0
type_OH = 3  # type 3 = OH-
type_Na = 4  # type 4 = Na+
type_Cl = 5  # type 5 = Cl-

charges = {}
charges[type_HA] = 0
charges[type_A] = -1
charges[type_H] = 1
charges[type_OH] = -1
charges[type_Na] = 1
charges[type_Cl] = -1

# bonding interaction parameter
bond_l = 1.2  # bond length
kbond = 100  # force constant for harmonic bond
harmonic_bond = interactions.HarmonicBond(k=kbond, r_0=bond_l)
system.bonded_inter.add(harmonic_bond)

# non-bonding interactions (LJ)
lj_eps = 1.0
lj_sig = 1.0
lj_cut = 1.12246
lj_shift = 0.0

# setting up the polymer
positions = polymer.positions(n_polymers=N_P,
                              beads_per_chain=MPC,
                              bond_length=bond_l,
                              seed=13)
for polymer in positions:
    for i, pos in enumerate(polymer):
コード例 #6
0
sig_cs = radius_col

# System setup
#############################################################
system = espressomd.System(box_l=[box_l] * 3)
system.time_step = time_step
system.cell_system.skin = skin
system.periodicity = [True, True, True]
# the LJ potential with the central bead keeps all the beads from simply collapsing into the center
system.non_bonded_inter[1, 0].wca.set_params(epsilon=eps_cs, sigma=sig_cs)
# the LJ potential (WCA potential) between surface beads causes them to be roughly equidistant on the
# colloid surface
system.non_bonded_inter[1, 1].wca.set_params(epsilon=eps_ss, sigma=sig_ss)

# the harmonic potential pulls surface beads towards the central colloid bead
col_center_surface_bond = interactions.HarmonicBond(k=3000.,
                                                    r_0=harmonic_radius)
system.bonded_inter.add(col_center_surface_bond)

# for the warmup we use a Langevin thermostat with an extremely low temperature and high friction coefficient
# such that the trajectories roughly follow the gradient of the potential while not accelerating too much
random.seed(os.getpid())
seed_pass = random.choice(range(os.getpid()))
print(seed_pass)
system.thermostat.set_langevin(kT=0.00001, gamma=40., seed=seed_pass)

print("# Creating raspberry")
center = system.box_l / 2
colPos = (0, 0, 0)

# Number of particles making up the raspberry (surface particles + the central particle). use liberally
n_col_part = round(4 * np.pi * pow(radius_col, 2) / pow(agrid, 2)) + 5