Heat transfer in Elmer / OpenFOAM
-
- Posts: 40
- Joined: 07 Jun 2011, 11:24
- Antispam: Yes
Heat transfer in Elmer / OpenFOAM
Hello!
My company needs to do some heat transfer calculations on a cooling tower using a 2D
cut through the tower. So I am searching for a FEM-software that can calculate this.
At first I had a look at OpenFOAM, this looks quite interesting and highly configurable,
but I am not sure if it would be the best solution. Searching for alternatives I came
across Elmer and had a look into its models and BCs and it looks fine so far.
I hope you can help to figure out if Elmer fits our needs.
Attached you find a picture showing our model and the BCs we want to apply.
The outer wall should get three BCs:
- Convection to the ambient temperature T_ambient: J_conv = alpha * (T_surface - T_ambient)
The convection could for a first approach be set to a fixed value (e.g. 20 W/m^2)
- Radiation to the sky: J_rad = sigma_boltz * emissitivity * (T_surface^4 - T_sky^4)
- a transient heat flux simulating sun shine, this is written in a text file that must be used
The inner wall should only use a (maybe fixed) convection for now.
Having to apply three BCs and to read one of them from a file is quite difficult in OpenFOAM.
I would have to rewrite a solver and add a mixed BC since it is only possible to add one
condition per border in OpenFOAM.
Can you tell me if Elmer will fit our needs?
Kind regards,
Walter
My company needs to do some heat transfer calculations on a cooling tower using a 2D
cut through the tower. So I am searching for a FEM-software that can calculate this.
At first I had a look at OpenFOAM, this looks quite interesting and highly configurable,
but I am not sure if it would be the best solution. Searching for alternatives I came
across Elmer and had a look into its models and BCs and it looks fine so far.
I hope you can help to figure out if Elmer fits our needs.
Attached you find a picture showing our model and the BCs we want to apply.
The outer wall should get three BCs:
- Convection to the ambient temperature T_ambient: J_conv = alpha * (T_surface - T_ambient)
The convection could for a first approach be set to a fixed value (e.g. 20 W/m^2)
- Radiation to the sky: J_rad = sigma_boltz * emissitivity * (T_surface^4 - T_sky^4)
- a transient heat flux simulating sun shine, this is written in a text file that must be used
The inner wall should only use a (maybe fixed) convection for now.
Having to apply three BCs and to read one of them from a file is quite difficult in OpenFOAM.
I would have to rewrite a solver and add a mixed BC since it is only possible to add one
condition per border in OpenFOAM.
Can you tell me if Elmer will fit our needs?
Kind regards,
Walter
- Attachments
-
- mesh_tower.jpg (48.21 KiB) Viewed 7932 times
-
- Site Admin
- Posts: 4832
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Heat transfer in Elmer / OpenFOAM
Hi Walter
The BCs that you need should be rather straight-forward: 1) and 2 are trivial. 3) is also easy if you can express the flux as a one dimensional table e.g. flux with time, [t f]. Then you can just a reference to table in the command file. If you need dependency also on the angular coordinate it might be easiest to use a user defined function where the dependecy is fitted to some polynomical expression, for example.
-Peter
The BCs that you need should be rather straight-forward: 1) and 2 are trivial. 3) is also easy if you can express the flux as a one dimensional table e.g. flux with time, [t f]. Then you can just a reference to table in the command file. If you need dependency also on the angular coordinate it might be easiest to use a user defined function where the dependecy is fitted to some polynomical expression, for example.
-Peter
-
- Posts: 40
- Joined: 07 Jun 2011, 11:24
- Antispam: Yes
Re: Heat transfer in Elmer / OpenFOAM
Hi!
Thanks for your quick response. These are really good news! Is it really that easy
to add multiple BDs in Elmer? I can hardly believe it
I would really like to start calculating and quit searching for the right tool
Sure, the flux can be expressed as a one dimensional table,
it is calculated using Octave, so I can put the values
to any desired format.
So far my plan is not to use an angle parameter to write the
depencency of the solar radiation on tower, but to discretize the outer
wall into small parts, maybe 1° or 5°. Each of this elements will
be a separate boundary with different BCs
(Octave written text file with dot product of surface normal * solar angle).
Since this surfaces should be created, named and assigned automatically
I would use Octave to write text files in Elmer's desired format.
Does this sound like a good idea? The hint with the angular dependency is
good, too and I will take a look at this.
Kind regards,
Walter
Thanks for your quick response. These are really good news! Is it really that easy
to add multiple BDs in Elmer? I can hardly believe it
I would really like to start calculating and quit searching for the right tool
Sure, the flux can be expressed as a one dimensional table,
it is calculated using Octave, so I can put the values
to any desired format.
So far my plan is not to use an angle parameter to write the
depencency of the solar radiation on tower, but to discretize the outer
wall into small parts, maybe 1° or 5°. Each of this elements will
be a separate boundary with different BCs
(Octave written text file with dot product of surface normal * solar angle).
Since this surfaces should be created, named and assigned automatically
I would use Octave to write text files in Elmer's desired format.
Does this sound like a good idea? The hint with the angular dependency is
good, too and I will take a look at this.
Kind regards,
Walter
-
- Site Admin
- Posts: 4832
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Heat transfer in Elmer / OpenFOAM
Hi Walter
In practice what you plan sounds ok. The only concern I would have is that if you have discretization by fixed angles you will not have optimal accuracy with the mesh parameter. You will also have dependency on the additional discretization parameter. Perhaps you could eventually make a Fortran (or C) library of the solar forcing to a user defined subroutine and calculate it on-the-fly given the angle and time. But for testing purposes this would certainly not be needed.
-Peter
In practice what you plan sounds ok. The only concern I would have is that if you have discretization by fixed angles you will not have optimal accuracy with the mesh parameter. You will also have dependency on the additional discretization parameter. Perhaps you could eventually make a Fortran (or C) library of the solar forcing to a user defined subroutine and calculate it on-the-fly given the angle and time. But for testing purposes this would certainly not be needed.
-Peter
-
- Posts: 40
- Joined: 07 Jun 2011, 11:24
- Antispam: Yes
Re: Heat transfer in Elmer / OpenFOAM
Hi!
Thanks for your response.
Yes, writing a subroutine could be done if we further develop the model. But for the first calculations it should be ok.
Is it difficult to call a subroutine or a C-function from the *.sif file? Or at best - is it possible to call MatLab/Octave-functions direcly?
I don't unterstand what you mean saying
The mesh should be created automatically, depending on the angle of the pieces, diameter and wall thickness. I want to create it using a Octave/MatLab function that writes a textfile (*.geo for gmsh)...same procedure as with setting the BCs.
Would you recommend to use a tool (e.g. gmsh) for this or should I stick to ElmerGrid? Or do you have a better idea?
Kind regards,
Walter
Thanks for your response.
Yes, writing a subroutine could be done if we further develop the model. But for the first calculations it should be ok.
Is it difficult to call a subroutine or a C-function from the *.sif file? Or at best - is it possible to call MatLab/Octave-functions direcly?
I don't unterstand what you mean saying
I have yet another question:if you have discretization by fixed angles you will not have optimal accuracy with the mesh parameter.
The mesh should be created automatically, depending on the angle of the pieces, diameter and wall thickness. I want to create it using a Octave/MatLab function that writes a textfile (*.geo for gmsh)...same procedure as with setting the BCs.
Would you recommend to use a tool (e.g. gmsh) for this or should I stick to ElmerGrid? Or do you have a better idea?
Kind regards,
Walter
-
- Site Admin
- Posts: 4832
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Heat transfer in Elmer / OpenFOAM
Hi Walter
The default user defined subroutine interface includes some Elmer structures that might be difficult to address in C. Hence I would think that it would be easier to wrap the C code in piece of Fortran passing only some primitive data types.
Perhaps I understood wrong. What I meant that if you divide the 2*pi to segments and there apply constant BCs per segment, you'll introduce additional discretization.
You could indeed automate the meshing with
octave -> gmsh -> ElmerGrid -> ElmerSolver
If you want to compare different designs then often different mesh morphing methods may be attractive since their results are numerically differentiable. Of course that approach has its limitations also.
-Peter
The default user defined subroutine interface includes some Elmer structures that might be difficult to address in C. Hence I would think that it would be easier to wrap the C code in piece of Fortran passing only some primitive data types.
Perhaps I understood wrong. What I meant that if you divide the 2*pi to segments and there apply constant BCs per segment, you'll introduce additional discretization.
You could indeed automate the meshing with
octave -> gmsh -> ElmerGrid -> ElmerSolver
If you want to compare different designs then often different mesh morphing methods may be attractive since their results are numerically differentiable. Of course that approach has its limitations also.
-Peter
-
- Posts: 40
- Joined: 07 Jun 2011, 11:24
- Antispam: Yes
Re: Heat transfer in Elmer / OpenFOAM
Hi!
About the discretization, you understood that right. But I do not get the point to what you mean with "not have optimal accuracy with the mesh parameter".
Do you have a very small piece of code showing how this is done in principle? Can this be added to the *.sif file or is it hard-coded?The default user defined subroutine interface includes some Elmer structures that might be difficult to address in C. Hence I would think that it would be easier to wrap the C code in piece of Fortran passing only some primitive data types.
About the discretization, you understood that right. But I do not get the point to what you mean with "not have optimal accuracy with the mesh parameter".
Re: Heat transfer in Elmer / OpenFOAM
Hi,
i think there is some documentation on this on the manuals. But anyway, you can define
a parameter (material, bc, or otherwise) from the sif file as a fortran procedure as follows:
the corresponding fortran code would have
then do
Juha
i think there is some documentation on this on the manuals. But anyway, you can define
a parameter (material, bc, or otherwise) from the sif file as a fortran procedure as follows:
Code: Select all
param = Variable v1,v2,v3
Real Procedure "file" "proc"
Code: Select all
FUNCTION proc(model,n,x) RESULT(param)
USE DefUtils
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: param, x(*) ! x(1)==v1, x(2)==v2,etc...
! here you give param some value
END FUNCTION proc
Code: Select all
elmerf90 file.f90 -o file
Re: Heat transfer in Elmer / OpenFOAM
Hi,
an example of calling c-function from the fortran could be
for the c-function
and linked together with
BR,Juha
an example of calling c-function from the fortran could be
Code: Select all
FUNCTION...
INTERFACE
SUBROUTINE p(x,y,z,param) BIND(c)
USE iso_c_binding
REAL(C_DOUBLE), VALUE :: x,y,z
REAL(C_DOUBLE) :: param
END SUBROUTINE p
END INTERFACE
..
CALL p(x,y,z,param)
END FUNCTION ...
Code: Select all
void p(double x,double y,double z,double *param)
{
*param = x*y*z;
}
Code: Select all
elmerf90 file.f90 file1.c -o file
-
- Posts: 40
- Joined: 07 Jun 2011, 11:24
- Antispam: Yes
Re: Heat transfer in Elmer / OpenFOAM
Thanks for your answer. This was exactly what I was looking for.
Ok, I am on my way to create the mesh. So far I found out that it is a bit tricky to write an Octave script that writes that *.geo file for gmsh.
I have to use some for-loop to discretize the outer and inner circle of the tower.
e.g.
the mesh-creation I have to walk along the inner and outer circle and the line numbers have to be uniqe.
e.g.
I found a pdf here in the forum (viewtopic.php?f=9&t=704, download/file.php?id=417)
explaining how to create and numbering BCs while converting the mesh from gmsh to Elmer's format. And since this is not completly easy going I hope you can
show me the best way how to complete my task.
I would really like to use a clear unique naming for BCs in the mesh-data and BCs in Elmer's sif-file, e.g. BC_outer_001 or something like this. Is this
supported in Elmer (if yes, which suitable meshing tool does?) or do BCs have to be assigned using only numbers in the sif-file?
Kind regards,
Walter
Ok, I am on my way to create the mesh. So far I found out that it is a bit tricky to write an Octave script that writes that *.geo file for gmsh.
I have to use some for-loop to discretize the outer and inner circle of the tower.
e.g.
It gets even more tricky to connect the lines afterwards, because since I want to completly automatizefor k = 0:359
xCoord = outerDiameter * sin( conv_deg_to_rad(k));
yCoord = outerDiameter * cos( conv_deg_to_rad(k));
fprintf(fid, 'Point(%d) = {%f, %f, 0, %f};\n', point_counter, xCoord, yCoord, meshSize);
point_counter += 1;
end
the mesh-creation I have to walk along the inner and outer circle and the line numbers have to be uniqe.
e.g.
So, I thought one of you might know an easier solution, whether it is another meshing tool or another way to accomplish the automated creation.for k = 0:358
fprintf(fid, 'Line(%d) = {%d, %d};\n', k , k , k+1);
end
I found a pdf here in the forum (viewtopic.php?f=9&t=704, download/file.php?id=417)
explaining how to create and numbering BCs while converting the mesh from gmsh to Elmer's format. And since this is not completly easy going I hope you can
show me the best way how to complete my task.
I would really like to use a clear unique naming for BCs in the mesh-data and BCs in Elmer's sif-file, e.g. BC_outer_001 or something like this. Is this
supported in Elmer (if yes, which suitable meshing tool does?) or do BCs have to be assigned using only numbers in the sif-file?
Kind regards,
Walter