[原创] 通用的任意层材料的激光加热程序
看到版上好多人的激光加热程序, 发现程序代码重复利用率不高,自己编了个任意层的激光加热代码,这里列出的是建摸部分,个人可以根据情况对特定层施加热源。例如,如果是三层结构,那么Layer=3,然后输入每层的厚度,属性和厚度方向的网格大小,比例。程序自动生成对应的模型。
FINISH! Make sure we are at BEGIN level
/Clear
/PREP7
/PNUM,VOLU,1
! In simulation, the X-Y is the media plane, while -Z is the depth direction
!********************************************************************
! The following is the the user-defined the simulation parmeters
!********************************************************************
Layer=3 !Total layer number
nm= 1e-9 !length unit
um=1e-6 !length unit
scale=10000 !for vovlap operation
T0=20 !Environment temperature
Length=1000*nm !Length of the block in y direction
Width=500*nm !Width of the block in x direction
Size=10*nm !Area mesh size, in X-Y plane
total=0 !1: total width, 0: half width
!********************************************************************
*DIM,Thickness,ARRAY,Layer !Array input for each layer thickness
*DIM,k_L,ARRAY,Layer !Array input for each layer lateral thermal conductivity
*DIM,k_N,ARRAY,Layer !Array input for each layer normal thermal conductivity
*DIM,Cp,ARRAY,Layer !Array input for each layer heat capacity
*DIM,Den,ARRAY,Layer !Array input for each layer density
*DIM,div,ARRAY,Layer !Array input for each layer thickness division
*DIM,dscale,ARRAY,Layer !Array input for each layer thickness division scale
!********************************************************************
!User specify the dimension and properties of each layer
!********************************************************************
!Layer properties, from top to bottom
!First layer thermal property
Num=1
k_L(Num)=20
k_N(Num)=10
Den(Num)=7800
Cp(Num)=500
Thickness(Num)=20*nm
div(Num)=15
dscale(Num)=1 !last/first in -Y direction
!Second layer thermal property
Num=2
k_L(Num)=200
k_N(Num)=50
Den(Num)=8900
Cp(Num)=450
Thickness(Num)=100*nm
div(Num)=5
dscale(Num)=1.5
!Third layer thermal property
Num=3
k_L(Num)=0.7
k_N(Num)=0.7
Den(Num)=3100
Cp(Num)=500
Thickness(Num)=150*nm
div(Num)=3
dscale(Num)=2.5
!Define the thermal element
ET,1,SOLID70
!Create the multilayer model using do loop
TSum1=0
TSum2=0
*do,Num,1,Layer,1
UIMP,Num,DENS, , ,Den(Num), !Define density of material Num
UIMP,Num,KXX,KYY,KZZ,k_L(Num),k_L(Num),k_N(Num) !Define thermal conductivity of material Num
UIMP,Num,C, , ,Cp(Num), !Define heat capacity of material Num
TSum1=TSum1+Thickness(Num)
BLOCK,-Width/2*total,Width/2,-Length/2,Length/2,-TSum1,-TSum2 !Draw the layer of Num
TSum2=TSum2+Thickness(Num)
*Enddo
d_total=TSum1 !Total thickness of the multilayer
VLSCALE,ALL, , , scale, scale, scale,,1,1,
*IF,Layer,GT,1,THEN
VGLUE,ALL
*ENDIF
VLSCALE,ALL, , , 1/scale, 1/scale, 1/scale, ,1,1,
TSum1=0
TSum2=0
aesize,all,Size,
!Determine the vertical mesh divsion along z axis for each layer using div(Num) and dscale(Num)
*do,Num,1,Layer,1
TSum1=TSum1+THICKNESS(Num)
lsel,all
!Determine the mesh scale and divison for each layer at Y direction
*do,i,-1,1,2
*do, j,-1,1,2
lsel,s,loc,z,-TSum1,-TSum2
*IF,total,EQ,1,THEN
lsel,r,loc,x,i*Width/2-1e-12,i*Width/2
*ELSE
lsel,r,loc,x,(0.5+SIGN(0.5,i))*Width/2-1e-12,(0.5+SIGN(0.5,i))*Width/2
*ENDIF
lsel,r,loc,y,j*Length/2-1e-12,j*Length/2
*GET,Line_Num,LINE, 0, NUM,MIN,
*GET,KP1,LINE,Line_Num,KP,1,
*GET,KP2,LINE,Line_Num,KP,2,
*GET,KP1_Y,KP,KP1, LOC, Z,
*GET,KP2_Y,KP,KP2, LOC, Z,
*IF,KP1_Y,GT,KP2_Y,THEN
lesize,all,THICKNESS(Num)/div(Num), , ,dscale(Num),1, , ,1,
*ELSE
lesize,all,THICKNESS(Num)/div(Num), , ,1/dscale(Num),1, , ,1,
*ENDIF
*ENDDO
*ENDDO
asel,all
esize,Size,0,
VSEL,S,LOC,Z,-TSum1,-TSum2
TYPE,1
MAT,Num
mshkey,1
mshape,0,3d
vmesh,ALL !Mesh the layer Num
allsel,all
TSum2=TSum2+Thickness(Num)
*enddo
/REP,FAST
/psf,hflu,,2,0
/PNUM,LINE,1
finish
/solu
Re:[原创] 通用的任意层材料的激光加热程序
以上代码所生成的三层模型。其对应层的MAT number分别是1,2,3(从上往下)。Re:[原创] 通用的任意层材料的激光加热程序
呵呵,其实这就是参数化建模的思想.最近做ansys,看的参考书也比较多了,有些书上就讲到了可以在ansys工具栏上面生成一个按纽,直接完成建模的工作,当然,这些就是ansys二次开发里面的内容.现在暂时还涉及不到.要求管理员为iomega加分
Re:[原创] 通用的任意层材料的激光加热程序
赞一个!
页:
[1]