UDF for Mass Flow at the Outlet: ERROR ACCESS VIOLATION
I would really appreciate if somebody take a look in the UDF and give me some advices.
I'm trying to define the temperature at the Pressure Inlet (ID=9) from the temperature at Pressure Outlet (ID=10). So i've written an UDF that in order: 1. defines temperature dependent viscosity; 2. calculates massflow at outlet; 3. calculates massflow at inlet; 4. calculates averaged temperature at outlet; 5. defines the temperature for the pressure inlet. At the beginning of the solution the following error occurs: iter continuity x-velocity y-velocity z-velocity energy time/iter Error: C:\PROGRA~1\ANSYSI~1\v145\fluent\fluent14.5.0\win6 4\3d\fl1450s.exe 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 Viscosity UDF works for sure so i've tried to run the simulation only with the following UDF: /************************************************** ******************* Define scalars for following operations ************************************************** ********************/ real flowout_tot; real flowin_tot; real tavg_tot; /************************************************** ******************* UDF measuring mass flow at pressure outlet ID 10 ************************************************** ********************/ DEFINE_EXECUTE_AT_END(measure_flow_out) { Domain *d; real flowout; cell_t c; Thread *tout; face_t f; d = Get_Domain(1); tout = Lookup_Thread(d,10); begin_f_loop(f,tout) { flowout+=F_FLUX(f,tout); } end_f_loop(f,tout) printf("MASS Flow Rate Out: %g\n",flowout); flowout_tot = flowout; flowout = 0.; } I have seen in other threads something very similar so i really don't understand where is the problem. Thanks in advice |
Looking the UDF row by row i've found there was a Get_Domain_(11) instead of Get_Domain(1).
Now the UDF is working. I've attached the complete UDF for those who are looking for something similar, and for those who have useful advice to give me. /************************************************** ******************* UDF for Temperature dependent Dynamic Viscosity ************************************************** ********************/ #include "udf.h" #include "math.h" DEFINE_PROPERTY(cell_viscosity,cell,thread) { real mu_lam; real temp = C_T(cell,thread); { mu_lam=0.0000631*pow(10,3.722*pow(1+(temp-273)/(135),-1.102)); return mu_lam; } } /************************************************** ******************* Define scalars for following operations ************************************************** ********************/ real flowout_tot; real flowin_tot; real tavg_tot; /************************************************** ******************* UDF measuring mass flow at pressure outlet ID 10 ************************************************** ********************/ DEFINE_EXECUTE_AT_END(measure_flow_out) { Domain *d; real flowout; cell_t c; Thread *tout; face_t f; d = Get_Domain(1); tout = Lookup_Thread(d,10); begin_f_loop(f,tout) { flowout+=F_FLUX(f,tout); } end_f_loop(f,tout) printf("MASS Flow Rate Out: %g\n",flowout); flowout_tot = flowout; flowout = 0.; } /************************************************** ******************* UDF measuring mass flow at pressure inlet ID 9 ************************************************** ********************/ DEFINE_EXECUTE_AT_END(measure_flow_in) { Domain *d; real flowin; cell_t c; Thread *tin; face_t f; d = Get_Domain(1); tin = Lookup_Thread(d,9); begin_f_loop(f,tin) { flowin+=F_FLUX(f,tin); } end_f_loop(f,tin) printf("MASS Flow Rate In: %g\n",flowin); flowin_tot = flowin; flowin = 0.; } /************************************************** ******************* UDF measuring Temperature at pressure outlet ID 10 ************************************************** ********************/ DEFINE_EXECUTE_AT_END(Temp_outlet) { Domain *d; real Temp_t; real area; real area_tot; real tavg; real A[ND_ND]; Thread *t; face_t f; d=Get_Domain(1); t=Lookup_Thread(d,10); tavg=0; area_tot=0; begin_f_loop(f,t) { F_AREA(A,f,t); area_tot += NV_MAG(A); tavg += F_T(f,t)*NV_MAG(A); } end_f_loop(f,t) tavg /= area_tot; tavg_tot=tavg; printf("Averaged Temperature at Pressure Outlet: %g\n",tavg_tot); } /************************************************** ******************* UDF settting temperature at pressure inlet ID 9 ************************************************** ********************/ DEFINE_PROFILE(temp_mixing,t,i) { real lambda=1; real temp_mix; real temp_supply=323; face_t f; if (ABS(flowin_tot) == 0) temp_mix = temp_supply; else temp_mix = (lambda*ABS(flowout_tot)*(tavg_tot)+(ABS(flowin_to t)-lambda*ABS(flowout_tot))*temp_supply)/(ABS(flowin_tot)); begin_f_loop(f,t) { F_PROFILE(f,t,i) = temp_mix; } end_f_loop(f,t) printf("Adjusted temperature: %f\n",temp_mix); } |
All times are GMT -4. The time now is 01:08. |