# how to plot new function or variable in fluent?

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

July 10, 2014, 11:35
#21
New Member

Jups
Join Date: Jul 2014
Posts: 12
Rep Power: 11
Quote:
 Originally Posted by Hershey Yes. Since your equation for q is the same in each source, it would be better to define it in DEFINE_ADJUST by saving the value as C_UDMI(c,t,0) = q. Then in the DEFINE_SOURCE you should just reference C_UDMI(c,t,0) instead of q. In the DEFINE_ADJUST, there are a couple things you must do: 1. You must use begin_cell_loop(c,t) to loop through the cells for C_UDMI. Try looking at Google to fine this and an example. 2. Finally, since DEFINE_ADJUST is called at the beginning of every iteration (not time step), you will want to only calculate q for the first iteration. Look at the following link on how to do that: http://www.cfd-online.com/Forums/flu...luent-5-a.html

thankyou Hersey,, later i will tell u how the progress..

July 11, 2014, 01:51
#22
New Member

Jups
Join Date: Jul 2014
Posts: 12
Rep Power: 11
SUN, HERSEY..
i make q in DEFINE_ADJUST and i use time step 0.001..
it's work.. but the result is not what i want

Code:
```#include "udf.h"
#define P 3000000
#define T 300
#define e 0.65
#define Rc 500
#define k 0.00013996
#define qe 0.0698337
double q, time, turq;

DEFINE_INIT(q_init,d)
{
cell_t c;

{
begin_c_loop_all(c,t)
{
C_T(c,t)=300;
C_P(c,t)=100000;
q = 0;
}
end_c_loop_all(c,t)
}
}

{
cell_t c;

{
begin_c_loop_all(c,t)
{

time = CURRENT_TIME;
turq = k*(qe-q);
q = q+turq*time;

C_UDMI(c,t,0) = q;
C_UDMI(c,t,1) = turq;

}
end_c_loop_all(c,t)
}
}

DEFINE_SOURCE(mass_source, c, t)
{
real source;

source = -((1-e)/e)*C_UDMI(c,t,1);

return source;
}

DEFINE_SOURCE(y_velocity, c, t)
{
real source;

source = -C_UDMI(c,t,1)*C_V(c,t);

return source;
}

{
real source;

source = -C_UDMI(c,t,1)*C_U(c,t);

return source;
}

DEFINE_SOURCE(energy_source, c, t)
{
real ha, source;

ha = 720.9272;
source = -C_UDMI(c,t,1)*Rc*H;

return source;
}```
I attach 2 pictures..
my result is "iterasi udm adjust" pic..
and the result i want is "sahoo" pic..

my case use porosity..
i imagine the result should be is like this..
when the methane flow through inlet,, the pressure and temperature at above is more highly than below... like we say, the vessel is 100cm high..
the pressure and temp at 0cm is different than 100cm..
but my result is same..
have any idea?
Attached Images
 iterasi udm adjust.jpg (96.3 KB, 5 views) sahoo.JPG (29.6 KB, 5 views)

 October 14, 2014, 01:30 hi #23 Member   Qureshi M Z I Join Date: Sep 2013 Posts: 79 Rep Power: 12 hi, i am facing the similar problem. my UDF of source term is showing zero output. here is my Udf , if anybody know the problem please help me . DEFINE_SOURCE(xmom,c,t,dS,eqn) { real x[ND_ND]; real source,ve; C_CENTROID(x,c,t); ve=sqrt((pow(C_U(c,t),2.0)+pow(C_V(c,t),2.0)+pow(C _W(c,t),2.0))); source =-1.225*0.2*0.55* C_U(c,t)*ve; C_UDMI(c,t,0)=source; return source; } thanks

 October 14, 2014, 01:36 hi #24 Member   Qureshi M Z I Join Date: Sep 2013 Posts: 79 Rep Power: 12 hi i am facing the similar problem. my UDF of source term is showing zero output. here is my Udf , if anybody know the problem please help me . DEFINE_SOURCE(xmom,c,t,dS,eqn) { real x[ND_ND]; real source,ve; C_CENTROID(x,c,t); ve=sqrt((pow(C_U(c,t),2.0)+pow(C_V(c,t),2.0)+pow(C _W(c,t),2.0))); source =-1.225*0.2*0.55* C_U(c,t)*ve; C_UDMI(c,t,0)=source; return source; } thanks

 October 14, 2014, 07:15 #25 Senior Member     Join Date: Nov 2010 Posts: 103 Rep Power: 15 Make sure "ve" and "C_U(c,t)" are non-zero by printing them out. Also, add dS[eqn] (derivative of source term) before returning the source. Cheers!

 October 14, 2014, 23:12 hi #26 Member   Qureshi M Z I Join Date: Sep 2013 Posts: 79 Rep Power: 12 thanks for hint. SUN , now UDF working

 Tags new function, plot