2014-11-21 84 views
0

我使用ANSYS分析一個基本結構,並且需要在動態分析和靜態分析之間切換。有時我只需要考慮一定的負載。這使解決方案陷入混亂。ANSYS:如何組織我的代碼?

!!! Add wind loads 
*DIM,windforce,,4 
windforce(1) = 2520 
windforce(2) = -1575 
windforce(3) = -1890 
windforce(4) = -1575 

*DO,i,1,3 
SFBEAM,i ,1 ,PRES ,windforce(1) 
*enddo 
*DO,i,4,6 
SFBEAM,i ,1 ,PRES ,windforce(2) 
*enddo 
*DO,i,7,9 
SFBEAM,i ,1 ,PRES ,windforce(3) 
*enddo 
*DO,i,10,12 
SFBEAM,i ,1 ,PRES ,windforce(4) 
*enddo 



FINISH 
/SOLU     ! enter solution phase 

! !!Dynamic Analysis 
! antype,modal     
! modopt,lanb,40,0,0,,off   
! mxpand,0,,,0      
! lumpm,1 
! solve 
! finish 

! ! ! Generate Mass and K Matrix 
! antype,substr 
! seopt,yg_bde,2 
! lumpm,1 
! m,all,all  
! /output,matrix 
! solve 
! /output 
! selist,yg_bde,3 
! finish 

SOLVE     ! solve the resulting system of equations 
FINISH 

每次我在這個分析之間切換時,我都需要評論一個大的代碼塊。這看起來非常糟糕。

那麼如何組織我的代碼?或者如何使這個代碼模塊化?有沒有ANSYS腳本語言的框架? (對於css類似scss)。

回答

1

我不認爲有這樣的工具,但有Ansys批准的文本編輯器和其他有用的程序(數字轉換器,CAD轉換器e.t.c)的list

我想,如果有任何好的框架,它必須在那裏列出。

0

我使用jedit來編輯複雜的ANSYS文件,除了具有腳本軟件的各種典型功能外,它還可以識別大多數ANSYS命令並對它們進行顏色編碼以便於參考。

您必須重命名輸入文件* .ans,以便jedit識別ANSYS格式。

我不確定這是否意味着「模塊化」代碼,但您可以創建各種腳本並使用命令 /INPUT,'file_name','file_extension'從主例程調用它們, 'relative_path',, 0

0

我建議在單獨的文件中使用代碼塊,然後在主代碼中調用這些文件。

切換部分代碼的最簡單方法是將* IF條件與參數結合使用。然後,您可以將腳本命名爲myscript.txt,ARG1,ARG2,ARG3 ..其中myscript.txt是您的腳本名稱(也是.ans, .mac ...),而ARGx是您的交換機。

樣品:

! here is the same stuff for any run 

*IF,ARG1,EQ,1,then 
! here is one variation of the code (e.g. static analysis) 
*ENDIF 

*IF,ARG1,EQ,2,then 
! here is another variation of the code (e.g. dynamic analysis) 
*ENDIF 

! here is again code used for any variation of the code 

如果上述樣品在稱爲solverswitch.txt文本文件,那麼將通過solverswitch.txt,1執行各種求解器選項(或solverswitch.txt,2)

0

我主要使用橋樑,我經常需要做多種類型的分析(靜態,動態等)。我的工作流程是基本的APDL文件,例如「truss_bridge.txt」,它分別調用其他文件:「bridge_load.txt」,「bridge_design.txt」,「bridge_out.txt」用於不同類型的分析,網格劃分,輸出。 我使用/ EOF命令在每個文件中分隔這些不同的選項,並使用/ INPUT命令指定相應的行來調用我想要的分析類型。所以我的基本檔案可能是這樣的:

/INPUT,viaduct_materials,txt,direct  ! material parameters 
    /INPUT,viaduct_real_constants,txt,direct ! R.C. parameters  
    /INPUT,viaduct_design,txt,direct   ! Design bridge and meshing 

    /INPUT,viaduct_load,txt,direct,1 ! LOAD File static analysis 
    ! Post Processing 
    /INPUT,viaduct_out,txt,direct,1 ! Output file S.A. 

    /INPUT,viaduct_load,txt,direct,14 ! LOAD File dynamic analysis 
    ! Post Processing 
    /INPUT,viaduct_out,txt,direct,21 ! Output file D.A.