3
$\begingroup$

Wave equation. Mixed BC.

Applied Neuman boundary condition ($\frac{\partial u}{\partial x}\big|_N=0$) to the RHS of the domain

You may observe the sharp edge in the middle of the string in the image attached. I do understand it bouncing at Dirichlet BC, but for some reason, it bounces off the Neuman Boundary on the right side as well. So it bounces back and forth from L to R.

P.S. also tried $u_N=u_{N-1}$, same result. (my indexation of nodes is 1 to 101, i.e. last node is 101=n+1).

Could you kindly link any resources of overcoming this issue? Or explain what I am doing wrong at the boundary.

Code for MatLab is attached below.

clc;clear all;clf; close all;
L = 1;
n = 100;
dx = L / n;
ld = 30; 
dt = sqrt(dx^2/ld);
x = 0:dx:L;
u_prev = sin(2*pi*x)+5*sin(3*pi*x);
u = dt*(3*sin(5*pi*x)) + u_prev;
u_new = u + 1;
vareps = 10^-8;
delta = 1; 
ctr = 0;
mplot = 1;
while delta > vareps
    for i=2:n
        u_new(i) = ld*dt*dt*(u(i-1)-2*u(i)+u(i+1))/dx/dx + 2*u(i) - u_prev(i);
    end
    u_new(1)=0;
    u_new(n+1) = -(-4*u_new(n)+u_new(n-1))/3; % Neuman condition du/dx = 0 at Right boundary
    if mplot > 0
        plot(x,u_new); 
        axis([0 1 -50 50])
        drawnow;
        mplot=0;
    end
    delta = max(abs(u-u_new));
    u_prev = u;
    u = u_new;
    
    mplot = mplot + delta;
    ctr = ctr + 1;
end

Update. Tried Thomas method, same results... :(

clc;clear;clf; close all; format long;
n = 101;
dx = 1/(n-1);
dt = 10^-4;
alpha = 3;
u0 = 0;
ux = 0;
m = 1;
yps = 10^-5;
x = 0:dx:1;
prev = ut0(x);
curr = upt0(x)*dt+prev;
next = prev + 1;
prev(1)=0; prev(n)=prev(n-1);
curr(1)=0; curr(n)=curr(n-1);
next(1)=0; next(n)=next(n-1);
a = curr;
b = curr;
ctr = 0;
A = (-1*alpha^2)/(dx^2);
B = (2*alpha^2/dx^2)+(1/dt^2);
C = -1*alpha^2/(dx^2);
while m > yps
    a(2) = 0; b(2) = u0;
    D = (2*curr-prev)/(dt^2);
    %forw
    for i = 2:n-1
        a(i+1) = (-A)/(B + C*a(i));
        b(i+1) = (D(i)-C*b(i))/(B+C*a(i));
    end
    %backw
    next(n)=b(n)/(1-a(n)); % Neuman from P_{n-1}=a_n P_n + b_n P_{n-1}=P_n
    for i = n-1:-1:1  
        next(i)=next(i+1)*a(i+1)+b(i+1);
    end
    if mod(ctr,50)==0 
        plot(x,next,'b');
        axis([0 1 -8 8]);
        drawnow;
    end
    prev  = curr;
    curr = next;
    m = max(abs(prev-curr));
    next = curr+1;
    ctr = ctr+1;
end

function y = ut0(x)
    y = sin(2*pi*x)+5*sin(3*pi*x);
end

function y = upt0(x)
    y = 3*sin(5*pi*x);
end

enter image description here

$\endgroup$
4
  • 2
    $\begingroup$ If you don’t want reflections you need either a radiation condition or a perfectly absorbing boundary, a Neumann condition won’t do it. $\endgroup$ Oct 4 at 0:51
  • $\begingroup$ @Aruralreader thank you! could you kindly link an example to perfectly absorbing boundary condition? I found some articles on the internet, though they require graduate level of understanding :( $\endgroup$
    – 2Napasa
    Oct 4 at 17:04
  • 1
    $\begingroup$ There are some questions on this site about it. If you think that they don't satisfy your needs, consider asking a new question. $\endgroup$
    – nicoguaro
    Oct 4 at 19:08
  • $\begingroup$ @nicoguaro thank you once again! :) $\endgroup$
    – 2Napasa
    Oct 4 at 19:36
4
$\begingroup$

You should get reflection both in Dirichlet and Neumann boundary conditions. The difference is that on the former you get an inversion in the phase while in the latter you get the reflection in phase. You could generalize it to Robin boundary conditions and see that there you also have a reflection. Dirichlet and Neumann can be seen as limit values for the Robin boundary conditions.

If you want a reason for having a reflection, you could say that it is because the lost in (continuous) tanslation symmetry.

If what you want is to have a non-reflecting boundary you need other type of boundary conditions, as mentioned by A rural reader.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.