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

help udf error

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

Like Tree3Likes
  • 2 Post By pakk
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 26, 2014, 02:50
Default help udf error
  #1
Member
 
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 10
adi.ptb is on a distinguished road
hi guys, i have a problem compiling a udf ,i want to simulate a pulse tube refrigerator,in order to model the piston i used this udf :
#include "udf.h"
#include "dynamesh_tools.h"
DEFINE_CG_MOTION(oscillate,dt,vel,omega,time,dtime )
{
Thread *t;
face_t f; /* define the variables */

t = DT_THREAD(dt); /* get the thread pointer for which the motion is defined */

/* if (!Data_Valid_P())
/* return; /* check if the values of the variables are accessible before you compute the function */

begin_f_loop(f,t) /* loop over each face in the zone to create an array of data */
{
if (time <= 1)
vel[0] = -2* 3.14159 * 2 * 0.025 * cos (2 * 3.14159 * 2 * time); /* define the velocity of the moving zone---*/
else
vel[0] = 0;
}
end_f_loop(f,t)
}
i successfully compiled it,but when i tried to compile this udf for time dependent viscosity :
#include "udf.h"
DEFINE_PROPERTY(helium_viscosity,c,t)
{
real T = C_T(c,t);
return (0.412e-6)*(T**0.68014);
}

it wont compile,i even tried a udf from fluent udf manual:
#include "udf.h"
DEFINE_PROPERTY(cell_viscosity, cell, thread)
{
real mu_lam;
real T = C_T(cell, thread);
if (T > 288.)
mu_lam = 5.5e-3;
else if (T > 286.)
mu_lam = 143.2135 - 0.49725 * T;
else
mu_lam = 1.;
return mu_lam;
}
but it wont compile either,does anyone know what might be the problem?
please help
adi.ptb is offline   Reply With Quote

Old   September 26, 2014, 03:26
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24
pakk will become famous soon enough
Code:
T**0.68014
This is not c-code.
I guess you want
Code:
pow(T,0.68014)
pakk is offline   Reply With Quote

Old   September 26, 2014, 04:15
Default
  #3
Member
 
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 10
adi.ptb is on a distinguished road
thanks for your reply
i used your advice
#include "udf.h"
DEFINE_PROPERTY(helium_viscosity,c,t)
{
real T = C_T(c,t);
return (0.412e-6)*pow(T,0.68014);
}

but it gave me this error:

line 5: function returning float returns double.
adi.ptb is offline   Reply With Quote

Old   September 26, 2014, 04:45
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24
pakk will become famous soon enough
That is not an error, but a warning (small difference).

What it means: you are calculating in double precision, but the function that you defined now returns a result in single precision.
The compiler can change a number in single precision into a number in double precision, but it gives a warning because it might not have been what you intended.

In your case, this is no problem. (The number 0.412e-6 is probably not exactly 0.4120000000000e-6, so single precision for the viscosity is accurate enough.)

If you want to get rid of this warning, cast the result into a double yourself:

Code:
return (real)((0.412e-6)*pow(T,0.68014));
adi.ptb and tiancaidushen like this.
pakk is offline   Reply With Quote

Old   September 26, 2014, 05:55
Default
  #5
Member
 
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 10
adi.ptb is on a distinguished road
thanks a lot man, you are so right, now i have one more problem im able to interpret but it wont compile,what do you think about this?whats the problem?
this is a first udf that i compiled:Copied C:\Users\edi\Desktop\kos/C:\Users\edi\Desktop\kos\piston.c to libudf\src
Creating user_nt.udf file for 2ddp ...
(system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\2ddp")# Generating ud_io1.h
piston.c
# Generating udf_names.c because of makefile piston.obj
udf_names.c
udf_names.c(8) : warning C4113: 'void (*)()' differs in parameter lists from 'void (*)(void)'
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj piston.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library libudf.lib and object libudf.exp

Done.

but when i compile the second one nothing happend,
Copied C:\Users\edi\Desktop\kos/C:\Users\edi\Desktop\kos\New Text Document (2).c to libudf2\src
Copied C:\Users\edi\Desktop\kos/C:\Users\edi\Desktop\kos\piston.c to libudf2\src
Creating user_nt.udf file for 2ddp ...
(system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf2\win64\2ddp\makefile" ")
1 file(s) copied.
(chdir "libudf2")(chdir "win64\2ddp")
Done.
adi.ptb is offline   Reply With Quote

Old   September 26, 2014, 06:39
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24
pakk will become famous soon enough
It could be because you have spaces in your filename.
adi.ptb likes this.
pakk is offline   Reply With Quote

Old   September 26, 2014, 06:54
Default
  #7
Member
 
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 10
adi.ptb is on a distinguished road
you are right again,thank you so much man,thanks for your time
adi.ptb is offline   Reply With Quote

Old   October 3, 2014, 08:02
Default
  #8
Member
 
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 10
adi.ptb is on a distinguished road
hi,i'v got another problem :
#include "udf.h"
#define permeability 1.06e-10
#define resistance 76090
DEFINE_SOURCE(xmom_source,c,t,dS,eqn)
{
real x[ND_ND];
real source,a,b;
C_CENTROID(x,c,t);
a=(C_MU_L(c,t))/permeability;
b=0.5*resistance*C_R(c,t);
source=-((a*C_U(c,t))+(b*C_U(c,t)*fabs(C_U(c,t))));
dS=-(a+(2*b*fabs(C_U(c,t))));
return source;
}

when i try to interpret this udf it gives me line 12: invalid type conversion: double -> pointer to float.
,im new in c language,i cant undrestand the relation between float,double
help please
adi.ptb is offline   Reply With Quote

Old   October 3, 2014, 08:18
Default
  #9
Member
 
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 10
adi.ptb is on a distinguished road
I missed a dS[eqn],problem solved
adi.ptb is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] an error in Calculator's equation immortality ParaView 12 June 29, 2021 00:10
Undeclared Identifier Errof UDF SteveGoat Fluent UDF and Scheme Programming 7 October 15, 2014 07:11
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 06:42
Installation OF1.5-dev ttdtud OpenFOAM Installation 46 May 5, 2009 02:32
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


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