General Mechanical

General Mechanical

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

Stiffness matrix commands for student version

    • blmcdona
      Subscriber

      Are commands such as the "ematwrite,yes" command supported with this software version?  I have written the command as an inserted command object in the model tree, but the stiffness matrix is not being written.  Is this due to using the Student Version of the software?

    • Aniket
      Forum Moderator

      it should work in the student version as well. 

      The EMATWRITE command in Mechanical APDL forces the writing of the element matrices to a file named Jobname.emat. This command can be particularly useful when you need to ensure that the element matrices are written out, which might not be done by default. The command can be used with a key of "YES" to force the writing of the element matrices, even if it's not normally done. By default, the value is "NO," which means element matrices are written only if required. It's important to note that if used in the solution processor with the /SOLU command, EMATWRITE is valid only within the first load step. Additionally, this command is also valid in PREP7, but it cannot be accessed from a menu.

      -Aniket

      Forum Rules & Guidelines

    • blmcdona
      Subscriber

      Thank you for your response.  Regarding commands, I actually used different commands to write the following code for stiffness and mass matrix:

       

       
       
      *CFOPEN, stiffness_matrix.txt, TXT  ! Open a file for writing the stiffness matrix
       
      /SOLU                     ! Switch to the solution environment
      MAT, K, 1, STIFF  ! This will extract the global stiffness matrix
       
      *DO, I, 1, 1000   ! Loop over matrix rows (adjust the number based on your model size)
          *DO, J, 1, 1000  ! Loop over matrix columns (adjust based on your model)
              *GET, Kij, MATRIX, I, J, STIFF  ! Get the stiffness matrix component K_ij
              *VWRITE, I, J, Kij
              (F10.5, F10.5, F10.5)  ! Format for writing the data
          *ENDDO
      *ENDDO
       
      *CFCLOS   ! Close the output file after writing the matrix
       
       
      !Mass matrix
       
      *CFOPEN, global_mass_matrix.txt, TXT  ! Open a text file for writing the mass matrix
       
      /SOLU                     ! Switch to the solution environment
      MAT, M, 1, MASS  ! Extract the global mass matrix
       
      *DO, I, 1, 1000   ! Loop over matrix rows (adjust the number based on your model size)
          *DO, J, 1, 1000  ! Loop over matrix columns (adjust based on your model)
              *GET, Mij, MATRIX, I, J, MASS  ! Get the mass matrix component M_ij
              *VWRITE, I, J, Mij
              (F10.5, F10.5, F10.5)  ! Format for writing the data (adjust as needed)
          *ENDDO
      *ENDDO
       
      *CFCLOS  ! Close the output file after writing the matrix
       
      However, the matrices are not square.  Instead, the only have three columns.  How do I make the matrices square?
       
      Best,
      Brandon
    • blmcdona
      Subscriber

      I wrote the following code in order to create a 10x10 stiffness matrix after modal analysis.  However, only the first column of the matrix is written; the rest are zeros.

       
      *CFOPEN, stiffness_matrix.txt, TXT  ! Open a file for writing the stiffness matrix
       
      /SOLU                     ! Switch to the solution environment
      MAT, K, 1, STIFF  ! This will extract the global stiffness matrix
       
       *DO, I, 1, 10   ! Loop over matrix rows (adjust the number based on your model size)
           *DO, J, 1, 10  ! Loop over matrix columns (adjust based on your model)
               *GET, K_GLOBAL, STIF, I, J, STIFF  ! Get the stiffness matrix component K_ij
               
               *VWRITE, I, J, K_GLOBAL
               
               (F10.5, F10.5, F10.5)  ! Format for writing the data
           *ENDDO
       *ENDDO
       
      *CFCLOS   ! Close the output file after writing the matrix
       
      The error message that I get states that the element types 2-10 are not defined.  How do I define all 10 elements in my code?
       
      Best,
      Brandon
    • Ashish Khemka
      Forum Moderator

      Hello,

      I think MAT command is used to define element attributes. Please refer to following forum thread which should be helpful:

       

      How to Create a Stiffness Matrix in APDL

       

      Thanks and Regards,

      Ashish Khemka

       

Viewing 4 reply threads
  • You must be logged in to reply to this topic.