|
[Sponsors] |
how to write udf for a component source term on a wall ? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 12, 2017, 00:48 |
how to write udf for a component source term on a wall ?
|
#1 |
New Member
Join Date: Jul 2017
Posts: 13
Rep Power: 9 |
Hi
How can I include a component source term on a wall. The source term udf in fluent is defined for volumetric zone. Any suggestions will be very helpful. Thank you |
|
September 12, 2017, 05:10 |
|
#2 |
Senior Member
|
Can you elucidate on the concept of "source term on a wall"? Because that's not something typically present in the NS equations, so Fluent does not allow you to do it. If it is something specific to a certain model, you might find a FLUENT option in the specific section of the manual.
|
|
September 12, 2017, 07:06 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
You may apply heat flux to the wall:
1 way - use profile and apply flux as a table 2 way - use UDF and Define_profile function Best regards |
|
September 12, 2017, 07:48 |
|
#4 |
Senior Member
|
Which goes under the "boundary condition" nomenclature (and Fluent section). That's why I asked for elucidation. Once we agree on the terminology we can go further with giving help.
|
|
September 14, 2017, 23:22 |
|
#5 |
New Member
Join Date: Jul 2017
Posts: 13
Rep Power: 9 |
Hi
I have a rectangular box, and on one wall of this box I want to generate water (all over the wall). I was thinking to write a UDF on wall for mass source term. But mass source term can be applied on cell volume (mol/m3-sec) not on face cell (mol/m2-sec). Can you please suggest something now ? |
|
September 14, 2017, 23:23 |
|
#6 | |
New Member
Join Date: Jul 2017
Posts: 13
Rep Power: 9 |
Quote:
I have a rectangular box, and on one wall of this box I want to generate water (all over the wall). I was thinking to write a UDF on wall for mass source term. But mass source term can be applied on cell volume (mol/m3-sec) not on face cell (mol/m2-sec). Can you please suggest something now ? |
||
September 14, 2017, 23:27 |
|
#7 | |
New Member
Join Date: Jul 2017
Posts: 13
Rep Power: 9 |
Quote:
But now , how to select the cell volumes there ? and how to convert the units, since it give mass generate rate in volume instead of surface? |
||
September 15, 2017, 06:51 |
|
#8 | |
Senior Member
|
Quote:
1) Define a new UDM and, in a DEFINE_ON_DEMAND UDF, set it first, say, to -1 in all the cells (by looping on all cells of all cell threads). Then perform a loop on the boundary threads and, for your selected boundary, loop on the thread faces and set the UDM in the C0 cell to the relative cell face area. 2) Use a DEFINE_SOURCE UDF where only the cells with positive UDM have the source term applied, the others simply return 0. However, you need to know your model, the physical meaning of the source term and how it shoud be defined. Then you can simply scale it via the cell volume and the face area you stored in the UDM. If you give more details (there are several ways to simulate water) maybe we can give more help. |
||
September 15, 2017, 13:04 |
|
#9 | |
New Member
Join Date: Jul 2017
Posts: 13
Rep Power: 9 |
Quote:
And, source term is volumetric, so how can I write a mass source term at wall ? And, if there is way by considering the cells next to walls, then how to do it so source term units remains unchanged. I hope problem statement is clear now. Any help will be much appreciated |
||
September 18, 2017, 09:04 |
|
#10 |
Senior Member
|
Ok, I assume then that you are using the species transport approach. If I understand what you wrote, you are saying that using surface reactions from species transport is not working in your case.
If this is the case, I first suggest to investigate more why this is not working straight out of the box. There is no trick that is going to work if that is a physical reason. I cannot help on the physics. You are in charge for this. So, let us assume the reason is not physical and this can be done. At this stage, you should have an expression for what you think should be the source formula to be used for each face of the right boundary. Now, the only thing you need to know is that for source terms Fluent has units of generation-rate/volume or, roughly, your source term will be interpreted as an additional term in the equations having the same units of the unsteady term. In practice, for you, given you know your source term, this means that Fluent is going to multiply it by the cell volume (i.e., it is going to make the volume integral on the cell, according to the FV technique). If you want a surface flux then, probably, you want it to be face integrated, so you need to divide your source term by the cell volume and multiply it by the relative cell face area (the one you stored in the UDM). However, this is, somehow, part of tyhe physics of the source term. It is up to you to establish if, say, you need multiplication by the cell face area. |
|
September 22, 2017, 02:55 |
|
#11 | |
New Member
Join Date: Jul 2017
Posts: 13
Rep Power: 9 |
https://www.dropbox.com/s/64u6v0s50t...20box.cas?dl=0
https://www.dropbox.com/s/cqd8bbjpuv...ctangle.c?dl=0 Hi, I think the problem was not clear. So I am attaching my case file here for your reference. In the geometry you can see, at wall-1, specified mass fraction of components given and at wall-2 ,3, and 4, there is no mass flux. The components (H2, H20 and CH4 are diffusing through the geometry) and H2 gets consumed at constant rate (0.03 mol/m2-sec)at wall-3 and H2O gets generated there at the same rate. So how to do it ? I have written udf for that, and attached here for your reference. Please have a look. It would be great help if you can comment on that. Quote:
|
||
September 22, 2017, 05:35 |
|
#12 |
Senior Member
|
I honestly don't understand what is not clear from my side.
Sorry to be rude but, one thing is "I don't know how to do THIS with udf" and a completely different one is "I don't know how to use udf IN GENERAL". You need to activate "Source term" under cell conditions and provide the right udf for each species (you need two udf). Also, your udf can be ok as first attempt, just to see if everything is ok, but you need to be sure that the selected x[0] range correctly selects only the cell layer you are interested in. I have no idea if the source term is correct or not. You need to look into the manual and see what are the units for the species (I guess mass fractions, so no units). Your resulting source term in the given cells will be [units of species] [units of density]/[units of time] x cell volume x numerical value of source term. Still, looking at the manual, my first attempt would have been to use surface reactions and not an udf. I suggest to move to something simpler than species transport and reactions to start with udf. A simple exercise you can do is with a pipe with inlet and outlet, a single species and a mass source term on a certain set of cells. Then monitor the mass imbalance between inlet and outlet to see the effect of the numerical value of the source term. |
|
September 3, 2019, 09:43 |
|
#13 | |
New Member
Hasan Najafi Khaboshan
Join Date: Jan 2018
Posts: 11
Rep Power: 8 |
Quote:
I have the same problem and your suggestion was great. I know that we can add the source term with UDF to our simulation in FLUENT (cell centroid), and I done this. But, I want to change the velocity (normal velocity of wall) on the faces of the wall boundary condition. With your way, I have added my source term to the first cells of the wall boundary condition (as you said in this forum). I want to know that is there any way to change the velocity component (x,y,z-velocity) of the wall? |
||
September 3, 2019, 09:55 |
|
#14 |
Senior Member
|
Dear Hasan,
I don't know if I understood correctly your problem, but fixing the wall velocity via UDF should be straightforward with a DEFINE_PROFILE UDF. Unfortunately, I don't have anymore access to Fluent and the manual, so I'm not 100% sure if velocity components at wall can be assigned by UDF, but they should be. Note, however, that any wall-normal component is removed by Fluent, if I recall correctly. In constrast, there is nothing, in the approach I described, that prevents you from varying the wall normal velocity to be used in your source term. You can store it in a separate UDM or premultiplied with the face area in a single UDM. This should work if the velocity doesn't change with iterations/time steps. |
|
September 4, 2019, 01:14 |
|
#15 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
ansys fluent customization manual
DEFINE_PROFILE macro best regards |
|
September 4, 2019, 12:04 |
|
#16 | |
New Member
Hasan Najafi Khaboshan
Join Date: Jan 2018
Posts: 11
Rep Power: 8 |
Quote:
According to my project and what I studied in the Fluent Customization Manual, I can't use the DEFINE_PROFILE macro. So, I should consider the effect of wall faces to the first cells near the wall based on FVM. |
||
November 8, 2019, 02:20 |
|
#17 |
Member
Vignesh Lakshmanan
Join Date: Nov 2016
Posts: 79
Rep Power: 10 |
Hi All,
I have an equation which describes the variation of Cooling Capacity with respect to evaporating temperature. I need to input this in cell zone conditions as a source term in Fluent, so that this can act as a sink and remove heat from the intended cell zone/domain. Can anyone help me on writing this udf? More details of the simulation: Problem: Thermal pull down of Deep Freezer Simulation: 3d, transient, natural convection case Thanks in advace, Vignesh |
|
November 9, 2019, 06:29 |
|
#18 | |
New Member
Hasan Najafi Khaboshan
Join Date: Jan 2018
Posts: 11
Rep Power: 8 |
Quote:
I think the below UDF will help you. First, you should mark your appropriate cells near the boundary condition by defining the UDM as DEFINE_ON_DEMAND Macro. Then, you can use it as an “if” statements in your source term. It should be noted that this UDF must be compiled and will be just run in parallel cases. I hope this UDF could help you. Best regard Hasan Najafi Khaboshan Code:
#include "udf.h" DEFINE_ON_DEMAND(selecting_the_cells) { #if !RP_HOST Domain *d; Thread *t, *tc, *t0; face_t f; cell_t c, c0; d=Get_Domain(1); tc=Lookup_Thread(d,9); //thread pointer of the surface (the ID can be obtained from the boundary condition panel) //Loop through all the cell threads in the domain thread_loop_c(t,d) { //Loop through the cells in each cell thread begin_c_loop(c,t) { C_UDMI(c,t,0)=0; } end_c_loop(c,t) } begin_f_loop(f,tc) { c0=F_C0(f,tc); t0=THREAD_T0(tc); C_UDMI(c0,t0,0)=1; } end_f_loop(f,tc) #endif } DEFINE_SOURCE(energy_source, c, t, dS, eqn) { real source; if (C_UDMI(c,t,0)>0.) { source=1000.; dS[eqn]=0.; } else { source=0.; dS[eqn]=0.; } return source; } |
||
November 13, 2019, 00:58 |
|
#19 | |
Member
Vignesh Lakshmanan
Join Date: Nov 2016
Posts: 79
Rep Power: 10 |
Quote:
Thanks for your reply. I'm pretty new to Fluent udf. Can you pls tell me what is the meaning/how the following line works: ds(eqn) = o; The reason im asking is im not sure whether my equation (which is a profile) can fit in here. Also, suppose my equation is ax2+bx+c, how can I correlate temperature with "x" ? Thanks and Regards Vignesh |
||
November 13, 2019, 04:07 |
|
#20 | |
New Member
Hasan Najafi Khaboshan
Join Date: Jan 2018
Posts: 11
Rep Power: 8 |
Quote:
The “dS[eqn]=0;” is derivative of the source term with respect to the temperature (for the energy source term in your UDF). This line can enhance the stability of the solution and help convergence rates due to the increase in diagonal terms on the solution matrix. For more information about it, you can see the ANSYS FLUENT UDF Manual (there is an example for the source term that you can understand the argument's type of this Macro easily). To make the correlation between the temperature and position of “x”; if your temperature changes as a function of position, you can write your source term by using these lines. real x[ND_ND], xx, yy, zz; C_CENTROID(x,c,t); xx=x[0]; //x-position yy=x[1]; //y-position zz=x[2]; //z-position Best regard Hasan Najafi Khaboshan |
||
Tags |
mass source udf, wall udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mesh file for flow over a circular cylinder | Ardalan | Main CFD Forum | 7 | December 15, 2020 14:06 |
polynomial BC | srv537 | OpenFOAM Pre-Processing | 4 | December 3, 2016 10:07 |
[swak4Foam] Error bulding swak4Foam | sfigato | OpenFOAM Community Contributions | 18 | August 22, 2013 13:41 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 14:59 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |