Exemple #1
0
def test_rectangles():
    """Tests geometric shape by converting them to quivalent smoldyn text
    lines.

    >>> test_rectangles()
    panel PanelShape.rect +x 0 10 1 10 20 A
    panel PanelShape.tri  0 0 0 1 1 1 1 3 -10 t1
    panel PanelShape.sph  0 -10 0 3 10 10 s1
    panel PanelShape.cyl  20 30 70 20 50 70 4 20 20 cyl1
    panel PanelShape.disk  20 20 20 10 10 20 20 d1
    """
    r1 = S.Rectangle((0, 10, 1), dimensions=(10, 20), axis="+x", name="A")
    print(r1.toText())
    tr = S.Triangle(vertices=[[0, 0, 0], [1, 1, 1], [1, 3, -10]], name="t1")
    print(tr.toText())
    sph = S.Sphere(center=[0, -10, 0],
                   radius=3,
                   slices=10,
                   stacks=10,
                   name="s1")
    print(sph.toText())
    cyl = S.Cylinder(start=[20, 30, 70],
                     end=[20, 50, 70],
                     radius=4,
                     slices=20,
                     stacks=20,
                     name="cyl1")
    print(cyl.toText())
    disk = S.Disk(center=[20, 20, 20],
                  radius=10,
                  vector=[10, 20, 20],
                  name="d1")
    print(disk.toText())
Exemple #2
0
                   difc=dict(all=3, front=0),
                   display_size=5)
yellow = s.addSpecies("yellow",
                      color="black",
                      difc=dict(soln=3, back=1),
                      display_size=5)
blue = s.addSpecies("blue", color="blue", difc=3, display_size=5)

red.addToSolution(100)
yellow.addToSolution(50, pos=(50, 50))
blue.addToSolution(50, pos=(20, 20))

# Construct a closed path in 2D.
p = s.addPath2D((0, 0), (100, 0), (100, 100), (0, 100), closed=True)
walls = s.addSurface("walls", panels=p.panels)
walls.setAction('both', [red, yellow, blue], "reflect")
walls.setStyle('both', color="black")

sph = smoldyn.Sphere(center=(50, 50), radius=20, slices=20)
surf = s.addSurface("stick", panels=[sph])
surf.setRate(red, "fsoln", "front", rate=1, revrate=0.1)
surf.setRate(yellow, "bsoln", "back", rate=1, revrate=0.1)
surf.setRate(blue, "fsoln", "bsoln", rate=1, revrate=0.1)
surf.setStyle('front', color=(1, 0.7, 0))
surf.setStyle('back', color=(0.6, 0, 0.6))
surf.addMolecules((red, "front"), 100)

s.setGraphics("opengl")
s.addCommand("killmolinsphere red all", "b")
sim = s.run(1000, dt=0.01)
Exemple #3
0
import smoldyn
import smoldyn._smoldyn as S
import numpy
import matplotlib.pyplot as plt

s = smoldyn.Simulation(low=[-10, -10, -10], high=[10, 10, 10])
target = s.addSpecies("target",
                      color=dict(all="red"),
                      display_size={"all": 10})
protein = s.addSpecies("protein",
                       color="black",
                       display_size=3,
                       difc=dict(all=1))
counter = s.addSpecies("counter", color="white", display_size=0)

sph1 = smoldyn.Sphere(center=[0, 0, 0], radius=10, slices=20, stacks=20)
membrane = s.addSurface(name="membrane", panels=[sph1])
membrane.setStyle("both", color="blue", drawmode="edge")
#membrane.setRate(protein, "bsoln", "back", rate=1, revrate=0.1)

r1 = s.addReaction("r1",
                   subs=[(target, "up"), (protein, "bsoln")],
                   prds=[(target, "up"), counter],
                   rate=6)
r2 = s.addReaction("r2",
                   subs=[(target, "up"), (protein, "back")],
                   prds=[(target, "up"), counter],
                   rate=12)

#s.setGraphics("opengl", frame_thickness=0, text_display=["time",protein,(protein,"back"), counter])
s.addOutputData("output")
Exemple #4
0
# Type `help(smoldyn.Species)` in Python console to see all parameters.
S = s.addSpecies("S",
                 difc=3,
                 color=dict(all="green"),
                 display_size=dict(all=0.02))
E = s.addSpecies("E", color=dict(all="darkred"), display_size=dict(all=0.03))
P = s.addSpecies("P",
                 difc=3,
                 color=dict(all="darkblue"),
                 display_size=dict(all=0.02))
ES = s.addSpecies("ES", color=dict(all="orange"), display_size=dict(all=0.03))

# Surfaces in and their properties. Each surface requires at least one panel.
# Add action to `both` faces for surface. You can also use `front` or `back`
# as well. Here, `all` molecules reflect at both surface faces.
sph1 = smoldyn.Sphere(center=(0, 0), radius=1, slices=50)
membrane = s.addSurface("membrane", panels=[sph1])
membrane.setAction('both', [S, E, P, ES], "reflect")
membrane.setStyle('both', color="black", thickness=1)

# Define a compartment, which is region inside the 'membrane' surface.
inside = s.addCompartment(name="inside", surface=membrane, point=[0, 0])

# Chemical reactions. Here, E + S <-> ES -> P
r1 = s.addBidirectionalReaction("r1",
                                subs=[(E, "front"), (S, "bsoln")],
                                prds=[(ES, "front")],
                                kf=K_FWD,
                                kb=K_BACK)
r1.reverse.productPlacement("pgemmax", 0.2)