PDA

View Full Version : ValueError: setting an array element with a sequence



ayamgolek
March 3rd, 2011, 05:06 PM
here is my python programme for a runge-kutta ode. but i dont know how 2 make it right... please help me...

import math,numpy

def rk4_odesolve(d_config_by_dt, config_start,
t0, t_max, nsteps):

"""return the approximation using runge-kutta"""

dt = (t_max-t0)/float(nsteps)
s = config_start
for n in range(nsteps):
s1=d_config_by_dt*(s,t0+n*dt)
s2=d_config_by_dt*(s+numpy.dot(0.5*dt,s1),t0+(n+0. 5)*dt)
s3=d_config_by_dt*(s+numpy.dot(0.5*dt,s2),t0+(n+0. 5)*dt)
s4=d_config_by_dt*(s+numpy.dot(dt,s3),t0+(n+1)*dt)

return s+(1/6)*dt*(s1+2*s2+2*s3+s4)

cgroza
March 3rd, 2011, 05:49 PM
Please put the code in code tags, the indentation has been lost and the code is almost unreadable.

ayamgolek
March 3rd, 2011, 05:56 PM
im sorry,but how do i do that?

cgroza
March 3rd, 2011, 08:09 PM
When you click New Reply, an editor will show up, look for a # button to insert the tags.