Along with the example Using Design Assessment to Obtain Results from Mechanical APDL, the purpose of this example is to illustrate how to run Mechanical APDL in batch mode using Design Assessment, and how to present the results within the Workbench environment - see MAPDL Command Reference for further information.
Unlike Using Design Assessment to Obtain Results from Mechanical APDL which is more generic, this example is set up to run a specific script and obtain specific results; therefore the interface can be more targeted and offer better guidance to the user.
In this example the input file for Mechanical APDL is dynamically generated by the python script. This in turn calls a fix macro with various given parameters as determined from the DA Result objects added to the model.
The macro file that is run, named LayerMultiPly.mac, is as follows:
! INPUT:
! Input arguments relate to the failure criteria for one material
! ARG1 Type of result, e.g. 'fail'
! ARG2 Subtype of the result, e.g. 'emax'
! ARG3 1 for nodal or 0 for elemental based results
! ARG4 1 based layer number
!
! OUTPUT: critical layer and Strength Ratio will be written to defined CSV file
!
/post1
/delete,CSVFile_Directory(1),csv
/cwd,Current_Directory(1)
Type = ARG1
SubType = ARG2
DisplayType = ARG3
LayerNum = ARG4
file,SYS_Directory(1),rst
set,last ! set the last set into memory
rsys,solu
! set the failure criteria
FCTYP,add,all
tblist,,1
! set the layer
layer,LayerNum
*if,DisplayType,eq,0,then
! select the elements
esel,s,ename,,181
! get the number of elements that we need to loop over
*get,ecount,elem,0,count
! make sure some elements are selection
*if,ecount,lt,1,then
*MSG,ERROR
THERE ARE NO ELEMENTS SELECTED FOR FAILURE CHECKING
*endif
! dimension the output arrays
*dim,output,arra,ecount,2
etab,bob,Type,SubType
!get elemental results
curre = 0
*do,i,1,ecount
curre = ELNEXT(curre) ! get the element number
output(i,1) = curre
*get,output(i,2),etab,1,elem,curre
*enddo
*cfopen,CSVFileScratch_Directory(1),csv
*vwrite,output(1,1),output(1,2)
(F10.0,',',F16.3)
*cfclose
*elseif,DisplayType,eq,1,then
! select the elements
esel,s,ename,,181
nsle
! get the number of nodes that we need to loop over
*get,ncount,node,0,count
! make sure some nodes are selection
*if,ncount,lt,1,then
*MSG,ERROR
THERE ARE NO NODES SELECTED FOR FAILURE CHECKING
*endif
*dim,output2,arra,ncount,2
curre = 0
*do,i,1,ncount
curre = NDNEXT(curre)
output2(i,1) = curre
*get,output2(i,2),node,i,Type,SubType
*enddo
*cfopen,CSVFileScratch_Directory(1),csv
*vwrite,output2(1,1),output2(1,2)
(F10.0,',',F16.3)
*cfclose
*endifIt is recommended that the files for this example are to be placed in your user_files folder.