how to solve this ODE

16 views
Skip to first unread message

qiu zhanlong

unread,
Jul 8, 2015, 11:51:41 AM7/8/15
to scikits-b...@googlegroups.com

Hi folks,
I am kind of new to the BVP solver, I found it is very confusing for me to understand what is and how to format the singular points, the boundary_conditions_derivative, and function_derivative basing on the few examples online.


My current ODE problem may require me to implement the singular points, boundary_conditions_derivative, and function_derivative into my code. Thus I need to seek help from you guys, and any suggestion is appreciated.


Below is the ODE and the boundary conditions I have














This is the my BVP code, which can only find the trivial solution, namely y(x)=0, other than that, it always generates error code, stating that the Newton iteration failed.


import numpy

import scikits.bvp_solver as bvp


epsilon=10**(-6)

b=0.3

k=10


def Fode(x,y):

    return numpy.array([y[1],y[2],y[3],(((y[1]**2-y[0]*y[2])/16.0+(y[1]**2)/4.0)*y[2]-y[0]*(k**2)*((k**2)*(y[2]**2)/4.0+(x**2-b**2)/2.0))/epsilon-(-2*(k**2)*y[2]+(k**4)*y[0])])


def Fbc(ya,yb):

    bca=numpy.array([ya[2],epsilon*(-ya[3]+2*(k**2)*ya[1])+ya[1]*((ya[1]**2)/4.0+(ya[1]**2-ya[0]*ya[2])/16.0)])

    bcb=numpy.array([yb[2],epsilon*(-yb[3]+2*(k**2)*yb[1])+yb[1]*((yb[1]**2)/4.0+(yb[1]**2-yb[0]*yb[2])/16.0)])

    return bca, bcb



def guess_y(x):

    if x<0.3:

        return numpy.array([(2*(b**2-x**2))**(0.5)/k,

                                     -2**(0.5)*x/(k**(b**2-x**2)**(0.5)),

                                     -(2)**(0.5)*b**2/(k*(b**2-x**2)**(1.5)),

                                     -3*(2)**(0.5)*b**2*x/(k*(b**2-x**2)**(2.5))])

    else:

        return 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,0.5),

                                                 function=Fode,boundary_conditions=Fbc)


solution=bvp.solve(bvp_problem=problem,solution_guess=guess_y,trace=1)




Robert Schroll

unread,
Jul 8, 2015, 4:58:39 PM7/8/15
to scikits-b...@googlegroups.com
On Wed, Jul 8, 2015 at 11:51 AM, qiu zhanlong <com...@gmail.com> wrote:
> This is the my BVP code, which can only find the trivial solution,
> namely y(x)=0, other than that, it always generates error code,
> stating that the Newton iteration failed.


As you're probably aware, the way that boundary-value solvers tend to
work is to start with a guess for the solution and then refine it to
reduce the error. As with any minimizer, there are regions of the
domain that will not converge to the correct solution. Choosing a good
initial guess is crucial.

> epsilon=10**(-6)
>

I haven't played with you system at all, but I suspect that this is the
problem. Having such a small parameter probably means that you'll have
a small features in your solution which will likely be missing from any
large-scale initial guess. I suspect you need a better initial guess
that respects that.

Have you tried solving the system with a larger epsilon, 0.1 or 0.01?
In my experience, this will increase the likelihood of a successful
solution. Once you have a solution for a large epsilon, you might try
using that as an initial guess for a smaller epsilon, and with a little
luck you may be able to ratchet yourself down to 10^-6.

You may also be able to take advantage of knowledge of the expected
form of a solution. If you know that some feature should scale like a
given power of epsilon, you can rescale your solution at large epsilon
before using it at smaller epsilon.

Good luck,
Robert



qiu zhanlong

unread,
Jul 8, 2015, 5:59:15 PM7/8/15
to scikits-b...@googlegroups.com
Hi Robert,
it's so surprising to bump into you here.

I think my equation is very similar to what Cerda had solved before. I am currently checking his code. 

I took you suggestion to try larger epsilon, then no error message was generated, however, the solution is always the trivial one, namely y(x)=0 in the whole region.

Because of my correct initial guess, I would expect to see a non-zero continuous shape, exhibiting a boundary layer effect induced by the small epsilon.

Do you have any experience about how to obtain the non-trivial solution?

thanks

Zhanlong 

Reply all
Reply to author
Forward
0 new messages