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/)
-   -   can OpenFOAM calculate definite integral? (https://www.cfd-online.com/Forums/openfoam-programming-development/132921-can-openfoam-calculate-definite-integral.html)

sharonyue April 7, 2014 22:05

can OpenFOAM calculate definite integral?
 
Hi guys,

I wanna implant this equation into OpenFOAM. But I dont know how to deal with this definite integral. Any ideas?

Code:

    fvScalarMatrix nEqn
    (
        fvm::ddt(n) 
      + fvm::div(phi1,n)
      ==
        ????
    );

\frac{{\partial \left( {{\rho _d}{N_d}} \right)}}{{\partial t}} + \nabla  \cdot \left( {{\rho _d}{u_d}{N_d}} \right) = \int\limits_{0.5}^1 {f\left( \varepsilon  \right)d\varepsilon }

chrisb2244 April 7, 2014 22:15

What sort of object is f(e)?

I mean, for example, if phi is a surfaceScalarField and U is a volVectorField etc.

sharonyue April 7, 2014 22:21

Quote:

Originally Posted by chrisb2244 (Post 484530)
What sort of object is f(e)?

I mean, for example, if phi is a surfaceScalarField and U is a volVectorField etc.

Actually I made this very simple to make it clear. The complete edition is

f\left( \xi  \right) = {\xi ^{0.55}} \cdot {e^{\left( {surfacetension \bullet rho \bullet epsilon \bullet \xi } \right)}}

So I think its volScalarField. rite?

chrisb2244 April 7, 2014 23:03

So I took a few swings at this but I think you're going to wind up with a Gamma function in your integrated quantity here.

http://reference.wolfram.com/mathematica/ref/Gamma.html

https://www.wolframalpha.com/input/?...8a%20x%29&lk=2

I'm not sure how you'd want to implement that in OpenFOAM :/

You can presumably get somewhere by just summing up over a set of values of \xi but I don't know how horribly inaccurate that will become.

You have all of the fields you're going to need reasonably easily accessible, but I'm not sure how to get a better answer than writing out some sort of for loop, or a functor - which would require you to write a class afaict.

chrisb2244 April 7, 2014 23:05

In terms of a for loop, what I mean is something conceptually like

Code:

for (double x = 0.5; x <= 1; x = x+0.01)
{
    sum += ( pow(x, 0.55)  * exp(a * x));
}

where a is a volScalarField equal to the product of your \rho \epsilon \sigma

sharonyue April 7, 2014 23:17

Quote:

Originally Posted by chrisb2244 (Post 484535)
In terms of a for loop, what I mean is something conceptually like

Code:

for (double x = 0.5; x <= 1; x = x+0.01)
{
    sum += ( pow(x, 0.55)  * exp(a * x));
}

where a is a volScalarField equal to the product of your \rho \epsilon \sigma

This method is feasible. But I think if OpenFOAM can deal with definite integral directly, that would be perfect. And the Gamma function you'd mentioned Im not familar with that, maybe it will take me a while to dig into it.

Actually Im tring to implant PBM into Foam, the RHS of the equation is luo breakage kernel~. Right now Im stuck here. I will try your loop method and keep this thread update. However, I dont know if it would be accurate, but its a good start I think. Thanks very much.


All times are GMT -4. The time now is 07:23.