You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Is the oscillation in the picture a boundary condition problem?
16 Comments
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.
Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)