|
[Sponsors] |
How to write a UDF for a UDS constant source term |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 7, 2020, 04:29 |
How to write a UDF for a UDS constant source term
|
#1 |
New Member
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7 |
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. |
|
April 7, 2020, 05:08 |
Source
|
#2 |
Senior Member
|
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. |
|
April 7, 2020, 05:19 |
|
#3 |
New Member
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7 |
||
April 7, 2020, 05:31 |
|
#4 | |
New Member
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7 |
Quote:
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; } |
||
April 7, 2020, 05:42 |
Source Value
|
#5 |
Senior Member
|
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. |
|
April 7, 2020, 05:51 |
|
#6 |
New Member
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7 |
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.
|
|
April 7, 2020, 06:05 |
UDS value
|
#7 |
Senior Member
|
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. |
|
April 7, 2020, 06:55 |
|
#8 |
New Member
MengqiangHu
Join Date: Feb 2019
Posts: 13
Rep Power: 7 |
||
|
|
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 |