How to couple interface of two domains in MATLAB?
9 views (last 30 days)
Show older comments
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
6 Comments
Taj
on 12 Oct 2023
In this case you can defined a double node at the interface u1(b)=u2(b). But in this case you will the problem of ghost point values that youn can solve by using the second coupling condition for example after approximation your nodes e.g x_I is your interface node in the schme for the left hand boundary you will have u1(x_I+1) also for the right hand region you will have u2(x_I-1). These you can interpolate by using one sided approximation as well as the central differnce approximation.
Answers (1)
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
0 Comments
See Also
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!