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

Problem with UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 17, 2019, 20:03
Default Problem with UDF
  #1
New Member
 
Javier Valenzuela
Join Date: Jun 2019
Posts: 1
Rep Power: 0
Mascarius is on a distinguished road
Hi, i have a problem with the syntax of the following code. But I do not know where the problem is. I will appreciate if you can help me with this.

#include "udf.h"
static const real Arrhenius = 1.4e08;
static const real E_Activation = 1.612e08;
#define SMALL_S 1.e-29
DEFINE_HET_RXN_RATE(arrh,c,t,hr,mw,yi,rr,rr_t)
{
Domain **domain_reactant = hr->domain_reactant;
real *stoich_reactant = hr->stoich_reactant;
Thread **pt=THREAD_SUB_THREADS(t);
/* for each phase */
Thread *tp = pt[0];
Thread *ts = pt[1];
int *reactant = hr->reactant;
int i;
int sp_id;
int dindex;
Thread *t_reactant;
real ci;
/* obtain temperature from cell for each phase */
real Tp=C_T(c,tp);
real Ts=C_T(c,ts);
real T=(Tp+Ts)/2.;
/* instead of compute rr directly, compute log(rr) and then
take exp */
*rr = 0;
for (i=0; i < hr->n_reactants; i++)
{
sp_id = reactant[i]; /* species ID to access mw and yi */
if (sp_id == -1) sp_id = 0; /* if phase does not have species,
mw, etc. will be stored at index 0 */
dindex = DOMAIN_INDEX(domain_reactant[i]);
/* domain index to access mw & yi */
t_reactant = THREAD_SUB_THREAD(t,dindex);
/* get conc. */
ci = yi[dindex][sp_id]*C_R(c,t_reactant)/mw[dindex][sp_id];
ci = MAX(ci,SMALL_S);
*rr += stoich_reactant[i]*log(ci);
}
*rr += log(Arrhenius + SMALL_S) -
E_Activation/(UNIVERSAL_GAS_CONSTANT*T);
/* 1.e-40 < rr < 1.e40 */
*rr = MAX(*rr,-40);
*rr = MIN(*rr,40);
*rr = exp(*rr);
Mascarius is offline   Reply With Quote

Old   June 19, 2019, 06:18
Default
  #2
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Try using VC++ Udf Studio. It can tell you where to revise and it's free for less than two macros.

Quote:
Originally Posted by Mascarius View Post
Hi, i have a problem with the syntax of the following code. But I do not know where the problem is. I will appreciate if you can help me with this.

#include "udf.h"
static const real Arrhenius = 1.4e08;
static const real E_Activation = 1.612e08;
#define SMALL_S 1.e-29
DEFINE_HET_RXN_RATE(arrh,c,t,hr,mw,yi,rr,rr_t)
{
Domain **domain_reactant = hr->domain_reactant;
real *stoich_reactant = hr->stoich_reactant;
Thread **pt=THREAD_SUB_THREADS(t);
/* for each phase */
Thread *tp = pt[0];
Thread *ts = pt[1];
int *reactant = hr->reactant;
int i;
int sp_id;
int dindex;
Thread *t_reactant;
real ci;
/* obtain temperature from cell for each phase */
real Tp=C_T(c,tp);
real Ts=C_T(c,ts);
real T=(Tp+Ts)/2.;
/* instead of compute rr directly, compute log(rr) and then
take exp */
*rr = 0;
for (i=0; i < hr->n_reactants; i++)
{
sp_id = reactant[i]; /* species ID to access mw and yi */
if (sp_id == -1) sp_id = 0; /* if phase does not have species,
mw, etc. will be stored at index 0 */
dindex = DOMAIN_INDEX(domain_reactant[i]);
/* domain index to access mw & yi */
t_reactant = THREAD_SUB_THREAD(t,dindex);
/* get conc. */
ci = yi[dindex][sp_id]*C_R(c,t_reactant)/mw[dindex][sp_id];
ci = MAX(ci,SMALL_S);
*rr += stoich_reactant[i]*log(ci);
}
*rr += log(Arrhenius + SMALL_S) -
E_Activation/(UNIVERSAL_GAS_CONSTANT*T);
/* 1.e-40 < rr < 1.e40 */
*rr = MAX(*rr,-40);
*rr = MIN(*rr,40);
*rr = exp(*rr);
gearboy is offline   Reply With Quote

Old   June 20, 2019, 01:47
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
how do you know there is a problem?
put here all logs you have

best regards
AlexanderZ is offline   Reply With Quote

Reply

Tags
udf


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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 07:05
Problem with DPM simulation with particles injection and EXECUTE_AT_THE_END UDF. Ari Fluent UDF and Scheme Programming 4 May 31, 2016 09:51
udf loading problem santu Fluent UDF and Scheme Programming 1 May 22, 2015 16:47
Vaporization pressure UDF property problem? lehoanganh07 Fluent UDF and Scheme Programming 1 September 13, 2014 11:59
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 07:56


All times are GMT -4. The time now is 12:42.