Python: Problem with SciPy solve_bvp ODE function

Viewed 94

I´m working on solving a system of ODE´s and have some problems to understand how to correctly set the boundary conditions which (maybe) relates to me not getting any solution.

I need to solve these equations for a high x value down to x~0:

differential equations

and the following boundary conditions:

v(x=1) = 1 & a(x=1) = 2

The code I wrote sofar looks like this:

def func(x, r):
    v, a = r
    dvdx = ( ((x - v)*a - 2/x ) * (x - v) ) / ( (x - v)**2 - 1 )
    dadx = ( (a - 2/x * (x - v)) * (x - v) )*a / ( (x - v)**2 - 1 )
    return dvdx, dadx

def bc(rv, ra):
    return np.array((rv[1], ra[1]-2))

x = np.linspace(0.1, 100, 1000)
y = np.zeros((2, x.size))

sol = solve_bvp(func, bc, x, y)

But when I execute the code I get devision by 0 errors. Which makes sense, since the denominator of my equation will be 0 for x=1. But shouldn't the boundary conditions account for that?

0 Answers
Related