|
[Sponsors] |
September 26, 2016, 21:17 |
UDF for energy source
|
#1 |
New Member
Nitesh Kumar
Join Date: May 2016
Posts: 17
Rep Power: 10 |
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... |
|
September 27, 2016, 06:11 |
|
#2 |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
share what you've done and we can see possible faults.
|
|
September 27, 2016, 07:03 |
UDF for energy source
|
#3 |
New Member
Nitesh Kumar
Join Date: May 2016
Posts: 17
Rep Power: 10 |
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; } |
|
September 27, 2016, 07:35 |
|
#4 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
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). |
||
September 27, 2016, 10:07 |
|
#5 |
New Member
Nitesh Kumar
Join Date: May 2016
Posts: 17
Rep Power: 10 |
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). |
|
September 27, 2016, 12:53 |
|
#6 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
|
||
September 28, 2016, 06:47 |
|
#7 | |
New Member
Nitesh Kumar
Join Date: May 2016
Posts: 17
Rep Power: 10 |
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"? |
||
September 30, 2016, 05:52 |
|
#8 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
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. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
HELP! adding a mass source to VOF eqn. by UDF??? | ROOZBEH | FLUENT | 5 | December 3, 2016 18:53 |
[Other] How to use finite area method in official OpenFOAM 2.2.0? | Detian Liu | OpenFOAM Meshing & Mesh Conversion | 4 | November 3, 2015 04:04 |
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 | Seroga | OpenFOAM Community Contributions | 9 | June 12, 2015 18:18 |
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error | FerdiFuchs | OpenFOAM Community Contributions | 27 | April 16, 2014 16:14 |
UDF Scalar Code: HT 1 | Greg Perkins | FLUENT | 8 | October 20, 2000 13:40 |