How to couple interface of two domains in MATLAB?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Taj
2023-10-12
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.
回答(1 个)
Bill Greene
2022-9-6
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
1 个评论
Francesco Santoni
2024-4-11
Hello,
how would you implement a different Neumann boundary condition, such as: ?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!