Define Profile, time dependent flow variation query
Hello
I'm trying to send a wave down a tank/conduit that is 100m long and 5x5m and filled with 1m of water. To do this im using a UDF to vary the flow at the input face of the tank (one end). essentially all the UDF is supposed to do is check the time, as an if statement to the effect of; if the time is greater than A, but less than B, then set input mass kg/s to x, else set input mass kg/s to y. This is my first attempt at using fluent or indeed any CFD and im having problems getting it working. I've written two UDFs; one that just inputs a constant flow. I figured if i could get it working at least i would know the basic syntax etc. And one that inputs a wave/flow rise and decline. The first UDF does load in to fluent but doesnt produce the desired result (i don't get any water flowing down the tank), the second wont load as there are syntax issues with the If statement (im not a very experienced programmer and no little about c). heres my code, can any one give me some pointers? ============ UDF 1 a constant flow #include “udf.h” DEFINE_PROFILE(constant_in, t, nv) { real x[ND_ND]; real v; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); v=2; F_PROFILE(f,t,nv) =v; } end_f_loop(f,t) #include “udf.h” DEFINE_PROFILE(wave_in, t, nv) { real x[ND_ND]; real v =5; face_t f; real T; real a =2; real b=4; begin_f_loop(f,t) { F_CENTROID(x,f,t); T=RP_Get_real(“flowtime”); if (T>=a, T<=b); { F_PROFILE(f,t,nv) =v; } else { F_PROFILE(f,t,nv) =2; } } end_f_loop(f,t) } 
similar
Hi SDesmond,
I'm trying to do the same thing: have the UDF "turn on" at a certain time in the simulation, with IF statements. Here is my UDF, which seemed to turn on at right time. notice the 1e4 seconds (when it turns on). The UDF doesn't change rho unless time > 1e4 s. ================================================== ===== #include"udf.h" #define BMODULUS 1.1e15 #define rho_ref 1060 DEFINE_PROPERTY(superfluid_density,c,t) { real rho; real p, dp; real p_operating; real time; p_operating = RP_Get_Real("operatingpressure"); time = CURRENT_TIME; p = C_P(c,t); dp = pp_operating; rho = rho_ref/(1.0dp/BMODULUS); if (dp > BMODULUS/2) rho = rho_ref; if (dp < 0) rho = rho_ref; if (time < 1e4) rho = rho_ref; return rho; } ================================================== ================== Hope this helps! I think in your UDF you have two IF conditions like if (dp < 0, dp > x). Try writing it so its just one like if (dp < 0). That might help, but also you may be right: if that is how to say "if this or this" in C+ let me know ! 
I managed to get my UDF working. Reading the user manuals for fluent, i realised that the UDF code was based on C, so i asked google how you write double clause if statements in C.
you use && symbols between each statement so; if ( y >= a && Y <= b) is the correct syntax. also for some reason you have to multiply your eventual flow mass rate by the vector. This means creating a vector variable y=x[1] and then when defining my F_PROFILE i must multiply my flow by it so if flow rate =F F_PROFILE = F*Y. apart from those two errors i think most of my UDF above is fine 
UDF to read velocity from a text file
Hello,
I would like to set the boundary conditions for LES that can read velocity data from a text file and adapt the boundary conditions accordingly. Any help regarding how to read the data file (velocity.txt) and distribute the values on a grid of points at the input will be appreciated. 
You can use fscanf to read a text file and use it's information as you want.

Could you please help me find the error in this UDF:
#include "udf.h" #include "para.h" #include "prf.h" const int maxz=10, maxy=10, SIZE = 10 * 10; real u[100],v[100],w[100]; int ind[100]; FILE *fp1, *fp2; DEFINE_ON_DEMAND(my_init_func) { #if RP_NODE if (I_AM_NODE_ZERO_P) { Domain *domain; domain = Get_Domain(1); fp1 = fopen("u.txt", "r"); fp2 = fopen("index.txt","r"); int i; for(i = 0;i < SIZE;i++) { fscanf(fp2,"%d",&ind[i]); } printf("Files opened\n"); } #endif } DEFINE_EXECUTE_AT_END(velo_update) { #if RP_NODE if (I_AM_NODE_ZERO_P) { Domain *domain; domain = Get_Domain(1); static const int SIZE = maxy * maxz; int i; for(i = 0;i < SIZE;i++) fscanf(fp1, "%f", &u[i]); } #endif } DEFINE_PROFILE(u_velocity,thread,index) { #if RP_NODE if (I_AM_NODE_ZERO_P) { face_t f; int i = 0; begin_f_loop(f,thread) { F_PROFILE(f,thread,index) = u[ind[i]]; i++; } end_f_loop(f,thread) } #endif } I would like to read the values of u from the file u.text each time step and distribute that on the input (input bc is varing with time). Thanks 
All times are GMT 4. The time now is 04:45. 