CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   What's wrong with my UDF? (http://www.cfd-online.com/Forums/fluent/28632-whats-wrong-my-udf.html)

 olivia June 22, 2001 11:36

What's wrong with my UDF?

Hi everybody:

I want to solve heat and moisture transfer analysis.
This problem is the heat tranfer in conjunction with moisture transfer. This is a 3-D problem. The solution domain is cube of dense bale.
The governing equation is following for 1-D:

dM / dt = Dm * d^2 m / dx^2
dT / dt = alpha * d^2 T / dx^2 + 1 / Cp * dM / dt * Lg

M : is the moisture
t : time
Dm : moisture diffusivity
T : temperature
alpha = thermal diffusivity
Cp : specific heat at constant pressure
Lg = L * (1 + 8.31 * exp(-0.436 * m)
L = 2440

The boundary conditions are
at surface
M = (Mi - Me)* exp(-Km * t) + Me
Km : moisture sorption rate, Km = 1.83e-4

T = 45 deg C

The initial condition
T = 18 deg C
M = 0.85 both T and M is uniform.

I want to solve this problem with Fluent v.5.5. I add an user-scalar transport equation to solve the moisture. Then determine the time derivative of moisture and substitute it into the energy equation as the source term. I employed the UDF function to do my
job. However I encountered some problem. The compilation of UDF is ok, but something is wrong in excution. The error message is as follow :

Error:
1. Note exact events leading to error.
:
:
Error Object: ()

I woundered that there is some bugs in my UDF codes.
Maybe it is due to wrong type of passed argument or incorrect usages of some subroutine. I hope that somebody help me to debug my codes. My code is as follow :

#include "udf.h"
#define rho 1000
#define l 2440.0
#define mi 100.0
#define me 50.0
#define km 1.83e-4
#define el 1.0

{
float time_step, vol, phi_old, phi_curr;

time_step= RP_Get_Real("physical-time-step");

*apu = -rho*vol*phi_curr/time_step; /*central coefficient part*/

*su = rho*vol*phi_old/time_step; /*source term part*/

}

{
real source;

float lg,A,phi_curr,phi_old,time_diff,vol,time_step;

time_step= RP_Get_Real("physical-time-step");

time_diff = (phi_curr - phi_old) / time_step;

lg = el * ( 1.0 + 8.31 * exp(-1.0 * 0.436 * phi_curr) );

A=1.0/0.5*lg;

source = A * time_diff * vol * rho;

ds[eqn] = 0.0;

return source;
}

{
face_t f;

{
real flow_time = RP_Get_Real("flow-time");
F_PROFILE(f,thread,position) = (mi - me) * exp( - 1.0 * km * flow_time) + me;
}
}

Thanks again

 John C. Chien June 23, 2001 17:06

Re: What's wrong with my UDF?

(1). Why not try to write a finite-difference code for this set of parabolic differential equations. (2). Most numerical method books should give you some schemes to start with. (a good reference book is: Applied Numerical Methods by Carnaham,Luther, Wilkes)

 All times are GMT -4. The time now is 15:49.