Non-linear elliptic differential equation - python

In summary, Leon is struggling to solve an equation for u'' which is a function of x. He needs help from someone who understands the material.
  • #1
leonmate
84
1
Hey guys,

I'm going to be honest and say I'm so stuck on this assignment - I really need help!
I've took on a third year computational physics course last year - turn your weaknesses into strengths someone told me.

Well, I failed and I'm back doing it again this year!

So, I just have to pass which means I need 30% in this assignment. But, I'm not getting there on my own - I've struggled to get to grips with the module - I got 20% in my last assignment :'(

Can someone help guide me through it?

So, I've already solved a similar problem, the one I did was:

u''(x) = f(x) = - exp(x) * (-2 + 2x + 5x2 + x3)

Code:
from pylab import *
from scipy import interpolate
       
def EllipticSolver(Nx):
    dx = 1.0/Nx
    pts = linspace(-dx/2.0,1.+dx/2.0,Nx+2)
    soln = zeros(Nx+2)
    rhs = zeros(Nx+2)
    rhs = -exp(pts)*(-2.0 + 2.*pts + 5.*pts**2 + pts**3)
    soln = tridiagonal2(soln,rhs,dx)
    return pts[1:-1], soln[1:-1]
   
def tridiagonal2(dat,d,dx):
    N = len(dat)
    print(N)
    dx2 = 1.0/(dx*dx)
    a = zeros(N)
    b = zeros(N)
    c = zeros(N)
    a[:] = dx2
    c[:] = dx2
    b[:] = -2.0*dx2
   
    b[1] = -1.0*dx2
    b[N-2] = -3.0*dx2
  
    c[1] = c[1]/b[1]
    d[1] = d[1]/b[1]
    for j in range(2,N-1):
        c[j] = c[j]/(b[j] - c[j-1]*a[j])
        d[j] = (d[j] - d[j-1]*a[j])/(b[j] - c[j-1]*a[j])
       
    print(a)
    print(b)
    print(c)
    print(d)
  
    dat[N-2] = d[N-2]
    for j in range(N-3,0,-1):
        dat[j] = d[j] - c[j]*dat[j+1]
   
    return dat

x1, soln1 = EllipticSolver(100)
x2, soln2 = EllipticSolver(200)
x3, soln3 = EllipticSolver(400)

figure(1)
clf()
plot(x1,soln1,'r-')
plot(x2,soln2,'g-')

s2 = interpolate.interp1d(x2,soln2,'cubic')
soln2a = s2(x1)

s3 = interpolate.interp1d(x3,soln3,'cubic')
soln3a = s3(x2)

diff1 = soln1 - soln2a
diff2 = soln2 - soln3a

figure(2)
clf()
plot(x1,diff1,'r-')
plot(x2,4.*diff2,'g-')

Now I have to solve it for:

u'' + 500*exp(-100*x2) - u3 = 0

I guess I rearrange so:

u'' = u3 - 500*exp(-100*x2)

and then solve that

How do I solve it with an x and a u in the equation :O :(

If you've made it this far I love you and please help me, I have until next Wednesday to get this done and I can't do it on my own..... pleeeeeease help I just need 30 damn percent

I attached a copy of the assignmentLeon
 

Attachments

  • Assignment3.pdf
    128.4 KB · Views: 322
Technology news on Phys.org
  • #2
OK, so I've made a little progressFirst thing we have to do is find the finite-difference approximation for the u'' matrix for a staggered grid

So, Newton-Raphson method, discretise using finite-difference approximations of the derivatives

u'' = (ui+1 + ui-1 - 2ui) / dx2

So, the first thing I'm going to have to do is set up some kind of array for u in order to whack it in a for loop and populate it using the above equation

I don't know what 'u' should be here, I could use an array of zeros, but I need some values in order to get something for u''

In the example above, i create the rhs array using the staggered grid I produced called pts

Do I need to make another staggered grid for u, and then use that to make a RHS array:

rhs = zeros(N)
rhs = ui+1 + ui-1 - 2ui / dx2

That wouldn't quite work but something along those lines...
 

1. What is a non-linear elliptic differential equation?

A non-linear elliptic differential equation is a type of differential equation that involves multiple variables and their derivatives, where the highest order derivative appears in a non-linear fashion. It is called 'elliptic' because it typically involves second-order derivatives and has a similar form to the shape of an ellipse.

2. How is Python used to solve non-linear elliptic differential equations?

Python is a programming language that is widely used for scientific computing, including solving differential equations. It has a variety of libraries and packages, such as SciPy and NumPy, that offer powerful tools for solving non-linear elliptic differential equations numerically.

3. What is the difference between a linear and non-linear elliptic differential equation?

A linear elliptic differential equation has the form of a linear combination of functions and their derivatives, while a non-linear elliptic differential equation has non-linear terms, making it more challenging to solve analytically. Linear equations have well-known solutions, whereas non-linear equations often require numerical methods to find solutions.

4. What are some applications of non-linear elliptic differential equations?

Non-linear elliptic differential equations have a wide range of applications in various fields, including physics, engineering, economics, and biology. They are commonly used to model complex systems, such as fluid flow, heat transfer, and chemical reactions.

5. Can non-linear elliptic differential equations be solved analytically?

In most cases, non-linear elliptic differential equations cannot be solved analytically, meaning that there is no exact formula for the solution. Instead, numerical methods, such as finite difference or finite element methods, are used to approximate the solution. However, there are some special cases where analytical solutions are possible.

Similar threads

  • Programming and Computer Science
Replies
1
Views
944
  • Programming and Computer Science
Replies
3
Views
931
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
12
Views
3K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
999
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top