First of all ANSYS Stuff colleagues are not here to debug your code as this is mainly your task. We are here only to provide guidance.

The snipped provided has to work:

#include "udf.h"

DEFINE_PROPERTY(density_function,c,t)

{

real rho;

real y, x[ND_ND];

C_CENTROID(x,c,t);

y = x[1];

rho =y*1000 ;/*define your function rho(y)*/

return rho;

}

You might past you final function here.