# Mixed BC - heat transfer - laplacianFoam

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 4, 2010, 01:46 Mixed BC - heat transfer - laplacianFoam #1 Member   Bjorn H. Hjertager Join Date: Mar 2009 Posts: 72 Rep Power: 17 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 alishafiee likes this.

 April 11, 2010, 04:40 #2 Member   Bjorn H. Hjertager Join Date: Mar 2009 Posts: 72 Rep Power: 17 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

 April 11, 2010, 07:02 #3 Member   MSR CHANDRA MURTHY Join Date: Mar 2009 Posts: 33 Rep Power: 17 did u try groovyBC ?. http://openfoamwiki.net/index.php/Contrib_groovyBC

 July 21, 2010, 04:17 #4 Member   Join Date: Nov 2009 Location: Germany Posts: 96 Rep Power: 16 Hi Bjorn, did you succeed implementing your BC in laplacianFoam? Regards, Toni

 July 21, 2010, 04:24 #5 Member   Bjorn H. Hjertager Join Date: Mar 2009 Posts: 72 Rep Power: 17 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

 July 21, 2010, 08:51 #6 Member   Join Date: Nov 2009 Location: Germany Posts: 96 Rep Power: 16 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.

 July 22, 2010, 03:54 #7 Member   Bjorn H. Hjertager Join Date: Mar 2009 Posts: 72 Rep Power: 17 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

 July 22, 2010, 04:21 #8 Senior Member   Stefan Herbert Join Date: Dec 2009 Location: Darmstadt, Germany Posts: 129 Rep Power: 17 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, nimasam, armyou and 6 others like this. Last edited by herbert; July 22, 2010 at 05:27. Reason: Syntax error

 July 22, 2010, 04:53 #9 Member   Bjorn H. Hjertager Join Date: Mar 2009 Posts: 72 Rep Power: 17 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

 July 22, 2010, 04:57 #10 Member   Bjorn H. Hjertager Join Date: Mar 2009 Posts: 72 Rep Power: 17 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

 July 22, 2010, 05:27 #11 Senior Member   Stefan Herbert Join Date: Dec 2009 Location: Darmstadt, Germany Posts: 129 Rep Power: 17 Hi Bjorn, sorry, such mistakes are my personal special when writing code to posts. I'll edit it. Regards, Stefan

 August 13, 2010, 03:36 #12 Member   Join Date: Nov 2009 Location: Germany Posts: 96 Rep Power: 16 Hi Bjorn, i also managed to solve a problem with laplacianFoam and groovyBC. Did you realize you set your Tinf to -253 °C ? 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

 August 13, 2010, 05:59 #13 Member   Bjorn H. Hjertager Join Date: Mar 2009 Posts: 72 Rep Power: 17 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

December 6, 2010, 16:00
#14
Senior Member

Ben K
Join Date: Feb 2010
Posts: 140
Rep Power: 19
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::gradientInternalCoeffs( ) const in file fields/fvPatchFields/basic/generic/genericFvPatchField.C at line 782.
Does anybody know how I can fix this?

 December 6, 2010, 19:42 #15 Senior Member   Ben K Join Date: Feb 2010 Location: Ottawa, Canada Posts: 140 Rep Power: 19 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))?

 February 3, 2011, 16:34 #16 Member   Join Date: Nov 2010 Posts: 54 Rep Power: 15 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

February 3, 2011, 16:58
#17
Senior Member

Ben K
Join Date: Feb 2010
Posts: 140
Rep Power: 19
Quote:
 Originally Posted by usergk 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.

February 15, 2011, 10:55
Robin BC, groovyBC, value in the cell center
#18
New Member

Raimonds Vilums
Join Date: Oct 2010
Posts: 17
Rep Power: 16
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 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?

 February 17, 2011, 07:18 #19 New Member   Raimonds Vilums Join Date: Oct 2010 Posts: 17 Rep Power: 16 At last, I've got it. It seems that I am not so stupid as I thought 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? novyno, mirko, bhh and 46 others like this.

 March 20, 2011, 23:40 2nd Order? #20 New Member   Brent Craven Join Date: Mar 2009 Location: University Park, PA, USA Posts: 21 Rep Power: 17 I agree that this implementation of the mixed BC is first order. Has anyone come up with a way to implement 2nd order?