# How to couple interface of two domains in MATLAB?

5 views (last 30 days)
Anadi Mondal on 3 Sep 2022
Answered: Bill Greene on 6 Sep 2022
Hello,
Can you give me an idea/useful links/example code of similar type of problem to solve the following problems(variation of u1 and u2 along x asis)? Actually I am struggling with the interface coupling/interface boundary conditions.
Any kinds of suggestion will be appreciated!
Regards,
Anadi Mondal on 6 Sep 2022
Can you send me a link/example code where two pde in two region have been solved with interface boundary conditions?
Regards,

Bill Greene on 6 Sep 2022
As I said, I believe that the expression for S in your definition of the problem is not correct and your explanation did not really clarify this.
Nevertheless, here is a solution using pdepe to the problem I think you may be trying to solve. As I said in my comment, only a single dependent variable (PDE) is needed to describe the problem-- not two as you show in your definition.
function twoRegionExample
a=0; b=1; c=3;
x2=linspace(b,c,20);
N1=10;
x = [linspace(a,b,N1) x2(2:end)];
t = linspace(0,.05,50);
A=10; B=2;
pdeFunc = @(x,t,u,DuDx) heatpde(x,t,u,DuDx,b);
icFunc = @(x) heatic(x, A,B, b);
bcFunc = @(xl,ul,xr,ur,t) heatbc(xl,ul,xr,ur,t,A,B);
m=0;
u = pdepe(m, pdeFunc,icFunc,bcFunc,x,t);
figure; plot(x, u(1,:)); grid on;
title 'initial value'; xlabel 'x';
figure; plot(x, u(end,:)); grid on;
title 'solution at final time'; xlabel 'x';
figure; plot(t, u(:,N1)); grid on;
title 'solution at x=b as a function of time'; xlabel 'time';
end
function [c,f,s] = heatpde(x,t,u,DuDx,b)
c = 1;
D1=10; D2=3;
if(x < b)
f = D1*DuDx;
else
f = D2*DuDx;
end
s = 0;
end
function u0 = heatic(x,T1,T2,b)
if(x < b)
u0 = T1;
else
u0 = T2;
end
end
% --------------------------------------------------------------
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t,A,B)
pl = ul-A;
ql = 0;
pr = ur-B;
qr = 0;
end