Density UDF
4 Attachment(s)
Hi,
I made simple code to calculate liquid density as Tammannn equation: (p+pc)=k*rho*(t+t0) this is the code: #include "udf.h" #define pc 1944610000 #define t0 3836.94 #define ck 472.26 DEFINE_PROPERTY(liq_rho,c,t) { real temp=C_T(c,t); real p =C_P(c,t); real rhol; rhol=(p+pc)/ck/(temp+t0); return rhol; } When I interpret and loaded the UDF file above in the density option, but the file was not loaded as in the picture below. And I got this warning cpp -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/src" -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/client/src" -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/multiport/src" -I. -DUDF ONFIG_H="<udfconfig.h>" "C:\Users\Ledinhanh07\Desktop\liquid_density.c " temp definition shadows previous definition .entry liq_rho: .local.int c (r0) .local.pointer t (r1) 0 .local.end 0 save .local.double temp (r3) 1 ld.pointer t (r1) 3 push.int 328 5 pointer.incr 6 push.int 1688 8 pointer.incr 9 slda.pointer 10 ld.int c (r0) 12 push.int 8 14 mul.int 15 pointer.incr 16 slda.double .local.double p (r4) 17 ld.pointer t (r1) 19 push.int 328 21 pointer.incr 22 push.int 0 24 pointer.incr 25 slda.pointer 26 ld.int c (r0) 28 push.int 8 30 mul.int 31 pointer.incr 32 slda.double .local.double rhol (r5) 33 push.double 0 35 ld.double p (r4) 37 push.double 1.94461e+09 39 add.double 40 push.double 472.26 42 div.double 43 ld.double temp (r3) 45 push.double 3836.94 47 add.double 48 div.double 49 sto.double rhol (r5) 51 pop.double 52 ld.double rhol (r5) 54 ret.double 55 restore 56 ret.v Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: #f The pictures as in order: 1. interpret UDF 2. load the UDF in the density panel 3. the UDF name: liq_rho is loaded 4. but when I check again, the file liq_rho dissapare Anyone can help me? |
See whether this code works
Code:
#include "udf.h" |
Thank blackmask,
I try your code, but still got the trouble. I dont know why I could not load the UDF for water density. |
hello every body...........need for help
i try to make an UDF for changing density as a function of coordinates(say z coordinate) but it didnot work in fluent. this is my UDF. #include "udf.h" DEFINE_PROPERTY(ANODE_DENSITY, thread, position) { float x[ND_ND]; /* this will hold the position vector */ float t,air,anode,electrolyte,po,va,ve,n,z,a,r,l,p,d,w,y ,u,POROSITY; cell_t c; t= 0.00008; /* ANODE THICKNESS */ air=1.28; anode=4500.; electrolyte=6010.; n=2; z=5; w=(n+z)/n; y=n/(n+z); r=pow(w,n); l=pow(y,z); a=r/(1-l); begin_c_loop(c,thread) { C_CENTROID(x, c, thread); va=x[3]/t; ve=1-va; u=x[3]/t; p= pow(u,n); d= pow(u,z); POROSITY = (a*p*(1-d)); po= ((va*anode)+(ve*electrolyte)); C_R(c, thread, position) =po*(1-POROSITY)+air*POROSITY; } end_c_loop(c, thread) } |
All times are GMT -4. The time now is 16:55. |