# Implementing Robin Boundary condition (finite difference)

I'm interested in applying Robin boundary condition to a convection-diffusion problem in 1D.

In the following system, $$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2} - v\frac{\partial C}{\partial x}$$

$$\frac{\partial C}{\partial t} = \frac{\partial}{\partial x}( D\frac{\partial C}{\partial x} - vC)$$ To implement no-flux boundary condition ,flux $$N = D\frac{\partial C}{\partial x} - vC$$ is set to zero at the left and right boundary.

I'd like to know whether the sign of terms in the flux will vary at the right and left boundary.

According to the following description given in wiki,

Could someone explain if the above-mentioned method is the right way to implement?

I think that the second boundary condition equation is incorrect. The first one should be right for both ends. Following your notation, the flux of mass in the domain should be: $$N = vC - D \frac{\partial C}{\partial x}$$ everywhere including the boundary points.

Keep in mind that the sign of the boundary condition value is positive if the direction of mass flux is positive and vice versa.

• Many thanks for the response . However, I don't understand why you have denoted flux to be vC-DdC/dx and not DdC/dx - vC as represented in my post.Could you please explain? Oct 30 '19 at 2:29
• The total fiux consists of two fluxes: The first one is advective flux that carries mass by the flow. This can be expressed in $vC$, which means the mass $C$ is transported along the direction of the flow. The second one is dispersive (or diffusive) flux that moves mass from higher concentration area to lower one. The direction of this flux is against the concentration gradient, so $-D \partial C / \partial x$.
– KJ N
Oct 30 '19 at 4:46
• Thank you. Your explanation makes sense. But I saw another post here and here that states flux (DdC/dx -vC).n =g .Side note: My flow is in the positive direction Oct 30 '19 at 5:06
• It is amazing and unfortunate to see how inaccurate the information on the internet can be. I would rather recommend this Wikipedia document, en.wikipedia.org/wiki/…, to you. No matter where you look at, the equation should not vary.
– KJ N
Oct 30 '19 at 5:15
• I had a look at the description in the link that you provided. Over there, all the terms are on the LHS and the definition of flux that you stated holds true. But in pdepe solver of MATLAB the expression itself has the form of time derivative on LHS and rest on RHS. I would think in such a case N would be DdC/dx - vC. Second thoughts? Oct 30 '19 at 5:33