이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Is the oscillation in the picture a boundary condition problem?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1753734/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1753739/image.jpeg)
댓글 수: 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.
![](/matlabcentral/answers/uploaded_files/1754909/IMG_7494.jpeg)
답변 (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 (한국어)