General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

MAPDL Code to Find Component Mass, CG, and MOI

    • whbutc
      Subscriber

      I'm using Ansys 2019 R3 for a static structural analysis and trying to write APDL code to find the individual component mass, CG, and MOI. I've already got code that grabs each component name and then grabs the max value of each of von-mises, max and min principal. When I've tried adding on the following code it just gives results for the entire model instead of the selected component elements.

      IRLIST

      *Get,mass_x,ELEM,0,MTOT,X

      *Get,cg_x,ELEM,0,MC,X

      *Get,moi_x,ELEM,0,IMC,X

      I've found an example online that uses the below code and then uses the above *Get commands tograb individual component results. But it appears that PSOLVE is now a legacy command. Is there a new command that has taken its place that I need to be using? Or a different approach I should be using for this?

      irlf,-1                   ! Precalculate masses for summary printout only (no inertia relief)
      psolve,elform             ! Getting information about partial solving
      psolve,elprep             ! Solving
      


    • wrbulat
      Ansys Employee
      Yes, PSOLVE is legacy command (undocumented) but it's still in the code and still works. The documentation of this command looked like this:
      Please rename attached "inertial_props.txt" to "inertial_props.mac". Read attached "test01.txt" into an interactive MAPDL session (make sure "inertial_props.mac" is in the MAPDL working directory when you do). It solves in a heartbeat and leaves you looking at the inertial properties of the model:
      Best Bill
    • wrbulat
      Ansys Employee
      Oh, so to get the inertial properties of a subset of elements, select those elements and their nodes (ESLN) and then invoke the macro.
    • wrbulat
      Ansys Employee
      contents of "test01.inp":

      fini
      /cle

      /vie,1,1,1,1
      /esha,1

      *abbr,inrtprop,inertial_props
      abbs
      abbr

      C************************************
      C*** PARAMETERS
      C************************************
      l=0.1
      w=0.02
      t=0.005

      E=2e11
      nu=0.3
      dnsty=7800

      mass_expected=l*w*t*dnsty


      C************************************
      C*** MODEL
      C************************************
      /prep7

      rect,,l,,w

      et,1,181
      sect,1,shell
      secd,t
      r,1,t

      mp,ex,1,E
      mp,nuxy,1,nu
      mp,dens,1,dnsty

      ames,all

      nsel,s,loc,x
      d,all,all

      fini

      allsel

      inertial_props


      Contents of "inertial_props.mac":

      /sol ! macro by Bill Bulat

      /uis,msgpop,3
      irlf,-1
      ematwrite,yes
      psolve,elform
      psolve,elprep
      irlist
      *get,mtot,elem,,mtot,x

      *get,mcx,elem,,mc,x
      *get,mcy,elem,,mc,y
      *get,mcz,elem,,mc,z

      *get,imcx,elem,,imc,x
      *get,imcy,elem,,imc,y
      *get,imcz,elem,,imc,z

      *get,ipx,elem,,iprin,x
      *get,ipy,elem,,iprin,y
      *get,ipz,elem,,iprin,z

      *get,ang_xy,elem,,iang,xy
      *get,ang_yz,elem,,iang,yz
      *get,ang_zx,elem,,iang,zx

      /uis,msgpop,2
      *msg,ui,mtot,mcx,mcy,mcz,imcx,imcy,imcz
      Total Mass: %G %/&
      CGX = %G %/&
      CGY = %G %/&
      CGZ = %G %/&
      IXX = %G %/&
      IYY = %G %/&
      IZZ = %G %/&

    • Aniket
      Forum Moderator
      contents of "test01.inp":
      fini
      /cle
      /vie,1,1,1,1
      /esha,1
      *abbr,inrtprop,inertial_props
      abbs
      abbr
      C************************************
      C*** PARAMETERS
      C************************************
      l=0.1
      w=0.02
      t=0.005
      E=2e11
      nu=0.3
      dnsty=7800
      mass_expected=l*w*t*dnsty
      C************************************
      C*** MODEL
      C************************************
      /prep7
      rect,,l,,w
      et,1,181
      sect,1,shell
      secd,t
      r,1,t
      mp,ex,1,E
      mp,nuxy,1,nu
      mp,dens,1,dnsty
      ames,all
      nsel,s,loc,x
      d,all,all
      fini
      allsel
      inertial_props
      Contents of "inertial_props.mac":
      /sol ! macro by Bill Bulat
      /uis,msgpop,3
      irlf,-1
      ematwrite,yes
      psolve,elform
      psolve,elprep
      irlist
      *get,mtot,elem,,mtot,x
      *get,mcx,elem,,mc,x
      *get,mcy,elem,,mc,y
      *get,mcz,elem,,mc,z
      *get,imcx,elem,,imc,x
      *get,imcy,elem,,imc,y
      *get,imcz,elem,,imc,z
      *get,ipx,elem,,iprin,x
      *get,ipy,elem,,iprin,y
      *get,ipz,elem,,iprin,z
      *get,ang_xy,elem,,iang,xy
      *get,ang_yz,elem,,iang,yz
      *get,ang_zx,elem,,iang,zx
      /uis,msgpop,2
      *msg,ui,mtot,mcx,mcy,mcz,imcx,imcy,imcz
      Total Mass: %G %/&
      CGX = %G %/&
      CGY = %G %/&
      CGZ = %G %/&
      IXX = %G %/&
      IYY = %G %/&
      IZZ = %G %/&
    • S.Bender
      Subscriber

      I am using mechanical and I used the following post command to extract the mass of 2 of the 4 bodies in my model. (it's essentially what has been discussed above)

      /solu
      allsel
      cmsel,,comp_1,elem
      cmsel,a,comp_2,elem
      nsle
      !irlf,-1          Commented because irlf command doesnt work with axisymmetric elements
      psolve,elform
      psolve,elprep
      *get,mass_x,elem,,MTOT,X
      my_mass_x = mass_x*386.1 !use "my_" prefix to create parameterized output (in lbm)

Viewing 5 reply threads
  • The topic ‘MAPDL Code to Find Component Mass, CG, and MOI’ is closed to new replies.