|
[Sponsors] |
April 8, 2015, 05:20 |
New velocity components
|
#1 |
Senior Member
Join Date: Mar 2014
Posts: 375
Rep Power: 13 |
This code appears to work fine (not really) after weeks of attempts.
The idea was to make the particle reflect if a certain condition was fulfilled. The particle does reflect, and quickly attains the gas speed so the reflected speed i suppose doesn't really matter. But... still curious to know what it was and tried to print the reflected components, the values are very illogical. ''The printed new velocity components are: -1.3e+38 5.9e-323 1.9e-323.'' Also using printf and not message0 as I have other issues trying to compile the UDF so just interpreting it at the moment. Code:
#include "udf.h" DEFINE_DPM_BC(drop_col_wet_scrubber, particle_data, thread_face, f_index, f_normal, dim) { real vsqr=0; /*Initializing the variables*/ real vmag=0; real vn=0; real normal[3]; real collision_weber_number; int i, idim=dim; for (i=0; i<idim;i++) { vsqr += P_VEL(particle_data)[i]*P_VEL(particle_data)[i]; /*Taking all dimensions into consideration*/ vmag += sqrt(vsqr); printf("The velocity magnitude is: %e\n", vmag); /*From specified node only*/ collision_weber_number=(P_RHO(particle_data) * P_DIAM(particle_data) * vmag*vmag) /0.072; /*Weber number calculation*/ printf("The collision Weber number is: %e\n", collision_weber_number); } for(i=0; i<idim; i++) normal[i]= f_normal[i]; /* printf("The fnormal vector components are: %d %d %d\n", f_normal[0],f_normal[1],f_normal[2]); */ if (collision_weber_number >=500) /*Critical weber number values from experiments/literature*/ {return PATH_END; } else if (1 <=collision_weber_number <500) /*Compute normal velocity*/ { for(i=0; i<idim; i++) vn +=P_VEL(particle_data)[i]*normal[i]; /*printf("The face normal vector is: %d %d %d\n", normal[i]); */ printf("The normal velocity is: %e\n", vn); /* Subtract off normal velocity*/ for(i=0; i<idim; i++); P_VEL(particle_data)[i] -= vn*normal[i]; /*Add reflected normal velocity*/ for(i=0;i<idim; i++) P_VEL(particle_data)[i] -=vn*normal[i]; /*Store new velocity in P_VEL0 of particle*/ for(i=0;i<idim; i++) P_VEL0(particle_data)[i]= P_VEL(particle_data)[i]; printf("New velocity components are: %e %e %e\n", P_VEL(particle_data)[i]); return PATH_ACTIVE; } else {return PATH_END; } } |
|
April 8, 2015, 05:28 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
You have three %e's in your printf() function but only one value to provide these three values: P_VEL(particle_data)[i] where 'i' is your last dimension (idim-1).
|
|
April 8, 2015, 05:36 |
|
#3 |
Senior Member
Join Date: Mar 2014
Posts: 375
Rep Power: 13 |
They are certainly more logical now! But i am certain I did try that before, well one of the things about beginner programming, might have something else wrong when I tried displaying all three of them before, thanks!
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
calculate mean velocity components in all cells after some time steps | behest | FLUENT | 3 | September 15, 2013 20:26 |
Plotting Radial and Circumferential Velocity Components for FSI modelling | ashtonJ | CFX | 1 | May 28, 2012 05:36 |
Converting cartesian to spherical velocity components | feldy77 | OpenFOAM | 1 | September 13, 2011 18:40 |
velocity components of dispersed phase in posdat.f | kube | STAR-CD | 3 | November 24, 2010 02:41 |
How to specify velocity components in UDF | Ynot | FLUENT | 1 | March 11, 2006 14:53 |