|
[Sponsors] |
Using C_VOF to compute saturation temperature |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 26, 2019, 23:30 |
Using C_VOF to compute saturation temperature
|
#1 |
New Member
Alexandre Coulombe
Join Date: Feb 2019
Posts: 7
Rep Power: 7 |
Hello everyone,
I want to simulate humid air condensing on a cold surface. I'm using the VOF multiphase model with Lee condensation-evaporation model. I'm trying to write my first UDF to define the saturation temperature of humid air in the Lee model based on the C_VOF of water vapor, the water vapor density, the C_VOF of air, the air density and the temperature. I tried to follow this thread: UDF for volume fraction #include "udf.h" #define rho_water_vapor 0.59; #define rho_air 1.2; #define mix_pressure 101325; DEFINE_PROPERTY(saturation_temperature,c,t) { real sat_temp; real partial_vapor_pressure; cell_t cell; Thread **pt; Thread *cell_threads; Domain *mixture_domain; { mp_thread_loop_c(t, mixture_domain, pt) { begin_c_loop(cell,pt) { real temp = C_T(cell,pt[0]); real VOF_air = C_VOF(cell,pt[2]); real VOF_water_vapor = C_VOF(cell,pt[2]) w = (VOF_water_vapor*rho_water_vapor)/(VOF_air*rho_air); sat_temp = w*0.008-0.14; } end_c_loop(cell,pt) } return sat_temp; } } I'm getting parse error on line 21. I think that the domain 1 is the mixture level, 1 is the air phase and 2 is the water vapor phase. However I'm not sure how to use mp_thread_loop_c and C_VOF. Do you have any tips for me? Alex |
|
February 27, 2019, 01:51 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
read your console output next time
your code Code:
real VOF_water_vapor = C_VOF(cell,pt[2]) Code:
real VOF_water_vapor = C_VOF(cell,pt[2]); |
|
February 27, 2019, 02:23 |
|
#3 |
New Member
Alexandre Coulombe
Join Date: Feb 2019
Posts: 7
Rep Power: 7 |
Thank you Alexander, however I'm still getting the same errors.
|
|
February 27, 2019, 04:09 |
|
#4 |
Member
annan
Join Date: Nov 2016
Posts: 72
Rep Power: 10 |
Dear Alex2293,
First of all, I would recommand defining the mixture domain as : Domain *mixture_domain = Get_Domain(1); Is your air volume fraction equal to your water vapor volume fraction ? because you are assigning them the same value real VOF_air = C_VOF(cell,pt[2]); real VOF_water_vapor = C_VOF(cell,pt[2]); How many phases do you have ? which one is the primary phase and which ones are the secondary phases ? This would enable me help you to use the right index to define the right volume fraction. Regards, Annan |
|
February 27, 2019, 05:15 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
The problem is in the first few lines:
Code:
#define rho_water_vapor 0.59; #define rho_air 1.2; #define mix_pressure 101325; You should not put the semicolon at the end. These lines are not for the c-compiler, but for the pre-processor. The lines should be: Code:
#define rho_water_vapor 0.59 #define rho_air 1.2 #define mix_pressure 101325 |
|
February 27, 2019, 08:09 |
|
#6 |
New Member
Alexandre Coulombe
Join Date: Feb 2019
Posts: 7
Rep Power: 7 |
Thanks to both of you. The UDF code now looks like this:
#include "udf.h" #define rho_air 1.2 #define rho_wv 0.59 #define mix_pressure 101325 DEFINE_PROPERTY(saturation_temperature,c,thread) { real temp = C_T(c,thread); real sat_temp; real w; Domain *mix_domain = Get_Domain(1); Thread *mix_thread; Thread **pt; cell_t cell; mp_thread_loop_c(mix_thread, mix_domain, pt) { begin_c_loop(cell,pt) { real VOF_wv = C_VOF(c,pt[3])*rho_wv; real VOF_air = C_VOF(c,pt[2])*rho_air; w = VOF_wv / VOF_air; sat_temp = w * 101325 * 0.008; end_c_loop(cell,pt) } } return sat_temp; } I can add it as an interpreted UDF without errors but Fluent crashes when I initialize. I was also able to hook it to the lee model in the phase interaction dialog. I have 3 phases. The air is the main phase, the water vapor is the second phase and the liquid water is the third phase. Should I use this UDF as a compiled one? I can only start Fluent in serial mode, if I use the parallel mode it crashes right after reading the udf file. Alex |
|
February 27, 2019, 13:08 |
|
#7 |
New Member
Alexandre Coulombe
Join Date: Feb 2019
Posts: 7
Rep Power: 7 |
Annan, I have 3 phases. The principal phase is air, the second is water vapor and the third is liquid water.
I'm simulating a simple case where I have a closed volume of air at 20°C 50%RH which is around 0.01VOF of water vapor. The bottom surface of the enclosure is at 0°C. The humid air should cool down below the dew point and form a water film on the cold surface. I removed the semicolons at the end and assigned the correct pt[] values. I don't have parse errors anymore. It can be interpreted and run in serial mode only. However I think that instead of using the Lee model and a UDF to define the saturation temperature I should use a source term to define the mass transfer rate. The present UDF returns a saturation temperature, but how does it tell Fluent that there is a different saturation temperature for each cell? Thanks again for your help, it's really appreciated. |
|
February 28, 2019, 04:03 |
|
#8 |
Member
annan
Join Date: Nov 2016
Posts: 72
Rep Power: 10 |
Dear Alexandre,
First of all, I still see a small error in your UDF, there are two lines which need to be switched like this : sat_temp = w * 101325 * 0.008; } end_c_loop(cell,pt) Also, I don't think it is appropriate to use a cell loop inside a DEFINE_PROPERTY Macro, this is how I would write the UDF : #include "udf.h" #define rho_air 1.2 #define rho_wv 0.59 #define mix_pressure 101325 DEFINE_PROPERTY(saturation_temperature,c,thread) { real temp = C_T(c,thread); real sat_temp; real w; Thread *t_air = THREAD_SUB_THREAD(thread,0); Thread *t_wv = THREAD_SUB_THREAD(thread,1); Thread *t_wl = THREAD_SUB_THREAD(thread,2); real VOF_wv = C_VOF(c,t_wv)*rho_wv; real VOF_air = C_VOF(c,t_air)*rho_air; w = VOF_wv / VOF_air; sat_temp = w * 101325 * 0.008; return sat_temp; } As for how fluent understands that there is a different saturation temperature in each cell : - the DEFINE_PROPERTY macro is executed in a cell of the domain => DEFINE_PROPERTY(saturation_temperature,c,thread) - it calculates the property sat_temp each time as it is executed in a cell - it returns the value sat_temp in that cell Now, as the volume fraction, temperature and other properties change from one cell to another, fluent will assign a different saturation temperature for each cell. Hope this will help, good luck. Regards, Annan |
|
February 28, 2019, 04:20 |
|
#9 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Since we are focussing on details:
Code:
#include "udf.h" #define rho_air 1.2 #define rho_wv 0.59 #define mix_pressure 101325 #define magic_constant 0.008 DEFINE_PROPERTY(saturation_temperature,c,thread) { Thread *t_air = THREAD_SUB_THREAD(thread,0); Thread *t_wv = THREAD_SUB_THREAD(thread,1); real VOF_wv = C_VOF(c,t_wv)*rho_wv; real VOF_air = C_VOF(c,t_air)*rho_air; if (VOF_air>0) { w = VOF_wv / VOF_air; return w * mix_pressure * magic_constant); } else { return 1000; } } |
|
March 4, 2019, 08:29 |
|
#10 |
New Member
Alexandre Coulombe
Join Date: Feb 2019
Posts: 7
Rep Power: 7 |
Thanks again to both of you, now my UDF is running without errors and the mass conservation is ok.
The mass of water vapor in the air at the beginning equals the mass of water after a few iterations. However, the water doesn't form a film a the bottom of the domain (rectangular domain without flow, cold bottom surface). It stays suspended with a very small density gradient. I activated gravity and sharp in the interface modeling. It forms a film when I choose the interfacial anti-diffusion option. However, it then diverge I get the message Error: Divergence detected in AMG solver: Pressure correction. Do anyone have an idea? Thanks again |
|
December 12, 2021, 03:44 |
|
#11 |
New Member
Babak
Join Date: Oct 2021
Posts: 12
Rep Power: 5 |
Hello Alexandre.
By any chance do you have the final form of your code which is working without error? is it possible for you to share it with me? That would be a big help. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Ansys CFX problem: unexpected very high temperatures in premix laminar combustion | faizan_habib7 | CFX | 4 | February 1, 2016 18:00 |
Plotting Saturation Temperature | Jannssen | CFX | 4 | January 27, 2016 17:04 |
unexpected constant Temperature on a clip surface | Sungki | OpenFOAM Running, Solving & CFD | 0 | August 4, 2015 05:50 |
Calculation of the Governing Equations | Mihail | CFX | 7 | September 7, 2014 07:27 |
Bulk temperature Tf is obtained from total or static temperature? | NPU_conanxie | FLUENT | 0 | March 30, 2011 06:56 |