CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

Accessing the species mass fraction for particles data in UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   June 7, 2015, 09:50
Smile Accessing the species mass fraction for particles data in UDF
  #1
New Member
 
New South Wales
Join Date: May 2015
Location: UNSW, NSW, Sydney
Posts: 11
Rep Power: 2
mac_09 is on a distinguished road
Hello all,

I am doing the spray simulation using the DPM modelling with the composition PDF method.

I am trying to access the particles species mass fraction in the UDF.

I know there are MACROS for particles like:
P_MASS (p) = particles mass
P_T(p) = particles temperature

How to access the species mass fraction for the particles?

Thanks in advanced.

Regards:
Chishty
mac_09 is offline   Reply With Quote

Old   June 20, 2015, 11:47
Default
  #2
New Member
 
Amirsaman Farrokhpanah
Join Date: Dec 2010
Location: University of Toronto
Posts: 7
Rep Power: 6
siramirsaman is on a distinguished road
TP_COMPONENT_I(p,is) is the macro that gives you mass fraction inside each particle.

I will add an example here on how to use it:

int is;
int nc = TP_N_COMPONENTS(p); /* number of particle components */
printf("\n######");
for (is = 0; is < nc; is++)
{
int gas_index = TP_COMPONENT_INDEX_I(p,is); /* index of vaporizing component in the gas phase */
printf(" gas_index=%d is=%d TP_COMPONENT_I=%e ",gas_index,is,TP_COMPONENT_I(p,is));
}
printf("#######$\n");

To look in closely,

TP_N_COMPONENTS(p) gives you the total number of components inside each particle.

TP_COMPONENT_INDEX_I(p,is) gives gas index. if the component is not meant to evaporate, this gives -1.

and TP_COMPONENT_I(p,is) actually gives you the mass fraction.

Last edited by siramirsaman; June 20, 2015 at 14:56.
siramirsaman is offline   Reply With Quote

Old   June 21, 2015, 01:47
Default
  #3
New Member
 
New South Wales
Join Date: May 2015
Location: UNSW, NSW, Sydney
Posts: 11
Rep Power: 2
mac_09 is on a distinguished road
Hello Amirsaman,

Thanks for your reply.
I got this error when I tired to compile my UDF

qrad_source.c:18: error: 'Particle' has no member named 'component'

Here is my UDF:

#include "udf.h"
#include "pdf_transport.h"
#include "dpm.h"
#include "mem.h"
#include "materials.h"
FILE *fp;
DEFINE_SOURCE(rad_source,c,t,dS,eqn)
{
Particle *p;
int id_o2=0;
/***************************************/
Material *mat = THREAD_MATERIAL(t); /* This segment determines the species index number */
id_o2 = mixture_specie_index(mat, "o2");
/**************************************/
begin_particle_cell_loop(p,c,t)
{
fp = fopen("check.dat", "a");
fprintf(fp,"%g\t%g\t%g\t%g\t\n",CURRENT_TIME,C_YI( c, t, id_o2),TP_COMPONENT_I(p,id_o2));
fclose(fp);
}
end_particle_cell_loop(p,c,t)

return 0;
}

Is this "TP_COMPONENT_I(p,is)" hidden in some libraries?
I am using FLUENT 14.5.

Thanks again for your time and help.

Regards:
Chishty
mac_09 is offline   Reply With Quote

Old   June 21, 2015, 10:54
Default
  #4
New Member
 
Amirsaman Farrokhpanah
Join Date: Dec 2010
Location: University of Toronto
Posts: 7
Rep Power: 6
siramirsaman is on a distinguished road
you need to use this in one of DPM UDF codes where particle is inputted among function inputs, like this DPM code where "p" is inputted to the function:

DEFINE_DPM_PROPERTY(coal_cp,c,t,p,T)
{
real mp0= P_INIT_MASS(p);
real mp = P_MASS(p);
real cf = P_CF(p); /*char fraction */
real vf = P_VF(p); /* volatiles fraction */
real af = 1. - P_VF(p) - P_CF(p); /* ash fraction */
real Cp = 2000*af + 1100*vf + 1300*cf;
p->enthalpy = Cp*(T-T_REF);
return Cp;
}


I am guessing in your code, the line where you define "Particle *p", just creates a pointer that is meant to point to a particle structure. However this pointer is never assigned to an actual particle and hence is never initialized. So you need to utilize it in DPM UDFs, where like the example above, the particle pointer is already initialized as an input to the function.

try the function like this:


DEFINE_DPM_PROPERTY(viscosity,c,t,p,T)
{

int is;
int nc = TP_N_COMPONENTS(p); /* number of particle components */
printf("\n######");
for (is = 0; is < nc; is++)
{
int gas_index = TP_COMPONENT_INDEX_I(p,is); /* index of vaporizing component in the gas phase */
printf(" gas_index=%d is=%d TP_COMPONENT_I=%e ",gas_index,is,TP_COMPONENT_I(p,is));
}
printf("#######$\n");

return (0.001);
}


Compile the function above and use it in Materials tab to assign the viscosity of the mixture component "Particle Mixture", or the viscosity of one the components that are inside each particle.
siramirsaman is offline   Reply With Quote

Old   June 21, 2015, 11:57
Default
  #5
New Member
 
Amirsaman Farrokhpanah
Join Date: Dec 2010
Location: University of Toronto
Posts: 7
Rep Power: 6
siramirsaman is on a distinguished road
I also got the feeling that you are trying to adjust source terms inside domain due to particle existence. If that is the case, trying having a look at fluent examples for:

DEFINE_DPM_HEAT_MASS (name, p, C_p, hgas, hvap, cvap_surf, Z, dydt, dzdt)
or
DEFINE_DPM_SOURCE (name, c, t, S, strength, p)
siramirsaman is offline   Reply With Quote

Old   June 21, 2015, 21:27
Default
  #6
New Member
 
New South Wales
Join Date: May 2015
Location: UNSW, NSW, Sydney
Posts: 11
Rep Power: 2
mac_09 is on a distinguished road
Quote:
Originally Posted by siramirsaman View Post
I also got the feeling that you are trying to adjust source terms inside domain due to particle existence. If that is the case, trying having a look at fluent examples for:

DEFINE_DPM_HEAT_MASS (name, p, C_p, hgas, hvap, cvap_surf, Z, dydt, dzdt)
or
DEFINE_DPM_SOURCE (name, c, t, S, strength, p)
I am trying to couple the DOM radiation model with the TPDF model for my diesel spray soot simulation in FLUENT.
The DOM energy coupling with the TPDF is not available in FLUENT, as the DOM solves the radiation source term at the CFD resolution and the TPDF solves the energy equation on the particle side.

So, I am trying to give the negative of radiation source term in the energy equation.

For the complete TRI, I need to update the absorption co-efficient using the particle data. For this, I need the mass fraction of soot, CH4 & CO2, but the problem is I did not find any macro for the species mass fraction of the particles.

I tried to print TP_COMPONENT_I(p,8) where "8" is the location of oxygen in my chemical mechanism, but it does not work.
mac_09 is offline   Reply With Quote

Old   June 22, 2015, 16:23
Default
  #7
New Member
 
Amirsaman Farrokhpanah
Join Date: Dec 2010
Location: University of Toronto
Posts: 7
Rep Power: 6
siramirsaman is on a distinguished road
Unfortunately I am not familiar with SOOT simulations. A couple of ideas, and perhaps maybe someone else could also help.

I do not think it will be possible to access particles inside fluid domain macros. You will be able to work with mass fractions released from particles into each cell, but I am not sure if the particles in each cell can be accessed from macros designed for fluid part.

I have a suggestion that might work for you, done it in the past, needs a little bit of caution.

So you need to access particle data inside a macro that is not designed for particles. I suggest you use two macros and a couple of global variables.

One macro for fluid part, one macro for particles and global variables to establish the connection between these two.

In the particle macro, you can access particle info's. Better than that, you can have a global variable for particles, let's say an array of pointers that are going to point to particles, like Particle * Array_p[1000]. I am not sure if this is possible.

If you could create a global pointer array like that, then you can use particle UDF macros to copy available particle pointers to the global array. These particles can then be accesses in the macro inside fluid domain.

The main challenge will be tracking particles that are dead and also to make sure you do not overwrtie particle addresses in your global array.

All this said, perhaps there might be a much easier way out there!
siramirsaman is offline   Reply With Quote

Old   June 22, 2015, 22:24
Default
  #8
New Member
 
New South Wales
Join Date: May 2015
Location: UNSW, NSW, Sydney
Posts: 11
Rep Power: 2
mac_09 is on a distinguished road
Thanks for your time and suggestions.

I will look into it.

But just one quick question, is there any MACRO assigned to access the species mass fraction of particles whether in DEFINE_SOURCE or DPM MACRO's?

If it is, than in which MACRO?

I will access that and safe into the UDM, so I can access it anywhere.

mac_09 is offline   Reply With Quote

Old   June 22, 2015, 23:44
Default
  #9
New Member
 
Amirsaman Farrokhpanah
Join Date: Dec 2010
Location: University of Toronto
Posts: 7
Rep Power: 6
siramirsaman is on a distinguished road
In the header file, dpm_types.h, the function has been defined as

#define TP_COMPONENT_I(tp,i) (tp->component.state[i])

which is accessing the component.state member in the "tp" particle. component.state[i] is the mass fraction of each component that you are looking for.

I think even by modifying macros, you will still miss the link to access pointer to particles that have already been injected inside the domain.

All DPM macros like the one below are inputted particle pointer as an input:

#define DEFINE_DPM_SOURCE(name, c, t, S, strength, p) \
void name(cell_t c, Thread *t, dpms_t *S, real strength, Tracked_Particle *p)
siramirsaman is offline   Reply With Quote

Reply

Tags
composition pdf method, dpm, macros, udf and programming

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem of simulating of small droplet with radius of 2mm liguifan OpenFOAM Running, Solving & CFD 5 June 3, 2014 02:53
Species Mole and Mass Fraction Macro combustion FLUENT 15 October 29, 2013 04:57
Low Mixing time Problem Mavier CFX 5 April 29, 2013 00:00
UDF for species mass fractions MRR FLUENT 0 December 29, 2005 08:14
Gradient of species mass fraction zhou FLUENT 0 July 19, 2004 17:36


All times are GMT -4. The time now is 09:04.