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 body force in DPM

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 5, 2011, 05:16
Default UDF for body force in DPM
  #1
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
I want to write a udf for body force that included (fluid velocity minus particle velocity) in x direction.[du/dt-dv/dt].
can anybody help me how to write du/dt?
elah599 is offline   Reply With Quote

Old   March 5, 2011, 08:58
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
first you should specify the cell index that contains particle, then you can use:
du=C_U(c,t)-C_U_M1(c,t)
Amir is offline   Reply With Quote

Old   March 5, 2011, 09:15
Default
  #3
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
this formula that you wrote,was just for du/dt? I read in help of fluent that the velocity of particle is shown with P_VEL(P)[i] that p is particle tracked and i represnts the coordinate. can you explain the terms that you wrote for that formula?
elah599 is offline   Reply With Quote

Old   March 5, 2011, 09:29
Default
  #4
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by elah599 View Post
can anybody help me how to write du/dt?
Hi iman,
first I think that you mean acceleration difference?am I right?
yes it's for the flow field part:
Code:
du/dt=(C_U(c,t)-C_U_M1(c,t))/CURRENT_TIMESTEP;
for particle part, you can implement user scalars for particles.
Amir is offline   Reply With Quote

Old   March 5, 2011, 12:51
Default
  #5
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
Hi Amir
thanks for your answering. yes, I mean relative acceleration between fluid and particle. I know that c_u(c,t) is u(cell,thread). but what is U_M1(c,t)? and I have to duplicate exactly "CURRENT_TIMESTEP" to my udf? I owe you lot!!thank you very much Amir
elah599 is offline   Reply With Quote

Old   March 5, 2011, 16:07
Default
  #6
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by elah599 View Post
Hi Amir
thanks for your answering. yes, I mean relative acceleration between fluid and particle. I know that c_u(c,t) is u(cell,thread). but what is U_M1(c,t)? and I have to duplicate exactly "CURRENT_TIMESTEP" to my udf? I owe you lot!!thank you very much Amir
Hi iman,
C_U_M1(c,t) : flow x-velocity in previous one time step
CURRENT_TIMESTEP : flow time step, you should use that to make your UDF independent of FLUENT changes in time step.

regards,

Amir
Amir is offline   Reply With Quote

Old   March 8, 2011, 05:07
Default
  #7
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
Hi amir
what is your comment aboat this udf?
# include "udf.h"
/* this udf insert a body force on particle in DPM model(A(du/dt-dv/dt)),A is a constant
that is known*/
DEFINE_DPM_BODY_FORCE(particle_body_fprce,cell,thr ead,p)
{
real bforce;
bforce= A((((C_U(cell,thread)-C_U_M1(cell,thread))/CURRENT_TIMESTEP)-((P_VEL(P)[0]-P_VEL_M1(P)[0])/CURRENT_TIMESTEP)));
return bforce;
}
elah599 is offline   Reply With Quote

Old   March 8, 2011, 10:35
Default
  #8
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi Iman,
I'm not sure that P_VEL_M1(p) exists in dpm.h library!
if it exist, that's true else you can implement user scalars for particles.
Amir is offline   Reply With Quote

Old   March 9, 2011, 08:00
Default
  #9
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
Hi amir
I implemented the udf and fluent took this error:
line 7: non-integer subscript expression: pointer to structure.
do you know what that means?
elah599 is offline   Reply With Quote

Old   March 9, 2011, 09:00
Default
  #10
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi,
it means that something is wrong in variables storage. i.e. you have stored a pointer parameter in a structure kind one.
in above UDF, use A*(...) syntax, also check the validity of P_VEL_M1 function.

regards,

Amir
Amir is offline   Reply With Quote

Old   March 9, 2011, 09:36
Default
  #11
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
my udf:
# include "udf.h"
/* this udf insert a body force on particle in DPM model(A(du/dt-dv/dt)),A is a constant
that is known*/
DEFINE_DPM_BODY_FORCE(particle_body_fprce,cell,thr ead,p)
{
real bforce;
bforce= (0.000000000000000000015)*((((C_U(cell,thread)-C_U_M1(cell,thread))/CURRENT_TIMESTEP)-((P_VEL(p)[0]-P_VEL_M1(p)[0])/CURRENT_TIMESTEP)));
return bforce;
}
how can I check the validity of P_VEL_M1?
regards
elah599 is offline   Reply With Quote

Old   March 9, 2011, 12:59
Default
  #12
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
you can check the validity a function by viewing it's header in src folder, I checked that and it didn't exist so you should use particle scalar array for your purpose as follow:
first you should specify the No. of scalar array in model->discrete phase->UDF tab->user variables -> increase to 1.
use this code. I didn't check that before:
Code:
# include "udf.h"
int n=0;
DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
Thread *t=P_CELL_THREAD(p);
cell_t c=P_CELL(p);
real bforce;
if(n==0) p->user[0]=0.0;
bforce= (1.5e-20)*((C_U(c,t)-C_U_M1(c,t))/CURRENT_TIMESTEP-(P_VEL(p)[0]-p->user[0])/CURRENT_TIMESTEP);
p->user[0]=P_VEL(p)[0];
n+=1;
return bforce;
}
czhao86 and Shalabh like this.
Amir is offline   Reply With Quote

Old   March 12, 2011, 05:31
Default
  #13
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
Hi amir,
Thanks for your help,
when I interpret your code there is a error:
line 5: P_CELL_THREAD: undeclared variable
elah599 is offline   Reply With Quote

Old   March 12, 2011, 11:17
Default
  #14
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi Iman,
I checked that as a compiled one, it didn't have any error!
compile your UDF instead.
Amir is offline   Reply With Quote

Old   March 14, 2011, 10:28
Default
  #15
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
Hi amir
I dont know but something is wrong.I couldent compile that code. I use fluent 12. does it affect? I think there shouldnt be many different between interpret & compile a udf?the version of visual studio is important?
elah599 is offline   Reply With Quote

Old   March 14, 2011, 11:40
Default
  #16
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi Iman,
you can't interpret this UDF because P_CELL and P_CELL_THREAD need FLUENT solution, so you should compile that.
for compiling you need visual C++ 2000 or newer(at least ver 6.) installed on your PC. and ensure that VC++ is linked with FLUENT and your file name doesn't have any space... .
I've checked that before as compiled one. if you post the errors during compilation, I may help you.
Amir is offline   Reply With Quote

Old   March 15, 2011, 09:15
Default
  #17
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
hi amir
when I compile udf the fluent gives the following error:
(chdir "libudf")()
(chdir "win64\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.
elah599 is offline   Reply With Quote

Old   March 15, 2011, 09:41
Default
  #18
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi,
you don't have linked FLUENT with VC++.
for more information refer to:
http://www.cfd-online.com/Forums/flu...iling-udf.html
Amir is offline   Reply With Quote

Old   March 15, 2011, 15:49
Default
  #19
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
hi amir
I have run fluent from VC command prompt, but again i recieved these errors,I'm totally confused!
(system "copy "C:\PROGRA~1\ANSYSI~1\v120\fluent"\fluent12.0.16\s rc\makefile_nt.udf libudf\win64\2ddp\makefile")
1 file(s) copied.
(chdir "libudf")()
(chdir "win64\2ddp")()
# Generating ud_io1.h
vmp.c
c:\program files\ansys inc\v120\fluent\fluent12.0.16\src\config.h(110) : error C2143: syntax error : missing '{' before ':'
c:\program files\ansys inc\v120\fluent\fluent12.0.16\src\config.h(110) : error C2059: syntax error : ':'
C:\PROGRA~1\ANSYSI~1\v120\fluent\fluent12.0.16\cor tex\src\dll.h(64) : error C2061: syntax error : identifier 'CX_DLL_GetProc'
C:\PROGRA~1\ANSYSI~1\v120\fluent\fluent12.0.16\cor tex\src\dll.h(64) : error C2059: syntax error : ';'
C:\PROGRA~1\ANSYSI~1\v120\fluent\fluent12.0.16\cor tex\src\dll.h(64) : error C2059: syntax error : 'type'
..\..\src\vmp.c(6) : warning C4047: 'initializing' : 'Thread *' differs in levels of indirection from 'int'
Done.
elah599 is offline   Reply With Quote

Old   March 16, 2011, 05:12
Default
  #20
Member
 
iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 16
elah599 is on a distinguished road
Quote:
Originally Posted by elah599 View Post
hi amir
I have run fluent from VC command prompt, but again i recieved these errors,I'm totally confused!
(system "copy "C:\PROGRA~1\ANSYSI~1\v120\fluent"\fluent12.0.16\s rc\makefile_nt.udf libudf\win64\2ddp\makefile")
1 file(s) copied.
(chdir "libudf")()
(chdir "win64\2ddp")()
# Generating ud_io1.h
vmp.c
c:\program files\ansys inc\v120\fluent\fluent12.0.16\src\config.h(110) : error C2143: syntax error : missing '{' before ':'
c:\program files\ansys inc\v120\fluent\fluent12.0.16\src\config.h(110) : error C2059: syntax error : ':'
C:\PROGRA~1\ANSYSI~1\v120\fluent\fluent12.0.16\cor tex\src\dll.h(64) : error C2061: syntax error : identifier 'CX_DLL_GetProc'
C:\PROGRA~1\ANSYSI~1\v120\fluent\fluent12.0.16\cor tex\src\dll.h(64) : error C2059: syntax error : ';'
C:\PROGRA~1\ANSYSI~1\v120\fluent\fluent12.0.16\cor tex\src\dll.h(64) : error C2059: syntax error : 'type'
..\..\src\vmp.c(6) : warning C4047: 'initializing' : 'Thread *' differs in levels of indirection from 'int'
Done.
there is no difference which udf I want to compile. every udf that I want to compile,fluent gives that error.
elah599 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 for defining a body force in Singel ROtating Reference Frame teymourj Fluent UDF and Scheme Programming 9 August 18, 2016 16:33
UDF force on a face enry Fluent UDF and Scheme Programming 10 March 23, 2011 11:48
DPM UDF particle position using the macro P_POS(p)[i] dm2747 FLUENT 0 April 17, 2009 02:29
DPM with UDF - Step-by-Step Procedure???? Prashanth FLUENT 3 April 3, 2009 18:45
DPM drag force UDF hedonists FLUENT 0 March 12, 2003 22:10


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