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

temperature gradient

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By `e`

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2018, 14:51
Default temperature gradient
  #1
New Member
 
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8
sahoo is on a distinguished road
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.
Attached Images
File Type: png Capture5.PNG (3.0 KB, 23 views)
File Type: png Capture.PNG (2.9 KB, 16 views)
File Type: png Capture2.PNG (3.4 KB, 17 views)
File Type: png Capture3.PNG (2.8 KB, 18 views)
File Type: png Capture4.PNG (3.1 KB, 17 views)
sahoo is offline   Reply With Quote

Old   June 13, 2018, 21:35
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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
`e` is offline   Reply With Quote

Old   June 14, 2018, 04:13
Default
  #3
New Member
 
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8
sahoo is on a distinguished road
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.
Attached Images
File Type: png Capture.PNG (5.6 KB, 16 views)
sahoo is offline   Reply With Quote

Old   June 14, 2018, 04:59
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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:

\nabla T = \frac{\partial T}{\partial x}\mathbf{i} + \frac{\partial T}{\partial y}\mathbf{j} + \frac{\partial T}{\partial z}\mathbf{k}

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:
Originally Posted by sahoo View Post
And also tell if you know the code for finding differential of function with respect to different variables.
For the example you provided with \alpha(T), you could differentiate with respect to T analytically. What different variables are you referring to?
`e` is offline   Reply With Quote

Old   June 14, 2018, 05:24
Default
  #5
New Member
 
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8
sahoo is on a distinguished road
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.
Attached Images
File Type: png Capture.PNG (3.8 KB, 16 views)
sahoo is offline   Reply With Quote

Old   June 14, 2018, 07:47
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
If your source term is \frac{\partial}{\partial x} \left( \alpha(T) \frac{\partial T}{\partial x}\right) then you could create a user-defined scalar (UDS) for \alpha(T) \frac{\partial T}{\partial x} using:

Code:
C_UDSI(c,t,0) = alpha_function(C_T(c,t))*C_T_G(c,t)[0];
within a loop, and creating a function for alpha. For example:

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.);
}
where e-4 means *10^-4 or *pow(10,-4). Lastly, the source term can be evaluated with C_UDSI_G. Read through the examples in "8.2.5. User-Defined Scalars" (for R15.0) in the UDF manual for further guidance.

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).
ray_lo and FelixS like this.
`e` is offline   Reply With Quote

Old   June 14, 2018, 09:05
Default
  #7
New Member
 
Animesh Sahoo
Join Date: May 2018
Posts: 20
Rep Power: 8
sahoo is on a distinguished road
Thank you very much I got it.
sahoo 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
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


All times are GMT -4. The time now is 17:27.