January 11, 2017, 16:25
|
Density UDF Divergence
|
#1
|
Member
Join Date: Jun 2016
Posts: 64
Rep Power: 10
|
Hello all.
I am attempting to use a UDF to define a density that changes every iteration. However, the code I am using results in a x-momentum divergence error upon the first iteration. I created a fresh Fluent setup with the only changes from default being using the transient solver and the following UDFs for initialization and material density (hooked correctly of course):
Code:
#include "udf.h"
#define thread_ID 2 /* thread ID of the fluid cell zone */
#define rho_water 997 /* density of water */
DEFINE_INIT(initialize, d)
{
Thread *t = Lookup_Thread(d, thread_ID);
cell_t c;
begin_c_loop(c, t)
{
C_UDMI(c, t, 0) = 1;
}
end_c_loop(c, t)
}
DEFINE_PROPERTY(density, c, t)
{
real Y_water = C_UDMI(c, t, 0);
real rho_f = rho_water * Y_water;
return rho_f;
}
Obviously, the code is simplified from what I am actually using, but the above code is adequate to replicate my problem. What is odd is that the code works if I change the first line of the DEFINE_PROPERTY() macro to:
Code:
real Y_water = 1.0;
I honestly have no idea what the problem is. Any help would be appreciated.
|
|
|