CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

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

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

Like Tree2Likes
  • 2 Post By zfaraday

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 15, 2015, 14:51
Question 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: 22
zfaraday will become famous soon enough
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;
    }
This is the typical convection heat transfer expression that can be found in the forum (actually, I took it from some other thread a while ago) but the value of hc is defined as a variable (created in the following step) instead of a constant value.

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;
    }
3. Manipulation of the created fields in order to make them take the proper values according to some formulas. This process is done by means of the use of another function object: manipulatePatchField. Below you can see the piece of code belonging to the manipulation of the Pr nš field:
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=1e-6*(2.469+0.0536*Tf+P/8280000.0);"
                   "Pr_=cp*mu/k;");
        expression "Pr_";
        mask "true";
        writeManipulated true;
    }
The order would be: Pr --> Ra --> Nu --> h_Ext ----> h_Ext of the current iteration is used in the calculation of Twall of the following iteration?? Am I right?

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
jherb and vs1 like this.
__________________
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!
zfaraday is offline   Reply With Quote

Old   January 19, 2015, 09:02
Smile
  #2
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
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_";
    }
It saves me a good amount of space, besides to make it cleaner.

NON-RESOLVED POINTS


1.
Quote:
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...
I still don't know if there is a way to make groovyBC acces the kappa field in the constant/solidRegion/thermophysicalProperties file. Is it possible?

2.
Quote:
The order would be: Pr --> Ra --> Nu --> h_Ext ----> h_Ext of the current iteration is used in the calculation of Twall of the following iteration?? Am I right?
According to what I see in the output log file, it seems that h_Ext (and all the other fields) are calculated at the end of the time step. Thus, I should be right that in the current time step, the value of h_Ext used is the one calculated in the previous time step. Then a question arises, How is it calculated the first value of h_Ext? I guess that it is calculated taking into account the value of T (remember that h_Ext only depends on ambient and wall temperatures) from the initial conditions, but I cannot check it by myself because no field files are created in the 0 folder when using ExpressionField FO... Any hints about it?

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!
zfaraday is offline   Reply With Quote

Old   January 19, 2015, 09:16
Default
  #3
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13
ssss is on a distinguished road
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)
to create a volScalarField from the surfaceScalarField
ssss is offline   Reply With Quote

Old   January 19, 2015, 13:31
Default
  #4
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Thanks for your quick response Mr. ssss.

Quote:
Originally Posted by ssss View Post
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
It could be a valid approach for my purpose. However, I've never modified a solver because my knowledge of C++ is pretty weak, I can barely read and understand pieces of the code. If you could guide me on how to proceed or send me some info regarding this matter maybe I would have courage enough to try it. Otherwise, I prefer to wait for another approach to come.

Quote:
Originally Posted by ssss View Post
3) Have a look at this tool made by wyldkat (thanks to him)

https://github.com/wyldckat/reconstr...ctSurfaceField
This is such a great discovery! It could make it! However, I have already downloaded, installed and tested it and I found a limitation that makes it useless for my case (at least to my eyes). The problem is that my case is a multi domain case but no -region flag exists for this tool, thus, unless there is a workaround to make it work for multi domain cases I cannot make use of it.

Quote:
Originally Posted by ssss View Post
If not you could make a tool that reads the surfaceScalarFields and then calls
Code:
fvc::reconstruct(scalarField)
to create a volScalarField from the surfaceScalarField
As I said above, I don't have strong skills with C++ programming...


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!
zfaraday is offline   Reply With Quote

Old   January 19, 2015, 14:28
Default
  #5
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13
ssss is on a distinguished road
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.
ssss is offline   Reply With Quote

Old   January 19, 2015, 15:05
Default
  #6
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
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!
zfaraday is offline   Reply With Quote

Reply

Tags
convection, expressionfield, groovybc, heat tranfer, swak4foam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 12:45.