v_init updating between the gui runcontrol and hoc code

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc.
Post Reply
margopolo

v_init updating between the gui runcontrol and hoc code

Post by margopolo » Fri Apr 16, 2010 12:08 pm

Hi,
I am having an issue with the v_init updating between my hoc code and the run control. In my hoc code, I set v_init=-70 as a global parameter, and then in my initialization section I set my e_pas=v_init. Everything seems to run fine, but when I change the v_init value in the run control (say to -10), although there are changes with the plot reflecting some of these changes, the e_pas is still at -70. Does anyone know why it would initialize correctly in some areas of the code but not throughout?
Thanks for your help!
Margo

ted
Site Admin
Posts: 5704
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: v_init updating between the gui runcontrol and hoc code

Post by ted » Fri Apr 16, 2010 1:36 pm

So tell me if I understand correctly.
margopolo wrote:In my hoc code, I set v_init=-70 as a global parameter, and then in my initialization section I set my e_pas=v_init. Everything seems to run fine
by which you mean that e_pas is -70, right?
when I change the v_init value in the run control (say to -10)
And when are you making this change? _After_ the statement
e_pas=v_init
has been executed, right?
but . . . e_pas is still at -70.
as it should be, because execution of the statement
e_pas = v_init
causes evaluation of the expression on the right hand side of the = sign, and assigns the numerical outcome of that evaluation to the variable on the left hand side of the = sign. In other words, e_pas is not a pointer or an object reference. The assignment statement does not forge a permanent link between e_pas and the stuff on the right hand side. e_pas gets what it gets at the time that the statement is executed.

If you want updates to v_init to also affect e_pas, you need to execute
e_pas = v_init
before you launch a simulation. You could do this with a custom proc init().

Code: Select all

proc init() {
  e_pas = v_init
  finitialize(v_init)
  if (cvode.active()) {
    cvode.re_init()
  } else {
    fcurrent()
  }
  frecord_init()
}

Post Reply