Second order nonlinear solution with Scipy (draft).

March 17, 2013 at 00:36 - by eelvex   |   no comments (Leave a comment)

Share on RedditShare on FacebookShare on Google+Tweet about this on TwitterShare on StumbleUponPrint this page

U_{xx} U_x^{-2/3} + kU^{1/3} + c = 0

Split like this to make a system:

\begin{align*}
\frac{d}{dx}{\phi_0} &= \phi_1\\
\frac{d}{dx}{\phi_1} &= -\phi_1^{2/3}(k\phi_0^{1/3} + c)
\end{align*}
where \phi_0(x) = U(x), \phi_1 = U_x(x)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import scipy
import scipy.integrate

k = 1.0
c = 0.0

def system_d(phi, x=0):
    y = [phi[1], -phi[1]**(2/3)*(k*phi[0]**(1/3) + c)]
    return y

if __name__ == "__main__":
    x = scipy.linspace(0, 15, 1000)
    phi_init = scipy.array([0, 0])
    phi = scipy.integrate.odeint(system_d, phi_init, x)
No tips yet.
Be the first to tip!
Like this post? Tip me with bitcoin!

1Kaxd6KGJ8MGLUm7UsGth5NdQMji5vBbHp

Share on RedditShare on FacebookShare on Google+Tweet about this on TwitterShare on StumbleUponPrint this page
{ Tags: , , }

no comments

RSS / trackback

respond

Real Time Analytics