Exemple #1
0
class Big(m.Particle):
    mass = 10
    radius = 8
    frozen = True
    style = {'color': 'orange'}


# simple harmonic potential to pull particles
pot = m.Potential.harmonic(k=1, r0=0.1, max=3)

# potentials between green and big objects.
pot_yc = m.Potential.glj(e=1, r0=1, m=3, min=0.01)
pot_cc = m.Potential.glj(e=0.0001, r0=0.1, m=3, min=0.005, max=2)

# random points on surface of a sphere
pts = m.random_points(m.Sphere,
                      10000) * (Green.radius + Big.radius) + m.Universe.center

# make the big particle at the middle
Big(m.Universe.center)

# constuct a particle for each position, make
# a list of particles
beads = [Green(p) for p in pts]

# create an explicit bond for each pair in the
# list of particles. The bind_pairwise method
# searches for all possible pairs within a cutoff
# distance and connects them with a bond.
#m.bind_pairwise(pot, beads, 0.7)

rforce = m.forces.random(0, 0.01, durration=0.1)
Exemple #2
0
#pot_yc = m.Potential.glj(e=500, r0=10, m=5, k=100, min=0.1, max=50*Cell.radius, tol=0.1)
pot_yc = m.Potential.glj(e=100,
                         r0=5,
                         m=3,
                         k=500,
                         min=0.1,
                         max=50 * Cell.radius,
                         tol=0.1)
pot_cc = m.Potential.glj(e=1, r0=2, m=2, min=0.05, max=2.2 * Cell.radius)

# bind the potential with the *TYPES* of the particles
m.Universe.bind(pot_yc, Yolk, Cell)
m.Universe.bind(pot_cc, Cell, Cell)

# create a random force. In overdamped dynamcis, we neeed a random force to
# enable the objects to move around, otherwise they tend to get trapped
# in a potential
rforce = m.forces.random(0, 100, durration=0.5)

# bind it just like any other force
m.bind(rforce, Cell)

yolk = Yolk(position=center - [0., 0., yshift])

for i, p in enumerate(m.random_points(m.SolidSphere, count)):
    pos = p * clump_radius + center + [0., 0., cshift]
    Cell(position=pos)

# run the simulator interactive
m.Simulator.run()
Exemple #3
0
class Receptor(m.Particle):
    mass = 0.1
    radius = 0.1
    target_temperature = 1
    dynamics = m.Overdamped


class Virus(m.Particle):
    mass = 1
    radius = 0.5
    target_temperature = 1
    dynamics = m.Overdamped


# locations of initial receptor positions
receptor_pts = m.random_points(m.Sphere, receptor_count) * Big.radius + center

pot_rr = m.Potential.soft_sphere(kappa=0.02,
                                 epsilon=0,
                                 r0=0.5,
                                 eta=2,
                                 tol=0.05,
                                 min=0.01,
                                 max=4)
pot_vr = m.Potential.soft_sphere(kappa=0.02,
                                 epsilon=0.1,
                                 r0=0.6,
                                 eta=4,
                                 tol=0.05,
                                 min=0.01,
                                 max=3)
    eta=2, tol = 0.05, min=0, max=3)

# bind the potential with the *TYPES* of the particles
m.Universe.bind(pot_bs, Yolk, Cell)
m.Universe.bind(pot_ss, Cell, Cell)

# create a random force. In overdamped dynamcis, we neeed a random force to
# enable the objects to move around, otherwise they tend to get trapped
# in a potential
rforce = m.forces.random(0, 0.05)

# bind it just like any other force
m.bind(rforce, Cell)

yolk = Yolk(position=center, velocity=[0., 0., 0.])

for p in m.random_points(m.SolidSphere, count) * \
    0.5 * Yolk.radius + center + [0, 0, 1.3 * Yolk.radius]:
    Cell(p)

# run the simulator interactive
m.Simulator.run()








Exemple #5
0
import mechanica as m
import numpy as np

m.Simulator(dim=[20., 20., 20.], cutoff=8, bc=m.BOUNDARY_NONE)


class Bead(m.Particle):
    mass = 1
    radius = 0.1
    dynamics = m.Overdamped


pot = m.Potential.harmonic(k=1, r0=0.1, max=3)

pts = m.random_points(m.SolidCube, 10000) * 18 + m.Universe.center

beads = [Bead(p) for p in pts]

m.bind_pairwise(pot, beads, 1)

m.run()
Exemple #6
0

class B(m.Particle):
    radius = 0.1
    dynamics = m.Overdamped
    mass = 10
    style = {"color": "skyblue"}


p = m.Potential.coulomb(q=2, min=0.01, max=3)

m.bind(p, A, A)
m.bind(p, B, B)
m.bind(p, A, B)

r = m.forces.random(0, 1)

m.bind(r, A)

pos = m.random_points(m.SolidCube, 50000) * 10 + m.Universe.center

[A(p) for p in pos]

a = A.items()[0]

[p.become(B) for p in a.neighbors(3)]

a.radius = 2

m.show()
Exemple #7
0

class Nucleus(m.Particle):
    mass = 500000
    radius = 1


class Receptor(m.Particle):
    mass = 0.2
    radius = 0.05
    target_temperature = 1
    #dynamics = m.Overdamped


# locations of initial receptor positions
receptor_pts = m.random_points(m.SolidSphere, receptor_count) * 5 + center

pot_nr = m.Potential.well(k=15, n=3, r0=7)
pot_rr = m.Potential.soft_sphere(kappa=15,
                                 epsilon=0,
                                 r0=0.3,
                                 eta=2,
                                 tol=0.05,
                                 min=0.01,
                                 max=1)

# bind the potential with the *TYPES* of the particles
m.bind(pot_rr, Receptor, Receptor)
m.bind(pot_nr, Nucleus, Receptor)

# create a random force (Brownian motion), zero mean of given amplitide
Exemple #8
0
m.init(dim=dim,
       cutoff=5,
       integrator=m.FORWARD_EULER,
       dt=0.001)

class A(m.Particle):
    radius=0.1
    dynamics = m.Overdamped
    mass=5
    style={"color":"MediumSeaGreen"}

class C(m.Particle):
    radius=10
    frozen = True
    style={"color":"orange"}

C(m.Universe.center)

pos = m.random_points(m.Sphere, 5000) * (C.radius+A.radius)  + m.Universe.center

[A(p) for p in pos]

pc = m.Potential.glj(e=30, m=2, max=5)
pa = m.Potential.coulomb(q=100, min=0.01, max=5)

m.bind(pc, A, C)
m.bind(pa, A, A)

m.show()
Exemple #9
0
h = m.Potential.harmonic(k=40, r0=0.001, max=5)

m.bind(pc, A, C)
m.bind(pc, B, C)
m.bind(pa, A, A)
#m.bind(pb, B, B)
#m.bind(pab, A, B)

r = m.forces.random(0, 5)

m.bind(r, A)
#m.bind(r, B)

c = C(m.Universe.center)

pos_a = m.random_points(m.SolidSphere, 3000, dr=0.25, phi=(0, 0.60 * np.pi)) \
    * ((1 + 0.25/2) * C.radius)  + m.Universe.center

parts, bonds = m.bind_sphere(h,
                             type=B,
                             n=4,
                             phi=(0.6 * np.pi, np.pi),
                             radius=C.radius + B.radius)

[A(p) for p in pos_a]

# grab a vertical slice of the neighbors of the yolk:
slice_parts = [p for p in c.neighbors() if p.spherical()[1] > 0]

m.bind_pairwise(pab, slice_parts, cutoff=5 * A.radius, pairs=[(A, B)])
Exemple #10
0
pot_yc = m.Potential.glj(e=100, r0=5, m=3, k=500, min=0.1,  max=1.5 * Big.radius, tol=0.1)
#pot_cc = m.Potential.glj(e=0,   r0=2, m=2, k=10,  min=0.05, max=1 * Big.radius)
pot_cc = m.Potential.harmonic(r0=0, k=0.1, max=10)

#pot_yc = m.Potential.glj(e=10, r0=1, m=3, min=0.1, max=50*Small.radius, tol=0.1)
#pot_cc = m.Potential.glj(e=100, r0=5, m=2, min=0.05, max=0.5*Big.radius)

# bind the potential with the *TYPES* of the particles
m.Universe.bind(pot_yc, Big, Small)
m.Universe.bind(pot_cc, Small, Small)

# create a random force. In overdamped dynamcis, we neeed a random force to
# enable the objects to move around, otherwise they tend to get trapped
# in a potential
rforce = m.forces.random(0, 100, durration=0.5)

# bind it just like any other force
m.bind(rforce, Small)

yolk = Big(position=center)


for p in m.random_points(m.Sphere, count):
    pos = p * (Big.radius + Small.radius) + center
    Small(position=pos)


# run the simulator interactive
m.Simulator.run()
Exemple #11
0
m.bind(p_yolk, Cell, Yolk)
m.bind(p_yolk, Actin, Yolk)
m.bind(p_cell, Cell, Cell)
m.bind(p_cellactin, Cell, Actin)

r = m.forces.random(0, 5)

m.bind(r, Cell)
#m.bind(r, Actin)

# make a yolk at the center of the simulation domain
yolk = Yolk(m.Universe.center)

# create the initial cell positions
cell_positions = m.random_points(m.SolidSphere, 6000, dr=dr, phi=(0, epiboly_percent * np.pi)) \
    * ((1 + dr/2) * Yolk.radius)  + yolk.position

# create an actin mesh that covers a section of a sphere.
parts, bonds = m.bind_sphere(p_actin, type=Actin, n=4, \
                             phi=(0.9 * epiboly_percent * np.pi, \
                                  (epiboly_percent + actin_percent * (1 - epiboly_percent)) * np.pi), \
                             radius = Yolk.radius + Actin.radius)

# create the initial cell cells
[Cell(p) for p in cell_positions]

#m.bind_pairwise(h, c.neighbors(2* Cell.radius), cutoff=2*Cell.radius, pairs=[(Cell,Actin)])

# set visiblity on the different objects
Yolk.style.visible = True
Exemple #12
0
    radius = 0.2
    target_temperature=0


pot_bs = m.Potential.soft_sphere(kappa=100, epsilon=1, r0=3.2, \
    eta=3, tol = 0.1, min=0.1, max=8)

pot_ss = m.Potential.soft_sphere(kappa=1, epsilon=0.1, r0=0.2, \
    eta=2, tol = 0.05, min=0.01, max=4)

# bind the potential with the *TYPES* of the particles
m.Universe.bind(pot_bs, Big, Small)
m.Universe.bind(pot_ss, Small, Small)

Big(position=center, velocity=[0., 0., 0.])

for p in m.random_points(m.Disk, count) * \
    2.5 * Big.radius + center + [0, 0, Big.radius + 1]:
    Small(p)

# run the simulator interactive
m.Simulator.run()








Exemple #13
0
    style={"color":"MediumSeaGreen"}

class B(m.Particle):
    radius=0.2
    dynamics = m.Overdamped
    mass=1
    style={"color":"skyblue"}

class C(m.Particle):
    radius=10
    frozen = True
    style={"color":"orange"}

C(m.Universe.center)

pos_a = m.random_points(m.Sphere, 12000) * (C.radius+A.radius)  + m.Universe.center
pos_b = m.random_points(m.Sphere, 4000) * (C.radius+B.radius + 1)  + m.Universe.center

# make a ring of of 50 particles
pts = m.points(m.Ring, 100) * (C.radius+B.radius)  + m.Universe.center - [0, 0, 1]

#positions = m.random_points(m.SolidSphere, 5000) * 9 + m.Universe.center

#[A(p) for p in pos_a if p[2] > m.Universe.center[2]]
[B(p) for p in pts]


pc  = m.Potential.glj(e=30, m=2, max=5)
pa   = m.Potential.glj(e=3, m=2.5, max=3)
pb   = m.Potential.glj(e=1, m=4, max=1)
pab  = m.Potential.glj(e=1, m=2, max=1)