|
[Sponsors] |
November 15, 2017, 09:51 |
Store a UDF variable
|
#1 |
New Member
Join Date: Sep 2017
Posts: 5
Rep Power: 9 |
Hello,
i am using a UDF to set my own property in Fluent (2D, wet steam model) and want to save a UDF variable to be able to plot it in postprocessing. I know i need to use UD Memory and first allocate the appropriate number of Memory locations. In my case i just need one to save the value of the variable "NBTF". Unfortunately i am always getting a constant value in NBTF even though it is a function of the temperature which is changing May someone please tell me if something is wrong with my code? Here is the begin and the part of the code with my NBTF variable. #include "udf.h" #include "stdio.h" #include "ctype.h" #include "stdarg.h" /*Global Constants for this model*/ real ws_TPP = 338.150 ; real ws_aaa = 0.01 ; real cpg = 1882.0 ; DEFINE_ON_DEMAND(I_do_nothing) { } void wetst_init(Domain *domain) { ws_Tc = 647.286 ;/*Critical Temp. */ ws_Pc = 22089000.00 ;/*Critical Pressure */ mw_f = 18.016 ;/*fluid droplet molecular weight (water) */ Rgas_v = 461.50 ;/*vapor Gas Const*/ } . . . real wetst_surft(real T) { Domain *domain; Thread *t; cell_t c; real sigma ; real sigma_u ; real NBTF ; real Tr ; real a1= 82.27 ; real a2= 75.612 ; real a3= -256.889 ; real a4= 95.928 ; real p1=0.98; real p2=-270; real q1=-275; if (T > ws_Tc) T = ws_Tc ; Tr = T/ws_Tc ; sigma_u = 0.001*(a1 + Tr*(a2+ Tr*(a3+ Tr*a4))) ; NBTF = (p1*T+p2)/(T+q1) ; sigma = NBTF*sigma_u ; domain=Get_Domain(1); thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDMI(c,t,0) = NBTF; } end_c_loop (c,t) } return sigma ; } Regards. |
|
November 16, 2017, 04:06 |
|
#2 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
Quote:
real wetst_surft(real T) is just a definition, won't be executed unless you call it in your UDF macros. |
||
November 16, 2017, 06:40 |
|
#3 |
New Member
Join Date: Sep 2017
Posts: 5
Rep Power: 9 |
Hi Gearboy,
thanks for your reply. Sorry i did not get your point. Why do i need to add a new DEFINE Macro? The code is still working fine. The problem is the constant value i am getting for NBTF in my UD Memory. Here are the final lines of my code. You may need it to help me UDF_EXPORT WS_Functions WetSteamFunctionList = { wetst_init, wetst_satP, wetst_satT, . . . wetst_ktl, wetst_surft }; |
|
November 16, 2017, 18:56 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
You should use build-in macros (such as DEFINE_ON_DEMAND, DEFINE_ADJUST or others, depends on your algorithm) to execute your functions.
Read Ansys Fluent Customization manual, you may find there information and tutorials regarding UDMs Best regards |
|
November 20, 2017, 11:41 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Stripping away all irrelevant code, I think it you want something like this:
Code:
DEFINE_ON_DEMAND(I_do_something) { Domain *domain; Thread *t; cell_t c; real NBTF ; real ws_Tc = 647.286 ; real p1=0.98; real p2=-270; real q1=-275; real T; domain=Get_Domain(1); thread_loop_c (t,domain) { begin_c_loop (c,t) { T = C_T(c,t); if (T > ws_Tc) T = ws_Tc ; NBTF = (p1*T+p2)/(T+q1) ; C_UDMI(c,t,0) = NBTF; } end_c_loop (c,t) } } |
|
November 22, 2017, 07:14 |
|
#6 |
New Member
Join Date: Sep 2017
Posts: 5
Rep Power: 9 |
Pakk, thank you for your reply. This is how i managed it and it is working fine
|
|
January 10, 2020, 04:42 |
|
#7 |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 |
hi everybody please help me
i wrote a udf for calculating the mass transfer coefficient. now i want write another udf for calculating the source term of mass transfer. i need to access the mass transfer rate variable(m_dot) how can i calling this variable in define_source udf?? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting cell variable values in a fluid zone using UDF | eromon84 | Fluent UDF and Scheme Programming | 6 | March 28, 2021 12:59 |
Monitor a variable of a UDF | ChristophGradl | Fluent UDF and Scheme Programming | 0 | June 13, 2014 05:12 |
global variable in udf | mohsen zendehbad | FLUENT | 2 | November 22, 2009 06:30 |
udf variable for wall temperature | Kiran | FLUENT | 0 | July 31, 2008 09:31 |
UDF compilation problem -- "undeclared variable" | Henrik Ström | FLUENT | 1 | September 21, 2005 06:25 |