dhruvbhagtani / toy-model

This is a hybrid model of the global ocean with simplified governing equations to understand large scale circulations.
4 stars 0 forks source link

Advection equation 1D #6

Open navidcy opened 3 years ago

navidcy commented 3 years ago

Let's start with the advection equation in 1D

∂φ/∂t + u ∂φ/∂x = 0

where u = constant and φ(x, t) a tracer concentration.

(I hope this is not boring...)

dhruvbhagtani commented 3 years ago

Okay, I've got this notebook, which has periodic boundary conditions, and it has a sine curve, instead of a gaussian curve, and it moves a distance with a constant velocity a. I've plotted both the numerical and analytical solution using a backward, forward(not shown in the notebook since the case I'm taking has a positive advection speed, and forward difference is unstable) and central difference schemes.

I've also plotted a convergence scheme, and while the stability of backward difference increases with the number of points, the central difference stability doesn't show such a straightforward curve. It shows a second order stability up to a certain number of points, but if we increase the number of points further, the error increases. I've seen this happen often due to roundoff error increasing, but we don't have so much points such that roundoff errors can play any significant part (or so I think). Do you have any suggestions?

navidcy commented 3 years ago

I’ll look tomorrow!

But is forward scheme always unstable? Do you know how to do stability analysis a la von Neumann? If not we can chat about it when we talk next.

navidcy commented 3 years ago

Why you didn’t like my gaussian suggestion? You seem to imply that you can’t have periodic bcs with gaussian initial condition. Am I interpreting the hidden messages correctly? :)

navidcy commented 3 years ago

@dhruvbhagtani2105 I had a look and have lots of questions. The notebook is not self-explanatory. Shall we talk perhaps or shall I write my comments here?

navidcy commented 3 years ago

But before addressing the notebook I'd like to discuss 1) why you think that gaussian won't work? did you try it? (I have tried it.) 2) forward in time, backwards in space scheme is not unstable necessarily, why do you say that? That is, if we denote φ(x_j, t_n) = φⱼⁿ then why do you claim that (φⱼⁿ⁺¹ - φⱼⁿ) / dt = -U (φⱼⁿ-φⱼ₋₁ⁿ) / dx is unstable?

dhruvbhagtani commented 3 years ago

Yes, I know how to do von Neumann stability analysis, and the forward (backward) Euler explicit scheme is unstable for negative (positive) advection velocity. Did these doubts go away after our chat yesterday?

navidcy commented 3 years ago

Yes, just wanted to be sure you know how to do that. Great!

Do you have a feeling intuitively why forward scheme for space won't work when you have a positive advecting velocity?