
[Sponsors] 
[swak4Foam] Using swak4foam to implement a BC for heat convection with h(Tamb,Twall) 

LinkBack  Thread Tools  Search this Thread  Display Modes 
January 15, 2015, 13:51 
Using swak4foam to implement a BC for heat convection with h(Tamb,Twall)

#1 
Senior Member
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 21 
Dear foamers,
Lately I have been working on the implementation of a BC for heat convection using swak4foam. You can check this thread (problems creating volscalarfield expressionfield function object) I started before Christmas regarding this matter. The BC I would like to use is externalWallHeatFluxTemperature, but this one uses a constant value for the h coefficient and what I want is that this coeff. is calculated each time step depending on the ambient and wall temperatures. As I'm not an experinced user of swak4foam (not even of OF) I have been facing several problems since I started with this. However, now I think I'm starting to do things right. I will list in the following lines the steps I have in mind to develop de desired BC (some of them have been already taken with a little success): 1. As a first step I created a BC with groovyBC that solves the convection heat transfer for T. Here comes the code: Code:
convection_wall { type groovyBC; variables ("hc=h_Ext;" "Tinf=5.0;" "k=0.5;"); valueExpression "Tinf"; fractionExpression "1.0/(1.0 + k/(mag(delta())*hc))"; value uniform 10; } 2. Creation of the required fields needed to calculate h coefficient. These field are: Pr (Prandtl) nš, Ra (Raileigh) nš, Nu (Nuselt) nš and h_Ext (convection coeff. itself). These fields are created by means of the expressionField function object. Here comes the Pr creation as an example: Code:
Pr_Expression { type expressionField; outputControl none;//timeStep; outputInterval no;//1; region ext_wall; fieldName Pr; expression "!(onPatch(sim_lat1)onPatch(sim_lat2)onPatch(sim_sup)onPatch(sim_inf)) ? interpolate(1) : interpolate(0)"; dimension [0 0 0 0 0 0 0]; autowrite true; } Code:
Pr_convection_wall { type manipulatePatchField; outputControl timeStep; outputInterval 1; fieldName Pr; region ext_wall; patchName convection_wall; aliases { } variables ( "Twall=average(T);" "Tinf=5.0;" "P=101325.0;" "Tf=(Tinf+Twall)/2.0;" "cp=980.16+0.08*Tf;" "k=(3.807+0.074*Tf)/1000.0;" "rho=3.484*P/(1000.0*Tf);" "mu=1e6*(2.469+0.0536*Tf+P/8280000.0);" "Pr_=cp*mu/k;"); expression "Pr_"; mask "true"; writeManipulated true; } I have some questions about my procedure. First of all, I don't know if it's a proper method and I'm sure it's not the best one for sure, but I think it could work in my case. Any suggestion on how to improve it? One thing I would like to know is how can I access the kappa field of my solid region in the thermophysicalProperties file in the step 1 of my procedure? (marked in red) My intention is that the BC retrieves the value of k automatically from the thermophysicalProperties file like externalWallHeatFluxTemperature BC does when the field kappa is set to solidThermo. Is there a way to do that? I know how to retrieve the values of rho and alpha by means of the use of aliases but I have no clue on how to do that with kappa... On the other side, I would like to know if its possible to use the #include directive within the variables field. My intention is to create a file with the formulas marked in blue in the step 3 and call them with a simple line instead of writing all of them in every function object (I have to write them all in every field created. Besides that, in the example above I only talk about one patch but I have to set up more than one patch with the same BC in the same case!!) This is all for now. So far I have only implemented the calculation of the Pr and Ra fields and I have to take a look at it because I think the results I got are not correct. That's why I ask above if my procedure is correct or not, because I checked the formulas and they look correct... I will really apprecaite any hint you can share with me in regards of the matters I mention above. Many thanks in advance. Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in! 

January 19, 2015, 08:02 

#2  
Senior Member
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 21 
Just for the information of the ones that may be interested, finally I managed to implement my BC. I hope that everything does what its meant to do, I still have some doubts about it that I would like to be resolved by someone with deeper knowledge in swak4foam than me.
First of all, I found out that the #include directive can be used normally, the problem I had was that I enclosed the #include statement within quotation marks as if it was a variable itself within the variables field. This is the correct way to use it: Code:
Pr_convection_wall { type manipulatePatchField; (...) variables ( #include "$FOAM_CASE/include/propsAir_out" "Pr_=cp*mu/k;"); expression "Pr_"; } NONRESOLVED POINTS 1. Quote:
2. Quote:
3. Another problem I have to face is that, according to my procedure, the fields created are of type surfaceScalarField. Originally I wanted them to be volScalarField although I only worked with the patch fields. The fact that I only manipulate values at patches gave me a lot of troubles when I tried to create the fields as volScalarFields, that was why I finally ended up working with surfaceScalarFields instead. The main problem of the surfaceScalarFields is that they cannot be displayed in paraview, at least I haven't found the way to do it... How can I display surfaceScalarFields in paraview? If it's not possible, How could I proceed to create the fields as volScalarFields but only work with the values at patches?  I hope someone can give me some tips or hints so that I can finally finish the developement of my BC. Any word you can send me will be very welcome. Many thanks in advance, Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in! 

January 19, 2015, 08:16 

#3 
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12 
1) You can modify the solver to create a volScalarField from the kappa value in constant/solidRegion/thermophysicalProperties and then you should be able to access it from groovyBC
2) I'll have to a dig about it a bit more, I have no clue right now 3) Have a look at this tool made by wyldkat (thanks to him) https://github.com/wyldckat/reconstr...ctSurfaceField If not you could make a tool that reads the surfaceScalarFields and then calls Code:
fvc::reconstruct(scalarField) 

January 19, 2015, 12:31 

#4  
Senior Member
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 21 
Thanks for your quick response Mr. ssss.
Quote:
Quote:
Quote:
Thank you very much for your advices, it's been of much help (maybe not as much as I needed, though) Regards, Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in! 

January 19, 2015, 13:28 

#5 
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12 
Do you know how to compile a new solver? In this case I can help you to implement the new things I've told you.


January 19, 2015, 14:05 

#6 
Senior Member
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 21 
I think I have some documentation regarding the compilation of new solvers. I never tried it because I never had the need to do it, but I think if I dig a little into my files I can find info regarding the compilation of solvers and utilities.
I will really appreciate if you help me with the implementation!
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in! 

Tags 
convection, expressionfield, groovybc, heat tranfer, swak4foam 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
How to implement the convection B.C. in chtMultirigionFoam(conjugate problem)  zahraa  OpenFOAM PreProcessing  0  June 30, 2014 18:32 
Thermophysical properties for natural convection  Ciefdi  OpenFOAM Running, Solving & CFD  0  November 7, 2013 11:44 
[swak4Foam] fails in parallel with otherTime?  Phicau  OpenFOAM Community Contributions  3  June 26, 2013 13:00 
Modeling both radiation and convection on surfaces  Ansys Transient Thermal R13  s.mishra  ANSYS  0  March 31, 2012 04:12 
How to implement convection boundary condition  hsieh  OpenFOAM Running, Solving & CFD  7  January 10, 2012 07:48 