Changeset 371
- Timestamp:
- 06/18/08 14:02:10 (5 months ago)
- Files:
-
- trunk/src/neuron2/__init__.py (modified) (7 diffs)
- trunk/src/neuron2/cells.py (modified) (2 diffs)
- trunk/src/neuron2/utility.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/neuron2/__init__.py
r367 r371 37 37 simulator but not by others. 38 38 """ 39 global initialised, quit_on_end, running, parallel_context 39 global initialised, quit_on_end, running, parallel_context, initializer 40 40 if not initialised: 41 41 h('min_delay = 0') … … 44 44 parallel_context.spike_compress(1,0) 45 45 cvode = neuron.CVode() 46 initializer = Initializer() 46 47 utility.init_logging("neuron2.log.%d" % rank(), debug) 47 48 logging.info("Initialization of NEURON (use setup(.., debug=True) to see a full logfile)") … … 69 70 """Run the simulation for simtime ms.""" 70 71 global running 71 logging.info("Running the simulation for %d ms" % simtime)72 72 if not running: 73 73 running = True … … 80 80 "There are connections with delays (%g) shorter than the minimum delay (%g)" % (local_minimum_delay, get_min_delay()) 81 81 h.tstop = simtime 82 logging.info("Running the simulation for %d ms" % simtime) 82 83 parallel_context.psolve(h.tstop) 83 84 return get_current_time() … … 165 166 for id in all_ids[mask_local]: 166 167 id.cellclass = cellclass 168 initializer.register(*all_ids[mask_local]) 167 169 if len(all_ids) == 1: 168 170 all_ids = all_ids[0] … … 281 283 label is an optional name for the population. 282 284 """ 283 ##global gid_counter284 285 common.Population.__init__(self, dims, cellclass, cellparams, label) 285 286 self.recorders = {'spikes': Recorder('spikes', population=self), 286 287 'v': Recorder('v', population=self)} 287 ##self.first_id = gid_counter288 ##self.last_id = gid_counter + self.size289 288 self.label = self.label or 'population%d' % Population.nPop 290 289 self.celltype = cellclass(cellparams) … … 294 293 # All are stored in a single numpy array for easy lookup by address 295 294 # The local cells are also stored in a list, for easy iteration 296 297 295 self._all_ids, self._mask_local, self.first_id, self.last_id = _create(self.celltype, self.size, parent=self) 298 ##self._all_ids = numpy.array([id for id in range(self.first_id, self.last_id)], ID) #.reshape(self.dim)299 ### _mask_local is used to extract those elements from arrays that apply to the cells on the current node, e.g. for tset()300 ##self._mask_local = self._all_ids%num_processes()==0 # round-robin distribution of cells between nodes301 ##for i,(id,is_local) in enumerate(zip(self._all_ids, self._mask_local)):302 ## if is_local:303 ## self._all_ids[i] = ID(id)304 # _local_ids is a list containing only those cells that exist on the current node305 296 self._local_ids = self._all_ids[self._mask_local] 306 297 self._all_ids = self._all_ids.reshape(self.dim) 307 298 self._mask_local = self._mask_local.reshape(self.dim) 308 299 309 310 ##for id in self._local_ids: 311 ## id._build_cell(self.celltype, parent=self) 312 #gid_counter += self.size 300 initializer.register(self) 313 301 Population.nPop += 1 314 302 logging.info(self.describe('Creating Population "%(label)s" of shape %(dim)s, '+ trunk/src/neuron2/cells.py
r367 r371 81 81 if self.v_init is None: 82 82 self.v_init = self.v_rest 83 84 # need to deal with FinitializeHandler for v_init?85 self.fih = neuron.h.FInitializeHandler("memb_init()", self)86 self.fih2 = neuron.h.FInitializeHandler('print "kjyuyv"')87 83 self.spiketimes = neuron.Vector(0) 88 self.fih.allprint()89 84 90 85 def __set_tau_m(self, value): … … 124 119 125 120 def memb_init(self, v_init=None): 126 print "memb_init() called"127 121 if v_init: 128 122 self.v_init = v_init 129 self.v = v_init 130 123 self.seg.v = self.v_init 131 124 132 125 trunk/src/neuron2/utility.py
r367 r371 1 1 from pyNN import __path__ as pyNN_path 2 from pyNN import common 2 3 import platform 3 4 import logging … … 87 88 self.population_list = [] 88 89 neuron.h('objref initializer') 89 neuron.h('initializer = PythonObject(self)') 90 neuron.h.initializer = self 91 self.fih = h.FInitializeHandler("initializer.initialize()") 92 93 def register(self, *items): 94 for item in items: 95 if isinstance(item, common.Population): 96 if "Source" not in item.__class__.__name__: 97 self.population_list.append(item) 98 else: 99 if hasattr(item._cell, "memb_init"): 100 self.cell_list.append(item) 90 101 91 102 def initialize(self): 103 logging.info("Initializing membrane potential of %d cells and %d Populations." % \ 104 (len(self.cell_list), len(self.population_list))) 92 105 for cell in self.cell_list: 93 cell.memb_init() 94 106 cell._cell.memb_init() 107 for population in self.population_list: 108 for cell in population: 109 cell._cell.memb_init() 95 110 96 111 load_mechanisms()

