CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

How to write a UDF for a UDS constant source term

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 7, 2020, 04:29
Default How to write a UDF for a UDS constant source term
  #1
New Member
 
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7
POSTHU is on a distinguished road
Hi, all

I am working about a UDS problem in Fluent, and there is a constant release source in a specific area in the domain. Now, I am trying to set it by UDF, and the UDF was interpreted well; however, there is some problem. Besides, My case is transient.

This is my code.

#include "udf.h"

DEFINE_SOURCE(uds1_source,c,t,dS,eqn)
{
real x[ND_ND];
real source;
C_CENTROID(x,c,t);
if (x[0]<=3.05 && x[0]>=2.95 && x[1]>=2.75 && x[1]<=2.85)
{
source = 1.;
dS[eqn] = 0.;
}
else
{
source=0.;
dS[eqn] = 0.;
}
return source;
}

As you can see, I want the source located in the area around (3,2.8), and the source release strength is 1. However, the simulation results show that there may be some mistake about the release strength. The contour at 1s is shown below, the maximum value is around 0.3, which is smaller than 1. How this happens? Could anyone help me? Thank you.
Attached Images
File Type: png 20200407162701.png (18.7 KB, 13 views)
POSTHU is offline   Reply With Quote

Old   April 7, 2020, 05:08
Default Source
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
The source value is always volumetric. Therefore, the value supplied by UDF, i.e., 1.0, is multiplied by the volume of the cell to which it is applied.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 7, 2020, 05:19
Default
  #3
New Member
 
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7
POSTHU is on a distinguished road
Quote:
Originally Posted by vinerm View Post
The source value is always volumetric. Therefore, the value supplied by UDF, i.e., 1.0, is multiplied by the volume of the cell to which it is applied.
Thank you so much, I would have a try.
POSTHU is offline   Reply With Quote

Old   April 7, 2020, 05:31
Default
  #4
New Member
 
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7
POSTHU is on a distinguished road
Quote:
Originally Posted by vinerm View Post
The source value is always volumetric. Therefore, the value supplied by UDF, i.e., 1.0, is multiplied by the volume of the cell to which it is applied.
Hi, vinerm

I have tried, and rewrite the UDF as follow, as you can see, I have add the C_VOLUME, but I think the result is still wrong, because the value becomes around 3300, I think the problem occurs because the volume of the cell, as you said before, but I can't find a suitable way to fix it, could you give me some detail advices, please?

#include "udf.h"

DEFINE_SOURCE(uds1_source,c,t,dS,eqn)
{
real x[ND_ND];
real source;
C_CENTROID(x,c,t);
if (x[0]<=3.05 && x[0]>=2.95 && x[1]>=2.75 && x[1]<=2.85)
{
source = 1/C_VOLUME(c,t);
dS[eqn] = 0.;
}
else
{
source=0.;
dS[eqn] = 0.;
}
return source;
}
POSTHU is offline   Reply With Quote

Old   April 7, 2020, 05:42
Default Source Value
  #5
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
That depends on what value do you want? If you want value of 1.0, then what you are doing now is correct. If you want a small value, then, you just scale it.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 7, 2020, 05:51
Default
  #6
New Member
 
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7
POSTHU is on a distinguished road
Quote:
Originally Posted by vinerm View Post
That depends on what value do you want? If you want value of 1.0, then what you are doing now is correct. If you want a small value, then, you just scale it.
Okay, thank you. I would re-think about that. I think it's a little amazing for me because the source strenth is only 1, and only after 1 second, the value of the scalar reaches about 3300.
POSTHU is offline   Reply With Quote

Old   April 7, 2020, 06:05
Default UDS value
  #7
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
If you want value to be 1 in each cell, then it has to be 1/cell volume, exactly what you are doing. If the value is increasing, it is most likely due to no convection and/or diffusion of the scalar.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 7, 2020, 06:55
Default
  #8
New Member
 
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7
POSTHU is on a distinguished road
Quote:
Originally Posted by vinerm View Post
If you want value to be 1 in each cell, then it has to be 1/cell volume, exactly what you are doing. If the value is increasing, it is most likely due to no convection and/or diffusion of the scalar.
Okay, I would check that, thank you again!
POSTHU is offline   Reply With Quote

Reply


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
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 21:53
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 05:18
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 07:58.