|
[Sponsors] |
Using parameter defined in one UDF into another UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 13, 2021, 11:53 |
Using parameter defined in one UDF into another UDF
|
#1 |
New Member
Jam
Join Date: Aug 2021
Posts: 15
Rep Power: 5 |
Hi,
I am writing 3 different udfs for calculating the concentration of 3 different species of mine. I also have a mass transfer coefficient in another UDF. I need to use that mass transfer coefficient in one of the concentration UDFs. I don't know how should I use a parameter that is defined in one UDF in another UDF. I appreciate your help. Thanks, |
|
September 13, 2021, 14:35 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Write a function that calculates free mass transfer, and call that function in both macros.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
September 14, 2021, 08:11 |
|
#3 | |
New Member
Jam
Join Date: Aug 2021
Posts: 15
Rep Power: 5 |
Quote:
Thank you for your response. So my question is that how do I call the mass transfer in my source UDF? Should I use the name I chose for the mass transfer UDF in my source UDF? OR does fluen have a specified variable for kl (which I could not find any)? Do I need to add any thing in the beginning after #include udf.h? I appreciate your help! Thank you! |
||
September 14, 2021, 14:56 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I did not say you should call the mass transfer function in your source UDF.
I mean you should write a separate function, and call that function in the mass transfer macro and in the source UDF.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
September 21, 2021, 14:23 |
|
#5 | |
New Member
Jam
Join Date: Aug 2021
Posts: 15
Rep Power: 5 |
Quote:
Sorry but I still do not know how I can do that. So I have a multiphase system there is air as one phase and a mix of species in the liquid phase. mass transfer between gas and liquid is obtained from this UDF (I am not sure yet if it works) #include "udf.h" #define D_O2 1.97*pow(10,-9) real m_lg; DEFINE_MASS_TRANSFER(kl_my2, cell, thread, from_index, from_species_index, to_index, to_species_index) { cell_t c; Thread *gas, *liq; gas = THREAD_SUB_THREAD(thread, from_index); liq = THREAD_SUB_THREAD(thread, to_index); m_lg = 0.0; m_lg = (0.4)*pow(D_O2,0.5)*pow(C_D(c,liq)*C_R(c,liq)/C_MU_EFF(c,liq), 0.25) ; return (m_lg); } Then I have source codes for consumption or generation of two of my species: /************************************************** ******************* UDF for specifying a volume reaction rate for a first order reaction. ************************************************** ********************/ #include "udf.h" #define WRmax 0.67 #define KS 0.0004 #define KO 0.0004 DEFINE_SOURCE(BMsource,c,t,dS,eqn) { real BM, SUB, source; BM = C_YI(c,t,0) * C_R(c,t); /*Biomass concentration*/ SUB = C_YI(c,t,1) * C_R(c,t); /*Substrate concentration*/ OXN = C_YI(c,t,2) * C_R(c,t)+kl*a*(0.08- C_YI(c,t,2) * C_R(c,t)); /*O2 concentration* source = WRmax*(SUB/(SUB+KS)*BM)*(OXN/(OXN+KO)*BM); /*Source term*/ return source; } the part for O2 concentration I need to call the calculated kl which is from the UDF m_lg . I do not know how to define it, do I need a UDM and how can I write it in my UDF? I really appreciate your help. |
||
September 22, 2021, 10:54 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
A UDM can also work. Like this:
Code:
#include "udf.h" #define D_O2 1.97e-9 DEFINE_MASS_TRANSFER(kl_my2, cell, thread, from_index, from_species_index, to_index, to_species_index) { Thread *gas, *liq; gas = THREAD_SUB_THREAD(thread, from_index); /*isn't this from_species_index? species always confuse me */ liq = THREAD_SUB_THREAD(thread, to_index); m_lg = (0.4)*pow(D_O2,0.5)*pow(C_D(cell,liq)*C_R(cell,liq)/C_MU_EFF(cell,liq), 0.25) ; UDMI(cell,thread,0)=m_lg; return (m_lg); } /************************************************** ******************* UDF for specifying a volume reaction rate for a first order reaction. ************************************************** ********************/ #define WRmax 0.67 #define KS 0.0004 #define KO 0.0004 DEFINE_SOURCE(BMsource,c,t,dS,eqn) { real BM, SUB, source; BM = C_YI(c,t,0) * C_R(c,t); /*Biomass concentration*/ SUB = C_YI(c,t,1) * C_R(c,t); /*Substrate concentration*/ OXN = C_YI(c,t,2) * C_R(c,t)+UDMI(c,t,0)*a*(0.08- C_YI(c,t,2) * C_R(c,t)); /*O2 concentration* source = WRmax*(SUB/(SUB+KS)*BM)*(OXN/(OXN+KO)*BM); /*Source term*/ return source; } The code will not work yet because you multiply by "a" in OXN, and you never defined "a" and I have no idea what it should be.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
September 22, 2021, 11:04 |
|
#7 | |
New Member
Jam
Join Date: Aug 2021
Posts: 15
Rep Power: 5 |
Quote:
|
||
November 18, 2021, 09:10 |
|
#8 | |
New Member
Jam
Join Date: Aug 2021
Posts: 15
Rep Power: 5 |
Quote:
I have another question related to the same code. So here ''a'' is the interfacial area between gas and liquid. So in case I use a single bubble size in my model I can write the following code for the interfacial area and then store in another UDM and use it in the codes I mentioned above. /************************************************** ******************* UDF for specifying interfacial area ************************************************** ********************/ #include "udf.h" real area_intf; DEFINE_EXCHANGE_PROPERTY(custom_ia,c,t,i,j) { /* i -- liquid-phase; j -- vapor-phase */ Thread **pt = THREAD_SUB_THREADS(t); real diam = C_PHASE_DIAMETER(c, pt[j]); real vof_i = C_VOF(c,pt[i]); real vof_j = C_VOF(c,pt[j]); area_intf = 6.*vof_j/diam; C_UDMI(c,t,1)=area_intf; return area_intf; } - I wanted to make sure if this is correct?, since I get 0 for data stored in C_UDMI(c,t,1). -Also I wanted to see if anyone knows how do I define interfacial area when I am using interfacial area concentration model with a range of bubbles from 2mm to 1 cm? Is there any specific macro defined for fluent that I can directly use? Or I need to find the interfacial area for different bubble categories? (sth similar to PBM) and what is the bubble size macro for the interfacial area concentration model? Many thanks, |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is it possible to plot momentum source defined using UDF? | CaptainCombo | Fluent UDF and Scheme Programming | 9 | February 20, 2023 18:04 |
Scheme (or UDF) load Parameter value | HHOS | FLUENT | 0 | September 4, 2017 05:25 |
Using UDF to define parameter | Oleg V. | Fluent UDF and Scheme Programming | 2 | January 24, 2017 03:55 |
UDF error:strcpy has already been defined in the curren | alinik | FLUENT | 0 | November 2, 2016 21:17 |
Can I use UDF to input a parameter which is related to the result of last step? | bagecy | Fluent UDF and Scheme Programming | 0 | January 31, 2016 22:17 |