CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] Groovy BC for lookup Table values (https://www.cfd-online.com/Forums/openfoam-community-contributions/100616-groovy-bc-lookup-table-values.html)

alessio.nz April 27, 2012 12:08

Groovy BC for lookup Table values
 
Hello,

i am solving the following problem:

- I have a boundary condition for a scalar field 'E' which is dependent to a scalar field 'C'. A lookup table describes this behaviour of C,E (I just attach the first lines of the table).

// ( C E)
(
( 0.00000000000000e+000 -0.00000000000000e+000 )
( 1.00249993687028e-002 -5.11523952089498e+004 )
( 1.99994949622485e-002 -8.68932017480435e+004 )
( 2.99234867806367e-002 -1.19566441219959e+005 )
( 3.97969748238680e-002 -1.50625905429174e+005 )
( 4.96199590919422e-002 -1.80659748473604e+005 )
( 5.93924395848590e-002 -2.09976653091197e+005 )
( 6.91144163026187e-002 -2.38760349142520e+005 )
( 7.87858892452210e-002 -2.67129314269836e+005 )
---------------------

I guess I need to set this boundary condition using the Groovy BC tool. As far as I know it is possible with this tool to have the boundary condition as a math function for example, but I am wondering how is it possible, during the runtime of the simulation, to make sure that the value of E will be dependent on the value of C. Do you know if there is any tutorial or someone who already solved a problem similar to this?

best regards,

Alex

gschaider April 27, 2012 12:50

Quote:

Originally Posted by alessio.nz (Post 357512)
Hello,

i am solving the following problem:

- I have a boundary condition for a scalar field 'E' which is dependent to a scalar field 'C'. A lookup table describes this behaviour of C,E (I just attach the first lines of the table).

// ( C E)
(
( 0.00000000000000e+000 -0.00000000000000e+000 )
( 1.00249993687028e-002 -5.11523952089498e+004 )
( 1.99994949622485e-002 -8.68932017480435e+004 )
( 2.99234867806367e-002 -1.19566441219959e+005 )
( 3.97969748238680e-002 -1.50625905429174e+005 )
( 4.96199590919422e-002 -1.80659748473604e+005 )
( 5.93924395848590e-002 -2.09976653091197e+005 )
( 6.91144163026187e-002 -2.38760349142520e+005 )
( 7.87858892452210e-002 -2.67129314269836e+005 )
---------------------

I guess I need to set this boundary condition using the Groovy BC tool. As far as I know it is possible with this tool to have the boundary condition as a math function for example, but I am wondering how is it possible, during the runtime of the simulation, to make sure that the value of E will be dependent on the value of C. Do you know if there is any tutorial or someone who already solved a problem similar to this?

best regards,

Alex

Been there. Done that: quickly googling for "groovyBC lookuptables" finds your posting (impressive after 35 minutes) and this presentation I held last year: http://www.openfoamworkshop.org/6th_...der_slides.pdf

To cut a long story short: the feature is already in swak4faom/groovyBC. Have a look at the wobbler-exampleCase that comes with swak4Foam (or the presentation)

alessio.nz April 27, 2012 22:02

thanks for the hint! I will have a look soon. best regards!

alessio.nz May 1, 2012 09:37

Hello Bernhard,

i tried to read the swak4foam slides and I tried to build the script for the boundary condition for the patch 'walls'. The fields which are in the 'table.dat' are first column C and second En. Writing the BC in this way it runs without error but the results are not the expected ones (see below) Do you think I should add some detailsin the script to make sure that during the solving for each value of C it will refer to the appropriate value of En?

thanks a lot, Alex

---------------

walls
{
// type fixedValue;
// value uniform -1757593;

type groovyBC ;

fields
(
C En
);


lookuptables (
{
name profile;
outOfBounds clamp;
fileName "$FOAM_CASE/table.dat";
}
);

}

alessio.nz May 1, 2012 09:38

Just to make it clear. The BC I am putting regards the patch walls for the field 'En' (C is the lookupvalue and it has other BC).

gschaider May 1, 2012 17:44

Quote:

Originally Posted by alessio.nz (Post 358636)
Hello Bernhard,

i tried to read the swak4foam slides and I tried to build the script for the boundary condition for the patch 'walls'. The fields which are in the 'table.dat' are first column C and second En. Writing the BC in this way it runs without error but the results are not the expected ones (see below) Do you think I should add some detailsin the script to make sure that during the solving for each value of C it will refer to the appropriate value of En?

thanks a lot, Alex

---------------

walls
{
// type fixedValue;
// value uniform -1757593;

type groovyBC ;

fields
(
C En
);


lookuptables (
{
name profile;
outOfBounds clamp;
fileName "$FOAM_CASE/table.dat";
}
);

}

That worked. groovyBC is way to tolerant. At least something like

valueExpression "profile(C)";

should be there, too

alessio.nz May 3, 2012 05:12

Now it seems to work! thanks a lot for the help.

gschaider May 3, 2012 06:59

Quote:

Originally Posted by alessio.nz (Post 359035)
Now it seems to work! thanks a lot for the help.

Could you please confirm: The problem was that "valueExpression" was completely missing? Because that is much too tolerant (and I should fix it)

alessio.nz May 3, 2012 07:49

I guess it's this, even if now I am thinking whether the boundary condition should be properly set. My physical problem is to set up the boundary for the enthalpy on the wall of my burner as a function of the progress variable (which is the measure of the combustion progress for my premixed combustion [gas turbine] ). The behaviour of the enthalpy is decreasing (from a set off value 0 till -1.7e+6) as a function of the PV (which has value included between 0 and 1). Due to the decrease of the enthalpy there will be a heat loss, and, as a consequence of this, the stabilized flame is not attached to the inlet but lifted up. I want to reproduce this problem and that's why I am setting the BC for the enthalpy En as a function of the progress variable C. Unfortunately there are still some problems in the results, that's why I am doubting whether I have done the proper script for the groovyBC.

Anyway the script is the following and it doesn't crash (see below). Thanks for the support. alex

-------------------------------------------
walls
{
// type fixedValue;
// value uniform -1757593;

type groovyBC ;

fields
(
C En
);


lookuptables (
{
name profile;
outOfBounds clamp;
fileName "$FOAM_CASE/table.dat";
}
);

valueExpression "profile(C)";
}

mikeP May 14, 2012 08:49

Hi,
I have a similar problem. I am trying to impose turbulent kinetic energy values from a dat file on my inlet boundary. But I get an error:

Code:

--> FOAM FATAL ERROR:
 Parser Error at "1.1-7" :"field profile not existing or of wrong type"
"profile(yc)"
" ^^^^^^^  "
    From function parsingValue
    in file PatchValueExpressionDriver.C at line 192.

FOAM exiting

Inlet
{
type groovyBC;
value uniform 0.0138;
variables "yc=pos().y;";
fields
(
yc k
);
lookuptables (
{
name profile;
outOfBounds clamp;
filename "$FOAM_CASE/k_profile.dat";
}
);
valueExpression "profile(yc)";
}


k_profile.dat:

( // first column: vertical position, second column k
(1 0.1)
(10 0.2)
(100 0.4)
)

ps: I have OpenFOAM v2.0.1 and the latest swak4FOAM

gschaider May 14, 2012 17:47

Quote:

Originally Posted by alessio.nz (Post 359058)

Anyway the script is the following and it doesn't crash (see below). Thanks for the support. alex

-------------------------------------------
walls
{
// type fixedValue;
// value uniform -1757593;

type groovyBC ;

fields
(
C En
);


lookuptables (
{
name profile;
outOfBounds clamp;
fileName "$FOAM_CASE/table.dat";
}
);

valueExpression "profile(C)";
}

Quote:

Originally Posted by mikeP (Post 360957)
Hi,
I have a similar problem. I am trying to impose turbulent kinetic energy values from a dat file on my inlet boundary. But I get an error:

Code:

--> FOAM FATAL ERROR:
 Parser Error at "1.1-7" :"field profile not existing or of wrong type"
"profile(yc)"
" ^^^^^^^  "
    From function parsingValue
    in file PatchValueExpressionDriver.C at line 192.

FOAM exiting

Inlet
{
type groovyBC;
value uniform 0.0138;
variables "yc=pos().y;";
fields
(
yc k
);
lookuptables (
{
name profile;
outOfBounds clamp;
filename "$FOAM_CASE/k_profile.dat";
}
);
valueExpression "profile(yc)";
}


k_profile.dat:

( // first column: vertical position, second column k
(1 0.1)
(10 0.2)
(100 0.4)
)

ps: I have OpenFOAM v2.0.1 and the latest swak4FOAM

The boundary conditions look OK to me. One question: what is the purpose of the "fields"-entry? (don't know that for groovyBC and I thought I knew a little bit about swak4Foam)

As I said: the expression looks OK to me. Some hints for finding the problem:
- make sure the lookuptables are really read. For instance remove the "name"-entry. Execution should fail
- try a different name for the lookuptable than "profile" (although this should only be a problem if you have a field called "profile")

mikeP May 15, 2012 03:53

When I comment out "name profile;", I still get the same error. Nothing changes. So you think, it never reads inside lookuptables?

I have seen "fields" entry in this post and decided to try, as well. But I tested it now and it does not have any effects either.

gschaider May 15, 2012 05:34

Quote:

Originally Posted by mikeP (Post 361116)
When I comment out "name profile;", I still get the same error. Nothing changes. So you think, it never reads inside lookuptables?

Yep. From the posting I can't tell why. Problem is that lookuptables is optional. So if it doesn't find it (due to a missing ";" , a missspelled keyword ... but your example seems to be alright in that respect) swak doesn't complain

Quote:

Originally Posted by mikeP (Post 361116)
I have seen "fields" entry in this post and decided to try, as well. But I tested it now and it does not have any effects either.

That is only needed in utilities that have to be forced to load fields into memory

Jonathan September 30, 2012 19:36

hi Bernhard,

hope you are well! i want to us groovyBC to patch a Fluent inlet profile onto a OF case, and came upon this thread. I guess from above its possible to use a lookup table.

Just a couple things:

1) would you mind posting your slides again - i would be very keen to check them out by the link seems to be dead???
2) have you ever used groovy to patch a (linear / 1D) radial profile (ie such as for a turbine inlet) which can then be rotated across a blade pitch to form a 2D inlet condition???

many thanks and best regards!
sincerely
Jonathan

gschaider September 30, 2012 20:06

Quote:

Originally Posted by Jonathan (Post 384274)
hi Bernhard,

hope you are well! i want to us groovyBC to patch a Fluent inlet profile onto a OF case, and came upon this thread. I guess from above its possible to use a lookup table.

Just a couple things:

1) would you mind posting your slides again - i would be very keen to check them out by the link seems to be dead???

Could you be a bit more specific: which link (on which page)?

Quote:

Originally Posted by Jonathan (Post 384274)
2) have you ever used groovy to patch a (linear / 1D) radial profile (ie such as for a turbine inlet) which can then be rotated across a blade pitch to form a 2D inlet condition???

No. But if I understand you correctly it shouldn't be too hard: calculate the radius of a point (distance from the center) and with that go into a lookup table

Jonathan October 1, 2012 08:15

Hi Bernhard,

Quote:

Originally Posted by gschaider (Post 384276)
Could you be a bit more specific: which link (on which page)?

thanks for your response - i am meaning the link posted earlier ...

http://www.openfoamworkshop.org/6th_...der_slides.pdf

Quote:

No. But if I understand you correctly it shouldn't be too hard: calculate the radius of a point (distance from the center) and with that go into a lookup table
sorry - yes the question was a bit vague ... i have just compiled the utilities and so will have to play around a little bit first, and perhaps if i get stuck, might post a couple more questions ... but essentially, i have a table of:

Code:

Radius    Prof_value
xxx        yyy
xxx        yyy
etc

and i want to apply this across a 18 degree segment of a turbine annulus - i.e. x1 blade pitch, and i was wondering whether you would know whether this would be possible ... but i will play around first and see how i go!

thanks for the response,
best regards
jon

gschaider October 1, 2012 09:08

Quote:

Originally Posted by Jonathan (Post 384352)
Hi Bernhard,



thanks for your response - i am meaning the link posted earlier ...

http://www.openfoamworkshop.org/6th_...der_slides.pdf

That currently won't work (see Martin Beaudoins announcement in the 7th Workshop thread ... I think yesterday). But there is a link (and a copy) to that presentation on the openfoamwiki.net (from the swak-page)

Quote:

Originally Posted by Jonathan (Post 384352)
sorry - yes the question was a bit vague ... i have just compiled the utilities and so will have to play around a little bit first, and perhaps if i get stuck, might post a couple more questions ... but essentially, i have a table of:

Code:

Radius    Prof_value
xxx        yyy
xxx        yyy
etc

and i want to apply this across a 18 degree segment of a turbine annulus - i.e. x1 blade pitch, and i was wondering whether you would know whether this would be possible ... but i will play around first and see how i go!

thanks for the response,
best regards
jon

Should be possible. But you'll have to convert the table into a format the OF-inerpolationTable understands. Either OF-native or CSV. Then in the groovyBC you can calculate the radius in the variables with something like

"centerOfRotation=vector(1,0,0);"
"radius=mag(pos()-centerOfRotation);"

and if you specified a lookup-table named profileVsRadius then a valueExpression "profileVsRadius(radius)" should give you the value you want

Vesposo July 9, 2013 05:13

n-dim lookup table
 
Hi,

is there a possibility to use a n-dimensional lookup table? For expample a 3-dim like

(
(xx0 yy0 zz0)
(xx1 yy0 zz0)
(xx2 yy0 zz0)
...
(xx0 yy1 zz0)
(xx1 yy1 zz0)
(xx2 yy1 zz0)
...
)

Thanks and regards

gschaider July 9, 2013 05:52

Quote:

Originally Posted by Vesposo (Post 438629)
Hi,

is there a possibility to use a n-dimensional lookup table? For expample a 3-dim like

(
(xx0 yy0 zz0)
(xx1 yy0 zz0)
(xx2 yy0 zz0)
...
(xx0 yy1 zz0)
(xx1 yy1 zz0)
(xx2 yy1 zz0)
...
)

Thanks and regards

You mean you want a lookup zz(xx,yy)? Currently not possible. Mainly because the interpolation would have to be implemented from scratch (see also https://sourceforge.net/apps/mantisb...view.php?id=43). So I don't see myself doing that in the foreseeable future. Contributions accepted

gruenertee July 21, 2013 12:32

Hi foamers,

first of all i want to thank everybody who keeps runing this forum; i want to implement a Robin Boundary condition via the groovy Boundary condition, but Tinf should be read out of a .dat file (lookuptable)
(Openfoam2.2.0)

wall
{
type groovyBC;
variables "k=0.8;alpha=15;Tinf=65;f=1/(1+k(alpha*mag(delta())));";
valueExpression "Tinf";
gradientExpression "0";
fractionExpression "f";
value uniform 0;
}

I am asking myself how to tell "Tinf" to read the inlet.dat file :) How to combine the type groovyBC with the lookuptables for Tinf?

lookuptables (
{
name inlet;
outOfBounds clamp;
fileName "$FOAM_CASE/inlet.dat";
}

Thank you


All times are GMT -4. The time now is 04:31.