# UDF function diverging

 Register Blogs Members List Search Today's Posts Mark Forums Read

 June 22, 2009, 08:23 UDF function diverging #1 Member   Akour Join Date: May 2009 Posts: 79 Rep Power: 9 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. 3. MOMENTUM SOURCES #include "udf.h" DEFINE_SOURCE(xmom_source,c,t,dS,eqn) { real source; source = -C_R(c,t)*C_UDSI(c,t,1)*C_UDSI_G(c,t,0)[0]; dS[eqn] = 0; return source; } DEFINE_SOURCE(ymom_source,c,t,dS,eqn) { 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 AK

 December 23, 2013, 06:05 #2 New Member   xingangzheng Join Date: Jul 2009 Posts: 11 Rep Power: 9 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!

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31 gaottino OpenFOAM Native Meshers: blockMesh 7 July 19, 2010 14:11 skabilan OpenFOAM Installation 3 July 28, 2009 00:35 ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50 Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00

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