Al momento, stai seguendo questa domanda
- Vedrai gli aggiornamenti nel tuofeed del contenuto seguito.
- Potresti ricevere delle e-mail a seconda delle tuepreferenze per le comunicazioni.
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 Commenti
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)
Risposte (0)
Vedere anche
Categorie
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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-Pacifico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)