Boundary conditions with stiff problems
이전 댓글 표시
Hello, I'm trying to solve a system of PDEs that depends on space (1 dimension) and time. I want to solve it using a second order discretization in space and then using ode23s to solve the system of ODEs (method of lines).
The problem is that I have a laplacian operator and I can just integrate in the interior nodes (let's say from 2 to n-1). The values for nodes 1 and n depend on their neighbours and should be updated at each time step.
How could I set these restrictions to solver?
Here is the scheme:
function dydt = fun(t,u)
for j = 2:n-1
impose right hand side function
end
%Now I want to impose the value in y(1) and y(end)
end
답변 (3개)
Torsten
2016년 12월 8일
0 개 추천
Boundary conditions don't depend on neighbour values, but are given independently.
What are the boundary conditions for your PDE ?
Best wishes
Torsten.
댓글 수: 1
Albert Jimenez
2016년 12월 8일
편집: Albert Jimenez
2016년 12월 8일
Torsten
2016년 12월 9일
Use the equations
(u(2)-u(1))/(x(2)-x(1)) = G(u(1))
(u(n)-u(n-1))/(x(n)-x(n-1)) = G(u(n))
to solve for u(1) (u at 0) and u(n) (u at 1).
Then use these values for the discretization in the inner grid points.
Best wishes
Torsten.
Albert Jimenez
2016년 12월 9일
댓글 수: 6
Torsten
2016년 12월 12일
If your boundary condition reads
du/dx = A*(u-B) at x=0 and x=1,
then the discretized form is
(u(2)-u(0))/(2*deltax) = A*(u(1)-B)
(u(n+1)-u(n-1))/(2*deltax) = A*(u(n)-B)
So you have a sign error in your equation from above.
Best wishes
Torsten.
Albert Jimenez
2016년 12월 12일
Torsten
2016년 12월 13일
Your loop
for j=2:n-1
must run from 1 to n.
Best wishes
Torsten.
Albert Jimenez
2016년 12월 13일
Albert Jimenez
2016년 12월 21일
카테고리
도움말 센터 및 File Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!