|
[Sponsors] |
March 10, 2017, 16:40 |
How can I write UDF FOR Integral?
|
#1 |
New Member
Mansoor Shademan
Join Date: Jul 2016
Posts: 8
Rep Power: 10 |
Hi,
I hope it is the right forum to ask. I want to simulate single DMFC using fluent 16.0 for study concentration in the flow channels of the bipolar plates and performance of the DMFC. I'm writing a UDF to calculate current density in the fuel cell according to the following equation: Icell=(1/Lcell)*(double integral over "ACL", ja*dxdy) "I hope the formula is clear". My c-code is: DEFINE_ADJUST(i_cell,d) { Thread *t; real i; real x[ND_ND]; real sum_i=0.; cell_t c; thread_loop_c(t,d) { begin_c_loop(c,t) C_CENTROID(x,c,t); sum_i += C_UDMI(c,t,0)*C_VOLUME(c,t)/L_cell; /// C_UDMI(c,t,0)=ja///// end_c_loop(c,t) } printf("Volume integral of current density: %g\n", sum_i); } 1. Is my UDF code correct? 2. Should I use “DEFINE_ADUJST” to calculate the integral? Thank you. Last edited by Mansoor_shad; March 10, 2017 at 16:56. Reason: missed Formulation for integral |
|
March 12, 2017, 15:21 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
1. Try it. If it does what you want, it is correct.
2. Probably not. I think you want DEFINE_ON_DEMAND. |
|
April 22, 2017, 11:13 |
Reply
|
#3 |
New Member
Mansoor Shademan
Join Date: Jul 2016
Posts: 8
Rep Power: 10 |
Hello my friend,
Thank you for spending time thinking and answering my Question. Be successful... |
|
July 24, 2018, 18:11 |
|
#4 |
New Member
Jing
Join Date: Feb 2013
Posts: 25
Rep Power: 13 |
Hi Mansoor,
Did you get your code work good? I'm also trying to calculate integral along a face using data stored in UDM, but my code does not work for now. I checked my data in UDM, but I got 0 for I1_integ. I still couldn't find where cause the error. Any reply will be appreciated. Thanks. Jing Domain *d; face_t f; Thread *t; Thread *t0; cell_t c; cell_t c0; d = Get_Domain(1); t = Lookup_Thread(d,7); /* Loop over all faces on wall */ begin_c_loop(c,t) { c0 = F_C0(f, t); t0 = THREAD_T0(t); F_CENTROID(x,f,t); y=x[1]; I1_integ+=C_UDMI(c,t0,0)/(C_UDMI(c,t0,0)+sigma)*dx; I2_integ+=C_UDMI(c,t0,0)/(C_UDMI(c,t0,0)+sigma)*(zt1-y)*dx; } end_c_loop(c,t) |
|
July 25, 2018, 03:17 |
|
#5 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
What is the variable dx? Where have you declared and initialised the variables I1_integ and I2_integ? Why not use the surface integrals already available within Fluent?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
write code UDF Fluent solve kinetic reaction rate equation palm oil | zirkov | FLUENT | 0 | February 13, 2017 11:16 |
is it possible to write post processing UDF or TUI commands to do following task? | Ash Kot | Fluent UDF and Scheme Programming | 1 | October 7, 2016 06:38 |
fluent udf problem: write specific data for every iteration in a file. | nnvoro | Fluent UDF and Scheme Programming | 1 | May 27, 2013 16:26 |
Write UDF to add a sink term for PEM fuel cell design | kitrax | Fluent UDF and Scheme Programming | 0 | March 15, 2012 05:56 |
how to write a 3D linear temperature of UDF | venus | FLUENT | 1 | October 28, 2008 03:46 |