CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   [solidification/melting] udf to init Temperature (https://www.cfd-online.com/Forums/fluent-udf/109842-solidification-melting-udf-init-temperature.html)

 ghost82 November 28, 2012 02:53

[solidification/melting] udf to init Temperature

Hi,
I'm trying to solve a solidification-melting problem and I have to initialize temperature, function of x coordinate: I used the following udf, which compiles/interprets fine:

Code:

```#include "udf.h" DEFINE_INIT(my_init_func,d) {   cell_t c;   Thread *t;   real xc[ND_ND];   /* loop over all cell threads in the domain  */   thread_loop_c(t,d)     {       /* loop over all cells  */       begin_c_loop_all(c,t)         {           C_CENTROID(xc,c,t);             if (xc[0] <= 0.015)                 C_T(c,t) = 346.15;             else if (xc[0] <= 0.01575 && xc[0] > 0.015)                 C_T(c,t) = -2208.*xc[0]+351.171;             else if (xc[0] <= 0.01625 && xc[0] > 0.01575)                 C_T(c,t) = -414.*xc[0]+322.9155;             else if (xc[0] <= 0.01675 && xc[0] > 0.01625)                 C_T(c,t) = -66.*xc[0]+317.2605;             else if (xc[0] <= 0.01725 && xc[0] > 0.01675)                 C_T(c,t) = -8.*xc[0]+316.289;             else if (xc[0] <= 0.01775 && xc[0] > 0.01725)                 C_T(c,t) = -2.*xc[0]+316.1855;             else                 C_T(c,t) = 316.15;         }       end_c_loop_all(c,t)     } }```
Solidus temperature for my problem is 316.15 K, liquidus temperature 327.15 K;
However, after initializing, temperature contour plot looks fine, but when I plot liquid fraction my domain is 100% liquid....

Do I have to patch also the liquid fraction in my udf?If yes, how?

Daniele

 ghost82 November 28, 2012 04:15

I initialized also the liquid fraction thanks to C_LIQF(c,t) to 0; my problem was that I initialized all my domain, whch is composed by solid and fluid, but, as the fluent guide says, C_LIQF(c,t) is available only for fluid zones, so I received an access violation..now all is ok (I think).

..but I didn't know that I had to initialize also the liquid fraction, I thought that fluent would compute it automatically.

Daniele

 yashganatra June 19, 2013 02:31

Hi,
I am also working on the same problem. Were you able to solve this problem? I know it's late, you should also update enthalpy right to get the updated liquid fraction? Did you use the inbuilt solidification module?

 All times are GMT -4. The time now is 12:08.