Upload
mine-rva
View
217
Download
0
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.