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

compiling udf for pulsatile flow

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 20, 2018, 05:26
Default compiling udf for pulsatile flow
  #1
New Member
 
Akshat
Join Date: Jun 2018
Posts: 1
Rep Power: 0
Akshat is on a distinguished road
Hello Everyone,

I'm trying to compile a UDF for pulsatile flow which is:-

#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"


double sumx0=0; /* Initial x position of the bubble in the pool */
double sumy0=0.; /* Initial y position of the bubble in the pool */


double uvel; /* u Velocity, a global variable */
double vvel; /* v Velocity, a global variable */
double uavgo;
double uavgoo;

double yo[65];
double uo[65];
double vo[65];
double to[65];

double yoo[34];
double uoo[34];
double voo[34];
double too[34];

double yi[65];
double ui[65];
double vi[65];
double ti[65];

double yii[34];
double uii[34];
double vii[34];
double tii[34];

real qwa = 32000.0;
real CpL = 4182.0;
real CpG = 1006.43;
real rhoL = 997.0;
real rhoG = 1.225;
real R = 0.0005;
real LUC = 0.005;
real omega = 100.0;
real eg = 0.3;
real U1= 0.2;
real UTP=0.1;

DEFINE_ADJUST(outlet1_store,domain)
{

real FC1[2];
face_t f;
real areao=0.0, uao=0.0;
real NV_VEC(A);
int IDo=10;/*Zone ID for outlet zone from Boundary Conditions task page*/
int p=0;

Thread *thread=Lookup_Thread(domain,IDo);


begin_f_loop(f,thread)
{
F_CENTROID(FC1,f,thread);

yo[p]=FC1[1];
uo[p]=F_U(f,thread);
vo[p]=F_V(f,thread);
to[p]=F_T(f,thread);
areao +=F_AREA(A,f,thread);
uao +=(F_U(f,thread))*(NV_MAG(A));


p+=1;

}
end_f_loop(f,thread)
uavgo=(uao/areao);


}

DEFINE_ADJUST(outlet2_store,domain)
{

real FC2[2];
face_t f;
real area=0.0, ua=0.0;
real NV_VEC(A);
int IDo=11;/*Zone ID for outlet zone from Boundary Conditions task page*/
int w=0;

Thread *thread=Lookup_Thread(domain,IDo);


begin_f_loop(f,thread)
{
F_CENTROID(FC2,f,thread);

yoo[w]=FC2[1];
uoo[w]=F_U(f,thread);
voo[w]=F_V(f,thread);
too[w]=F_T(f,thread);
area +=F_AREA(A,f,thread);
ua +=(F_U(f,thread))*(NV_MAG(A));


w+=1;

}
end_f_loop(f,thread)
uavgoo=(ua/area);


}

DEFINE_ADJUST(inlet1_store,domain)
{

real FC3[2];
face_t f;
int IDi=8;/*Zone ID for intlet zone from Boundary Conditions task page*/
int k=0;

Thread *thread1=Lookup_Thread(domain,IDi);


begin_f_loop(f,thread1)
{
F_CENTROID(FC3,f,thread1);

yi[k]=FC3[1];
ti[k]=F_T(f,thread1);
ui[k]=F_U(f,thread1);



k+=1;

}
end_f_loop(f,thread1)



}

DEFINE_ADJUST(inlet2_store,domain)
{

real FC4[2];
face_t f;
int IDi=9;/*Zone ID for intlet zone from Boundary Conditions task page*/
int a=0;

Thread *thread1=Lookup_Thread(domain,IDi);


begin_f_loop(f,thread1)
{
F_CENTROID(FC4,f,thread1);

yii[a]=FC4[1];
tii[a]=F_T(f,thread1);
uii[a]=F_U(f,thread1);



a+=1;

}
end_f_loop(f,thread1)



}

DEFINE_PROFILE(x1_velocity,t,i)
{
face_t f;
real r, R, y, x, Ub, utp, omega, tin, U1;
real xc[ND_ND];/*This will hold the position vector*/
real xc2[ND_ND];/*This will hold the position vector*/
real time_step=RP_Get_Integer("time-step");
int n=0;

R=0.0005;/*The radius of tube in m*/
utp=0.1;
U1 = 0.2;
omega = 100;
tin= CURRENT_TIME;

if ((time_step)<300000)
{
begin_f_loop(f,t)
{
F_CENTROID(xc,f,t);
x=xc[0];
y=xc[1];
r=y/R; /*non-dimensional y coordinate*/



F_PROFILE(f,t,i)= 2*((U1+utp*(cos(omega*(tin-0.024995))))*(1-(r*r)));



}
end_f_loop(f,t)

}

else
{

begin_f_loop (f,t)
{

F_CENTROID(xc2,f,t);

for (n=0;n<65;n++)
{
if ((fabs(xc2[1]-yo[n]))<0.000000001)
{

F_PROFILE (f,t,i) =(uo[n]);

}
}

}
end_f_loop (f,t)


}
}

DEFINE_PROFILE(x2_velocity,t,i)
{
face_t f;
real r, R, y, x, Ub, utp, omega, tin, U1;
real xc3[ND_ND];/*This will hold the position vector*/
real xc4[ND_ND];/*This will hold the position vector*/
real time_step=RP_Get_Integer("time-step");
int l=0;

R=0.0005;/*The radius of tube in m*/
utp=0.1;
U1=0.2;
omega = 100;
tin= CURRENT_TIME;

if ((time_step)<300000)
{
begin_f_loop(f,t)
{
F_CENTROID(xc3,f,t);
x=xc3[0];
y=xc3[1];
r=y/R; /*non-dimensional y coordinate*/



F_PROFILE(f,t,i)= 2*((U1+utp*(cos(omega*(tin-0.024995))))*(1-(r*r)));



}
end_f_loop(f,t)

}

else
{

begin_f_loop (f,t)
{

F_CENTROID(xc4,f,t);

for (l=0;l<34;l++)
{
if ((fabs(xc4[1]-yoo[l]))<0.000000001)
{

F_PROFILE (f,t,i) =uoo[l];

}
}

}
end_f_loop (f,t)


}
}

DEFINE_PROFILE(y1_velocity,t,i)
{

real xc5[ND_ND];/*This will hold the position vector*/
face_t f;
int m=0;

real time_step=RP_Get_Integer("time-step");


if ((time_step)<300000)
{
begin_f_loop(f,t)
{


F_PROFILE(f,t,i)= 0;


}
end_f_loop(f,t)

}

else
{

begin_f_loop (f, t)
{

F_CENTROID(xc5,f,t);

for (m=0;m<65;m++)
{
if ((fabs(xc5[1]-yo[m]))<0.000000001)
{

F_PROFILE (f,t,i) =vo[m];
}
}

}
end_f_loop (f, t)

}
}

DEFINE_PROFILE(y2_velocity,t,i)
{

real xc6[ND_ND];/*This will hold the position vector*/
face_t f;
int e=0;

real time_step=RP_Get_Integer("time-step");


if ((time_step)<300000)
{
begin_f_loop(f,t)
{


F_PROFILE(f,t,i)= 0;


}
end_f_loop(f,t)

}

else
{

begin_f_loop (f, t)
{

F_CENTROID(xc6,f,t);

for (e=0;e<34;e++)
{
if ((fabs(xc6[1]-yoo[e]))<0.000000001)
{

F_PROFILE (f,t,i) =voo[e];
}
}

}
end_f_loop (f, t)

}
}

DEFINE_CG_MOTION(vel_comp, dt, vel, omega, time, dtime)
{





vel[0] = uvel;




}



DEFINE_PROFILE(outlet1_temp,thread, nv)
{
real xc7[ND_ND];
face_t f;
int j=0;
int d=0;

real UK, tin, wallheat, bulkheat, dtemp;

tin= CURRENT_TIME;
UK = ((U1+UTP*(cos(omega*(tin-0.024995)))));
wallheat= qwa*2*M_PI*R*LUC;
bulkheat= (((UK-eg*uvel)*(rhoL*CpL))+ (eg*uvel*rhoG*CpG))*M_PI*R*R;
dtemp = ( wallheat/bulkheat );

begin_f_loop (f, thread);
{
F_CENTROID(xc7,f,thread);

for (j=0;j<65;j++)
{
if ((fabs(uvel-ui[j]))>0.0000000001)
{

for (d=0;d<65;d++)
{
if ((fabs(xc7[1]-yi[d]))<0.0000000001)
{

F_PROFILE (f,thread, nv) = ((ti[d])+(dtemp));

}
}
}
}
}
end_f_loop (f, thread)
}

DEFINE_PROFILE(outlet2_temp,thread, nv)
{
real xc8[ND_ND];
face_t f;
int s=0;
int g=0;

real UK, tin, wallheat, bulkheat, dtemp;

tin= CURRENT_TIME;
UK = ((U1+UTP*(cos(omega*(tin-0.024995)))));
wallheat= qwa*2*M_PI*R*LUC;
bulkheat= (((UK-eg*uvel)*(rhoL*CpL))+ (eg*uvel*rhoG*CpG))*M_PI*R*R;
dtemp = ( wallheat/bulkheat );

begin_f_loop (f, thread);
{
F_CENTROID(xc8,f,thread);

for (s=0;s<34;s++)
{
if ((fabs(uvel-uii[s]))>0.0000000001)
{

for (g=0;g<34;g++)
{
if ((fabs(xc8[1]-yii[g]))<0.0000000001)
{

F_PROFILE (f,thread, nv) = ((tii[g])+(dtemp));

}
}
}
}
}
end_f_loop (f, thread)
}


DEFINE_PROFILE(inlet1_temp,thread, nv)
{
real xc9[ND_ND];
face_t f;
int z=0;
int b=0;

real UK, tin, wallheat, bulkheat, dtemp;
tin= CURRENT_TIME;
UK = ((U1+UTP*(cos(omega*(tin-0.024995)))));
wallheat= qwa*2*M_PI*R*LUC;
bulkheat= (((UK-eg*uvel)*(rhoL*CpL))+ (eg*uvel*rhoG*CpG))*M_PI*R*R;
dtemp = ( wallheat/bulkheat );

begin_f_loop (f, thread);
{
F_CENTROID(xc9,f,thread);

for (z=0;z<65;z++)
{
if ((fabs(uvel-uo[z]))>0.0000000001)
{
for (b=0;b<65;b++)
{
if ((fabs(xc9[1]-yo[b]))<0.0000000001)
{

F_PROFILE (f,thread, nv) = ((to[b])-(dtemp));

}
}
}
}
}
end_f_loop (f, thread)
}

DEFINE_PROFILE(inlet2_temp,thread, nv)
{
real xc10[ND_ND];
face_t f;
int h=0;
int v=0;

real UK, tin, wallheat, bulkheat, dtemp;
tin= CURRENT_TIME;
UK = ((U1+UTP*(cos(omega*(tin-0.024995)))));
wallheat= qwa*2*M_PI*R*LUC;
bulkheat= (((UK-eg*uvel)*(rhoL*CpL))+ (eg*uvel*rhoG*CpG))*M_PI*R*R;
dtemp = ( wallheat/bulkheat );

begin_f_loop (f, thread);
{
F_CENTROID(xc10,f,thread);

for (h=0;h<34;h++)
{
if ((fabs(uvel-uoo[h]))>0.0000000001)
{
for (v=0;v<34;v++)
{
if ((fabs(xc10[1]-yoo[v]))<0.0000000001)
{

F_PROFILE (f,thread, nv) = ((too[v])-(dtemp));

}
}
}
}
}
end_f_loop (f, thread)
}

DEFINE_ADJUST(velocity,domain)

{

FILE *fp2;
Thread *t;
Thread *st;
cell_t c;



real max=0.0,Ymin=0.0, x0, y0, VFs, VFp, tin;
real xc11[ND_ND];/*This will hold the position vector*/

double x;


fp2 = fopen("Ub.txt","a");

thread_loop_c(t,domain)

{

st=THREAD_SUB_THREAD(t,1);


/* printf("x0 = %g\n ", sumx0);*/

begin_c_loop(c,t)
{
C_CENTROID(xc11,c,t);

VFs=C_VOF(c,st); /* Getting volume factions of cells */



max+=C_VOF(c,st)*(C_U(c,t))*(C_VOLUME(c,t))*2*M_PI ;
Ymin+=C_VOF(c,st)*(C_VOLUME(c,t))*2*M_PI;



}
end_c_loop(c,t)

uvel=(max/Ymin);

tin = CURRENT_TIME;

fprintf(fp2," TIME = %g MAX = %g Y = %g U = %g\n ", tin, max, Ymin, uvel);


}
fclose(fp2);
}

While compiling this UDF I'm encountering these different types of error:-
1)'nmake is not recognized as an internal or external command,operable program or batch file.
2) Error: Auto-compilation skipped. Could not find "libudf" or input files for creating "libudf" library
Error Object: #f
Reading "E:\IITG\PULSATILE FLOW\T_Puls_25000.dat"...
Error: chip-exec: function "x1_velocity::libudf" not found.
Error: chip-exec: function "y1_velocity::libudf" not found.
Error: chip-exec: function "x2_velocity::libudf" not found.
Error: chip-exec: function "y2_velocity::libudf" not found.

Is there any solution to these errors?
I've tried many things like launching fluent through microsoft sdk command prompt.I'm having Visual Studio 2013 in my PC.I'm working on this error since last 10 days.
Any suggestion to this thread are heavily appreciated.
Thanks
Akshat is offline   Reply With Quote

Old   June 21, 2018, 05:07
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Akshat,

Here are some useful posts on compiling UDFs -- for example: links to instructions Visual Studio 2017 for udf use - which modules do I need?; troubleshooting errors How to solve UDF compilation problems in Fluent.; the basic steps of compile/load/hook The UDF library you are trying to load (libudf) is not compiled for 3D on the current.

It would be a good idea to check that you can compile a really simple UDF before you launch into multiple UDFs with hundreds of lines of code. Then build up the complexity of the UDFs slowly.

Good luck!
Ed
obscureed is offline   Reply With Quote

Reply

Tags
libudf, nmake, udf


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
Review: Reversed flow CRT FLUENT 1 May 7, 2018 06:36
UDF profile based on function of flow time ERROR! Ash Kot Fluent UDF and Scheme Programming 1 September 2, 2016 10:35
UDF to adjust flow rate at outflow boundary condition kharnabnew FLUENT 1 May 24, 2016 07:33
Can I change flow direction using UDF? newcfdone Fluent UDF and Scheme Programming 4 April 6, 2016 23:49
Basic question regarding compiling a UDF A.Jalal Fluent UDF and Scheme Programming 2 August 6, 2015 14:57


All times are GMT -4. The time now is 13:49.