|
[Sponsors] |
June 13, 2018, 14:51 |
temperature gradient
|
#1 |
New Member
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8 |
hello everyone,
Actually I am trying to solve the transport equation, as given in the attachment. So, I have made 2 UDS which has also been attached. I just want to know how to include gradient with respect to temperature. The code for UDS are as follows:- UDS0 :- DEFINE_DIFFUSIVITY(teg_diffusivity, cell, thread, i) { real res; real temp = C_T(cell, thread); res = -3.982 * pow(CON,-5) + 2.98 * pow(CON,-7) * temp - 4.685 * pow(CON,-10) * pow(temp,2) + 2.51 * pow(CON,-12) * pow(temp,3); real res1 = 1 / res; return res1; } UDS1 :- DEFINE_SOURCE(teg1_source, c, t, dS, eqn) { real temp = C_T(c,t); dS[eqn] = grad((8.439 * pow(CON,-4) - 3.81 * pow(10,-6) * temp + 6.736 * pow(CON,-9) * pow(temp,-9) - 3.934 * pow(CON,-12) * pow(temp,-12))*grad(temp)); return (8.439 * pow(CON,-4) - 3.81 * pow(10,-6) * temp + 6.736 * pow(CON,-9) * pow(temp,-9) - 3.934 * pow(CON,-12) * pow(temp,-12))*grad(temp); } Please help me, I am a beginner and I need it desperately for my project. |
|
June 13, 2018, 21:35 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
The temperature gradient is retrieved with C_T_G(c,t) which is a vector with components in each direction, and the magnitude can be calculated with NV_MAG(C_T_G(c,t)).
Further reading: UDF temperature gradient |
|
June 14, 2018, 04:13 |
|
#3 |
New Member
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8 |
Thanks 'e' for replying ,
Can you just tell me, if I have a property as a function of temperature(like the one I have attached) and I need gradient of that function then can I simply use grad(function) ? And also tell if you know the code for finding differential of function with respect to different variables. |
|
June 14, 2018, 04:59 |
|
#4 | |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
First of all, determine which equations you would like to solve, and provide some further details. Remember that the nabla symbol means that you are differentiating the variable in each spatial direction, for example in three dimensions:
Each term corresponds to C_T_G(c,t)[0], C_T_G(c,t)[1] and C_T_G(c,t)[2]. For details, read section "3.2.3.7. Gradient (G) and Reconstruction Gradient (RG) Vector Macros" (for R15.0) in the UDF manual. Quote:
|
||
June 14, 2018, 05:24 |
|
#5 |
New Member
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8 |
Hey thanks again,
Actually I was trying to include the R.H.S of the equation (attached) in source of UDS0 and I know the alpha in the equation as a function of temperature. So, I made the code as follows :- static real CON = 10; DEFINE_SOURCE(teg1_source, c, t, dS, eqn) { real temp = C_T(c,t); dS[eqn] = grad((8.439 * pow(CON,-4) - 3.81 * pow(10,-6) * temp + 6.736 * pow(CON,-9) * pow(temp,-9) - 3.934 * pow(CON,-12) * pow(temp,-12)) * C_T_G(c,t)); return (8.439 * pow(CON,-4) - 3.81 * pow(10,-6) * temp + 6.736 * pow(CON,-9) * pow(temp,-9) - 3.934 * pow(CON,-12) * pow(temp,-12)) * C_T_G(c,t); } But it wont work. So, I was a bit confused between gradient and differential. But now I understood what you explained. Can you just post the correct code for the above equation, it will be very helpful. |
|
June 14, 2018, 07:47 |
|
#6 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
If your source term is then you could create a user-defined scalar (UDS) for using:
Code:
C_UDSI(c,t,0) = alpha_function(C_T(c,t))*C_T_G(c,t)[0]; Code:
real alpha_function(real T) { return 8.439e-4 - 3.81e-6*T + 6.736e-9*pow(T,-9.) - 3.934e-12*pow(T,-12.); } Note: you would need two other UDS for the y and z components (remember to take the gradients in the y and z directions respectively). |
|
June 14, 2018, 09:05 |
|
#7 |
New Member
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8 |
Thank you very much I got it.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to create a temperature gradient in thin wall and two dimensions | leggman7 | Main CFD Forum | 0 | October 30, 2013 00:21 |
How to get temperature gradient in dat.file | jason feng | FLUENT | 0 | September 30, 2013 00:39 |
Wall correction for the temperature gradient | Hagen | OpenFOAM | 0 | March 7, 2011 21:04 |
temperature normal gradient on a boundary | Sandrine | Main CFD Forum | 2 | June 10, 2009 17:34 |
Direct calculation of temperature gradient | J.W.Ryu | FLUENT | 5 | December 27, 2001 07:39 |