def setUp(self): self.model = smodel.Model() A = smodel.Spec('A', self.model) surfsys = smodel.Surfsys('ssys', self.model) D_a = smodel.Diff('D_a', surfsys, A) self.DCST = 0.2e-9 D_a.setDcst(self.DCST) self.mesh = meshio.importAbaqus2("directional_dcst_test/mesh_tet.inp", "directional_dcst_test/mesh_tri.inp", 1e-6, "directional_dcst_test/mesh_conf")[0] boundary_tris = self.mesh.getROIData("boundary") v1_tets = self.mesh.getROIData("v1_tets") comp1 = sgeom.TmComp("comp1", self.mesh, v1_tets) patch1 = sgeom.TmPatch("patch", self.mesh, boundary_tris, comp1) patch1.addSurfsys("ssys") self.neigh_tris = self.mesh.getROIData("neigh_tri") self.focus_tri = self.mesh.getROIData("focus_tri")[0] self.rng = srng.create('r123', 512) self.rng.initialize(1000) self.solver = solv.Tetexact(self.model, self.mesh, self.rng)
def setUp(self): DCST = 0.08e-10 self.model = smodel.Model() A = smodel.Spec('A', self.model) self.vsys = smodel.Volsys('vsys', self.model) self.ssys = smodel.Surfsys('ssys', self.model) self.diff = smodel.Diff("diff", self.vsys, A, DCST) self.sdiff = smodel.Diff("diff", self.ssys, A, DCST) if __name__ == "__main__": self.mesh = meshio.importAbaqus('meshes/test_mesh.inp', 1e-7)[0] else: self.mesh = meshio.importAbaqus( 'parallel_diff_sel_test/meshes/test_mesh.inp', 1e-7)[0] self.tmcomp = sgeom.TmComp('comp', self.mesh, range(self.mesh.ntets)) self.tmcomp.addVolsys('vsys') self.surf_tris = self.mesh.getSurfTris() self.tmpatch = sgeom.TmPatch('patch', self.mesh, self.surf_tris, icomp=self.tmcomp) self.tmpatch.addSurfsys('ssys') self.rng = srng.create('r123', 512) self.rng.initialize(1000)
def setUp(self): mdl = smodel.Model() S1 = smodel.Spec('S1', mdl) ssys = smodel.Surfsys('ssys', mdl) smodel.SReac('SR01', ssys, slhs=[S1], srhs=[S1], kcst=1) if __name__ == "__main__": mesh = meshio.importAbaqus('meshes/test.inp', 1e-7)[0] else: mesh = meshio.importAbaqus( 'tetODE_setPatchSReacK_bugfix_test/meshes/test.inp', 1e-7)[0] comp1 = sgeom.TmComp('comp1', mesh, range(mesh.countTets())) patch1 = sgeom.TmPatch('patch1', mesh, mesh.getSurfTris(), comp1) patch1.addSurfsys('ssys') rng = srng.create('mt19937', 512) rng.initialize(1234) self.sim = ssolver.TetODE(mdl, mesh, rng) self.sim.setTolerances(1.0e-3, 1.0e-3)
def setUp(self): self.model = smodel.Model() self.vsys1 = smodel.Volsys('vsys1', self.model) self.ssys1 = smodel.Surfsys('ssys1', self.model) if __name__ == "__main__": self.mesh = meshio.loadMesh('meshes/cyl_len10_diam1')[0] else: self.mesh = meshio.loadMesh( 'getROIArea_bugfix_test/meshes/cyl_len10_diam1')[0] ntets = self.mesh.countTets() comp1Tets, comp2Tets = [], [] comp1Tris, comp2Tris = set(), set() for i in range(ntets): if self.mesh.getTetBarycenter(i)[0] > 0: comp1Tets.append(i) comp1Tris |= set(self.mesh.getTetTriNeighb(i)) else: comp2Tets.append(i) comp2Tris |= set(self.mesh.getTetTriNeighb(i)) patch1Tris = list(comp1Tris & comp2Tris) self.comp1 = sgeom.TmComp('comp1', self.mesh, comp1Tets) self.comp2 = sgeom.TmComp('comp2', self.mesh, comp2Tets) self.comp1.addVolsys('vsys1') self.comp2.addVolsys('vsys1') self.patch1 = sgeom.TmPatch('patch1', self.mesh, patch1Tris, self.comp1, self.comp2) self.patch1.addSurfsys('ssys1') self.ROI1 = self.mesh.addROI('ROI1', sgeom.ELEM_TRI, patch1Tris)
def setUp(self): DCST = 0.08e-10 self.model = smodel.Model() A = smodel.Spec('A', self.model) self.vsys = smodel.Volsys('vsys', self.model) self.ssys = smodel.Surfsys('ssys', self.model) self.diff = smodel.Diff("diff", self.vsys, A, DCST) self.sdiff = smodel.Diff("diff", self.ssys, A, DCST) if __name__ == "__main__": self.mesh = meshio.importAbaqus('meshes/test_mesh.inp', 1e-7)[0] else: self.mesh = meshio.importAbaqus( 'parallel_std_string_bugfix_test/meshes/test_mesh.inp', 1e-7)[0] self.tmcomp = sgeom.TmComp('comp', self.mesh, range(self.mesh.ntets)) self.tmcomp.addVolsys('vsys') self.surf_tris = self.mesh.getSurfTris() self.tmpatch = sgeom.TmPatch('patch', self.mesh, self.surf_tris, icomp=self.tmcomp) self.tmpatch.addSurfsys('ssys') self.rng = srng.create('r123', 512) self.rng.initialize(1000) tet_hosts = gd.binTetsByAxis(self.mesh, steps.mpi.nhosts) tri_hosts = gd.partitionTris(self.mesh, tet_hosts, self.surf_tris) self.solver = solv.TetOpSplit(self.model, self.mesh, self.rng, solv.EF_NONE, tet_hosts, tri_hosts) self.solver.reset()
def gen_model(): mdl = smodel.Model() X = smodel.Spec('X', mdl) ssys = smodel.Surfsys('ssys', mdl) diff_X = smodel.Diff('diffX', ssys, X, DCST) return mdl
def gen_model(): mdl = smodel.Model() A = smodel.Spec('A', mdl) ssys = smodel.Surfsys('ssys', mdl) diff_A = smodel.Diff('diffA', ssys, A, DCST) return mdl
def setUp(self): self.model = smodel.Model() A = smodel.Spec("A", self.model) B = smodel.Spec("B", self.model) C = smodel.Spec("C", self.model) D = smodel.Spec("D", self.model) E = smodel.Spec("E", self.model) self.vsys1 = smodel.Volsys('vsys1', self.model) self.vsys2 = smodel.Volsys('vsys2', self.model) self.ssys1 = smodel.Surfsys('ssys1', self.model) self.reac1 = smodel.Reac('reac1', self.vsys1, lhs = [A], rhs = [A], kcst = 1e5) self.reac2 = smodel.Reac('reac2', self.vsys2, lhs = [E], rhs = [E], kcst = 1e4) self.sreac = smodel.SReac('sreac', self.ssys1, slhs = [B], srhs = [B], kcst = 1e3) if __name__ == "__main__": self.mesh = meshio.loadMesh('meshes/cyl_len10_diam1')[0] else: self.mesh = meshio.loadMesh('getROIArea_bugfix_test/meshes/cyl_len10_diam1')[0] ntets = self.mesh.countTets() comp1Tets, comp2Tets = [], [] comp1Tris, comp2Tris = set(), set() for i in range(ntets): if self.mesh.getTetBarycenter(i)[0] > 0: comp1Tets.append(i) comp1Tris |= set(self.mesh.getTetTriNeighb(i)) else: comp2Tets.append(i) comp2Tris |= set(self.mesh.getTetTriNeighb(i)) patch1Tris = list(comp1Tris & comp2Tris) self.comp1 = sgeom.TmComp('comp1', self.mesh, comp1Tets) self.comp2 = sgeom.TmComp('comp2', self.mesh, comp2Tets) self.comp1.addVolsys('vsys1') self.comp2.addVolsys('vsys2') self.patch1 = sgeom.TmPatch('patch1', self.mesh, patch1Tris, self.comp1, self.comp2) self.patch1.addSurfsys('ssys1') self.ROI1 = self.mesh.addROI('ROI1', sgeom.ELEM_TET, comp1Tets) self.ROI2 = self.mesh.addROI('ROI2', sgeom.ELEM_TET, comp2Tets) self.ROI3 = self.mesh.addROI('ROI3', sgeom.ELEM_TRI, patch1Tris) self.rng = srng.create('r123', 512) self.rng.initialize(1000) tet_hosts = gd.linearPartition(self.mesh, [steps.mpi.nhosts, 1, 1]) tri_hosts = gd.partitionTris(self.mesh, tet_hosts, patch1Tris) self.solver = solv.TetOpSplit(self.model, self.mesh, self.rng, solv.EF_NONE, tet_hosts, tri_hosts)
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() self.v1 = 1e-20 self.v2 = 2e-20 self.a1 = 3e-14 self.kreac = 200.0 self.ksreac = 100.0 S1 = smodel.Spec('S1', mdl) S2 = smodel.Spec('S2', mdl) S1S2 = smodel.Spec('S1S2', mdl) vsys = smodel.Volsys('vsys', mdl) ssys = smodel.Surfsys('ssys', mdl) smodel.Reac('reac', vsys, lhs=[S1, S2], rhs=[S2, S2], kcst=self.kreac) smodel.SReac('sreac', ssys, ilhs=[S1], slhs=[S2], srhs=[S1S2], kcst=self.ksreac) geom = sgeom.Geom() comp1 = sgeom.Comp('comp1', geom) comp1.setVol(self.v1) comp1.addVolsys('vsys') comp2 = sgeom.Comp('comp2', geom) comp2.setVol(self.v2) comp1.addVolsys('vsys') patch = sgeom.Patch('patch', geom, comp1, comp2) patch.addSurfsys('ssys') patch.setArea(self.a1) self.mdl, self.geom, self.rng = mdl, geom, srng.create('mt19937',512) self.rng.initialize(1234)
# # Katri Hituri # IP3R model by Doi et al. 2005 ########### # Import packages import steps.model as smodel import steps.geom as sgeom # *MODEL* # mdl = smodel.Model() volsys = smodel.Volsys('vsys', mdl) # Volume system surfsys = smodel.Surfsys('ssys', mdl) # Surface system # CHEMICAL SPECIES Ca = smodel.Spec('Ca', mdl) # Calcium IP3 = smodel.Spec('IP3', mdl) # IP3 # IP3 receptor states R = smodel.Spec('R', mdl) # IP3 receptor with no bound ligands RIP3 = smodel.Spec('RIP3', mdl) # bound IP3 Ropen = smodel.Spec('Ropen', mdl) # bound IP3 and Ca (open) RCa = smodel.Spec('RCa', mdl) # 1 bound Ca to inactivation site RCa2 = smodel.Spec('RCa2', mdl) # 2 bound Ca to inactivation sites RCa3 = smodel.Spec('RCa3', mdl) # 3 bound Ca to inactivation sites RCa4 = smodel.Spec('RCa4', mdl) # 4 bound Ca to inactivation sites # REACTIONS
def test_soirev2d(): VOL = 1.0e-18 COUNTA = 100.0 n=2.0 COUNTB = COUNTA/n KCST = 10.0e10 # The reaction constant AREA = 10.0e-12 CCST = KCST/(6.02214179e23*AREA) NITER = 1000 # The number of iterations DT = 0.05 # Sampling time-step INT = 1.05 # Sim endtime # In tests fewer than 0.1% fail with tolerance of 2% tolerance = 2.0/100 ######################################################################## mdl = smod.Model() A = smod.Spec('A', mdl) B = smod.Spec('B', mdl) C = smod.Spec('C', mdl) surfsys = smod.Surfsys('ssys',mdl) SR1 = smod.SReac('SR1', surfsys, slhs = [A, B], srhs = [C], kcst = KCST) geom = sgeom.Geom() comp1 = sgeom.Comp('comp1', geom, VOL) patch1 = sgeom.Patch('patch1', geom, comp1, area = AREA) patch1.addSurfsys('ssys') import random rng = srng.create('mt19937', 1000) rng.initialize(int(random.random()*4294967295)) sim = ssolv.Wmdirect(mdl, geom, rng) sim.reset() tpnts = numpy.arange(0.0, INT, DT) ntpnts = tpnts.shape[0] res_m = numpy.zeros([NITER, ntpnts, 3]) for i in range (0, NITER): sim.restore('./validation_cp/cp/second_order_irev_2D') for t in range(0, ntpnts): sim.run(tpnts[t]) res_m[i, t, 0] = sim.getPatchCount('patch1', 'A') res_m[i, t, 1] = sim.getPatchCount('patch1', 'B') mean_res = numpy.mean(res_m, 0) lnBA = numpy.zeros(ntpnts) lineAB = numpy.zeros(ntpnts) C = COUNTA-COUNTB passed =True max_err = 0.0 for i in range(ntpnts): A = mean_res[i][0] B = mean_res[i][1] lnBA[i] = math.log(B/A) lineAB[i] = math.log(COUNTB/COUNTA) -C*CCST*tpnts[i] assert(tol_funcs.tolerable(lnBA[i], lineAB[i], tolerance))
def getModel(): # Create model container mdl = smod.Model() # Create chemical species ca = smod.Spec('ca', mdl) ip3 = smod.Spec('ip3', mdl) plc = smod.Spec('plc', mdl) # Create calcium buffers GCaMP6s = smod.Spec('GCaMP6s', mdl) ca_GCaMP6s = smod.Spec('ca_GCaMP6s', mdl) # Create IP3R states species unb_IP3R = smod.Spec('unb_IP3R', mdl) ip3_IP3R = smod.Spec('ip3_IP3R', mdl) caa_IP3R = smod.Spec('caa_IP3R', mdl) cai_IP3R = smod.Spec('cai_IP3R', mdl) open_IP3R = smod.Spec('open_IP3R', mdl) cai_ip3_IP3R = smod.Spec('cai_ip3_IP3R', mdl) ca2_IP3R = smod.Spec('ca2_IP3R', mdl) ca2_ip3_IP3R = smod.Spec('ca2_ip3_IP3R', mdl) # ER surface sys ssys = smod.Surfsys('ssys', mdl) # plasma membrane surface mb_surf = smod.Surfsys('mb_surf', mdl) # Create volume system # cytosol volume system vsys = smod.Volsys('vsys', mdl) # ER volume system er_vsys = smod.Volsys('er_vsys', mdl) ################################## ##### DEFINE DIFFUSION RULES ##### ################################## # Diffusion constants # Diffusion constant of Calcium (buffered) DCST = 0.013e-9 # Diffusion constant of IP3 DIP3 = 0.280e-9 # Diffusion constant of GCaMP6s DGCAMP = 0.050e-9 diff_freeca = smod.Diff('diff_freeca', vsys, ca, DCST) diff_ip3 = smod.Diff('diff_ip3', vsys, ip3, DIP3) diff_GCaMP6s = smod.Diff('diff_GCaMP6s', vsys, GCaMP6s, DGCAMP) diff_ca_GCaMP6s = smod.Diff('diff_ca_GCaMP6s', vsys, ca_GCaMP6s, DGCAMP) ################################## ######## DEFINE REACTIONS ######## ################################## #### Calcium in and out and Buffering Reactions #### # Ca -> null ca_deg = smod.Reac('ca_deg', vsys, lhs=[ca]) # Ca leak ca_leak = smod.Reac('ca_leak', vsys, rhs=[ca]) # Calcium binding to GCaMP6s molecules GCaMP6s_bind_ca_f = smod.Reac('GCaMP6s_bind_ca_f', vsys, \ lhs=[ca, GCaMP6s], rhs=[ca_GCaMP6s]) GCaMP6s_bind_ca_b = smod.Reac('GCaMP6s_bind_ca_b', vsys, \ lhs=[ca_GCaMP6s], rhs=[GCaMP6s, ca]) #### IP3 Influx and Buffering Reactions ###### # IP3 leak ip3_leak = smod.Reac('ip3_leak', vsys, rhs=[ip3]) # IP3 degradation ip3_deg = smod.Reac('ip3_deg', vsys, lhs=[ip3]) # ca activating plc_delta-dependent IP3 synthesis plc_ip3_synthesis = smod.SReac('plc_ip3_synthesis', mb_surf, \ slhs=[plc], ilhs= [ca], srhs=[plc], irhs= [ca, ip3]) ##### IP3R kinetics ##### # surface/volume reaction ca from cytosol binds activating IP3R site on unbound IP3R unb_IP3R_bind_caa_f = smod.SReac('unb_IP3R_bind_caa_f', ssys,\ ilhs=[ca], slhs=[unb_IP3R], srhs=[caa_IP3R]) unb_IP3R_bind_caa_b = smod.SReac('unb_IP3R_bind_caa_b', ssys, \ slhs=[caa_IP3R], srhs=[unb_IP3R], irhs=[ca]) # surface/volume reaction ca from cytosol binds inactivating IP3R site on unbound IP3R unb_IP3R_bind_cai_f = smod.SReac('unb_IP3R_bind_cai_f', ssys, \ ilhs=[ca], slhs=[unb_IP3R], srhs=[cai_IP3R]) unb_IP3R_bind_cai_b = smod.SReac('unb_IP3R_bind_cai_b', ssys, \ slhs=[cai_IP3R], srhs=[unb_IP3R], irhs=[ca]) # surface/volume reaction ca from cytosol binds activating IP3R site on caa_IP3R caa_IP3R_bind_ca_f = smod.SReac('caa_IP3R_bind_ca_f', ssys, \ ilhs=[ca], slhs=[caa_IP3R], srhs=[ca2_IP3R]) caa_IP3R_bind_ca_b = smod.SReac('caa_IP3R_bind_ca_b', ssys, \ slhs=[ca2_IP3R], srhs=[caa_IP3R], irhs=[ca]) # surface/volume reaction ca from cytosol binds activating IP3R site on ip3_IP3R ip3_IP3R_bind_caa_f = smod.SReac('ip3_IP3R_bind_caa_f', ssys, \ ilhs=[ca], slhs=[ip3_IP3R], srhs=[open_IP3R]) ip3_IP3R_bind_caa_b = smod.SReac('ip3_IP3R_bind_caa_b', ssys, \ slhs=[open_IP3R], srhs=[ip3_IP3R], irhs=[ca]) # surface/volume reaction ca from cytosol binds inactivating IP3R site on ip3_IP3R ip3_IP3R_bind_cai_f = smod.SReac('ip3_IP3R_bind_cai_f', ssys, \ ilhs=[ca], slhs=[ip3_IP3R], srhs=[cai_ip3_IP3R]) ip3_IP3R_bind_cai_b = smod.SReac('ip3_IP3R_bind_cai_b', ssys, \ slhs=[cai_ip3_IP3R], srhs=[ip3_IP3R], irhs=[ca]) # surface/volume reaction ca from cytosol binds activating IP3R site on cai_IP3R cai_IP3R_bind_ca_f = smod.SReac('cai_IP3R_bind_ca_f', ssys, \ ilhs=[ca], slhs=[cai_IP3R], srhs=[ca2_IP3R]) cai_IP3R_bind_ca_b = smod.SReac('cai_IP3R_bind_ca_b', ssys, \ slhs=[ca2_IP3R], srhs=[cai_IP3R], irhs=[ca]) # surface/volume reaction ca from cytosol binds inactivating IP3R site on open_IP3R open_IP3R_bind_ca_f = smod.SReac('open_IP3R_bind_ca_f', ssys, \ ilhs=[ca], slhs=[open_IP3R], srhs=[ca2_ip3_IP3R]) open_IP3R_bind_ca_b = smod.SReac('open_IP3R_bind_ca_b', ssys, \ slhs=[ca2_ip3_IP3R], srhs=[open_IP3R], irhs=[ca]) # surface/volume reaction ca from cytosol binds activating IP3R site on cai_ip3_IP3R cai_ip3_IP3R_bind_ca_f = smod.SReac('cai_ip3_IP3R_bind_ca_f', ssys, \ ilhs=[ca], slhs=[cai_ip3_IP3R], srhs=[ca2_ip3_IP3R]) cai_ip3_IP3R_bind_ca_b = smod.SReac('cai_ip3_IP3R_bind_ca_b', ssys, \ slhs=[ca2_ip3_IP3R], srhs=[cai_ip3_IP3R], irhs=[ca]) # surface/volume reaction ip3 from cytosol binds unb_IP3R unb_IP3R_bind_ip3_f = smod.SReac('unb_IP3R_bind_ip3_f', ssys, \ ilhs=[ip3], slhs=[unb_IP3R], srhs=[ip3_IP3R]) unb_IP3R_bind_ip3_b = smod.SReac('unb_IP3R_bind_ip3_b', ssys, \ slhs=[ip3_IP3R], srhs=[unb_IP3R], irhs=[ip3]) # surface/volume reaction ip3 from cytosol binds caa_IP3R caa_IP3R_bind_ip3_f = smod.SReac('caa_IP3R_bind_ip3_f', ssys, \ ilhs=[ip3], slhs=[caa_IP3R], srhs=[open_IP3R]) caa_IP3R_bind_ip3_b = smod.SReac('caa_IP3R_bind_ip3_b', ssys, \ slhs=[open_IP3R], srhs=[caa_IP3R], irhs=[ip3]) # surface/volume reaction ip3 from cytosol binds cai_IP3R cai_IP3R_bind_ip3_f = smod.SReac('cai_IP3R_bind_ip3_f', ssys, \ ilhs=[ip3], slhs=[cai_IP3R], srhs=[cai_ip3_IP3R]) cai_IP3R_bind_ip3_b = smod.SReac('cai_IP3R_bind_ip3_b', ssys, \ slhs=[cai_ip3_IP3R], srhs=[cai_IP3R], irhs=[ip3]) # surface/volume reaction ip3 from cytosol binds ca2_IP3R ca2_IP3R_bind_ip3_f = smod.SReac('ca2_IP3R_bind_ip3_f', ssys, \ ilhs=[ip3], slhs=[ca2_IP3R], srhs=[ca2_ip3_IP3R]) ca2_IP3R_bind_ip3_b = smod.SReac('ca2_IP3R_bind_ip3_b', ssys, \ slhs=[ca2_ip3_IP3R], srhs=[ca2_IP3R], irhs=[ip3]) ##### Ca ions passing through open IP3R channel to cytosol ##### Ca_IP3R_flux = smod.SReac('R_Ca_channel_f', ssys, \ slhs=[open_IP3R], irhs=[ca], srhs=[open_IP3R]) ################################## #### REACTION CONSTANT VALUES #### ################################## ##### Calcium Influx and Buffering Reactions ##### # GCaMP6s mediated calcium buffering GCaMP6s_bind_ca_f.setKcst(7.78e6) GCaMP6s_bind_ca_b.setKcst(1.12) ############# VALUES FOR GCAMP6f ################# #### GCaMP6s_bind_ca_f.setKcst(1.05e7) #### #### GCaMP6s_bind_ca_b.setKcst(3.93) #### ################################################## # Ca -> null ca_deg.setKcst(30) # Ca leak ca_leak.setKcst(15e-8) ##### IP3 Influx and Buffering Reactions ##### # IP3 leak does not exist in this model. IP3 synthesis only occurs through PLC activity # IP3 -> null ip3_deg.setKcst(1.2e-4) # ca activating plc_delta-dependent IP3 synthesis plc_ip3_synthesis.setKcst(1) #### IP3R kinetics ##### caa_f = 1.2e6 cai_f = 1.6e4 ip3_f = 4.1e7 caa_b = 5e1 cai_b = 1e2 ip3_b = 4e2 unb_IP3R_bind_caa_f.setKcst(caa_f) unb_IP3R_bind_caa_b.setKcst(caa_b) unb_IP3R_bind_cai_f.setKcst(cai_f) unb_IP3R_bind_cai_b.setKcst(cai_b) caa_IP3R_bind_ca_f.setKcst(cai_f) caa_IP3R_bind_ca_b.setKcst(cai_b) ip3_IP3R_bind_caa_f.setKcst(caa_f) ip3_IP3R_bind_caa_b.setKcst(caa_b) ip3_IP3R_bind_cai_f.setKcst(cai_f) ip3_IP3R_bind_cai_b.setKcst(cai_b) cai_IP3R_bind_ca_f.setKcst(caa_f) cai_IP3R_bind_ca_b.setKcst(caa_b) open_IP3R_bind_ca_f.setKcst(cai_f) open_IP3R_bind_ca_b.setKcst(cai_b) unb_IP3R_bind_ip3_f.setKcst(ip3_f) unb_IP3R_bind_ip3_b.setKcst(ip3_b) caa_IP3R_bind_ip3_f.setKcst(ip3_f) caa_IP3R_bind_ip3_b.setKcst(ip3_b) cai_IP3R_bind_ip3_f.setKcst(ip3_f) cai_IP3R_bind_ip3_b.setKcst(ip3_b) cai_ip3_IP3R_bind_ca_f.setKcst(caa_f) cai_ip3_IP3R_bind_ca_b.setKcst(caa_b) ca2_IP3R_bind_ip3_f.setKcst(ip3_f) ca2_IP3R_bind_ip3_b.setKcst(ip3_b) # Ca ions passing through open IP3R channel Ca_IP3R_flux.setKcst(6e3) return mdl
Ob = smodel.Spec('Ob', mdl) Oc = smodel.Spec('Oc', mdl) Ia = smodel.Spec('Ia', mdl) Ib = smodel.Spec('Ib', mdl) A01 = smodel.Spec('A01', mdl) Pa = smodel.Spec('Pa', mdl) Pb = smodel.Spec('Pb', mdl) Pc = smodel.Spec('Pc', mdl) Sa = smodel.Spec('Sa', mdl) Sb = smodel.Spec('Sb', mdl) #create the volume system vsys = smodel.Volsys('vsys', mdl) #surface system is similar to the valume system. surfsys = smodel.Surfsys('ssys', mdl) #the forward reaction without the forward binding reaction A11_to_Oa_f = smodel.SReac('A11_to_Oa_f', surfsys, slhs=[A11], srhs=[Oa], kcst=1800) Oa_to_Ob_f = smodel.SReac('Oa_to_Ob_f', surfsys, slhs=[Oa], srhs=[Ob], kcst=133) Oc_to_Ia_f = smodel.SReac('Oc_to_Ia_f', surfsys, slhs=[Oc],
ax.set_title('MESH FILE: {}'.format(meshfile), fontsize=16, color='red', fontweight='bold') ax.scatter(cbaryc[0], cbaryc[1], cbaryc[2], s=30, marker='d') ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('z') model = smodel.Model() vsys0 = smodel.Volsys('vsys0', model) # cytosol vsys1 = smodel.Volsys('vsys1', model) # ER surfsys0 = smodel.Surfsys('surfsys0', model) # cytosol membrane surfsys2 = smodel.Surfsys('surfsys2', model) # ER memb ssys = smodel.Surfsys('ssys', model) # AZ ########## Initial Membrane Potential ######### init_pot = -60e-3 vrange = [-400.0e-3, 400e-3, 1e-4] ########## BULK RESISTIVITY ########## Ra = 235.7 * 1.0e-2 # Calcium channel Ca = smodel.Spec('Ca', model) # Ca_Ch = smodel.Spec('Ca_Ch', model) # Ca_sens = smodel.Spec('Ca_sens', model)
# CBCaf CBCaf = smodel.Spec('CBCaf', mdl_WM) # CBCaCa CBCaCa = smodel.Spec('CBCaCa', mdl_WM) # PV PV = smodel.Spec('PV', mdl_WM) # PVMg PVMg = smodel.Spec('PVMg', mdl_WM) # PVCa PVCa = smodel.Spec('PVCa', mdl_WM) # Mg Mg = smodel.Spec('Mg', mdl_WM) ssys_diff = smodel.Surfsys('ssys_diff', mdl_WM) ssys_chans = smodel.Surfsys('ssys_chans', mdl_WM) vsys_buffs = smodel.Volsys('vsys_buffs', mdl_WM) #for EField ssys_stoch = smodel.Surfsys('ssys_stoch', mdl_stoch) # Diffusions diff_Ca_inward = smodel.SReac('diff_Ca_inward', ssys_diff, olhs=[Ca], irhs=[Ca], kcst=0) diff_Ca_outward = smodel.SReac('diff_Ca_outward', ssys_diff, ilhs=[Ca], orhs=[Ca], kcst=0) diff_CBsf_inward = smodel.SReac('diff_CBsf_inward', ssys_diff, olhs=[CBsf], irhs=[CBsf], kcst=0) diff_CBsf_outward = smodel.SReac('diff_CBsf_outward', ssys_diff, ilhs=[CBsf], orhs=[CBsf], kcst=0)
def setUp(self): self.DCST = 0.08e-12 self.model = smodel.Model() A = smodel.Spec('A', self.model) X = smodel.Spec('X', self.model) self.ssys1 = smodel.Surfsys('ssys1', self.model) self.ssys2 = smodel.Surfsys('ssys2', self.model) self.sreac = smodel.SReac('sreac', self.ssys1, slhs = [A], srhs = [A], kcst = 1e5) self.diff1 = smodel.Diff('diffX1', self.ssys1, X, self.DCST) self.diff2 = smodel.Diff('diffX2', self.ssys2, X, self.DCST) if __name__ == "__main__": self.mesh = meshio.loadMesh('meshes/coin_10r_1h_13861')[0] else: self.mesh = meshio.loadMesh('sdiff_bugfix_test/meshes/coin_10r_1h_13861')[0] ntets = self.mesh.countTets() self.comp = sgeom.TmComp('cyto', self.mesh, range(ntets)) alltris = self.mesh.getSurfTris() patchA_tris = [] patchB_tris = [] patchA_bars = set() patchB_bars = set() for t in alltris: vert0, vert1, vert2 = self.mesh.getTri(t) if (self.mesh.getVertex(vert0)[2] > 0.0 \ and self.mesh.getVertex(vert1)[2] > 0.0 \ and self.mesh.getVertex(vert2)[2] > 0.0): if self.mesh.getTriBarycenter(t)[0] > 0.0: patchA_tris.append(t) bar = self.mesh.getTriBars(t) patchA_bars.add(bar[0]) patchA_bars.add(bar[1]) patchA_bars.add(bar[2]) else: patchB_tris.append(t) bar = self.mesh.getTriBars(t) patchB_bars.add(bar[0]) patchB_bars.add(bar[1]) patchB_bars.add(bar[2]) self.patchA = sgeom.TmPatch('patchA', self.mesh, patchA_tris, icomp = self.comp) self.patchA.addSurfsys('ssys1') self.patchB = sgeom.TmPatch('patchB', self.mesh, patchB_tris, icomp = self.comp) self.patchB.addSurfsys('ssys2') # Find the set of bars that connect the two patches as the intersecting bars barsDB = patchA_bars.intersection(patchB_bars) barsDB=list(barsDB) # Create the surface diffusion boundary self.diffb = sgeom.SDiffBoundary('sdiffb', self.mesh, barsDB, [self.patchA, self.patchB]) ctetidx = self.mesh.findTetByPoint([0.0, 0.0, 0.5e-6]) ctet_trineighbs = self.mesh.getTetTriNeighb(ctetidx) self.ctri_idx=-1 for t in ctet_trineighbs: if t in patchA_tris+patchB_tris: self.ctri_idx = t self.rng = srng.create('r123', 512) self.rng.initialize(1000) self.solver = solv.Tetexact(self.model, self.mesh, self.rng)
def model(tissue): """ initialises model using tissue array """ mdl = smodel.Model() unique_p = [] for cell in tissue: [unique_p.append(p) for p in cell.prtcl_names if p not in unique_p] NP = [] NPi = [] NPR = [] # Create particles and corresponding species for p in unique_p: # Free NPs NP.append(smodel.Spec('N{}'.format(p), mdl)) # internalised NPs NPi.append(smodel.Spec('N{}i'.format(p), mdl)) # complexes state: NPs bound to a cell receptor # NPR.append(smodel.Spec('N{}R'.format(p), mdl)) # receptor state: 'naive' state (no bound NPs) R = smodel.Spec('R', mdl) NPR = smodel.Spec('NPR', mdl) d = {} rxn_ = {} dfsn_ = {} # Lpop where cell and particle properties are connected to reactions for n, cell in enumerate(tissue): for p_idx, p in enumerate(unique_p): tag = str(n) + p prtcl = getattr(cell, p) d["surfsys{}".format(tag)] = smodel.Surfsys( "surfsys{}".format(tag), mdl) d["volsys{}".format(tag)] = smodel.Volsys("volsys{}".format(tag), mdl) k_diff = prtcl['D'] / (float(cell.S) * float(cell.S)) dfsn_["frwd_{}".format(tag)] = smodel.SReac( "frwd_{}".format(tag), d["surfsys{}".format(tag)], ilhs=[NP[p_idx]], orhs=[NP[p_idx]], kcst=k_diff) dfsn_["bkwd_{}".format(tag)] = smodel.SReac( "bkwd_{}".format(tag), d["surfsys{}".format(tag)], olhs=[NP[p_idx]], irhs=[NP[p_idx]], kcst=k_diff) # binding reactions: if 'k_a' in prtcl: k_bind = prtcl['k_a'] k_unbind = prtcl['k_d'] k_intern = prtcl['k_i'] rxn_["bind_{}".format(tag)] = smodel.Reac( "bind_{}".format(tag), d["volsys{}".format(tag)], lhs=[NP[p_idx], R], rhs=[NPR], kcst=k_bind) rxn_["unbind_{}".format(tag)] = smodel.Reac( "unbind_{}".format(tag), d["volsys{}".format(tag)], lhs=[NPR], rhs=[NP[p_idx], R], kcst=k_unbind) rxn_["intern_{}".format(tag)] = smodel.Reac( "intern_{}".format(tag), d["volsys{}".format(tag)], lhs=[NPR], rhs=[NPi[p_idx], R], kcst=k_intern) # Diffusion dfsn1 = smodel.Diff('dfsn1', d["volsys{}".format(tag)], NP[p_idx], dcst=k_diff) dfsn2 = smodel.Diff('dfsn2', d["volsys{}".format(tag)], NPR, dcst=k_diff) dfsn3 = smodel.Diff('dfsn3', d["volsys{}".format(tag)], R, dcst=k_diff) dfsn4 = smodel.Diff('dfsn4', d["volsys{}".format(tag)], NPi[p_idx], dcst=k_diff) return mdl
# CBCaCa CBCaCa = smodel.Spec('CBCaCa', mdl_det) # PV PV = smodel.Spec('PV', mdl_det) # PVMg PVMg = smodel.Spec('PVMg', mdl_det) # PVCa PVCa = smodel.Spec('PVCa', mdl_det) # Mg Mg = smodel.Spec('Mg', mdl_det) # Vol/surface systems vsys_stoch = smodel.Volsys('vsys_stoch', mdl_stoch) ssys_stoch = smodel.Surfsys('ssys_stoch', mdl_stoch) vsys_det = smodel.Volsys('vsys_det', mdl_det) ssys_det = smodel.Surfsys('ssys_det', mdl_det) # Diffusions diff_Ca = smodel.Diff('diff_Ca', vsys_det, Ca_det) diff_Ca.setDcst(DCST) diff_CBsf = smodel.Diff('diff_CBsf', vsys_det, CBsf) diff_CBsf.setDcst(DCB) diff_CBsCa = smodel.Diff('diff_CBsCa', vsys_det, CBsCa) diff_CBsCa.setDcst(DCB) diff_CBCaf = smodel.Diff('diff_CBCaf', vsys_det, CBCaf) diff_CBCaf.setDcst(DCB) diff_CBCaCa = smodel.Diff('diff_CBCaCa', vsys_det, CBCaCa) diff_CBCaCa.setDcst(DCB)
def setUp(self): KCST = 1e6 DCST = 0.08e-12 self.model = smodel.Model() A = smodel.Spec('A', self.model) B = smodel.Spec('B', self.model) C = smodel.Spec('C', self.model) D = smodel.Spec('D', self.model) E = smodel.Spec('E', self.model) F = smodel.Spec('F', self.model) self.ssys1 = smodel.Surfsys('ssys1', self.model) self.ssys2 = smodel.Surfsys('ssys2', self.model) self.sreac1 = smodel.SReac('sreac1', self.ssys1, slhs=[A, B], srhs=[C], kcst=KCST) self.sreac2 = smodel.SReac('sreac2', self.ssys2, slhs=[D, E], srhs=[F], kcst=KCST) self.geom = sgeom.Geom() self.comp = sgeom.Comp('comp', self.geom, 1e-18) self.patch1 = sgeom.Patch('patch1', self.geom, self.comp, None, 1e-12) self.patch1.addSurfsys('ssys1') self.patch2 = sgeom.Patch('patch2', self.geom, self.comp, None, 1e-12) self.patch2.addSurfsys('ssys2') if __name__ == "__main__": self.mesh = meshio.importAbaqus('meshes/brick_40_4_4_1400tets.inp', 1e-6)[0] else: self.mesh = meshio.importAbaqus( 'multi_sys_test/meshes/brick_40_4_4_1400tets.inp', 1e-6)[0] comp1_tets = [] comp2_tets = [] for t in range(self.mesh.ntets): cord = self.mesh.getTetBarycenter(t) if cord[0] < 0.0: comp1_tets.append(t) else: comp2_tets.append(t) self.tmcomp = sgeom.TmComp('comp', self.mesh, range(self.mesh.ntets)) surf_tris = self.mesh.getSurfTris() patch_tris1 = [] patch_tris2 = [] for tri in surf_tris: tet_neighs = self.mesh.getTriTetNeighb(tri) for tet in tet_neighs: if tet in comp1_tets: patch_tris1.append(tri) break elif tet in comp2_tets: patch_tris2.append(tri) break self.tmpatch1 = sgeom.TmPatch('patch1', self.mesh, patch_tris1, self.tmcomp) self.tmpatch1.addSurfsys('ssys1') self.tmpatch2 = sgeom.TmPatch('patch2', self.mesh, patch_tris2, self.tmcomp) self.tmpatch2.addSurfsys('ssys2') self.rng = srng.create('r123', 512) self.rng.initialize(1000)
NITER = 1000 # The number of iterations DT = 0.05 # Sampling time-step INT = 1.05 # Sim endtime # In tests fewer than 0.1% fail with tolerance of 2% tolerance = 2.0/100 ######################################################################## mdl = smod.Model() A = smod.Spec('A', mdl) B = smod.Spec('B', mdl) C = smod.Spec('C', mdl) surfsys = smod.Surfsys('ssys',mdl) SR1 = smod.SReac('SR1', surfsys, slhs = [A, B], srhs = [C], kcst = KCST) geom = sgeom.Geom() comp1 = sgeom.Comp('comp1', geom, VOL) patch1 = sgeom.Patch('patch1', geom, comp1, area = AREA) patch1.addSurfsys('ssys') import random rng = srng.create('mt19937', 1000) rng.initialize(int(random.random()*4294967295)) sim = ssolv.Wmdirect(mdl, geom, rng)
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)
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()
def getModel(): mdl = smodel.Model() # chemical species objects Ca = smodel.Spec('Ca', mdl) # Calcium IP3 = smodel.Spec('IP3', mdl) # IP3 # receptor state objects R = smodel.Spec('R', mdl) # IP3 receptor in 'naive' state RIP3 = smodel.Spec('RIP3', mdl) # bound IP3 Ropen = smodel.Spec('Ropen', mdl) # bound IP3 and Ca (open) RCa = smodel.Spec('RCa', mdl) # 1 bound Ca to inactivation site R2Ca = smodel.Spec('R2Ca', mdl) # 2 bound Ca to inactivation sites R3Ca = smodel.Spec('R3Ca', mdl) # 3 bound Ca to inactivation sites R4Ca = smodel.Spec('R4Ca', mdl) # 4 bound Ca to inactivation sites surfsys = smodel.Surfsys('ssys', mdl) # The 'forward' binding reactions: R_bind_IP3_f = smodel.SReac('R_bind_IP3_f', surfsys, \ olhs=[IP3], slhs=[R], srhs=[RIP3]) RIP3_bind_Ca_f = smodel.SReac('RIP3_bind_Ca_f', surfsys, \ olhs=[Ca], slhs=[RIP3], srhs = [Ropen]) R_bind_Ca_f = smodel.SReac('R_bind_Ca_f', surfsys, \ olhs=[Ca], slhs=[R], srhs=[RCa]) RCa_bind_Ca_f = smodel.SReac('RCa_bind_Ca_f', surfsys, \ olhs=[Ca], slhs=[RCa],srhs = [R2Ca]) R2Ca_bind_Ca_f = smodel.SReac('R2Ca_bind_Ca_f', surfsys, \ olhs=[Ca], slhs= [R2Ca], srhs = [R3Ca]) R3Ca_bind_Ca_f = smodel.SReac('R3Ca_bind_ca_f', surfsys, \ olhs=[Ca], slhs=[R3Ca], srhs=[R4Ca]) # The 'backward' binding reactions: R_bind_IP3_b = smodel.SReac('R_bind_IP3_b', surfsys, \ slhs=[RIP3], orhs=[IP3], srhs=[R]) RIP3_bind_Ca_b = smodel.SReac('RIP3_bind_Ca_b', surfsys, \ slhs=[Ropen], orhs=[Ca], srhs=[RIP3]) R_bind_Ca_b = smodel.SReac('R_bind_Ca_b', surfsys, \ slhs=[RCa], orhs=[Ca], srhs=[R]) RCa_bind_Ca_b = smodel.SReac('RCa_bind_Ca_b', surfsys, \ slhs=[R2Ca], orhs=[Ca], srhs=[RCa]) R2Ca_bind_Ca_b = smodel.SReac('R2Ca_bind_Ca_b', surfsys, \ slhs=[R3Ca], orhs=[Ca], srhs= [R2Ca]) R3Ca_bind_Ca_b = smodel.SReac('R3Ca_bind_ca_b', surfsys, \ slhs=[R4Ca], orhs=[Ca], srhs=[R3Ca]) # Ca ions passing through open IP3R channel R_Ca_channel_f = smodel.SReac('R_Ca_channel_f', surfsys, \ ilhs=[Ca], slhs=[Ropen], orhs=[Ca], srhs=[Ropen]) R_Ca_channel_b = smodel.SReac('R_Ca_channel_b', surfsys, \ olhs=[Ca], slhs=[Ropen], irhs=[Ca], srhs=[Ropen]) # The reaction constants R_bind_IP3_f.setKcst(1000e6) R_bind_IP3_b.setKcst(25800) RIP3_bind_Ca_f.setKcst(8000e6) RIP3_bind_Ca_b.setKcst(2000) R_bind_Ca_f.setKcst(8.889e6) R_bind_Ca_b.setKcst(5) RCa_bind_Ca_f.setKcst(20e6) RCa_bind_Ca_b.setKcst(10) R2Ca_bind_Ca_f.setKcst(40e6) R2Ca_bind_Ca_b.setKcst(15) R3Ca_bind_Ca_f.setKcst(60e6) R3Ca_bind_Ca_b.setKcst(20) # Corresponds to Ca input ~ 20000/ms for open receptor R_Ca_channel_f.setKcst(8e6) R_Ca_channel_b.setKcst(8e6) return mdl
def run_sim(): # Set up and run the simulations once, before the tests # analyze the results. ##################### First order irreversible ######################### global KCST_foi, N_foi, tolerance_foi KCST_foi = 5 # The reaction constant N_foi = 50 # Can set count or conc NITER_foi = 1 # The number of iterations # Tolerance for the comparison: tolerance_foi = 1.0e-4 / 100 ####################### First order reversible ######################### global KCST_f_for, KCST_b_for, COUNT_for, tolerance_for KCST_f_for = 20.0 # The reaction constant KCST_b_for = 5.0 COUNT_for = 100000 # Can set count or conc NITER_for = 1 # The number of iterations tolerance_for = 1.0e-4 / 100 ####################### Second order irreversible A2 ################### global KCST_soA2, CONCA_soA2, tolerance_soA2 KCST_soA2 = 10.0e6 # The reaction constant CONCA_soA2 = 10.0e-6 NITER_soA2 = 1 # The number of iterations tolerance_soA2 = 1.0e-4 / 100 ####################### Second order irreversible AA ################### global KCST_soAA, CONCA_soAA, CONCB_soAA, tolerance_soAA KCST_soAA = 5.0e6 # The reaction constant CONCA_soAA = 20.0e-6 CONCB_soAA = CONCA_soAA NITER_soAA = 1 # The number of iterations tolerance_soAA = 1.0e-4 / 100 ####################### Second order irreversible AB ################### global KCST_soAB, CONCA_soAB, CONCB_soAB, tolerance_soAB KCST_soAB = 5.0e6 # The reaction constant CONCA_soAB = 1.0e-6 n_soAB = 2 CONCB_soAB = CONCA_soAB / n_soAB NITER_soAB = 1 # The number of iterations tolerance_soAB = 1.0e-4 / 100 ####################### Third order irreversible A3 ################### global KCST_toA3, CONCA_toA3, tolerance_toA3 KCST_toA3 = 1.0e12 # The reaction constant CONCA_toA3 = 10.0e-6 NITER_toA3 = 1 # The number of iterations tolerance_toA3 = 1.0e-4 / 100 ####################### Third order irreversible A2B ################### global KCST_toA2B, CONCA_toA2B, CONCB_toA2B, tolerance_toA2B KCST_toA2B = 0.1e12 # The reaction constant CONCA_toA2B = 30.0e-6 CONCB_toA2B = 20.0e-6 NITER_toA2B = 1 # The number of iterations tolerance_toA2B = 1.0e-4 / 100 ####################### Second order irreversible 2D ################### global COUNTA_so2d, COUNTB_so2d, CCST_so2d, tolerance_so2d COUNTA_so2d = 100.0 n_so2d = 2.0 COUNTB_so2d = COUNTA_so2d / n_so2d KCST_so2d = 10.0e10 # The reaction constant AREA_so2d = 10.0e-12 NITER_so2d = 1 # The number of iterations tolerance_so2d = 1.0e-4 / 100 ############################ Common parameters ######################## global VOL DT = 0.1 # Sampling time-step INT = 1.1 # Sim endtime NITER_max = 1 ######################################################################## mdl = smod.Model() volsys = smod.Volsys('vsys', mdl) surfsys = smod.Surfsys('ssys', mdl) # First order irreversible A_foi = smod.Spec('A_foi', mdl) A_foi_diff = smod.Diff('A_foi_diff', volsys, A_foi, 0.01e-12) R1_foi = smod.Reac('R1_foi', volsys, lhs=[A_foi], rhs=[], kcst=KCST_foi) # First order reversible A_for = smod.Spec('A_for', mdl) B_for = smod.Spec('B_for', mdl) A_for_diff = smod.Diff('A_for_diff', volsys, A_for, 0.01e-12) B_for_diff = smod.Diff('B_for_diff', volsys, B_for, 0.01e-12) R1_for = smod.Reac('R1_for', volsys, lhs=[A_for], rhs=[B_for], kcst=KCST_f_for) R2_for = smod.Reac('R2_for', volsys, lhs=[B_for], rhs=[A_for], kcst=KCST_b_for) # Second order irreversible A2 A_soA2 = smod.Spec('A_soA2', mdl) C_soA2 = smod.Spec('C_soA2', mdl) A_soA2_diff = smod.Diff('A_soA2_diff', volsys, A_soA2, 1e-12) R1_soA2 = smod.Reac('R1_soA2', volsys, lhs=[A_soA2, A_soA2], rhs=[C_soA2], kcst=KCST_soA2) # Second order irreversible AA A_soAA = smod.Spec('A_soAA', mdl) B_soAA = smod.Spec('B_soAA', mdl) C_soAA = smod.Spec('C_soAA', mdl) A_soAA_diff = smod.Diff('A_soAA_diff', volsys, A_soAA, 0.2e-12) B_soAA_diff = smod.Diff('B_soAA_diff', volsys, B_soAA, 0.2e-12) R1_soAA = smod.Reac('R1_soAA', volsys, lhs=[A_soAA, B_soAA], rhs=[C_soAA], kcst=KCST_soAA) # Second order irreversible AB A_soAB = smod.Spec('A_soAB', mdl) B_soAB = smod.Spec('B_soAB', mdl) C_soAB = smod.Spec('C_soAB', mdl) A_soAB_diff = smod.Diff('A_soAB_diff', volsys, A_soAB, 0.1e-12) B_soAB_diff = smod.Diff('B_soAB_diff', volsys, B_soAB, 0.1e-12) R1_soAB = smod.Reac('R1_soAB', volsys, lhs=[A_soAB, B_soAB], rhs=[C_soAB], kcst=KCST_soAB) # Third order irreversible A3 A_toA3 = smod.Spec('A_toA3', mdl) C_toA3 = smod.Spec('C_toA3', mdl) A_soA3_diff = smod.Diff('A_soA3_diff', volsys, A_toA3, 0.2e-12) R1_toA3 = smod.Reac('R1_toA3', volsys, lhs=[A_toA3, A_toA3, A_toA3], rhs=[C_toA3], kcst=KCST_toA3) # Third order irreversible A2B A_toA2B = smod.Spec('A_toA2B', mdl) B_toA2B = smod.Spec('B_toA2B', mdl) C_toA2B = smod.Spec('C_toA2B', mdl) A_soA2B_diff = smod.Diff('A_soA2B_diff', volsys, A_toA2B, 0.1e-12) B_soA2B_diff = smod.Diff('B_soA2B_diff', volsys, B_toA2B, 0.1e-12) R1_toA3 = smod.Reac('R1_toA2B', volsys, lhs=[A_toA2B, A_toA2B, B_toA2B], rhs=[C_toA2B], kcst=KCST_toA2B) # Second order irreversible 2D A_so2d = smod.Spec('A_so2d', mdl) B_so2d = smod.Spec('B_so2d', mdl) C_so2d = smod.Spec('C_so2d', mdl) A_so2d_diff = smod.Diff('A_so2d_diff', surfsys, A_so2d, 1.0e-12) B_so2d_diff = smod.Diff('B_so2d_diff', surfsys, B_so2d, 1.0e-12) SR1_so2d = smod.SReac('SR1_so2d', surfsys, slhs=[A_so2d, B_so2d], srhs=[C_so2d], kcst=KCST_so2d) mesh = smeshio.importAbaqus('validation_rd/meshes/sphere_rad1_37tets.inp', 1e-6)[0] VOL = mesh.getMeshVolume() comp1 = sgeom.TmComp('comp1', mesh, range(mesh.ntets)) comp1.addVolsys('vsys') patch1 = sgeom.TmPatch('patch1', mesh, mesh.getSurfTris(), comp1) patch1.addSurfsys('ssys') CCST_so2d = KCST_so2d / (6.02214179e23 * patch1.getArea()) rng = srng.create('r123', 512) rng.initialize(1000) sim = ssolv.TetODE(mdl, mesh, rng) sim.setTolerances(1e-9, 1e-7) global tpnts, ntpnts tpnts = numpy.arange(0.0, INT, DT) ntpnts = tpnts.shape[0] res_m_foi = numpy.zeros([NITER_foi, ntpnts, 1]) res_m_for = numpy.zeros([NITER_for, ntpnts, 2]) res_m_soA2 = numpy.zeros([NITER_soA2, ntpnts, 2]) res_m_soAA = numpy.zeros([NITER_soAA, ntpnts, 3]) res_m_soAB = numpy.zeros([NITER_soAB, ntpnts, 3]) res_m_toA3 = numpy.zeros([NITER_toA3, ntpnts, 2]) res_m_toA2B = numpy.zeros([NITER_toA2B, ntpnts, 3]) res_m_so2d = numpy.zeros([NITER_so2d, ntpnts, 3]) for i in range(0, NITER_max): if i < NITER_foi: sim.setCompCount('comp1', 'A_foi', N_foi) if i < NITER_for: sim.setCompCount('comp1', 'A_for', COUNT_for) sim.setCompCount('comp1', 'B_for', 0.0) if i < NITER_soA2: sim.setCompConc('comp1', 'A_soA2', CONCA_soA2) if i < NITER_soAA: sim.setCompConc('comp1', 'A_soAA', CONCA_soAA) sim.setCompConc('comp1', 'B_soAA', CONCB_soAA) if i < NITER_soAB: sim.setCompConc('comp1', 'A_soAB', CONCA_soAB) sim.setCompConc('comp1', 'B_soAB', CONCB_soAB) if i < NITER_toA3: sim.setCompConc('comp1', 'A_toA3', CONCA_toA3) if i < NITER_toA2B: sim.setCompConc('comp1', 'A_toA2B', CONCA_toA2B) sim.setCompConc('comp1', 'B_toA2B', CONCB_toA2B) if i < NITER_so2d: sim.setPatchCount('patch1', 'A_so2d', COUNTA_so2d) sim.setPatchCount('patch1', 'B_so2d', COUNTB_so2d) for t in range(0, ntpnts): sim.run(tpnts[t]) if i < NITER_foi: res_m_foi[i, t, 0] = sim.getCompCount('comp1', 'A_foi') if i < NITER_for: res_m_for[i, t, 0] = sim.getCompConc('comp1', 'A_for') * 1e6 res_m_for[i, t, 1] = sim.getCompConc('comp1', 'B_for') * 1e6 if i < NITER_soA2: res_m_soA2[i, t, 0] = sim.getCompConc('comp1', 'A_soA2') if i < NITER_soAA: res_m_soAA[i, t, 0] = sim.getCompConc('comp1', 'A_soAA') res_m_soAA[i, t, 1] = sim.getCompConc('comp1', 'B_soAA') if i < NITER_soAB: res_m_soAB[i, t, 0] = sim.getCompConc('comp1', 'A_soAB') res_m_soAB[i, t, 1] = sim.getCompConc('comp1', 'B_soAB') if i < NITER_toA3: res_m_toA3[i, t, 0] = sim.getCompConc('comp1', 'A_toA3') if i < NITER_toA2B: res_m_toA2B[i, t, 0] = sim.getCompConc('comp1', 'A_toA2B') res_m_toA2B[i, t, 1] = sim.getCompConc('comp1', 'B_toA2B') res_m_toA2B[i, t, 2] = sim.getCompConc('comp1', 'C_toA2B') if i < NITER_so2d: res_m_so2d[i, t, 0] = sim.getPatchCount('patch1', 'A_so2d') res_m_so2d[i, t, 1] = sim.getPatchCount('patch1', 'B_so2d') global mean_res_foi mean_res_foi = numpy.mean(res_m_foi, 0) global mean_res_for mean_res_for = numpy.mean(res_m_for, 0) global mean_res_soA2 mean_res_soA2 = numpy.mean(res_m_soA2, 0) global mean_res_soAA mean_res_soAA = numpy.mean(res_m_soAA, 0) global mean_res_soAB mean_res_soAB = numpy.mean(res_m_soAB, 0) global mean_res_toA3 mean_res_toA3 = numpy.mean(res_m_toA3, 0) global mean_res_toA2B mean_res_toA2B = numpy.mean(res_m_toA2B, 0) global mean_res_so2d mean_res_so2d = numpy.mean(res_m_so2d, 0) global ran_sim ran_sim = True
def gen_model(x, flux): #### #### print "Create sim" mdl = smod.Model() # Defining chemical compartments vsys = smod.Volsys('vsys_Cyt', mdl) ssys = smod.Surfsys('ssys', mdl) ## ## Cytosolic molecule species ## CYT_MOL_NUM = len(x.CYT_MOL_NAME) CYT_MOL = [] for i in range(CYT_MOL_NUM): print i, x.CYT_MOL_NAME[i] ns = globals() ns[x.CYT_MOL_NAME[i]] = smod.Spec(x.CYT_MOL_NAME[i], mdl) # CYT_MOL.append( smod.Spec(CYT_MOL_NAME[i], mdl) ) ## ## Surface molecule species ## SUR_MOL_NUM = len(x.SUR_MOL_NAME) SUR_MOL = [] for i in range(SUR_MOL_NUM): print i, x.SUR_MOL_NAME[i] ns = globals() ns[x.SUR_MOL_NAME[i]] = smod.Spec(x.SUR_MOL_NAME[i], mdl) ## ## Cytosolic molecule reactions ## smod.Reac('on_CB', vsys, lhs=[Ca, CB], rhs=[CBCa], kcst=x.kon_CB) smod.Reac('of_CB', vsys, lhs=[CBCa], rhs=[Ca, CB], kcst=x.kof_CB) smod.Reac('on_TN1', vsys, lhs=[Ca, N0C0], rhs=[N1C0], kcst=2 * x.kon_TN) smod.Reac('of_TN1', vsys, lhs=[N1C0], rhs=[Ca, N0C0], kcst=x.kof_TN) smod.Reac('on_RN1', vsys, lhs=[Ca, N1C0], rhs=[N2C0], kcst=x.kon_RN) smod.Reac('of_RN1', vsys, lhs=[N2C0], rhs=[Ca, N1C0], kcst=2 * x.kof_RN) smod.Reac('on_TN2', vsys, lhs=[Ca, N0C1], rhs=[N1C1], kcst=2 * x.kon_TN) smod.Reac('of_TN2', vsys, lhs=[N1C1], rhs=[Ca, N0C1], kcst=x.kof_TN) smod.Reac('on_RN2', vsys, lhs=[Ca, N1C1], rhs=[N2C1], kcst=x.kon_RN) smod.Reac('of_RN2', vsys, lhs=[N2C1], rhs=[Ca, N1C1], kcst=2 * x.kof_RN) smod.Reac('on_TN3', vsys, lhs=[Ca, N0C2], rhs=[N1C2], kcst=2 * x.kon_TN) smod.Reac('of_TN3', vsys, lhs=[N1C2], rhs=[Ca, N0C2], kcst=x.kof_TN) smod.Reac('on_RN3', vsys, lhs=[Ca, N1C2], rhs=[N2C2], kcst=x.kon_RN) smod.Reac('of_RN3', vsys, lhs=[N2C2], rhs=[Ca, N1C2], kcst=2 * x.kof_RN) smod.Reac('on_TC1', vsys, lhs=[Ca, N0C0], rhs=[N0C1], kcst=2 * x.kon_TC) smod.Reac('of_TC1', vsys, lhs=[N0C1], rhs=[Ca, N0C0], kcst=x.kof_TC) smod.Reac('on_RC1', vsys, lhs=[Ca, N0C1], rhs=[N0C2], kcst=x.kon_RC) smod.Reac('of_RC1', vsys, lhs=[N0C2], rhs=[Ca, N0C1], kcst=2 * x.kof_RC) smod.Reac('on_TC2', vsys, lhs=[Ca, N1C0], rhs=[N1C1], kcst=2 * x.kon_TC) smod.Reac('of_TC2', vsys, lhs=[N1C1], rhs=[Ca, N1C0], kcst=x.kof_TC) smod.Reac('on_RC2', vsys, lhs=[Ca, N1C1], rhs=[N1C2], kcst=x.kon_RC) smod.Reac('of_RC2', vsys, lhs=[N1C2], rhs=[Ca, N1C1], kcst=2 * x.kof_RC) smod.Reac('on_TC3', vsys, lhs=[Ca, N2C0], rhs=[N2C1], kcst=2 * x.kon_TC) smod.Reac('of_TC3', vsys, lhs=[N2C1], rhs=[Ca, N2C0], kcst=x.kof_TC) smod.Reac('on_RC3', vsys, lhs=[Ca, N2C1], rhs=[N2C2], kcst=x.kon_RC) smod.Reac('of_RC3', vsys, lhs=[N2C2], rhs=[Ca, N2C1], kcst=2 * x.kof_RC) ## ## Ca pump and VGCC ## smod.SReac('PA_To_PA_Ca', ssys, slhs=[PA], ilhs=[Ca], srhs=[PA_Ca], kcst=150 * 1e6) smod.SReac('PA_Ca_To_PA', ssys, slhs=[PA_Ca], srhs=[PA], kcst=12) smod.SReac('Leak_To_Leak_Ca', ssys, slhs=[Leak], srhs=[Leak], irhs=[Ca], kcst=0.015) smod.SReac('NR_Glu_To_NR', ssys, slhs=[NR_Glu], srhs=[NR], kcst=50) smod.SReac('NR_Glu_To_NR_O', ssys, slhs=[NR_Glu], srhs=[NR_O], kcst=200) smod.SReac('NR_O_To_NR_Glu', ssys, slhs=[NR_O], srhs=[NR_Glu], kcst=50) smod.SReac('NR_O_To_NR_O_Ca', ssys, slhs=[NR_O], srhs=[NR_O], irhs=[Ca], kcst=flux) ## ## Species on left hand side: Surface (slhs), Outer comp (olhs), Inner comp (ilhs) ## Species on right hand side: Surface (srhs), Outer comp (orhs), Inner comp (irhs) ## # Diffusion rules smod.Diff('D_Ca', vsys, Ca, x.DCa) smod.Diff('D_N0C0', vsys, N0C0, x.DCaM) smod.Diff('D_N0C1', vsys, N0C1, x.DCaM) smod.Diff('D_N0C2', vsys, N0C2, x.DCaM) smod.Diff('D_N1C0', vsys, N1C0, x.DCaM) smod.Diff('D_N1C1', vsys, N1C1, x.DCaM) smod.Diff('D_N1C2', vsys, N1C2, x.DCaM) smod.Diff('D_N2C0', vsys, N2C0, x.DCaM) smod.Diff('D_N2C1', vsys, N2C1, x.DCaM) smod.Diff('D_N2C2', vsys, N2C2, x.DCaM) smod.Diff('D_CB', vsys, CB, x.DCB) smod.Diff('D_CBCa', vsys, CBCa, x.DCB) return mdl
def run_sim(): # Set up and run the simulations once, before the tests # analyze the results. ##################### First order irreversible ######################### global KCST_foi, N_foi, tolerance_foi KCST_foi = 5 # The reaction constant N_foi = 50 # Can set count or conc NITER_foi = 100000 # The number of iterations # Tolerance for the comparison: # In test runs, with good code, < 1% will fail with a 1.5% tolerance tolerance_foi = 2.0 / 100 ####################### First order reversible ######################### global KCST_f_for, KCST_b_for, COUNT_for, tolerance_for KCST_f_for = 10.0 # The reaction constant KCST_b_for = 2.0 COUNT_for = 100000 # Can set count or conc NITER_for = 10 # The number of iterations # In test runs, with good code, <0.1% will fail with a tolerance of 1% tolerance_for = 1.0 / 100 ####################### Second order irreversible A2 ################### global KCST_soA2, CONCA_soA2, tolerance_soA2 KCST_soA2 = 10.0e6 # The reaction constant CONCA_soA2 = 10.0e-6 NITER_soA2 = 1000 # The number of iterations # In test runs, with good code, <0.1% will fail with a tolerance of 2% tolerance_soA2 = 1.0 / 100 ####################### Second order irreversible AA ################### global KCST_soAA, CONCA_soAA, CONCB_soAA, tolerance_soAA KCST_soAA = 50.0e6 # The reaction constant CONCA_soAA = 20.0e-6 CONCB_soAA = CONCA_soAA NITER_soAA = 1000 # The number of iterations # In test runs, with good code, <0.1% will fail with a tolerance of 1% tolerance_soAA = 1.0 / 100 ####################### Second order irreversible AB ################### global KCST_soAB, CONCA_soAB, CONCB_soAB, tolerance_soAB KCST_soAB = 5.0e6 # The reaction constant CONCA_soAB = 1.0e-6 n_soAB = 2 CONCB_soAB = CONCA_soAB / n_soAB NITER_soAB = 1000 # The number of iterations # In test runs, with good code, <0.1% will fail with a tolerance of 1% tolerance_soAB = 1.0 / 100 ####################### Third order irreversible A3 ################### global KCST_toA3, CONCA_toA3, tolerance_toA3 KCST_toA3 = 1.0e12 # The reaction constant CONCA_toA3 = 100.0e-6 NITER_toA3 = 1000 # The number of iterations # In test runs, with good code, <0.1% will fail with a tolerance of 1% tolerance_toA3 = 1.0 / 100 ####################### Third order irreversible A2B ################### global KCST_toA2B, CONCA_toA2B, CONCB_toA2B, tolerance_toA2B KCST_toA2B = 0.1e12 # The reaction constant CONCA_toA2B = 30.0e-6 CONCB_toA2B = 20.0e-6 NITER_toA2B = 1000 # The number of iterations # In test runs, with good code, <0.1% will fail with a tolerance of 1% tolerance_toA2B = 1.0 / 100 ####################### Second order irreversible 2D ################### global COUNTA_so2d, COUNTB_so2d, CCST_so2d, tolerance_so2d COUNTA_so2d = 100.0 n_so2d = 2.0 COUNTB_so2d = COUNTA_so2d / n_so2d KCST_so2d = 10.0e10 # The reaction constant AREA_so2d = 10.0e-12 CCST_so2d = KCST_so2d / (6.02214179e23 * AREA_so2d) NITER_so2d = 1000 # The number of iterations # In tests fewer than 0.1% fail with tolerance of 2% tolerance_so2d = 2.0 / 100 ############################ Common parameters ######################## global VOL DT = 0.1 # Sampling time-step INT = 1.1 # Sim endtime VOL = 9.0e-18 NITER_max = 100000 ######################################################################## mdl = smod.Model() volsys = smod.Volsys('vsys', mdl) surfsys = smod.Surfsys('ssys', mdl) # First order irreversible A_foi = smod.Spec('A_foi', mdl) R1_foi = smod.Reac('R1_foi', volsys, lhs=[A_foi], rhs=[], kcst=KCST_foi) # First order reversible A_for = smod.Spec('A_for', mdl) B_for = smod.Spec('B_for', mdl) R1_for = smod.Reac('R1_for', volsys, lhs=[A_for], rhs=[B_for], kcst=KCST_f_for) R2_for = smod.Reac('R2_for', volsys, lhs=[B_for], rhs=[A_for], kcst=KCST_b_for) # Second order irreversible A2 A_soA2 = smod.Spec('A_soA2', mdl) C_soA2 = smod.Spec('C_soA2', mdl) R1_soA2 = smod.Reac('R1_soA2', volsys, lhs=[A_soA2, A_soA2], rhs=[C_soA2], kcst=KCST_soA2) # Second order irreversible AA A_soAA = smod.Spec('A_soAA', mdl) B_soAA = smod.Spec('B_soAA', mdl) C_soAA = smod.Spec('C_soAA', mdl) R1_soAA = smod.Reac('R1_soAA', volsys, lhs=[A_soAA, B_soAA], rhs=[C_soAA], kcst=KCST_soAA) # Second order irreversible AB A_soAB = smod.Spec('A_soAB', mdl) B_soAB = smod.Spec('B_soAB', mdl) C_soAB = smod.Spec('C_soAB', mdl) R1_soAB = smod.Reac('R1_soAB', volsys, lhs=[A_soAB, B_soAB], rhs=[C_soAB], kcst=KCST_soAB) # Third order irreversible A3 A_toA3 = smod.Spec('A_toA3', mdl) C_toA3 = smod.Spec('C_toA3', mdl) R1_toA3 = smod.Reac('R1_toA3', volsys, lhs=[A_toA3, A_toA3, A_toA3], rhs=[C_toA3], kcst=KCST_toA3) # Third order irreversible A2B A_toA2B = smod.Spec('A_toA2B', mdl) B_toA2B = smod.Spec('B_toA2B', mdl) C_toA2B = smod.Spec('C_toA2B', mdl) R1_toA3 = smod.Reac('R1_toA2B', volsys, lhs=[A_toA2B, A_toA2B, B_toA2B], rhs=[C_toA2B], kcst=KCST_toA2B) # Second order irreversible 2D A_so2d = smod.Spec('A_so2d', mdl) B_so2d = smod.Spec('B_so2d', mdl) C_so2d = smod.Spec('C_so2d', mdl) SR1_so2d = smod.SReac('SR1_so2d', surfsys, slhs=[A_so2d, B_so2d], srhs=[C_so2d], kcst=KCST_so2d) geom = sgeom.Geom() comp1 = sgeom.Comp('comp1', geom, VOL) comp1.addVolsys('vsys') patch1 = sgeom.Patch('patch1', geom, comp1, area=AREA_so2d) patch1.addSurfsys('ssys') rng = srng.create('r123', 512) rng.initialize(1000) sim = ssolv.Wmdirect(mdl, geom, rng) sim.reset() global tpnts, ntpnts tpnts = numpy.arange(0.0, INT, DT) ntpnts = tpnts.shape[0] res_m_foi = numpy.zeros([NITER_foi, ntpnts, 1]) res_std1_foi = numpy.zeros([ntpnts, 1]) res_std2_foi = numpy.zeros([ntpnts, 1]) res_m_for = numpy.zeros([NITER_for, ntpnts, 2]) res_m_soA2 = numpy.zeros([NITER_soA2, ntpnts, 2]) res_m_soAA = numpy.zeros([NITER_soAA, ntpnts, 3]) res_m_soAB = numpy.zeros([NITER_soAB, ntpnts, 3]) res_m_toA3 = numpy.zeros([NITER_toA3, ntpnts, 2]) res_m_toA2B = numpy.zeros([NITER_toA2B, ntpnts, 3]) res_m_so2d = numpy.zeros([NITER_so2d, ntpnts, 3]) for i in range(0, NITER_max): sim.reset() if i < NITER_foi: sim.setCompCount('comp1', 'A_foi', N_foi) if i < NITER_for: sim.setCompCount('comp1', 'A_for', COUNT_for) sim.setCompCount('comp1', 'B_for', 0.0) if i < NITER_soA2: sim.setCompConc('comp1', 'A_soA2', CONCA_soA2) if i < NITER_soAA: sim.setCompConc('comp1', 'A_soAA', CONCA_soAA) sim.setCompConc('comp1', 'B_soAA', CONCB_soAA) if i < NITER_soAB: sim.setCompConc('comp1', 'A_soAB', CONCA_soAB) sim.setCompConc('comp1', 'B_soAB', CONCB_soAB) if i < NITER_toA3: sim.setCompConc('comp1', 'A_toA3', CONCA_toA3) if i < NITER_toA2B: sim.setCompConc('comp1', 'A_toA2B', CONCA_toA2B) sim.setCompConc('comp1', 'B_toA2B', CONCB_toA2B) if i < NITER_so2d: sim.setPatchCount('patch1', 'A_so2d', COUNTA_so2d) sim.setPatchCount('patch1', 'B_so2d', COUNTB_so2d) for t in range(0, ntpnts): sim.run(tpnts[t]) if i < NITER_foi: res_m_foi[i, t, 0] = sim.getCompCount('comp1', 'A_foi') if i < NITER_for: res_m_for[i, t, 0] = sim.getCompConc('comp1', 'A_for') * 1e6 res_m_for[i, t, 1] = sim.getCompConc('comp1', 'B_for') * 1e6 if i < NITER_soA2: res_m_soA2[i, t, 0] = sim.getCompConc('comp1', 'A_soA2') if i < NITER_soAA: res_m_soAA[i, t, 0] = sim.getCompConc('comp1', 'A_soAA') res_m_soAA[i, t, 1] = sim.getCompConc('comp1', 'B_soAA') if i < NITER_soAB: res_m_soAB[i, t, 0] = sim.getCompConc('comp1', 'A_soAB') res_m_soAB[i, t, 1] = sim.getCompConc('comp1', 'B_soAB') if i < NITER_toA3: res_m_toA3[i, t, 0] = sim.getCompConc('comp1', 'A_toA3') if i < NITER_toA2B: res_m_toA2B[i, t, 0] = sim.getCompConc('comp1', 'A_toA2B') res_m_toA2B[i, t, 1] = sim.getCompConc('comp1', 'B_toA2B') res_m_toA2B[i, t, 2] = sim.getCompConc('comp1', 'C_toA2B') if i < NITER_so2d: res_m_so2d[i, t, 0] = sim.getPatchCount('patch1', 'A_so2d') res_m_so2d[i, t, 1] = sim.getPatchCount('patch1', 'B_so2d') global mean_res_foi, std_res_foi mean_res_foi = numpy.mean(res_m_foi, 0) std_res_foi = numpy.std(res_m_foi, 0) global mean_res_for mean_res_for = numpy.mean(res_m_for, 0) global mean_res_soA2 mean_res_soA2 = numpy.mean(res_m_soA2, 0) global mean_res_soAA mean_res_soAA = numpy.mean(res_m_soAA, 0) global mean_res_soAB mean_res_soAB = numpy.mean(res_m_soAB, 0) global mean_res_toA3 mean_res_toA3 = numpy.mean(res_m_toA3, 0) global mean_res_toA2B mean_res_toA2B = numpy.mean(res_m_toA2B, 0) global mean_res_so2d mean_res_so2d = numpy.mean(res_m_so2d, 0) global ran_sim ran_sim = True
def getModel(): mdl = smodel.Model() # Calcium Ca = smodel.Spec('Ca', mdl) # Pump Pump = smodel.Spec('Pump', mdl) # CaPump CaPump = smodel.Spec('CaPump', mdl) # iCBsf iCBsf = smodel.Spec('iCBsf', mdl) # iCBsCa iCBsCa = smodel.Spec('iCBsCa', mdl) # iCBCaf iCBCaf = smodel.Spec('iCBCaf', mdl) # iCBCaCa iCBCaCa = smodel.Spec('iCBCaCa', mdl) # CBsf CBsf = smodel.Spec('CBsf', mdl) # CBsCa CBsCa = smodel.Spec('CBsCa', mdl) # CBCaf CBCaf = smodel.Spec('CBCaf', mdl) # CBCaCa CBCaCa = smodel.Spec('CBCaCa', mdl) # PV PV = smodel.Spec('PV', mdl) # PVMg PVMg = smodel.Spec('PVMg', mdl) # PVCa PVCa = smodel.Spec('PVCa', mdl) # Mg Mg = smodel.Spec('Mg', mdl) # Vol/surface systems vsys = smodel.Volsys('vsys', mdl) ssys = smodel.Surfsys('ssys', mdl) diff_Ca = smodel.Diff('diff_Ca', vsys, Ca) diff_Ca.setDcst(DCST) diff_CBsf = smodel.Diff('diff_CBsf', vsys, CBsf) diff_CBsf.setDcst(DCB) diff_CBsCa = smodel.Diff('diff_CBsCa', vsys, CBsCa) diff_CBsCa.setDcst(DCB) diff_CBCaf = smodel.Diff('diff_CBCaf', vsys, CBCaf) diff_CBCaf.setDcst(DCB) diff_CBCaCa = smodel.Diff('diff_CBCaCa', vsys, CBCaCa) diff_CBCaCa.setDcst(DCB) diff_PV = smodel.Diff('diff_PV', vsys, PV) diff_PV.setDcst(DPV) diff_PVCa = smodel.Diff('diff_PVCa', vsys, PVCa) diff_PVCa.setDcst(DPV) diff_PVMg = smodel.Diff('diff_PVMg', vsys, PVMg) diff_PVMg.setDcst(DPV) #Pump PumpD_f = smodel.SReac('PumpD_f', ssys, ilhs=[Ca], slhs=[Pump], srhs=[CaPump]) PumpD_f.setKcst(P_f_kcst) PumpD_b = smodel.SReac('PumpD_b', ssys, slhs=[CaPump], irhs=[Ca], srhs=[Pump]) PumpD_b.setKcst(P_b_kcst) PumpD_k = smodel.SReac('PumpD_k', ssys, slhs=[CaPump], srhs=[Pump]) PumpD_k.setKcst(P_k_kcst) #iCBsf-fast iCBsf1_f = smodel.Reac('iCBsf1_f', vsys, lhs=[Ca, iCBsf], rhs=[iCBsCa], kcst=iCBsf1_f_kcst) iCBsf1_b = smodel.Reac('iCBsf1_b', vsys, lhs=[iCBsCa], rhs=[Ca, iCBsf], kcst=iCBsf1_b_kcst) #iCBsCa iCBsCa_f = smodel.Reac('iCBsCa_f', vsys, lhs=[Ca, iCBsCa], rhs=[iCBCaCa], kcst=iCBsCa_f_kcst) iCBsCa_b = smodel.Reac('iCBsCa_b', vsys, lhs=[iCBCaCa], rhs=[Ca, iCBsCa], kcst=iCBsCa_b_kcst) #iCBsf_slow iCBsf2_f = smodel.Reac('iCBsf2_f', vsys, lhs=[Ca, iCBsf], rhs=[iCBCaf], kcst=iCBsf2_f_kcst) iCBsf2_b = smodel.Reac('iCBsf2_b', vsys, lhs=[iCBCaf], rhs=[Ca, iCBsf], kcst=iCBsf2_b_kcst) #iCBCaf iCBCaf_f = smodel.Reac('iCBCaf_f', vsys, lhs=[Ca, iCBCaf], rhs=[iCBCaCa], kcst=iCBCaf_f_kcst) iCBCaf_b = smodel.Reac('iCBCaf_b', vsys, lhs=[iCBCaCa], rhs=[Ca, iCBCaf], kcst=iCBCaf_b_kcst) #CBsf-fast CBsf1_f = smodel.Reac('CBsf1_f', vsys, lhs=[Ca, CBsf], rhs=[CBsCa], kcst=CBsf1_f_kcst) CBsf1_b = smodel.Reac('CBsf1_b', vsys, lhs=[CBsCa], rhs=[Ca, CBsf], kcst=CBsf1_b_kcst) #CBsCa CBsCa_f = smodel.Reac('CBsCa_f', vsys, lhs=[Ca, CBsCa], rhs=[CBCaCa], kcst=CBsCa_f_kcst) CBsCa_b = smodel.Reac('CBsCa_b', vsys, lhs=[CBCaCa], rhs=[Ca, CBsCa], kcst=CBsCa_b_kcst) #CBsf_slow CBsf2_f = smodel.Reac('CBsf2_f', vsys, lhs=[Ca, CBsf], rhs=[CBCaf], kcst=CBsf2_f_kcst) CBsf2_b = smodel.Reac('CBsf2_b', vsys, lhs=[CBCaf], rhs=[Ca, CBsf], kcst=CBsf2_b_kcst) #CBCaf CBCaf_f = smodel.Reac('CBCaf_f', vsys, lhs=[Ca, CBCaf], rhs=[CBCaCa], kcst=CBCaf_f_kcst) CBCaf_b = smodel.Reac('CBCaf_b', vsys, lhs=[CBCaCa], rhs=[Ca, CBCaf], kcst=CBCaf_b_kcst) #PVca PVca_f = smodel.Reac('PVca_f', vsys, lhs=[Ca, PV], rhs=[PVCa], kcst=PVca_f_kcst) PVca_b = smodel.Reac('PVca_b', vsys, lhs=[PVCa], rhs=[Ca, PV], kcst=PVca_b_kcst) #PVmg PVmg_f = smodel.Reac('PVmg_f', vsys, lhs=[Mg, PV], rhs=[PVMg], kcst=PVmg_f_kcst) PVmg_b = smodel.Reac('PVmg_b', vsys, lhs=[PVMg], rhs=[Mg, PV], kcst=PVmg_b_kcst) # Ca Influx converted from P Type current CaInflux = smodel.Reac('CaInflux', vsys, lhs=[], rhs=[Ca], kcst=0.0) return mdl