Simulation with UDF for species mass fraction and velocity profile
Hi
I want to simulate a simple pipe (radius= 0.0005 m) in 3D. The inlet has 2 boundary conditions written with UDF: the first boundary condition is the parabolic profile of velocity  the second one is a parabolic profile of mass fraction of a species without reaction along the pipe. I calculate the velocity with UDF (it works) and I save it in a file .dat. After Fluent has calculated it, I keep the file .dat with the profile of velocity, I turn off the NavierStokes model and I activate the species model (I'd like to separate NavierStokes model and species model because it reduces the the time of simulation). The UDF for the mass fraction is correctly interpreted by Fluent, I can select my UDF profile in species mass fraction boundary condition, but when I press the button "calculate" I receive this message: "FLUENT received fatal signal (ACCESS_VIOLATION)". Does anybody know what to do? Can I give two different UDF in this way? Is there anything wrong in my UDF? My UDF for mass fraction of a species is here: # include "udf.h" # include "mem.h" DEFINE_PROFILE (indop, thread, nv) { face_t f; real x; real y; real n[ND_ND]; real coeff = 0.01; real r = 0.0005; real r2 = (pow((r),2)); begin_f_loop (f,thread) { F_CENTROID(n,f,thread); x=n[0]; y=n[1]; F_YI(f,thread,nv)= coeff(coeff/r2) * ( (pow((x),2))+(pow((y),2)) ); } end_f_loop (f,thread) } Thanks a lot, Virgy 
F_YI(f,thread,nv) ???> F_PROFILE(f,thread,nv)???

UDF for profile with fopen function
Quote:
Now, can I ask another question to you? I want to modify the last UDF in this way: now the profile has to change every time Fluent changes time step (my simulation now is transient with a fixed physical time step = 0.1 s). I define and initialize an array A. A contains the values (constant) for my profile. Example: time step #1 : F_PROFILE=A1; time step #2 : F_PROFILE=A2; time step #n : F_PROFILE=An. I use "RP_Get_Integer" to take the current number of iteration and I put it in the variable "n_iter". I define the profile in this way: F_PROFILE= A[n_iter]; This UDF works correctly!! But if the values of array A are taken from an external file .txt with the function fopen, Fluent exit automatically when I press the button "Calculate" (the UDF is correctly interpretated). Do you know why? This is my new UDF: #include "udf.h" real x; real y; real A[5]; // the array with coefficients for my profile of species FILE *fp; // pointer for the function fopen DEFINE_PROFILE(mass_fraction_profile, thread, i) { int n_iter = RP_Get_Integer ("timestep"); /* every time step, the variable n_iter will contain a new value */ real a[ND_ND]; face_t f; begin_f_loop(f,thread) { F_CENTROID(a,f,thread); x=a[0]; y=a[1]; fp = fopen ("coefficients", "r"); // coefficients is my file .txt F_PROFILE(f,thread,i) = A[n_iter]; fclose (fp); } end_f_loop (f,thread) } My file "coefficients.txt": A[0]=0.1; A[1]=0.05; A[2]=1; A[3]=0.6; A[4]=0.3; Thank you!! ;) Virgy 
Quote:
i think you should use "F_PROFILE(f,thread,nv)= coeff(coeff/r2) * ( (pow((x),2))+(pow((y),2)) );'' , not ''F_YI(f,thread,nv)= coeff(coeff/r2) * ( (pow((x),2))+(pow((y),2)) );" second, i recommend you to use "compile pattern " not ''interpreted pattern" 
Quote:
fp = fopen ("coefficients", "r"); // coefficients is my file .txt it just open the your file "coefficients.txt" and return the pointer of your file to the pointer fp. no other use. it can not read the content of your file.txt .so your code is wrong you can achieve the function in other simple way. #include "udf.h" DEFINE_PROFILE(mass_fraction_profile, thread, i) { int n_iter = RP_Get_Integer ("timestep"); if(n_iter<1) {F_PROFILE(f,thread,i) = 0.1; } if(1<n_iter<2) {F_PROFILE(f,thread,i) = 0.05; } if(2<n_iter<3) {F_PROFILE(f,thread,i) = 1; } if(3<n_iter<4) {F_PROFILE(f,thread,i) = 0.6; } if(4<n_iter<5) {F_PROFILE(f,thread,i) = 0.3; } } 
Quote:
Right! Thank youuu!! Could you help me again? My function now is more ardous: at the end it makes the same job of the previous one, but now there isn't only one array, but seven arrays and everyone has 2174 elements. Furthermore my f_profile is more complicated. Fluent correctly interprets the function (why do you suggest me compiler mode?) but, during iterations it gives this error: "chip: invalid opcode".. what kind of mistake I'm making now? Thank you!!!! My UDF is: #include "udf.h" real x; real y; int t; double A[2173]; double B[2173]; double C[2173]; double D[2173]; double E[2173]; double F[2173]; double G[2173]; DEFINE_PROFILE(mass_fraction_profile, thread, i) { int n_iter = RP_Get_Integer ("timestep"); real a[ND_ND]; face_t f; begin_f_loop(f,thread) { F_CENTROID(a,f,thread); x=a[0]; y=a[1]; /*initialize my arrays*/ A[577]=0.99765443333; A[578]=58493022717118; . . . A[2750]=47392911.04883626; B[577]=3447372.4947262; . . . B[2750]; // the same for C[], D[], E[], F[], G[] if (n_iter<577) {F_PROFILE(f,thread,i) =0;} if (n_iter>2750) {F_PROFILE(f,thread,i) =1;} else { t=(n_iter577); F_PROFILE(f,thread,i) = A[t]*pow(((pow((x+0.0024),2))+(pow((y),2))),6))+ B[t]*pow(((pow((x+0.0024),2))+(pow((y),2))),5))+ C[t]*pow(((pow((x+0.0024),2))+(pow((y),2))),4))+ D[t]*(pow(((pow((x+0.0024),2))+(pow((y),2))),3))+ E[t]*(pow(((pow((x+0.0024),2))+(pow((y),2))),2))+ F[t]*((((x+0.0024),2))+(pow((y),2)))+G[t];} } end_f_loop (f,thread) } 
Quote:
then i recommend you to read the content of"file operate"of"C Programme" by the way. what is the problem you simulate 
Quote:
The profile has to change every time Fluent changes time step (my simulation now is transient with a fixed physical time step = 0.9 s). I'd like to simulate a drug that enters in the pipe only after 8.6 minutes (577*0.9 s). It enters with a profile variabile in time, and after 41.25 minutes (2750*0.9 s) it enters with a constant mass fration=1. The arrays A, B, C, D, E, F, G contain coefficients to multiply to the raidius of my pipe: ((pow((x+0.0024),2))+(pow((y),2)) the variable t=(n_iter577) means: timestep=1 > t=577577=0 > in my f_profile: A[0], B[0], C[0]...G[0]. timestep=2 > t=578577=1 > in my f_profile: A[1], B[1], C[1]...G[1]. ... timestep=2173 > t=2750577=2173 > in my f_profile A[2173], B[2173]...G[2173]. So the profile of mass fraction changes every time step. In particular: if time step < 577 I'd like the mass fraction is always 0; if time step > 2750 I'd like the mass fraction is always 1. P.s. Where I can find "file operate"of"C Programme"? 
Quote:
"file oprate" is the content of C programme ,did you study it at university? you also can search it on internet. i have it ,but i am afraid that you can not understand the language.haha... and what is your email? 
All times are GMT 4. The time now is 20:39. 