source energy
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, "reaction-1")) { 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, "reaction-2")){ 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, "reaction-3")) { 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, "reaction-4")){ 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; } |
Quote:
|
What have you done so far? Do you have a geometry? Mesh? Base models? Did you take a look at the tutorials?
|
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(1-b)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. |
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(1-b)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. |
Varying heat generation rate
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 |
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? |
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. |
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 |
1 Attachment(s)
Quote:
I have elaborated and explained the issue in the attachment. Please let me know if it is helpful. |
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 |
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. |
you can read/write from file if it is needed.
|
1 Attachment(s)
Hi, I am currently trying to create a UDF for a source term to input into ANSYS FLUENT. I am modeling heat generation within a Li-ion cell and have the current charging profile. The heat generated within the cell is modeled with the equation q = I^2*R where I is current, R is internal resistance and q is the heat generation.
I have this current charging profile which varies over time. The internal resistance value is constant throughout the charging. I would like to know how to write a UDF such that the current changes with time according to this curve (attached image) . Any help would be appreciated! thanks in advance |
All times are GMT -4. The time now is 22:58. |