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

can any one correct this(udf)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 28, 2007, 03:50
Default can any one correct this(udf)
  #1
solomon
Guest
 
Posts: n/a
hello

i writting an position based udf like source=5(x*x)*(y*y) here x and y are the position of grids .i tried like this and iam new to c programming.so kinly help me to do this

thank you

#include "udf.h"

DEFINE_SOURCE(cure_source,c,t,ds,eqn) {

real source; cell_t c; Thread *t; real xc[ND_ND];

/* loop over all cells */

begin_c_loop_all(c,t)

{

C_CENTROID(xc,c,t);

source=8*C_CENTROID(xc,c,t)*C_CENTROID(xc,c,t);

}

end_c_loop_all(c,t)

return source; }
  Reply With Quote

Old   December 1, 2007, 10:06
Default Re: can any one correct this(udf)
  #2
mohanraj
Guest
 
Posts: n/a
#include "udf.h" DEFINE_SOURCE(cure_source,c,t,ds,eqn) { real source; real xc[ND_ND]; C_CENTROID(xc,c,t); /* Returns centroid in xc[ND_ND] for cell in thread t */ /* xc[0] = x distance, xc[1] = y distance */ source=5.0*xc[0]*xc[0]*xc[1]*xc[1]; ds[eqn]=0.0; return source; }
  Reply With Quote

Old   December 3, 2007, 22:34
Default Re: can any one correct this(udf)
  #3
solomon
Guest
 
Posts: n/a
thank you
  Reply With Quote

Old   December 3, 2007, 22:38
Default Re: can any one correct this(udf)
  #4
solomon
Guest
 
Posts: n/a
thank you mohan again i trapped in to another udf,it is hooked well but when i give iterare it shows fattel error,the udf goes like this

#include"udf.h" #include <mem.h> #include"math.h" #include"complex.h"

DEFINE_SOURCE(heat_gen,cell,thread,ds,eqn) { real x[ND_ND]; real source; real ko,E,R,Qalpha;

C_CENTROID(x, cell, thread);

ko=1.0;

E=53830.0;

R=8.341;

Qalpha=2000000.0;

source=C_R(cell,thread)*Qalpha*ko*exp(-E/(R*C_T(cell,thread)));

ds[eqn]=0;

return source; } pleaese give some sujjestions
  Reply With Quote

Old   December 4, 2007, 12:02
Default Re: can any one correct this(udf)
  #5
mohanraj
Guest
 
Posts: n/a
Hi,

Do you need to have "math.h" and "complex.h"? Instead of complex.h you can use a data structure. For example,

typedef struct cmpx { double x; double y; } complex;

complex z;

z.x="real" z.y="imaginary"

This should work. But, I don't see any error in the code.

Can u pls. check the following step?

1. Go to the fluent case file directory and invoke fluent 2. load the .cas and .dat file, initialize 3. unload the library namely, "libudf" (define->user-define->function->manage) 4. complie your source term udf again 5. load and hook the UDF in your scalar equation.

then you try running.

Other way is you can activate the species transport and reaction. Include your custom reaction in DEFINE_VR_RATE(...). This should definitely work.

  Reply With Quote

Old   December 5, 2007, 01:24
Default Re: can any one correct this(udf)
  #6
solomon
Guest
 
Posts: n/a
hello

i am new to this udf writing,but other udf like boiling etc hooked well and running.i think the complex.h and math.h is nessesary because there is a funtion called exp(...) used. any way i will try it

thank you
  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
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Is this understanding of turbulence models correct? 3kha Main CFD Forum 3 January 31, 2011 21:31
LES correct function luiz eduardo OpenFOAM Running, Solving & CFD 6 September 14, 2007 04:10
Correct lift but wrong pressure drag - possible? zx Main CFD Forum 4 July 27, 2007 23:38
For a correct the mole fraction ... kevin FLUENT 0 April 9, 2002 04:39


All times are GMT -4. The time now is 01:33.