TAGGED: adhesion, interior-bc, udf
-
-
August 7, 2024 at 4:27 pmkiran.purushothamakeshavanBbp_participant
Hi,
I'm trying to compile a UDF to impose a criteria for particle adhesion.
This is my first attempt at writing a UDF, I ran into a few errors when I tried to build it and then when I load the UDF I see the following error, I will attach the UDF after the error message, I need some advise on this matter.Thanks,
Kiranerror:
Files udf_names.c and user_nt.udf in 3ddp_host are up-to-date.
Copyright 1987-2024 ANSYS, Inc. All Rights Reserved.
Compiler and linker: Microsoft Visual C++
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj test-UDF-four.obj
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
NMAKE : U1077: 'link -nologo /Libpath:"C:\PROGRA~1\ANSYSI~1\v241\fluent"\fluent24.1.0\win64\3ddp_host /Libpath:"C:\PROGRA~1\ANSYSI~1\v241\fluent"\fluent24.1.0\multiport\win64\net\shared /dll /out:libudf.dll udf_names.obj test-UDF-four.obj mport.lib fl2410.lib ' : return code '0x450'
Stop.
Files udf_names.c and user_nt.udf in 3ddp_node are up-to-date.
Copyright 1987-2024 ANSYS, Inc. All Rights Reserved.
Compiler and linker: Microsoft Visual C++
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj test-UDF-four.obj
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
NMAKE : U1077: 'link -nologo /Libpath:"C:\PROGRA~1\ANSYSI~1\v241\fluent"\fluent24.1.0\win64\3ddp_node /Libpath:"C:\PROGRA~1\ANSYSI~1\v241\fluent"\fluent24.1.0\multiport\win64\mpi\shared /dll /out:libudf.dll udf_names.obj test-UDF-four.obj mport.lib fl_mpi2410.lib ' : return code '0x450'
Stop.
Done.
kiran: Opening library "C:\Users\usr\OneDrive\Desktop\Me\UDF_compiled\test_files\dp0\FFF-1\Fluent\one_way_transient-1"...
ERROR: The UDF library you are trying to load (one_way_transient-1) is not compiled for parallel use on the current platform (win64).
The system cannot find the file specified.
C:\\Users\\usr\\OneDrive\\Desktop\\Me\\UDF_compiled\\test_files\\dp0\\FFF-1\\Fluent\\one_way_transient-1\\win64\\3ddp_host\\libudf.dll
Done.
kiran: Opening library "C:\Users\usr\OneDrive\Desktop\Me\UDF_compiled\test_files\dp0\FFF-1\Fluent\one_way_transient-1"...
ERROR: The UDF library you are trying to load (one_way_transient-1) is not compiled for parallel use on the current platform (win64).
The system cannot find the file specified.
C:\\Users\\usr\\OneDrive\\Desktop\\Me\\UDF_compiled\\test_files\\dp0\\FFF-1\\Fluent\\one_way_transient-1\\win64\\3ddp_node\\libudf.dll
Error: An error occurred in the previous operation.
The details can be found in the text output.
Error Object: #f
UDF:
#include "udf.h"#include "dpm.h"/* Define constants */#define Rho_air 1.225 /* Density of air in kg/m^3 */#define Cd 0.44 /* Drag coefficient */#define mu 0.196 /* Friction coefficient */DEFINE_DPM_BC(particle_bc, p, t, f, normal, dim){// Particle *p;// real A = P_AREA(P_DIAM(p)); /* Assuming a method to calculate the projected area of the particle */real V = sqrt(P_VEL(p)[0] * P_VEL(p)[0] + P_VEL(p)[1] * P_VEL(p)[1] + P_VEL(p)[2] * P_VEL(p)[2]); /* Velocity magnitude in m/s */real radius = P_DIAM(p) / 2.0;real A = M_PI * radius * radius; /* M_PI is a constant for π *//* Get the thread and cell pointers */Thread *t0 = P_CELL_THREAD(p);cell_t c0 = P_CELL(p);/* Get local pressure at the particle's location */real P_local = C_P(c0, t0);/* Calculate aerodynamic force Fa */real Fa = 0.5 * Rho_air * A * Cd * V * V;/* Calculate normal force Fn */real Fn = P_local * A;/* Calculate frictional force Ff */real Ff = mu * Fn;/* Check the removal condition */if (Fa > Ff){/* Particle needs to be removed from the surface */return PATH_ACTIVE; /*No adhesion*/}else{/* Particle sticks to the boundary */P_USER_REAL(p, 0) = 1.;return PATH_ABORT; /*Adhesion*/}} -
August 8, 2024 at 10:07 amRobForum Moderator
Try using the built in compiler and see what happens. Can you compile any of the examples?
-
August 8, 2024 at 4:22 pmkiran.purushothamakeshavanBbp_participant
Thanks for your reply.
The issue was that I did not build the udf from x86_x64 VS prompt. After opening fluent from Visual Studio prompt UDF seems to be loading without issues.
However, I have an issue where the particles in my model seem to not stick to the boundary. below I’ve copied the UDF for your reference.
I expected to see certain particles bounce while the rest of them to stick to the surface, here I do not see the particles bounce or stick.#include “udf.h”#include “dpm.h”#include “math.h”#define Rho_air 1.225 /* Air density in kg/m^3 */#define Cd 0.47 /* Drag coefficient for a sphere */#define mu 0.5 /* Coefficient of friction *//* Define your boundary condition function */DEFINE_DPM_BC(particle_bc, p, t, f, normal, dim){real V = sqrt(P_VEL(p)[0] * P_VEL(p)[0] + P_VEL(p)[1] * P_VEL(p)[1] + P_VEL(p)[2] * P_VEL(p)[2]); /* Velocity magnitude in m/s */real radius = P_DIAM(p) / 2.0;real A = M_PI * radius * radius; /* M_PI is a constant for π *//* Get the thread and cell pointers */Thread *t0 = P_CELL_THREAD(p);cell_t c0 = P_CELL(p);/* Get local pressure at the particle’s location */real P_local = C_P(c0, t0);/* Calculate aerodynamic force Fa */real Fa = 0.5 * Rho_air * A * Cd * V * V;/* Calculate normal force Fn */real Fn = P_local * A;/* Calculate frictional force Ff */real Ff = mu * Fn;/* Coefficient of restitution */real e;if (Fa > Ff){/* Particle needs to bounce with a coefficient of restitution of 1 */e = 1.0;/* Update the particle velocity to simulate the bounce */for (int i = 0; i < dim; i++){P_VEL(p)[i] = -e * P_VEL(p)[i];}return PATH_ACTIVE; /* No adhesion */}else{/* Particle sticks to the boundary with a coefficient of restitution of 0 */// e = 0.0;/* Update the particle velocity to simulate sticking */for (int i = 0; i < dim; i++){P_VEL(p)[i] = 0;}P_USER_REAL(p, 0) = 1.;return PATH_ACTIVE; /* Adhesion */}}Can you please comment on the code?
-
August 9, 2024 at 8:59 amRobForum Moderator
Why would the particle stick? You look to have killed the velocity but what happens in the next integration step?
-
August 9, 2024 at 8:29 pmkiran.purushothamakeshavanBbp_participant
Okay I get this, but how do I get the particle to stick on the wall?
1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process / visualise the results?
2. What do you think I must do to model particle trajectory after colliding with the boundary?3. From the below UDF I do not see a text file being generated to run my simulation, what could be the reason?
#include “udf.h”#include “dpm.h”#include “math.h”#include “mem.h”#include#define Rho_air 1.225 /* Air density in kg/m^3 */#define Cd 0.47 /* Drag coefficient for a sphere */#define mu 0.5 /* Coefficient of friction *//* Define your boundary condition function */DEFINE_DPM_BC(particle_bc, p, t, f, normal, dim){real V = sqrt(P_VEL(p)[0] * P_VEL(p)[0] + P_VEL(p)[1] * P_VEL(p)[1] + P_VEL(p)[2] * P_VEL(p)[2]); /* Velocity magnitude in m/s */FILE * fp1 ;real alpha; /* angle of particle path with face normal */real vn=0.;real nor_coeff = 1.;real tan_coeff = 0.3;//real normal[3];int i, idim;real NV_VEC(x);real radius = P_DIAM(p) / 2.0;real A = M_PI * radius * radius; /* M_PI is a constant for π *//* Get the face pressure */real P_local = F_P(f, t);/* Calculate aerodynamic force Fa */real Fa = 0.5 * Rho_air * A * Cd * V * V;/* Calculate normal force Fn */real Fn = P_local * A;/* Calculate frictional force Ff */real Ff = mu * Fn;if (Fa > Ff){/* Particle needs to bounce with a coefficient of restitution of 1 *//* Compute normal velocity. */for(i=0; ivn += P_VEL(p)[i]*normal[i];/* Subtract off normal velocity. */for(i=0; iP_VEL(p)[i] -= vn*normal[i];/* Apply tangential coefficient of restitution. */for(i=0; iP_VEL(p)[i] *= tan_coeff;/* Add reflected normal velocity. */for(i=0; iP_VEL(p)[i] -= nor_coeff*vn*normal[i];/* Store new velocity in P_VEL0 of particle */for(i=0; iP_VEL0(p)[i] = P_VEL(p)[i];fp1=fopen ( “Impact.txt” , “a” ) ;fprintf( fp1 , “%f %f %f %f\n”, Fa, Ff, radius, P_local);fclose( fp1 );return PATH_ACTIVE;}else{/* Particle sticks to the boundary */for (int i = 0; i < dim; i++){P_VEL(p)[i] = 0; /* Set velocity to zero */}P_USER_REAL(p, 0) = 1.0; /* Optionally set a user-defined variable to indicate sticking *//* Save the impingement location */P_USER_REAL(p, 1) = P_POS(p)[0]; /* X-coordinate */P_USER_REAL(p, 2) = P_POS(p)[1]; /* Y-coordinate */P_USER_REAL(p, 3) = P_POS(p)[2]; /* Z-coordinate */P_USER_REAL(p, 4) = 1.0; /* Mark as stuck */return PATH_ABORT; /* Stop tracking the particle */}}
-
-
August 12, 2024 at 8:41 amRobForum Moderator
If you stick particles to the wall you'll break the DPM volume fraction rules. As the amount of stuck material won't alter the chances of anything else sticking why would you? You can add mass to a wall (facet) UDM for post processing.
-
August 13, 2024 at 8:07 amkiran.purushothamakeshavanBbp_participant
Yes maybe using the number of particles on the wall with impingement location can be fed into a UDM for post processing, I'll keep you posted on this.
But before I can go that far, I see that my Force values and pressure values seem to be off. I printed the variable values for 'Fa, Fn, radius, P_local' from my UDF into a text file.
This is how the values look in the same chronological order as stated above
(Fa, Fn, radius, P_local)
1.000000 0.023929 0.021373 0.000000
1.000000 0.027982 0.023274 0.000000
1.000000 0.024288 0.021810 0.000000
1.000000 0.027118 0.023750 0.000000
1.000000 0.026723 0.024311 0.000000
1.000000 0.024109 0.021391 0.000000
1.000000 0.026214 0.024212 0.000000
1.000000 0.027531 0.023820 0.000000
1.000000 0.028039 0.023649 0.000000
1.000000 0.025427 0.023606 0.000000
1.000000 0.024226 0.021913 0.000000
1.000000 0.025716 0.022863 0.000000
1.000000 0.025270 0.023653 0.000000.....................& so onWhat could be the reason for such random values being calculated? most importantly why are the values of Pressure equal to zero(found from F_P(f, t) = 0)?
I know this is a lot to ask for on a forum like this but your thoughts on this would help me a lot.
UDF:
#include "udf.h"#include "dpm.h"#include "math.h"#include "mem.h"#include#define Rho_air 1.225 /* Air density in kg/m^3 */#define Cd 0.47 /* Drag coefficient for a sphere */#define mu 0.5 /* Coefficient of friction */#define Vflow 10#define PI 3.14/* Define your boundary condition function */DEFINE_DPM_BC(particle_bc, p, t, f, normal, dim){real Vparticle = sqrt(P_VEL(p)[0] * P_VEL(p)[0] + P_VEL(p)[1] * P_VEL(p)[1] + P_VEL(p)[2] * P_VEL(p)[2]); /* Velocity magnitude in m/s */real V = fabs(Vparticle - Vflow);FILE *fp1 ;FILE *fp2;real alpha; /* angle of particle path with face normal */real vn=0.;real nor_coeff = 1.;real tan_coeff = 0.3;//real normal[3];int i, idim;real NV_VEC(x);real radius = P_DIAM(p) / 2.0;real A = PI * radius * radius; /* M_PI is a constant for π *//* Get the face pressure */real P_local = F_P(f, t);// real P_local = C_P(c,t);/* Calculate aerodynamic force Fa */real Fa = 0.5 * Rho_air * A * Cd * V * V;/* Calculate normal force Fn */real Fn = P_local * A;/* Calculate frictional force Ff */real Ff = mu * Fn;if (Fa > Ff){/* Particle needs to bounce with a coefficient of restitution of 1 *//* Compute normal velocity. */for(i=0; ivn += P_VEL(p)[i]*normal[i];/* Subtract off normal velocity. */for(i=0; iP_VEL(p)[i] -= vn*normal[i];/* Apply tangential coefficient of restitution. */for(i=0; iP_VEL(p)[i] *= tan_coeff;/* Add reflected normal velocity. */for(i=0; iP_VEL(p)[i] -= nor_coeff*vn*normal[i];/* Store new velocity in P_VEL0 of particle */for(i=0; iP_VEL0(p)[i] = P_VEL(p)[i];fp1=fopen ("Impact.txt" , "a") ;fprintf( fp1 , "%f %f %f %f %f\n", Fa, Fn, Ff, radius, P_local);fclose(fp1);return PATH_ACTIVE;}else{/* Particle sticks to the boundary */for (int i = 0; i < dim; i++){P_VEL(p)[i] = 0; /* Set velocity to zero */}P_USER_REAL(p, 0) = 1.0; /* Optionally set a user-defined variable to indicate sticking *//* Save the impingement location */P_USER_REAL(p, 1) = P_POS(p)[0]; /* X-coordinate */P_USER_REAL(p, 2) = P_POS(p)[1]; /* Y-coordinate */P_USER_REAL(p, 3) = P_POS(p)[2]; /* Z-coordinate */P_USER_REAL(p, 4) = 1.0; /* Mark as stuck */fp2=fopen ("Impact2.txt" , "a") ;// fprintf(fp2 , "%f %f %f %f\n", P_USER_REAL(p, 0), P_USER_REAL(p, 1), P_POS(p)[1], P_POS(p)[2]);fprintf( fp2 , "%f %f %f %f %f %f \n", Fa, Fn, Ff, radius, P_local, F_P(f, t));fclose(fp2);return PATH_ABORT; /* Stop tracking the particle */}}Thanks,
KiranAugust 13, 2024 at 10:24 amRobForum ModeratorTry returning (for example) a facet x-coordinate. That'll confirm if you're returning F_P(f,t) or if it's not triggering for some reason. There's no face loop so not sure what it's doing.
-
August 19, 2024 at 3:27 pmkiran.purushothamakeshavanBbp_participant
I think the issue was with the order of each force quantities, it was in the scale if E-09 or E-11 so I used a factor which multiplied these insignificant quantities to compare with the others.
anyway, now my question is simple, I get to see how many particles stick and how many bounce from the object. How do I visualise the contours for the same? I would want to display the particle adhesion on a surface as a heatmap.
here is my code:
#include “udf.h”#include “dpm.h”#define mu 0.5#define PI 3.14real FD(real diam, real velocidad){return ((1/2) * 1.225 * 0.44 * M_PI*(((diam)*(diam))/4) * (velocidad*velocidad));}FILE *fp1;FILE *fp2;FILE *fp3;//real x[3];//x[0] = 0.0; // Assign value to the x component//x[1] = 0.0; // Assign value to the y component//x[2] = 0.0; // Assign value to the z componentDEFINE_DPM_DRAG(particle_drag_force, Re, p){FILE *fp1;real w, drag_force, F, nf, ff, ff123;Thread* tcell = P_CELL_THREAD(p);cell_t c = P_CELL(p);real relVel[ND_3], dvtdn, fluidVel[ND_3];if (Re < 1){drag_force = 18;}else if (Re < 20.0){w = log10(Re);drag_force = 18.0 + 2.367 * pow(Re, 0.82 – 0.05 * w);}else{drag_force = 18.0 + 3.483 * pow(Re, 0.6305);}NV_D(fluidVel, =, C_U(c, tcell), C_V(c, tcell), C_W(c, tcell)); //assigning fluid velocity components to vectorNV_VV(relVel, =, fluidVel, -, P_VEL(p)); //calculating relative velocity of flow on particle by subtracting absolute particle velocity from fluid velocitydvtdn = NV_MAG(relVel); //calculation of relative velocity magnitude// P_USER_REAL(p, 0) = FD(drag_force, C_MU_L(c, tcell), P_RHO(p), P_DIAM(p), P_MASS(p), dvtdn); /*Drag force*/P_USER_REAL(p, 0) = FD(P_DIAM(p), dvtdn); /*Drag force*/P_USER_REAL(p, 1) = dvtdn;// F = (1/2)*1.225*0.3*M_PI*(((P_DIAM(p))*(P_DIAM(p)))/4)*(dvtdn*dvtdn);// F = (1/2)*1.225*0.3*10000000*M_PI*(((P_DIAM(p))*(P_DIAM(p)))/4)*(dvtdn*dvtdn)*(10000000000);// P_USER_REAL(p, 2) = F;// nf = C_P(c, tcell) * M_PI (((P_DIAM(p))*(P_DIAM(p)))/4) *10000000000;fp1=fopen (“Impact-2-drag-data.txt” , “a”);// fprintf( fp1 , “%e %f %e %f %f %e %e\n”, P_USER_REAL(p, 0), P_USER_REAL(p, 1), P_USER_REAL(p, 2), drag_force, P_DIAM(p), F, P_USER_REAL(p, 3));real diameter_squared = P_DIAM(p) * P_DIAM(p);real area_term = (diameter_squared) / 4;real velocity_term = dvtdn * dvtdn;real constant_factor = (1.0 / 2.0) * 1.225 * 0.3 * PI;F = constant_factor * area_term * velocity_term * (10000000);P_USER_REAL(p, 2) = F;nf = C_P(c, tcell) * (PI/4.0) * diameter_squared *10000000;ff = mu * nf;ff123 = ff;P_USER_REAL(p, 3) = ff123;fprintf(fp1, “Area Term: %e, Velocity Term: %e, F (final): %e, Constant factor: %e, friction force: %e, Normal force: %e\n”, area_term, velocity_term, P_USER_REAL(p, 2), constant_factor, P_USER_REAL(p, 3), nf);fprintf(fp1, “Pressure: %e, ff123: %e\n”, C_P(c, tcell), ff123);fclose(fp1);return (drag_force);}DEFINE_DPM_BC(wall_model, p, t, f, f_normal, dim){real alpha; /* angle of particle path with face normal */real vn=0.;real nor_coeff = 0.3;real tan_coeff = 0.3;real normal[3];int i;real posx, posy, posz;// real NV_VEC(x);real x[ND_ND];//#if !RP_HOST#if RP_2D//dim is always 2 in 2D compilation. Need special treatment for 2d axisymmetric and swirl flowsif (rp_axi_swirl){real R = sqrt(P_POS(p)[1]*P_POS(p)[1] +P_POS(p)[2]*P_POS(p)[2]);if (R > 1.e-20){idim = 3;normal[0] = f_normal[0];normal[1] = (f_normal[1]*P_POS(p)[1])/R;normal[2] = (f_normal[1]*P_POS(p)[2])/R;}else{for (i=0; inormal[i] = f_normal[i];}}else#endiffor (i=0; inormal[i] = f_normal[i];//Message (“Text \n”);if (p->type == DPM_TYPE_INERT){if (fabs(P_USER_REAL(p, 2)) < fabs(P_USER_REAL(p, 3)))// Particle bounce: Aerodynamic force > Pressure force on particle. So particle must be resuspended to the flow.{posx = P_POS(p)[0];posy = P_POS(p)[1];posz = P_POS(p)[2];P_USER_REAL(p, 4) = posx;P_USER_REAL(p, 5) = posy;P_USER_REAL(p, 6) = posz;for(i=0; iP_VEL(p)[i] = 0;P_USER_REAL(p, 7) += 1.;fp2=fopen (“Impact-Stick.txt” , “a”);fprintf( fp2 , “Force due to aero (Fa): %f, Friction force (ff): %f, How many stick? = %f, x coordinate: %f, y coorfdinate: %f, z coordinate: %f\n”, P_USER_REAL(p, 2), P_USER_REAL(p, 3), P_USER_REAL(p, 7), P_USER_REAL(p, 4), P_USER_REAL(p, 5), P_USER_REAL(p, 6));fflush(fp2);fclose(fp2);return PATH_ACTIVE;}else{alpha = (PI/2.0) – acos(MAX(-1.,MIN(1.,NV_DOT(normal,P_VEL(p))/ MAX(NV_MAG(P_VEL(p)),DPM_SMALL))));if ((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))F_CENTROID(x, f, t);/* Compute normal velocity. */for(i=0; ivn += P_VEL(p)[i]*normal[i];/* Subtract off normal velocity. */for(i=0; iP_VEL(p)[i] -= vn*normal[i];/* Apply tangential coefficient of restitution. */for(i=0; iP_VEL(p)[i] *= tan_coeff;/* Add reflected normal velocity. */for(i=0; iP_VEL(p)[i] -= nor_coeff*vn*normal[i];/* Store new velocity in P_VEL0 of particle */for(i=0; iP_VEL0(p)[i] = P_VEL(p)[i];P_USER_REAL(p, 8) += 1.;fp3=fopen (“Impact-Bounce.txt” , “a”) ;fprintf(fp3 , “Force due to aero (Fa): %f, Friction force (ff): %f, Number of particles bounced: %f\n”, P_USER_REAL(p, 2), P_USER_REAL(p, 3), P_USER_REAL(p, 8));fflush(fp3);fclose(fp3);return PATH_ACTIVE;}}else{return PATH_END;}//#endif}
August 20, 2024 at 8:58 amRobForum ModeratorIf you're using facet UDMs you can display those.
August 20, 2024 at 4:32 pmkiran.purushothamakeshavanBbp_participantDo we have to use DEFINE_ON_DEMAND to save data in the UDM?? When I did not use this macro, I saw some SIGSERV error or memory error. Why does this happen? Where can I read about this?
August 20, 2024 at 4:54 pmRobForum ModeratorNo, it should be possible as part of the calculation loop. Did you assign enough UDM slots in the Fluent solver?
August 23, 2024 at 8:50 amkiran.purushothamakeshavanBbp_participantI guess this error was because of an issue because of insuffecient ram.
From the text file export, I see that the number of particles saved in the UDM's repeat from 1 to 9 and again start from 1 - 9. Can you please comment on why I might be seeing this?
I just want to know how I can visualise the number of particle hits on a particular coordinate.August 23, 2024 at 9:25 amRobForum ModeratorCheck what the %e and %f are in the print statements, don't you need a number ie %12.6f but won't %d work better?
Why parcel count and not mass?
Viewing 10 reply threads- You must be logged in to reply to this topic.
Ansys Innovation SpaceTrending discussionsTop Contributors-
421
-
192
-
178
-
162
-
140
Top Rated Tags© 2024 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-
-
Please Login to Report Topic
Please Login to Share Feed