CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Adding linear generation in InterFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/119151-adding-linear-generation-interfoam.html)

voingiappone June 10, 2013 22:51

Adding linear generation in InterFOAM
 
Hello everybody,

I am trying to do something which is probably trivial but I don't find the proper formulation.
I have managed to add a tracer in my InterFOAM simulation by adding a jump condition as per this thread. Now I just want to overcome the lack of chemical reactions in the modified solver by adding a simple parameter. I can calculate an approximate generation term knowing the daily performance of my reactor (it is a bioreactor so it is really slow) and I can add it as follow (the K parameter):

\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C -\nabla K_{gen} = \nabla \cdot D C_{eq}\nabla \alpha

Let's say I have algae growing on CO2 and I want to see how its concentration decreases along the X axis only (linear reactor with negligible culture depth solved in 2D neglecting the y direction). How do I specify not to solve the \nabla K_{gen} along the z axis???

I am quite sure it's a really easy task but I don't know even what to look for.

Thank you everybody for your help

Luca

akidess June 11, 2013 04:05

Quote:

Originally Posted by voingiappone (Post 433250)
Hello everybody,

I am trying to do something which is probably trivial but I don't find the proper formulation.
I have managed to add a tracer in my InterFOAM simulation by adding a jump condition as per this thread. Now I just want to overcome the lack of chemical reactions in the modified solver by adding a simple parameter. I can calculate an approximate generation term knowing the daily performance of my reactor (it is a bioreactor so it is really slow) and I can add it as follow (the K parameter):

\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C -\nabla K_{gen} = \nabla \cdot D C_{eq}\nabla \alpha

Let's say I have algae growing on CO2 and I want to see how its concentration decreases along the X axis only (linear reactor with negligible culture depth solved in 2D neglecting the y direction). How do I specify not to solve the \nabla K_{gen} along the z axis???

I am quite sure it's a really easy task but I don't know even what to look for.

Thank you everybody for your help

Luca

Would this be feasable:
\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C -\nabla K_{gen}\cdot \left(\begin{array}{c}1\\1\\0\\\end{array}
\right) = \nabla \cdot D C_{eq}\nabla \alpha

voingiappone June 12, 2013 21:30

Quote:

Originally Posted by akidess (Post 433290)
Would this be feasable:
\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C -\nabla K_{gen}\cdot \left(\begin{array}{c}1\\1\\0\\\end{array}
\right) = \nabla \cdot D C_{eq}\nabla \alpha

Akidess, thanks for the quick reply.
Of course what you wrote is right but I don't know how to translate it in viable code. The equation I wrote in my post above is now (before additions):

Code:

fvm::ddt(C)
+ fvm::div(phi, C)
+ fvm::laplacian(DC, C)
- fvc::laplacian(DCeq, alpha1)

I am using this code on a daily base without problems. Now, I don't have any clue on how to implement that vector... So, in coding language, what should I write? Looking through the documentation I found the product between two vectors needs to be represented like [A & B], thus:

Code:

fvm::ddt(C)
+ fvm::div(phi, C)
+ fvm::laplacian(DC, C) & (1 1 0)
- fvc::laplacian(DCeq, alpha1)

Would this be correct?

Thank you.

akidess June 13, 2013 04:14

Your code does not match your equation. You completely dropped grad(K)?
Code:

fvm::ddt(C)
+ fvm::div(phi, C)
+ fvm::laplacian(DC, C)
+ fvc::grad(K) & vector(1 1 0)
- fvc::laplacian(DCeq, alpha1)


voingiappone June 13, 2013 04:40

Quote:

Originally Posted by akidess (Post 433740)
Your code does not match your equation. You completely dropped grad(K)?
Code:

fvm::ddt(C)
+ fvm::div(phi, C)
+ fvm::laplacian(DC, C)
+ fvc::grad(K) & vector(1 1 0)
- fvc::laplacian(DCeq, alpha1)


You're right... sorry! I just copy-pasted it from the other file (present formulation) and forgot to add the grad(K) part.
Thank you very much for your help in the proper formulation too! I will add it in the code and post the results even though I suppose it will work right out of the box.

Thank you for your kind help!

akidess June 13, 2013 04:50

Quote:

Originally Posted by voingiappone (Post 433742)
You're right... sorry! I just copy-pasted it from the other file (present formulation) and forgot to add the grad(K) part.
Thank you very much for your help in the proper formulation too! I will add it in the code and post the results even though I suppose it will work right out of the box.

Thank you for your kind help!

Actually, no. I just realized I forgot to add commas between the components of the vector ;)

voingiappone June 13, 2013 04:54

Okey dokey!

Actually I thought it was right that way.... why would you use different notations for the same vector in different part of OF (ie the source files and the boundary conditions)? Will place also the commas then!

akidess June 13, 2013 05:12

In C++ you don't really have a choice - the compiler won't treat the whitespace as delimiter for the arguments (as it does with commas). Why the makers of OpenFOAM decided to go with a different syntax in the case files only they know ;)

voingiappone June 14, 2013 00:47

It works like a charm!!
Thank you for the hints and help :D

Luca


All times are GMT -4. The time now is 10:05.