CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF for Mass Flow at the Outlet: ERROR ACCESS VIOLATION

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By I-mech

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 23, 2014, 12:45
Red face UDF for Mass Flow at the Outlet: ERROR ACCESS VIOLATION
  #1
New Member
 
Marco Dc
Join Date: Feb 2014
Location: Italy
Posts: 20
Rep Power: 12
I-mech is on a distinguished road
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
__________________
Marco
I-mech is offline   Reply With Quote

Old   May 23, 2014, 13:37
Default
  #2
New Member
 
Marco Dc
Join Date: Feb 2014
Location: Italy
Posts: 20
Rep Power: 12
I-mech is on a distinguished road
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);
}
macfly likes this.
__________________
Marco
I-mech is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF to adjust pressure outlet a.lynchy FLUENT 4 February 15, 2021 01:50
Mass flow inlet and pressure outlet issue nikhil FLUENT 5 December 11, 2013 13:30
CFDesign V11 -- Reverse flow at outlet maruthiv Autodesk Simulation CFD 1 June 17, 2011 10:38
Outlet BC for subsonic flow in pipe andrea panizza FLUENT 6 May 10, 2003 08:44
UDF in Fluent to Match Mass Flow at Pressure Outlet Jonas Larsson Main CFD Forum 1 April 29, 1999 11:44


All times are GMT -4. The time now is 18:15.