8
 18/2 /2 015 20 APD L C om m ands Ev er y ANS YS M ec h anical User Should Know | PAD T, I nc . Th e Bl og http://www. padti nc.com/ bl o g/the-f ocus/20-a pdl - com mands- e very - ansys- mechani cal -user -shoul d- know 1/8 padtinc.com  http://www.padtinc.com/blog/the-focus/20-apdl-commands-every-ansys-mechanic al-user-should-know By Eric Miller August 29, 2013 20 APDL Commands Every ANSYS Mechanical User Should Know One of the most powerful things about ANSYS Mechanical is the fact that it creates an input file that is sent to  ANSYS Mechanical APDL (MAPDL) to solve. This is awesome because you as a user have complete and full access to the huge breadth and depth available in the MAPDL program. MAPDL is a good old-fashioned command driven program that takes in text commands one line at a time and executes them. So to access all those features, you just need to enter in the commands you want. For many older users this is not a problem because we grew up using the text commands. But new users did not get the chance to be exposed to the power of APDL (ANSYS Parametric Design Language) so getting access to those advanced capabilities can be tough. In fact, I was in a room next to one of our support engineers while they were showing a customer how to change the elements that the solver would solve (Mechanical defaults to the most common formulation, but you can change them to whatever still makes sense) and the user had to admit he had never really used or even seen APDL commands before. So, as a way to get ANSYS Mechanical users out there started down the road of loving APDL commands, we got together and came up with a list of 20 APDL commands that every user should know. Well, actually , it is more than 20 because we grouped some of them together. We are not going to give too much detail on their usage, the APDL help is fantastic and it explains everything. In fact, if you use a copy of PeDAL you can get the help right there live as you type (yes, that was a plug for you to go out and plop down $49 and buy PeDAL).  Also note that we are not getting in to how to script with APDL. It is a truly parametric command language in that you can replace most values in commands with parameters. It also has control logic, functions and other capabilities that you find in most scripting languages. We will focus on actual commands you use to do things in the program here. If you want to learn more about how to program with APDL, you can purchase a copy of our “Introduction to the ANSYS Parametric Design Language” book. (another plug) Some APDL Basics  APDL was developed back in the day of punch cards. It was much easier to use than the other programs out there because the commands you entered didn’t have to be formatted in columns. Instead arguments for commands are separated by commas. Therefore, instead of defining a Node in your model as: 345 12.456 17.4567 0.0034 (note that the location of that decimal point is critical). You create a line as: N,345,12.456,17.4567, 0.0034 Trust me, that was a big deal. But what you need to know now is that all APDL commands start with a keyword and are followed by arguments. The arguments are explained in the Command R eference in the help. So the entry for creating a node looks like this:

20 APDL Commands

Embed Size (px)

Citation preview

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

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

    ByEricMiller August29,2013

    20APDLCommandsEveryANSYSMechanicalUserShouldKnow

    OneofthemostpowerfulthingsaboutANSYSMechanicalisthefactthatitcreatesaninputfilethatissenttoANSYSMechanicalAPDL(MAPDL)tosolve.ThisisawesomebecauseyouasauserhavecompleteandfullaccesstothehugebreadthanddepthavailableintheMAPDLprogram.MAPDLisagoodoldfashionedcommanddrivenprogramthattakesintextcommandsonelineatatimeandexecutesthem.Sotoaccessallthosefeatures,youjustneedtoenterinthecommandsyouwant.

    Formanyolderusersthisisnotaproblembecausewegrewupusingthetextcommands.ButnewusersdidnotgetthechancetobeexposedtothepowerofAPDL(ANSYSParametricDesignLanguage)sogettingaccesstothoseadvancedcapabilitiescanbetough.

    Infact,Iwasinaroomnexttooneofoursupportengineerswhiletheywereshowingacustomerhowtochangetheelementsthatthesolverwouldsolve(Mechanicaldefaultstothemostcommonformulation,butyoucanchangethemtowhateverstillmakessense)andtheuserhadtoadmithehadneverreallyusedorevenseenAPDLcommandsbefore.

    So,asawaytogetANSYSMechanicalusersouttherestarteddowntheroadoflovingAPDLcommands,wegottogetherandcameupwithalistof20APDLcommandsthateveryusershouldknow.Well,actually,itismorethan20becausewegroupedsomeofthemtogether.Wearenotgoingtogivetoomuchdetailontheirusage,theAPDLhelpisfantasticanditexplainseverything.Infact,ifyouuseacopyofPeDALyoucangetthehelprightthereliveasyoutype(yes,thatwasaplugforyoutogooutandplopdown$49andbuyPeDAL).

    AlsonotethatwearenotgettingintohowtoscriptwithAPDL.Itisatrulyparametriccommandlanguageinthatyoucanreplacemostvaluesincommandswithparameters.Italsohascontrollogic,functionsandothercapabilitiesthatyoufindinmostscriptinglanguages.Wewillfocusonactualcommandsyouusetodothingsintheprogramhere.IfyouwanttolearnmoreabouthowtoprogramwithAPDL,youcanpurchaseacopyofourIntroductiontotheANSYSParametricDesignLanguagebook.(anotherplug)

    SomeAPDLBasics

    APDLwasdevelopedbackinthedayofpunchcards.Itwasmucheasiertousethantheotherprogramsouttherebecausethecommandsyouentereddidnthavetobeformattedincolumns.Insteadargumentsforcommandsareseparatedbycommas.Therefore,insteadofdefiningaNodeinyourmodelas:

    34512.45617.45670.0034

    (notethatthelocationofthatdecimalpointiscritical).Youcreatealineas:

    N,345,12.456,17.4567,0.0034

    Trustme,thatwasabigdeal.ButwhatyouneedtoknownowisthatallAPDLcommandsstartwithakeywordandarefollowedbyarguments.TheargumentsareexplainedintheCommandReferenceinthehelp.Sotheentryforcreatinganodelookslikethis:

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

    Thedocumentationisveryconsistentandyouwillquicklygetthehangofhowtogetwhatyouneedoutofit.Thelayoutisexplainedinthehelp://CommandReference//3.CommandDictionary

    AnotherkeythingtoknowaboutcommandsinMAPDListhatmostentitiesyoucreate(notloadsandboundaryconditions)haveanIDnumber.YourefertoentitiesbytheirIDnumber.ThisisakeyconceptthatgetslostifyougrewupusingGUIs.Soifyouwanttomakeacoordinatesystemanduseit,youdefineanIDforitandthenrefertothatID.Samethinggoesforelementdefinitions(ElementTypes),materialproperties,etcRememberthis,ithangsupalotofnewerusers.

    TouseMAPDLcommandsyousimplyentereachcommandonalineinacommandobjectthatyouplaceinyourmodeltree.Wedidaseminaronthisverysubjectabouttwoyearsagothatyoucanwatchhere.

    TheideaofentityselectionisfundamentaltoAPDL.AbovewepointoutthatallentitieshaveanID.YoucaninteractwitheachentitybyspecifyingitsID.Butwhenyouhavealotofthem,likenodesandelements,itwouldbeapain.SoAPDLdealswiththisbylettingyouselectentitiesofagiventypeandmakingthemselectedorunselectedThenwhenyouexecutecommands,insteadofspecifyinganID,youcanspecifyALLandalloftheselectedentitiesareusedforthatcommand.Sometimeswerefertoentitiesasbeingselected,andsometimeswerefertothemasactive.ThebasicconceptisthatanyentityinANSYSMechanicalAPDLcanbeoneoftwostates:active/selectedorinactive/unselected.inactive/unselectedentitiesarenotusedbywhatevercommandyoumightbeexecuting.

    IfyouwanttoseealloftheAPDLcommandthatANSYSMechanicalwritesout,simplyselectthesetupbranchofyourmodeltreeandchooseTools>WriteInputFile.Youcanviewitinatexteditor,orevenbetter,inPeDAL.

    Onelastimportantnotebeforewegothroughourlistofcommands:theoldGUIforMAPDLcanbeusedtomodifyorcreatemodelsaswellasANSYSMechanical.EveryactionyoutakeintheoldGUIisconvertedintoacommandandstoredinthejobname.logfile.Manyuserswillcarryouttheactionstheywantinaninteractive

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

    session,thensavethecommandstheyneedfromthelogfile.

    Wait,onemorething:Rightnowyouneedthesecommands.ButateveryreleasemoreandmoreofthesolverisexposedinANSYSMechanicalFUIandweendupusinglessandlessAPDLscripts.Sobeforeyouwriteascript,makesurethatANSYSMechanicalcantalreadydowhatyouwant.

    TheCommands

    1.!

    AnexclamationpointisacommentinAPDL.Anycharacterstotherightofoneareignoredbytheprogram.Usethemoftenandaddgreatcommentstohelpyouandothersrememberwhattheheckyouweretryingtodo.

    2./PREP7/SOLU/POST1FINISH

    TheMAPDLprogramconsistsofacollectionof10processors(thereweremore,buttheyhavebeenundocumented.)Commandsonlyworkinsomeprocessors,andmostonlyinone.Ifyouenterinapreprocessorcommandwhenyouareinthepostprocessor,youwillgetanerror.

    WhenyoucreateacommandobjectinyourANSYSMechanicalmodel,itwillbeexecutedineitherthePreprocessor,theSolutionprocessor,orinthePostprocessor.Dependingonwhereinthemodeltreeyouinsertthecommandobject.Ifyouneedtogointoanotherprocessoryoucan,yousimplyissuethepropercommandtochangeprocessors.JUSTREMEMBERTOGOBACKTOTHEPROCESSORYOUSTARTEDINwhenyouaredonewithyourcommands.

    /PREP7goestothepreprocessor.Usethistochangeelements,createthings,ormodifyyourmeshinanyway.

    /SOLUgoestothesolutionprocessor.Mostofthetimeyouwillstarttheresoyoumostoftenwillusethiscommandifyouwentinto/PREP7andneedtogetback.Modifyloads,boundaryconditions,andsolversettingsinthisprocessor.

    /POST1goestothepostprocessor.Thisiswhereyoucanplaywithyourresults,makeyourownplots,anddosomeverysophisticatedpostprocessing.

    FINISHgoestothebeginlevel.Youwillneedtogothereifyouaregoingtoplaywithfilenames.

    3.TYPEMATREALSECNUM

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

    YouonlyreallyneedtoknowthesecommandsifyouwillbemakingyourownelementsbutoneofthosethingseveryoneshouldknowbecausetheassignmentofelementattributesisfundamentaltothewayAPDLworks.soreadonevenifyoudontneedtomakeyourownelements.

    Everyelementinyourmodelisassignedpropertiesthatdefinetheelement.Whenyoudefineanelement,insteadofspecifyingallofitspropertiesforeachelement,youcreatedefinitionsandgivethemnumbers,thenassignthenumbertoeachelement.Thesimplestexamplearematerialproperties.Youdefineasetofmaterialproperties,giveitanumber,thenassignthatnumbertoalltheelementsinyourmodelthatyouwanttosolvewiththoseproperties.

    ButyoudonotspecifytheIDswhenyoucreatetheelements,thatwouldbeapain.Instead,youmaketheIDforeachpropertytypeactiveandeveryelementyoucreatewillbeassignedtheactiveIDs.

    Thecommandsareselfexplanatory:TypesetstheElementType,MATsetsthematerialID,REALsettherealconstantnumber,andSECNUMsetstheactivesectionnumber.

    So,ifyoudothefollowing:

    type,4real,2mat,34secnum,112e,1,2,3,4,11,12,13,14

    youget:

    ELEMMATTYPRELESYSECNODES13442011212341112131423440200101102103104111112113114

    4.ET

    TheMAPDLsolversupportshundredsofelements.ANSYSMechanicalpicksthebestelementforwhateversimulationyouwanttodofromageneralsense.Butthatmaynotbethebestforyourmodel.Insuchcases,youcanredefinetheelementdefinitionthatANSYSMechanicalused.

    Note:Thenewelementmusthavethesametopology.Youcantchangea4nodedshellintoan8nodedhex.Butifthenodeorderingisthesame(thetopology)thenyoucanmakethatchangeusingtheETcommand.

    5.EMODIF

    Ifyoudefinearealconstant,elementtype,ormaterialIDinAPDLandyouwanttochangeabunchofelementstothosenewIDs,youuseEMODIF.Thisisthefastestwaytochangeanelementsdefinition.

    6.MPMPDATAMPTEMPTBTBDATATBTEMP

    ProbablythemostcommonlyneededAPDLcommandforANSYSMechanicalusersarethebasicmaterialpropertycommands.LinearpropertiesaredefinedwithMPcommandforapolynomialvs.temperatureorMPDATAandMPTEMPforapiecewiselineartemperatureresponse.NonlinearmaterialpropertiesaredefinedwiththeTB,TBDATA,andTBTEMPcommands.

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

    Itisalwaysagoodideatostickyourmaterialdefinitionsinatextfilesoyou1)havearecordofwhatyouused,and2)canreusethematerialmodelonothersimulationjobs.

    7.RRMODIF

    IfyoudefineanelementsformulationwithoptionsontheETcommand,andthematerialpropertiesonthematerialcommands,wheredoyouspecifyotherstufflikeshellthickness,contactparameters,orhourglassstiffness?Youputtheminrealconstants.IfyouarenewtotheMAPDLsolvertheideaofRealconstantsisabithardtogetusedto.

    Theofficialexplanationis:

    Datarequiredforthecalculationoftheelementmatricesandloadvectors,butwhichcannotbedeterminedbyothermeans,areinputasrealconstants.Typicalrealconstantsincludehourglassstiffness,contactparameters,strandedcoilparameters,andplanethicknesses.

    Itreallyisaplacetoputstuffthathasnootherplace.Rcreatesarealconstant,andRMODIFcanbeusedtochangethem.

    8.NSELESEL

    Asmentioned,selectionlogicisahugepartofhowMAPDLworks.Youneverwanttoworkoneachobjectyouwanttoview,change,load,etcInsteadyouwanttoplaceentitiesofagiventypeintoanactivegroupandthenoperateonallactiveentities.(youcangroupthemandgivethemnamesaswell,seeCMCMSELCMDELEbelowtolearnaboutcomponents)

    WhenaccessingMAPDLfromANSYSMechanicalyouaremostoftenworkingwitheithernodesorelements.NSELandESELareusedtomanagewhatnodesandelementsareactive.Thesecommandshavealotofoptions,soreviewthehelp.

    9.NSLEESLN

    Youoftenselectnodesandthenneedtheelementsattachedtothosenodes.Oryouselectelementsandyouneedthenodesonthoseelements.NSLEandESLNdothat.NSLEselectsallofthenodesonthecurrentlyactiveelementsandESLNdoestheopposite.

    10.ALLSEL

    AverycommonmistakeforpeoplewritinglittlescriptsinAPDLforANSYSMechanicalistheyuseselectionlogictoselectthingsthattheywanttooperateon,andthentheydontremembertoreselectallthenodesandelements.IfyouissueanNSELandgetsaythenodesonthetopofyourpartthatyouwanttoapplyaloadto.Ifyoujuststoptherethesolverwillgenerateerrorsbecausethosewillbetheonlyactivenodesinthemodel.

    ALLSELfixesthis.Itsimplymakeseverythingactive.Itisagoodideatojuststickitattheendofyourscriptsifyoudoanyselecting.

    11.CMCMSEL

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

    IfyouuseANSYSMechanicalyoushouldbeveryfamiliarwiththeconceptofNamedSelections.Thesearegroupsofentities(nodes,elements,surfaces,edges,vertices)thatyouhaveputintoagroupsoyoucanscopebasedonthemratherthanselectingeachtime.InANSYSMAPDLthesearecalledcomponentsandcommandsthatworkwiththemstartwithCM.

    AnynamedselectionyoucreateforgeometryinANSYSMechanicalgetsturnedintoanodalcomponentallofthenodesthattouchthegeometryintheNamedSelectiongetthrownintothecomponent.YoucanalsocreateyourownnodeorelementNamedSelectionsandthosealsogetcreatedascomponentsinMAPDL.

    YoucanuseCMtocreateyourowncomponentsinyourAPDLscripts.Yougiveitanameandoperateaway.YoucanalsoselectcomponentswiththeCMSELcommand.

    12.*GET

    ThisisthesinglemostawesomelyusefulcommandinAPDL.Itisawaytointerrogateyourmodeltofindoutallsortsofusefulinformation:numberofnodes,largestZvaluefornodeposition,ifanodeisselected,loadsonanode,resultinformation,etc

    Checkoutthehelponthecommand.IfyoueverfindyourselfwritingascriptandgoingifIonlyknewblahdeblahblahaboutmymodelthenyouprobablyneedtouse*get.

    13.CSYSLOCALRSYS

    CoordinatesystemsareveryimportantinANSYSMechanicalandANSYSMAPDL.InmostcasesyoushouldcreateanycoordinatesystemsyouneedinANSYSMechanical.TheywillbeavailabletoyouinANSYSMAPDL,butbydefaultANSYSMechanicalassignsadefaultID.TouseacoordinatesysteminMAPDLyoushouldspecifythecoordinatesystemnumberinthedetailsforagivencoordinatesystembychangingCoordinateSystemfromProgramDefinedtoManualandthenspecifyinganumberforCoordinateSystemID

    IfyouneedtomakeacoordinatesysteminyourAPDLscript,usetheLOCALcommand.

    Whenyouwanttouseacoordinatesystem,useCSYStomakeagivencoordinatesystemactive.

    Note:Coordinatesystem0istheglobalCartesiansystem.IfyouchangetheactivecoordinatesystemmakesureyousetitbacktotheglobalsystemwithCSYS,0

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

    RSYSislikeCSYSbutforresults.IfyouwanttoplotorlistresultinformationinacoordinatesystemotherthantheglobalCartesian,useRSYStomakethecoordinatesystemyouwantactive.

    14:NROTATE

    Onethingtobeveryawareofisthateachnodeinamodelhasarotationassociatedwithit.Bydefault,theUX,UY,andUZdegreesoffreedomareorientedwiththeglobalCartesiancoordinatesystem.InANSYSMechanical,whenyouspecifyaloadoraboundaryconditionasnormalortangenttoasurface,theprogramactuallyrotatesallofthosenodessoadegreeoffreedomisnormaltothatsurface.

    IfyouneedtodothatyourselfbecauseyouwanttoapplyaloadorboundaryconditioninacertaindirectionbesidestheglobalCartesian,useNROTATE.Youbasicallyselectthenodesyouwanttorotate,specifytheactivecoordinatesystemwithCSYS,thenissueNROTATE,ALLtorotatethem.

    Becarefulthough.YoudontwanttoscrewwithanyrotationsthatANSYSMechanicalspecified.

    15.D

    Themostcommonboundaryconditionisdisplacement,evenfortemperature.TospecifythoseinanANSYSMAPDLscript,usetheDcommand.Mostpeopleusenodalselectionorcomponentstoapplydisplacementstomultiplenodes.

    Initssimplestformyouapplyasinglevaluefordisplacementtoonenodeinonedegreeoffreedom.Butyoucanspecifymultiplenodes,multipledegreesoffreedom,andmorepowerfully,thevaluefordeflectioncanbeatable.Learnabouttableshere.

    16.F

    TheFcommandisthesameastheDcommand,exceptitdefinesforcesinsteadofdisplacement.Know,it,useit.

    17.SFSFE

    Ifyouneedtoapplyapressureload,youuseeitherSFtoapplytonodesoreSFEtoapplytoelements.ItworksalotliketheDandFcommands.

    18./OUTPUT

    WhentheANSYSMAPDLsolverissolvingawayitwritesbitsandpiecesofinformationtoafilecalledjobename.out,wherejobnameisthenameofyoursolverjob.Sometimesyoumaywanttowriteoutspecificinformation,saylistthestressesforallthecurrentlyselectednodes,toafile.use/OUTPUT,filenametoredirectoutputtoafile.Whenyouaredonespecify/OUTPUTwithnooptionsanditwillgobacktothestandardoutput.

    19./SHOW

    ANSYSMAPDLhassomeverysophisticatedplottingcapabilities.Thereareatonofcommandandoptionsusedtosetupandcreateaplot,butthemostimportantis/SHOW,png.ThistellsANSYSMAPDLthatallplotsfromnowonwillbewritteninPNGformattoafile.Readallabouthowtousethiscommand,andhowtocontrolyourplots,here.

  • 18/2/2015 20APDLCommandsEveryANSYSMechanicalUserShouldKnow|PADT,Inc.TheBlog

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

    20.ETABLE

    TheANSYSMAPDLsolversolvesforalotofvalues.Themorecomplextheelementyouareusing,themorethenumberofvaluesyoucanstore.Buthowdoyougetaccesstothemoreobscureones?ETABLE.Issue38ofTheFocusfrom2005goesintosomeofthethingsyoucandowithETABLE.

    WheretogoFromHere

    Thisiscertainlynotthedefinitivelist.Ask20ANSYSMAPDLuserswhatAPDLcommandsallANSYSMechanicalusersshouldknow,andyoumightgetfiveorsixincommon.Butbasedonthesupportcallswegetandthescriptswewrite,this20arethemostcommonthatweuse.

    Commandhelpisyourfriendhere.Useitalot.

    TheotherthingyoushoulddoisopenupANSYSMAPDLinteractivelyandplaywiththesecommands.Seewhathappenswhenyouexecutethem.