現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)