Ejemplo n.º 1
0
    def test_one_particle(self):
        gfrdbase.place_particle(self.w, self.S, [0.0, 0.0, 0.0])

        t = self.s.t
        for i in range(5):
            self.s.step()
        self.failIf(t == self.s.t)
Ejemplo n.º 2
0
    def test_one_particle(self):
        gfrdbase.place_particle(self.w, self.S, [0.0,0.0,0.0])

        t = self.s.t
        for i in range(5):
            self.s.step()
        self.failIf(t == self.s.t)
Ejemplo n.º 3
0
def singlerun(T):

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    kf = 100 * sigma * D_tot

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma / 2)
    m.add_species_type(A)
    B = model.Species('B', D, sigma / 2)
    m.add_species_type(B)
    C = model.Species('C', D, sigma / 2)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    w = gfrdbase.create_world(m, 3)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng)

    class check_reactions:
        def __init__(self):
            self.reactions = []

        def __call__(self, ri):
            self.reactions.append(ri)

    cr = check_reactions()
    s.reaction_recorder = cr

    pid1 = gfrdbase.place_particle(w, A, [0, 0, 0])[0]
    pid2 = gfrdbase.place_particle(
        w, B, [float(A['radius']) + float(B['radius']) + 1e-23, 0, 0])[0]

    end_time = T

    while s.step(end_time):
        if len(cr.reactions) != 0:
            cr.reactions = []
            return 0, s.t

    p1 = s.world.get_particle(pid1)[1]
    p2 = s.world.get_particle(pid2)[1]

    distance = w.distance(p1.position, p2.position)

    return distance, s.t
Ejemplo n.º 4
0
def singlerun(T):

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    kf = 100 * sigma * D_tot

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma/2)
    m.add_species_type(A)
    B = model.Species('B', D, sigma/2)
    m.add_species_type(B)
    C = model.Species('C', D, sigma/2)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    w = gfrdbase.create_world(m, 3)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng)

    class check_reactions:
        def __init__(self):
            self.reactions = []

        def __call__(self, ri):
            self.reactions.append(ri)

    cr = check_reactions()
    s.reaction_recorder = cr

    pid1 = gfrdbase.place_particle(w, A, [0,0,0])[0]
    pid2 = gfrdbase.place_particle(w, B, [float(A['radius']) + 
                                          float(B['radius'])+1e-23,0,0])[0]

    end_time = T

    while s.step(end_time):
        if len(cr.reactions) != 0:
            cr.reactions = []
            return 0, s.t

    p1 = s.world.get_particle(pid1)[1]
    p2 = s.world.get_particle(pid2)[1]

    distance = w.distance(p1.position, p2.position)

    return distance, s.t
Ejemplo n.º 5
0
    def test_immobile_is_immobile(self):
        particleA = gfrdbase.place_particle(self.w, self.A, [0.0,0.0,0.0])
        gfrdbase.place_particle(self.w, self.B, [1.5000001e-8,0.0,0.0])

        initial_position = particleA[1].position

        for i in range(10):
            self.s.step()
            #print particleA[1].position
        
        new_position = particleA[1].position
        dist = self.w.distance(initial_position, new_position)

        self.failIf(dist != 0, 'initial pos: %s,\tnew pos: %s' %
                    (initial_position, new_position))
Ejemplo n.º 6
0
def singlerun2(T):

    #s.set_user_max_shell_size(1e-7)
    #s.set_user_max_shell_size(1e-3)

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    kf = 100 * sigma * D_tot

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma / 2)
    m.add_species_type(A)
    B = model.Species('B', D, sigma / 2)
    m.add_species_type(B)
    C = model.Species('C', D, sigma / 2)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    w = gfrdbase.create_world(m, 3)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    s = EGFRDSimulator(w, myrandom.rng, nrw)

    particleA = gfrdbase.place_particle(w, A, [0, 0, 0])
    particleB = gfrdbase.place_particle(
        w, B, [float(A['radius']) + float(B['radius']) + 1e-23, 0, 0])

    end_time = T

    while 1:
        s.step()
        if s.last_reaction:
            #print 'reaction'
            return 0.0, s.t

        next_time = s.get_next_time()
        if next_time > end_time:
            s.stop(end_time)
            break

    distance = w.distance(s.get_position(particleA), s.get_position(particleB))

    return distance, s.t
Ejemplo n.º 7
0
    def test_immobile_is_immobile(self):
        particleA = gfrdbase.place_particle(self.w, self.A, [0.0, 0.0, 0.0])
        gfrdbase.place_particle(self.w, self.B, [1.5000001e-8, 0.0, 0.0])

        initial_position = particleA[1].position

        for i in range(10):
            self.s.step()
            #print particleA[1].position

        new_position = particleA[1].position
        dist = self.w.distance(initial_position, new_position)

        self.failIf(
            dist != 0,
            'initial pos: %s,\tnew pos: %s' % (initial_position, new_position))
Ejemplo n.º 8
0
def singlerun(T, S):

    m = model.ParticleModel(1e-3)

    A = model.Species('A', 1e-12, 5e-9)
    m.add_species_type(A)

    w = gfrdbase.create_world(m, 3)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    # s = EGFRDSimulator(w, myrandom.rng, nrw)
    # s.set_user_max_shell_size(S)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng, 1, 1e-5, S)

    particleA = gfrdbase.place_particle(w, A, [0, 0, 0])

    end_time = T
    s.step()

    while 1:
        next_time = s.t + s.dt
        if next_time > end_time:
            # s.stop(end_time)
            s.step(end_time)
            break
        s.step()

    pos = w.get_particle(iter(w.get_particle_ids(A.id)).next())[1].position
    distance = w.distance([0, 0, 0], pos)
    return distance, s.t
Ejemplo n.º 9
0
def singlerun(T, S):

    m = model.ParticleModel(1e-3)

    A = model.Species('A', 1e-12, 5e-9)
    m.add_species_type(A)

    w = gfrdbase.create_world(m, 3)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    # s = EGFRDSimulator(w, myrandom.rng, nrw)
    # s.set_user_max_shell_size(S)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng, 1, 1e-5, S)
    
    particleA = gfrdbase.place_particle(w, A, [0, 0, 0])

    end_time = T
    s.step()

    while 1:
        next_time = s.t + s.dt
        if next_time > end_time:
            # s.stop(end_time)
            s.step(end_time)
            break
        s.step()

    pos = w.get_particle(iter(w.get_particle_ids(A.id)).next())[1].position
    distance = w.distance([0,0,0], pos)
    return distance, s.t
Ejemplo n.º 10
0
Archivo: run.py Proyecto: Jintram/egfrd
def singlerun2(T):

    #s.set_user_max_shell_size(1e-7)
    #s.set_user_max_shell_size(1e-3)

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    kf = 100 * sigma * D_tot

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma/2)
    m.add_species_type(A)
    B = model.Species('B', D, sigma/2)
    m.add_species_type(B)
    C = model.Species('C', D, sigma/2)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    w = gfrdbase.create_world(m, 3)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    s = EGFRDSimulator(w, myrandom.rng, nrw)

    particleA = gfrdbase.place_particle(w, A, [0,0,0])
    particleB = gfrdbase.place_particle(w, B, [float(A['radius']) + float(B['radius'])+1e-23,0,0])

    end_time = T

    while 1:
        s.step()
        if s.last_reaction:
            #print 'reaction'
            return 0.0, s.t

        next_time = s.get_next_time()
        if next_time > end_time:
            s.stop(end_time)
            break

    distance = w.distance(s.get_position(particleA), s.get_position(particleB))

    return distance, s.t
Ejemplo n.º 11
0
    def test_three_particles(self):
        gfrdbase.place_particle(self.w, self.S, [0.0, 0.0, 0.0])
        gfrdbase.place_particle(self.w, self.S, [5e-6, 5e-6, 5e-6])
        gfrdbase.place_particle(self.w, self.S, [1e-7, 1e-7, 1e-7])

        t = self.s.t
        for i in range(5):
            self.s.step()
        self.failIf(t == self.s.t)
Ejemplo n.º 12
0
    def test_three_particles(self):
        gfrdbase.place_particle(self.w, self.S, [0.0,0.0,0.0])
        gfrdbase.place_particle(self.w, self.S, [5e-6,5e-6,5e-6])
        gfrdbase.place_particle(self.w, self.S, [1e-7,1e-7,1e-7])

        t = self.s.t
        for i in range(5):
            self.s.step()
        self.failIf(t == self.s.t)