|
[Sponsors] |
Accessing the species mass fraction for particles data in UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 7, 2015, 10:50 |
Accessing the species mass fraction for particles data in UDF
|
#1 |
New Member
Luleå tekniska universitet
Join Date: May 2015
Location: LTU, Luleå, Sweden
Posts: 11
Rep Power: 11 |
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 |
|
June 20, 2015, 12:47 |
|
#2 |
New Member
Join Date: Dec 2010
Posts: 15
Rep Power: 16 |
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 15:56. |
|
June 21, 2015, 02:47 |
|
#3 |
New Member
Luleå tekniska universitet
Join Date: May 2015
Location: LTU, Luleå, Sweden
Posts: 11
Rep Power: 11 |
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 |
|
June 21, 2015, 11:54 |
|
#4 |
New Member
Join Date: Dec 2010
Posts: 15
Rep Power: 16 |
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. |
|
June 21, 2015, 12:57 |
|
#5 |
New Member
Join Date: Dec 2010
Posts: 15
Rep Power: 16 |
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) |
|
June 21, 2015, 22:27 |
|
#6 | |
New Member
Luleå tekniska universitet
Join Date: May 2015
Location: LTU, Luleå, Sweden
Posts: 11
Rep Power: 11 |
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. |
||
June 22, 2015, 17:23 |
|
#7 |
New Member
Join Date: Dec 2010
Posts: 15
Rep Power: 16 |
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! |
|
June 22, 2015, 23:24 |
|
#8 |
New Member
Luleå tekniska universitet
Join Date: May 2015
Location: LTU, Luleå, Sweden
Posts: 11
Rep Power: 11 |
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. |
|
June 23, 2015, 00:44 |
|
#9 |
New Member
Join Date: Dec 2010
Posts: 15
Rep Power: 16 |
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) |
|
July 10, 2016, 06:38 |
|
#10 | |
New Member
Yin Xu
Join Date: Aug 2015
Posts: 1
Rep Power: 0 |
Quote:
|
||
January 10, 2017, 01:31 |
|
#11 |
Senior Member
Join Date: Jun 2014
Location: Taiwan
Posts: 100
Rep Power: 12 |
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] ? |
|
January 10, 2017, 01:39 |
|
#12 |
New Member
Join Date: Dec 2010
Posts: 15
Rep Power: 16 |
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"] / |
|
January 10, 2017, 04:00 |
|
#13 |
Senior Member
Join Date: Jun 2014
Location: Taiwan
Posts: 100
Rep Power: 12 |
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? @@ |
|
January 11, 2017, 00:25 |
|
#14 |
New Member
Join Date: Dec 2010
Posts: 15
Rep Power: 16 |
I am not sure if I follow this correctly, perhaps this might help. In your gas mixture (gas surrounding your particles) the average molecular weight can be calculated using the following loop over all species:
Code:
int ns; Material *sp; Material *gas_mix = THREAD_MATERIAL(DPM_THREAD(t0, p)); mixture_species_loop(gas_mix, sp, ns) { molwt_bulk += c->yi[ns] / MATERIAL_PROP(sp, PROP_mwi); /* average molecular weight */ } and as you mentioned, for the vaporizing components inside the particles, the following loop is used: Code:
for (is = 0; is < nc; is++) { int gas_index = TP_COMPONENT_INDEX_I(p,is); /* index of vaporizing component in the gas phase */ if (gas_index >= 0) { /* 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]; } } Now the averaging I think is done as follows and it is called harmonic mean: So the variable that is confusing I think should be . Here, is the average molar mass and is the mass fractions. |
|
January 11, 2017, 07:28 |
|
#15 |
Senior Member
Join Date: Jun 2014
Location: Taiwan
Posts: 100
Rep Power: 12 |
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". |
|
August 9, 2017, 14:33 |
|
#16 | |
New Member
Martin
Join Date: Apr 2017
Location: Germany
Posts: 26
Rep Power: 9 |
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 |
||
August 9, 2017, 14:36 |
|
#17 |
New Member
Martin
Join Date: Apr 2017
Location: Germany
Posts: 26
Rep Power: 9 |
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] |
|
August 9, 2017, 21:15 |
|
#18 |
Senior Member
Join Date: Jun 2014
Location: Taiwan
Posts: 100
Rep Power: 12 |
It seems MATERIAL_PROP(sp,PROP_mwi) is for gas species, and solver_par.molWeight[gas_index] is for species in a particle ?
|
|
Tags |
composition pdf method, dpm, macros, udf and programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Species Mole and Mass Fraction Macro | combustion | FLUENT | 18 | February 5, 2024 13:23 |
Gradient of species mass fraction | zhou | FLUENT | 1 | March 14, 2020 07:28 |
Problem of simulating of small droplet with radius of 2mm | liguifan | OpenFOAM Running, Solving & CFD | 5 | June 3, 2014 03:53 |
Low Mixing time Problem | Mavier | CFX | 5 | April 29, 2013 01:00 |
UDF for species mass fractions | MRR | FLUENT | 0 | December 29, 2005 08:14 |