# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # CHANNELS  # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

###### CaP channel ##############

CaPchan = smodel.Chan('CaPchan', mdl_stoch)

CaP_m0 = smodel.ChanState('CaP_m0', mdl_stoch, CaPchan)
CaP_m1 = smodel.ChanState('CaP_m1', mdl_stoch, CaPchan)
CaP_m2 = smodel.ChanState('CaP_m2', mdl_stoch, CaPchan)
CaP_m3 = smodel.ChanState('CaP_m3', mdl_stoch, CaPchan)

CaPm0m1 = smodel.VDepSReac('CaPm0m1',
                           ssys_stoch,
                           slhs=[CaP_m0],
                           srhs=[CaP_m1],
                           k=lambda V: 1.0e3 * 3. * alpha_cap(V * 1.0e3) * Qt)
CaPm1m2 = smodel.VDepSReac('CaPm1m2',
                           ssys_stoch,
                           slhs=[CaP_m1],
                           srhs=[CaP_m2],
                           k=lambda V: 1.0e3 * 2. * alpha_cap(V * 1.0e3) * Qt)
CaPm2m3 = smodel.VDepSReac('CaPm2m3',
                           ssys_stoch,
                           slhs=[CaP_m2],
                           srhs=[CaP_m3],
                           k=lambda V: 1.0e3 * 1. * alpha_cap(V * 1.0e3) * Qt)

CaPm3m2 = smodel.VDepSReac('CaPm3m2',
                           ssys_stoch,
Beispiel #2
0
    def setUp(self):
        mdl = smodel.Model()

        S1 = smodel.Spec('S1', mdl)

        vsys = smodel.Volsys('vsys', mdl)
        ssys = smodel.Surfsys('ssys', mdl)

        smodel.Reac('R01', vsys, lhs=[S1], rhs=[S1], kcst=1)
        smodel.SReac('SR01', ssys, slhs=[S1], srhs=[S1], kcst=1)

        vrange = [-200.0e-3, 50e-3, 1e-3]
        vrate = lambda v: 2.0
        Chan1 = smodel.Chan('Chan1', mdl)
        chanop = smodel.ChanState('chanop', mdl, Chan1)
        chancl = smodel.ChanState('chancl', mdl, Chan1)
        smodel.VDepSReac('VDSR01',
                         ssys,
                         slhs=[chancl],
                         srhs=[chanop],
                         k=vrate,
                         vrange=vrange)
        smodel.VDepSReac('VDSR02',
                         ssys,
                         srhs=[chancl],
                         slhs=[chanop],
                         k=vrate,
                         vrange=vrange)

        Chan1_Ohm_I = smodel.OhmicCurr('Chan1_Ohm_I',
                                       ssys,
                                       chanstate=chanop,
                                       g=20e-12,
                                       erev=-77e-3)

        if __name__ == "__main__":
            self.mesh = meshio.importAbaqus('meshes/test.inp', 1e-7)[0]
        else:
            self.mesh = meshio.importAbaqus(
                'missing_solver_methods_test/meshes/test.inp', 1e-7)[0]

        comp1 = sgeom.TmComp('comp1', self.mesh, range(self.mesh.countTets()))
        comp1.addVolsys('vsys')

        patch1 = sgeom.TmPatch('patch1', self.mesh, self.mesh.getSurfTris(),
                               comp1)
        patch1.addSurfsys('ssys')

        self.c1ROIInds = range(10)
        self.p1ROIInds = range(5)
        self.mesh.addROI('comp1ROI', sgeom.ELEM_TET, self.c1ROIInds)
        self.mesh.addROI('patch1ROI', sgeom.ELEM_TRI, self.p1ROIInds)

        membrane = sgeom.Memb('membrane', self.mesh, [patch1], opt_method=1)

        rng = srng.create('mt19937', 512)
        rng.initialize(1234)

        self.sim = ssolver.Tetexact(mdl, self.mesh, rng, True)
        self.sim.setEfieldDT(1e-4)

        self.sim.reset()
Beispiel #3
0
mdl = smodel.Model()

#surface systems (No need for a vol sys)
ssys = smodel.Surfsys('ssys', mdl)

# Potassium channel
Kchan = smodel.Chan('Kchan', mdl)
K_n0 = smodel.ChanState('K_n0', mdl, Kchan)
K_n1 = smodel.ChanState('K_n1', mdl, Kchan)
K_n2 = smodel.ChanState('K_n2', mdl, Kchan)
K_n3 = smodel.ChanState('K_n3', mdl, Kchan)
K_n4 = smodel.ChanState('K_n4', mdl, Kchan)


Kn0n1 = smodel.VDepSReac('Kn0n1', ssys, slhs = [K_n0], srhs = [K_n1], \
                            k=lambda V: 1.0e3 *4.*a_n(V*1.0e3)* Qt, vrange = Vrange)
Kn1n2 = smodel.VDepSReac('Kn1n2', ssys, slhs = [K_n1], srhs = [K_n2], \
                            k=lambda V: 1.0e3 *3.*a_n(V*1.0e3)* Qt, vrange = Vrange)
Kn2n3 = smodel.VDepSReac('Kn2n3', ssys, slhs = [K_n2], srhs = [K_n3], \
                            k=lambda V: 1.0e3 *2.*a_n(V*1.0e3)* Qt, vrange = Vrange)
Kn3n4 = smodel.VDepSReac('Kn3n4', ssys, slhs = [K_n3], srhs = [K_n4], \
                            k=lambda V: 1.0e3 *1.*a_n(V*1.0e3)* Qt, vrange = Vrange)

Kn4n3 = smodel.VDepSReac('Kn4n3', ssys, slhs = [K_n4], srhs = [K_n3], \
                            k=lambda V: 1.0e3 *4.*b_n(V*1.0e3)* Qt, vrange = Vrange)
Kn3n2 = smodel.VDepSReac('Kn3n2', ssys, slhs = [K_n3], srhs = [K_n2], \
                            k=lambda V: 1.0e3 *3.*b_n(V*1.0e3)* Qt, vrange = Vrange)
Kn2n1 = smodel.VDepSReac('Kn2n1', ssys, slhs = [K_n2], srhs = [K_n1], \
                            k=lambda V: 1.0e3 *2.*b_n(V*1.0e3)* Qt, vrange = Vrange)
Kn1n0 = smodel.VDepSReac('Kn1n0', ssys, slhs = [K_n1], srhs = [K_n0], \
                            k=lambda V: 1.0e3 *1.*b_n(V*1.0e3)* Qt, vrange = Vrange)
Beispiel #4
0
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # CHANNELS  # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

###### CaP channel ##############

CaPchan = smodel.Chan('CaPchan', mdl)

CaP_m0 = smodel.ChanState('CaP_m0', mdl, CaPchan)
CaP_m1 = smodel.ChanState('CaP_m1', mdl, CaPchan)
CaP_m2 = smodel.ChanState('CaP_m2', mdl, CaPchan)
CaP_m3 = smodel.ChanState('CaP_m3', mdl, CaPchan)

CaPm0m1 = smodel.VDepSReac('CaPm0m1',
                           ssys,
                           slhs=[CaP_m0],
                           srhs=[CaP_m1],
                           k=lambda V: 1.0e3 * 3. * alpha_cap(V * 1.0e3) * Qt)
CaPm1m2 = smodel.VDepSReac('CaPm1m2',
                           ssys,
                           slhs=[CaP_m1],
                           srhs=[CaP_m2],
                           k=lambda V: 1.0e3 * 2. * alpha_cap(V * 1.0e3) * Qt)
CaPm2m3 = smodel.VDepSReac('CaPm2m3',
                           ssys,
                           slhs=[CaP_m2],
                           srhs=[CaP_m3],
                           k=lambda V: 1.0e3 * 1. * alpha_cap(V * 1.0e3) * Qt)

CaPm3m2 = smodel.VDepSReac('CaPm3m2',
                           ssys,
def test_rallpack3():
    print("Rallpack 3 with TetODE")
    #meshfile ='axon_cube_L1000um_D866m_600tets'
    meshfile = 'axon_cube_L1000um_D866m_1135tets'
    #meshfile = 'axon_cube_L1000um_D866nm_1978tets'

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    # Potassium conductance, Siemens/m^2
    K_G = 360
    # Sodium conductance, Siemens/m^2
    Na_G = 1200
    # Leak conductance, Siemens/m^2
    L_G = 0.25

    # Potassium reversal potential, V
    K_rev = -77e-3
    # Sodium reversal potential, V
    Na_rev = 50e-3
    # Leak reveral potential, V
    leak_rev = -65.0e-3

    # Potassium channel density
    K_ro = 18.0e12
    # Sodium channel density
    Na_ro = 60.0e12

    # Total leak conductance for ideal cylinder:
    surfarea_cyl = 1.0 * np.pi * 1000 * 1e-12
    L_G_tot = L_G * surfarea_cyl

    # A table of potassium density factors at -65mV, found in getpops. n0, n1, n2, n3, n4
    K_FACS = [0.216750577045, 0.40366011853, 0.281904943772, \
                0.0874997924409, 0.0101845682113 ]

    # A table of sodium density factors. m0h1, m1h1, m2h1, m3h1, m0h0, m1h0, m2h0, m3h0
    NA_FACS = [0.343079175644, 0.0575250437508, 0.00321512825945, 5.98988373918e-05, \
                0.506380603793, 0.0849062503811, 0.00474548939393, 8.84099403236e-05]

    # Ohm.m
    Ra = 1.0

    # # # # # # # # # # # # # # # # SIMULATION CONTROLS # # # # # # # # # # # # # #

    # The simulation dt (seconds); for TetODE this is equivalent to EField dt
    SIM_DT = 5.0e-6

    # Sim end time (seconds)
    SIM_END = 0.1

    # The number of sim 'time points'; * SIM_DT = sim end time
    SIM_NTPNTS = int(SIM_END / SIM_DT) + 1

    # The current injection in amps
    Iinj = 0.1e-9

    # # # # # # # # # # # # # DATA COLLECTION # # # # # # # # # # # # # # # # # #

    # record potential at the two extremes along (z) axis
    POT_POS = np.array([0.0, 1.0e-03])

    POT_N = len(POT_POS)

    # Length of the mesh, in m
    LENGTH = 1000.0e-6

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    mdl = smodel.Model()
    ssys = smodel.Surfsys('ssys', mdl)

    # K channel
    K = smodel.Chan('K', mdl)
    K_n0 = smodel.ChanState('K_n0', mdl, K)
    K_n1 = smodel.ChanState('K_n1', mdl, K)
    K_n2 = smodel.ChanState('K_n2', mdl, K)
    K_n3 = smodel.ChanState('K_n3', mdl, K)
    K_n4 = smodel.ChanState('K_n4', mdl, K)

    # Na channel
    Na = smodel.Chan('Na', mdl)
    Na_m0h1 = smodel.ChanState('Na_m0h1', mdl, Na)
    Na_m1h1 = smodel.ChanState('Na_m1h1', mdl, Na)
    Na_m2h1 = smodel.ChanState('Na_m2h1', mdl, Na)
    Na_m3h1 = smodel.ChanState('Na_m3h1', mdl, Na)
    Na_m0h0 = smodel.ChanState('Na_m0h0', mdl, Na)
    Na_m1h0 = smodel.ChanState('Na_m1h0', mdl, Na)
    Na_m2h0 = smodel.ChanState('Na_m2h0', mdl, Na)
    Na_m3h0 = smodel.ChanState('Na_m3h0', mdl, Na)

    # Leak
    L = smodel.Chan('L', mdl)
    Leak = smodel.ChanState('Leak', mdl, L)

    # Gating kinetics
    _a_m = lambda mV: ((((0.1 * (25 - (mV + 65.)) / (np.exp(
        (25 - (mV + 65.)) / 10.) - 1)))))
    _b_m = lambda mV: ((((4. * np.exp(-((mV + 65.) / 18.))))))
    _a_h = lambda mV: ((((0.07 * np.exp((-(mV + 65.) / 20.))))))
    _b_h = lambda mV: ((((1. / (np.exp((30 - (mV + 65.)) / 10.) + 1)))))
    _a_n = lambda mV: ((((0.01 * (10 - (mV + 65.)) / (np.exp(
        (10 - (mV + 65.)) / 10.) - 1)))))
    _b_n = lambda mV: ((((0.125 * np.exp(-(mV + 65.) / 80.)))))

    Kn0n1 = smodel.VDepSReac('Kn0n1',
                             ssys,
                             slhs=[K_n0],
                             srhs=[K_n1],
                             k=lambda V: 1.0e3 * 4. * _a_n(V * 1.0e3))
    Kn1n2 = smodel.VDepSReac('Kn1n2',
                             ssys,
                             slhs=[K_n1],
                             srhs=[K_n2],
                             k=lambda V: 1.0e3 * 3. * _a_n(V * 1.0e3))
    Kn2n3 = smodel.VDepSReac('Kn2n3',
                             ssys,
                             slhs=[K_n2],
                             srhs=[K_n3],
                             k=lambda V: 1.0e3 * 2. * _a_n(V * 1.0e3))
    Kn3n4 = smodel.VDepSReac('Kn3n4',
                             ssys,
                             slhs=[K_n3],
                             srhs=[K_n4],
                             k=lambda V: 1.0e3 * 1. * _a_n(V * 1.0e3))

    Kn4n3 = smodel.VDepSReac('Kn4n3',
                             ssys,
                             slhs=[K_n4],
                             srhs=[K_n3],
                             k=lambda V: 1.0e3 * 4. * _b_n(V * 1.0e3))
    Kn3n2 = smodel.VDepSReac('Kn3n2',
                             ssys,
                             slhs=[K_n3],
                             srhs=[K_n2],
                             k=lambda V: 1.0e3 * 3. * _b_n(V * 1.0e3))
    Kn2n1 = smodel.VDepSReac('Kn2n1',
                             ssys,
                             slhs=[K_n2],
                             srhs=[K_n1],
                             k=lambda V: 1.0e3 * 2. * _b_n(V * 1.0e3))
    Kn1n0 = smodel.VDepSReac('Kn1n0',
                             ssys,
                             slhs=[K_n1],
                             srhs=[K_n0],
                             k=lambda V: 1.0e3 * 1. * _b_n(V * 1.0e3))

    Na_m0h1_m1h1 = smodel.VDepSReac('Na_m0h1_m1h1',
                                    ssys,
                                    slhs=[Na_m0h1],
                                    srhs=[Na_m1h1],
                                    k=lambda V: 1.0e3 * 3. * _a_m(V * 1.0e3))
    Na_m1h1_m2h1 = smodel.VDepSReac('Na_m1h1_m2h1',
                                    ssys,
                                    slhs=[Na_m1h1],
                                    srhs=[Na_m2h1],
                                    k=lambda V: 1.0e3 * 2. * _a_m(V * 1.0e3))
    Na_m2h1_m3h1 = smodel.VDepSReac('Na_m2h1_m3h1',
                                    ssys,
                                    slhs=[Na_m2h1],
                                    srhs=[Na_m3h1],
                                    k=lambda V: 1.0e3 * 1. * _a_m(V * 1.0e3))

    Na_m3h1_m2h1 = smodel.VDepSReac('Na_m3h1_m2h1',
                                    ssys,
                                    slhs=[Na_m3h1],
                                    srhs=[Na_m2h1],
                                    k=lambda V: 1.0e3 * 3. * _b_m(V * 1.0e3))
    Na_m2h1_m1h1 = smodel.VDepSReac('Na_m2h1_m1h1',
                                    ssys,
                                    slhs=[Na_m2h1],
                                    srhs=[Na_m1h1],
                                    k=lambda V: 1.0e3 * 2. * _b_m(V * 1.0e3))
    Na_m1h1_m0h1 = smodel.VDepSReac('Na_m1h1_m0h1',
                                    ssys,
                                    slhs=[Na_m1h1],
                                    srhs=[Na_m0h1],
                                    k=lambda V: 1.0e3 * 1. * _b_m(V * 1.0e3))

    Na_m0h0_m1h0 = smodel.VDepSReac('Na_m0h0_m1h0',
                                    ssys,
                                    slhs=[Na_m0h0],
                                    srhs=[Na_m1h0],
                                    k=lambda V: 1.0e3 * 3. * _a_m(V * 1.0e3))
    Na_m1h0_m2h0 = smodel.VDepSReac('Na_m1h0_m2h0',
                                    ssys,
                                    slhs=[Na_m1h0],
                                    srhs=[Na_m2h0],
                                    k=lambda V: 1.0e3 * 2. * _a_m(V * 1.0e3))
    Na_m2h0_m3h0 = smodel.VDepSReac('Na_m2h0_m3h0',
                                    ssys,
                                    slhs=[Na_m2h0],
                                    srhs=[Na_m3h0],
                                    k=lambda V: 1.0e3 * 1. * _a_m(V * 1.0e3))

    Na_m3h0_m2h0 = smodel.VDepSReac('Na_m3h0_m2h0',
                                    ssys,
                                    slhs=[Na_m3h0],
                                    srhs=[Na_m2h0],
                                    k=lambda V: 1.0e3 * 3. * _b_m(V * 1.0e3))
    Na_m2h0_m1h0 = smodel.VDepSReac('Na_m2h0_m1h0',
                                    ssys,
                                    slhs=[Na_m2h0],
                                    srhs=[Na_m1h0],
                                    k=lambda V: 1.0e3 * 2. * _b_m(V * 1.0e3))
    Na_m1h0_m0h0 = smodel.VDepSReac('Na_m1h0_m0h0',
                                    ssys,
                                    slhs=[Na_m1h0],
                                    srhs=[Na_m0h0],
                                    k=lambda V: 1.0e3 * 1. * _b_m(V * 1.0e3))

    Na_m0h1_m0h0 = smodel.VDepSReac('Na_m0h1_m0h0',
                                    ssys,
                                    slhs=[Na_m0h1],
                                    srhs=[Na_m0h0],
                                    k=lambda V: 1.0e3 * _a_h(V * 1.0e3))
    Na_m1h1_m1h0 = smodel.VDepSReac('Na_m1h1_m1h0',
                                    ssys,
                                    slhs=[Na_m1h1],
                                    srhs=[Na_m1h0],
                                    k=lambda V: 1.0e3 * _a_h(V * 1.0e3))
    Na_m2h1_m2h0 = smodel.VDepSReac('Na_m2h1_m2h0',
                                    ssys,
                                    slhs=[Na_m2h1],
                                    srhs=[Na_m2h0],
                                    k=lambda V: 1.0e3 * _a_h(V * 1.0e3))
    Na_m3h1_m3h0 = smodel.VDepSReac('Na_m3h1_m3h0',
                                    ssys,
                                    slhs=[Na_m3h1],
                                    srhs=[Na_m3h0],
                                    k=lambda V: 1.0e3 * _a_h(V * 1.0e3))

    Na_m0h0_m0h1 = smodel.VDepSReac('Na_m0h0_m0h1',
                                    ssys,
                                    slhs=[Na_m0h0],
                                    srhs=[Na_m0h1],
                                    k=lambda V: 1.0e3 * _b_h(V * 1.0e3))
    Na_m1h0_m1h1 = smodel.VDepSReac('Na_m1h0_m1h1',
                                    ssys,
                                    slhs=[Na_m1h0],
                                    srhs=[Na_m1h1],
                                    k=lambda V: 1.0e3 * _b_h(V * 1.0e3))
    Na_m2h0_m2h1 = smodel.VDepSReac('Na_m2h0_m2h1',
                                    ssys,
                                    slhs=[Na_m2h0],
                                    srhs=[Na_m2h1],
                                    k=lambda V: 1.0e3 * _b_h(V * 1.0e3))
    Na_m3h0_m3h1 = smodel.VDepSReac('Na_m3h0_m3h1',
                                    ssys,
                                    slhs=[Na_m3h0],
                                    srhs=[Na_m3h1],
                                    k=lambda V: 1.0e3 * _b_h(V * 1.0e3))

    OC_K = smodel.OhmicCurr('OC_K',
                            ssys,
                            chanstate=K_n4,
                            erev=K_rev,
                            g=K_G / K_ro)
    OC_Na = smodel.OhmicCurr('OC_Na',
                             ssys,
                             chanstate=Na_m3h0,
                             erev=Na_rev,
                             g=Na_G / Na_ro)

    # Mesh geometry
    mesh = meshio.loadMesh('validation_efield/meshes/' + meshfile)[0]

    cyto = sgeom.TmComp('cyto', mesh, range(mesh.ntets))

    # The tetrahedrons from which to record potential
    POT_TET = np.zeros(POT_N, dtype='uint')

    i = 0
    for p in POT_POS:
        # Assuming axiz aligned with z-axis
        POT_TET[i] = mesh.findTetByPoint([0.0, 0.0, POT_POS[i]])
        i = i + 1

    # Find the tets connected to the bottom face
    # First find all the tets with ONE face on a boundary
    boundtets = []
    #store the 0to3 index of the surface triangle for each of these boundary tets
    bt_srftriidx = []

    for i in range(mesh.ntets):
        tettemp = mesh.getTetTetNeighb(i)
        if (tettemp[0] == -1 or tettemp[1] == -1 or tettemp[2] == -1
                or tettemp[3] == -1):
            boundtets.append(i)
            templist = []
            if (tettemp[0] == -1):
                templist.append(0)
            if (tettemp[1] == -1):
                templist.append(1)
            if (tettemp[2] == -1):
                templist.append(2)
            if (tettemp[3] == -1):
                templist.append(3)
            bt_srftriidx.append(templist)

    assert (boundtets.__len__() == bt_srftriidx.__len__())

    # Find the tets on the z=0 and z=1000um boundaries, and the triangles
    minztets = []
    minztris = []
    maxztris = []
    minzverts = set([])

    boundminz = mesh.getBoundMin()[2] + LENGTH / mesh.ntets
    boundmaxz = mesh.getBoundMax()[2] - LENGTH / mesh.ntets

    for i in range(boundtets.__len__()):
        # get the boundary triangle
        for btriidx in bt_srftriidx[i]:
            zminboundtri = True
            tribidx = mesh.getTetTriNeighb(boundtets[i])[btriidx]
            tritemp = mesh.getTri(tribidx)
            trizs = [0.0, 0.0, 0.0]
            trizs[0] = mesh.getVertex(tritemp[0])[2]
            trizs[1] = mesh.getVertex(tritemp[1])[2]
            trizs[2] = mesh.getVertex(tritemp[2])[2]
            for j in range(3):
                if (trizs[j] > boundminz): zminboundtri = False
            if (zminboundtri):
                minztets.append(boundtets[i])
                minztris.append(tribidx)
                minzverts.add(tritemp[0])
                minzverts.add(tritemp[1])
                minzverts.add(tritemp[2])
                continue

            zmaxboundtri = True
            for j in range(3):
                if (trizs[j] < boundmaxz): zmaxboundtri = False
            if (zmaxboundtri):
                maxztris.append(tribidx)

    n_minztris = len(minztris)
    assert (n_minztris > 0)
    minzverts = list(minzverts)
    n_minzverts = len(minzverts)
    assert (n_minzverts > 0)

    memb_tris = list(mesh.getSurfTris())

    # Doing this now, so will inject into first little z section
    for t in minztris:
        memb_tris.remove(t)
    for t in maxztris:
        memb_tris.remove(t)

    # Create the membrane with the tris removed at faces
    memb = sgeom.TmPatch('memb', mesh, memb_tris, cyto)
    memb.addSurfsys('ssys')

    membrane = sgeom.Memb('membrane',
                          mesh, [memb],
                          opt_method=2,
                          search_percent=100.0)

    # Set the single-channel conductance:
    g_leak_sc = L_G_tot / len(memb_tris)
    OC_L = smodel.OhmicCurr('OC_L',
                            ssys,
                            chanstate=Leak,
                            erev=leak_rev,
                            g=g_leak_sc)

    # Create the solver objects
    sim = ssolver.TetODE(mdl, mesh, calcMembPot=True)
    sim.setTolerances(1.0e-6, 1e-6)

    surfarea_mesh = sim.getPatchArea('memb')
    surfarea_cyl = 1.0 * np.pi * 1000 * 1e-12
    corr_fac_area = surfarea_mesh / surfarea_cyl

    vol_cyl = np.pi * 0.5 * 0.5 * 1000 * 1e-18
    vol_mesh = sim.getCompVol('cyto')
    corr_fac_vol = vol_mesh / vol_cyl

    RES_POT = np.zeros((SIM_NTPNTS, POT_N))

    for t in memb_tris:
        sim.setTriCount(t, 'Leak', 1)

    sim.setPatchCount('memb', 'Na_m0h1', (Na_ro * surfarea_cyl * NA_FACS[0]))
    sim.setPatchCount('memb', 'Na_m1h1', (Na_ro * surfarea_cyl * NA_FACS[1]))
    sim.setPatchCount('memb', 'Na_m2h1', (Na_ro * surfarea_cyl * NA_FACS[2]))
    sim.setPatchCount('memb', 'Na_m3h1', (Na_ro * surfarea_cyl * NA_FACS[3]))
    sim.setPatchCount('memb', 'Na_m0h0', (Na_ro * surfarea_cyl * NA_FACS[4]))
    sim.setPatchCount('memb', 'Na_m1h0', (Na_ro * surfarea_cyl * NA_FACS[5]))
    sim.setPatchCount('memb', 'Na_m2h0', (Na_ro * surfarea_cyl * NA_FACS[6]))
    sim.setPatchCount('memb', 'Na_m3h0', (Na_ro * surfarea_cyl * NA_FACS[7]))
    sim.setPatchCount('memb', 'K_n0', (K_ro * surfarea_cyl * K_FACS[0]))
    sim.setPatchCount('memb', 'K_n1', (K_ro * surfarea_cyl * K_FACS[1]))
    sim.setPatchCount('memb', 'K_n2', (K_ro * surfarea_cyl * K_FACS[2]))
    sim.setPatchCount('memb', 'K_n3', (K_ro * surfarea_cyl * K_FACS[3]))
    sim.setPatchCount('memb', 'K_n4', (K_ro * surfarea_cyl * K_FACS[4]))

    sim.setMembPotential('membrane', -65e-3)
    sim.setMembVolRes('membrane', Ra * corr_fac_vol)
    sim.setMembCapac('membrane', 0.01 / corr_fac_area)

    for v in minzverts:
        sim.setVertIClamp(v, Iinj / n_minzverts)

    for l in range(SIM_NTPNTS):

        sim.run(SIM_DT * l)

        for p in range(POT_N):
            RES_POT[l, p] = sim.getTetV(int(POT_TET[p])) * 1.0e3

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    # Benchmark
    # At 0um- the end of the mesh
    ifile_benchmark_x0 = open(
        'validation_efield/data/rallpack3_benchmark/rallpack3_0_0.001dt_1000seg',
        'r')

    # At 1000um- the end of the mesh
    ifile_benchmark_x1000 = open(
        'validation_efield/data/rallpack3_benchmark/rallpack3_1000_0.001dt_1000seg',
        'r')

    tpnt_benchmark = []
    v_benchmark_x0 = []
    v_benchmark_x1000 = []

    lines_benchmark_x0 = ifile_benchmark_x0.readlines()[2:]

    # Read in mv and ms
    for line_benchmark_x0 in lines_benchmark_x0:
        nums = line_benchmark_x0.split()
        tpnt_benchmark.append(float(nums[0]))
        v_benchmark_x0.append(float(nums[1]))

    lines_benchmark_x1000 = ifile_benchmark_x1000.readlines()[2:]

    for line_benchmark_x1000 in lines_benchmark_x1000:
        nums = line_benchmark_x1000.split()
        v_benchmark_x1000.append(float(nums[1]))

    # Get rid of the last point which seems to be missing from STEPS
    v_benchmark_x0 = v_benchmark_x0[:-1]
    tpnt_benchmark = tpnt_benchmark[:-1]
    v_benchmark_x1000 = v_benchmark_x1000[:-1]

    rms0 = stats(v_benchmark_x0, RES_POT[:, 0])
    assert (rms0 < 0.15)
    rms1000 = stats(v_benchmark_x1000, RES_POT[:, 1])
    assert (rms1000 < 1.1)
Beispiel #6
0
BKO2 = smodel.SReac('BKO2',
                    ssys_stoch,
                    slhs=[BK_O3],
                    srhs=[BK_O2],
                    irhs=[Ca_stoch],
                    kcst=o_32)
BKO3 = smodel.SReac('BKO3',
                    ssys_stoch,
                    slhs=[BK_O4],
                    srhs=[BK_O3],
                    irhs=[Ca_stoch],
                    kcst=o_43)

BKC0O0 = smodel.VDepSReac('BKC0O0',
                          ssys_stoch,
                          slhs=[BK_C0],
                          srhs=[BK_O0],
                          k=lambda V: f_0(V))
BKC1O1 = smodel.VDepSReac('BKC1O1',
                          ssys_stoch,
                          slhs=[BK_C1],
                          srhs=[BK_O1],
                          k=lambda V: f_1(V))
BKC2O2 = smodel.VDepSReac('BKC2O2',
                          ssys_stoch,
                          slhs=[BK_C2],
                          srhs=[BK_O2],
                          k=lambda V: f_2(V))
BKC3O3 = smodel.VDepSReac('BKC3O3',
                          ssys_stoch,
                          slhs=[BK_C3],
Beispiel #7
0
                       kcst=0.0)

######## CaT channel ##########

CaTchan = smodel.Chan('CaTchan', mdl_stoch)

CaT_m0h0 = smodel.ChanState('CaT_m0h0', mdl_stoch, CaTchan)
CaT_m0h1 = smodel.ChanState('CaT_m0h1', mdl_stoch, CaTchan)
CaT_m1h0 = smodel.ChanState('CaT_m1h0', mdl_stoch, CaTchan)
CaT_m1h1 = smodel.ChanState('CaT_m1h1', mdl_stoch, CaTchan)
CaT_m2h0 = smodel.ChanState('CaT_m2h0', mdl_stoch, CaTchan)
CaT_m2h1 = smodel.ChanState('CaT_m2h1', mdl_stoch, CaTchan)

CaTm0h0_m1h0 = smodel.VDepSReac('CaTm0h0_m1h0',
                                ssys_stoch,
                                slhs=[CaT_m0h0],
                                srhs=[CaT_m1h0],
                                k=lambda V: 1.0e3 * 2. * alpham_cat(V * 1.0e3))
CaTm1h0_m2h0 = smodel.VDepSReac('CaTm1h0_m2h0',
                                ssys_stoch,
                                slhs=[CaT_m1h0],
                                srhs=[CaT_m2h0],
                                k=lambda V: 1.0e3 * 1. * alpham_cat(V * 1.0e3))

CaTm2h0_m1h0 = smodel.VDepSReac('CaTm2h0_m1h0',
                                ssys_stoch,
                                slhs=[CaT_m2h0],
                                srhs=[CaT_m1h0],
                                k=lambda V: 1.0e3 * 2. * betam_cat(V * 1.0e3))
CaTm1h0_m0h0 = smodel.VDepSReac('CaTm1h0_m0h0',
                                ssys_stoch,