# UDF for body force in DPM

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 5, 2011, 05:16 UDF for body force in DPM #1 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 Sponsored Links 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?

 March 5, 2011, 08:58 #2 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 16 first you should specify the cell index that contains particle, then you can use: du=C_U(c,t)-C_U_M1(c,t)

 March 5, 2011, 09:15 #3 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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?

March 5, 2011, 09:29
#4
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 16
Quote:
 Originally Posted by elah599 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.

 March 5, 2011, 12:51 #5 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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

March 5, 2011, 16:07
#6
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 16
Quote:
 Originally Posted by elah599 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

 March 8, 2011, 05:07 #7 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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; }

 March 8, 2011, 10:35 #8 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 16 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.

 March 9, 2011, 08:00 #9 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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?

 March 9, 2011, 09:00 #10 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 16 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

 March 9, 2011, 09:36 #11 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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

 March 9, 2011, 12:59 #12 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 16 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.

 March 12, 2011, 05:31 #13 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 Hi amir, Thanks for your help, when I interpret your code there is a error: line 5: P_CELL_THREAD: undeclared variable

 March 12, 2011, 11:17 #14 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 16 Hi Iman, I checked that as a compiled one, it didn't have any error! compile your UDF instead.

 March 14, 2011, 10:28 #15 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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?

 March 14, 2011, 11:40 #16 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 16 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.

 March 15, 2011, 09:15 #17 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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.

 March 15, 2011, 09:41 #18 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 16 Hi, you don't have linked FLUENT with VC++. for more information refer to: http://www.cfd-online.com/Forums/flu...iling-udf.html

 March 15, 2011, 15:49 #19 Member   iman vasefi Join Date: Aug 2010 Posts: 39 Rep Power: 8 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.

March 16, 2011, 05:12
#20
Member

iman vasefi
Join Date: Aug 2010
Posts: 39
Rep Power: 8
Quote:
 Originally Posted by elah599 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.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post teymourj Fluent UDF and Scheme Programming 9 August 18, 2016 15:33 enry Fluent UDF and Scheme Programming 10 March 23, 2011 11:48 dm2747 FLUENT 0 April 17, 2009 01:29 Prashanth FLUENT 3 April 3, 2009 17:45 hedonists FLUENT 0 March 12, 2003 22:10