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

How to plot UDF variables in Ansys fluent?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By bhargavbharathan
  • 1 Post By agarhaji

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 18, 2018, 09:33
Post How to plot UDF variables in Ansys fluent?
  #1
New Member
 
Agar Haji
Join Date: May 2018
Posts: 3
Rep Power: 8
agarhaji is on a distinguished road
Hello everyone.

I am testing different drag correlations for non-spherical particles and have made this UDF and compiled it in Fluent.

The problem i am facing now is, that i want to plot the drag coefficient for the particles and drag force calculated from the UDF.

I have tried the user-defined memory but without any luck. The results i get are all zeros.

Can anyone help me with this one. Maybe i need something in my UDF?

Quote:
#include "udf.h"
#include "dpm_types.h"


DEFINE_DPM_DRAG(drag_force,Re,tp)
{
double C_D, drag_force;
double d_sv, L, W, d_Cl, d_CC, Psi;
d_sv = TP_DIAM(tp); /* Sieve Diameter defined as the injected particle diameter */
L = 0.0115*log(d_sv) + 0.0818;
W = -42.365*pow(d_sv, 2) + 1.5702*d_sv - 0.0012;
d_Cl = W; /* Defining the diameter of the inscriped circle as the with of the particle*/
d_CC = L; /* Defining the diameter of the circumscribed circle as the with of the particle*/
Psi = sqrt(d_Cl / d_CC);
/* Calculating the drag coefficient using Yow's correlation */
C_D= (15.21 + (10.82 / Psi) - (0.14 / pow(Psi, 2))) / Re + (13.41 - (10.64 / Psi) - (0.016 / pow(Psi, 2))) / sqrt(Re) - 8.82 + 5.70 / Psi + 0.23 / pow(Psi, 2);
/* Calculating the dragforce as a dimentionless group */
drag_force = (18 * C_D*Re) / 24;
return (drag_force);
}
agarhaji is offline   Reply With Quote

Old   May 19, 2018, 20:48
Default
  #2
Member
 
Bhargav Bharathan
Join Date: Jun 2015
Location: Montreal, Canada
Posts: 71
Rep Power: 11
bhargavbharathan is on a distinguished road
Quote:
Originally Posted by agarhaji View Post
Hello everyone.

I am testing different drag correlations for non-spherical particles and have made this UDF and compiled it in Fluent.

The problem i am facing now is, that i want to plot the drag coefficient for the particles and drag force calculated from the UDF.

I have tried the user-defined memory but without any luck. The results i get are all zeros.

Can anyone help me with this one. Maybe i need something in my UDF?
Hi,

Firstly make sure you go to=>

Parameters & Customization -> User Defined Memory -> Number of User-Defined Memory Location and select the no. of UDMs you need.

Note that the UDM numbering starts from 0. So if you select 3 UDMs, their numbers would be 0, 1 and 2.

In your UDF you need to then assign your variable to a specific UDM. It would go something like:

F_UDMI(f,t,0)=drag_force;
C_UDMI(c0,t0,0)=drag_force;

Check out the below link:
https://www.sharcnet.ca/Software/Flu...udf/node96.htm


-B
Md Nabil likes this.
bhargavbharathan is offline   Reply With Quote

Old   May 21, 2018, 08:44
Default
  #3
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Agarhaji,

As Bhargavbharathan points out, one option is to allocate User-Defined Memory (UDM) and save something in the cells containing the DPM parcels at any instant. This could be a single value for the latest parcel to pass through that cell, or you could (using more than one UDM) save average values. You could plot these by contour plots on section planes, etc. It would be a good idea to have a DEFINE_ON_DEMAND function to reset the UDM back to zero everywhere. You will need to be able to access the cell (as defined by a cell index and a cell-thread pointer) from inside the DPM-based UDF: you can use something like this:
Code:
  C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 0) = drag_force;
Or this to calculate and store an average:
Code:
#define CUDM_AV_DRAGCOEFF 0
#define CUDM_VISIT_COUNTER 1
  C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), CUDM_AV_DRAGCOEFF) *= 
    C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), CUDM_VISIT_COUNTER);
  C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), CUDM_AV_DRAGCOEFF) += 
    drag_force;
  C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), CUDM_VISIT_COUNTER) += 1;
  C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), CUDM_AV_DRAGCOEFF) /= 
    C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), CUDM_VISIT_COUNTER);
(By the way, lots of DPM macros have changed names in recent versions, from P_* to TP_*. Check which version you are using. If you're searching the internet for help, look also for P_CELL etc.)

An alternative approach, which I might prefer, would be to use particle-based user-defined memory -- the so-called "scalars" allocated in the UDF tab of the Discrete Phase Model. These are allocated to each parcel, and you can use them like other particle variables to colour the displayed tracks etc. They are numbered from 0 upwards, like cell-based UDM but completely separate.
Code:
  TP_USER_REAL(tp,i) = drag_force;
Good luck!
Ed
obscureed is offline   Reply With Quote

Old   May 25, 2018, 05:07
Thumbs up It works
  #4
New Member
 
Agar Haji
Join Date: May 2018
Posts: 3
Rep Power: 8
agarhaji is on a distinguished road
Hi again.

I tried to use the C_UDMI. I stored drag_force, C_D and it looks like this.

C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 0) = drag_force;
C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 1) = C_D;

I can now choose in GRAPHICS, User-defined memory and plot the variables

Thank you both !

Have a nice day.
agarhaji is offline   Reply With Quote

Old   May 25, 2018, 05:41
Default
  #5
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Great -- well done! To help others, please could you post your working UDF code? (And also tell us which version of Fluent it works in.) Thanks!


I would recommend the particle-based approach as a good alternative.



Ed
obscureed is offline   Reply With Quote

Old   May 25, 2018, 10:19
Thumbs up Store variables in working UDF. Ansys Fluent 18.2
  #6
New Member
 
Agar Haji
Join Date: May 2018
Posts: 3
Rep Power: 8
agarhaji is on a distinguished road
Im running Ansys fluent 18.2

Compiling steps:

Load Fluent --> User-defined functions --> Load UDF --> Build --> Load Mesh-->SET user-defined memory(in my case, 6.) -->Load UDF --> Write Case --> Close fluent and open again and now the UDF is compiled.

For this UDF, I stored 6 variables.
Quote:
#include "udf.h"
#include "dpm_types.h"


DEFINE_DPM_DRAG(drag_force,Re,tp)
{

double C_D, drag_force;
double d_sv, L, W, d_Cl, d_CC, Psi;
d_sv = TP_DIAM(tp); /* Sieve Diameter defined as the injected particle diameter */
L = 0.0115*log(d_sv) + 0.0818;
W = -42.365*pow(d_sv, 2) + 1.5702*d_sv - 0.0012;
d_Cl = W; /* Defining the diameter of the inscriped circle as the with of the particle*/
d_CC = L; /* Defining the diameter of the circumscribed circle as the with of the particle*/
Psi = sqrt(d_Cl / d_CC);
/* Calculating the drag coefficient using Yow's correlation */
C_D= ((15.21 + (10.82 / Psi) - (0.14 / pow(Psi, 2))) / Re) + (13.41 - (10.64 / Psi) - (0.016 / pow(Psi, 2))) / sqrt(Re) - 8.82 + (5.70 / Psi) + (0.23) / pow(Psi, 2);
/* Calculating the dragforce as a dimentionless group */
drag_force = (18 * C_D*Re) / 24;
C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 0) = L;
C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 1) = W;
C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 2) = Psi;
C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 3) = C_D;
C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 4) = drag_force;
C_UDMI( TP_CELL(tp), TP_CELL_THREAD(tp), 5) = Re;


return (drag_force);

}
After the simulation has converged, the variables can be found under GRAPHICS.


- Agar Haji
mCiFlDk likes this.
agarhaji 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
UDF for ANSYS Fluent and Runge Kutta Method cagri.metin.ege Fluent UDF and Scheme Programming 3 January 24, 2020 04:46
Can you help me with a problem in ansys static structural solver? sourabh.porwal Structural Mechanics 0 March 27, 2016 18:07
Ansys SIG$ILL error loth ANSYS 3 December 24, 2015 06:31
The fluent stopped and errors with "Emergency: received SIGHUP signal" yuyuxuan FLUENT 0 December 3, 2013 23:56
UDF to record FLUENT solver variables... mariachi FLUENT 1 February 3, 2010 23:18


All times are GMT -4. The time now is 08:54.