CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

How can I write UDF FOR Integral?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Mansoor_shad

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 10, 2017, 16:40
Default How can I write UDF FOR Integral?
  #1
New Member
 
Mansoor Shademan
Join Date: Jul 2016
Posts: 8
Rep Power: 10
Mansoor_shad is on a distinguished road
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.
ramakant likes this.

Last edited by Mansoor_shad; March 10, 2017 at 16:56. Reason: missed Formulation for integral
Mansoor_shad is offline   Reply With Quote

Old   March 12, 2017, 15:21
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
1. Try it. If it does what you want, it is correct.
2. Probably not. I think you want DEFINE_ON_DEMAND.
pakk is offline   Reply With Quote

Old   April 22, 2017, 11:13
Default Reply
  #3
New Member
 
Mansoor Shademan
Join Date: Jul 2016
Posts: 8
Rep Power: 10
Mansoor_shad is on a distinguished road
Hello my friend,
Thank you for spending time thinking and answering my Question.
Be successful...
Mansoor_shad is offline   Reply With Quote

Old   July 24, 2018, 18:11
Default
  #4
New Member
 
Jing
Join Date: Feb 2013
Posts: 25
Rep Power: 13
serene6390 is on a distinguished road
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)
serene6390 is offline   Reply With Quote

Old   July 25, 2018, 03:17
Default
  #5
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by serene6390 View Post
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.
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?
`e` is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 14:08.