def build_model(mesh, param): mdl = smodel.Model() memb = sgeom.castToTmPatch(mesh.getPatch('memb')) ssys = smodel.Surfsys('ssys', mdl) memb.addSurfsys('ssys') L = smodel.Chan('L', mdl) Leak = smodel.ChanState('Leak', mdl, L) # membrane conductance area_cylinder = np.pi * param['diameter'] * param['length'] L_G_tot = area_cylinder / param['R_M'] g_leak_sc = L_G_tot / len(memb.tris) OC_L = smodel.OhmicCurr('OC_L', ssys, chanstate = Leak, erev = param['E_M'], g = g_leak_sc) return mdl
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()
kcst=diro2_t) SKO1C3 = smodel.SReac('SKO1C3', ssys_stoch, slhs=[SK_O1], srhs=[SK_C3], kcst=invo1_t) SKO2C4 = smodel.SReac('SKO2C4', ssys_stoch, slhs=[SK_O2], srhs=[SK_C4], kcst=invo2_t) OC1_SK = smodel.OhmicCurr('OC1_SK', ssys_stoch, chanstate=SK_O1, erev=SK_rev, g=SK_G) OC2_SK = smodel.OhmicCurr('OC2_SK', ssys_stoch, chanstate=SK_O2, erev=SK_rev, g=SK_G) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ########### MESH & COMPARTMENTALIZATION ################# ##########Import Mesh
AMPAC2C1 = smodel.SReac('AMPAC2C1', ssys_chans, slhs = [AMPA_C2], srhs = [AMPA_C1], kcst = ru2) AMPAOC2 = smodel.SReac('AMPAOC2', ssys_chans, slhs = [AMPA_O], srhs = [AMPA_C2], kcst = rc) AMPAD1 = smodel.SReac('AMPAD1', ssys_chans, slhs = [AMPA_C1], srhs = [AMPA_D1], kcst = rd) AMPAD2 = smodel.SReac('AMPAD2', ssys_chans, slhs = [AMPA_C2], srhs = [AMPA_D2], kcst = rd) AMPARD1 = smodel.SReac('AMPARD1', ssys_chans, slhs = [AMPA_D1], srhs = [AMPA_C1], kcst = rr) AMPARD2 = smodel.SReac('AMPARD2', ssys_chans, slhs = [AMPA_D2], srhs = [AMPA_C2], kcst = rr) ###### Leak current channel ##### L = smodel.Chan('L', mdl_stoch) Leak = smodel.ChanState('Leak', mdl_stoch, L) OC_L = smodel.OhmicCurr('OC_L', ssys_stoch, chanstate = Leak, erev = L_rev, g = L_G) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ########### MESH & COMPARTMENTALIZATION ################# ##########Import Mesh for EField calculation # For stochastic sim: meshfile_ab = 'chop_mesh.inp' mesh_stoch, nodep, tetp, trip = meshio.importAbaqus('./meshes/'+meshfile_ab,1e-6) tetgroups = tetp.blocksToGroups()
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) OC_K = smodel.OhmicCurr('OC_K', ssys, chanstate=K_n4, g=K_G, erev=K_rev) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Sodium channel Nachan = smodel.Chan('Nachan', mdl) Na_m0h0 = smodel.ChanState('Na_m0h0', mdl, Nachan) Na_m1h0 = smodel.ChanState('Na_m1h0', mdl, Nachan) Na_m2h0 = smodel.ChanState('Na_m2h0', mdl, Nachan) Na_m3h0 = smodel.ChanState('Na_m3h0', mdl, Nachan) Na_m0h1 = smodel.ChanState('Na_m0h1', mdl, Nachan) Na_m1h1 = smodel.ChanState('Na_m1h1', mdl, Nachan) Na_m2h1 = smodel.ChanState('Na_m2h1', mdl, Nachan) Na_m3h1 = smodel.ChanState('Na_m3h1', mdl, Nachan) Na_m0h1_m1h1 = smodel.VDepSReac('Na_m0h1_m1h1', ssys, \
ssys, slhs=[BK_O2], srhs=[BK_C2], k=lambda V: b_2(V)) BKO3C3 = smodel.VDepSReac('BKO3C3', ssys, slhs=[BK_O3], srhs=[BK_C3], k=lambda V: b_3(V)) BKO4C4 = smodel.VDepSReac('BKO4C4', ssys, slhs=[BK_O4], srhs=[BK_C4], k=lambda V: b_4(V)) OC_BK0 = smodel.OhmicCurr('OC_BK0', ssys, chanstate=BK_O0, erev=BK_rev, g=BK_G) OC_BK1 = smodel.OhmicCurr('OC_BK1', ssys, chanstate=BK_O1, erev=BK_rev, g=BK_G) OC_BK2 = smodel.OhmicCurr('OC_BK2', ssys, chanstate=BK_O2, erev=BK_rev, g=BK_G) OC_BK3 = smodel.OhmicCurr('OC_BK3', ssys, chanstate=BK_O3, erev=BK_rev, g=BK_G) OC_BK4 = smodel.OhmicCurr('OC_BK4', ssys, chanstate=BK_O4, erev=BK_rev, g=BK_G) ###### SK channel ################## DETERMINISTIC SKchan = smodel.Chan('SKchan', mdl) SK_C1 = smodel.ChanState('SK_C1', mdl, SKchan) SK_C2 = smodel.ChanState('SK_C2', mdl, SKchan) SK_C3 = smodel.ChanState('SK_C3', mdl, SKchan) SK_C4 = smodel.ChanState('SK_C4', mdl, SKchan) SK_O1 = smodel.ChanState('SK_O1', mdl, SKchan) SK_O2 = smodel.ChanState('SK_O2', mdl, SKchan)
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('./meshes/' + meshfile)[0] cyto = sgeom.TmComp('cyto', mesh, range(mesh.ntets)) # The tetrahedrons from which to record potential POT_TET = zeros(POT_N, dtype='uint') i = 0
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') corr_fac_area = memb.getArea() / surfarea_cyl membrane = sgeom.Memb('membrane', mesh, [memb]) # 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 random number generator r = srng.create('mt19937', 512) r.initialize(7) # Create solver object sim = ssolver.Tetexact(mdl, mesh, r, True) surfarea_mesh = sim.getPatchArea('memb') surfarea_cyl = 1.0 * math.pi * 1000 * 1e-12 vol_cyl = math.pi * (diam / 2.0) * (diam / 2.0) * 1000 * 1e-18 vol_mesh = sim.getCompVol('cyto')
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)
srhs=[BK_C2], k=lambda V: b_2(V)) BKO3C3 = smodel.VDepSReac('BKO3C3', ssys_stoch, slhs=[BK_O3], srhs=[BK_C3], k=lambda V: b_3(V)) BKO4C4 = smodel.VDepSReac('BKO4C4', ssys_stoch, slhs=[BK_O4], srhs=[BK_C4], k=lambda V: b_4(V)) OC_BK0 = smodel.OhmicCurr('OC_BK0', ssys_stoch, chanstate=BK_O0, erev=BK_rev, g=BK_G) OC_BK1 = smodel.OhmicCurr('OC_BK1', ssys_stoch, chanstate=BK_O1, erev=BK_rev, g=BK_G) OC_BK2 = smodel.OhmicCurr('OC_BK2', ssys_stoch, chanstate=BK_O2, erev=BK_rev, g=BK_G) OC_BK3 = smodel.OhmicCurr('OC_BK3', ssys_stoch, chanstate=BK_O3,