def highlightPatch(mesh, patch_id, tri_proxy): """ Highlight the STEPS compartment. Parameters: * mesh Associated Tetmesh object created in STEPS * patch_id Name of the patch * tri_proxy Triangle element proxy generated by STEPS mesh importing function Return: None """ patch = sgeom.castToTmPatch(mesh.getPatch(patch_id)) data = patch.getAllTriIndices() highlightSTEPSTris(data, tri_proxy)
def init_sim(model, mesh, seed, param): # previous setup # rng = srng.create('r123', 512) # rng.initialize(seed) # sim = ssolver.Tetexact(model, mesh, rng, True) # Create the solver objects if param['SSA_solver'] == 'TetODE': sim = ssolver.TetODE(model, mesh, calcMembPot=sim_parameters['EF_solver']) sim.setTolerances(1.0e-6, 1e-6) elif param['SSA_solver'] == 'Tetexact': rng = srng.create('mt19937', 512) rng.initialize(seed) sim = ssolver.Tetexact(model, mesh, rng, calcMembPot=sim_parameters['EF_solver']) sim.reset() sim.setEfieldDT(param['EF_dt']) else: raise ValueError('SSA solver ' + param['SSA_solver'] + 'not available') print('Running Rallpack1 test with ' + param['SSA_solver']) # Correction factor for deviation between mesh and model cylinder: area_cylinder = np.pi * param['diameter'] * param['length'] area_mesh_factor = sim.getPatchArea('memb') / area_cylinder # Set initial conditions memb = sgeom.castToTmPatch(mesh.getPatch('memb')) for t in memb.tris: sim.setTriCount(t, 'Leak', 1) sim.setMembPotential('membrane', param['E_M']) sim.setMembVolRes('membrane', param['R_A']) sim.setMembCapac('membrane', param['C_M'] / area_mesh_factor) v_zmin = mesh.getROIData('v_zmin') I = param['Iinj'] / len(v_zmin) for v in v_zmin: sim.setVertIClamp(v, I) return sim
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 init_sim(model, mesh, seed, param): rng = srng.create('r123', 512) # previous setup # rng.initialize(seed) rng.initialize(steps.mpi.rank + 1000) memb = sgeom.castToTmPatch(mesh.getPatch('memb')) # partition geometry across hosts (tet_hosts, tri_hosts) = host_assignment_by_axis(mesh, memb.tris) # sim = ssolver.TetOpSplit(model, mesh, rng, True, tet_hosts, tri_hosts) sim = ssolver.TetOpSplit(model, mesh, rng, param['EF_solver'], tet_hosts, tri_hosts) # Correction factor for deviation between mesh and model cylinder: area_cylinder = np.pi * param['diameter'] * param['length'] area_mesh_factor = sim.getPatchArea('memb') / area_cylinder # Set initial conditions sim.reset() for t in memb.tris: sim.setTriCount(t, 'Leak', 1) sim.setEfieldDT(param['EF_dt']) sim.setMembPotential('membrane', param['E_M']) sim.setMembVolRes('membrane', param['R_A']) sim.setMembCapac('membrane', param['C_M'] / area_mesh_factor) v_zmin = mesh.getROIData('v_zmin') I = param['Iinj'] / len(v_zmin) for v in v_zmin: sim.setVertIClamp(v, I) return sim