Is the oscillation in the picture a boundary condition problem?
16 个评论
Hi @Rahul,
As I understand that you are probably thinking that reason for your oscillations are due to arising from insufficient resolution or inappropriate boundary conditions, that is why you keep asking @Torsten to suggest ideas to resolve this issue by asking him “ case I want to keep both I and dI/dx to be not equal to zero,in that case how should I write the bc for right boundary?” and round Robin, so for your boundary conditions, if you want to maintain both the variable ( I ) and its derivative dI/dx non-zero at the right endpoint, you can proceed implementing Robin boundary conditions as follows
% Left and right boundary conditions
bc = @(xl, ul, xr, ur) deal(ul - 0, qr*ur - pr);
So, in this code snippet, qr and pr are coefficients that you can adjust to control the behavior of the solution at the boundary. I will also suggest that diffusion coefficient sigma is set to a minimum of 1, as values below this can lead to divergence. Additionally, consider using a higher-order method or applying artificial viscosity to dampen oscillations. This approach will help stabilize your solution while maintaining accuracy.
Afterwards, you mentioned “the equation is a convection-diffusion equation, if I wish to use Robin bc, how should I proceed,”, I would proceed by discretizing the domain by defining spatial grid and time steps. Then, setup the equations for interior points by using the standard finite difference approximations for convection and diffusion. Then, at the boundary, replacing the standard boundary conditions with the Robin condition. For example, at the left boundary (i=1):
u(1) = (g - beta * (u(2) - u(1))/dx) / alpha;
Finally, updating your solution iteratively, so that the Robin condition is applied at each time step.
Hi @Rahul,
The code that you provided was incorrect. So, I had to fix the errors and update the code. Please see attached. Hopefully, this answers your question.
回答(0 个)
另请参阅
类别
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 (한국어)