Ansys Learning Forum › Forums › Discuss Simulation › General Mechanical › Stiffness matrix commands for student version › Reply To: Stiffness matrix commands for student version
November 9, 2024 at 8:52 am
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