24小时热门版块排行榜    

查看: 799  |  回复: 7

ZBY右婪

新虫 (初入文坛)

[求助] udf文件哪里错了 已有1人参与

#include "udf.h"
#include "mem.h"
#include "sg_mphase.h"
#include "sg.h"
#include "flow.h"
#include "math.h"
#include "surf.h"
#include "stdio.h"
/**************************************************/
/***** D * E * F * I * N * E *** A * D * J * U * S * T *****/
/*************************************************/

DEFINE_ADJUST(adjust_1,domain)
{
Thread *t;
cell_t c;
real Temp,Visc,str;
real dudx, dudy, dudz, dvdx, dvdy, dvdz, dwdx, dwdy, dwdz;
real conversion_visc; /*conversion efficiency of viscous dissipation*/
conversion_visc=0.9;       
thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
Temp=C_T(c,t);                       
Visc=0.1*C_UDMI(c,t,0);          /*modified viscocity   */
dudx=C_DUDX(c,t);
dudy=C_DUDY(c,t);
dudz=C_DUDZ(c,t);
dvdx=C_DVDX(c,t);
dvdy=C_DVDY(c,t);
dvdz=C_DVDZ(c,t);
dwdx=C_DWDX(c,t);
dwdy=C_DWDY(c,t);
dwdz=C_DWDZ(c,t);                       
str=C_STRAIN_RATE_MAG(c,t);
if(str>1&&str<400)       
C_UDMI(c,t,1)=conversion_visc*Visc*fabs(2*dudx*dudx+2*dvdy*dvdy+2*dwdz*dwdz+(dvdx+dudy)*(dvdx+dudy)+(dvdz+dwdy)*(dvdz+dwdy)+(dwdx+dudz)*(dwdx+dudz));
else       
C_UDMI(c,t,1)=0;
                                                               
C_UDMI(c,t,4)=2*dudx*dudx+2*dvdy*dvdy+2*dwdz*dwdz+(dvdx+dudy)*(dvdx+dudy)+(dvdz+dwdy)*(dvdz+dwdy)+(dwdx+dudz)*(dwdx+dudz);
}
end_c_loop(c,t)
}       
}



/****************************************************************/
/***** M * A * T * E * R * I * A * L *** P * R * O * P * E * R * T * Y *****/
/**************************************************************/
DEFINE_PROPERTY(U_Visc,c,t)
{
real Temp,Visc,str,A,alfa,n,Q,Z,stress,stress_modify,R,asinh_input,asinh_output,Visc_limit_up,Visc_limit_down;
/*
real dudx, dudy, dudz, dvdx, dvdy, dvdz, dwdx, dwdy, dwdz;
  dudx=C_DUDX(c,t);
        dudy=C_DUDY(c,t);
        dudz=C_DUDZ(c,t);
        dvdx=C_DVDX(c,t);
        dvdy=C_DVDY(c,t);
        dvdz=C_DVDZ(c,t);
        dwdx=C_DWDX(c,t);
        dwdy=C_DWDY(c,t);
        dwdz=C_DWDZ(c,t);
str=sqrt(0.6667*(dudx*dudx+dvdy*dvdy+dwdz*dwdz+0.5*(dudy+dvdx)*(dudy+dvdx)+0.5*(dudz+dwdx)*(dudz+dwdx)+0.5*(dvdz+dwdy)*(dvdz+dwdy)));
*/
str=C_STRAIN_RATE_MAG(c,t);
Temp=C_T(c,t);
A=240000000;
alfa=0.000000045;
n=3.55;
Q=145000;
R=8.314; /* Specific gas constant */
Visc_limit_up=10000000;
if(str<0.1)
{
str=0.1;
Z=str*exp(Q/(R*Temp));
asinh_input=pow(Z/A,1/n);
asinh_output=log(asinh_input + sqrt(asinh_input *asinh_input + 1));
stress=(1/alfa)*asinh_output;
}
else if(str>1000)
{
str=1000;
Z=str*exp(Q/(R*Temp));
asinh_input=pow(Z/A,1/n);
asinh_output=log(asinh_input + sqrt(asinh_input *asinh_input + 1));
stress=(1/alfa)*asinh_output;
}
else
{
Z=str*exp(Q/(R*Temp));
asinh_input=pow(Z/A,1/n);
asinh_output=log(asinh_input + sqrt(asinh_input *asinh_input + 1));
stress=(1/alfa)*asinh_output;
}
stress_modify=stress;
Visc=stress_modify/(3*str);
if((Visc>Visc_limit_up)|| (str == 0))       
{
Visc=Visc_limit_up;
}
C_UDMI(c,t,2)=stress_modify;
C_UDMI(c,t,0)=Visc;
return Visc;
}


/*material density */
DEFINE_PROPERTY(material_density,c,t)
{
real density;                                       
density=2770.0;
return density;
}

/*material heat capacity */
DEFINE_SPECIFIC_HEAT(cell_specific_heat,T,Tref,h,yi)
{
real cp;
cp=39.3608+4.9426*T-0.0088404*T*T+0.0000055778*T*T*T;
*h=cp*(T-Tref);
return cp;
}


/*material thermal conductivity */
DEFINE_PROPERTY(material_thermal_conductivity,c,t)
{
real k;           
real temp=C_T(c,t);                                 
k=54.7398+0.3543*temp-0.00041846*temp*temp+0.0000002392*temp*temp*temp;
return k;
}

/*************************************************************************************************/
/***** H * E * A * T *** F * L * U * X *** F * R * O * M *** T * H * E *** I * N * T * E * R * F * A * C * E *****/
/************************************************************************************************/

/*heat flux from the shoulder*/
DEFINE_PROFILE(shoulder_heat,t,i)
{
face_t f;
real b[ND_ND];
real x,y,r;
real sin_theta;
real Beta2;         
real Delta;         
real Mu;            
real rad;               
real U;      
real p0;         
real k_w,k_t,Cp_w,Cp_t,Rho_w,Rho_t;
real e_w,e_t;
real fact_w;       /*the heat trans betweent the interface of workpiece and tool*/
real T;
real stress;
cell_t c0;
Thread *t0;
Beta2=1;           /*conversion efficiency of the tool-workpiece interface*/
Delta=0.3;         /*Slip rate between the tool and the workpiece*/
Mu=0.4;              /*Frictional coefficient between the tool and the workpiece*/
rad=60;          /*rotation speed   rad s-1*/
U=0.001;            /*welding speed   m s-1*/
p0=12000000;   /*normal stress*/
begin_f_loop(f,t)
{
F_CENTROID(b,f,t);
x=b[0];
y=b[1];
r=sqrt(x*x+y*y);
sin_theta=y/r;               
c0=F_C0(f,t);                        /* Adjacent Cell Index Macros Defined in mem.h*/
t0=THREAD_T0(t);      /*THREAD_T0(t) Adjacent Cell Thread */
T=F_T(f,t);                        /*face temperature*/
k_w=120.0;                       /*thermal conductivity of workpiece*/
k_t=42.0;                           /*thermal conductivity of tool*/
Cp_w=1172.0;                  /*heat capacity of workpiece*/
Cp_t=440.0;                      /*heat capacity of tool*/
Rho_w=2770.0;                /*density of workpiece*/
Rho_t=7800.0;                  /*density of tool*/
e_w=sqrt(k_w*Cp_w*Rho_w);                   /*thermal effusivity of workpiece*/
e_t=sqrt(k_t*Cp_t*Rho_t);                          /*thermal effusivity of tool*/
fact_w=e_w/(e_w+e_t);               
stress=C_UDMI(c0,t0,2);       
F_PROFILE(f,t,i)=fact_w*Beta2*(Delta*stress+(1-Delta)*Mu*p0)*fabs(rad*r-U*sin_theta);               
}
end_f_loop(f,t)
}


/*heat flux from the pin_side_acr*/
DEFINE_PROFILE(pin_side,t,i)
{
face_t f;
real b[ND_ND];
real x,y,r;
real sin_theta;
real Beta2;         
real Delta;         
real Mu;            
real rad;               
real U;      
real p0;         
real k_w,k_t,Cp_w,Cp_t,Rho_w,Rho_t;
real e_w,e_t;
real fact_w;       /*the heat trans betweent the interface of workpiece and tool*/
real T;
real stress;
real sin_cone;
cell_t c0;
Thread *t0;
Beta2=1;           /*conversion efficiency of the tool-workpiece interface*/
Delta=0.5;         /*Slip rate between the tool and the workpiece*/
Mu=0.4;              /*Frictional coefficient between the tool and the workpiece*/
rad=60;          /*rotation speed   rad s-1*/
U=0.001;            /*welding speed   m s-1*/
p0=12000000;   /*normal stress*/
sin_cone=0.196;            /*sin Cone angle of the pin*/
begin_f_loop(f,t)
{
F_CENTROID(b,f,t);
x=b[0];
y=b[1];
r=sqrt(x*x+y*y);
sin_theta=y/r;               
c0=F_C0(f,t);                        /* Adjacent Cell Index Macros Defined in mem.h*/
t0=THREAD_T0(t);      /*THREAD_T0(t) Adjacent Cell Thread */
T=F_T(f,t);                        /*face temperature*/
k_w=120.0;                       /*thermal conductivity of workpiece*/
k_t=42.0;                           /*thermal conductivity of tool*/
Cp_w=1172.0;                  /*heat capacity of workpiece*/
Cp_t=440.0;                      /*heat capacity of tool*/
Rho_w=2770.0;                /*density of workpiece*/
Rho_t=7800.0;                  /*density of tool*/
e_w=sqrt(k_w*Cp_w*Rho_w);                   /*thermal effusivity of workpiece*/
e_t=sqrt(k_t*Cp_t*Rho_t);                          /*thermal effusivity of tool*/
fact_w=e_w/(e_w+e_t);               
stress=C_UDMI(c0,t0,2);               
F_PROFILE(f,t,i)=fact_w*Beta2*(Delta*stress+(1-Delta)*Mu*p0*sin_cone)*fabs(rad*r-U*sin_theta);               
}
end_f_loop(f,t)
}



/*heat flux from the pin*/
DEFINE_PROFILE(pin_bottom_heat,t,i)
{
face_t f;
real b[ND_ND];
real x,y,r;
real sin_theta;
real Beta2;         
real Delta;         
real Mu;            
real rad;               
real U;      
real p0;         
real k_w,k_t,Cp_w,Cp_t,Rho_w,Rho_t;
real e_w,e_t;
real fact_w;       /*the heat trans betweent the interface of workpiece and tool*/
real T;
real stress;
cell_t c0;
Thread *t0;
Beta2=1;           /*conversion efficiency of the tool-workpiece interface*/
Delta=0.35;         /*Slip rate between the tool and the workpiece*/
Mu=0.4;              /*Frictional coefficient between the tool and the workpiece*/
rad=60;          /*rotation speed   rad s-1*/
U=0.001;            /*welding speed   m s-1*/
p0=12000000;   /*normal stress*/
begin_f_loop(f,t)
{
F_CENTROID(b,f,t);
x=b[0];
y=b[1];
r=sqrt(x*x+y*y);
sin_theta=y/r;               
c0=F_C0(f,t);                        /* Adjacent Cell Index Macros Defined in mem.h*/
t0=THREAD_T0(t);      /*THREAD_T0(t) Adjacent Cell Thread */
T=F_T(f,t);                        /*face temperature*/
k_w=120.0;                       /*thermal conductivity of workpiece*/
k_t=42.0;                           /*thermal conductivity of tool*/
Cp_w=1172.0;                  /*heat capacity of workpiece*/
Cp_t=440.0;                      /*heat capacity of tool*/
Rho_w=2770.0;                /*density of workpiece*/
Rho_t=7800.0;                  /*density of tool*/
e_w=sqrt(k_w*Cp_w*Rho_w);                   /*thermal effusivity of workpiece*/
e_t=sqrt(k_t*Cp_t*Rho_t);                          /*thermal effusivity of tool*/
fact_w=e_w/(e_w+e_t);               
stress=C_UDMI(c0,t0,2);       
F_PROFILE(f,t,i)=fact_w*Beta2*(Delta*stress+(1-Delta)*Mu*p0)*fabs(rad*r-U*sin_theta);               
}
end_f_loop(f,t)
}


/*********************************************************/
/***** S * O * U * R * C * E *** O * F *** F * L * U * I * D *****/
/*******************************************************/
/*source of energy equation (viscous dissipation)*/

DEFINE_SOURCE(heat_source_vd,c,t,dS,eqn)
{
real source;
source=C_UDMI(c,t,1);
dS[eqn]=0;
return source;
}



/***************************************************************************************/
/***** V * E * L * O * C * I * T * Y *** O * F *** T * H * E *** I * N * T * E * R * F * A * C * E *****/
/**************************************************************************************/
DEFINE_PROFILE(shoulder_u,t,i)
{
real x[ND_ND];
real omega;
face_t f;
real theta,r, u_delta, x1, y1,u_weld;
real Delta;
Delta=0.3;
u_weld=0.001;
omega=60;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t); /*Get the centroid positions into x */
x1=x[0] ;
y1=x[1] ;
r=pow(x1*x1+y1*y1,0.5);
theta=atan2(y1,x1) ;
u_delta=omega*r*Delta*sin(theta)-u_weld;
F_PROFILE(f,t,i)= u_delta;
}
end_f_loop(f,t)
}


DEFINE_PROFILE(shoulder_v,t,i)
{
real x[ND_ND];
real omega;
face_t f;
real theta,r, v_delta, x1, y1,u_weld;
real Delta;
Delta=0.3;
u_weld=0.001;
omega=60; /*rad per sec */
begin_f_loop(f,t)
{
F_CENTROID(x,f,t); /*Get the centroid positions into x */
x1=x[0] ;
y1=x[1] ;
r=pow(x1*x1+y1*y1,0.5);
theta=atan2(y1,x1) ;
v_delta=-omega*r*Delta*cos(theta);
F_PROFILE(f,t,i)= v_delta;
}
end_f_loop(f,t)
}




DEFINE_PROFILE(pin_side_u,t,i)
{
real x[ND_ND];
real omega;
face_t f;
real theta,r, u_delta, x1, y1,u_weld;
real Delta;
Delta=0.5;
u_weld=0.001;
omega=60;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t); /*Get the centroid positions into x */
x1=x[0] ;
y1=x[1] ;
r=pow(x1*x1+y1*y1,0.5);
theta=atan2(y1,x1) ;
u_delta=omega*r*Delta*sin(theta)-u_weld;
F_PROFILE(f,t,i)= u_delta;
}
end_f_loop(f,t)
}


DEFINE_PROFILE(pin_side_v,t,i)
{
real x[ND_ND];
real omega;
face_t f;
real theta,r, v_delta, x1, y1,u_weld;
real Delta;
Delta=0.5;
u_weld=0.001;
omega=60; /*rad per sec */
begin_f_loop(f,t)
{
F_CENTROID(x,f,t); /*Get the centroid positions into x */
x1=x[0] ;
y1=x[1] ;
r=pow(x1*x1+y1*y1,0.5);
theta=atan2(y1,x1) ;
v_delta=-omega*r*Delta*cos(theta);
F_PROFILE(f,t,i)= v_delta;
}
end_f_loop(f,t)
}



DEFINE_PROFILE(pin_bottom_u,t,i)
{
real x[ND_ND];
real omega;
face_t f;
real theta,r, u_delta, x1, y1,u_weld;
real Delta;
Delta=0.35;
u_weld=0.001;
omega=60;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t); /*Get the centroid positions into x */
x1=x[0] ;
y1=x[1] ;
r=pow(x1*x1+y1*y1,0.5);
theta=atan2(y1,x1) ;
u_delta=omega*r*Delta*sin(theta)-u_weld;
F_PROFILE(f,t,i)= u_delta;
}
end_f_loop(f,t)
}


DEFINE_PROFILE(pin_bottom_v,t,i)
{
real x[ND_ND];
real omega;
face_t f;
real theta,r, v_delta, x1, y1,u_weld;
real Delta;
Delta=0.35;
u_weld=0.001;
omega=60; /*rad per sec */
begin_f_loop(f,t)
{
F_CENTROID(x,f,t); /*Get the centroid positions into x */
x1=x[0] ;
y1=x[1] ;
r=pow(x1*x1+y1*y1,0.5);
theta=atan2(y1,x1) ;
v_delta=-omega*r*Delta*cos(theta);
F_PROFILE(f,t,i)= v_delta;
}
end_f_loop(f,t)
}

发自小木虫Android客户端
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ZBY右婪

新虫 (初入文坛)

2楼2017-09-24 21:10:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ZBY右婪

新虫 (初入文坛)

3楼2017-09-24 21:11:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ZBY右婪

新虫 (初入文坛)

Error:received a fatal signal (segmentation fault)

发自小木虫Android客户端
4楼2017-09-24 21:12:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tumu_tu

金虫 (小有名气)

引用回帖:
4楼: Originally posted by ZBY右婪 at 2017-09-24 21:12:02
Error:received a fatal signal (segmentation fault)

是不是没开UDM啊

发自小木虫Android客户端
5楼2017-09-25 01:46:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ZBY右婪

新虫 (初入文坛)

udm,应该开了吧,我使用教程的时候在workbench里点开solution后加载udf能够用,但是在steup里面自己按照教程设置加载的udf初始化后就报错

发自小木虫Android客户端
6楼2017-09-25 10:01:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

fluid00

禁虫 (小有名气)

感谢参与,应助指数 +1
本帖内容被屏蔽

7楼2017-09-25 10:14:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ZBY右婪

新虫 (初入文坛)

8楼2017-09-27 13:23:21
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 ZBY右婪 的主题更新
信息提示
请填处理意见