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

Error in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 1, 2018, 14:36
Default Error in UDF
  #1
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Hi all,

I have written a udf to calculate the current in a MFC but I am getting some error:
Error: / (devide) invalid argument (wrong type): not a number.
Error Object: nan

I think the error is in udf (attached with this thread). Can anyone please check report error if any.

Thank you
Attached Files
File Type: c current.c (1.0 KB, 8 views)
Nishant_Sharma is offline   Reply With Quote

Old   July 2, 2018, 16:08
Default
  #2
Member
 
zobekenobe
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 72
Rep Power: 17
zobekenobe is on a distinguished road
Error 1:

begine_thread_loop(t,d)

should read

begin_thread_loop(t,d)


Error 2:

begine_c_loop(c,t)

should read

begin_c_loop(c,t)



The 'e' after the begin
zobekenobe is offline   Reply With Quote

Old   July 2, 2018, 16:35
Default
  #3
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Quote:
Originally Posted by zobekenobe View Post
Error 1:

begine_thread_loop(t,d)

should read

begin_thread_loop(t,d)


Error 2:

begine_c_loop(c,t)

should read

begin_c_loop(c,t)



The 'e' after the begin
Yaah, that I figured out after, and even after correcting it I am getting an error / (divide): not an argument
Nishant_Sharma is offline   Reply With Quote

Old   July 3, 2018, 01:47
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Try this code
Code:
#include "udf.h"
real Voc = 0.92;
real Rext = 100.0;
real k2 = 9.13e-9;
real k1 = 5.57e-5;
real r1 = 1.62e-6;
real r2 = 4.32e-6;
real F = 96485;
real A = 0.6;
real B = 0.4;
real Kac = 0.592;
real Kox = 0.004;
real R = 8.314;
real T = 300.0;
real den = 998.0;

DEFINE_ADJUST(current, d)
{
    Thread *t;
    cell_t c;
    face_t f;
    real Vac, Vox, I, Cac, Cox, YI_AC, YI_OX, mw[6], V;
    thread_loop_c (t,d)
    {
        begin_c_loop (c,t)
        {
            YI_AC = C_YI(c,t,0);
            YI_OX = C_YI(c,t,1);
            Cac = YI_AC*den/60.0;
            Cox = YI_OX*den/32.0;
            Vac = R*T*log(r1*(Kac+Cac)/(Cac*k1))/(A*F);
            Vox = R*T*log(r2*(Kox+Cox)/(Cox*k2))/((B-1)*F);
            V = Voc - Vac - Vox;
            I = V/Rext;
            C_UDMI(c,t,0) = Cac;
            C_UDMI(c,t,1) = Cox;
            C_UDMI(c,t,2) = Vac;
            C_UDMI(c,t,3) = Vox;
            C_UDMI(c,t,4) = V;
            C_UDMI(c,t,5) = I;
        }
        end_c_loop(c,t);
    }
}
best regards
AlexanderZ 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
udf for one dimensional linear motion based on force maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 03:18
Save output of udf in another udf! JuanJoMex FLUENT 0 February 8, 2018 13:43
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 01:53
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 13:44.