Dear Sage users,

How can I make the the scipy.integrate odeint function returns a Sage function as a function of the independent variable (e.g t)?

In my example (see http://aleph.sagemath.org/?q=e1bf244c-6518-4637-8d3e-d32de7ab0367 or the code bellow) i obtain a NumPy array that I have to zip with the independent variable to get a plot. Ideally, i would like to obtain a Sage function to operate on it.

Thanks a lot in advance!

-- Code --


# Two-state kinetic model
#
#        alpha*[cc]
# (1-n) ----------> n
# <----------
#          beta

from numpy import linspace
from scipy.integrate import odeint

# define a square pulse with the concentration of Glu

def pulse(t):
    """ t in ms """
    if t<=2 or t>=3:
        return 0.0
    else:
        return 1.0 # in mM

# Plot Glu concentration
time = linspace(0,10, 1000) # 10 ms


# define differential equation

def diff(n, t, alpha, beta):
    """
    alpha in 1/(mM*ms)
    betha in 1/ms
    """
    cc = pulse(t) # square pulse
    return alpha*cc*(1-n)-beta*n

# and solve it for alpha = 1 and beta = 1
y = odeint(func = diff, y0=0, t= time, args=(1,1))

# and plot the conductance
list_plot(zip(time, y), figsize=[4,3], plotjoined=True)


--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to