CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Problems in air flow udf - divergence (http://www.cfd-online.com/Forums/fluent-udf/118473-problems-air-flow-udf-divergence.html)

PJT May 28, 2013 10:01

Problems in air flow udf - divergence
 
Hi, I'm having problems in my UDF, I'm new in fluent and I'm trying to make a on-off air machine. But when I put to calculate, fluent shows a message: divergence in AMG solver.Here is my C file, if anyone could help me, please send a message, because I'm lost here... :confused:
PS: I'm catching average temperature and moisture by calculating the total area and the area*temperature/moisture in face, than divisioning them.



#include "udf.h"
#include "math.h"
static real umid_avgFd = 0.005;
static real temp_avgFd = 293.15;
static real temp_avgF = 293.15;
static real deltaTemp = 0;
static real umid_avgF = 0.05;
static real ma = 0.25;
static real Q = -5;
static real a = -2940.94;
//Parâmetros do controlador
// AC
static int AC = 1;
static real wsonoff = 0;
static real tsonoff = 0;
static real we;

DEFINE_EXECUTE_AT_END(controller)
{
real Tsat;
real setpoint = 293.15; // [k]
real massFlowRate = 0.485376; // [kg s^-1]
real specHeat = 1005; // [J kg^-1 K^-1]
real B;
real C;
real Qm;
real dT = 1;
real mar = 0.25; // fluxo de ar em kg/s
real SPS = setpoint + (dT/2);
real SPI = setpoint - (dT/2);
real dhSens = 0;

Domain *d;
Thread *t;
face_t f;
real A[ND_ND];
real area;
real temp = 0;
real temp_avg = 0;
real area_tot = 0;
real calorOut = 0;
real To = 0;
real Ti = 0;
real Te = 0;
real Ts = 0;
real Tss = 0;
real Tsl = 0;
real umid = 0;
real umid_avg = 0;
real b = 0;
real c = 0;
real wsl = 0;
real ws = 0;
real wss = 0;


// Relacionando variáveis às localizações.
d = Get_Domain(1);
t = Lookup_Thread(d,10);


// temperature in outlet.
begin_f_loop(f, t)
{
// F_T is for temperature in the faces.
// F_AREA save the area value in vector A.
F_AREA(A,f,t);
area = NV_MAG(A);
area_tot += area;
temp += F_T(f,t)*area;
}
end_f_loop(f, f_thread)

// Calculating the temperature.
temp_avg = temp / area_tot;
temp_avgF = temp_avg;
To = temp_avgF/ma;
temp = 0;
temp_avg = 0;
area_tot = 0;
// moisture in outlet.
begin_f_loop(f, t)
{
// F_YI pega dados de umidade nas faces.
// F_AREA armazena o valor da área no vetor A.
F_AREA(A,f,t);
area = NV_MAG(A);
area_tot += area;
umid += F_YI(f,t,1)*area;
}
end_f_loop(f, f_thread)
// Cálculo da temperatura média na superfície.
umid_avg = umid / area_tot;
umid_avgF = umid_avg;
we = umid_avgF;
temp = 0;
temp_avg = 0;
area_tot = 0;
// Relacionando variáveis às localizações.
t = Lookup_Thread(d,9);
// Dados de temperatura no inlet.
begin_f_loop(f, t)
{
// F_T pega dados de temperatura nas faces.
// F_AREA armazena o valor da área no vetor A.
F_AREA(A,f,t);
area = NV_MAG(A);
area_tot += area;
temp += F_T(f,t)*area;
}
end_f_loop(f, f_thread)
// Cálculo da temperatura média na superfície.
temp_avg = temp / area_tot;
temp_avgF = temp_avg;
Ti = temp_avgFd/ma;

/////////////////////////////////////
//Declarando variáveis
wss = we;
Tsat = 15.66*log(1000*we)-21.695;
Te = To;
dhSens = 1.005*(Te-Tsat)+we*1.82*(Te-Tsat);
b = 1243 + (1.82*(15.66*log(1000*we)-21.70)+2500.8+5203.2*we+2.92+2500.9);
Qm = -Q/ma;
c = Qm+(-1.005*Te)+(-1.82*we*Te)+(1.82*we*Tsat)+(-2500.8*we)+(-1.233)+(5.16*we)+(-2500.9*we);
Tss = (Te-(Qm/1.005+1.82*we));

//condição para o valor de wsl
if((-b*pow(2*a,-1))+(pow(b*b-4*a*c,0.5))*pow(2*a,-1)>we)
{
wsl = we;

}else
{
wsl = -b*pow(2*a,-1)+(pow(b*b-4*a*c,0.5))*pow(2*a,-1);
}
//achando valor de Tsl
Tsl = 15.66*log(1000*wsl)-21.695;
//condição para o valor de Ts
if(Qm>dhSens)
{
Ts = Tsl;
}else
{
Ts = Tss;
}
//condição para o valor de ws
if(Qm>dhSens)
{
ws = wsl;
}else
{
ws = wss;
}
//condição para controladot onoff

if(Ti>(To-(dT/2)))
{if(To>SPS)
{ AC = 1;
}
else
{ AC = 0;
}
}else
{if(To<SPI)
{ AC = 0;
}
else
{ AC = 1;
}
}
// condição para temperatura

if(AC==1)
{
tsonoff = Ts;
}else
{
tsonoff = To;
}
//condição para umidade
if(AC == 1)
{
wsonoff = ws;
}else
{
wsonoff = we;
}
}

//Define a temperatura do inlet
DEFINE_PROFILE(temp_inlet,t,i)
{
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = tsonoff;
}
end_f_loop(f,t)
}
//Define a umidade do inlet
DEFINE_PROFILE(umid_inlet,t,i)
{
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = wsonoff;
}
end_f_loop(f,t)
}


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