
[Sponsors] 
May 27, 2013, 04:07 
source energy

#41 
New Member
hossein
Join Date: May 2013
Posts: 1
Rep Power: 0 
hi
Where is my problem udf? #include "udf.h" DEFINE_SR_RATE(my_rate,f,t,r,mw,yi,rr) { real y_ch4 = yi[0]; real y_h2o = yi[1]; real y_h2 = yi[2]; real y_co = yi[3]; real y_co2 = yi[4]; real y_o2 = yi[6]; real y_n2 = yi[5]; real K1, K2, K3, K4, T_w, TP ,Nsum , K_C1, K_C2, K_C3, K_C4, K_C5, K_C6, QR , keq2 , keq3 , keq4; real r1,T_WALL,A, r2 ,r3, r4, k3,k4, min=0, max=1e+5, k1, k2; Thread *t0 = THREAD_T0(t); cell_t c0 = F_C0(f,t); y_ch4 *= 1/mw[0]; y_h2o *= 1/mw[1]; y_h2 *= 1/mw[2]; y_co *= 1/mw[3]; y_co2 *= 1/mw[4]; y_o2 *= 1/mw[6]; y_n2 *= 1/mw[5]; Nsum = y_ch4 + y_h2o + y_h2 + y_co + y_co2 + y_n2 + y_o2 ; y_ch4 *= 1/Nsum; y_h2o *= 1/Nsum; y_h2 *= 1/Nsum; y_co *= 1/Nsum; y_co2 *= 1/Nsum; y_o2 *= 1/Nsum; y_n2 *= 1/Nsum; T_w = F_T(f,t); begin_c_loop(c0,t0) { T_WALL = C_T(c0,t0); C_UDSI(c0,t0,0) = T_WALL; } end_c_loop(c0,t0) /* ki( Kmol*m^2*s ) */ K1 = KO_1*exp(E1/(R*T_w))*aa; K2 = KO_2*exp(E2/(R*T_w))*aa; K3 = KO_3*exp(E3/(R*T_w))*aa; K4 = KO_4*exp(E4/(R*T_w))*aa; K_C1 = K_CO1*exp((AH1)/(R*T_w)); K_C2 = K_CO2*exp((AH2)/(R*T_w)); K_C3 = K_CO3*exp((AH3)/(R*T_w)); K_C4 = K_CO4*exp((AH4)/(R*T_w)); K_C5 = K_CO5*exp((AH5)/(R*T_w)); K_C6 = K_CO6*exp((AH6)/(R*T_w)); /* TP( bar ) */ TP = C_P(c0,t0)/ad; keq2 = (ab)*exp(ac/T_w); keq3 = (ae)*exp(af/T_w); keq4 = (ag)*exp(ah/T_w); QR = 1+(K_C4*(TP*y_co))+(K_C5*(TP*y_h2))+(K_C3*(TP*y_ch 4))+((K_C6*(TP*y_h2o))/(TP*y_h2)); /* rr (Kmol*m^2*s)*/ if (STREQ(r>name, "reaction1")) { r1 = k1*(((TP*y_ch4)*pow(TP*y_o2,.5))/pow((1+(K_C1*(TP*y_ch4))+(K_C2*pow(TP*y_o2,.5))),2 )); if(r1<min) { *rr = min; } else if (r1 > min && r1 < max) *rr = r1; else if (r1 > max){ *rr = max; } } else if (STREQ(r>name, "reaction2")){ r2=((k2/pow(TP*y_h2,2.5))*(((TP*y_ch4)*(TP*y_h2o))((pow(TP*y_h2,3)*(TP*y_co))/(keq2)))/(pow(QR,2))); if(r2 < min) { *rr = min; } else if (r2 > min && r2 < max) *rr = r2; else if (r2 > max){ *rr = max; } } else if (STREQ(r>name, "reaction3")) { r3=((k3/(TP*y_h2))*(((TP*y_co)*(TP*y_h2o))(((TP*y_h2)*(TP*y_co2))/(keq3)))/(pow(QR,2))); if(r3 < min) { *rr = min; } else if (r3 > min && r3 < max) *rr = r3; else if (r3 > max){ *rr = max; } } else if (STREQ(r>name, "reaction4")){ r4=((k4/pow(TP*y_h2,3.5))*(((TP*y_ch4)*pow(TP*y_h2o,2))(((pow(TP*y_h2,4))*(TP*y_co2))/(keq4)))/(pow(QR,2))); if(r4 < min) { *rr = min; } else if (r4 > min && r4 < max) *rr = r4; else if (r4 > max){ *rr = max; } } } DEFINE_ON_DEMAND(copy_uds_to_udm) { Domain* d = Get_Domain(1); Thread* t; cell_t c; thread_loop_c(t,d) { begin_c_loop(c,t) Thread* t0; cell_t c0; { C_UDMI(c0,t0,0) =C_UDSI(c0,t0,0); } end_c_loop(c,t) } return; } DEFINE_SOURCE(energy,c,t,dS,eqn) { real source; source = C_UDMI(c0,t0,0); dS[eqn] = 0; return source; } 

October 18, 2015, 12:08 

#42  
New Member
HSA
Join Date: Oct 2015
Posts: 2
Rep Power: 0 
Quote:
Last edited by student_231; October 18, 2015 at 12:09. Reason: mistake 

October 20, 2015, 10:25 

#43 
Senior Member
Bruno
Join Date: Mar 2009
Location: Brazil
Posts: 277
Rep Power: 18 
What have you done so far? Do you have a geometry? Mesh? Base models? Did you take a look at the tutorials?


August 12, 2017, 05:05 

#44  
New Member
maziyar ghanikolahloo
Join Date: Jan 2017
Posts: 5
Rep Power: 6 
Quote:
I should write an udf for my photovoltaic cell project to relate heat generation rate(output power) to photovoltaic cell's temperature actually I wanna consider this correlation Pel=a(1b)Tc.I.SCR.A in which all the parameters are constant except Tc how can I write its udf code? In fact I have written no udf code yet. 

August 12, 2017, 05:10 

#45  
New Member
maziyar ghanikolahloo
Join Date: Jan 2017
Posts: 5
Rep Power: 6 
Quote:
I should write an udf for my photovoltaic cell project to relate heat generation rate(output power) to photovoltaic cell's temperature actually I wanna consider this correlation Pel=a(1b)Tc.I.SCR.A in which all the parameters are constant except Tc how can I write its udf code? In fact I have written no udf code yet. 

November 25, 2019, 23:44 
Varying heat generation rate

#46 
New Member
Amit Chauhan
Join Date: May 2010
Location: Chennai, India
Posts: 18
Rep Power: 13 
Hello,
I am trying to simulate 3D thermal analysis of a physical domain. In the domain, on a surface, heat is being removed by jet impingement of fluid from an orifice plate 150 mm above it. Since multiple jet impingement problems are unstable and difficult to converge, I take alternate approach. I would provide convective boundary condition on the wall surface (exposed to jet practically). There would be heat loss from the surface. Now this heat I want to provide as heat source in the fluid volume above it. So the logic is as follows: 1) Estimate the heat from the surface (imposed with convective boundary condition) with every iteration 2) Provide this estimated heat as heat source for the fluid above the wall, with every iteration. P.S.  I would be deleting a cell layer above this surface in fluid domain, in order to impose convective boundary condition. Has anybody experienced such problem/issue in Fluent. It would be appreciable if anybody can share the logic and approach to write the UDF for above explained problem. Thank you 

November 26, 2019, 03:31 

#47 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 1,763
Rep Power: 28 
how are you going to apply heat source to fluid above the wall
if you want to delete cell layer above surface in fluid domain?
__________________
best regards ****************************** press LIKE if this message was helpful 

November 26, 2019, 03:43 

#48  
New Member
Amit Chauhan
Join Date: May 2010
Location: Chennai, India
Posts: 18
Rep Power: 13 
Quote:
As said, I am going to delete a cell from fluid regime. There are more than 6 layers of cells in the fluid regime. I will delete one, at the bottom surface, in order to give boundary condition of convection. 

November 26, 2019, 23:27 

#49 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 1,763
Rep Power: 28 
I don't catch your idea. Make a sketch
To make volumetric heat source in UDF you can use DEFINE_SOURCE macro more information and examples are in Ansys Fluent Customization manual
__________________
best regards ****************************** press LIKE if this message was helpful 

November 29, 2019, 01:24 

#50  
New Member
Amit Chauhan
Join Date: May 2010
Location: Chennai, India
Posts: 18
Rep Power: 13 
Quote:
I have elaborated and explained the issue in the attachment. Please let me know if it is helpful. 

December 1, 2019, 20:59 

#51 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 1,763
Rep Power: 28 
zones R and I should have mesh
use Define_profile macro to apply surface heat flux on A boundary, same for C boundary good examples you can find in Ansys Fluent Customization manual
__________________
best regards ****************************** press LIKE if this message was helpful 

December 4, 2019, 00:40 

#52  
New Member
Amit Chauhan
Join Date: May 2010
Location: Chennai, India
Posts: 18
Rep Power: 13 
Quote:
Thank you so much Alexander for your response. I understand that, with every iteration I need to write/save heat/heat flux value on surface A into a table (may be CSV) and the same could be read in order to impose heat flux/heat on surface C. Is this possible? However, I will go through the manual and try to find out some way out. Again thank you so much for the response and support. 

December 4, 2019, 22:51 

#53 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 1,763
Rep Power: 28 
you can read/write from file if it is needed.
__________________
best regards ****************************** press LIKE if this message was helpful 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF to measure Mass Flow Rate  a.lynchy  Fluent UDF and Scheme Programming  31  October 4, 2018 14:10 
strain rate in UDF  Paulina  FLUENT  11  November 20, 2014 03:06 
UDF for critical strain rate to extinction  Birute Bunkute  FLUENT  1  March 25, 2010 15:40 
surface reaction rate with udf  yellowstuff  FLUENT  4  January 29, 2010 12:53 
heat generation rate w/m3 in 2D  Laszlo  FLUENT  1  May 6, 2004 11:58 