Search code examples
python-2.7scipyscikits

scikits.bvp_solver generates ValueError: too many values to unpack


I will start with a very simple ODE, which generates the same error code by using scikits.bvp_solver as I applied to complex ODE. Below is the ODE and the boundary conditions:

f''''(x)=f(x), f(0)=0, f'(1)=1, f''(0)=1, f'''(1)=1

The code for solving this ODE:

import numpy
import scikits.bvp_solver as bvp
def Fode(x,y):
    return numpy.array([y[1],y[2],y[3],y[0]])
def Fbc(ya,yb):
    return (numpy.array([ya[0]]),numpy.array([yb[1]-1]),
            numpy.array([ya[2]-1]),numpy.array([yb[3]-1]))
guess=numpy.array([0.0,0.0,0.0,0.0])

problem=bvp.ProblemDefinition (num_ODE=4,num_parameters=0,
                               num_left_boundary_conditions=2,
                               boundary_points=(0,1),
                               function=Fode,boundary_conditions=Fbc)
solution=bvp.solve(bvp_problem=problem,solution_guess=guess)

when I run this code, I receive:

enter image description here

I can not figure out what is the problem, since the same code works well for 2nd order ODE. Any comment is appreciated.


Solution

  • Your Fbc function should return exactly two arrays, one containing function value differences for boundary conditions at the left, the other one containing the values at the right.

    See https://pythonhosted.org/scikits.bvp_solver/tutorial.html#defining-the-problem

    https://pythonhosted.org/scikits.bvp_solver/examples/examples.example4.html