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 = 1e-3/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 = 1 # The number of iterations # Tolerance for the comparison. The only test where tolerance must # be relatively high tolerance_for = 0.5/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-3/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 = 1 # The number of iterations tolerance_soAA = 1.0e-3/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-3/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 = 1 # The number of iterations tolerance_toA3 = 1.0e-3/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-3/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 = 1 # The number of iterations tolerance_so2d = 1.0e-3/100 ############################ Common parameters ######################## global VOL DT = 0.1 # Sampling time-step INT = 1.1 # Sim endtime VOL = 9.0e-18 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) 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.Wmrk4(mdl, geom, rng) sim.setDT(0.00001) 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
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], srhs=[Ia], kcst=630) A01_to_Pa_f = smodel.SReac('A01_to_Pa_f', surfsys, slhs=[A01],
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',
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 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 ####################### 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 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) # 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_soAA = numpy.zeros([NITER_soAA, ntpnts, 3]) res_m_soAB = numpy.zeros([NITER_soAB, 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_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_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_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_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_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_so2d mean_res_so2d = numpy.mean(res_m_so2d, 0) global ran_sim ran_sim = True
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
# receptor state: Ca bound to two inactivation sites R2Ca = smodel.Spec('R2Ca', mdl) # receptor state: Ca bound to three inactivation sites R3Ca = smodel.Spec('R3Ca', mdl) # receptor state: Ca bound to four inactivation sites R4Ca = smodel.Spec('R4Ca', mdl) ####################################################### # Surface system 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' unbinding reactions: R_bind_IP3_b = smodel.SReac('R_bind_IP3_b', surfsys, slhs=[RIP3], orhs=[IP3], srhs=[R])
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) tet_hosts = gd.linearPartition(self.mesh, [1, 1, steps.mpi.nhosts]) tri_hosts = gd.partitionTris(self.mesh, tet_hosts, self.mesh.getSurfTris()) self.sim = ssolver.TetOpSplit(mdl, self.mesh, rng, ssolver.EF_DEFAULT, tet_hosts, tri_hosts) self.sim.setEfieldDT(1e-4) self.sim.reset()
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
RI2 = smodel.Spec('RI2', mdl) RI3 = smodel.Spec('RI3', mdl) P = smodel.Spec('P', mdl) #naive state 1 PI = smodel.Spec('PI', mdl) PI2 = smodel.Spec('PI2', mdl) PI3 = smodel.Spec('PI3', mdl) C1 = smodel.Spec('C1', mdl) O1 = smodel.Spec('O1', mdl) # open state 1 O2 = smodel.Spec('O2', mdl) # open state 1 # REACTIONS #1 R <=> P reac1_f = smodel.SReac('R_P', surfsys, slhs=[R], srhs=[P]) reac1_b = smodel.SReac('P_R', surfsys, slhs=[P], srhs=[R]) #2 R + IP3 <=> RI reac2_f = smodel.SReac('R_RI', surfsys, olhs=[IP3], slhs=[R], srhs=[RI]) reac2_b = smodel.SReac('RI_R', surfsys, slhs=[RI], orhs=[IP3], srhs=[R]) #3 RI + IP3 <=> RI2 reac3_f = smodel.SReac('RI_RI2', surfsys, olhs=[IP3], slhs=[RI], srhs=[RI2]) reac3_b = smodel.SReac('RI2_RI', surfsys, slhs=[RI2], orhs=[IP3], srhs=[RI]) #4 RI2 + IP3 <=> RI3 reac4_f = smodel.SReac('RI2_RI3', surfsys, olhs=[IP3], slhs=[RI2], srhs=[RI3]) reac4_b = smodel.SReac('RI3_RI2', surfsys, slhs=[RI3], orhs=[IP3], srhs=[RI2]) #5 RI3 + IP3 <=> O1
# ser_x0y0 = smodel.SReac('ser_x0y0', surfsys2, slhs=[SERCA_X0Ca], srhs=[SERCA_Y0Ca] , kcst=kx0y0) # //////////////////////////////////////////////////////////////////////////////////////////////////////// # Ca + SERCA <-> Ca1SERCA +Ca <-> Ca2SERCA -> SERCA DCST_MEM = 0.05e-12 SERCA = smodel.Spec('SERCA', model) CaSERCA = smodel.Spec('CaSERCA',model) Ca2SERCA = smodel.Spec('Ca2SERCA',model) diff_SERCA = smodel.Diff('diff_SERCA', surfsys2, SERCA, DCST_MEM) diff_CaSERCA = smodel.Diff('diff_CaSERCA', surfsys2, CaSERCA, DCST_MEM) diff_Ca2SERCA = smodel.Diff('diff_Ca2SERCA', surfsys2, Ca2SERCA, DCST_MEM) Reac9 = smodel.SReac('Reac9', surfsys2, olhs=[Ca], slhs=[SERCA], srhs=[CaSERCA], kcst=17147e6) Reac10 = smodel.SReac('Reac10', surfsys2, slhs=[CaSERCA], orhs=[Ca], srhs=[SERCA], kcst=8426.3) Reac11 = smodel.SReac('Reac11', surfsys2, olhs=[Ca], slhs=[CaSERCA], srhs=[Ca2SERCA], kcst=17147e6) Reac12 = smodel.SReac('Reac12', surfsys2, slhs=[Ca2SERCA], orhs=[Ca], srhs=[CaSERCA], kcst=8426.3) Reac13 = smodel.SReac('Reac13', surfsys2, slhs=[Ca2SERCA], srhs=[SERCA], irhs=[Ca,Ca], kcst=250) # //////////////////////////////////////////////////////////////////////////////////////////////////////// # PMCA species: PMCA_P0 = smodel.Spec('PMCA_P0', model) PMCA_P1 = smodel.Spec('PMCA_P1', model) k1_pmca = 1.5e8 k2_pmca = 15 k3_pmca = 12 kl_pmca = 4.3
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))
A11 = smodel.Spec('A11', 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) Oa = smodel.Spec('Oa', mdl) Ob = smodel.Spec('Ob', mdl) Oc = smodel.Spec('Oc', mdl) Ia = smodel.Spec('Ia', mdl) Ib = smodel.Spec('Ib', mdl) # REACTIONS #1 Sa + Ca <=> Sb reac1_f = smodel.SReac('Sa_Sb', surfsys, olhs=[Ca], slhs=[Sa], srhs=[Sb]) reac1_b = smodel.SReac('Sb_Sa', surfsys, slhs=[Sb], orhs=[Ca], srhs=[Sa]) #2 Pc <=> Sa reac2_f = smodel.SReac('Pc_Sa', surfsys, slhs=[Pc], srhs=[Sa]) reac2_b = smodel.SReac('Sa_Pc', surfsys, slhs=[Sa], srhs=[Pc]) #3 Pb + Ca_ER <=> Pc reac3_f = smodel.SReac('Pb_Pc', surfsys, ilhs=[Ca], slhs=[Pb], srhs=[Pc]) reac3_b = smodel.SReac('Pc_Pb', surfsys, slhs=[Pc], irhs=[Ca], srhs=[Pb]) #4 Pa <=> Pb reac4_f = smodel.SReac('Pa_Pb', surfsys, slhs=[Pa], srhs=[Pb]) reac4_b = smodel.SReac('Pb_Pa', surfsys, slhs=[Pb], srhs=[Pa]) #5 A01 <=> Pa
# 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,
diff_CBsCa.setDcst(DCB) diff_CBCaf = smodel.Diff('diff_CBCaf', vsys_stoch, CBCaf) diff_CBCaf.setDcst(DCB) diff_CBCaCa = smodel.Diff('diff_CBCaCa', vsys_stoch, CBCaCa) diff_CBCaCa.setDcst(DCB) diff_PV = smodel.Diff('diff_PV', vsys_stoch, PV) diff_PV.setDcst(DPV) diff_PVCa = smodel.Diff('diff_PVCa', vsys_stoch, PVCa) diff_PVCa.setDcst(DPV) diff_PVMg = smodel.Diff('diff_PVMg', vsys_stoch, PVMg) diff_PVMg.setDcst(DPV) #Pump PumpD_f = smodel.SReac('PumpD_f', ssys_det, ilhs=[Ca_det], slhs=[Pump], srhs=[CaPump]) PumpD_f.setKcst(P_f_kcst) PumpD_b = smodel.SReac('PumpD_b', ssys_det, slhs=[CaPump], irhs=[Ca_det], srhs=[Pump]) PumpD_b.setKcst(P_b_kcst) PumpD_k = smodel.SReac('PumpD_k', ssys_det, slhs=[CaPump], srhs=[Pump]) PumpD_k.setKcst(P_k_kcst) #iCBsf-fast
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