# Finite Element - Flux Calculation

I am solving an advection-diffusion equation using the FEM and am having trouble calculating my fluxes.

$$\frac{\partial n}{\partial t} = \frac{\partial j_{n}}{\partial x}\, ,$$

Where my flux (current density) is given by,

$$j_n = \mu E n + D \frac{\partial n}{\partial x}\, ,$$

where $$\mu$$ is my drift velocity and $$D$$ the diffusion coefficient.

Solving this equation using FEM-FCT to ensure stability I obtain my nodal values of , which I then use to solve for my fluxes.

The issue I am having currently is that my steady state current density should be zero, where an in-built field causes the drift and diffusion terms to balance, however I am obtaining non-zero current densities.

In order to determine the cause of this, I plotted the two components of the current density in the following plot, and as is seen the two are not equal. I am wondering if it has to do with how the drift flux uses the calculated $$n$$ directly while the diffusion flux requires a derivative which will introduce error.

Any help in generating more accurate fluxes would be appreciated.

A few notes: FEM-FCT limits me to linear basis functions, however I tried to create a higher order first derivative matrix just using finite differences however that did not seem to fix the problem.

• Welcome to SciComp.SE, for future reference you can type your equations right in your question since it supports MathJax. – nicoguaro Mar 12 '19 at 13:54
• Regarding your question, you mean that the two lines in your plot are different, right? At first glance, they look (about) the same to me. – nicoguaro Mar 12 '19 at 13:55
• They look close but begin to deviate towards the boundary. The boundary itself isn't a problem as I know the flux on the boundary. The main issue is that I would like the fluxes to be as accurate as possible, which in this case should equate to equal drift and diffusion fluxes, I can simply increase the spatial resolution but this too only helps to a certain degree. – MGreen Mar 12 '19 at 15:24
• In "regular" FEM derivatives are not continuous and you need to do some smoothing afterward if you want to visualize it as a smooth field. I don't know about FEM-FCT (Flux-corrected transport), though. – nicoguaro Mar 12 '19 at 15:48
• Okay, would you be able to point me to some material that would help me implement this? – MGreen Mar 12 '19 at 16:05

If you are using a (classical) finite element formulation you have $$C^0$$ continuity, that is, your function is continuous but its derivatives are not. Thus, it is expected to have that behavior towards the end, since there the derivatives are larger. As you refine these two curves will get closer to each other.