예제 #1
0
파일: dimer.py 프로젝트: TheOtherOne/egfrd
m.set_all_repulsive()

s.set_model(m)

s.throw_in_particles(S, N / 2, box1)
s.throw_in_particles(P, N / 2, box1)

#l = Logger('dimer')
l = None
interrupter = None

if l is not None:
    interrupter = FixedIntervalInterrupter(s, 1e-7, l.log)

import myrandom
myrandom.seed(0)


def profrun():
    if l is not None:
        l.start(s)
    for _ in xrange(15000):
        if interrupter is not None:
            interrupter.step()
        else:
            s.step()


PROFMODE = True

if PROFMODE:
예제 #2
0
# gfrd
from model2 import *
from egfrd import *
from logger import *
import myrandom

# for calculating and sampling
import numpy as np
import matplotlib.pyplot as plt
try:
    import mpmath as m
except ImportError:
    import sympy.mpmath as m


myrandom.seed(0)
# settings and parameters for the sampling run
#
# files
# --------------ADAPT THIS!-----------
DATADIR = '/home/miedema/code/simulations/nils/runs/fp_sampling'
DATAFN = 'sample'
#
# outer loop count. each time there are 9 particles running in parallel.
# therefore, the total number of counts in the histogram is about 9*NUMEROFRUNS
NUMBEROFRUNS = int(1e2)
#
# upper cutoff time for sampling: if a particle stays alive longer than this time, 
# it is discarded
CUTOFFTIME = .2
# the geometry and kinetic constants, collected here for easy reference
예제 #3
0
def run_single(T, V, N):

    print 'T =', T, '; V= ', V, '; N=', N

    # disable gc
    import gc
    gc.disable()

    L = math.pow(V * 1e-3, 1.0 / 3.0)

    matrix_size = max(3, int((3 * N)**(1.0 / 3.0)))

    print 'matrix_size=', matrix_size

    D = 1e-12

    m = model.ParticleModel(L)
    A = model.Species('A', D, 2.5e-9)
    m.add_species_type(A)
    m.set_all_repulsive()

    w = gfrdbase.create_world(m, matrix_size)
    nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
    #s = EGFRDSimulator(w, myrandom.rng, nrw)
    myrandom.seed(3964642685656813207)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng)
    #s.paranoiac = True

    gfrdbase.throw_in_particles(w, A, N)
    print 'stir'

    stir_time = T * .1
    while 1:
        s.step()
        next_time = s.t + s.dt
        if next_time > stir_time:
            s.step(stir_time)
            break

    stir_steps = s.num_steps

    #print 'reset'
    #s.reset()

    print 'run'
    run_time = T + stir_time

    start = time.time()
    while s.t < run_time:
        s.step()
    end = time.time()
    timing = end - start

    steps = s.num_steps - stir_steps
    stepspersec = float(steps) / timing
    print 'steps (total)= ', steps
    print 'steps/sec= ', stepspersec, ', steps/N= ', float(steps) / N
    print 'TIMING:\n', timing, '\n'

    gc.collect()
    gc.enable()

    return end - start, steps, stepspersec
예제 #4
0
def run_single(T, V, N):

    print 'T =', T, '; V= ', V, '; N=', N
    
    # disable gc
    import gc
    gc.disable()

    L = math.pow(V * 1e-3, 1.0 / 3.0)

    matrix_size = max(3, int((3 * N) ** (1.0/3.0)))

    print 'matrix_size=', matrix_size
    
    D = 1e-12

    m = model.ParticleModel(L)
    A = model.Species('A', D, 2.5e-9)
    m.add_species_type(A)
    m.set_all_repulsive()

    w = gfrdbase.create_world(m, matrix_size)
    nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
    #s = EGFRDSimulator(w, myrandom.rng, nrw)
    myrandom.seed(3964642685656813207)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng)
    #s.paranoiac = True

    gfrdbase.throw_in_particles(w, A, N)
    print 'stir'

    stir_time = T * .1
    while 1:
        s.step()
        next_time = s.t + s.dt
        if next_time > stir_time:
            s.step(stir_time)
            break

    stir_steps = s.num_steps

    #print 'reset'
    #s.reset()

    print 'run'
    run_time = T + stir_time

    start = time.time()
    while s.t < run_time:
        s.step()
    end = time.time()
    timing = end - start

    steps = s.num_steps - stir_steps
    stepspersec = float(steps) / timing
    print 'steps (total)= ', steps
    print 'steps/sec= ', stepspersec, ', steps/N= ', float(steps) / N
    print 'TIMING:\n', timing, '\n'

    gc.collect()
    gc.enable()

    return end - start, steps, stepspersec
예제 #5
0
'''Settings

'''
# Make multis run 'BD_DT_FACTOR' times faster than normal.
BD_DT_FACTOR       = 1
RADIUS_FACTOR      = 1
SINGLE_RATE_FACTOR = 1
PAIR_RATE_FACTOR   = 1
N_PARTICLES_FACTOR = 1
WORLD_SIZE_FACTOR  = 1

N_STEPS = 15000

MY_SEED = 0
myrandom.seed(MY_SEED)

L = WORLD_SIZE_FACTOR * 1e-6    # Size of simulation box.
D = 1e-12                       # Diffusion constant.
radius = RADIUS_FACTOR * 2.5e-9 # Radius of particles.


'''Reaction rates

'''
sigma = 2 * radius
D_tot = D
tau = sigma * sigma / D_tot
# Bimolecular reaction type.
kf_2 = PAIR_RATE_FACTOR * 100 * sigma * D_tot
# Unimolecular reaction type.