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

Actuator surface method udf code

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 15, 2023, 06:18
Smile Actuator surface method udf code
  #1
New Member
 
Meysam Paghandeh
Join Date: May 2022
Posts: 6
Rep Power: 3
Meysam2710 is on a distinguished road
hi everyone
i write this udf code for simulation of wing in ansys fluent


#include "udf.h"
#define PI 3.1415
#define ro 1.225
real Vrel[20];
real alpha[20];

real Vx[20];
real Vy[20];

DEFINE_ADJUST(samplevelocity,d)
{
Thread *t ;
cell_t c ;
real x[ND_ND],z,y,db,d_new,xx,yy,zz;

real z0[21] = {-2,-1.9,-1.8,-1.7,-1.6,-1.5,-1.4,-1.3,-1.2,-1.1,-1,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0};

//real z0[21] = {-1,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1};
real y0[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

real uu,vv,ww;

int i;
db = 0.1;

for(i=0;i<=20;i++)
{

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{

C_CENTROID(x,c,t);
d_new = sqrt (pow(x[0] - 1.1,2) + pow(x[1]- y0[i],2)+ pow(x[2]- z0[i],2));
if (d_new<db)
{
db = d_new;
uu = C_U(c,t);
vv = C_V(c,t);
ww = C_W(c,t);

Vrel[i] = sqrt(pow(vv,2) + pow(uu,2));
alpha[i] = atan(vv/uu);

Vx[i]= sqrt(pow(uu,2));
Vy[i]= sqrt(pow(vv,2));

}

}end_c_loop(c,t)

}


}

}


DEFINE_SOURCE(xmom_source,c,t,dS,eqn)
{
#if !RP_HOST
real x[ND_ND];
int i,j;

real y0[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

real z0[21] = {-2,-1.9,-1.8,-1.7,-1.6,-1.5,-1.4,-1.3,-1.2,-1.1,-1,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0};

real x0[12] = {1.4,1.425,1.45,1.475,1.525,1.55,1.575,1.6,1.625,1 .65,1.675,1.7};

real L,D,U,chord=0.3,E,etta,y,z,r,rr,source,Fx,Fy,Fxtot al,Fytotal,etta1,r1,Dtotal,Ltotal,VO,total;
C_CENTROID(x,c,t);
double CL,CD;

VO = C_VOLUME(c,t);

real sourcex = 0.0;
real sourceyy = 0.0;
real sourcezz = 0.0;
Fxtotal=0;
Fytotal=0;
Dtotal=0;
Ltotal=0;
total=0;

for(i=0;i<=20;i++)

{
E = 0.25*chord;

CL = -1*pow(10,-9)*pow(alpha[i],6) -2*pow(10,-7)*pow(alpha[i],5) +6*pow(10,-7)*pow(alpha[i],4) -6*pow(10,-5)*pow(alpha[i],3) -7*pow(10,-5)*pow(alpha[i],2) + 0.1155*alpha[i] + 0.0009;

CD = 2*pow(10,-9)*pow(alpha[i],6) + 1*pow(10,-9)*pow(alpha[i],5) -6*pow(10,-7)*pow(alpha[i],4) -4*pow(10,-7)*pow(alpha[i],3) + 0.0001*pow(alpha[i],2) +3*pow(10,-5)*alpha[i] + 0.0059;

for(j=0;j<=11;j++){

r = sqrt(ND_SUM(pow(x[0] - x0[j],2),pow(x[1],2),pow(x[2] - z0[i],2)));

etta = exp(- pow(r/E,2)) * (pow(E,-2)* pow(PI,-1.5));



D = 0.5 * ro * Vrel[i] * Vrel[i] * 0.1 * chord * CD *etta/(12);

L = 0.5 * ro * Vrel[i] * Vrel[i] * 0.1 * chord * CL *etta/(12);

Dtotal+=D;

Ltotal+=L;

}


sourcex += ((Dtotal*chord*0.1/0.6)*cos(alpha[i])-(Ltotal*chord*0.1/0.6)*sin(alpha[i]));
sourceyy += ((Dtotal*chord*0.1/0.6)*sin(alpha[i])+(Ltotal*chord*0.1/0.6)*cos(alpha[i]));


}

C_UDMI(c,t,0) = -sourcex;

C_UDMI(c,t,1) = -sourceyy;

source = C_UDMI(c,t,0);

dS[eqn] = 0;
return source;
#endif
}


DEFINE_SOURCE(ymom_source,c,t,dS,eqn)
{
#if !RP_HOST
real source;
real x[ND_ND];

C_CENTROID(x,c,t);

source = C_UDMI(c,t,1);

dS[eqn] = 0;

return source;
#endif

}


y0,z0 and x0 are coordinate of wing

in define adjust sampling of velocity will be done and define_sorces for calculating body forces

can anyone check my code, because i dont get correct resultts,

thanks
Meysam2710 is offline   Reply With Quote

Old   November 15, 2023, 18:15
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
probably you want to calculate both source inside define_adjust macro (not inside one of the sources) and return source value through udmi (as it done with DEFINE_SOURCE(ymom_source,c,t,dS,eqn) )
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
actuator disk, actuator line, actuator-line, wind turbines


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 Error: Error code 126 cilliant FLUENT 0 June 30, 2023 06:52
Getting an error while compiling UDF code Sohrabs FLUENT 2 June 6, 2023 07:22
This UDF code was not working :( Sumin Lee FLUENT 2 June 30, 2022 07:18
UDF code help solve reaction rate equation palm oil zirkov Fluent UDF and Scheme Programming 0 February 13, 2017 10:34
write code UDF Fluent solve kinetic reaction rate equation palm oil zirkov FLUENT 0 February 13, 2017 10:16


All times are GMT -4. The time now is 19:57.