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

UDF for 2D gaussian distribution

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 29, 2010, 15:07
Question UDF for 2D gaussian distribution
  #1
New Member
 
sunitha
Join Date: Jun 2010
Posts: 17
Rep Power: 15
slek is on a distinguished road
Hai,
I have written a code but im having problems with how to assign the absolute value.Can anyone tell me whats de mistake in my code? thank you

# include "udf.h"
# define v 10
# define delt .05
# define delx .5
# define I0 2*10000000
# define n 39
DEFINE_PROFILE(g_profile,t,i)
{
int x[ND_ND];
int j,k;
double xreg;
double xl[39],I[39],y[39];
face_t f;
/*xl= (v*delt)+(delx/2);*/
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y[0]=x[1];
for(j=1;j<=n;j++)
{
y[j]=(j-1)*delt;
/*k=j;*/
xl[j]=(j-1)*v*delt;
printf("%f\n",&xl[j]);
/*xreg=(y[j]-xl[j]);*/
double fabs(double (y[j]-xl[j]));
{
if ((y[j]-xl[j]) < 0)
xreg = -1*(y[j]-xl[j]);
else
xreg = (y[j]-xl[j]);
}
if(xreg<delx)
{
I[j]=I0*exp((-2*((xreg)*(xreg)))/(delx*delx));
}
else
{
I[j]=0;
}
printf( "%f\n", &I[j]);
}
}
end_f_loop(f,t)
}

when i try to interpret fluent is showing parse error at line where the fabs function is there...
slek is offline   Reply With Quote

Old   June 29, 2010, 15:12
Default
  #2
Senior Member
 
Join Date: Nov 2009
Posts: 411
Rep Power: 19
DoHander is on a distinguished road
You've missed an :

#include <math.h>
DoHander is offline   Reply With Quote

Old   June 29, 2010, 15:16
Question
  #3
New Member
 
sunitha
Join Date: Jun 2010
Posts: 17
Rep Power: 15
slek is on a distinguished road
Hai,
I have included #include "math.h" but this is still showing parse error at line 27..what should i change?
slek is offline   Reply With Quote

Old   June 29, 2010, 16:52
Unhappy please solve my problem in udf
  #4
New Member
 
sunitha
Join Date: Jun 2010
Posts: 17
Rep Power: 15
slek is on a distinguished road
when i am tring to compile i am getting this error....


Deleted old libudf\ntx86\2ddp\libudf.dll
1 file(s) copied.
1 file(s) copied.
(system "copy \speedy\sdsmtshare\NetApps\FLUENT.INC\fluent6.3.26 \src\makefile_nt.udf libudf\ntx86\2ddp\makefile")
1 file(s) copied.
(chdir "libudf")()
(chdir "ntx86\2ddp")()
'nmake' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.

what could be the mistake? please let me know
slek is offline   Reply With Quote

Old   June 29, 2010, 19:43
Default
  #5
Senior Member
 
Join Date: Nov 2009
Posts: 411
Rep Power: 19
DoHander is on a distinguished road
NOT #include "math.h" BUT

#include <math.h>

Also you should first try to interpret the UDF in order to be sure the C code is fine and after that you can try to compile the code .

Again use <> and not "" for math.h.

Do
DoHander is offline   Reply With Quote

Old   June 29, 2010, 21:13
Default
  #6
Senior Member
 
Join Date: Nov 2009
Posts: 411
Rep Power: 19
DoHander is on a distinguished road
Anyway it seems that you have a logical error in your code the line that gives you an error the one with fabs has no role in this code . If you erase (or comment) this line and leave the code as it is it will work.

Do

===============================

# include "udf.h"
# define v 10
# define delt .05
# define delx .5
# define I0 2*10000000
# define n 39
DEFINE_PROFILE(g_profile,t,i)
{
int x[ND_ND];
int j,k;
double xreg;
double xl[39],I[39],y[39];
face_t f;
/*xl= (v*delt)+(delx/2);*/
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y[0]=x[1];
for(j=1;j<=n;j++)
{
y[j]=(j-1)*delt;
/*k=j;*/
xl[j]=(j-1)*v*delt;
printf("%f\n",&xl[j]);
/*xreg=(y[j]-xl[j]);*/
/*double fabs(double (y[j]-xl[j]));*/
{
if ((y[j]-xl[j]) < 0)
xreg = -1*(y[j]-xl[j]);
else
xreg = (y[j]-xl[j]);
}
if(xreg<delx)
{
I[j]=I0*exp((-2*((xreg)*(xreg)))/(delx*delx));
}
else
{
I[j]=0;
}
printf( "%f\n", &I[j]);
}
}
end_f_loop(f,t)
}
DoHander is offline   Reply With Quote

Old   June 30, 2010, 14:17
Default
  #7
New Member
 
sunitha
Join Date: Jun 2010
Posts: 17
Rep Power: 15
slek is on a distinguished road
Thank you.
I have tried like that and its getting interpreted its not showing any errors but when im trying to compile i am getting error like


1 file(s) copied.
1 file(s) copied.
(system "copy \speedy\sdsmtshare\NetApps\FLUENT.INC\fluent6.3.26 \src\makefile_nt.udf libudf\ntx86\2ddp\makefile")
1 file(s) copied.
(chdir "libudf")()
(chdir "ntx86\2ddp")()
'nmake' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.
Done.
"f:/projects/cml/lekkala_sunitha/project spring10/newmodelapril2010"
Opening library "libudf"...
Error: open_udf_library: The system cannot find the file specified.

Can you tell me why is this coming and could you plss suggest something about it??

Thank you
slek is offline   Reply With Quote

Old   June 30, 2010, 15:54
Default
  #8
New Member
 
Luk
Join Date: Jun 2009
Posts: 24
Rep Power: 16
Geisel is on a distinguished road
Do you have external compiler e.g. Microsoft Visual?
__________________
*******************************
Geisel is offline   Reply With Quote

Old   June 30, 2010, 16:28
Default
  #9
New Member
 
sunitha
Join Date: Jun 2010
Posts: 17
Rep Power: 15
slek is on a distinguished road
yes i do have microsoft visual studio.NET and im trying to open fluent through the command prompt..but still same error is coming up..
slek is offline   Reply With Quote

Old   June 30, 2010, 17:30
Default
  #10
New Member
 
Luk
Join Date: Jun 2009
Posts: 24
Rep Power: 16
Geisel is on a distinguished road
It compiles on my system, in both interpreted and compiled way. But after compiled could not find libudf library.

Try to reinstal visual studio, on wikicfd is a nice description how to do it. http://www.cfd-online.com/Wiki/Fluen...Fload_a_UDF.3F
__________________
*******************************
Geisel is offline   Reply With Quote

Old   June 30, 2010, 18:56
Smile
  #11
New Member
 
sunitha
Join Date: Jun 2010
Posts: 17
Rep Power: 15
slek is on a distinguished road
Quote:
Originally Posted by Geisel View Post
It compiles on my system, in both interpreted and compiled way. But after compiled could not find libudf library.

Try to reinstal visual studio, on wikicfd is a nice description how to do it. http://www.cfd-online.com/Wiki/Fluen...Fload_a_UDF.3F
its working for me... i opened fluent through visual studio command prompt.. thank you so much for your help
slek is offline   Reply With Quote

Old   July 7, 2010, 16:43
Default regarding results need help
  #12
New Member
 
sunitha
Join Date: Jun 2010
Posts: 17
Rep Power: 15
slek is on a distinguished road
Quote:
Originally Posted by slek View Post
its working for me... i opened fluent through visual studio command prompt.. thank you so much for your help

Hai,

i have run de code but not getting de output correctly as i have written in code.donno y?? below is my code
# include "udf.h"
# define v 10 /* constants */
# define delt .1
# define delx .5
# define I0 2*10000000
# define n 10
DEFINE_PROFILE(g_profile,t,i)
{
int x[ND_ND];
int j;
double xreg;
double xl[1],I[1],y[1];
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
xl[1]=x[0];
y[1]=x[0];
for(j=1;j<=n;j++)
{
y[j]=(j-1)*delt;
xl[j]=(j-1)*v*delt;
{
if ((y[j]-xl[j]) < 0)
xreg = -1*(y[j]-xl[j]);
else
xreg = (y[j]-xl[j]);
}
if(xreg<=delx)
I[j]=I0*exp((-2*((xreg)*(xreg)))/(delx*delx));
else
I[j]=0;
/*F_PROFILE(f,t,i)= I[j];*/
printf( "%i\n", j);
printf( "%f\n", I[j]);
}
}
end_f_loop(f,t)
}

thanks

please suggest me what could be wrong??
slek is offline   Reply With Quote

Old   January 14, 2020, 15:33
Default
  #13
New Member
 
Join Date: Jan 2020
Posts: 6
Rep Power: 6
kawkab is on a distinguished road
Did you find out what's wrong with it? I'm having the same problem now
kawkab is offline   Reply With Quote

Old   January 14, 2020, 21:52
Default
  #14
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
# include "udf.h"
# define v 10 /* constants */
# define delt .1
# define delx .5
# define I0 2*10000000
# define n 10
DEFINE_PROFILE(g_profile,t,i)
{
int x[ND_ND];
int j;
double xreg;
double xl[n],I[n],y[n];
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
xl[0]=x[0];
y[0]=x[0];
for(j=0;j<n;j++)
{
y[j]=(j)*delt;
xl[j]=(j)*v*delt;
{
if ((y[j]-xl[j]) < 0)
xreg = -1*(y[j]-xl[j]);
else
xreg = (y[j]-xl[j]);
}
if(xreg<=delx)
I[j]=I0*exp((-2*((xreg)*(xreg)))/(delx*delx));
else
I[j]=0;
/*F_PROFILE(f,t,i)= I[j];*/
Message0( "%i\n", j);
Message0( "%f\n", I[j]);
}
}
end_f_loop(f,t)
}
kawkab likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply


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
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
Customize Heat Flux Distribution Using UDF Ken Adams FLUENT 0 May 25, 2007 15:25
udf for drop size distribution Rashmi FLUENT 6 December 11, 2005 23:09
Udf about the distribution of the diameter as FLUENT 7 April 3, 2005 17:36
Problem in UDF about particle size distribution fpingqian FLUENT 0 February 25, 2005 01:48


All times are GMT -4. The time now is 13:07.