CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF function diverging (

ak6g08 June 22, 2009 08:23

UDF function diverging
hello all,

I am trying to implement a source term on the x and y momentum equations that equals Q (space charge) x E_i (electric field)

so I have defined two User defined scalars, one for the space charge which is composed of a unsteady function, a diffusivity function and a scalar flux function. All of which I effectively took out of the udf manual so i know there are no mistakes there. The electric field UDS only has a diffusion term (diffusion of the voltage), and a source term which equals Q/epsilon...and I have tested it on its own and it works so no mistakes there. However, Every time I run these two UDSs with the momentum field on (which I need to calculate the scalar flux term in the UDS) the mass conservation residuals diverge, and so I then get a floating point error.

I think the problem is with the gradient of the scalar term, i.e. the source term for x-momentum = -C_R(c,t)*C_UDSI_G(c,t,0)[0]*C_UDSI_G(c,t,1). There is no C_UDSI_RG macro as far as I am aware... please note that the field=-(gradient of the voltage). which is why I need to calculate a gradient of a user defined scalar...

If anyone knows if there is a better way I can implement the user defined gradient macros I would really appreciate it...

Im attaching the momentum source UDFs which I believe are the problem.


#include "udf.h"

real source;
source = -C_R(c,t)*C_UDSI(c,t,1)*C_UDSI_G(c,t,0)[0];
dS[eqn] = 0;
return source;

real source;
source = -C_R(c,t)*C_UDSI(c,t,1)*C_UDSI_G(c,t,0)[1];
dS[eqn] = 0;
return source;

Thanks in advance

ustbdynamic December 23, 2013 06:05

Dear ak,
Do you have solved this question. I have meet the same problem as you have meet.
The gradient of the scalar term! How good method you have to treat it?

thank you very much!

All times are GMT -4. The time now is 22:56.