
[Sponsors] 
January 9, 2012, 02:51 
UDF code problem about total value

#1 
New Member
YuPei Chen
Join Date: Jun 2011
Posts: 26
Rep Power: 6 
Hi, everybody, here is my code :
Code:
#include "udf.h" #include "mem.h" #include "math.h" #include "stdio.h" #define mass_alloy 0.295 DEFINE_ADJUST(adj_UDS,d) { cell_t c ; Thread *t; real H_M,mass,sum ; thread_loop_c(t,d) { begin_c_loop(c,t) { mass= (C_UDSI(c,t,0)8238)*C_VOLUME(c,t)*3.14159; H_M = (mass/mass_alloy)*432.4; C_UDMI(c,t,0) = H_M ; sum += sum C_UDMI(c,t,0) ; } end_c_loop(c,t) } } Thanks. 

January 9, 2012, 04:36 

#2  
Senior Member

Hi,
First of all the summation command is something like this: Quote:
Quote:
Bests,
__________________
Amir 

January 9, 2012, 08:42 

#3  
New Member
YuPei Chen
Join Date: Jun 2011
Posts: 26
Rep Power: 6 
Hi, Amir,
the reason that I calculate "sum" is I should use the value to calculate "p_eq" as following : Code:
#include "udf.h" #include "mem.h" #include "math.h" #include "stdio.h" #define A 18.3 #define B 3704.6 #define a 0.0819 #define b 330 DEFINE_ADJUST(adj_peq,d) { cell_t c ; Thread *t real tem ; thread_loop_c(t,d) { begin_c_loop(c,t) { tem = C_T(c,t); if(sum<1.2972) { p_eq = 1000*exp((a*1.2972(B/tem)+A)*(1((sum1.2972)*(sum1.2972))/1.6827)); } if(1.2972 <= sum <= 4.7564) { p_eq = 1000*exp((a*sum)(B/tem)+A) ; } if(sum> 4.7564) { p_eq = 1000*exp(((a*4.7564)(B/tem)+A)+b*((sum4.7564)*(sum4.7564))/tem) ; } C_UDMI(c,t,1) = p_eq ; } end_c_loop(c,t) } } can I import the "custom field function" by UDF ? besides, I check the "UDF guide " and found that : Quote:
if I add the iteration number, the H_M will be added more time ? Thank you very much. 

January 9, 2012, 09:06 

#4  
Senior Member

Quote:
I'm not sure about this. it may be possible with schemes where I don't have any experiences with. You can search threads or open a new one. To avoid this feature you have 2 options: 1) use a simple ifclause in current UDF and use the commands when the time changes. 2) use DEFINE_EXECUTE_AT_THE_END macro which executes at the end of each time step automatically. Bests,
__________________
Amir 

January 10, 2012, 02:11 

#5  
New Member
YuPei Chen
Join Date: Jun 2011
Posts: 26
Rep Power: 6 
Quote:


January 10, 2012, 04:28 

#6  
Senior Member

Quote:
This is an example of manual: Quote:
__________________
Amir 

January 10, 2012, 23:32 

#7 
New Member
YuPei Chen
Join Date: Jun 2011
Posts: 26
Rep Power: 6 
You really help me. Thank you very much, Amir.


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
solving a conduction problem in FLUENT using UDF  Avin2407  Fluent UDF and Scheme Programming  1  March 13, 2015 03:02 
Problem with zeroGradient wall BC for temperature  Total temperature loss  cboss  OpenFOAM  10  March 5, 2015 07:57 
A problem about 'printf' and 'Message' in UDF.  LICH  Fluent UDF and Scheme Programming  2  May 2, 2013 02:45 
Problem with my udf  july  Fluent UDF and Scheme Programming  3  June 20, 2010 06:56 
UDF (write a data file) problem  lichun Dong  FLUENT  2  July 29, 2005 11:39 