New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use 2d-array of 'u0'? #18
Comments
@cfunc(lsoda_sig)
def rhs(t, u, du, p):
u_2D = nb.carray(u, (1,2))
# rest of function goes here
du[0] = u_2D[0,0]-u_2D[0,0]*u_2D[0,1]
du[1] = u_2D[0,0]*u_2D[0,1]-u_2D[0,1]*p[0]
funcptr = rhs.address
u0_2d = np.array([[5.,0.8]])
u0 = u0_2d.flatten()
data = np.array([1.0])
t_eval = np.linspace(0.0,50.0,1000)
usol, success = lsoda(funcptr, u0, t_eval, data = data) |
@Nicholaswogan Perfect! ;) Thanks a lot! |
I have an additional question. Can I not use slicing? def swing_lsoda(network, N):
rhs = swing_cover(network)
funcptr = rhs.address
...
data = np.array([1.0])
usol, success = lsoda(funcptr, u0, t_eval, data = data)
@nb.cfunc(lsoda_sig) # network
def rhs(t, u, du, p): # p0=m, p1=gamma, p2=P, p3=K
# u_2D = nb.carray(u, (N,2))
Interaction = p[3] * SinIntE(network, u[:N])
du[0] = u[N:] #Thetas of nodes
du[1] = 1/p[0]*(p[2] - p[1]*u[N:] - Interaction) #Omegas of nodes |
You can slice, but only after you have converted @nb.cfunc(lsoda_sig) # network
def rhs(t, u, du, p):
u_2D = nb.carray(u,(N,2))
# `u_2D` can be sliced, but `u` can not be
u_1D = nb.carray(u,(N*2))
# `u_1D` can be sliced as well |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to use the 2d-shape initial values of the multiple-particles system. But, I think I cannot use the slicing or indexing.
How can I try it?
The text was updated successfully, but these errors were encountered: