CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   regarding the following UDF (https://www.cfd-online.com/Forums/fluent/128786-regarding-following-udf.html)

rp.soni January 21, 2014 08:52

regarding the following UDF
 
Hii friends...i am using UDF for source term of volumetric heat generation for my 2D simulation of heat transfer. Since i am new user for UDF, so i am in doubt whether i have written a correct UDF or not. UDF is given below.

/* sinusoidal heat generation in heater*/
#include "udf.h"
DEFINE_SOURCE(heat_gen_1e5,cell,thread,dS,eqn)
{
double source,time,A,B,omega,pi,time_period ;
A = 1.0e2, B=1.0e5;
pi= 22.0/7.0;
time_period = 900.0; //time in seconds;
time = CURRENT_TIME; //taking time value;
omega = (2.0*pi)/time_period;
source = A+B*(1+sin(omega*time));
//dS[eqn]= B*omega*cos(omega*time);
dS[eqn]= 0.0;
return source;
}


Kindly go through this UDF and reply whether it is in correct format or not.

Thanking you

pakk January 21, 2014 09:46

We could (with a lot of effort) check it for you, but I think it is better if you learn how do check it yourself.
  • Try to compile it. Do you get errors? Something is wrong, try to understand where the error comes from and fix it.
  • If you don't get errors, try to use it, and see if you get errors when you run the simulation. Do you get errors? Something is wrong, try to understand where the error comes from and fix it.
  • If you still don't have errors, examine the results. Did the UDF do what you expected? In this case, it seems like you want to generate heat in a sinusoidal pattern. So just calculate the generated heat, and see if it indeed a sinuasoidal pattern in time.
One remark already:
Code:


 pi= 22.0/7.0;

Although this might be sufficiently accurate in your case, it looks... unprofessionally...
Just use the built-in constant M_PI instead.

rp.soni January 22, 2014 00:25

regarding UDF
 
Thanks Pakk....
I have already compiled and i did not get any error. Actually I was thinking that if antbody have used this type of UDF then they can guide me whether I have written correct UDF or not..
I will run simulation and try to analyse the results..
Thanks for giving your valuble time...

pakk January 22, 2014 03:35

If your UDF compiles and runs without errors, you have written a correct UDF. But there are billions of correct UDFs; most of them don't have the effect what you want. You haven't specified which effect you want, so nobody here can check that.

sbaffini January 22, 2014 13:39

My two cents, just for you to know.

The term "dS[eqn]", which you have fortunately commented, is intended to be the derivative of the source term with respect to the dependent variable of the equation you are solving for. In your case it should be the derivative with respect to the TEMPERATURE, so for your source term it has to remain 0.

rp.soni January 23, 2014 08:26

regarding UDF
 
Thank u sbaffini for your valuble suggestions..
Ir means whatever code I have written is correct, right?
Actually I was not sure that's why I asked for this UDF issue...:)

sbaffini January 26, 2014 12:27

I can't see any other obvious mistake.

rp.soni January 27, 2014 00:08

thanks a lot 4 replying...


All times are GMT -4. The time now is 08:34.