Sie sind auf Seite 1von 8

18/2/2015

padtinc.com

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

20APDLCommandsEveryANSYSMechanicalUserShould
Know
ByEricMiller

August29,2013

OneofthemostpowerfulthingsaboutANSYSMechanicalisthefactthatitcreatesaninputfilethatissentto
ANSYSMechanicalAPDL(MAPDL)tosolve.Thisisawesomebecauseyouasauserhavecompleteandfull
accesstothehugebreadthanddepthavailableintheMAPDLprogram.MAPDLisagoodoldfashioned
commanddrivenprogramthattakesintextcommandsonelineatatimeandexecutesthem.Sotoaccessall
thosefeatures,youjustneedtoenterinthecommandsyouwant.
Formanyolderusersthisisnotaproblembecausewegrewupusingthetextcommands.Butnewusersdid
notgetthechancetobeexposedtothepowerofAPDL(ANSYSParametricDesignLanguage)sogetting
accesstothoseadvancedcapabilitiescanbetough.
Infact,Iwasinaroomnexttooneofoursupportengineerswhiletheywereshowingacustomerhowto
changetheelementsthatthesolverwouldsolve(Mechanicaldefaultstothemostcommonformulation,butyou
canchangethemtowhateverstillmakessense)andtheuserhadtoadmithehadneverreallyusedoreven
seenAPDLcommandsbefore.
So,asawaytogetANSYSMechanicalusersouttherestarteddowntheroadoflovingAPDLcommands,we
gottogetherandcameupwithalistof20APDLcommandsthateveryusershouldknow.Well,actually,itis
morethan20becausewegroupedsomeofthemtogether.Wearenotgoingtogivetoomuchdetailontheir
usage,theAPDLhelpisfantasticanditexplainseverything.Infact,ifyouuseacopyofPeDALyoucangetthe
helprightthereliveasyoutype(yes,thatwasaplugforyoutogooutandplopdown$49andbuyPeDAL).
AlsonotethatwearenotgettingintohowtoscriptwithAPDL.Itisatrulyparametriccommandlanguageinthat
youcanreplacemostvaluesincommandswithparameters.Italsohascontrollogic,functionsandother
capabilitiesthatyoufindinmostscriptinglanguages.Wewillfocusonactualcommandsyouusetodothings
intheprogramhere.IfyouwanttolearnmoreabouthowtoprogramwithAPDL,youcanpurchaseacopyof
ourIntroductiontotheANSYSParametricDesignLanguagebook.(anotherplug)

SomeAPDLBasics
APDLwasdevelopedbackinthedayofpunchcards.Itwasmucheasiertousethantheotherprogramsout
therebecausethecommandsyouentereddidnthavetobeformattedincolumns.Insteadargumentsfor
commandsareseparatedbycommas.Therefore,insteadofdefiningaNodeinyourmodelas:
34512.45617.45670.0034
(notethatthelocationofthatdecimalpointiscritical).Youcreatealineas:
N,345,12.456,17.4567,0.0034
Trustme,thatwasabigdeal.ButwhatyouneedtoknownowisthatallAPDLcommandsstartwithakeyword
andarefollowedbyarguments.TheargumentsareexplainedintheCommandReferenceinthehelp.Sothe
entryforcreatinganodelookslikethis:
http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

1/8

18/2/2015

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

Thedocumentationisveryconsistentandyouwillquicklygetthehangofhowtogetwhatyouneedoutofit.
Thelayoutisexplainedinthehelp://CommandReference//3.CommandDictionary
AnotherkeythingtoknowaboutcommandsinMAPDListhatmostentitiesyoucreate(notloadsandboundary
conditions)haveanIDnumber.YourefertoentitiesbytheirIDnumber.Thisisakeyconceptthatgetslostif
yougrewupusingGUIs.Soifyouwanttomakeacoordinatesystemanduseit,youdefineanIDforitand
thenrefertothatID.Samethinggoesforelementdefinitions(ElementTypes),materialproperties,etc
Rememberthis,ithangsupalotofnewerusers.
TouseMAPDLcommandsyousimplyentereachcommandonalineinacommandobjectthatyouplacein
yourmodeltree.Wedidaseminaronthisverysubjectabouttwoyearsagothatyoucanwatchhere.
TheideaofentityselectionisfundamentaltoAPDL.AbovewepointoutthatallentitieshaveanID.Youcan
interactwitheachentitybyspecifyingitsID.Butwhenyouhavealotofthem,likenodesandelements,itwould
beapain.SoAPDLdealswiththisbylettingyouselectentitiesofagiventypeandmakingthemselectedor
unselectedThenwhenyouexecutecommands,insteadofspecifyinganID,youcanspecifyALLandallof
theselectedentitiesareusedforthatcommand.Sometimeswerefertoentitiesasbeingselected,and
sometimeswerefertothemasactive.ThebasicconceptisthatanyentityinANSYSMechanicalAPDLcan
beoneoftwostates:active/selectedorinactive/unselected.inactive/unselectedentitiesarenotusedby
whatevercommandyoumightbeexecuting.
IfyouwanttoseealloftheAPDLcommandthatANSYSMechanicalwritesout,simplyselectthesetupbranch
ofyourmodeltreeandchooseTools>WriteInputFile.Youcanviewitinatexteditor,orevenbetter,inPeDAL.
Onelastimportantnotebeforewegothroughourlistofcommands:theoldGUIforMAPDLcanbeusedto
modifyorcreatemodelsaswellasANSYSMechanical.EveryactionyoutakeintheoldGUIisconvertedintoa
commandandstoredinthejobname.logfile.Manyuserswillcarryouttheactionstheywantinaninteractive
http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

2/8

18/2/2015

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

session,thensavethecommandstheyneed
fromthelogfile.
Wait,onemorething:Rightnowyouneed
thesecommands.Butateveryreleasemore
andmoreofthesolverisexposedinANSYS
MechanicalFUIandweendupusinglessand
lessAPDLscripts.Sobeforeyouwriteascript,
makesurethatANSYSMechanicalcant
alreadydowhatyouwant.

TheCommands
1.!
AnexclamationpointisacommentinAPDL.
Anycharacterstotherightofoneareignoredby
theprogram.Usethemoftenandaddgreat
commentstohelpyouandothersremember
whattheheckyouweretryingtodo.

2./PREP7/SOLU/POST1FINISH
TheMAPDLprogramconsistsofacollectionof
10processors(thereweremore,buttheyhave
beenundocumented.)Commandsonlyworkin
someprocessors,andmostonlyinone.Ifyou
enterinapreprocessorcommandwhenyouare
inthepostprocessor,youwillgetanerror.
WhenyoucreateacommandobjectinyourANSYSMechanicalmodel,itwillbeexecutedineitherthePre
processor,theSolutionprocessor,orinthePostprocessor.Dependingonwhereinthemodeltreeyouinsert
thecommandobject.Ifyouneedtogointoanotherprocessoryoucan,yousimplyissuethepropercommand
tochangeprocessors.JUSTREMEMBERTOGOBACKTOTHEPROCESSORYOUSTARTEDINwhenyou
aredonewithyourcommands.
/PREP7goestothepreprocessor.Usethistochangeelements,createthings,ormodifyyourmeshinany
way.
/SOLUgoestothesolutionprocessor.Mostofthetimeyouwillstarttheresoyoumostoftenwillusethis
commandifyouwentinto/PREP7andneedtogetback.Modifyloads,boundaryconditions,andsolversettings
inthisprocessor.
/POST1goestothepostprocessor.Thisiswhereyoucanplaywithyourresults,makeyourownplots,and
dosomeverysophisticatedpostprocessing.
FINISHgoestothebeginlevel.Youwillneedtogothereifyouaregoingtoplaywithfilenames.

3.TYPEMATREALSECNUM
http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

3/8

18/2/2015

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

Youonlyreallyneedtoknowthesecommandsifyouwillbemakingyourownelementsbutoneofthose
thingseveryoneshouldknowbecausetheassignmentofelementattributesisfundamentaltothewayAPDL
works.soreadonevenifyoudontneedtomakeyourownelements.
Everyelementinyourmodelisassignedpropertiesthatdefinetheelement.Whenyoudefineanelement,
insteadofspecifyingallofitspropertiesforeachelement,youcreatedefinitionsandgivethemnumbers,then
assignthenumbertoeachelement.Thesimplestexamplearematerialproperties.Youdefineasetofmaterial
properties,giveitanumber,thenassignthatnumbertoalltheelementsinyourmodelthatyouwanttosolve
withthoseproperties.
ButyoudonotspecifytheIDswhenyoucreatetheelements,thatwouldbeapain.Instead,youmaketheID
foreachpropertytypeactiveandeveryelementyoucreatewillbeassignedtheactiveIDs.
Thecommandsareselfexplanatory:TypesetstheElementType,MATsetsthematerialID,REALsetthereal
constantnumber,andSECNUMsetstheactivesectionnumber.
So,ifyoudothefollowing:
type,4
real,2
mat,34
secnum,112
e,1,2,3,4,11,12,13,14
youget:
ELEMMATTYPRELESYSECNODES
134420112123411121314
23440200101102103104111112113114

4.ET
TheMAPDLsolversupportshundredsofelements.ANSYSMechanicalpicksthebestelementforwhatever
simulationyouwanttodofromageneralsense.Butthatmaynotbethebestforyourmodel.Insuchcases,
youcanredefinetheelementdefinitionthatANSYSMechanicalused.
Note:Thenewelementmusthavethesametopology.Youcantchangea4nodedshellintoan8nodedhex.
Butifthenodeorderingisthesame(thetopology)thenyoucanmakethatchangeusingtheETcommand.

5.EMODIF
Ifyoudefinearealconstant,elementtype,ormaterialIDinAPDLandyouwanttochangeabunchofelements
tothosenewIDs,youuseEMODIF.Thisisthefastestwaytochangeanelementsdefinition.

6.MPMPDATAMPTEMPTBTBDATATBTEMP
ProbablythemostcommonlyneededAPDLcommandforANSYSMechanicalusersarethebasicmaterial
propertycommands.LinearpropertiesaredefinedwithMPcommandforapolynomialvs.temperatureor
MPDATAandMPTEMPforapiecewiselineartemperatureresponse.Nonlinearmaterialpropertiesaredefined
withtheTB,TBDATA,andTBTEMPcommands.
http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

4/8

18/2/2015

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

Itisalwaysagoodideatostickyourmaterialdefinitionsinatextfilesoyou1)havearecordofwhatyouused,
and2)canreusethematerialmodelonothersimulationjobs.

7.RRMODIF
IfyoudefineanelementsformulationwithoptionsontheETcommand,andthematerialpropertiesonthe
materialcommands,wheredoyouspecifyotherstufflikeshellthickness,contactparameters,orhourglass
stiffness?Youputtheminrealconstants.IfyouarenewtotheMAPDLsolvertheideaofRealconstantsisa
bithardtogetusedto.
Theofficialexplanationis:

Datarequiredforthecalculationoftheelementmatricesandloadvectors,butwhichcannotbe
determinedbyothermeans,areinputasrealconstants.Typicalrealconstantsincludehourglass
stiffness,contactparameters,strandedcoilparameters,andplanethicknesses.

Itreallyisaplacetoputstuffthathasnootherplace.Rcreatesarealconstant,andRMODIFcanbeusedto
changethem.

8.NSELESEL
Asmentioned,selectionlogicisahugepartofhowMAPDLworks.Youneverwanttoworkoneachobjectyou
wanttoview,change,load,etcInsteadyouwanttoplaceentitiesofagiventypeintoanactivegroupand
thenoperateonallactiveentities.(youcangroupthemandgivethemnamesaswell,seeCMCMSEL
CMDELEbelowtolearnaboutcomponents)
WhenaccessingMAPDLfromANSYSMechanicalyouaremostoftenworkingwitheithernodesorelements.
NSELandESELareusedtomanagewhatnodesandelementsareactive.Thesecommandshavealotof
options,soreviewthehelp.

9.NSLEESLN
Youoftenselectnodesandthenneedtheelementsattachedtothosenodes.Oryouselectelementsandyou
needthenodesonthoseelements.NSLEandESLNdothat.NSLEselectsallofthenodesonthecurrently
activeelementsandESLNdoestheopposite.

10.ALLSEL
AverycommonmistakeforpeoplewritinglittlescriptsinAPDLforANSYSMechanicalistheyuseselection
logictoselectthingsthattheywanttooperateon,andthentheydontremembertoreselectallthenodesand
elements.IfyouissueanNSELandgetsaythenodesonthetopofyourpartthatyouwanttoapplyaloadto.
Ifyoujuststoptherethesolverwillgenerateerrorsbecausethosewillbetheonlyactivenodesinthemodel.
ALLSELfixesthis.Itsimplymakeseverythingactive.Itisagoodideatojuststickitattheendofyourscriptsif
youdoanyselecting.

11.CMCMSEL
http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

5/8

18/2/2015

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

IfyouuseANSYSMechanicalyoushouldbeveryfamiliarwiththeconceptofNamedSelections.Theseare
groupsofentities(nodes,elements,surfaces,edges,vertices)thatyouhaveputintoagroupsoyoucanscope
basedonthemratherthanselectingeachtime.InANSYSMAPDLthesearecalledcomponentsandcommands
thatworkwiththemstartwithCM.
AnynamedselectionyoucreateforgeometryinANSYSMechanicalgetsturnedintoanodalcomponentallof
thenodesthattouchthegeometryintheNamedSelectiongetthrownintothecomponent.Youcanalsocreate
yourownnodeorelementNamedSelectionsandthosealsogetcreatedascomponentsinMAPDL.
YoucanuseCMtocreateyourowncomponentsinyourAPDLscripts.Yougiveitanameandoperateaway.
YoucanalsoselectcomponentswiththeCMSELcommand.

12.*GET
ThisisthesinglemostawesomelyusefulcommandinAPDL.Itisawaytointerrogateyourmodeltofindoutall
sortsofusefulinformation:numberofnodes,largestZvaluefornodeposition,ifanodeisselected,loadsona
node,resultinformation,etc
Checkoutthehelponthecommand.IfyoueverfindyourselfwritingascriptandgoingifIonlyknewblahde
blahblahaboutmymodelthenyouprobablyneedtouse*get.

13.CSYSLOCALRSYS
CoordinatesystemsareveryimportantinANSYSMechanicalandANSYSMAPDL.Inmostcasesyoushould
createanycoordinatesystemsyouneedinANSYSMechanical.TheywillbeavailabletoyouinANSYS
MAPDL,butbydefaultANSYSMechanicalassignsadefaultID.TouseacoordinatesysteminMAPDLyou
shouldspecifythecoordinatesystemnumberinthedetailsforagivencoordinatesystembychanging
CoordinateSystemfromProgramDefinedtoManualandthenspecifyinganumberforCoordinateSystem
ID

IfyouneedtomakeacoordinatesysteminyourAPDLscript,usetheLOCALcommand.
Whenyouwanttouseacoordinatesystem,useCSYStomakeagivencoordinatesystemactive.
Note:Coordinatesystem0istheglobalCartesiansystem.Ifyouchangetheactivecoordinatesystemmake
sureyousetitbacktotheglobalsystemwithCSYS,0
http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

6/8

18/2/2015

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

RSYSislikeCSYSbutforresults.Ifyouwanttoplotorlistresultinformationinacoordinatesystemotherthan
theglobalCartesian,useRSYStomakethecoordinatesystemyouwantactive.

14:NROTATE
Onethingtobeveryawareofisthateachnodeinamodelhasarotationassociatedwithit.Bydefault,theUX,
UY,andUZdegreesoffreedomareorientedwiththeglobalCartesiancoordinatesystem.InANSYS
Mechanical,whenyouspecifyaloadoraboundaryconditionasnormalortangenttoasurface,theprogram
actuallyrotatesallofthosenodessoadegreeoffreedomisnormaltothatsurface.
Ifyouneedtodothatyourselfbecauseyouwanttoapplyaloadorboundaryconditioninacertaindirection
besidestheglobalCartesian,useNROTATE.Youbasicallyselectthenodesyouwanttorotate,specifythe
activecoordinatesystemwithCSYS,thenissueNROTATE,ALLtorotatethem.
Becarefulthough.YoudontwanttoscrewwithanyrotationsthatANSYSMechanicalspecified.

15.D
Themostcommonboundaryconditionisdisplacement,evenfortemperature.TospecifythoseinanANSYS
MAPDLscript,usetheDcommand.Mostpeopleusenodalselectionorcomponentstoapplydisplacementsto
multiplenodes.
Initssimplestformyouapplyasinglevaluefordisplacementtoonenodeinonedegreeoffreedom.Butyou
canspecifymultiplenodes,multipledegreesoffreedom,andmorepowerfully,thevaluefordeflectioncanbea
table.Learnabouttableshere.

16.F
TheFcommandisthesameastheDcommand,exceptitdefinesforcesinsteadofdisplacement.Know,it,use
it.

17.SFSFE
Ifyouneedtoapplyapressureload,youuseeitherSFtoapplytonodesoreSFEtoapplytoelements.Itworks
alotliketheDandFcommands.

18./OUTPUT
WhentheANSYSMAPDLsolverissolvingawayitwritesbitsandpiecesofinformationtoafilecalled
jobename.out,wherejobnameisthenameofyoursolverjob.Sometimesyoumaywanttowriteoutspecific
information,saylistthestressesforallthecurrentlyselectednodes,toafile.use/OUTPUT,filenametoredirect
outputtoafile.Whenyouaredonespecify/OUTPUTwithnooptionsanditwillgobacktothestandardoutput.

19./SHOW
ANSYSMAPDLhassomeverysophisticatedplottingcapabilities.Thereareatonofcommandandoptions
usedtosetupandcreateaplot,butthemostimportantis/SHOW,png.ThistellsANSYSMAPDLthatallplots
fromnowonwillbewritteninPNGformattoafile.Readallabouthowtousethiscommand,andhowtocontrol
yourplots,here.
http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

7/8

18/2/2015

20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

20.ETABLE
TheANSYSMAPDLsolversolvesforalotofvalues.The
morecomplextheelementyouareusing,themorethe
numberofvaluesyoucanstore.Buthowdoyouget
accesstothemoreobscureones?ETABLE.Issue38of
TheFocusfrom2005goesintosomeofthethingsyou
candowithETABLE.

WheretogoFromHere
Thisiscertainlynotthedefinitivelist.Ask20ANSYS
MAPDLuserswhatAPDLcommandsallANSYS
Mechanicalusersshouldknow,andyoumightgetfiveor
sixincommon.Butbasedonthesupportcallswegetand
thescriptswewrite,this20arethemostcommonthatwe
use.
Commandhelpisyourfriendhere.Useitalot.
TheotherthingyoushoulddoisopenupANSYSMAPDLinteractivelyandplaywiththesecommands.See
whathappenswhenyouexecutethem.

http://www.padtinc.com/blog/thefocus/20apdlcommandseveryansysmechanicalusershouldknow

8/8