이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
I just started to learn simulation about PDEs and encountered difficulties. How can I use method-of-lines to solve the following three variables and draw a graph?
조회 수: 2 (최근 30일)
이전 댓글 표시
댓글 수: 13
Umar
2024년 8월 21일
Hi @Yidan,
Could you please write these equations in text format, so they are legible enough to implement in Matlab. For example, I don’t know if you wrote dt or alpha with subscript t or Beta or B etc
Torsten
2024년 8월 21일
편집: Torsten
2024년 8월 21일
What problems do you encounter to modify the solution I gave you for a 2-component system to a 3-component system ?
If you have problems using MATLAB, try MATLAB Onramp for an introduction to MATLAB free-of-costs to learn the basics of the language:
If you have problems with the numerics of hyperbolic equations, consult a textbook.
Another option is to use the trick suggested by Bill Greene to make "pdepe" work for your problem. Using "pdepe" for hyperbolic systems is problematic because one of the boundary conditions has to be artificially set and often, the computed solution shows some oscillations because the discretization scheme is not adequate. But the general trend should be ok.
Yidan
2024년 8월 21일
편집: Yidan
2024년 8월 21일
Thank you very much for your reply again! !!
After the first question, I learned the method called method of lines and used pdepe again according to Bill Greene suggestion.
(1) In this problem with three variables, since f(x,t,u,∂u∂x)=0 is set, the value of q(x,t) does not affect the result according to theory, but I found that different values of q(x,t) have a great impact on the result, so I asked again.
The code about this question(picture) is :
function [c,f,s] = pdefun(x,t,u,dudx) % Equation to solve
c = [1; 1; 1];
f = [0; 0; 0];
s = [-0.6; 1.32; 10].*dudx+[-1; -1; 0].*u;
end
function u0 = pdeic(x) % Initial Conditions
u0 = [sin(pi*x); sin(pi*x) ; 0];
end
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t) % Boundary Conditions
pl = [2.2*ul(2)+ ul(1); 0; 0];
ql = [0; 1; 1];
pr = [-ur(2)+0.19*ur(1)+ul(3); 0; ur(3)];
qr = [0; 1; 1];
end
x = linspace(0,1,100);
t = linspace(0,1,30);
m = 0;
sol = pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
u3 = sol(:,:,3);
surf(x,t,u1)
title('u_(x,t)')
xlabel('Distance x')
ylabel('Time t')
If you choose different q, the result changes. I don't whether i made some mistakes.
(For example, if ql = [0; 1; 1];qr = [1; 1; 1]; The sesult changes)
(2) And I tried to use the method of lines on this three variables, and the error was the problem of array index. I think I haven't fully understood it yet, but it is difficult to find materials to study and code analysis, so I want to learn and understand by comparing the codes of different variables.
I sincerely thank you for your detailed answer.
Torsten
2024년 8월 21일
편집: Torsten
2024년 8월 21일
p must be set to 0 and q must be set to 1 (or any other value) for those equations and boundary points for which you don't have a boundary condition - thus for alpha at x = 1 and for beta and Z at x = 0. p must be set to the value and q must be set to 0 for those equations and boundary points for which you have a boundary condition - thus for alpha at x = 0 and for beta and Z at x = 1. So can you spot your mistakes in the boundary function ?
Yidan
2024년 8월 21일
I think may be the boundary condition is :
pl = [2.2*ul(2)+ ul(1); 0; 0];
ql = [0; 1; 1];
pr = [-ur(2)+0.19*ur(1)+ul(3); 0; ur(3)];
qr = [0; 1; 0];
but if I change it as:
pl = [2.2*ul(2)+ ul(1); 0; 0];
ql = [0; 1; 1];
pr = [-ur(2)+0.19*ur(1)+ul(3); ur(3); 0];
qr = [0; 0; 1];
it doesn't work, why?
Torsten
2024년 8월 21일
편집: Torsten
2024년 8월 21일
Both solutions are wrong.
pl(1) = 2.2*ul(2)+ ul(1),
ql(1) = 0,
pr(1) = -ur(2)+0.19*ur(1)+ul(3),
qr(1) = 0
means that you set boundary conditions for alpha at x = 0 as well as at x = 1.
But this is not correct. You can only set a boundary condition for alpha at x = 0.
Torsten
2024년 8월 21일
Sorry, but this is really a level of logic you should understand by yourself from what I said:
p must be set to 0 and q must be set to 1 (or any other value) for those equations and boundary points for which you don't have a boundary condition - thus for alpha at x = 1 and for beta and Z at x = 0.
p must be set to the value and q must be set to 0 for those equations and boundary points for which you have a boundary condition - thus for alpha at x = 0 and for beta and Z at x = 1.
Yidan
2024년 8월 21일
Thanks.
I rethought my thoughts and I think it should be like this:
pl = [2.2*ul(2)+ ul(1); 0; 0];
ql = [0; 1; 1];
pr = [0; -ur(2)+0.19*ur(1)+ul(3); ur(3)];
qr = [1; 0; 0];
Yidan
2024년 8월 21일
Thanks!!!
This is my first time to learn how to use Matlab to simulate PDE. I sincerely thank you for your guidance.
Next, I will learn how to use the method of lines to simulate.
답변 (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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)