UDF for energy source
Hello everyone,
I am writing UDF for energy source.I need to retrieve subdomain for primary ans secondary phase using THREAD_SUB_THREAD. I have gone through UDF manual but i,m having some problem in implementation part. Can someone help me? Thanks a lot... |
Quote:
|
UDF for energy source
Quote:
Thanks for reply.. #include "udf.h" #define LH 2250.0 #define T_SAT 373.15 DEFINE_SOURCE(eng_eqn,cell,thread,dS,eqn) { real x[ND_ND]; real con, source; begin_c_loop_all(cell,thread) { C_CENTROID(x,cell,thread); Thread *thread, *thread; thread = THREAD_SUB_THREAD(cell,thread); thread = THREAD_SUB_THREAD(cell,thread); if (C_T(cell, thread) > T_SAT) { con = -0.1*C_VOF(cell,thread)*C_R(cell,thread)*((C_T(cell ,thread)-T_SAT)/T_SAT)*x[1]; source = con*LH; } else if (C_T(cell, thread) < T_SAT) { con = 0.1*C_VOF(cell,thread)*C_R(cell,thread)*((T_SAT-C_T(cell,thread))/T_SAT)*x[1]; source = con*LH; } } end_c_loop_all(cell,thread) dS[eqn] =0.1*C_VOF(cell,thread)*C_R(cell,thread)/T_SAT; return source; } |
Quote:
Search for the Phase-Level Thread Pointer ( THREAD_SUB_THREAD). You will see that it defines for the primary phase as 0, but you can also define other fazes as different integers. In addition to that, you are also pointing and defining thread 2 times (and this value is already retrieved from the source macro). |
i have modified it as:
#include "udf.h" #define LH 2250.0 #define T_SAT 373.15 DEFINE_SOURCE(eng_source,cell,thread,dS,eqn) { real x[ND_ND]; real con, source; cell_t gas, liq; begin_c_loop_all(cell,thread) { C_CENTROID(x,cell,thread); liq = THREAD_SUB_THREAD(liq,0); gas = THREAD_SUB_THREAD(gas,1); if (C_T(cell, liq) > T_SAT) { con = -0.1*C_VOF(cell,liq)*C_R(cell,liq)*((C_T(cell,liq)-T_SAT)/T_SAT)*x[1]; source = con*LH; } else if (C_T(cell, gas) < T_SAT) { con = 0.1*C_VOF(cell,gas)*C_R(cell,gas)*((T_SAT-C_T(cell,gas))/T_SAT)*x[1]; source = con*LH; } } end_c_loop_all(cell,thread) dS[eqn] =0.1*C_VOF(cell,thread)*C_R(cell,thread)/T_SAT; return source; } But, after i interpret it at the first iteration it shows error as Error: received a fatal signal (Segmentation fault). |
Quote:
|
Quote:
Ohh.. Thank you. You have been very helpful. I've also written a mass transfer udf. Would you please give it a look? #include "udf.h" DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index,from_species_index,to_index, to_species_index) { real m_lg; real T_SAT = 373.15; Thread *gas, *liq; gas = THREAD_SUB_THREAD(thread, from_index); liq = THREAD_SUB_THREAD(thread, to_index); m_lg = 0.0; if (C_T(cell, liq) > T_SAT) { m_lg = -0.1*C_VOF(cell,liq)*C_R(cell,liq)*(C_T(cell,liq)-T_SAT)/T_SAT; /* Evaporating*/ } else if (C_T(cell, gas) < T_SAT) { m_lg = 0.1*C_VOF(cell,gas)*C_R(cell,gas)*(T_SAT-C_T(cell,gas))/T_SAT; /* Condensing */ } return (m_lg); } Do i need to use #include "sg_mphase.h"? |
Quote:
about the sg_mpahse.h library, i do not know.check the udf.h and see either it is already included or not in it. |
All times are GMT -4. The time now is 13:53. |