
[Sponsors] 
April 24, 2018, 11:13 
UDF: gradient of variable and reaction term

#1 
New Member
Solal
Join Date: Nov 2012
Posts: 6
Rep Power: 11 
Hi,
I'm trying to implement a combustion model as a UDF. Say I define a variable xi at every active node of the domain. How do I compute d(xi)dx_i? From examining the 'include/csi_libraries.h' file, I've found this function: calc_grad_global_scalar(double *grad_var, int kk, PRECISION *global_var, int ndim, int idim)); What exactly are ndim and idim? The only time this function is used in 'example_src/user_turbulence_model.c'. "ndim" seems to be the size of the array passed, but I'm not sure what idim is for. Also, given the temperature, pressure and mass composition of a cell, can I retrieve the reaction rate? Thank you! 

April 25, 2018, 19:39 

#2 
New Member
Dan Maciejewski
Join Date: Apr 2018
Location: Madison, WI, USA
Posts: 11
Rep Power: 5 
For CONVERGE 2.4 (and 2.3), you've identified the correct function to calculate the gradient: SHARED_calc_grad_global_scalar_node.
This function calculates the gradient of a scalar or vector. The gradient operator raises the dimensionality: gradient of a scalar is a vector; the gradient of a vector is a tensor. The last two arguments relate to the dimension of the input variable and which component of the result is of interest. 1st arg: pointer to an array to hold the computed gradient value 2nd arg: cell index 3rd arg: pointer to variable who's gradient you want to calculate 4rd arg: dimension of the variable you want to calculate 5th arg: index of the first component of the gradient you want to store. To calculate the gradient of a scalar, ndim = 1 (one value per cell), and idim = 0, since you want to store the first three components of the gradient in your new variable; these 3 components are stored in a 1D array, so the first three elements are the 3 components of the gradient of the first cell, next three elements are for the 2nd cell, etc. If taking the gradient of a vector, ndim = 3, and idim may be nonzero. Please contact support@convergecfd.com if taking the gradient of a vector (or tensor). 

May 7, 2018, 10:15 

#3  
New Member
Solal
Join Date: Nov 2012
Posts: 6
Rep Power: 11 
Thank you for your help!
Quote:


Tags 
converge, udf 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Fluent UDF urgent! Variable reaction rate  natantyt  Fluent UDF and Scheme Programming  8  October 17, 2021 04:35 
Volumatric reaction rate UDF  elmcmaster  FLUENT  8  October 6, 2010 06:22 
again on udf surface reaction  jason  FLUENT  0  November 7, 2003 11:45 
reaction rate as UDF variable  sivakumar  FLUENT  4  February 12, 2002 01:31 
chemical reaction  decompostition  La S. Hyuck  CFX  1  May 23, 2001 01:07 