Calling python function from hoc statement
Posted: Tue Jan 22, 2019 11:56 am
Hi,
I am trying to call python function in a class using hoc statements to redefine init block. It was pretty easy using hoc programming, but to do the same, in python, I used this approach.
I have a MPI based network and in the prun block, I define
Whenever I execute this program, it says that "prepruninitialize is not defined". I was able to execute this successfully when I run as individual blocks on nrniv shell but not with MPI based network code.
What am I doing wrong here? Can you kindly let me know?
Thank you.
I am trying to call python function in a class using hoc statements to redefine init block. It was pretty easy using hoc programming, but to do the same, in python, I used this approach.
I have a MPI based network and in the prun block, I define
Code: Select all
def prun(self):
if self.rank==0:
print 'In the function SIMULATING CELLS...\n'
self.pc.set_maxstep(10)
#h('proc init() {nrnpython("prepruninitialize()")}') - this didn't work either
h('''objref po
po=new PythonObject()
proc init(){
finitialize(-65)
po.prepruninitialize()
finitialize()
if (cvode_active()){
cvode.re_init()
}else{
fcurrent()
}
frecord_init()
}
''')
h.stdinit()
def prepruninitialize(self):
if self.rank==0:
print 'Setting up initial conditions...\n'
for ii in range(len(self.grcells)):
self.grcells[ii].setv() # setting up initial voltage.
What am I doing wrong here? Can you kindly let me know?
Thank you.