CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF saturation temperature (evaporation model Fluent) (https://www.cfd-online.com/Forums/fluent-udf/218352-udf-saturation-temperature-evaporation-model-fluent.html)

bbarbier07 June 18, 2019 04:24

UDF saturation temperature (evaporation model Fluent)
 
Hi everyone,

I want to simulate the evaporation of water with VOF model (water-liquid to water-vapor). I am using the evaporation-condensation model. In this model, we can put the desired saturation temperature (373.15 K for water). However this value is not always constant because it can change with pressure. I want to evaporate water by decreasing the pressure.
That's why I want to create a UDF to compute this saturation temperature in function of pressure (if pressure decreases, the saturation temperature decreases too...).

Here what I wrote (but nothing happens) :

#include "udf.h"

DEFINE_PROPERTY(saturation_temp,c,t)
{
real sat_t;
real vapor_p;
real static_p = C_P(c,t);
real operating_p = RP_Get_Float("operating-pressure");
vapor_p = static_p + operating_p; // absolute pressure = static pressure + operating pressure
sat_t = (1723.6425/(8.05573-log(vapor_p/133.322))-233.08)+273.15; // Pressure in Pa to mmHg (Yaws)
return sat_t;
}

I cannot find something about it, I do not know if I have to use DEFINE_PROPERTY... Can anyone help me?
Thanks in advance!

AlexanderZ June 19, 2019 00:03

you should hook your UDF
change constant 373.15K to your UDF function

best regards

bbarbier07 June 19, 2019 03:28

Quote:

Originally Posted by AlexanderZ (Post 736627)
you should hook your UDF
change constant 373.15K to your UDF function

best regards

Hi AlexanderZ, thank you for your answer but I forgot to say that I have compiled and hooked my UDF to the saturation temperature...
So the problem is still here. Do you think a DEFINE_PROPERTY is ok to define the temperature?

AlexanderZ June 20, 2019 00:45

yes it is OK

try this
Code:

#include "udf.h"

DEFINE_PROPERTY(saturation_temp,c,t)
{
real sat_t;
real vapor_p;
real static_p;
real operating_p;
static_p=C_P(c,t);
operating_p = RP_Get_Float("operating-pressure");
vapor_p = static_p + operating_p; // absolute pressure = static pressure + operating pressure
sat_t = (1723.6425/(8.05573-log(vapor_p/133.322))-233.08)+273.15; // Pressure in Pa to mmHg (Yaws)
return sat_t;
}

best regards

bbarbier07 June 20, 2019 03:30

Quote:

Originally Posted by AlexanderZ (Post 736736)
yes it is OK

try this
Code:

#include "udf.h"

DEFINE_PROPERTY(saturation_temp,c,t)
{
real sat_t;
real vapor_p;
real static_p;
real operating_p;
static_p=C_P(c,t);
operating_p = RP_Get_Float("operating-pressure");
vapor_p = static_p + operating_p; // absolute pressure = static pressure + operating pressure
sat_t = (1723.6425/(8.05573-log(vapor_p/133.322))-233.08)+273.15; // Pressure in Pa to mmHg (Yaws)
return sat_t;
}

best regards

I tried it and it is the same result, nothing happens.
Actually I want to evaporate water liquid (to water vapor) in a 2D container by warming the bottom wall. I did it correctly with the saturation temperature as a constant but when I replace with my UDF nothing happens, there is no water vapor. I should get the same result as the case with a constant...
If you have another idea thanks in advance...
Best regards

AlexanderZ June 20, 2019 21:19

Code:

#include "udf.h"

DEFINE_PROPERTY(saturation_temp,c,t)
{
return 373.15;
}

try this, if it works, than you'll get the same result as before -> which means UDF works well

best regards

bbarbier07 June 21, 2019 03:44

I tried it, it works well so UDF works but not the one function of pressure...
Best regards

AlexanderZ June 21, 2019 05:03

1. try with othe temperature 300, 400
2. try this
Code:

#include "udf.h"

DEFINE_PROPERTY(saturation_temp,c,t)
{
real sat_t;
real vapor_p;
vapor_p = C_P(c,t) + op_pres; // absolute pressure = static pressure + operating pressure
sat_t = (1723.6425/(8.05573-log(vapor_p/133.322))-233.08)+273.15; // Pressure in Pa to mmHg (Yaws)
return sat_t;
}

best regards

bbarbier07 June 21, 2019 05:54

I have found the solution!
Actually, there were 2 problems in my UDF. The first one was the operating pressure: change Float to Real. The second was with the "log": the correct formulation for a variable is "double log10 (double x)".

You can find the final code:

#include "udf.h"

DEFINE_PROPERTY(saturation_temp,c,t)
{
real sat_t;
real vapor_p;
real static_p = C_P(c,t);
real operating_p = RP_Get_Real ("operating-pressure");
vapor_p = static_p + operating_p; // absolute pressure = static pressure + operating pressure
sat_t = (1723.6425/(8.05573-((double)log10((double)vapor_p/133.322)))-233.08)+273.15; // Pressure in Pa to mmHg (Yaws)
return sat_t;
}

AlexanderZ June 23, 2019 22:02

when you start fluent in double precision regime all "reals" are double

best regards

stanlee8 June 12, 2021 23:35

Hi Sir,

Could you please help?
I used your code and it goes "The computed saturation temperature <=0.0.
What should I do? it has already driven me crazy!!

AlexanderZ June 15, 2021 04:18

most likely you didn't put correct operating pressure

bidax March 14, 2024 07:29

Quote:

Originally Posted by bbarbier07 (Post 736895)
I have found the solution!
Actually, there were 2 problems in my UDF. The first one was the operating pressure: change Float to Real. The second was with the "log": the correct formulation for a variable is "double log10 (double x)".

You can find the final code:

#include "udf.h"

DEFINE_PROPERTY(saturation_temp,c,t)
{
real sat_t;
real vapor_p;
real static_p = C_P(c,t);
real operating_p = RP_Get_Real ("operating-pressure");
vapor_p = static_p + operating_p; // absolute pressure = static pressure + operating pressure
sat_t = (1723.6425/(8.05573-((double)log10((double)vapor_p/133.322)))-233.08)+273.15; // Pressure in Pa to mmHg (Yaws)
return sat_t;
}


Hiiiii
what is the basis of this formula "sat_t" is there a detailed explanation
thanks in advance


All times are GMT -4. The time now is 06:23.