### Mass conservation check in FEniCS

233

views

0

Hello,

I am using a solver similar to ft09_reaction_system.py (https://github.com/hplgit/fenics-tutorial/blob/master/pub/python/vol1/ft09_reaction_system.py) for solving an advection-diffusion equation, with the only difference being that I am only solving one equation (not three, as in the example). I'm able to run the script, and plot the results.

I would like to do a mass conservation check on the results, i.e. assuming a medical application, where x gm of a drug (source term) is injected at a particular point in the mesh over the course of a complete simulation, I would like to check the amount of the drug in the entire mesh at the end of the simulation. The mass conservation check will be a part of the post-processing, and will be run after ft09_reaction_system.py.

I looked for similar examples, but could not find any. Any help will be greatly appreciated.

Thank you,

I am using a solver similar to ft09_reaction_system.py (https://github.com/hplgit/fenics-tutorial/blob/master/pub/python/vol1/ft09_reaction_system.py) for solving an advection-diffusion equation, with the only difference being that I am only solving one equation (not three, as in the example). I'm able to run the script, and plot the results.

I would like to do a mass conservation check on the results, i.e. assuming a medical application, where x gm of a drug (source term) is injected at a particular point in the mesh over the course of a complete simulation, I would like to check the amount of the drug in the entire mesh at the end of the simulation. The mass conservation check will be a part of the post-processing, and will be run after ft09_reaction_system.py.

I looked for similar examples, but could not find any. Any help will be greatly appreciated.

Thank you,

Community: FEniCS Project

### 1 Answer

3

You can integrate scalar quantities with assemble(), e.g.,

for the integral of u_1 over the domain.

`integral_of_u_1 = assemble(u_1*dx)`

for the integral of u_1 over the domain.

that was simple enough, thank you!

written
5 months ago by
Sophia Wright

Please login to add an answer/comment or follow this question.