Conversation
| For details refer to (Bandyopadhyay & Rabuffo et al. 2023) | ||
| """ | ||
|
|
||
| x = state_variables[0] |
There was a problem hiding this comment.
you can probably tuple unpack this like
x, V, n, DKi, Kg = state_variables|
|
||
| # helper functions | ||
|
|
||
| def m_inf(V): |
There was a problem hiding this comment.
does numba compile this efficiently?
There was a problem hiding this comment.
indeed decoration with @njit is more efficient
| r = R_minus[0] * x / numpy.pi | ||
| Vdot = (-1.0 / Cm[0]) * (I_Na + I_K + I_Cl + I_pump) | ||
|
|
||
| if_xdot = Delta[0] + 2 * R_minus[0] * (V - c_minus[0]) * x - J[0] * r * x |
There was a problem hiding this comment.
I'd prefer to see these if else terms factored for readability. e.g.
Vsmall = V <= Vstar
RVc = where(Vsmall, R_minus[0]*(V-c_minus[0]), R_plus[0]*(V - c_plus[0]))
dx[0] = Delta[0] + 2*RVc*x - J[0]*r*xor even better just
if V <= Vstar:
R, c = R_minus[0], c_minus[0]
else:
R, c = R_plus[0], c_plus[0]
dx[0] = Delta[0] + 2*R*(V - c)*x - J[0]*r*x
makes it clear that we're just switching two parameter values on the V <= Vstar branch not the whole expression
There was a problem hiding this comment.
agreed. added the necessary reshapes also
| if_Vdot = Vdot - R_minus[0] * x ** 2 + eta[0] + (R_minus[0] / numpy.pi) * Coupling_Term * (E[0] - V) | ||
| else_Vdot = Vdot - R_plus[0] * x ** 2 + eta[0] + (R_minus[0] / numpy.pi) * Coupling_Term * (E[0] - V) | ||
|
|
||
| dx[0] = numpy.where(V <= (Vstar * numpy.ones_like(V)), if_xdot, else_xdot)[0] |
There was a problem hiding this comment.
why is there a [0] at the end of this expression?
There was a problem hiding this comment.
the np.where was removed and so the [0]
maedoc
left a comment
There was a problem hiding this comment.
I left some minor comments. I didn't check the math in the numba is the same as numpy, I trust you have checked.
Hi
I added the numba dfun as I was working on cosimulation for this model anyway.
Michiel.