CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF to change density in species transport (http://www.cfd-online.com/Forums/fluent/35245-udf-change-density-species-transport.html)

Karthik December 8, 2004 07:14

UDF to change density in species transport
 
Hello all,

I am trying to fix upthe density values in a three dimensional cylindrical enclosure for which I give the density distribution at each cells. I am using species transport model. Interpreting does not display any result but when iterated Fluent displays error saying

"chip-exec: den_adjust: wrong return type: float udf function expected"

Could you please help to solve this problem. The udf i used is

#include "udf.h" DEFINE_ADJUST(den_adjust,d) {

Domain *d;

Thread *t;

cell_t c;

FILE *fp1;

real arr1=0.;

fp1=fopen("densitynew.dat","r");

begin_c_loop(c,t)

{

fscanf(fp1,"%g",&arr1);

C_R(c,t)=arr1;

}

end_c_loop(c,t)

printf("The density of cells are patched successfully");

fclose(fp1); }

Andrew Garrard December 8, 2004 07:45

Re: UDF to change density in species transport
 
Well I am unfamiliar with reading in data from a file, but from your UDF I can see that you are trying to conduct a cell loop over a thread that has not been defined. I don't know if that is causing your error, but if it isn't, it would cause a different one.

When I am creating UDF's I usually make them very simple, see if they work and then increase the complexity. That way de bugging becomes very easy. Try getting C_R(c,t) to be a constant value first, and see if that works before trying to read from a file.

Chimwemwe Banda December 8, 2004 07:59

Re: UDF to change density in species transport
 

Karthik December 8, 2004 08:31

Re: UDF to change density in species transport
 
Thanks Andrew for your attempt. But i have tried with declaring the cell values with a constant density also. I face with the same error. I hope that this error is not due to the variable values but in some other thing. Whats wrong in "return type" that could be seen in the error message?

chip-exec: den_adjust: wrong return type: float udf function expected

hongfw December 8, 2004 09:01

Re: UDF to change density in species transport
 
If you amend your UDF like following, The problem may be solved.

#include "udf.h" DEFINE_ADJUST(den_adjust,d) {

Thread *t;

cell_t c;

FILE *fp1;

real arr1=0.;

fp1=fopen("densitynew.dat","r");

thread_loop_c(t, d) { begin_c_loop(c,t)

{

fscanf(fp1,"%g",&arr1);

C_R(c,t)=arr1;

}

end_c_loop(c,t)

} printf("The density of cells are patched successfully");

fclose(fp1); }


Andrew Garrard December 8, 2004 09:03

Re: UDF to change density in species transport
 
It the first part of my message I mention this:

Well I am unfamiliar with reading in data from a file, but from your UDF I can see that you are trying to conduct a cell loop over a thread that has not been defined.

When you invoke the cell loop, you are applying a condition to every cell on a particular "cell thread". You delcare a thread pointer, in your case *t, but you do not tell the UDF what thread it is.

You will need to put in a line something like this

Thread *t = Lookup_Thread(ID, dom)

Where ID is the boundary ID, avaliable in the boundary condition panel and domain is your domain pointer, as passed in the argument of the DEFINE_ADJUST. There is more info at 6.5.7 in the UDF manual.


cg December 8, 2004 18:19

Re: UDF to change density in species transport
 
Try using a

DEFINE_PROPERTY(lem_density,c,t) { real rho;

rho = ...

return rho; }

and hook this to density in the Materials panel


All times are GMT -4. The time now is 11:51.