# a udf of rotating by DEFINE_ZONE_MOTION & Compute_Force_And_Moment:access violation

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

May 6, 2015, 08:55
a udf of rotating by DEFINE_ZONE_MOTION & Compute_Force_And_Moment:access violation
#1
New Member

ender
Join Date: May 2015
Posts: 1
Rep Power: 0
Hi everyone,

I want to simulate a turbine's rotation in free stream and write the udf as below:

#include "udf.h"
#include "f_wall.h"
static real theta=0.0;
static real omega_calc=0.0;
int flag=0;

DEFINE_ZONE_MOTION(turbinemotion,omega,axis,origin ,velocity,time,dtime)
{
const real inertia =1.38;
Domain *small=Get_Domain(3);
real force_rotor[ND_ND],moment_rotor[ND_ND];
real point_rotor[ND_ND];
real axis_rotor[3]={0.0, 0.0, 1.0}; /* shaft axis directional vector */
real torque_rotor;
real torque,domega,omega_prev,omega_dot,omega_out,power ;
FILE *fd;
int i;
for(i=0;i<=ND_ND;i++)
{
force_rotor[i]=0;
moment_rotor[i]=0;
point_rotor[i]=0;
}
Message ("\npoint2 %f\n ", theta) ;
/* Problem occurs on the line below */
Compute_Force_And_Moment(small,face_rotor,point_ro tor,force_rotor,moment_rotor,1);
Message ("\npoint3 %f\n ", theta) ;
torque_rotor=NV_DOT(moment_rotor,axis_rotor);
torque=torque_rotor;
domega=dtime*torque/inertia;
omega_dot=torque/inertia;
omega_prev=omega_calc;
omega_calc=omega_calc + domega;
omega_out=omega_calc;
theta=theta+0.5*dtime*(omega_prev+omega_calc);
power=torque*omega_out;
Message ("\npoint4 %f\n ", theta) ;
N3V_D (velocity,=,0.0,0.0,0.0);
N3V_D(axis,=,0.0,0.0,1.0);

if ( flag !=N_TIME)
{
fd=fopen("data.txt","a+");
if(flag==0)
{
fprintf(fd,"time torque omega theta power\n");
}
flag=N_TIME;
fprintf(fd," %g %g %g %g %g\n",CURRENT_TIME,torque,omega_out,theta,power);
fclose(fd);
}
Message ("\nomega: %f\n ", omega_out) ;
Message ("\n---------------------------------------\n");

*omega=omega_out;
}

This udf can be compiled by fluent. When I run the simulation an 'access violation' error occured as shown in attached. Now I can confirm that the problem is on the function Compute_Force_And_Moment (see udf /* Problem occurs on the line below */ ), but I don't know how to correct it. Can anybody give me some suggestions?

Attached Images
 ??.jpg (33.9 KB, 5 views)

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post guidofrate Fluent UDF and Scheme Programming 0 November 20, 2014 09:32 seanread Fluent UDF and Scheme Programming 7 September 14, 2014 10:34 be89 Fluent UDF and Scheme Programming 1 December 21, 2012 04:07 Tobard FLUENT 1 April 28, 2011 18:00 therandomestname FLUENT 0 April 15, 2011 17:31

All times are GMT -4. The time now is 11:34.