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