CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   C_UDMI Question in DPM (http://www.cfd-online.com/Forums/fluent/50711-c_udmi-question-dpm.html)

Prashanth February 27, 2009 18:25

C_UDMI Question in DPM
 
Hi all

I am using the DPM model to do particle tracking and I'm using a UDF to determine the mass and no. of particles that stick to the wall based on the particle normal and critical velocities. I am using a C_UDMI command to store the mass & no. of particles. My question is this: Can I just use the Define->User Defined->Memory option in the GUI to define 2 UDM locations, then use the Display->Contours option to display the UDM's so they get initialized, then compile my UDF and run my case? Is the above method right? Or do I have to use DEFINE_ON_DEMAND or some other macro to define the UDM's and set them to zero inside the UDF itself?

I have given my UDF below:

#include "udf.h" #include "dpm.h"

DEFINE_DPM_BC(deposition_bc,p,t,f,f_normal,dim) { /*#if !RP_HOST*/ Domain *d; cell_t c; d=Get_Domain(4); real Tavg,Ep,vcr; /*real norm_coeff=1.; real tang_coeff=1.;*/ real vn=0.; real R=287.; real normal[3]; int i,idim=dim; real x[ND_ND];

for (i=0.; i<idim; i++)

normal[i] = f_normal[i];

if(p->type==DPM_TYPE_INERT)

{

/*computing normal velocity*/

for(i=0.;i<idim;i++)

vn += p->state.V[i]*normal[i];

/*computing critical velocity*/

Tavg = (F_T(f,t)+P_T(p))/2.;

Ep = (3.*(pow(10.,20.)))*exp(-0.02365*Tavg);

vcr = pow(((2.*Ep)/P_DIAM(p)),(10./7.));

/*particle continues its path - no sticking*/

if (vn > vcr)

{

return PATH_ACTIVE;

}

/*particle sticks*/

else

{

thread_loop_c(t,d)

{

begin_c_loop(c,t)

{

C_UDMI(c,t,0) += P_MASS(p); /*mass of particles deposited*/

}

end_c_loop(c,t)

}

return PATH_ABORT;

}

}

/*#endif*/ }


giovanni franchello February 28, 2009 19:55

Re: C_UDMI Question in DPM
 
Hi Prashanth

You have to 1) compile your macro and load 2) run the case. At the beginning the UDMI values should be zero. However, to be sure, you can include a macro DEFINE_INIT (or DEFINE_ON_DEMAND) where you initialize 3) In your macro is not necessary to do the loop over all the cells: in this way the value of one particles is used to update all the domain, obtaining the same value in all the cells ! If you include the following: cell_t c = RP_CELL(&p->cCell); Thread *tcell = RP_THREAD(&p->cCell); you obtain the pointers to the cell where the particle is. Note that t in your DEFINE_DPM_BC is a face thread, not a cell Thread. Your UDMI should be updated as follows C_UDMI(c,tcell,0) += P_MASS(p); /*mass of particles */

If you whant the mass of the entire parcel, include C_UDMI(c,tcell,0) += P_MASS(p)*P_N(p); /*mass of particles */ Ciao Gian


Prashanth March 1, 2009 04:32

Re: C_UDMI Question in DPM
 
Hi Gian

Thanks a bunch for your reply. I have to get this UDF working within the next 4 days for a Thesis meeting with sponsors and your reply has really raised my hopes of not turning up at the meeting empty-handed. I am now able to run my UDF with a group injection but the UDM's still show zero after the particle tracking is done. I do think I'm closer to getting this working. It would be very helpful if you can take a look at the changes I have made and see if I'm missing something.

I'm particularly concerned about the domain ID in my DPM_BC and DEFINE_ON_DEMAND macros. My fluid zone ID is 1 and the ID for the wall on which the DPM_BC is applied is 4. When I initialize my UDM's using the DEFINE_ON_DEMAND, am I doing it right?

I have given my code below.

#include "udf.h"

#include "dpm.h"

#define NUM_UDM 2

static int udm_offset = UDM_UNRESERVED;

DEFINE_EXECUTE_ON_LOADING(on_loading,libname) { if (udm_offset == UDM_UNRESERVED)

udm_offset = Reserve_User_Memory_Vars(NUM_UDM);

if (udm_offset == UDM_UNRESERVED)

Message("\nNeed to define upto %d extra UDM's in GUI and reload %s\n",NUM_UDM,libname);

else

{

Message("%d UDM's have been reserved %s\n",NUM_UDM,libname);

Set_User_Memory_Name(udm_offset,"UDMmass");

Set_User_Memory_Name(udm_offset+1,"UDMnum");

}

Message("\nUDMoffset for current lib = %d",udm_offset); }

DEFINE_ON_DEMAND(set_udms) { Domain *d; Thread *ct; cell_t c; int i; d=Get_Domain(1); /*ID for fluid*/

if (udm_offset != UDM_UNRESERVED)

{

Message("Setting UDMs\n");

for (i=0;i<NUM_UDM;i++)

{

thread_loop_c(ct,d)

{

begin_c_loop(c,ct)

{

C_UDMI(c,ct,udm_offset+i)=0.0;

}

end_c_loop(c,ct)

}

}

}

else

Message("UDM's not reserved\n"); }

DEFINE_DPM_BC(deposition_bc,p,t,f,f_normal,dim) {

Domain *d; cell_t c=RP_CELL(&p->cCell); Thread *tcell=RP_THREAD(&p->cCell); real Tavg,Ep,vcr; d=Get_Domain(4); real vn=0.; real R=287.; real normal[3]; int i,idim=dim; real x[ND_ND];

for (i=0.; i<idim; i++)

normal[i] = f_normal[i];

if(p->type==DPM_TYPE_INERT)

{

/*computing normal velocity*/

for(i=0.;i<idim;i++)

vn += p->state.V[i]*normal[i];

/*computing critical velocity*/

Tavg = (F_T(f,t)+P_T(p))/2.;

Ep = (3.*(pow(10.,20.)))*exp(-0.02365*Tavg);

vcr = pow(((2.*Ep)/P_DIAM(p)),(10./7.));

/*particle continues its path - no sticking*/

if (vn > vcr)

{

return PATH_ACTIVE;

}

/*particle sticks*/

else

{

C_UDMI(c,tcell,0) += P_MASS(p); /* mass of particles deposited*/

C_UDMI(c,tcell,1) += 1.0;

Message("No. of particles deposited is %d",C_UDMI(c,tcell,1));

return PATH_ABORT;

}

}

}

giovanni franchello March 1, 2009 08:02

Re: C_UDMI Question in DPM
 
Now I have not time to debug your UDF. You should control the DEFINE_DPM_BC, loops like for(i=0.;ivn += p->state.V[i]*normal[i]; that are not clear. As I see in your macro the pointer domain is not used. Include messages to control if what is calculated correspond to what you expect. Include additional udmi to count no. of particles not sticking. Note that you don't count particles, but parcels. I suppose 4 day are not enougth. Sei ancora in alto mare Ciao Gian

Prashanth March 1, 2009 08:22

Re: C_UDMI Question in DPM
 
Hi Gian

Thanks a lot for your help. You have pointed out the direction to look in and thank you for that. I'll go back to working on it.

Thanks

Prashanth

panyd August 20, 2009 04:35

define reflect boundary conditions
 
hi Prashanth
resently, i study the particle deposition on tube surface. but during the interation with my defined reflect boundary,fluent display "Error:divergence detected in AMG solver: x-momentum" .my Define_dpm_bc is as follows:
#include "udf.h"
#include "dpm.h"
#include "mem.h"
#include <stdlib.h>
#include <math.h>
#include <iostream.h>
#include <time.h>
#define p_Ela_mol 3.6e11
#define p_sur_vos 0.15
#define p_den 1550
#define angle_cri 1.27
#define p_po 0.23
#define vn_y 7.5
DEFINE_DPM_BC(bc_reflect,p,t,f,f_normal,dim)
{
real alpha,alpha_a; /* angle of particle path with face normal */
real vn=0.;
real vt=0.;
real nor_coeff,tan_coeff;
real vn_cri,vnm_cri;
real fs_coeff=0.4;
real normal[3];
real c_num,c_xsh,poro;
int i, idim = dim;
int num_acc;
real NV_VEC(x);
real Eeff;
Thread *t0;
cell_t c0;

Eeff=p_Ela_mol/(1-p_po*p_po);
num_acc = F_UDMI(f,t,1);
c_num=num_acc*F_UDMI(f,t,2)/(0.0508*angle_cri/2);
c_xsh=pow((c_num/20),-0.282);
poro=pow(c_xsh,3)/(pow(c_xsh,3)+0.852);
if (poro<0.55)
vn_cri=0.0445+0.0074*exp(5.8828*poro);
else
vn_cri=0.2692+2.0303*pow(10,-7)*exp(20.8835*poro);
srand( (unsigned)time( NULL ) );
for (i=0; i<idim; i++)
normal[i] = f_normal[i];
if(p->type==DPM_TYPE_INERT)
{
alpha = M_PI/2. - acos(MAX(-1.,MIN(1.,NV_DOT(normal,p->state.V)/
MAX(NV_MAG(p->state.V),DPM_SMALL)))); alpha_a=alpha+5*M_PI*gaussrand()/180;
for(i=0; i<idim; i++)
vn +=p->state.V[i]*normal[i];
if ((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))
F_CENTROID(x,f,t);

if (alpha>angle_cri )
{
nor_coeff=1;
tan_coeff=1-fs_coeff*(1+nor_coeff)/tan(alpha_a);
}
else if (vn<=vn_cri)
{
nor_coeff=0;
tan_coeff=0;
}
else if (vn>vn_cri && vn<=vn_y)
{
nor_coeff=sqrt(1-pow(vn_cri/vn,2.0));
tan_coeff=1-fs_coeff*(1+nor_coeff)/tan(alpha_a);
}
else
{
nor_coeff=sqrt(1.2*sqrt(3)*(1-pow(vn_y/vn,2.0)/6)*sqrt((vn_y/vn)/((vn_y/vn)+2*sqrt(1.2-0.2*pow(vn_y/vn,2.0))))-pow(vn_cri/vn,2.0));
tan_coeff=1-fs_coeff*(1+nor_coeff)/tan(alpha_a);
}

for(i=0; i<idim; i++)
p->state.V[i] -=vn*normal[i];
for(i=0; i<idim; i++)
p->state.V[i] *=tan_coeff;
for(i=0; i<idim; i++)
p->state.V[i] -=nor_coeff*vn*normal[i];
for(i=0; i<idim; i++)
p->state0.V[i]=p->state.V[i];

if (nor_coeff==0)
{
return PATH_ABORT;
}
else
{
return PATH_ACTIVE;
}
}
return PATH_ABORT;
}

in the programme of DEFINE_DPM_EROSION(), i set F_UDMI(f, t, 1) to store the number of deposited particle and F_UDMI(f, t, 2) to store the mean diameter of deposited particle.

would you please help me to check my programme and point out the mistakes


All times are GMT -4. The time now is 14:39.