CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for body force in DPM (https://www.cfd-online.com/Forums/fluent-udf/85719-udf-body-force-dpm.html)

elah599 March 5, 2011 04:16

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

Amir March 5, 2011 07:58

first you should specify the cell index that contains particle, then you can use:
du=C_U(c,t)-C_U_M1(c,t)

elah599 March 5, 2011 08:15

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?

Amir March 5, 2011 08:29

Quote:

Originally Posted by elah599 (Post 298011)
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.

elah599 March 5, 2011 11:51

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:)

Amir March 5, 2011 15:07

Quote:

Originally Posted by elah599 (Post 298048)
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

elah599 March 8, 2011 04:07

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;
}

Amir March 8, 2011 09:35

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.

elah599 March 9, 2011 07:00

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?

Amir March 9, 2011 08:00

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

elah599 March 9, 2011 08:36

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

Amir March 9, 2011 11:59

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;
}


elah599 March 12, 2011 04:31

Hi amir,
Thanks for your help,
when I interpret your code there is a error:
line 5: P_CELL_THREAD: undeclared variable

Amir March 12, 2011 10:17

Hi Iman,
I checked that as a compiled one, it didn't have any error!
compile your UDF instead.

elah599 March 14, 2011 09:28

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?

Amir March 14, 2011 10:40

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.

elah599 March 15, 2011 08:15

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.

Amir March 15, 2011 08:41

Hi,
you don't have linked FLUENT with VC++.
for more information refer to:
http://www.cfd-online.com/Forums/flu...iling-udf.html

elah599 March 15, 2011 14:49

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 March 16, 2011 04:12

Quote:

Originally Posted by elah599 (Post 299548)
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.


All times are GMT -4. The time now is 08:38.