1
$\begingroup$

How to change the material properties, i.e. Young's modulus and Poisson's ratio, of a set of elements which is defined by a named selection in Ansys workbench using a command snippet of APDL code?

The named selection is denoted steelElements. An appropriate material, named Structural Steel is defined in an "engineering data" system.

$\endgroup$
1
$\begingroup$

Strategy:

  • Identify maximum number of material properties
  • Create material
  • Assign material to selected elements

Code:

    !   Commands inserted into this file will be executed just prior to the ANSYS SOLVE command.
    !   These commands may supersede command settings set by Workbench.

    !   Active UNIT system in Workbench when this object was created:  Metric (mm, t, N, s, mV, mA)
    !   NOTE:  Any data that requires units (such as mass) is assumed to be in the consistent solver unit system.
    !                See Solving Units in the help system for more information.
    FINISH
    /PREP7
    *DEL,mySelectioName,,nopr 
    *DIM, mySelectioName, string, 248, 1
    !################### Start User Input
    myEModul = 210000
    myPoissionration = 0.3
    mySelectioName(1, 1) = 'steelElements'
    !################### End User Input
    ALLSEL
    !Get maximal material number assigned and increment
    *GET,maxMaterialNumber,ELEM,0,MATM
    maxMaterialNumber = maxMaterialNumber + 1
    !Create new material properties
    MP, EX, maxMaterialNumber, myEModul
    MP, NUXY, maxMaterialNumber, myPoissionration
    !Select elements and change material property number of those materials
    CMSEL,s,mySelectioName(1, 1)
    MPCHG, maxMaterialNumber, all
    !Select all entities and leave code snippet
    ALLSEL
    FINISH
    /SOLU

    ! Doublecheck in Classic:
    !   /pnum,mat,1 !0=off, 1=on
    !   /number,1   !0=on, 1=off
$\endgroup$
1
  • $\begingroup$ To get the maximum material number defined, you should use: *GET, maxMaterialNumber, MAT, 0, NUM, MAX $\endgroup$ – Banghua Zhao Dec 8 '18 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.