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/)
-   -   error: uninitialized local variable 't' used (http://www.cfd-online.com/Forums/fluent-udf/80292-error-uninitialized-local-variable-t-used.html)

MASOUD September 22, 2010 00:19

error: uninitialized local variable 't' used
 
Hi,
I get the following error:

warning C4700: uninitialized local variable 't' used
warning C4700: uninitialized local variable 'c' used

When I compile the UDF (for line 65)

What could be the reason?

Here is the code:

***************************

#include "udf.h"
#include "sg.h"

/* Define which user-defined scalars to use. */
enum
{
E_CHARGE_UDS,
C_CHARGE_UDS,
N_REQUIRED_UDS
};

static real ACT_AREA_A=270;
static real ACT_AREA_C=300;
static real REF_EXCH_CURR_A=2.1;
static real REF_EXCH_CURR_C=0.40;
static real REV_POT=1.02;
static real MW_H2=0.032;
static real MW_H2O=0.032;
static real MW_O2=0.032;
static real MW_CO2=0.044;
static real MW_N2=0.032;
static real MW_MIX;
static real X_H2;
static real X_H2O;
static real X_O2;
static real X_CO2;
static real X_N2;
static real ALPHA_A=1.5;
static real ALPHA_C=0.5;
static real NO_ELEC=2;
static real FARADAY=96485;
static real UNI_GAS_CONS=8.314;
static real STOCH_H2=-1;
static real STOCH_H2O=1;
static real STOCH_O2=-0.5;
static real STOCH_CO2_A=1;
static real STOCH_CO2_C=-1;
static real RXN_RATE_A;
static real RXN_RATE_C;
static real Z_A;
static real ZZ_A;
static real ZZZ_A;
static real Z_C;
static real ZZ_C;
static real ZZZ_C;
static real source;
static real u=0.0;
static real domain_ID=30;



DEFINE_ADJUST(SUR,d)
{
u+=0.001;
}


DEFINE_ADJUST(UDM,d)
{
Thread *t;
cell_t c;



MW_MIX=MW_H2*C_YI(c,t,0)+MW_O2*C_YI(c,t,1)+MW_CO2* C_YI(c,t,2)+MW_H2O*C_YI(c,t,3)+MW_N2*C_YI(c,t,4);
X_H2=C_YI(c,t,0)*MW_H2/MW_MIX;
X_O2=C_YI(c,t,1)*MW_O2/MW_MIX;
X_CO2=C_YI(c,t,2)*MW_CO2/MW_MIX;
X_H2O=C_YI(c,t,3)*MW_H2O/MW_MIX;
X_N2=C_YI(c,t,4)*MW_N2/MW_MIX;


Z_A=ACT_AREA_A*REF_EXCH_CURR_A*(pow((X_H2),0.25));

ZZ_A=exp((ALPHA_A*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

ZZZ_A=exp(-(ALPHA_C*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

RXN_RATE_A=Z_A*(ZZ_A-ZZZ_A);

C_UDMI(c,t,0)=RXN_RATE_A;



Z_C=ACT_AREA_C*REF_EXCH_CURR_C*pow(X_O2,0.375)*pow (X_CO2,(-1.25));

ZZ_C=exp((ALPHA_A*FARADAY*(-(C_UDSI(c,t,0)-C_UDSI(c,t,1)-REV_POT)))/(UNI_GAS_CONS*C_T(c,t)));

ZZZ_C=exp(-(ALPHA_C*FARADAY*(-(C_UDSI(c,t,0)-C_UDSI(c,t,1)-REV_POT)))/(UNI_GAS_CONS*C_T(c,t)));

RXN_RATE_C=Z_C*(ZZ_C-ZZZ_C);

C_UDMI(c,t,1)=RXN_RATE_C;

}

aleisia June 23, 2011 18:53

Hi, have you figured out the way to eliminate the
"warning C4700: uninitialized local variable 't' used
warning C4700: uninitialized local variable 'c' used"?

I have the same problem in mu UDF, can you please share your experience with me?

Thanks!
Quote:

Originally Posted by MASOUD (Post 276080)
Hi,
I get the following error:

warning C4700: uninitialized local variable 't' used
warning C4700: uninitialized local variable 'c' used

When I compile the UDF (for line 65)

What could be the reason?

Here is the code:

***************************

#include "udf.h"
#include "sg.h"

/* Define which user-defined scalars to use. */
enum
{
E_CHARGE_UDS,
C_CHARGE_UDS,
N_REQUIRED_UDS
};

static real ACT_AREA_A=270;
static real ACT_AREA_C=300;
static real REF_EXCH_CURR_A=2.1;
static real REF_EXCH_CURR_C=0.40;
static real REV_POT=1.02;
static real MW_H2=0.032;
static real MW_H2O=0.032;
static real MW_O2=0.032;
static real MW_CO2=0.044;
static real MW_N2=0.032;
static real MW_MIX;
static real X_H2;
static real X_H2O;
static real X_O2;
static real X_CO2;
static real X_N2;
static real ALPHA_A=1.5;
static real ALPHA_C=0.5;
static real NO_ELEC=2;
static real FARADAY=96485;
static real UNI_GAS_CONS=8.314;
static real STOCH_H2=-1;
static real STOCH_H2O=1;
static real STOCH_O2=-0.5;
static real STOCH_CO2_A=1;
static real STOCH_CO2_C=-1;
static real RXN_RATE_A;
static real RXN_RATE_C;
static real Z_A;
static real ZZ_A;
static real ZZZ_A;
static real Z_C;
static real ZZ_C;
static real ZZZ_C;
static real source;
static real u=0.0;
static real domain_ID=30;



DEFINE_ADJUST(SUR,d)
{
u+=0.001;
}


DEFINE_ADJUST(UDM,d)
{
Thread *t;
cell_t c;



MW_MIX=MW_H2*C_YI(c,t,0)+MW_O2*C_YI(c,t,1)+MW_CO2* C_YI(c,t,2)+MW_H2O*C_YI(c,t,3)+MW_N2*C_YI(c,t,4);
X_H2=C_YI(c,t,0)*MW_H2/MW_MIX;
X_O2=C_YI(c,t,1)*MW_O2/MW_MIX;
X_CO2=C_YI(c,t,2)*MW_CO2/MW_MIX;
X_H2O=C_YI(c,t,3)*MW_H2O/MW_MIX;
X_N2=C_YI(c,t,4)*MW_N2/MW_MIX;


Z_A=ACT_AREA_A*REF_EXCH_CURR_A*(pow((X_H2),0.25));

ZZ_A=exp((ALPHA_A*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

ZZZ_A=exp(-(ALPHA_C*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

RXN_RATE_A=Z_A*(ZZ_A-ZZZ_A);

C_UDMI(c,t,0)=RXN_RATE_A;



Z_C=ACT_AREA_C*REF_EXCH_CURR_C*pow(X_O2,0.375)*pow (X_CO2,(-1.25));

ZZ_C=exp((ALPHA_A*FARADAY*(-(C_UDSI(c,t,0)-C_UDSI(c,t,1)-REV_POT)))/(UNI_GAS_CONS*C_T(c,t)));

ZZZ_C=exp(-(ALPHA_C*FARADAY*(-(C_UDSI(c,t,0)-C_UDSI(c,t,1)-REV_POT)))/(UNI_GAS_CONS*C_T(c,t)));

RXN_RATE_C=Z_C*(ZZ_C-ZZZ_C);

C_UDMI(c,t,1)=RXN_RATE_C;

}


MASOUD June 24, 2011 01:59

Yes, I had not included the looping macro.

Here is the corrected version of the above UDF with some changes:
====================



DEFINE_ADJUST(CUR_DEN_A,d)
{
cell_t c;
Thread *t= Lookup_Thread(d,ID_A);

double CURR_D_A;
double Z_A;
double ZZ_A;
double ZZZ_A;
double OV_P_A;

double MW_MIX_A;
double X_H2;
double X_H2O;
double X_CO2_A;

if (FLUID_THREAD_P(t))
begin_c_loop(c,t)
{

/*MW_MIX=(C_R(c,t)*UNI_GAS_CONS*C_T(c,t))/C_P(c,t);*/

MW_MIX_A=1/((C_YI(c,t,0)/MW_H2)+(C_YI(c,t,2)/MW_CO2)+(C_YI(c,t,3)/MW_H2O)
);


X_H2=C_YI(c,t,0)*MW_MIX_A/MW_H2;
X_CO2_A=C_YI(c,t,2)*MW_MIX_A/MW_CO2;
X_H2O=1-(X_CO2_A+X_H2);

Z_A=ACT_AREA_A*REF_EXCH_CURR_A*(pow((X_H2),0.25))* (pow((X_H2O),0.25))*(pow((X_CO2_A),0.25));
OV_P_A=C_UDSI(c,t,0)-C_UDSI(c,t,1);
ZZ_A=exp(ALPHA_AA*FARADAY*OV_P_A/(UNI_GAS_CONS*C_T(c,t)));
ZZZ_A=exp(-ALPHA_CA*FARADAY*OV_P_A/(UNI_GAS_CONS*C_T(c,t)));
CURR_D_A=Z_A*(ZZ_A-ZZZ_A);

C_UDMI(c,t,13)=OV_P_A;

C_UDMI(c,t,14)=Z_A;
C_UDMI(c,t,15)=ZZ_A;
C_UDMI(c,t,16)=ZZZ_A;


C_UDMI(c,t,0)=u*CURR_D_A;

}
end_c_loop(c,t)
}

Kanarya November 26, 2012 06:24

hi,
I have the same error with following code:
#include "udf.h"
DEFINE_EXECUTE_AT_END(measure_mass_flow)
{
float mass_flow, abs_v;
Domain *d;
Thread *t;
cell_t c;
mass_flow=0.;
/* Get the domain 1 (Mixture) */
d = Get_Domain(1);
abs_v=sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t));
thread_loop_c(t, d)
{
if( THREAD_ID(t) == 5 )
{
begin_c_loop(c, t)
{

mass_flow+=C_R(c,t)*abs_v ;
mass_flow=C_UDMI(c,t,0);
}
end_c_loop(c,t)
}

printf("mass_flow in outlet:%f/n",mass_flow);
}
}
can you help me?
thanks in advance!


All times are GMT -4. The time now is 03:53.