Determining the amount of time fluid spends in high shear regions


For certain applications (e.g., liquid-liquid multiphase reactors, bioreactors), the amount of time the fluid spends in the high strain regions near impellers and baffles is a key parameter. The following resolution presents a procedure to determine the amount of time the fluid spends in regions of different strain levels.
Starting with a converged steady solution, for example a mixing simulation using the SRF or MRF models. Compile the following UDF and execute it using the EXECUTE ON DEMAND function in Fluent (Define > User Defined > Execute on Demand). The UDF will write two columns of data to a file. The first column corresponds to the residence time and the second to the magnitude of the strain rate.

To obtain the distribution of residence time in the different strain levels, bin the strain rate values into discrete ranges (bins) and sum the corresponding residence time values in each bin. This will result in a histogram with strain rate on the x-axis and residence time on the y-axis.

Note that the following TUI command must be set so that the strain rate will be accessible from the UDF.

solve/set/expert
"Keep temporary memory from being freed?" Yes

An example distribution is presented here

<a target=_blank href="http://www.fluentusers.com/support/solutions/1072/strain_rtd.pdf">http://www.fluentusers.com/support/solutions/1072/strain_rtd.pdf</a>http://www.fluentusers.com/support/solutions/1072/strain_rtd.pdf

The data file created with the UDF presented here was further processed to create the figure using the Matlab/Octave script file below.


-------------------------------------------------------------------------------------------------------------------------
Fluent UDF:

#include "udf.h"

#define DEBUG FALSE

DEFINE_ON_DEMAND(mass_flow)
{
Domain *d = Get_Domain(1);
FILE *output;
face_t f;
cell_t c;
Thread *t;
Thread *tf;
int n;
real cflux = 0.0;
real myflux, volume;
real tau, density;
real strain_rate;

output = fopen("cell_flow_rates.out","w");

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
c_face_loop(c,t,n)
{
f=C_FACE(c,t,n);
tf=C_FACE_THREAD(c,t,n);
myflux = F_FLUX(f,tf);
if (F_C0(f,tf) == c)
{myflux=-myflux;}
#if DEBUG
fprintf(output, "cell %i, n %i, cell flux %en",c,n,myflux);
#endif
if (myflux > 0.0)
cflux += myflux;
}

volume = C_VOLUME(c,t);
density = C_R(c,t);
cflux = pow(cflux*cflux,0.5);
strain_rate = C_STRAIN_RATE_MAG(c,t);
if (cflux == 0.0)
tau = 0;
else
tau = volume*density/cflux;

#if DEBUG
fprintf(output, "n Net cell flux = %e n",cflux);
fprintf(output, "Cell volume = %e n",volume);
fprintf(output, "Density = %e n",density);
fprintf(output, "Residence time = %e s n",tau);
fprintf(output, "Strain rate = %e sn n",strain_rate);
#else
fprintf(output, "%e %e n",tau,strain_rate);
#endif
cflux=0.0;

}
end_c_loop(c,t)

fclose(output);
}
}

-------------------------------------------------------------------------------------
Script file used to create histogram (written for Matlab or Octave):

clear
load cell_flow_rates.out

num_bins = 100;
time = cell_flow_rates(:,1);
strain = cell_flow_rates(:,2);

max_strain = max(strain);
min_strain = min(strain);
[S,I] = sort(strain);
bin_width = (max_strain - min_strain)/num_bins;

for j = 1:num_bins
bin(j) = min_strain+(j-1)*bin_width+bin_width/2;
end

for j = 1:num_bins-1
bin_boundary(j) = min_strain + j*bin_width;
end
bin_boundary(num_bins) = max_strain;

num_cells = length(time);
residence_time = zeros(1,num_bins);
bin_count = 1;

for j = 1:num_cells
upper_limit = bin_boundary(bin_count);
if S(j) < upper_limit
residence_time(bin_count) = residence_time(bin_count) + time(I(j));
else
bin_count = bin_count + 1;
end
end

bar(bin,residence_time); title("Strain RTD")
xlabel("Strain"); ylabel("Residence Time, s");
% axis([0 1000 0 35]);
replot





Show Form
No comments yet. Be the first to add a comment!