CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

New velocity components

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 8, 2015, 04:20
Default New velocity components
  #1
Senior Member
 
Join Date: Mar 2014
Posts: 375
Rep Power: 13
hwet is on a distinguished road
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;
    }
    
}
The printed new velocity components are: -1.3e+38 5.9e-323 1.9e-323.
hwet is offline   Reply With Quote

Old   April 8, 2015, 04:28
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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).
`e` is offline   Reply With Quote

Old   April 8, 2015, 04:36
Default
  #3
Senior Member
 
Join Date: Mar 2014
Posts: 375
Rep Power: 13
hwet is on a distinguished road
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!
hwet is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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 19:26
Plotting Radial and Circumferential Velocity Components for FSI modelling ashtonJ CFX 1 May 28, 2012 04:36
Converting cartesian to spherical velocity components feldy77 OpenFOAM 1 September 13, 2011 17:40
velocity components of dispersed phase in posdat.f kube STAR-CD 3 November 24, 2010 01:41
How to specify velocity components in UDF Ynot FLUENT 1 March 11, 2006 13:53


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