How to solve the following PDE equation
    조회 수: 6 (최근 30일)
  
       이전 댓글 표시
    
채택된 답변
  Torsten
      
      
 2024년 7월 12일
        
      이동: Torsten
      
      
 2024년 7월 12일
  
      I think you mean x(s,0) = 10 instead of x(s,t) = 10, don't you ?
The easiest way to solve the equation is to discretize the expressions on the right-hand side and solve the resulting system of ordinary differential equations using ode15. Here, the integral term can be approximated by MATLAB's "trapz".
Look up "method-of-lines" for more details.
댓글 수: 2
  Torsten
      
      
 2024년 7월 12일
				integral_term = trapz(x, u);
"pdepe" supplies x and u pointwise, not for the complete interval [0,1]. Thus using "pdepe" this way is not possible.
It might be possible using this code for your purpose:
추가 답변 (1개)
  Bill Greene
      
 2024년 7월 12일
        I don't know how to evaluate that integral using pdepe. However, I have written a pde solver (pde1dm) that has an input syntax very similar to pdepe and includes an option that makes this straightforward.
The "vectorized" option tells pde1dm to call your pdefun with a vector of x values spanning the complete spatial domain of your problem. I have included a slightly-modified version of your code below. If you want to try pde1dm, it can be downloaded using the link above.
function matlabAnswers_7_12_2024
theta=solvePDE;
end
function theta = solvePDE
nx=50;
x = linspace(0, 1, nx);
nx2=ceil(nx/2);
t = linspace(0, 10, 100);
if 0
    sol = pdepe(0, @pdefun, @icfun, @bcfun, x, t);
else
    opts.vectorized='on';
    sol = pde1dm(0, @pdefun, @icfun, @bcfun, x, t,opts);
end
theta = sol(:,:,1);
figure; plot(x, sol(end,:)); title 'solution at final time';
figure; plot(t, sol(:,nx2)); title 'solution at center as a function of time';
end
function [c, f, s] = pdefun(x, t, u, dudx)
nx=length(x);
integral_term = trapz(x, u);
c = ones(1,nx);
f = dudx;
s = ones(1,nx)*integral_term;
end
function u0 = icfun(x)
u0 = 30* ones(size(x));
end
function [pl, ql, pr, qr] = bcfun(xl, ul, xr, ur, t)
pl = ul - 30;
ql = 0;
pr = ur - 30;
qr = 0;
end


댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



