How do I use the Boundary Conditions function in pdepe?
1 view (last 30 days)
Show older comments
1) I'm using the below code to graph the heat equation at different times and I want DCdx(0) = 0 for my left boundary condition. However, when I graph it the graph only approaches zero at a faster rate for different times, it never actually crosses zero which is what I want it to do for small times. Am I entering the boundary conditions incorrectly and how do I fix this problem?
2) Also, if I want DCdx(Xc) = 0 for Xc = some critical X that I calculate separately, how do I incorporate that into my code?
function pdex1
m = 0; x = linspace(0,1,20); t = linspace(0,20,50); hold on
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t); C = sol(:,:,1);
hold on plot(x,C(1,:)); % -------------------------------------------------------------- function [c,f,s] = pdex1pde(x,t,u,DCDx) L = 0.1; Dg = 5.2e-6; A = L^2/Dg; c = A; f = DCDx; s = 0; end % -------------------------------------------------------------- function C0 = pdex1ic(z) C0 = 0; end % -------------------------------------------------------------- function [pl,ql,pr,qr] = pdex1bc(xl,Cl,xr,Cr,t) pl = 0; ql = 1; pr = Cr - 1; qr = 0; end end
0 Comments
Answers (0)
See Also
Categories
Find more on Partial Differential Equation Toolbox 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!