|
[Sponsors] |
February 12, 2013, 19:09 |
Species Mole and Mass Fraction Macro
|
#1 |
New Member
Kaveh
Join Date: Aug 2011
Posts: 6
Rep Power: 15 |
Hi,
Fluent 14 has a macro for looking up mole and mass fractions of species for non-premixed combustion cases: Pdf_XY(cell c, thread *t, x, y) I am trying to write a source term for a UDS to duplicate the Brookes and Moss two equation soot model that is already built into fluent. I will later modify my source terms to make a new 2-eqn model. My problem is that when I don't know how the species are indexed in fluent. Is the indexing based on the flamelet library or based on the pdf-mixture species list? I have attached my code for one of the source terms. Thanks for your help. #include "udf.h" #include "pdf_props.h" #include "pdf_table.h" #include "mem.h" #include "materials.h" /*********Constant Declarations*************************************/ #define c_alph 54.0 /* Units: 1/s */ #define N_avog 6.022045e+26 /* 1/kmol */ #define c_bet 1.0 /* no units */ #define rho_soot 1800.0 /* kg/m3 */ #define T_alph 21000.0 /* activation temperature of soot inception in K */ #define N_norm 1.0e+15 /* Moss-Brookes model: normalizing parameter */ #define l 1.0 /* l indicates the particle nucleation sensitivity to Pressure: defined as 1.0 for now */ #define PI 3.14159265358979324 /* Pi as a constant...alternatively pi=4.0*atan(1.0) */ #define SpNo 20 /* The number of species in the mechanism file: should be adjusted according to the mechanism */ #define Species 22 /* This is the index for the species of interest (C2H2 in this case) */ /*********End Constant Declarations*********************************/ DEFINE_SOURCE(n_sourceterm, c, ct, dS, eqn) { /*********Variable Declarations*************************************/ double dNdT, dp, X_C2H2, T, P, rho_cell, M, N, Ysoot, bNuc, R; double x[SpNo], y[SpNo]; /* x is the array for species mole fractions and y is the array for mass fractions */ int id_c2h2; /*********End Variable Declarations*********************************/ /*********Variable Assignments**************************************/ Material *mat = THREAD_MATERIAL(ct); id_c2h2 = mixture_specie_index(mat, "c2h2"); Pdf_XY(c, ct, x, y); /* Calling the species mole and mass fractions for this cell */ X_C2H2 = x[id_c2h2]; /* arbitrarily defined for now */ T = C_T(c, ct); /* Temperature at the cell */ if (c == 400) Message("Temp is %g\n, species %", T); P = C_P(c, ct); /* Cell Presdsure */ if (c == 400) Message("Press is %g\n, ", P); rho_cell = C_R(c, ct); /* Cell average Density */ R = UNIVERSAL_GAS_CONSTANT; /* Universal gas constant is called with the built-in Fluent Macro */ Ysoot = C_UDSI(c, ct, 0); /* Calling soot mass fraction from m_sourceterm scalar */ if (c == 400) Message("Ysoot is %g\n, ", Ysoot); bNuc = C_UDSI(c, ct, 1); /* Calling soot number density from n_sourceterm scalar */ if (c == 400) Message("bNuc is %g\n, ", bNuc); /**********End Variable Assignments*********************************/ /**********Start Calculations************************************** */ M = rho_cell * Ysoot; N = bNuc * rho_cell * N_norm; dp = pow(((6.0 * M)/(PI * N * rho_soot)), (1.0/3.0)); dNdT = c_alph * N_avog * pow(((X_C2H2 * P)/(R * T)), l) * exp(-1.0 * T_alph / T) - c_bet * pow(((24.0 * R * T) / ( rho_soot * N_avog)), 0.5) * sqrt(dp) * pow(N, 2); if (c == 400) Message("dNdT is %g\n, ", dNdT); /**********End of Calculations**************************************/ return (dNdT / N_norm); } |
|
May 4, 2013, 02:35 |
Edit the constants of moss brooks soot model
|
#2 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
I desperately want to edit the constants of moss brooks soot model. But till now I did not get any idea. Is it possible to do such by any way? If possible please tell me.
|
|
May 6, 2013, 18:17 |
|
#3 |
New Member
Kaveh
Join Date: Aug 2011
Posts: 6
Rep Power: 15 |
Hi Prakash,
The answer is No and Yes. No: you cannot modify the constants in the Fluent solver. There is no option to go that route. Yes: you can write a UDF for a two-eqn model and manipulate the coefficients as you see fit. |
|
May 8, 2013, 06:05 |
UDF Soot
|
#4 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Thank you sir for your kind response.
Yes I want to create duplicate source term equations. In my result I am having c2h2. Any way I want to know how can I call temperature, pressure and specially mass fraction of C2H2 (Xprec, Xsgs) by udf. Also I want to know how can I call cell density for calculation of M and N. Can you plz help me? |
|
May 23, 2013, 03:26 |
udf soot
|
#5 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Sir Kaveh,
The same problem I am too facing. I am also using steady flamelet model. I got C2H2 in flamelet mixture. I also want to know what is the value of 'i' (index) so that I can use C_YI (c,t,i). I have number of species under pdf mixture and below it again number of species under flamelet mixture. So how can I count for species index? Should I start for pdf mixture or what??? plz help me |
|
May 23, 2013, 13:29 |
|
#6 |
New Member
Kaveh
Join Date: Aug 2011
Posts: 6
Rep Power: 15 |
Hi Prakash,
Who is "Sir" Kaveh? I found out that you can find the species index by putting the following segment in your code: /***************************************/ Material *mat = THREAD_MATERIAL(ct); /* This segment determines the species index number */ id_c2h2 = mixture_specie_index(mat, "c2h2"); /**************************************/ The example above is for acetylene. You can find any species index in the same manner. So, id_c2h2 is the variable that contains the species index for c2h2 which is an integer. I hope this was useful. |
|
May 24, 2013, 04:02 |
udf ssot
|
#7 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Thank you for your kind response.
|
|
May 28, 2013, 06:49 |
|
#8 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Sir,
When I am interpreting it, it shows the following error. Error: C:/Users/AMITAD~1/AppData/Local/Temp/udf soot 1_2.c.1.c: line 63: function "mixture_specie_index" not found (pc=87). Error: C:/Users/AMITAD~1/AppData/Local/Temp/udf soot 1_2.c.1.c: line 63: function "Pdf_XY" not found (pc=101). Error: C:/Users/AMITAD~1/AppData/Local/Temp/udf soot 1_2.c.1.c: line 63: function "CX_Message" not found (pc=150). Error: C:/Users/AMITAD~1/AppData/Local/Temp/udf soot 1_2.c.1.c: line 63: function "CX_Message" not found (pc=186). Error: C:/Users/AMITAD~1/AppData/Local/Temp/udf soot 1_2.c.1.c: line 63: function "CX_Message" not found (pc=246). Error: C:/Users/AMITAD~1/AppData/Local/Temp/udf soot 1_2.c.1.c: line 63: function "CX_Message" not found (pc=282). Error: C:/Users/AMITAD~1/AppData/Local/Temp/udf soot 1_2.c.1.c: line 63: function "CX_Message" not found (pc=405). |
|
May 28, 2013, 15:15 |
|
#9 |
New Member
Kaveh
Join Date: Aug 2011
Posts: 6
Rep Power: 15 |
Have you included the proper libraries?
#include "materials.h" #include "pdf_table.h" |
|
May 29, 2013, 06:50 |
udf soot
|
#10 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Sir,
I included following libraries. #include "udf.h" #include "pdf_props.h" #include "pdf_table.h" #include "mem.h" #include "materials.h" |
|
May 29, 2013, 12:12 |
|
#11 |
New Member
Kaveh
Join Date: Aug 2011
Posts: 6
Rep Power: 15 |
can you post your code here?
|
|
June 8, 2013, 05:29 |
udf soot
|
#12 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Sorry sir for late response. I was out of my city for few days. Actually I am using the UDF written by you on this forum. Again I was doing a great mistake that, I was interpreting the UDF in ANSYS 13.0 but now previous error is not there because now I am using Ansys 14.0.
But some new error came. cpp -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/src" -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/cortex/src" -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/client/src" -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/multiport/src" -I. - UDFCONFIG_H="<C:/Users/WINDOW~1/AppData/Local/Temp/udfconfig-node0.h>" "C:/Users/WINDOW~1/AppData/Local/Temp/udf soot 1_2.c.0.c" Error: C:\\PROGRA~1\\ANSYS Inc\\v140\\fluent\\fluent14.0.0/src/pdf_table.h: line 141: ran off top of typedef queue (300). cpp -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/src" -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/cortex/src" -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/client/src" -I"C:\PROGRA~1\ANSYS Inc\v140\fluent\fluent14.0.0/multiport/src" -I. - UDFCONFIG_H="<C:/Users/WINDOW~1/AppData/Local/Temp/udfconfig-node1.h>" "C:/Users/WINDOW~1/AppData/Local/Temp/udf soot 1_2.c.1.c" Error: C:\\PROGRA~1\\ANSYS Inc\\v140\\fluent\\fluent14.0.0/src/pdf_table.h: line 141: ran off top of typedef queue (300). |
|
June 8, 2013, 05:54 |
udf soot
|
#13 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
The red marks I cannot get anythging from udf HELP
I found in udf help it is written like Bold letter I have written. Sir plz can you help me regarding this metter #include "udf.h" #include "pdf_props.h" #include "pdf_table.h" #include "mem.h" #include "materials.h" /*********Constant Declarations*************************************/ #define c_alph 54.0 /* Units: 1/s */ #define N_avog 6.022045e+26 /* 1/kmol */ #define c_bet 1.0 /* no units */ #define rho_soot 1800.0 /* kg/m3 */ #define T_alph 21000.0 /* activation temperature of soot inception in K */ #define N_norm 1.0e+15 /* Moss-Brookes model: normalizing parameter */ #define l 1.0 /* l indicates the particle nucleation sensitivity to Pressure: defined as 1.0 for now */ #define PI 3.14159265358979324 /* Pi as a constant...alternatively pi=4.0*atan(1.0) */ #define SpNo 20 /* The number of species in the mechanism file: should be adjusted according to the mechanism */ #define Species 22 /* This is the index for the species of interest (C2H2 in this case) */ /*********End Constant Declarations*********************************/ DEFINE_SOURCE(n_sourceterm, c, ct, dS, eqn) { /*********Variable Declarations*************************************/ double dNdT, dp, X_C2H2, T, P, rho_cell, M, N, Ysoot, bNuc, R; double x[SpNo], y[SpNo]; /* x is the array for species mole fractions and y is the array for mass fractions */ int id_c2h2; ic2h2 /*********End Variable Declarations*********************************/ /*********Variable Assignments**************************************/ Material *mat = THREAD_MATERIAL(ct); Material *m = THREAD_MATERIAL(t); id_c2h2 = mixture_specie_index(mat, "c2h2"); ic2h2 = mixture_specie_index(m, "c2h2"); Pdf_XY(c, ct, x, y); Pdf_XY(c, t, x, y);/* Calling the species mole and mass fractions for this cell */ X_C2H2 = x[id_c2h2]; X_C2H2 = xi[ic2h2]; /* arbitrarily defined for now */ T = C_T(c, ct); T = C_T(c, t)/* Temperature at the cell */ if (c == 400) Message("Temp is %g\n, species %", T); P = C_P(c, ct); P = C_P(c, t)/* Cell Presdsure */ if (c == 400) Message("Press is %g\n, ", P); rho_cell = C_R(c, ct); rho_cell = C_R(c, t);/* Cell average Density */ R = UNIVERSAL_GAS_CONSTANT; /* Universal gas constant is called with the built-in Fluent Macro */ Ysoot = C_UDSI(c, ct, 0); Ysoot = C_UDSI(c, t, 0);/* Calling soot mass fraction from m_sourceterm scalar */ if (c == 400) Message("Ysoot is %g\n, ", Ysoot); bNuc = C_UDSI(c, ct, 1); bNuc = C_UDSI(c, t, 1);/* Calling soot number density from n_sourceterm scalar */ if (c == 400) Message("bNuc is %g\n, ", bNuc); /**********End Variable Assignments*********************************/ /**********Start Calculations************************************** */ M = rho_cell * Ysoot; N = bNuc * rho_cell * N_norm; dp = pow(((6.0 * M)/(PI * N * rho_soot)), (1.0/3.0)); dNdT = c_alph * N_avog * pow(((X_C2H2 * P)/(R * T)), l) * exp(-1.0 * T_alph / T) - c_bet * pow(((24.0 * R * T) / ( rho_soot * N_avog)), 0.5) * sqrt(dp) * pow(N, 2); if (c == 400) Message("dNdT is %g\n, ", dNdT); /**********End of Calculations**************************************/ return (dNdT / N_norm); } |
|
June 18, 2013, 11:15 |
udf soot
|
#14 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Sir I am posting my full udf, which is not running.
Plz help me. #include "udf.h" #include "pdf_props.h" #include "pdf_table.h" #include "mem.h" #include "materials.h" /*********Constant Declarations*************************************/ #define c_alph 54.0 /* Units: 1/s */ #define N_avog 6.022045e+26 /* 1/kmol */ #define c_bet 1.0 /* no units */ #define rho_soot 1800.0 /* kg/m3 */ #define T_alph 21000.0 /* activation temperature of soot inception in K */ #define N_norm 1.0e+15 /* Moss-Brookes model: normalizing parameter */ #define l 1.0 /* l indicates the particle nucleation sensitivity to Pressure: defined as 1.0 for now */ #define PI 3.14159265358979324 /* Pi as a constant...alternatively pi=4.0*atan(1.0) */ #define SpNo 20 /* The number of species in the mechanism file: should be adjusted according to the mechanism */ #define Species 22 /* This is the index for the species of interest (C2H2 in this case) */ #define Mp 144.0 /* mass of an incipent soot particle. here taken for C12 */ #define c_gama 11700.0 /* surface growth rate scaling factor */ #define T_gama 12100.0 /* activation temperature of surface growth rate */ #define m 1.0 #define n 1.0 #define c_oxid 0.015 #define c_omega 105.8125 #define eta_coll 0.04 /*********End Constant Declarations*********************************/ DEFINE_SOURCE(n_sourceterm, c, ct, dS, eqn) { /*********Variable Declarations*************************************/ double dNdT, dp, X_C2H2, X_OH, T, P, rho_cell, M, N, Ysoot, bNuc, R; double x[SpNo], y[SpNo]; /* x is the array for species mole fractions and y is the array for mass fractions */ int id_c2h2; int id_oh /*********End Variable Declarations*********************************/ /*********Variable Assignments**************************************/ Material *mat = THREAD_MATERIAL(ct); id_c2h2 = mixture_specie_index(mat, "c2h2"); id_oh = mixture_species_index(mat, "oh"); Pdf_XY(c, ct, x, y); /* Calling the species mole and mass fractions for this cell */ X_C2H2 = x[id_c2h2]; /* arbitrarily defined for now */ X_OH = x[id_oh]; T = C_T(c, ct); /* Temperature at the cell */ if (c == 400) Message("Temp is %g\n, species %", T); P = C_P(c, ct); /* Cell Presdsure */ if (c == 400) Message("Press is %g\n, ", P); rho_cell = C_R(c, ct); /* Cell average Density */ R = UNIVERSAL_GAS_CONSTANT; /* Universal gas constant is called with the built-in Fluent Macro */ Ysoot = C_UDSI(c, ct, 0); /* Calling soot mass fraction from m_sourceterm scalar */ if (c == 400) Message("Ysoot is %g\n, ", Ysoot); bNuc = C_UDSI(c, ct, 1); /* Calling soot number density from n_sourceterm scalar */ if (c == 400) Message("bNuc is %g\n, ", bNuc); /**********End Variable Assignments*********************************/ /**********Start Calculations************************************** */ M = rho_cell * Ysoot; N = bNuc * rho_cell * N_norm; dp = pow(((6.0 * M)/(PI * N * rho_soot)), (1.0/3.0)); dNdT = c_alph * N_avog * pow(((X_C2H2 * P)/(R * T)), l) * exp(-1.0 * T_alph / T) - c_bet * pow(((24.0 * R * T) / ( rho_soot * N_avog)), 0.5) * sqrt(dp) * pow(N, 2); if (c == 400) dMdT = Mp * C_alph * pow(((X_C2H2 * P)/(R * T)), l) * exp(-1.0 * T_alph / T) + c_gama * pow(((X_C2H2 * P)/(R * T)), m) * (exp(-1.0 * T_gama / T) * (pow((pi * N), 1.0/3.0)) * (pow((6 * M)/rho_soot), 2.0/3.0)) - c_oxid * c_omega * eta_coll * ((X_OH * P) / (R * T)) * sqrt(T) * pow((pi * N), 1.0/3.0) * pow((6*M/rho_soot), 2.0/3.0) Message("dNdT is %g\n, ", dNdT); /**********End of Calculations**************************************/ return (dNdT / N_norm); return (dMdT); } |
|
June 24, 2013, 07:47 |
soot model
|
#15 |
Member
Prakash Ghose
Join Date: Dec 2011
Posts: 34
Rep Power: 15 |
Dear kaveh.
I am giving my uds source code for soot mass fraction. Another code for nuclei is also there but I am not giving that, because both are similar. But still error is showing. can you plz help me. #include "udf.h" #include "pdf_props.h" #include "pdf_table.h" #include "mem.h" #include "materials.h" #include "sg_udms.h" /*********Constant Declarations*************************************/ #define Mp 144.0 /* mass of an incipent soot particle. here taken for C12 */ #define c_alph 54.0 /* Units: 1/s */ #define T_alph 21000.0 /* activation temperature of soot inception in K */ #define c_gama 11700.0 /* surface growth rate scaling factor */ #define T_gama 12100.0 /* activation temperature of surface growth rate */ #define c_oxid 0.015 /* oxidation rate scaling parameter */ #define c_omega 105.8125 /* oxidation model constant */ #define eta_coll 0.04 /* collisional efficiency parameter */ #define rho_soot 1800.0 /* kg/m3 */ #define l 1.0 /* indicates the particle nucleation sensitivity to Pressure */ #define m 1.0 /* indicates the particle surface growth sensitivity to Pressure */ #define n 1.0 /* indicates the particle surface growth sensitivity to soot mass concentration */ #define PI 3.14159265358979324 /* Pi as a constant...alternatively pi=4.0*atan(1.0) */ /*********End Constant Declarations*********************************/ DEFINE_SOURCE(m_sourceterm, c, t, dS, eqn) { /*********Variable Declarations*************************************/ double dMdT, X_C2H2, X_OH, T, P, rho_cell, M, N, Ysoot, bNuc, R; int ic2h2; int ioh; /*********End Variable Declarations*********************************/ /*********Variable Assignments**************************************/ Material *m = THREAD_MATERIAL(t); ic2h2 = mixture_specie_index(m, "c2h2"); ioh = mixture_species_index(m, "oh"); Pdf_XY(c, t, x, y); /* Calling the species mole and mass fractions for this cell */ X_C2H2 = xi[ic2h2]; X_OH = xi[ioh]; T = C_T(c, t); /* Temperature at the cell */ if (c == 400) Message("Temp is %g\n, species %", T); P = C_P(c, t); /* Cell Pressure */ if (c == 400) Message("Press is %g\n, ", P); rho_cell = C_R(c, t); /* Cell average Density */ R = UNIVERSAL_GAS_CONSTANT; /* Universal gas constant is called with the built-in Fluent Macro */ Ysoot = C_UDSI(c, t, 0); /* Calling soot mass fraction from m_sourceterm scalar */ if (c == 400) Message("Ysoot is %g\n, ", Ysoot); bNuc = C_UDSI(c, t, 1); /* Calling soot number density from n_sourceterm scalar */ if (c == 400) Message("bNuc is %g\n, ", bNuc); /**********End Variable Assignments*********************************/ /**********Start Calculations************************************** */ M = rho_cell * Ysoot; N = bNuc * rho_cell * N_norm; dMdT = Mp * C_alph * pow(((X_C2H2 * P)/(R * T)), l) * exp(-1.0 * T_alph / T) + c_gama * pow(((X_C2H2 * P)/(R * T)), m) * (exp(-1.0 * T_gama / T) * (pow((pi * N), 1.0/3.0)) * (pow((6 * M)/rho_soot), 2.0/3.0)) - c_oxid * c_omega * eta_coll * ((X_OH * P) / (R * T)) * sqrt(T) * pow((pi * N), 1.0/3.0) * pow((6*M/rho_soot), 2.0/3.0) Message("dMdT is %g\n, ", dMdT); /**********End of Calculations**************************************/ return (dMdT); } |
|
March 20, 2022, 06:17 |
|
#17 |
New Member
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5 |
following.........
|
|
February 9, 2023, 11:04 |
|
#18 |
New Member
陈玮
Join Date: Mar 2022
Posts: 10
Rep Power: 4 |
Now, it is 2023, I'm still looking for a way to do so. Even though there are macros to rewrite the soot nuclei rate and the soot mass rate, I compiled and selected them successfully in Fluent, while there show no significant between with or without macro.
|
|
February 5, 2024, 13:23 |
Changing constants of Moss-Brookes model
|
#19 | |
New Member
Fabio
Join Date: Jul 2022
Location: Brazil
Posts: 4
Rep Power: 4 |
Quote:
define/models/soot-model/soot-model-parameters and then you can change all constants of the Moss-Brookes model. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mass Fraction and Mole Fraction don't tie up | KieranHegarty | FLUENT | 1 | February 28, 2015 11:22 |
Diffusion-coefficient based on mole fraction | Fady | FLUENT | 1 | November 11, 2006 10:00 |
Species Partial Pressure or Mole Fraction | Priya | FLUENT | 2 | July 25, 2006 10:21 |
How to get mole fraction | shuqin | FLUENT | 2 | March 6, 2006 09:37 |
For a correct the mole fraction ... | kevin | FLUENT | 0 | April 9, 2002 05:39 |