CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Mixed BC - heat transfer - laplacianFoam (https://www.cfd-online.com/Forums/openfoam-pre-processing/74593-mixed-bc-heat-transfer-laplacianfoam.html)

bhh April 4, 2010 02:46

Mixed BC - heat transfer - laplacianFoam
 
I am working with heat transfer in solid material and using laplacianFoam. I have the possibility to impose
1) fixed temperature and
2) fixed temperature gradient (fixed heat flux (dT/dn)_w = q_w/k; q_w is given, k is the conductivity of the solid material) on the walls.
Often it is needed to set the heat flux on a boundary given by the heat transfer coefficient (h) and the outside temperature(T_inf)
3) (dT/dn)_w=h/k (T_w -T_inf). h and T_inf are given, k is the conductivity of the solid material and T_w is the wall temperature (Varies during the computations and along BC patch).

How can I get access to the mixed conditon ( 3) above)?
regards
Bjorn

bhh April 11, 2010 05:40

Often it is needed to set the heat flux on a boundary given by the heat transfer coefficient (h) and the outside temperature(T_inf)
3) (dT/dn)_w=h/k (T_w -T_inf). h and T_inf are given, k is the conductivity of the solid material and T_w is the wall temperature (Varies during the computations and along BC patch).

Can anybody give some hints on how to do this in laplacianFoam?

rgds
Bjorn

chandramurthy April 11, 2010 08:02

did u try groovyBC ?. http://openfoamwiki.net/index.php/Contrib_groovyBC

val46 July 21, 2010 05:17

Hi Bjorn,

did you succeed implementing your BC in laplacianFoam?


Regards,

Toni

bhh July 21, 2010 05:24

Hi Toni,

No, unfortunately I did not manage to find a solution. The use of groovyBC for this problem seems to unclear for my level of understanding.

rgds
Bjorn

val46 July 21, 2010 09:51

Hi bhh,

i found these 2 threads:

http://www.cfd-online.com/Forums/ope...roperties.html

http://www.cfd-online.com/Forums/ope...fficients.html


I will try it out and let you know about it.

bhh July 22, 2010 04:54

Hi,

I finally got around to use groovyBC for my problem. The following seemed to work after installation of the groovyBC ( http://openfoamwiki.net/index.php/Contrib_groovyBC )and using it in laplacianFoam:

rightWall
{
type groovyBC;
gradientExpression "gradT";
fractionExpression "0";
variables
"htot=100.0;Tinf=20.0;rho=800.0;cp=385.0;gradT=hto t/(DT*rho*cp)*(Tinf-T);";
timelines (
);
}

This seemed to work OK. However, when I raised the heat transfer coefficient, htot, to large values the solution diverged for a steady state heat conduction problem. For large values of htot I should find that the wall temperature should approach Tinf. My guess is that the BC should be handled through a source term addition to the CV close to the boundary to handel large values of htot.

Any comments to this?

rgds
Bjorn

herbert July 22, 2010 05:21

Hi Bjorn,

I have had the same problem with diverging results. You can formulate different (and more implicit) to get a stable and faster converging solution.
Code:

rightWall
{
    type                  groovyBC;
    variables              "htot=1000.0;Tinf=20.0;rho=800.0;cp=385.0;k=DT*rho*cp;";
    valueExpression    "Tinf";
    fractionExpression  "1.0/(1.0 + k/(mag(delta())*htot))";
}

The Syntax is derived from wallHeatFlux-BC inside the thermophysicalModels.

Regards,
Stefan

bhh July 22, 2010 05:53

Hi Stefan,

This is probably what is needed. However when I used your expression I got this error:
Time = 1



--> FOAM FATAL ERROR:
Parser Error at "1.33" :"invalid character"
"1.0/(1.0 + k/(mag(delta())*htot));"
" ^"

From function parsingValue
in file PatchValueExpressionDriver.C at line 188.

FOAM exiting

Any idea what went wrong?

rgds
Bjorn

bhh July 22, 2010 05:57

Hi Stefan,

It was the ; that should be changed:
fractionExpression "1.0/(1.0 + k/(mag(delta())*htot))";

Now it runs! Thank you very much for your help!

rgds
Bjorn

herbert July 22, 2010 06:27

Hi Bjorn,

sorry, such mistakes are my personal special when writing code to posts. ;) I'll edit it.

Regards,
Stefan

val46 August 13, 2010 04:36

Hi Bjorn,

i also managed to solve a problem with laplacianFoam and groovyBC.

Did you realize you set your Tinf to -253 °C ? :D

Code:

"htot=100.0;Tinf=20.0;rho=800.0;cp=385.0;gradT=hto  t/(DT*rho*cp)*(Tinf-T);";
I for myself used the code posted by Stefan with the following settings.

Code:

  type                  groovyBC;
    variables              "htot=100.0;Tinf=298.15;rho=2700.0;cp=900.0;k=DT*rho*cp;";
    valueExpression    "Tinf";
    fractionExpression  "1.0/(1.0 + k/(mag(delta())*htot))";

(These settings are for aluminium)

Regards,
Toni

bhh August 13, 2010 06:59

Hi,

I now only use the proposal from Stefan and abandoned my own proposal. Stefans code is much more stable and can accomodate the Tinf= -252. value

rgds
Bjorn

benk December 6, 2010 17:00

Hi, I'm trying to set exactly the same boundary condition: dT/dx = h/k (T_w -T_inf)

I've installed groovyBC but when I try the following:

Quote:

rightWall
{
type groovyBC;
variables "htot=100.0;Tinf=298.15;rho=2700.0;cp=900.0;k=DT*r ho*cp;";
valueExpression "Tinf";
fractionExpression "1.0/(1.0 + k/(mag(delta())*htot))";
}
I first get an error message saying:

Quote:

Cannot find 'value' entry on patch rightWall of field T in file "/Users/ben/OpenFOAM/ben-1.6-ext/run/poc/domain/0/T"
which is required to set the values of the generic patch field.
(Actual type groovyBC)

Please add the 'value' entry to the write function of the user-defined boundary-condition
or link the boundary-condition into libfoamUtil.so

and then when I try to add a value field to my BC:

Quote:

rightWall
{
type groovyBC;
variables "htot=100.0;Tinf=298.15;rho=2700.0;cp=900.0;k=DT*r ho*cp;";
valueExpression "Tinf";
value uniform 298.0;
fractionExpression "1.0/(1.0 + k/(mag(delta())*htot))";
}
I get an error saying:

Quote:

--> FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a genericFvPatchField (actual type groovyBC)
on patch rightWall of field T in file "/Users/ben/OpenFOAM/ben-1.6-ext/run/poc/domain/0/T"
You are probably trying to solve for a field with a generic boundary condition.

From function genericFvPatchField<Type>::gradientInternalCoeffs( ) const
in file fields/fvPatchFields/basic/generic/genericFvPatchField.C at line 782.
Does anybody know how I can fix this?

benk December 6, 2010 20:42

Whoops, I forgot to add libs ( "libgroovyBC.so" ) ; to my system/controlDict file...it seems to be working now.

But...can anybody explain how dT/dx = h/k (T_w -T_inf) becomes 1.0/(1.0 + k/(mag(delta())*h))?

usergk February 3, 2011 17:34

Hello,

Can someone reply what does DT refer to in the code above?

I got the following error:

--> FOAM FATAL ERROR:
Parser Error at "1.1-2" :"field DT not existing or of wrong type"
"DT*rho*cp"
" ^^ "

From function parsingValue
in file PatchValueExpressionDriver.C at line 192.

FOAM aborting (FOAM_ABORT set)


Thanks
gk

benk February 3, 2011 17:58

Quote:

Originally Posted by usergk (Post 293533)
Hello,

Can someone reply what does DT refer to in the code above?

DT is a volumeScalarField in this case. You got an error because in your solver the field DT must not exist. You may not need this field, you just have to make sure that your thermal conductivity (k) is defined properly in your solver.

argonaut February 15, 2011 11:55

Robin BC, groovyBC, value in the cell center
 
I have two questions which bothers me last few days concerning implementation of Robin boundary conditions by groovyBC:

1) I also cannot fully understand how the equality was obtained which was mentioned before:

Quote:

Originally Posted by benk (Post 286267)
But...can anybody explain how dT/dx = h/k (T_w -T_inf) becomes 1.0/(1.0 + k/(mag(delta())*h))?

As I can see from other threads, others try to use this formula, but no explanation I have found. If I take the formula and try to go back, I obtain that derivative dT/dx is substituted in the original boundary condition by Tinf/delta (environment temperature divided by the distance from the cell-center to the face-center).

If I linearize the derivative, I could use (T_center - T_face) instead of Tinf

2) Is it possible to get this T_center, i.e., cell-center-value in groovyBC? I saw "this->patchInternalField()" in the source code of the original mixedFixedValue. Can I access it somehow similar in groovyBC?

argonaut February 17, 2011 08:18

At last, I've got it. It seems that I am not so stupid as I thought :cool:

groovyBC is based on mixed BC. Algorithm in the function "evaluate" of the file mixedFvPatchField.C (src » finiteVolume » fields » fvPatchFields » basic » mixed) states that

Tface = f*refValue + (1-f)*(Tcenter + refGrad * delta)

where f is valueFraction, delta is distance between Tcenter and Tface (OpenFOAM's 1/deltaCoeffs() or groovyBC's mag(delta())). If we take boundary condition

k*dT/dn + h*(Tface-Tinf) = 0

linearize derivative

k*(Tface-Tcenter)/delta + h*(Tface-Tinf) = 0

divide by h and isolate Tface, we obtain

Tface = (1/(1+C))*Tinf + (1 - 1/(1+C))*Tcenter

where C=k/(h*delta). As you can see, comparison of this equation to the first one gives

f = 1/(1+C)
refValue = Tinf
refGrad = 0

Concerning approximation, it is the first order approximation if I understand it correctly. Does anybody knows if there are any 2nd order approximations in OpenFOAM for derivatives on the boundary. I know that it is possible to implement 2nd order approximation, but it would use values from previous timestep. Not sure if this possible with groovyBC, isn't it?

brent_craven March 21, 2011 00:40

2nd Order?
 
I agree that this implementation of the mixed BC is first order. Has anyone come up with a way to implement 2nd order?


All times are GMT -4. The time now is 01:38.