CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

An odd ERROR

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

Like Tree3Likes
  • 1 Post By Galileo
  • 1 Post By Galileo
  • 1 Post By Galileo

Reply
 
LinkBack Thread Tools Display Modes
Old   April 15, 2014, 08:27
Post An odd ERROR
  #1
New Member
 
mdakbari's Avatar
 
m.akbari
Join Date: Apr 2014
Posts: 14
Rep Power: 3
mdakbari is on a distinguished road
hi friends, i have a problem in interpreting my .c file
when i interpret it by fluent, an error appears that says:

label "temp" not found (pc=61)

so what does it mean?
i really need ur help dudes.
my code is below:

/************************************************** *******************
UDF

all calculations for al2o3 nanoparticles
************************************************** ********************/
#include "udf.h"
#define FI 0.01
#define RHO_np 3600
#define SI_1 0.9830
#define SI_2 12.959
DEFINE_PROPERTY(cell_conductivity,cell,thread)
{
real ktc;
real temp = C_T(cell,thread);
ktc = (-8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)-0.5981);
return ktc;
}

DEFINE_PROPERTY(cell_density,cell,thread)
{
real rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
real temp = C_T(cell,thread);
real rho = (FI*RHO_np)+((1-FI)*rho_w);
return rho;
}

DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
real mu_w,mu;
real temp = C_T(cell,thread);
mu_w = (2.591*(pow(10,-5))*(pow(10,(238.3/(temp-143.2)))));
mu = (SI_1*exp (SI_2*FI)*mu_w);
return mu;
}
mdakbari is offline   Reply With Quote

Old   April 15, 2014, 09:09
Default
  #2
Member
 
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 7
Galileo is on a distinguished road
Hi,
Try this,
declare all variables before assigning values to them, for example,
real x, y, z;
x=4.;
y=10.;
z=0.3;


Instead of
real x= 4.;
real y=10.;
real z=0.3;


NB:
Your error is in this line, you used temp before declaring it:
real rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
mdakbari likes this.
Galileo is offline   Reply With Quote

Old   April 16, 2014, 02:22
Post my error
  #3
New Member
 
mdakbari's Avatar
 
m.akbari
Join Date: Apr 2014
Posts: 14
Rep Power: 3
mdakbari is on a distinguished road
Quote:
Originally Posted by Galileo View Post
Hi,
Try this,
declare all variables before assigning values to them, for example,
real x, y, z;
x=4.;
y=10.;
z=0.3;


Instead of
real x= 4.;
real y=10.;
real z=0.3;


NB:
Your error is in this line, you used temp before declaring it:
real rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));

hello my friend, thank u for ur help. i did that correction and it did work. but unfortunately when i run the calculations, the calculations do not run and there would be an error, so i ask u to look at my full and entire code which i just completed it, and give me ur opinion with regard to the exact error which appeared in fluent:


/************************************************** *******************
Fluent UDF
Author: Milan
all calculations for al2o3 nanoparticles
************************************************** ********************/
#include "udf.h"
#define FI 0.01
#define RHO_np 3600
#define SI_1 0.9830
#define SI_2 12.959
#define KTC_np 36
#define TI 5*(pow(10,4))
#define BETA_1 8.4407
#define BETA_2 -1.07304
#define CP_w 4200
#define KA 1.383*(pow(10,-23))
#define SIi_1 2.8217*(pow(10,-2))
#define SIi_2 3.917*(pow(10,-3))
#define SIi_3 -3.0669*(pow(10,-2))
#define SIi_4 -3.91123*(pow(10,-3))
#define T_0 298.15
#define D_np 59*(pow(10,-9))
#define CP_np 765
DEFINE_PROPERTY(cell_conductivity,cell,thread)
{
real temp = C_T(cell,thread);
real ktc,ktc_w;
real f = ((SIi_1*FI+SIi_2*temp)/T_0)+(SIi_3*FI+SIi_4);
real beta = BETA_1*(pow(100*FI,BETA_2));
real rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
ktc_w = (-8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)-0.5981);
ktc = ((KTC_np+(2*ktc_w)-2*(ktc_w-KTC_np)*FI)/(KTC_np+(2*ktc_w)+(ktc_w-KTC_np)*FI))+(TI*beta*FI*rho_w*CP_w*(pow(((KA*temp )/(RHO_np*D_np)),0.5))*f);
return ktc;
}

DEFINE_PROPERTY(cell_density,cell,thread)
{
real temp = C_T(cell,thread);
real rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
real rho = (FI*RHO_np)+((1-FI)*rho_w);
return rho;
}

DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
real temp = C_T(cell,thread);
real mu,mu_w;
mu_w = (2.591*(pow(10,-5))*(pow(10,(238.3/(temp-143.2)))));
mu = (SI_1*exp(SI_2*FI)*mu_w);
return mu;
}

DEFINE_PROPERTY(cell_specificheat,cell,thread)
{
real temp = C_T(cell,thread);
real cp,rho_w,rho;
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
cp=(FI*RHO_np*CP_np)+(((1-FI)*rho_w*CP_w)/rho);
return cp;
}



and the error appeared when running the calculations:

Warning: D:\\mansys\\c\\c bank\\nanofluid\\nano---combined.c: line 26: Warning: D:\\mansys\\c\\c bank\\nanofluid\\nano---combined.c: line 38: Warning: D:\\mansys\\c\\c bank\\nanofluid\\nano---combined.c: line 46: Warning: D:\\mansys\\c\\c bank\\nanoflui
\\nano---combined.c: line 55:
Error: received a fatal signal (Segmentation fault).

Error: received a fatal signal (Segmentation fault).
Error Object: #f

Last edited by mdakbari; April 16, 2014 at 09:21.
mdakbari is offline   Reply With Quote

Old   April 16, 2014, 11:14
Default
  #4
Member
 
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 7
Galileo is on a distinguished road
NB: I did not run the code, but I think it should work now. You need to check through the edits shown in red to make sure the variables are spelt correctly. Please let me know if the errors persist.
Try and compile instead of interpreting before replying just in case it gives an error.


/************************************************** *******************
Fluent UDF
Author: Milan
all calculations for al2o3 nanoparticles
************************************************** ********************/
#include "udf.h"
#define FI 0.01
#define RHO_np 3600
#define SI_1 0.9830
#define SI_2 12.959
#define KTC_np 36
#define TI 5.E4
#define BETA_1 8.4407
#define BETA_2 -1.07304
#define CP_w 4200
#define KA 1.383E-23
#define SIi_1 2.8217E-2
#define SIi_2 3.917E-3
#define SIi_3 -3.0669E-2
#define SIi_4 -3.91123E-3
#define T_0 298.15
#define D_np 59.E-9
#define CP_np 765
DEFINE_PROPERTY(cell_conductivity,cell,thread)
{/*Declare variables first before using them */
real temp, ktc,ktc_w, f,beta,rho_w;
real dummy ;
/*************************/

temp = C_T(cell,thread);
f = ((SIi_1*FI+SIi_2*temp)/T_0)+(SIi_3*FI+SIi_4);
beta = BETA_1*(pow(100*FI,BETA_2));
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
ktc_w = (-8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)-0.5981);

/*Avoid too long equations,
split the equation into small parts but make sure it does not cause a bug*/
ktc =(TI*beta*FI*rho_w*CP_w*(pow(((KA*temp )/(RHO_np*D_np)),0.5))*f);
dummy =(KTC_np+(2*ktc_w)+(ktc_w-KTC_np)*FI);
ktc = ((KTC_np+(2*ktc_w)-2*(ktc_w-KTC_np)*FI)/dummy)+ ktc;

return ktc;
}

DEFINE_PROPERTY(cell_density,cell,thread)
{/*Declare variables first before using them */
real temp, rho, rho_w;
/************************/

temp = C_T(cell,thread);
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
return rho;
}

DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
real temp,mu,mu_w;
/******************/

temp = C_T(cell,thread);
mu_w = (2.591*(pow(10,-5))*(pow(10,(238.3/(temp-143.2)))));
mu = (SI_1*exp(SI_2*FI)*mu_w);
return mu;
}

DEFINE_PROPERTY(cell_specificheat,cell,thread)
{real temp, cp,rho_w,rho;
/******************/

temp = C_T(cell,thread);
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
cp=(FI*RHO_np*CP_np)+(((1-FI)*rho_w*CP_w)/rho);
return cp;
}
mdakbari likes this.
Galileo is offline   Reply With Quote

Old   April 17, 2014, 08:01
Default found the bug
  #5
New Member
 
mdakbari's Avatar
 
m.akbari
Join Date: Apr 2014
Posts: 14
Rep Power: 3
mdakbari is on a distinguished road
Quote:
Originally Posted by Galileo View Post
NB: I did not run the code, but I think it should work now. You need to check through the edits shown in red to make sure the variables are spelt correctly. Please let me know if the errors persist.
Try and compile instead of interpreting before replying just in case it gives an error.


/************************************************** *******************
Fluent UDF
Author: Milan
all calculations for al2o3 nanoparticles
************************************************** ********************/
#include "udf.h"
#define FI 0.01
#define RHO_np 3600
#define SI_1 0.9830
#define SI_2 12.959
#define KTC_np 36
#define TI 5.E4
#define BETA_1 8.4407
#define BETA_2 -1.07304
#define CP_w 4200
#define KA 1.383E-23
#define SIi_1 2.8217E-2
#define SIi_2 3.917E-3
#define SIi_3 -3.0669E-2
#define SIi_4 -3.91123E-3
#define T_0 298.15
#define D_np 59.E-9
#define CP_np 765
DEFINE_PROPERTY(cell_conductivity,cell,thread)
{/*Declare variables first before using them */
real temp, ktc,ktc_w, f,beta,rho_w;
real dummy ;
/*************************/

temp = C_T(cell,thread);
f = ((SIi_1*FI+SIi_2*temp)/T_0)+(SIi_3*FI+SIi_4);
beta = BETA_1*(pow(100*FI,BETA_2));
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
ktc_w = (-8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)-0.5981);

/*Avoid too long equations,
split the equation into small parts but make sure it does not cause a bug*/
ktc =(TI*beta*FI*rho_w*CP_w*(pow(((KA*temp )/(RHO_np*D_np)),0.5))*f);
dummy =(KTC_np+(2*ktc_w)+(ktc_w-KTC_np)*FI);
ktc = ((KTC_np+(2*ktc_w)-2*(ktc_w-KTC_np)*FI)/dummy)+ ktc;

return ktc;
}

DEFINE_PROPERTY(cell_density,cell,thread)
{/*Declare variables first before using them */
real temp, rho, rho_w;
/************************/

temp = C_T(cell,thread);
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
return rho;
}

DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
real temp,mu,mu_w;
/******************/

temp = C_T(cell,thread);
mu_w = (2.591*(pow(10,-5))*(pow(10,(238.3/(temp-143.2)))));
mu = (SI_1*exp(SI_2*FI)*mu_w);
return mu;
}

DEFINE_PROPERTY(cell_specificheat,cell,thread)
{real temp, cp,rho_w,rho;
/******************/

temp = C_T(cell,thread);
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
cp=(FI*RHO_np*CP_np)+(((1-FI)*rho_w*CP_w)/rho);
return cp;
}


hello my friend mr. galileo, i really appreciate ur help. ur so so kind.
i used the code that u have written but the errors appeared again. however finally found why it is happening, its the specific heat part . now i know the problem, its because of the way and the macro we must define specific heat with. so i modified the code. now no error would occur by compiling the code in fluent or by running the calcs.
but i'm not sure that my specific heat part is correct. whatever the modified code is below, i am really keen to have new comments.


/************************************************** *******************
Fluent UDF
Author: Milan
all calculations for al2o3 nanoparticles
************************************************** ********************/
#include "udf.h"
#define FI 0.01
#define RHO_np 3600
#define SI_1 0.9830
#define SI_2 12.959
#define KTC_np 36
#define TI 5.E4
#define BETA_1 8.4407
#define BETA_2 -1.07304
#define CP_w 4200
#define KA 1.383E-23
#define SIi_1 2.8217E-2
#define SIi_2 3.917E-3
#define SIi_3 -3.0669E-2
#define SIi_4 -3.91123E-3
#define T_0 298.15
#define D_np 59.E-9
#define CP_np 765
DEFINE_PROPERTY(cell_conductivity,cell,thread)
{
real ktc,ktc_w,temp,f,beta,rho_w;
temp = C_T(cell,thread);
f = ((SIi_1*FI+SIi_2*temp)/T_0)+(SIi_3*FI+SIi_4);
beta = BETA_1*(pow(100*FI,BETA_2));
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
ktc_w = (-8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)-0.5981);
ktc = ((KTC_np+(2*ktc_w)-2*(ktc_w-KTC_np)*FI)/(KTC_np+(2*ktc_w)+(ktc_w-KTC_np)*FI))+(TI*beta*FI*rho_w*CP_w*(pow(((KA*temp )/(RHO_np*D_np)),0.5))*f);
return ktc;
}

DEFINE_PROPERTY(cell_density,cell,thread)
{
real temp,rho_w,rho;
temp = C_T(cell,thread);
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
return rho;
}

DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
real mu,mu_w,temp;
temp = C_T(cell,thread);
mu_w = (2.591*(pow(10,-5))*(pow(10,(238.3/(temp-143.2)))));
mu = (SI_1*exp(SI_2*FI)*mu_w);
return mu;
}

DEFINE_SPECIFIC_HEAT(specificheat, T, Tref, h, yi)
{
real cp,rho_w,rho;
rho_w = (-3.570*(pow(10,-3))*(pow(T,2))+(1.88*T+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
cp = (FI*RHO_np*CP_np)+(((1-FI)*rho_w*CP_w)/rho);
return cp;
}
mdakbari is offline   Reply With Quote

Old   April 17, 2014, 11:29
Default
  #6
Member
 
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 7
Galileo is on a distinguished road
Are you compiling or interpreting the code? Good to hear the code now runs with no error. What else do you want to know? If the Cp is correct I suppose? That is not a UDF question in my own view. You will need to know how you formulated the equations, perhaps from a journal paper or a text book reference or a data fit. All you need to do is do the same equation in Excel and see if it is giving what you want it to give. If you are compiling the code, you can put CX_Message("Cp= %E \n", cp); before the return cp; line so that it will display the values used in the simulation.
mdakbari likes this.
Galileo is offline   Reply With Quote

Old   April 18, 2014, 02:22
Default
  #7
New Member
 
mdakbari's Avatar
 
m.akbari
Join Date: Apr 2014
Posts: 14
Rep Power: 3
mdakbari is on a distinguished road
Quote:
Originally Posted by Galileo View Post
Are you compiling or interpreting the code? Good to hear the code now runs with no error. What else do you want to know? If the Cp is correct I suppose? That is not a UDF question in my own view. You will need to know how you formulated the equations, perhaps from a journal paper or a text book reference or a data fit. All you need to do is do the same equation in Excel and see if it is giving what you want it to give. If you are compiling the code, you can put CX_Message("Cp= %E \n", cp); before the return cp; line so that it will display the values used in the simulation.

ok, thanks for ur help along making my code, i will update this page if the code was mistake and caused errors,
again thanks
mdakbari is offline   Reply With Quote

Reply

Tags
error, udf

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
blockMesh with double grading. spwater OpenFOAM Native Meshers: blockMesh 78 March 12, 2015 15:54
GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM 300 October 29, 2014 19:00
compile error in dynamicMesh and thermophysicalModels libraries NickG OpenFOAM Installation 2 August 30, 2013 07:42
POSDAT problem piotka STAR-CD 4 June 12, 2009 08:43
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


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