# [SciPy-User] scipy.integrate.solve_bvp with explicit dependence on independent variable? Classic List Threaded 3 messages Reply | Threaded
Open this post in threaded view
|

## [SciPy-User] scipy.integrate.solve_bvp with explicit dependence on independent variable?

 Hello all, I am trying to use scipy.integrate.solve_bvp to solve a boundary value problem of a function in one variable -- $\phi(r)$ --  for a cylindrical geometry. The examples here are pretty good: https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.integrate.solve_bvp.htmlHowever, when casting into a ocupled first-order system, the issue here is that I have explicit dependence on the independent variable $r$. When I write the equivalent of >>> def fun(x, y): ...     return np.vstack((y, -np.exp(y))) , the interpreter promptly replies "TypeError: only length-1 arrays can be converted to Python scalars" -- this makes sense, since So, can scipy.integrate.solve_bvp be used in problems where there's an explicit dependence on $r$, for functions where the right-hand side is F(dq/dx, q, r)? Cheers! -- Boyan Penkov _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

## Re: scipy.integrate.solve_bvp with explicit dependence on independent variable?

 ke, 2017-10-25 kello 16:01 -0400, Boyan Penkov kirjoitti: [clip] > So, can scipy.integrate.solve_bvp be used in problems where there's > an > explicit dependence on $r$, for functions where the right-hand side > is > F(dq/dx, q, r)? Does "dq/dx" mean "dq/dr" and equation of type d^2 q/dr^2 = F(dq/dr, q, r) Then the yes, the independent variable is the first argument in "def fun(r, y)". If this is not what you are looking for, if you write explicitly the first order system you want to solve maybe better answers come. -- Pauli Virtanen _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

## Re: scipy.integrate.solve_bvp with explicit dependence on independent variable?

 --Boyan Penkovwww.boyanpenkov.com On Oct 25, 2017, at 18:51, Pauli Virtanen <[hidden email]> wrote:ke, 2017-10-25 kello 16:01 -0400, Boyan Penkov kirjoitti:[clip]So, can scipy.integrate.solve_bvp be used in problems where there'sanexplicit dependence on $r$, for functions where the right-hand sideisF(dq/dx, q, r)?Does "dq/dx" mean "dq/dr" and equation of typed^2 q/dr^2 = F(dq/dr, q, r)Whoops, yeah….  you are correct, I do indeed mean dq/dr...Then the yes, the independent variable is the first argument in "def fun(r, y)". If this is not what you are looking for, if you writeexplicitly the first order system you want to solve maybe betteranswers come.The issue seems to be that I then generally have x = linspace(….)which makes the output of fun(x,y) have length len(x) + 1 and not just 2, as may be expected.Is there a syntactic solution to this?-- Pauli Virtanen_______________________________________________SciPy-User mailing list[hidden email]https://mail.python.org/mailman/listinfo/scipy-user_______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user