Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
General Mechanical

General Mechanical

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

how to change material for elements between load steps and continue the simulation?

    • Jirong
      Subscriber

      Hi ALL,

      I'm trying to use MPCHG to change material for some elements between load steps if the elements' EPELX is negative, and then go back to the solution processor and continue for a next load step. 

      I found this APDL script from SimuTech website, but don't know how to use it correctly. Any suggestions?


      *GET,current_loadstep,ACTIVE,,SET,LSTP ! current load step number

      *IF,current_loadstep,EQ,0,then ! before first load step SOLVE

      ! Location of macros in user_files

      FINISH

      /PSEARCH,_wb_userfiles_dir(1) ! provides location of “user_files”

      /SOLU

      *GET,my,ACTIVE,,JOBNAM ! jobname, <= 8 characters

      /DELETE,my,rdb ! if exists, req’d for single frame restart

      RESCONTROL,DEFINE,NONE ! no files for multiframe restart

      *ENDIF


      *GET,current_loadstep,ACTIVE,,SET,LSTP ! current load step number

      *IF,current_loadstep,GT,0,then ! after a load step SOLVE

      FINISH

      /POST1

      SET,LAST ! just in case not loaded

      *GET,num_elem,elem,,COUNT ! how many elements

      *GET,num_elem_max,elem,,NUM,MAX ! highest element number

      ! example examination of results

      ETABLE,my_epeq,NL,EPELX ! Example

      *DEL,my_epeq,,NOPR ! delete array without warning

      *DIM,my_epeq,ARRAY,num_elem_max ! array to hold strain

      *VGET,my_epeq(1),ELEM,1,ETAB,my_epeq ! element table column to array

      FINISH

      !

      /SOLU

      ANTYPE,,REST ! single frame restart

      ! Example: make changes according to my_epeq array contents

      current_elem=0

      *DO,ii,1,num_elem ! step through elements

      current_elem=ELNEXT(current_elem) ! next element

      ! create changes for this element per my_epeq(current_elem) value

      ! …

      *ENDDO

      ALLSEL

      *ENDIF

      ! At this point, WB follows with the next SOLVE using the above settings…


      Thanks,

      JL

    • ErKo
      Ansys Employee
      HI

      This is a not standard use of mechanical - we can only give some hints of what to do here.

      ! create changes for this element per my_epeq(current_elem) value
      ! 
      Add an if statement at that line (see *if in the apdl manual) to check the my_eplx(current_elem) is negative.

      If it is, then use the mpchg command (see apdl help manual), to change its property.

      All the best

      Erik
    • Jirong
      Subscriber
      Thanks for your reply!
      I try to use *if statement to achieve your suggestion:
      *IF,my_epeq(current_elem),LT,0,then
      CMSEL,s,my_epeq(current_elem)
      MPCHG, maxMaterialNumber,my_epeq(current_elem)
      *ENDIF
      But I got error said "Component MY_EPEQ is not defined" after *if statement was executed.Here is the error message:
      *IFmy_epeq(current_elem)( = -0.300000E-01 )LT
      0( =0.00000)THEN
      SELECTCOMPONENT MY_EPEQ
      *** ERROR ***CP =2.422TIME= 19:05:18
      Component MY_EPEQ is not defined.
      How to select the elements that satisfy the *if statement ? Do I need to create another array for CMSEL?

      Thanks Jirong
    • Felix Aschmann
      Subscriber
      Hi Jirong CMSEL selects a component, but you haven't defined a component.
      If you wanted to select the element then you need to issue the 'esel' command.
      However for changing the material assigned to an element you don't have to select the element. It's sufficient to issue the MPCHG command for the element(s) you want to change.

      Regards!
Viewing 3 reply threads
  • The topic ‘how to change material for elements between load steps and continue the simulation?’ is closed to new replies.
[bingo_chatbox]