! 平面刚架的优化设计
! (1) 设置变量,标题,分析类型,单元类型和材料参数
*CREATE,SCRATCH
D1=0.1
D2=0.1
! (2) 设置标题、分析类型、单元类型和材料参数
/PREP7
/TITLE, EX11.2, OPTIMIZATION OF A FRAME STRUCTURE
/COM REF. TOPPING AND ROBINSON, ENG.COMPUT., 1984, VOL.1, PP. 252-262
ANTYPE,STATIC
ET,1,BEAM3
C*** SET THE REAL CONSTANTS USING PARAMETRIC EXPRESSIONS
K=825000.0
D1CB=D1**3
D2CB=D2**3
R,1,(D1**2)/2,D1*(D1CB/24),D1
R,2,(D2**2)/2,D2*(D2CB/24),D2
MP,EX,1,1E10
MP,NUXY,1,0.3
! (3) 定义节点和单元
N,1
N,2,,2.5
N,3,2.165,3.75
REAL,1
E,1,2
REAL,2
E,2,3
! (4) 定义位移约束和荷载
D,1,ALL,0
F,3,FY,-2000
NSEL,S,LOC,X,2.1,2.2
DSYM,SYMM,X
NSEL,ALL
DLIST,ALL
FINISH
! (5) 在求解模块求解
/SOLU
SOLVE
FINISH
! (6) 在后处理模块通过单元表提取结果后,保存到变量
/POST1
ETABLE,VOLU,VOLU
ETABLE,MI,SMISC,6
ETABLE,MJ,SMISC,12
*GET,M11,ELEM,1,ETAB,MI
*GET,M21,ELEM,1,ETAB,MJ
*GET,M12,ELEM,2,ETAB,MI
*GET,M22,ELEM,2,ETAB,MJ
*STATUS,Parm
LIM1=D1CB*K
LIM2=D2CB*K
M11L=LIM1-(ABS(M11))
M21L=LIM1-(ABS(M21))
M12L=LIM2-(ABS(M12))
M22L=LIM2-(ABS(M22))
SSUM
*GET,TVOL,SSUM,,ITEM,VOLU
TVOL=TVOL*2
FINISH
*END
! (7) 进入优化设计模块,设置目标函数和优化变量
FINISH
/CLEAR, NOSTART
/FILENAME,EX11.2P
*USE,SCRATCH
/OPT
OPANL,SCRATCH
OPVAR,D1,DV,0.05,0.5
OPVAR,D2,DV,0.05,0.5
OPVAR,M11L,SV,0,2000
OPVAR,M21L,SV,0,2000
OPVAR,M12L,SV,0,2000
OPVAR,M22L,SV,0,2000
OPVAR,TVOL,OBJ,,,0.00001
OPTYPE,SUBP
OPSUBP,15
OPPRNT,ON
! (8) 开始优化设计
OPEXE
OPLIST,ALL,,1
! (9) 定义数组变量,将结果保存到这些数组变量
*DIM,LABEL,CHAR,3,2
*DIM,VALUE,,3,3
LABEL(1,1) = 'VOL ','DIS(1) ','DIS(2) '
LABEL(1,2) = 'CUB m','m','m'
*VFILL,VALUE(1,1),DATA,0.0764,0.118,0.129
*VFILL,VALUE(1,2),DATA,TVOL,D1,D2
*VFILL,VALUE(1,3),DATA,(TVOL/0.0764),(D1/0.118),(D2/0.129)
/COM
/OUT,EX11_2,out
/COM,------------------- EX11.2 RESULTS COMPARISON -------------
/COM,
/COM, | TARGET | ANSYS | RATIO
/COM,
*VWRITE,LABEL(1,1),LABEL(1,2),VALUE(1,1),VALUE(1,2),VALUE(1,3)
(1X,A8,A8,' ',F10.4,' ',F10.4,' ',1F7.3)
/COM,----------------------------------------------------------
/OUT
FINISH
*LIST,EX11_2,out |