|
[Sponsors] |
using define mass transfer udf for cavitation |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 18, 2011, 07:51 |
using define mass transfer udf for cavitation
|
#1 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
Hi!
For the last couple of days, I've beed trying to figure out how to use DEFINE_MASS_TRANSFER in order to put into fluent a cavitation model, which is a bit different than those already integrated. I know there is DEFINE_CAV_RATE macro available to put into fluent your own source and sink terms for cavitation models, but let's leave that besides for now. The problem I'm facing is: I've written a define-mass-transfer udf for Zwart-Gerber-Belamri cavitation model and compiled it into fluent successfully. the idea is to find out if my udf gives the same results as zwart-gerber-belamri model already available in fluent. The udf is written as follows: DEFINE_MASS_TRANSFER(zgb_model, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index) { real R; real p0, abs_p, dp, dp0, source; Thread *liq = THREAD_SUB_THREAD(mixture_thread, from_phase_index); Thread *vap = THREAD_SUB_THREAD(mixture_thread, to_phase_index); p0 = RP_Get_Real("operating-pressure"); abs_p = C_P(c,mixture_thread)+p0; dp = p_vap-abs_p; dp0 = ABS(dp); source = sqrt(2/3*dp0/C_R(c,liq)); if (dp > 0) R = Fe*3*alfa_n*(1-C_VOF(c,vap))/Rb*C_R(c,vap)*source; else R = -Fc*3*C_VOF(c,vap)*C_R(c,vap)/Rb*source; return (R); } some of the constants as alfa_n are of course predefined at the beggining of udf with #define alfa_n ... . The thing is that when I run the simulation, I get no mass transfer. However, the pressure in water doesn't drop below 0 Pa absolute pressure as it otherwise does in my problem(single phase simulation gives me pressures down to -5 bar ). So there is something happening with this udf, I just cannot figure out what exactly. Besides, if I put some constant value for R, I get mass transfer. Therefore I would really appreciate if someone would give a look at the UDF and tell me what I've done wrong. thanks in advance! |
|
December 19, 2011, 05:57 |
|
#2 |
Member
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15 |
If you want to know what is going on in your UDF it is worth trying write some values computed by your UDF to a textfile. You just have to create a file handle (by using fopen method called in DEFINE_INIT macro or some similar) and then write values that you are interested in (e.g. fprintf(handle, "%e,%e\n", dp, R);.
|
|
December 19, 2011, 11:23 |
|
#3 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
hi!
I tried printf, to print results for R to console. But it didn't work, nothing appeared in console. I tried this at two computers, results are always the same-no mass transfer and nothing written in the console. But I'll try your suggestion. p.s.: @Sixkillers, I tried your suggestion, and as I expected, there was no file created or anything written into the file if I myself created a .txt file before. I think there must be something wrong with the compiler or with the thread pointers, and the reason is as follows: I tried to change the UDF, given in my first post, in order to find out which part od the equation for R is problematic. The constants work ok, I got mass transfer and therefore vapor. The values for mass transfer were correct, corresponding to the values of constants (Fe,3,alfa_n and Rb). Then I added source. And got the same result as if I used full equations for R. 0 mass transfer. source itself is: source = sqrt(2/3*dp0/C_R(c,liq)); It contains C_R(c,t) and p0->operating pressure. So my question is: is it possible that I used wrong thread pointers, or is compiler the reason? I use win7, 64bit, ansys 12.1 and for compiled udf's I use visual studio 2010 with sdk command prompt from .net framework 2.0 as is suggested in FAQ on this portal. Last edited by Komon; December 19, 2011 at 19:40. |
|
December 20, 2011, 07:07 |
|
#4 |
Member
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15 |
This is really weird, here is your source code slightly modified for debug purpose. An output file is called DEBUG_REPORT and it should be created after UDF is loaded into Fluent. Operating pressure should be written into it as the simulation proceeds. Also I included some NULL checks. Definitely give it a try.
Code:
static FILE* handle = NULL; DEFINE_EXECUTE_ON_LOADING(init, libname) { handle = fopen("DEBUG_REPORT", "w"); if(handle == NULL) { Message("Unable to create DEBUG_REPORT\n"); abort(); } } DEFINE_MASS_TRANSFER(zgb_model, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index) { real R; real p0, abs_p, dp, dp0, source; Thread *liq = THREAD_SUB_THREAD(mixture_thread, from_phase_index); Thread *vap = THREAD_SUB_THREAD(mixture_thread, to_phase_index); if(liq == NULL) { Message("The liquid thread is NULL\n"); abort(); } if(vap == NULL) { Message("The vapour thread is NULL\n"); abort(); } p0 = RP_Get_Real("operating-pressure"); fprintf(handle, "%e\n", p0); /*ADDED*/ abs_p = C_P(c,mixture_thread)+p0; dp = p_vap-abs_p; dp0 = ABS(dp); source = sqrt(2/3*dp0/C_R(c,liq)); if (dp > 0) R = Fe*3*alfa_n*(1-C_VOF(c,vap))/Rb*C_R(c,vap)*source; else R = -Fc*3*C_VOF(c,vap)*C_R(c,vap)/Rb*source; return (R); } |
|
December 20, 2011, 12:30 |
|
#5 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
@Sixkillers
thanky you very much for your help! I was finally able to see which values are read into Fluent and where the problem is. I found out that all values read from macros like C_P and so on, even operating pressure, are OK. The problem was in equation for source variable. This was always 0, until I wrote it as follows: source = sqrt(2*dp0/(3*rho_liq)); /*rho_liq is C_R(c,liq)*/ then i got mass transfer from liquid to vapor and UDF finally started to give me some results.....which are still weird, but it is a progress I don't know the exact reason why this helped me to get results different from 0 for source.......it isn't that I wrote rho_liq instead of C_R, because only when I reordered the parts of equation I got results different from 0. I'm guessing it also isn't the numerical error because of using division and multiplying in a certain order.....it's just a complete unknown to me. anyway, thanks a lot for your help, I hope I'll be able to return the favour someday |
|
December 27, 2013, 16:15 |
|
#6 | |
New Member
Join Date: Aug 2013
Posts: 3
Rep Power: 13 |
Quote:
the 2nd version works where you do mixed type calculations of integer and double (result will be of type double). |
||
December 27, 2013, 16:47 |
|
#7 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
hi,
yes, it's an old thread and since then I figured out about the trick with integers and doubles it gave me quite some headache, especially as I was really at the beggining of writing the UDFs. but thanks for the 2nd part of your reply, I did never check what happens if you multiply integer and double, I just rather used doubles everywhere. p.s.: happy holidays! |
|
December 18, 2014, 10:10 |
|
#8 | |
New Member
Join Date: Jul 2012
Posts: 25
Rep Power: 14 |
are the results by "Define_mass_transfer" the same with the results by the zawart cavitation model"?
i also use the "define_mass_transfer" to define the cavitation? but the results are divergence. Quote:
|
||
December 22, 2014, 13:50 |
|
#9 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
Hi!
The define_mass_transfer did not work. What did work was define_cavitation_rate or an udf like that-which is specially meant for modelling cavitation source terms. |
|
December 22, 2014, 21:34 |
|
#10 |
New Member
Join Date: Jul 2012
Posts: 25
Rep Power: 14 |
||
December 23, 2014, 02:00 |
|
#11 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
calculation diverged and therefore the results were useless...
|
|
March 10, 2016, 11:38 |
|
#12 |
New Member
khaled oualha
Join Date: Feb 2016
Posts: 2
Rep Power: 0 |
Hello
I want to define the cavitation model from UDF in Fluent and I dont know how, can you help me please. if you have any tutorial or cavitation file to compile in Fluent because I have not made the programing. thanks a lot e-mail: khaled87walha@gmail.com |
|
March 10, 2016, 11:48 |
|
#13 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
Did you check the UDF manual for fluent, more specifically define_cavitation_rate udf description? If I'm not mistaken it has good points on how to include your own udf into fluent.
From the top of my head, you need to use compiled udf functions (there are options to have interpreted and compiled udfs), and you also need to enable singhal cavitation model if you want to then use your own cavitation model via udf. This request about singhal model is a bit funny, since you need to know that fluent then operates with mass and not volume fractions for phases...I think this is also shown in the example for the mentioned udf in the manual... |
|
June 20, 2016, 18:48 |
|
#14 | |
New Member
SHUJAN
Join Date: Jun 2016
Posts: 17
Rep Power: 10 |
Quote:
Hi. I am using DEFINE_MASS_TRANSFER for modelling evaporation-condensation. I can compile my udf successfully, but it is not available in phase interaction tab to hook. Can you tell me how you hook your udf? |
||
June 21, 2016, 03:50 |
|
#15 |
Member
Join Date: Sep 2011
Posts: 43
Rep Power: 15 |
hi,
huh, it's been a long time since I used this, I'm afraid I don't know it from the top of my head anymore. But I don't think I had some issues with chosing it, I think it was quite straightforward in fluent, as for any define_mass_transfer udf. regards |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mass flow in is not equal to mass flow out | saii | CFX | 12 | March 19, 2018 06:21 |
Mass Transfer UDF using Fluent VOF | Anirudh_Deodhar | Fluent UDF and Scheme Programming | 3 | November 18, 2015 10:29 |
Robin B.C. | Yu | FLUENT | 3 | May 27, 2012 05:19 |
UDF for Species Mass Fraction Gradient *IN SPECIFIC ZONE * -- e.g. along axis of sym. | ksiegs2 | Fluent UDF and Scheme Programming | 0 | February 27, 2011 13:55 |
About phase change heat and mass transfer | Michael | FLUENT | 2 | February 13, 2011 02:49 |