|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
jens meier
Join Date: Sep 2019
Posts: 28
Rep Power: 6 ![]() |
Hey everyone, I really need your help !
I'm dealing with a UDF code calculating the viscous force acting on a body. Now I want to extend that code so that the force of particles I want to insert is also calculated and added to the viscous force. If the particles are in my domain I expect the body to slow down very faster because of the particle forces acting on that body. I wrote a code, but I don't know the mistakes because I'm not familiar with programming in C. I would really appreciate if you could check and help me. So thats my code : #include "udf.h" static real v_prev = 0.3; DEFINE_CG_MOTION(bubble, dt, vel, omega, time, dtime) DEFINE_DPM_BC(Particle_Infos,p,t,f,f_normal,dim) { #if !RP_HOST Thread *t; face_t f; cell_t p_cell; /* Cells where particles reside */ real p_n; /* Number of particles in a parcel */ real p_mass; /* Mass of each particle */ real pur_vel[ND_ND]; /* Velocity of each particle */ int i; /* vector number*/ flow_time = CURRENT_TIME; /* Get current flow time */ Thread *p_cell_thread; real NV_VEC(A); real Wall_Shear_Force; real viscous; real force_p; real dv; /**** Now calculating force of particles*******/ p_cell = F_C0(f,t); /* return cell thread index in which face thread "t" is */ p_cell_thread = THREAD_T0(t); /* Get the face centroid from ANSYS FLUENT */ F_CENTROID(pur_f_centroid,f,t); /* Get the number of the particles in a parcel from FLUENT */ p_n = P_N(p); /* Get the mass of the particle from ANSYS FLUENT */ p_mass = P_MASS(p); /* Get the velocity of the particle from ANSYS FLUENT */ for(i=0;i<dim;i++) pur_vel[i] = P_VEL(p)[i]; /* When the particles hit the wall face, mark the cell, which consists this face.*/ C_UDMI(p_cell,p_cell_thread,0) = PUR_cell; /* Store the number of particles hitting this face all the time. */ C_UDMI(p_cell,p_cell_thread,1) += p_n; C_UDMI(p_cell,p_cell_thread,2) += p_n * p_mass; /* mass of particles hitting the face */ C_UDMI(p_cell,p_cell_thread,6) += p_n * p_mass * pur_vel[0]; /* Total impulse of all parcels in x direction in a cell */ force_p = C_UDMI(p_cell,p_cell_thread,6); C_UDMI(p_cell,p_cell_thread,17) += 1; /* Store the number of parcels hitting on this face all the time*/ return PATH_ABORT; #endif /**** Now calculating viscous force*******/ /* reset velocities */ NV_S (vel, =, 0.0); NV_S (omega, =, 0.0); if (!Data_Valid_P ()) return; /* get the thread pointer for which this motion is defined */ t = DT_THREAD (dt); /* compute pressure force on body by looping through all faces */ viscous = 0.0; begin_f_loop (f, t) { F_AREA (A, f, t); Wall_Shear_Force = -F_STORAGE_R_N3V(f,t ,SV_WALL_SHEAR)[0]; viscous += Wall_Shear_Force ; } end_f_loop (f, t) /* compute change in velocity, i.e., dv = F * dt / mass velocity update using explicit Euler formula */ dv = dtime * (viscous + 0.000512 + force_p/dtime) / 0.000055; v_prev += dv; Message ("time = %f, x_vel = %f, force = %f\n", time, v_prev, force); /* set x-component of velocity */ vel[0] = v_prev; } Best regards! |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
annan
Join Date: Nov 2016
Posts: 72
Rep Power: 9 ![]() |
Dear Jens,
Why do you have two functions ? Namely, DEFINE_CG_MOTION and DEFINE_DPM_BC. A part of your code might be missing here, but there should be only one of them. DEFINE_CG_MOTION(bubble, dt, vel, omega, time, dtime) { Code } Or DEFINE_DPM_BC(Particle_Infos,p,t,f,f_normal,dim) { Code } Regards, Annan |
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
jens meier
Join Date: Sep 2019
Posts: 28
Rep Power: 6 ![]() |
Hey annan
thank you for your answer. I thought I need two functions. One for the motion and one for the Particles... How can I change that into a right code ? best regards |
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Urgent Help Needed: Rotate mesh in ICEM | anand32 | ANSYS Meshing & Geometry | 5 | August 10, 2017 23:06 |
urgent help needed (rhie-chow interpolation problem) | Ardalan | Main CFD Forum | 2 | March 18, 2011 15:22 |
help needed in Turbulent flow (URGENT) | mike | FLUENT | 7 | November 7, 2008 06:11 |
sample code needed | buaalzr | Main CFD Forum | 0 | December 23, 2007 21:23 |
Design Integration with CFD? | John C. Chien | Main CFD Forum | 19 | May 17, 2001 15:56 |