UDF don't work
Hi everybody,
I'm new in this forum, and I'm not really able with UDF. In my case study, I have 2 inlets and I need to define 4 UDF (2 for velocity, 2 for epslon). I know that I can interpret only one UDF, so I write them in one file, but the software interpret only the first two. Attached the UDF file (note that until now I used them without problems, and that the software don't give me any message error). # include "udf.h" DEFINE_PROFILE(inlet_velocity_first, thread, index) { real p[ND_ND]; real y, u0=3.56, yref=10.0; face_t f; begin_f_loop (f, thread) { F_CENTROID (p,f,thread); y=p[1]; F_PROFILE(f,thread,index)=-u0*pow(y/yref,0.14); } end_f_loop(f, thread) } # include "udf.h" DEFINE_PROFILE(inlet_epson_first, thread, index) { real p[ND_ND]; real y, y0=0.03, u0=0.257; face_t f; begin_f_loop (f, thread) { F_CENTROID (p,f,thread); y=p[1]; F_PROFILE(f,thread,index)=(1/0.42)*pow(u0,3.0)/(y+y0); } end_f_loop(f, thread) } # include "udf.h" DEFINE_PROFILE(inlet_velocity_second, thread, index) { real p[ND_ND]; real y, u0=1.47, yref=10.0; face_t f; begin_f_loop (f, thread) { F_CENTROID (p,f,thread); y=p[1]; F_PROFILE(f,thread,index)=u0*pow(y/yref,0.14); } end_f_loop(f, thread) } # include "udf.h" DEFINE_PROFILE(inlet_epson_second, thread, index) { real p[ND_ND]; real y, y0=0.03, u0=0.106; face_t f; begin_f_loop (f, thread) { F_CENTROID (p,f,thread); y=p[1]; F_PROFILE(f,thread,index)=(1/0.42)*pow(u0,3.0)/(y+y0); } end_f_loop(f, thread) } Thanks a lot! |
There are some non-printing characters after the last "}" in the second and fourth DEFINE_PROFILE macro, and one of them is the NULL character. Please delete any thing from the last "}" line of the second macro and the #include line of the third macro, and retype the "}". You only need to include "udf.h" once.
|
Now it works, thanks a lot for your help! :)
|
Dear nicoletta90 and blackmask
I also want to write a UDF of transient mass flow rate for inlet boundary. I want to inject a gas with flow rate of 1.5 Cubic meter per hour, i.e. same flow rate to be injected every one hour of the physical flow-time. Do you have any experience with this? do you think the code below might fit the case? #include "udf.h“ DEFINE_PROFILE(transient_mf, thread, position) { face_t f ; real t = RP_Get_Real("flow-time"); /* to calculate the physical time step*/ begin_f_loop(f, thread) { if (t==0,3600, 2*3600, 3*3600, 4*3600, 5*3600) { F_PROFILE(f, thread, position) = 53; } else { F_PROFILE(f, thread, position) = 0; } } end_f_loop(f, thread) } |
All times are GMT -4. The time now is 08:01. |