示例#1
0
def makeModel():
    # create container for model
    model = moose.Neutral('model')
    harmonic = moose.CubeMesh('/model/harmonic')
    harmonic.volume = 1e-15
    lotka = moose.CubeMesh('/model/lotka')
    lotka.volume = 1e-15

    # create molecules and reactions
    x = moose.Pool('/model/lotka/x')
    y = moose.Pool('/model/lotka/y')
    z = moose.BufPool('/model/lotka/z')  # Dummy molecule.
    xreac = moose.Reac('/model/lotka/xreac')
    yreac = moose.Reac('/model/lotka/yreac')
    xrate = moose.Function('/model/lotka/xreac/func')
    yrate = moose.Function('/model/lotka/yreac/func')

    # Parameters
    alpha = 1.0
    beta = 1.0
    gamma = 1.0
    delta = 1.0
    k = 1.0
    x.nInit = 2.0
    y.nInit = 1.0
    z.nInit = 0.0
    xrate.x.num = 1
    yrate.x.num = 1
    xrate.expr = "x0 * " + str(beta) + " - " + str(alpha)
    yrate.expr = str(gamma) + " - x0 * " + str(delta)
    xreac.Kf = k
    yreac.Kf = k
    xreac.Kb = 0
    yreac.Kb = 0

    # connect them up for reactions
    moose.connect(y, 'nOut', xrate.x[0], 'input')
    moose.connect(x, 'nOut', yrate.x[0], 'input')
    moose.connect(xrate, 'valueOut', xreac, 'setNumKf')
    moose.connect(yrate, 'valueOut', yreac, 'setNumKf')
    moose.connect(xreac, 'sub', x, 'reac')
    moose.connect(xreac, 'prd', z, 'reac')
    moose.connect(yreac, 'sub', y, 'reac')
    moose.connect(yreac, 'prd', z, 'reac')

    # Create the output tables
    graphs = moose.Neutral('/model/graphs')
    xplot = moose.Table2('/model/graphs/x')
    yplot = moose.Table2('/model/graphs/y')

    # connect up the tables
    moose.connect(xplot, 'requestOut', x, 'getN')
    moose.connect(yplot, 'requestOut', y, 'getN')
def makeModel():
    # create container for model
    model = moose.Neutral('model')
    compartment = moose.CubeMesh('/model/compartment')
    compartment.volume = 1e-15
    # the mesh is created automatically by the compartment
    mesh = moose.element('/model/compartment/mesh')

    # create molecules and reactions
    # a <----> b
    # b + 10c ---func---> d
    a = moose.Pool('/model/compartment/a')
    b = moose.Pool('/model/compartment/b')
    c = moose.Pool('/model/compartment/c')
    d = moose.BufPool('/model/compartment/d')
    reac = moose.Reac('/model/compartment/reac')
    func = moose.Function('/model/compartment/d/func')
    func.numVars = 2
    #func.x.num = 2

    # connect them up for reactions

    moose.connect(reac, 'sub', a, 'reac')
    moose.connect(reac, 'prd', b, 'reac')
    if useY:
        moose.connect(func, 'requestOut', b, 'getN')
        moose.connect(func, 'requestOut', c, 'getN')
    else:
        moose.connect(b, 'nOut', func.x[0], 'input')
        moose.connect(c, 'nOut', func.x[1], 'input')

    moose.connect(func, 'valueOut', d, 'setN')
    if useY:
        func.expr = "y0 + 10*y1"
    else:
        func.expr = "x0 + 10*x1"

    # connect them up to the compartment for volumes
    #for x in ( a, b, c, cplx1, cplx2 ):
    #                        moose.connect( x, 'mesh', mesh, 'mesh' )

    # Assign parameters
    a.concInit = 1
    b.concInit = 0.5
    c.concInit = 0.1
    reac.Kf = 0.001
    reac.Kb = 0.01

    # Create the output tables
    graphs = moose.Neutral('/model/graphs')
    outputA = moose.Table2('/model/graphs/concA')
    outputB = moose.Table2('/model/graphs/concB')
    outputC = moose.Table2('/model/graphs/concC')
    outputD = moose.Table2('/model/graphs/concD')

    # connect up the tables
    moose.connect(outputA, 'requestOut', a, 'getConc')
    moose.connect(outputB, 'requestOut', b, 'getConc')
    moose.connect(outputC, 'requestOut', c, 'getConc')
    moose.connect(outputD, 'requestOut', d, 'getConc')
示例#3
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    #Adot.expr="0.001*((x0^2/x1)+1)-1*x0+0.5*x0"
    #Bdot.expr="0*x0+0.001*x0^2-1*x1+1*x1"
    Adot.expr = "0.1*((x0^2/x1)+1)-1.5*x0+0.5*x0"
    Bdot.expr = "0*x0+0.1*x0^2-1.5*x1+1*x1"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 2  #2
    Bdot.x.num = 2  #2
    #A.nInit=10
    #B.nInit=5
    A.nInit = 1
    B.nInit = 1
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')
    return compt
示例#4
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    epsilon = params['epsilon']
    theta = params['theta']
    eta = params['eta']
    alpha = params['alpha']
    gamma = params['gamma']

    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')

    Adot.expr = str(gamma) + "*(x0^2/(1+x0^2))-" + str(eta) + "*x0+x1-" + str(
        epsilon) + "*" + str(theta) + "*x0"
    Bdot.expr = "-(" + str(gamma) + "*(x0^2/(1+x0^2))-" + str(
        eta) + "*x0+x1)-" + str(epsilon) + "*" + str(alpha)

    print Adot.expr
    print Bdot.expr
    Adot.x.num = 2  #2
    Bdot.x.num = 2  #2
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')
示例#5
0
def makeChemProto(name):
    chem = moose.Neutral('/library/' + name)
    comptVol = diffLen * dendDia * dendDia * PI / 4.0
    for i in (['dend', comptVol], ['spine', 1e-19], ['psd', 1e-20]):
        print(('making ', i))
        compt = moose.CubeMesh(chem.path + '/' + i[0])
        compt.volume = i[1]
        z = moose.Pool(compt.path + '/z')
        z.concInit = 0.0
        z.diffConst = diffConst
    nInit = comptVol * 6e23 * concInit
    nstr = str(1 / nInit)

    x = moose.Pool(chem.path + '/dend/x')
    x.diffConst = diffConst
    func = moose.Function(x.path + '/func')
    func.expr = "-x0 * (0.3 - " + nstr + " * x0) * ( 1 - " + nstr + " * x0)"
    print((func.expr))
    func.x.num = 1
    moose.connect(x, 'nOut', func.x[0], 'input')
    moose.connect(func, 'valueOut', x, 'increment')
    z = moose.element('/library/' + name + '/dend/z')
    reac = moose.Reac('/library/' + name + '/dend/reac')
    reac.Kf = 1
    reac.Kb = 10
    moose.connect(reac, 'sub', x, 'reac')
    moose.connect(reac, 'prd', z, 'reac')
示例#6
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Adot.expr = "k*(b*(0.05*+(a^n/(K^n+a^n)))-a)"
    Bdot.expr = "-k*(b*(0.05*+(a^n/(K^n+a^n)))-a)"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 3  #2
    Bdot.x.num = 3  #2
    A.nInit = 1
    B.nInit = 1
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    return compt
示例#7
0
def makeChemProto( name, stimAmpl = 1, diffLength = 1e-6, preStim = 10.0 ):
    # Parameters

    sw = params['stimWidth']
    dca = params['diffConstA'] * diffLength * diffLength
    dcb = params['diffConstB'] * diffLength * diffLength

    # Objects
    chem = moose.Neutral( '/library/' + name )
    compt = moose.CubeMesh( chem.path + '/dend' )
    A = moose.Pool( compt.path + '/A' )
    B = moose.Pool( compt.path + '/B' )
    Z = moose.BufPool( compt.path + '/Z' )
    Ca = moose.BufPool( compt.path + '/Ca' )
    phase = moose.BufPool( compt.path + '/phase' )
    vel = moose.BufPool( compt.path + '/vel' )
    ampl = moose.BufPool( compt.path + '/ampl' )
    Adot = moose.Function( A.path + '/Adot' )
    Bdot = moose.Function( B.path + '/Bdot' )
    CaStim = moose.Function( Ca.path + '/CaStim' )
    A.diffConst = dca
    B.diffConst = dcb

    # Equations

    xv0 = '(x0-' + str( params['offsetV'] ) + ')'
    xv1 = '(x1-' + str( params['offsetV'] ) + ')'
    xw1 = '(x1-' + str( params['offsetW'] ) + ')'
    xw2 = '(x2-' + str( params['offsetW'] ) + ')'
    Adot.expr = '5*x3*( 0.0 +' + xv1 + ' - (' + xv1 + '^3)/3 -' + xw2 + ' + x0 )' # x0=Ca, x1=A, x2=B
    #Adot.expr = 'x3*( 0.5 + x1 - x1*x1*x1/3 - x2 + x0 )' # x0=Ca, x1=A, x2=B
    #Bdot.expr = 'x2*' + str(1.0/params['tau']) + '*(x0 + ' + sp('a', ' - ') + sp( 'b', ' * x1 ' ) + ')'
    Bdot.expr = 'x2*' + str(1.0/params['tau']) + '*(' + xv0 + '+' + sp('a', ' - ') + sp( 'b', ' * ' + xw1 ) + ')'
    CaStim.expr = 'x2 * exp( -((x0 - t)^2)/(2* ' + str(sw*sw) + ') )'

    print Adot.expr
    print Bdot.expr
    print CaStim.expr

    # Connections
    Adot.x.num = 4
    moose.connect( Ca, 'nOut', Adot.x[0], 'input' )
    moose.connect( A, 'nOut', Adot.x[1], 'input' )
    moose.connect( B, 'nOut', Adot.x[2], 'input' )
    moose.connect( Z, 'nOut', Adot.x[3], 'input' )
    moose.connect( Adot, 'valueOut', A, 'increment' )

    Bdot.x.num = 3
    moose.connect( A, 'nOut', Bdot.x[0], 'input' )
    moose.connect( B, 'nOut', Bdot.x[1], 'input' )
    moose.connect( Z, 'nOut', Bdot.x[2], 'input' )
    moose.connect( Bdot, 'valueOut', B, 'increment' )

    CaStim.x.num = 3
    moose.connect( phase, 'nOut', CaStim.x[0], 'input' )
    moose.connect( vel, 'nOut', CaStim.x[1], 'input' )
    moose.connect( ampl, 'nOut', CaStim.x[2], 'input' )
    moose.connect( CaStim, 'valueOut', Ca, 'setN' )

    return compt
def makeChemProto(name='hydra'):
        chem=moose.Neutral('/library/'+name)
        compt=moose.CubeMesh('/library/'+name + '/' + name)
        A=moose.Pool(compt.path+'/A')
        B=moose.Pool(compt.path+'/B')
        
        #A.diffConst=params['diffA']
        #B.diffConst=params['diffB']
        Adot = moose.Function( A.path + '/Adot' )
        Bdot = moose.Function( B.path + '/Bdot' )
       
        Adot.expr="-x0+(x0^2/(1+0.01*x0^2))*x1"
        Bdot.expr="x0-(x0^2/(1+0.01*x0^2))*x1"

 
        
        print moose.showmsg(Adot)
        Adot.x.num = 2 #2
        Bdot.x.num = 2 #2
        moose.connect( A, 'nOut', Adot.x[0], 'input' )
        moose.connect( B, 'nOut', Adot.x[1], 'input' )
        moose.connect( Adot, 'valueOut', A, 'increment' )

        moose.connect( A, 'nOut', Bdot.x[0], 'input' )
        moose.connect( B, 'nOut', Bdot.x[1], 'input' )
        moose.connect( Bdot, 'valueOut', B, 'increment' )
示例#9
0
def makeChemProto(name='hydra'):
    chemCompt = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    #Adot.expr="1*(-x0+x1*(0.05*+(x0^2/(1^2+x0^2))))"
    #Bdot.expr="-1*(-x0+x1*(0.05*+(x0^2/(1^2+x0^2))))"
    Adot.expr = "0*x0+0*x1"
    Bdot.expr = "0*x0+0*x1"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 2
    Bdot.x.num = 2
    A.nInit = 1
    B.nInit = 1
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')
    return compt
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    C = moose.Pool(compt.path + '/C')
    space = moose.Pool(compt.path + '/space')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Cdot = moose.Function(C.path + '/Cdot')
    #Adot.expr="0.001*((x0^2/x1)+1)-1*x0+0.5*x0"
    #Bdot.expr="0*x0+0.001*x0^2-1*x1+1*x1"
    Adot.expr = "0.5*exp(-1.5*x2/(50*1e-06))*x0^2*x1-(0.1+0.01)*x0+0.01*x1"
    Bdot.expr = "-0.5*exp(-1.5*x2/(50*1e-06))*x0^2*x1+0.1*x0-0.01*x1+0.01"

    print moose.showmsg(Adot)
    Adot.x.num = 3  #2
    Bdot.x.num = 3  #2
    #A.nInit=10
    #B.nInit=5
    A.nInit = 0
    B.nInit = 0
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(space, 'nOut', Adot.x[2], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(space, 'nOut', Bdot.x[2], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    return compt
示例#11
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Adot.expr = "11.8*x1-x0+0"
    Bdot.expr = "x0-(0.1*x1^3-6.3*x1^2+100*x1)"
    #Adot.expr="x0+0.0001*x1^3"
    #Bdot.expr="x0-0.001*x1^3"
    #Adot.expr="0.0000118*x1-0.000001x0"
    #Bdot.expr="x0-0.0000001*x1^3-0.0000063*x1^2+0.001*x1"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 2  #2
    Bdot.x.num = 2  #2
    A.nInit = 0.01
    B.nInit = 10
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')
    return compt
def makeModel():
    if len(sys.argv) == 1:
        useGsolve = True
    else:
        useGsolve = (sys.argv[1] == 'True')
    # create container for model
    model = moose.Neutral('model')
    compartment = moose.CubeMesh('/model/compartment')
    compartment.volume = 1e-22
    # the mesh is created automatically by the compartment
    moose.le('/model/compartment')
    mesh = moose.element('/model/compartment/mesh')

    # create molecules and reactions
    a = moose.Pool('/model/compartment/a')
    b = moose.Pool('/model/compartment/b')

    # create functions of time
    f1 = moose.Function('/model/compartment/f1')
    f2 = moose.Function('/model/compartment/f2')

    # connect them up for reactions
    moose.connect(f1, 'valueOut', a, 'setConc')
    moose.connect(f2, 'valueOut', b, 'increment')

    # Assign parameters
    a.concInit = 0
    b.concInit = 1
    #f1.numVars = 1
    #f2.numVars = 1
    f1.expr = '1 + sin(t)'
    f2.expr = '10 * cos(t)'

    # Create the output tables
    graphs = moose.Neutral('/model/graphs')
    outputA = moose.Table2('/model/graphs/nA')
    outputB = moose.Table2('/model/graphs/nB')

    # connect up the tables
    moose.connect(outputA, 'requestOut', a, 'getN')
    moose.connect(outputB, 'requestOut', b, 'getN')

    # Set up the solvers
    if useGsolve:
        gsolve = moose.Gsolve('/model/compartment/gsolve')
        gsolve.useClockedUpdate = True
    else:
        gsolve = moose.Ksolve('/model/compartment/gsolve')
    stoich = moose.Stoich('/model/compartment/stoich')
    stoich.compartment = compartment
    stoich.ksolve = gsolve
    stoich.path = '/model/compartment/##'
    '''
    '''

    # We need a finer timestep than the default 0.1 seconds,
    # in order to get numerical accuracy.
    for i in range(10, 19):
        moose.setClock(i, 0.1)  # for computational objects
示例#13
0
def test_streamer():
    compt = moose.CubeMesh('/compt')
    assert compt
    r = moose.Reac('/compt/r')
    a = moose.Pool('/compt/a')
    a.concInit = 1
    b = moose.Pool('/compt/b')
    b.concInit = 2
    c = moose.Pool('/compt/c')
    c.concInit = 0.5
    moose.connect(r, 'sub', a, 'reac')
    moose.connect(r, 'prd', b, 'reac')
    moose.connect(r, 'prd', c, 'reac')
    r.Kf = 0.1
    r.Kb = 0.01

    outfile = 'streamer_test.csv'
    if os.path.exists(outfile):
        os.remove(outfile)

    tabA = moose.Table2('/compt/a/tab')
    tabB = moose.Table2('/compt/tabB')
    tabC = moose.Table2('/compt/tabB/tabC')
    print(tabA, tabB, tabC)

    moose.connect(tabA, 'requestOut', a, 'getConc')
    moose.connect(tabB, 'requestOut', b, 'getConc')
    moose.connect(tabC, 'requestOut', c, 'getConc')

    # Now create a streamer and use it to write to a stream
    st = moose.Streamer('/compt/streamer')
    st.outfile = outfile

    print("outfile set to: %s " % st.outfile)
    st.addTable(tabA)
    st.addTables([tabB, tabC])
    assert st.numTables == 3

    moose.reinit()
    t = 100
    print('[INFO] Running for %d seconds' % t)
    moose.start(t)
    outfile = st.outfile
    moose.quit()  # Otherwise Streamer won't flush the rest of entries.

    print('Moose is done. Waiting for monitor to shut down...')

    # Now read the table and verify that we have written
    print('[INFO] Reading file %s' % outfile)
    if 'csv' in outfile:
        data = np.loadtxt(outfile, skiprows=1)
    else:
        data = np.load(outfile)
    # Total rows should be 58 (counting zero as well).
    #  print(data)
    # print( data.dtype )
    assert data.shape >= (101, ), data.shape
    print('[INFO] Test 2 passed')
    return 0
def makeModel():
    """ This function creates a bistable reaction system using explicit
    MOOSE calls rather than load from a file.
    The reaction is::

        a ---b---> 2b    # b catalyzes a to form more of b.
        2b ---c---> a    # c catalyzes b to form a.
        a <======> 2b    # a interconverts to b.

    """
    # create container for model
    model = moose.Neutral('model')
    compartment = moose.CubeMesh('/model/compartment')
    compartment.volume = 1e-15
    # the mesh is created automatically by the compartment
    mesh = moose.element('/model/compartment/mesh')

    # create molecules and reactions
    size = 100
    for i in range(size):
        a = moose.Pool('/model/compartment/a%s' % i)
        b = moose.Pool('/model/compartment/b%s' % i)
        c = moose.Pool('/model/compartment/c%s' % i)
        enz1 = moose.Enz('%s/enz1' % a.path)
        enz2 = moose.Enz('%s/enz2' % c.path)
        cplx1 = moose.Pool('%s/cplx' % enz1.path)
        cplx2 = moose.Pool('%s/cplx' % enz2.path)
        reac = moose.Reac('/model/compartment/reac%s' % i)

        # connect them up for reactions
        moose.connect(enz1, 'sub', a, 'reac')
        moose.connect(enz1, 'prd', b, 'reac')
        moose.connect(enz1, 'prd', b, 'reac')  # Note 2 molecules of b.
        moose.connect(enz1, 'enz', b, 'reac')
        moose.connect(enz1, 'cplx', cplx1, 'reac')

        moose.connect(enz2, 'sub', b, 'reac')
        moose.connect(enz2, 'sub', b, 'reac')  # Note 2 molecules of b.
        moose.connect(enz2, 'prd', a, 'reac')
        moose.connect(enz2, 'enz', c, 'reac')
        moose.connect(enz2, 'cplx', cplx2, 'reac')

        moose.connect(reac, 'sub', a, 'reac')
        moose.connect(reac, 'prd', b, 'reac')
        moose.connect(reac, 'prd', b, 'reac')  # Note 2 order in b.
        add_table(a)
        add_table(b)
        add_table(c)
        # Assign parameters
        a.concInit = 1
        b.concInit = 0
        c.concInit = 0.01
        enz1.kcat = 0.4
        enz1.Km = 4
        enz2.kcat = 0.6
        enz2.Km = 0.01
        reac.Kf = 0.001
        reac.Kb = 0.01
    return compartment
示例#15
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    C = moose.Pool(compt.path + '/C')
    fvec = moose.vec(compt.path + '/C').n
    numf = np.sum(fvec)
    r = params['r']
    b = params['b']
    c1 = params['c1']
    c2 = params['c2']
    c3 = params['c3']
    K1 = params['K1']
    K2 = params['K2']
    K3 = params['K3']
    df = params['df']
    lambdap = params['lambda']
    mt0 = params['mt0']
    Kf = params['Kf']

    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Cdot = moose.Function(C.path + '/Cdot')

    Adot.expr = str(-r) + "*x0+(" + str(b) + "+(" + str(
        c1) + "*x0^2/(x0^2+" + str(K1 ^ 2) + "))+(" + str(
            c2) + "*x2^2/(x2^2+" + str(K2 ^ 2) + ")))*x1"
    Bdot.expr = str(r) + "*x0-(" + str(b) + "+(" + str(
        c1) + "*x0^2/(x0^2+" + str(K1 ^ 2) + "))+(" + str(
            c2) + "*x2^2/(x2^2+" + str(K2 ^ 2) + ")))*x1"
    Cdot.expr = str(-df) + "*x2+((" + str(c3) + "*x0^2/(x0^2+" + str(
        K3 ^ 2) + "))*(" + str(Kf) + "/(" + str(Kf) + "+(" + str(
            mt0) + "*(1+" + str(lambdap) + "*" + str(numf * 1e-07) + ")))))"

    print Adot.expr
    print Bdot.expr
    print Cdot.expr
    print 'totalF-actin', numf
    Adot.x.num = 3  #2
    Bdot.x.num = 3  #2
    Cdot.x.num = 3
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(C, 'nOut', Adot.x[2], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(C, 'nOut', Bdot.x[2], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    moose.connect(A, 'nOut', Cdot.x[0], 'input')
    moose.connect(B, 'nOut', Cdot.x[1], 'input')
    moose.connect(C, 'nOut', Cdot.x[2], 'input')
    moose.connect(Cdot, 'valueOut', C, 'increment')
示例#16
0
def makeChemProto(name, stimAmpl=1, diffLength=1e-6, preStim=10.0):
    # Parameters

    sw = params['stimWidth']
    dca = params['diffConstA'] * diffLength * diffLength
    dcb = params['diffConstB'] * diffLength * diffLength

    # Objects
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh(chem.path + '/dend')
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    Z = moose.BufPool(compt.path + '/Z')
    Ca = moose.BufPool(compt.path + '/Ca')
    phase = moose.BufPool(compt.path + '/phase')
    vel = moose.BufPool(compt.path + '/vel')
    ampl = moose.BufPool(compt.path + '/ampl')
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    CaStim = moose.Function(Ca.path + '/CaStim')
    A.diffConst = dca
    B.diffConst = dcb

    # Equations

    Adot.expr = 'x3*(' + sp('k0a', '+ ') + sp('k1a', '*x1 + ') + sp(
        'k2a', '*x1*x1 + ') + sp('k3a', '*x1*x1*x1 + ') + sp(
            'k4a', '*x0*x1/(1+x1+10*x2) + ') + sp('k5a', '*x1*x2') + ')'

    Bdot.expr = 'x2*(' + sp('k1b', '*x0*x0 + ') + sp('k2b', '*x1') + ')'
    CaStim.expr = 'x2 * exp( -((x0 - t)^2)/(2* ' + str(sw * sw) + ') )'

    print Adot.expr
    print Bdot.expr
    print CaStim.expr

    # Connections
    Adot.x.num = 4
    moose.connect(Ca, 'nOut', Adot.x[0], 'input')
    moose.connect(A, 'nOut', Adot.x[1], 'input')
    moose.connect(B, 'nOut', Adot.x[2], 'input')
    moose.connect(Z, 'nOut', Adot.x[3], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    Bdot.x.num = 3
    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Z, 'nOut', Bdot.x[2], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    CaStim.x.num = 3
    moose.connect(phase, 'nOut', CaStim.x[0], 'input')
    moose.connect(vel, 'nOut', CaStim.x[1], 'input')
    moose.connect(ampl, 'nOut', CaStim.x[2], 'input')
    moose.connect(CaStim, 'valueOut', Ca, 'setN')

    return compt
示例#17
0
def makeChemProto(name):
    chem = moose.Neutral('/library/' + name)
    for i in (['dend', 1e-18], ['spine', 1e-19], ['psd', 1e-20]):
        print('making ', i)
        compt = moose.CubeMesh(chem.path + '/' + i[0])
        compt.volume = i[1]
        Ca = moose.Pool(compt.path + '/Ca')
        Ca.concInit = 0.08
        Ca.diffConst = 1e-11
示例#18
0
def makeModel():
                # create container for model
                model = moose.Neutral( 'model' )
                compartment = moose.CubeMesh( '/model/compartment' )
                compartment.volume = 1e-20
                # the mesh is created automatically by the compartment
                mesh = moose.element( '/model/compartment/mesh' )

                # create molecules and reactions
                a = moose.Pool( '/model/compartment/a' )
                b = moose.Pool( '/model/compartment/b' )
                c = moose.Pool( '/model/compartment/c' )
                enz1 = moose.Enz( '/model/compartment/b/enz1' )
                enz2 = moose.Enz( '/model/compartment/c/enz2' )
                cplx1 = moose.Pool( '/model/compartment/b/enz1/cplx' )
                cplx2 = moose.Pool( '/model/compartment/c/enz2/cplx' )
                reac = moose.Reac( '/model/compartment/reac' )

                # connect them up for reactions
                moose.connect( enz1, 'sub', a, 'reac' )
                moose.connect( enz1, 'prd', b, 'reac' )
                moose.connect( enz1, 'enz', b, 'reac' )
                moose.connect( enz1, 'cplx', cplx1, 'reac' )

                moose.connect( enz2, 'sub', b, 'reac' )
                moose.connect( enz2, 'prd', a, 'reac' )
                moose.connect( enz2, 'enz', c, 'reac' )
                moose.connect( enz2, 'cplx', cplx2, 'reac' )

                moose.connect( reac, 'sub', a, 'reac' )
                moose.connect( reac, 'prd', b, 'reac' )

                # connect them up to the compartment for volumes
                #for x in ( a, b, c, cplx1, cplx2 ):
                #                        moose.connect( x, 'mesh', mesh, 'mesh' )

                # Assign parameters
                a.concInit = 1
                b.concInit = 0
                c.concInit = 0.01
                enz1.kcat = 0.4
                enz1.Km = 4
                enz2.kcat = 0.6
                enz2.Km = 0.01
                reac.Kf = 0.001
                reac.Kb = 0.01

                # Create the output tables
                graphs = moose.Neutral( '/model/graphs' )
                outputA = moose.Table2( '/model/graphs/concA' )
                outputB = moose.Table2( '/model/graphs/concB' )

                # connect up the tables
                moose.connect( outputA, 'requestOut', a, 'getConc' );
                moose.connect( outputB, 'requestOut', b, 'getConc' );

                '''
示例#19
0
def makeChemProto(name):
    chem = moose.Neutral('/library/' + name)
    for i in ('dend', 'spine', 'psd'):
        print(('making ', i))
        compt = moose.CubeMesh(chem.path + '/' + i)
        compt.volume = 1e-18
        ca = moose.Pool(compt.path + '/Ca')
        ca.concInit = 0.08e-3
        ca.diffConst = 1e-12
示例#20
0
def makeChemProto( name, Aexpr, Bexpr, params ):
    sw = params['stimWidth']
    diffLength = params['diffusionLength']
    dca = params['diffConstA'] * diffLength * diffLength
    dcb = params['diffConstB'] * diffLength * diffLength

    # Objects
    chem = moose.Neutral( '/library/' + name )
    compt = moose.CubeMesh( '/library/' + name + '/' + name )
    A = moose.Pool( compt.path + '/A' )
    B = moose.Pool( compt.path + '/B' )
    Z = moose.BufPool( compt.path + '/Z' )
    Ca = moose.BufPool( compt.path + '/Ca' )
    phase = moose.BufPool( compt.path + '/phase' )
    vel = moose.BufPool( compt.path + '/vel' )
    ampl = moose.BufPool( compt.path + '/ampl' )
    Adot = moose.Function( A.path + '/Adot' )
    Bdot = moose.Function( B.path + '/Bdot' )
    CaStim = moose.Function( Ca.path + '/CaStim' )
    A.diffConst = dca
    B.diffConst = dcb

    # Equations

    Adot.expr = parseExpr( Aexpr, params, True )
    Bdot.expr = parseExpr( Bexpr, params, False )
    CaStim.expr = 'x2 * exp( -((x0 - t)^2)/(2* ' + str(sw*sw) + ') )'

    #print Adot.expr
    #print Bdot.expr
    #print CaStim.expr

    # Connections
    Adot.x.num = 4
    moose.connect( Ca, 'nOut', Adot.x[0], 'input' )
    moose.connect( A, 'nOut', Adot.x[1], 'input' )
    moose.connect( B, 'nOut', Adot.x[2], 'input' )
    moose.connect( Z, 'nOut', Adot.x[3], 'input' )
    moose.connect( Adot, 'valueOut', A, 'increment' )

    Bdot.x.num = 3
    if name[:5] == 'negFF':
        moose.connect( Ca, 'nOut', Bdot.x[0], 'input' )
        print('Doing special msg')
    else:
        moose.connect( A, 'nOut', Bdot.x[0], 'input' )
    moose.connect( B, 'nOut', Bdot.x[1], 'input' )
    moose.connect( Z, 'nOut', Bdot.x[2], 'input' )
    moose.connect( Bdot, 'valueOut', B, 'increment' )

    CaStim.x.num = 3
    moose.connect( phase, 'nOut', CaStim.x[0], 'input' )
    moose.connect( vel, 'nOut', CaStim.x[1], 'input' )
    moose.connect( ampl, 'nOut', CaStim.x[2], 'input' )
    moose.connect( CaStim, 'valueOut', Ca, 'setN' )

    return compt
示例#21
0
def makeModel():
    """This function creates a bistable reaction system using explicit
    MOOSE calls rather than load from a file.
    The reaction is::

        a ---b---> 2b    # b catalyzes a to form more of b.
        2b ---c---> a    # c catalyzes b to form a.
        a <======> 2b    # a interconverts to b.

    """
    # create container for model
    model = moose.Neutral("model")
    compartment = moose.CubeMesh("/model/compartment")
    compartment.volume = 1e-15
    # the mesh is created automatically by the compartment
    mesh = moose.element("/model/compartment/mesh")

    # create molecules and reactions
    a = moose.BufPool("/model/compartment/a")
    b = moose.Pool("/model/compartment/b")
    c = moose.Pool("/model/compartment/c")
    enz1 = moose.Enz("/model/compartment/b/enz1")
    enz2 = moose.Enz("/model/compartment/c/enz2")
    cplx1 = moose.Pool("/model/compartment/b/enz1/cplx")
    cplx2 = moose.Pool("/model/compartment/c/enz2/cplx")
    reac = moose.Reac("/model/compartment/reac")

    # connect them up for reactions
    moose.connect(enz1, "sub", a, "reac")
    moose.connect(enz1, "prd", b, "reac")
    moose.connect(enz1, "prd", b, "reac")  # Note 2 molecules of b.
    moose.connect(enz1, "enz", b, "reac")
    moose.connect(enz1, "cplx", cplx1, "reac")

    moose.connect(enz2, "sub", b, "reac")
    moose.connect(enz2, "sub", b, "reac")  # Note 2 molecules of b.
    moose.connect(enz2, "prd", a, "reac")
    moose.connect(enz2, "enz", c, "reac")
    moose.connect(enz2, "cplx", cplx2, "reac")

    moose.connect(reac, "sub", a, "reac")
    moose.connect(reac, "prd", b, "reac")
    moose.connect(reac, "prd", b, "reac")  # Note 2 order in b.

    # Assign parameters
    a.concInit = 1
    b.concInit = 0
    c.concInit = 0.01
    enz1.kcat = 0.4
    enz1.Km = 4
    enz2.kcat = 0.6
    enz2.Km = 0.01
    reac.Kf = 0.001
    reac.Kb = 0.01

    return compartment
示例#22
0
def test( ):
    compt = moose.CubeMesh( '/compt' )
    r = moose.Reac( '/compt/r' )
    a = moose.Pool( '/compt/a' )
    a.concInit = 1
    b = moose.Pool( '/compt/b' )
    b.concInit = 2
    c = moose.Pool( '/compt/c' )
    c.concInit = 0.5
    moose.connect( r, 'sub', a, 'reac' )
    moose.connect( r, 'prd', b, 'reac' )
    moose.connect( r, 'prd', c, 'reac' )
    r.Kf = 0.1
    r.Kb = 0.01

    tabA = moose.Table2( '/compt/a/tab' )
    tabB = moose.Table2( '/compt/tabB' )
    tabC = moose.Table2( '/compt/tabB/tabC' )
    print(tabA, tabB, tabC)

    moose.connect( tabA, 'requestOut', a, 'getConc' )
    moose.connect( tabB, 'requestOut', b, 'getConc' )
    moose.connect( tabC, 'requestOut', c, 'getConc' )

    # Now create a streamer and use it to write to a stream
    st = moose.Streamer( '/compt/streamer' )
    st.outfile = os.path.join( os.getcwd(), 'temp.npy' )
    print(("outfile set to: %s " % st.outfile ))
    assert st.outfile  == os.path.join( os.getcwd(), 'temp.npy' ), st.outfile

    st.addTable( tabA )
    st.addTables( [ tabB, tabC ] )

    assert st.numTables == 3

    moose.reinit( )
    print( '[INFO] Running for 57 seconds' )
    moose.start( 57 )
    outfile = st.outfile
    moose.quit() # Otherwise Streamer won't flush the rest of entries.

    # Now read the table and verify that we have written
    print( '[INFO] Reading file %s' % outfile )
    if 'csv' in outfile:
        data = np.loadtxt(outfile, skiprows=1 )
    else:
        data = np.load( outfile )
    # Total rows should be 58 (counting zero as well).
    # print(data)
    # print( data.dtype )
    time = data['time']
    print( time )
    assert data.shape >= (58,), data.shape
    print( '[INFO] Test 2 passed' )
    return 0
示例#23
0
def makeChemInCubeMesh():
    dendSide = 10.8e-6
    spineSide = 6.8e-6
    psdSide = 8.565e-7
    parent = moose.Neutral('/model/chem')
    neuroMesh = moose.CubeMesh('/model/chem/neuroMesh')
    spineMesh = moose.CubeMesh('/model/chem/spineMesh')
    psdMesh = moose.CubeMesh('/model/chem/psdMesh')
    coords = [dendSide] * 9
    coords[0] = 0
    coords[1] = 0
    coords[2] = 0
    neuroMesh.coords = coords
    neuroMesh.preserveNumEntries = 1

    coords = [spineSide] * 9
    coords[0] = dendSide
    coords[1] = 0
    coords[2] = 0
    coords[3] = spineSide + dendSide
    spineMesh.coords = coords
    spineMesh.preserveNumEntries = 1

    coords = [psdSide] * 9
    coords[0] = dendSide + spineSide
    coords[1] = 0
    coords[2] = 0
    coords[3] = psdSide + spineSide + dendSide
    psdMesh.coords = coords
    psdMesh.preserveNumEntries = 1

    createChemModel(neuroMesh, spineMesh, psdMesh)
    dendCa = moose.element('/model/chem/neuroMesh/Ca')
    assert dendCa.volume == dendSide * dendSide * dendSide
    spineCa = moose.element('/model/chem/spineMesh/Ca')
    assert spineCa.volume == spineSide * spineSide * spineSide
    psdGluR = moose.element('/model/chem/psdMesh/psdGluR')
    assert psdGluR.volume == psdSide * psdSide * psdSide
    dendKinaseEnzCplx = moose.element(
        '/model/chem/neuroMesh/Ca.kinase/enz/cplx')
    assert dendKinaseEnzCplx.volume == dendSide * dendSide * dendSide
示例#24
0
def test_inheritance():
    ta = moose.Table2('/tab2', 10)
    tb = moose.wildcardFind('/##[TYPE=Table2]')
    assert len(tb) == len(ta.vec)
    for i, (t1, t2) in enumerate(zip(tb, ta.vec)):
        assert t1 == t2, (t1, t2)
        assert t1.id == t2.id
        assert t1.dataIndex == t2.dataIndex
        assert t1.path == t2.path

    a = moose.CubeMesh('/dadada')
    isinstance(a, moose.CubeMesh)
    assert isinstance(a, moose.CubeMesh)
    aa = moose.wildcardFind('/##[TYPE=CubeMesh]')[0]
    assert a == aa
    # This must be true for isinstance to work.
    assert isinstance(aa, moose.CubeMesh), (a.__class__, aa.__class__)

    a = moose.CubeMesh('yapf')
    assert a.isA['CubeMesh']
    assert a.isA['ChemCompt']
示例#25
0
def makeModel():
    # create container for model
    model = moose.Neutral('model')
    harmonic = moose.CubeMesh('/model/harmonic')
    harmonic.volume = 1e-15
    lotka = moose.CubeMesh('/model/lotka')
    lotka.volume = 1e-15

    # create molecules and reactions
    p = moose.Pool('/model/harmonic/p')
    v = moose.Pool('/model/harmonic/v')
    pdot = moose.Function('/model/harmonic/p/func')
    vdot = moose.Function('/model/harmonic/v/func')

    # Parameters
    offset1 = 1.0
    offset2 = 1.0
    k = 0.1
    p.nInit = offset1
    v.nInit = offset2 + 0.1
    pdot.x.num = 1
    vdot.x.num = 1
    pdot.expr = "x0 - " + str(offset1)
    vdot.expr = "-" + str(k) + " * (x0 - " + str(offset2) + ")"

    # connect them up for reactions
    moose.connect(p, 'nOut', vdot.x[0], 'input')
    moose.connect(v, 'nOut', pdot.x[0], 'input')
    moose.connect(vdot, 'valueOut', v, 'increment')
    moose.connect(pdot, 'valueOut', p, 'increment')

    # Create the output tables
    graphs = moose.Neutral('/model/graphs')
    pplot = moose.Table2('/model/graphs/p')
    vplot = moose.Table2('/model/graphs/v')

    # connect up the tables
    moose.connect(pplot, 'requestOut', p, 'getN')
    moose.connect(vplot, 'requestOut', v, 'getN')
示例#26
0
def buildLargeSystem(useStreamer=False):
    # create a huge system.
    if moose.exists('/comptB'):
        moose.delete('/comptB')
    moose.CubeMesh('/comptB')

    tables = []
    for i in range(300):
        r = moose.Reac('/comptB/r%d' % i)
        a = moose.Pool('/comptB/a%d' % i)
        a.concInit = 10.0
        b = moose.Pool('/comptB/b%d' % i)
        b.concInit = 2.0
        c = moose.Pool('/comptB/c%d' % i)
        c.concInit = 0.5
        moose.connect(r, 'sub', a, 'reac')
        moose.connect(r, 'prd', b, 'reac')
        moose.connect(r, 'prd', c, 'reac')
        r.Kf = 0.1
        r.Kb = 0.01

        # Make table name large enough such that the header is larger than 2^16
        # . Numpy version 1 can't handle such a large header. If format 1 is
        # then this test will fail.
        t = moose.Table2('/comptB/TableO1%d' % i + 'abc' * 100)
        moose.connect(t, 'requestOut', a, 'getConc')
        tables.append(t)

    if useStreamer:
        s = moose.Streamer('/comptB/streamer')
        s.datafile = 'data2.npy'
        print("[INFO ] Total tables %d" % len(tables))

        # Add tables using wilcardFind.
        s.addTables(moose.wildcardFind('/comptB/##[TYPE=Table2]'))

        print("Streamer has %d table" % s.numTables)
        assert s.numTables == len(tables), (s.numTables, len(tables))

    moose.reinit()
    moose.start(10)

    if useStreamer:
        # load the data
        data = np.load(s.datafile)
        header = str(data.dtype.names)
        assert len(header) > 2**16
    else:
        data = {x.columnName: x.vector for x in tables}
    return data
示例#27
0
def createCompartment(basePath, model, comptSbmlidMooseIdMap):
    # ToDoList : Check what should be done for the spaitialdimension is 2 or
    # 1, area or length
    if not (model.getNumCompartments()):
        return False,
    else:
        for c in range(0, model.getNumCompartments()):
            compt = model.getCompartment(c)
            # print("Compartment " + str(c) + ": "+ UnitDefinition.printUnits(compt.getDerivedUnitDefinition()))
            msize = 0.0
            unitfactor = 1.0
            sbmlCmptId = None
            name = None

            if (compt.isSetId()):
                sbmlCmptId = compt.getId()

            if (compt.isSetName()):
                name = compt.getName()
                name = name.replace(" ", "_space")

            if (compt.isSetOutside()):
                outside = compt.getOutside()

            if (compt.isSetSize()):
                msize = compt.getSize()
                if msize == 1:
                    print("Compartment size is 1")

            dimension = compt.getSpatialDimensions()
            if dimension == 3:
                unitfactor, unitset, unittype = transformUnit(compt)

            else:
                print(
                    " Currently we don't deal with spatial Dimension less than 3 and unit's area or length"
                )
                return False

            if not (name):
                name = sbmlCmptId

            mooseCmptId = moose.CubeMesh(basePath.path + '/' + name)
            mooseCmptId.volume = (msize * unitfactor)
            comptSbmlidMooseIdMap[sbmlCmptId] = {
                "MooseId": mooseCmptId,
                "spatialDim": dimension,
                "size": msize
            }
    return True
示例#28
0
def makeReacs():
    # Parameters
    volume = 1e-15
    CaInitConc = 60e-6
    NA = 6.022e23
    tauI = 1
    tauG = 0.1

    model = moose.Neutral('/cells')
    compartment = moose.CubeMesh('/cells/compartment')
    compartment.volume = volume

    # Make pools
    Ca = moose.BufPool('/cells/compartment/Ca')
    tgtCa = moose.BufPool('/cells/compartment/tgtCa')
    m = moose.Pool('/cells/compartment/m')
    chan = moose.Pool('/cells/compartment/chan')

    # Make Funcs
    f1 = moose.Func('/cells/compartment/f1')
    f2 = moose.Func('/cells/compartment/f2')

    # connect up
    moose.connect(f1, 'valueOut', m, 'increment')
    moose.connect(f2, 'valueOut', chan, 'increment')

    moose.connect(Ca, 'nOut', f1, 'xIn')
    moose.connect(tgtCa, 'nOut', f1, 'yIn')

    moose.connect(m, 'nOut', f2, 'xIn')
    moose.connect(chan, 'nOut', f2, 'yIn')

    # Set params
    Ca.concInit = CaInitConc
    tgtCa.concInit = tgtCaInitConc
    m.concInit = 0.0
    chan.concInit = 0.0
    volscale = 1.0

    f1.expr = str(volscale / tauI) + " * (x-y)"
    f2.expr = str(volscale / tauG) + " * (x-y)"

    #Plotting
    channelPlot = makePlot('channelConc', chan, 'Conc', 18)
    mPlot = makePlot('mConc', m, 'Conc', 18)
    caPlot = makePlot('Ca', Ca, 'Conc', 18)
    targetPlot = makePlot('tgtCa', tgtCa, 'Conc', 18)
    return (channelPlot, mPlot, caPlot)
def makeChemProto(name='hydra'):
    maxs = 0.05
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    S = moose.Pool(compt.path + '/S')
    space = moose.Pool(compt.path + '/space')
    #C=moose.Pool(compt.path+'/C')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Sdot = moose.Function(S.path + '/Sdot')
    spacedot = moose.Function(space.path + '/spacedot')
    #Cdot = moose.Function( C.path + '/Cdot' )
    #Adot.expr="0.001*((x0^2/x1)+1)-1*x0+0.5*x0"
    #Bdot.expr="0*x0+0.001*x0^2-1*x1+1*x1"
    #Adot.expr="-x0+x1(0.067+(1*x0^2)/(1+x0^2))"
    #Bdot.expr="x0-x1(0.067+(1*x0^2)/(1+x0^2))"
    Adot.expr = "-x0+x1*(0.067+(1*x0^2)/(1+x0^2))+(t<20)*(0.05/2)*(1+cos(" + str(
        np.pi) + "*x3))*x1*x2+(t>20)*(t<25)*(0.05/4)*(cos(" + str(
            np.pi) + "*(t-20)/5))*(1+cos(" + str(np.pi) + "*x3))*x1*x2"
    Bdot.expr = "x0-x1*(0.067+(1*x0^2)/(1+x0^2))-(t<20)*(0.05/2)*(1+cos(" + str(
        np.pi) + "*x3))*x1*x2-(t>20)*(t<25)*(0.05/4)*(cos(" + str(
            np.pi) + "*(t-20)/5))*(1+cos(" + str(np.pi) + "*x3))*x1*x2"
    Sdot.expr = "0"
    spacedot.expr = "0"
    #Cdot.expr="0*x0+0.11*x1-0.11*x2+0.1*x0^2-0.1*(x1+x2)"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 4  #2
    Bdot.x.num = 4  #2
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(S, 'nOut', Adot.x[2], 'input')
    moose.connect(space, 'nOut', Adot.x[3], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(S, 'nOut', Bdot.x[2], 'input')
    moose.connect(space, 'nOut', Bdot.x[3], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    return compt
示例#30
0
def makeModel():
    rdes = rd.rdesigneur( useGssa = False, \
                combineSegments = False, \
                cellPortion = "/model/elec/#",  \
                meshLambda = 1e-6, \
                adaptorList = [ \
                    ( 'psd', '.', 'inject', 'Ca', False, 0, 2e-9 ) \
                    ], \
                addSpineList = [ \
                    ( 'spine', '#', \
                    spineSpacing, spineSpacingDistrib, spineSizeDistrib, \
                    0.0, 0.0, numpy.pi, numpy.pi / 2.0 ) \
                    ]
                )
    # Make a 'bare' spine: No synchans, no ion chans, no Ca.
    rdes.addSpineProto( 'spine', RM, RA, CM, \
             synList = (), chanList = (), caTau = 0.0 )
    elec = moose.Neutral('/tempelec')
    '''
    ecompt = rdes._buildCompt( elec, 'dend', 100e-6, 2.0e-6, 0, RM, RA, CM )
    ecompt.x0 = 0
    ecompt.x = 0
    ecompt.y0 = 0
    ecompt.y = 0
    ecompt.z0 = 0
    ecompt.z = 100e-6
    '''
    ecompt = []
    for i in range(numDendSegments):
        ec = rdes._buildCompt(elec, 'dend' + str(i), segLen, 2.0e-6,
                              i * segLen, RM, RA, CM)
        ecompt.append(ec)
        if i > 0:
            moose.connect(ecompt[i - 1], 'raxial', ec, 'axial')
    for i in ecompt:
        i.z0 = i.x0
        i.x0 = 0
        i.z = i.x
        i.x = 0

    chem = moose.Neutral('/tempchem')
    for i in ('dend', 'spine', 'psd'):
        compt = moose.CubeMesh('/tempchem/' + i)
        compt.volume = 1e-18
        ca = moose.Pool('/tempchem/' + i + '/Ca')
        ca.concInit = 0.08e-3
        ca.diffConst = 1e-12
    rdes.buildFromMemory('/tempelec', '/tempchem')