Accessing the species mass fraction for particles data in UDF
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 |
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. |
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 |
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. |
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) |
Quote:
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. |
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! ;) |
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. :) |
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) |
Quote:
|
Hi~
I found this in the example of DEFINE_DPM_HEAT_MASS : real molwt[MAX_SPE_EQNS]; /* molecular weight of gas species */ real molwt_bulk = 0.; /* average molecular weight in bulk gas */ molwt[ns] = MATERIAL_PROP(sp,PROP_mwi); /* molecular weight of gas species */ molwt_bulk += c->yi[ns] / molwt[ns]; /* average molecular weight */ /* bulk gas concentration (ideal gas) */ real cvap_bulk = c->pressure / UNIVERSAL_GAS_CONSTANT / c->temp * c->yi[gas_index] / molwt_bulk / solver_par.molWeight[gas_index]; and this in DEFINE_DPM_VP_EQUILIB : real molwt_cond = 0.; /* reciprocal molecular weight of the particle */ /* the molecular weight of particle material */ molwt[gas_index] = MATERIAL_PROP(MIXTURE_COMPONENT(gas_mix,gas_index) ,PROP_mwi); molwt_cond += TP_COMPONENT_I(p,is) / molwt[gas_index]; /* condensed component molefraction */ real xi_cond = TP_COMPONENT_I(p,is)/(molwt[gas_index]*molwt_cond); Q1. Do "c->yi[ns]" and "TP_COMPONENT_I(p,is)" both mean mass fraction ? Q2. If the answer of Q1 is Yes, why molwt_bulk += c->yi[ns] / molwt[ns] ? |
Both are, but in different places. The first one is the mass fraction inside each cell ("c"), so lets say you have gas mixtures like water vapour, air etc that shows the fraction of each gs species. Hence it had to be divided by the average molecular weight of the mixture. This one so goes for the finite volume solver.
The second is the mass fraction inside each injected drop. So if you have water and other compounds, gives you the mass fraction there. This one is for the discrete phase model. [QUOTE=SJSW;632653] Q1. Do "c->yi[ns]" and "TP_COMPONENT_I(p,is)" both mean mass fraction ? Q2. If the answer of Q1 is Yes, why molwt_bulk += c->yi[ns][COLOR="Red"] / |
The unit of "molwt_cond" could be mole/kg, according to the description "reciprocal molecular weight of the particle".
Then molwt_cond += TP_COMPONENT_I(p,is) / molwt[gas_index]. However, The unit of "molwt_bulk" could be kg/mole, according to the description "average molecular weight in bulk gas". Then why molwt_bulk += c->yi[ns] / molwt[ns] ? Does "molwt[gas_index] = MATERIAL_PROP(MIXTURE_COMPONENT(gas_mix,gas_index) ,PROP_mwi)" mean kg/mole, mole/kg or something else? @@ |
If there is a mixture composing of A and B,
for mass balance, unit :kg m_total=ma+mb for mole balance, m_total/W_total=ma/wa+mb/wb =>1/W_total=ma/m_total*1/wa+mb/m_total*1/wb W_total is average molecular weight. 1/W_total is reciprocal molecular weight of the particle. Then, The unit of "molwt_cond" could be mole/kg, according to the description "reciprocal molecular weight of the particle". I can see why "molwt_cond += TP_COMPONENT_I(p,is) / molwt[gas_index]". However, The unit of "molwt_bulk" could be kg/mole, according to the description "average molecular weight in bulk gas". Then why "molwt_bulk += c->yi[ns] / molwt[ns]", but not "molwt_bulk += c->yi[ns] / molwt[ns];" "molwt_bulk=1.0/molwt_bulk" ? and in the example of DEFINE_DPM_HEAT_MASS: 「 /* bulk gas concentration (ideal gas) */ real cvap_bulk = c->pressure / UNIVERSAL_GAS_CONSTANT / c->temp * c->yi[gas_index] / molwt_bulk / solver_par.molWeight[gas_index]; 」 this "molwt_bulk" seems -------- Wait, OK...I see what the answer is: molwt_bulk is not "average molecular weight in bulk gas", it is "total amount of moles". |
Quote:
ANSYS just did not and reverse. They just left out that step and it resolves in the end - just try it... The line for cvap_bulk = ... uses ideal gas law to calculate the concentration, where with with x_i as the mole fraction. And the mole fraction can be calculated via which is (For Germans) even the name molecular weight is irritating as it possibly should be called molar weight. #fluent #dpm #heat mass transfer #UDF #molecular weight #molwt_bulk |
An additional question: does anyone have an idea, why the once use
MATERIAL_PROP(sp,PROP_mwi) and the other time solver_par.molWeight[gas_index] |
It seems MATERIAL_PROP(sp,PROP_mwi) is for gas species, and solver_par.molWeight[gas_index] is for species in a particle ?
|
All times are GMT -4. The time now is 02:29. |