CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to add a summison term in the source code (https://www.cfd-online.com/Forums/openfoam/81814-how-add-summison-term-source-code.html)

nakul November 8, 2010 00:03

How to add a summison term in the source code
 
Hi,
I want to add a term like: Σaibi; i=1,2,...,n to a solver's governing equations.
Is there any inbuilt function in
openfoam that can be used to sum the individual terms

I don't think I can use for loop to add the terms because the values of these parameters are obtained simultaneoulsy by the solution of the governing equations.

Any help would be appreciated!!

Thanx



stevenvanharen November 8, 2010 04:28

if a and b are vectors you can use the inner product operator

look at page 18 and 23 of the programmer's guide.

schmittp54 November 8, 2010 07:00

I am not sure if I understand your question correctly.

If both the ai and bi are part of your solution vector and you solve an equation including a*b on the left hand side (like M(a,b)+a*b=c), this is a nonlinear equation. Linearize the equation and you will be able to add the linearized expression for a*b as a source term.

Patricia

nakul November 9, 2010 00:38

1 Attachment(s)
Hi Patricia,

To be more specific I want to code the energy equation for combustion. The energy equation is in the form, shown in the attached screenshot.

The "summision" term that I want to code is the equ. (1. 48) in the screenshot. And this energy equation needs to be solved simultaneously with continuity, momentum and species equations.

So my question is how can I code this term in the OpenFOAM's source code?
I would be adding this term to the energy equation of rhoCentralFoam.

schmittp54 November 9, 2010 03:56

Hi Nakul,
unfortunately the screenshot is still not a complete description of the problem. Maybe you can start coding a solver using similar principles as in the existing OpenFoam solvers. Then describe where your solver fails, and people will be able to assist.
If you want to solve for all variables simultaneously, you have to wait until OpenFoam supports block matrices, and even then you have to linearize the problem. But I don't see why you'd need block matrices. Why not start with a loop summing over the species instead of giving up before you have tried?

Patricia

nakul November 9, 2010 04:17

Hi Patricia,

Actually I was just mentioning the equation, that I want to code, in the screenshot.

The problem is that I am unaware of the correct way to code that summision term in the solver.
All I want to know is that, .if there is some way to add such summision terms.

I don't think that for loop is a correct option because at every time step the values of Yk, ie, the species mass fraction is unkown. They are the variables that are being solved for.

So adding them using a loop might not generate any result.

schmittp54 November 9, 2010 05:36

Quote:

Originally Posted by nakul (Post 282723)
Actually I was just mentioning the equation, that I want to code, in the screenshot.

Yes, but an equation is not a problem description.

Quote:

Originally Posted by nakul (Post 282723)
I don't think that for loop is a correct option because at every time step the values of Yk, ie, the species mass fraction is unkown. They are the variables that are being solved for.

I think you should try things out before you think they don't work. Many of the existing solvers show how to solve for variables that are needed simultaneously. Most of them use the segregrated approach which I think will work for you as well. If you don't want to spend any time by yourself, there are companies behind OpenFoam who can do the work for you (no, I am not affiliated to any).

I am out of this discussion. Good luck!

Patricia

Edit: You cannot solve for the Yk from equation 1.48. You need at least N additional equations (transport equations with reaction kinetics?) to get a well posed problem.


All times are GMT -4. The time now is 13:57.