In addition to its powerful parametric capabilities, APDL actually has another capability that is easily overlooked: its powerful matrix operation capability. This is outstanding among commercial finite element software. Meanwhile, using matrix objects, users can also access and modify ANSYS internal data files, such as mass matrices, stiffness matrices, result files, etc. This is essential for users who want to do advanced secondary development. This article organizes common matrix operation functions for easy reference and citation.
Note that the matrices here are different from the arrays and variables we commonly encounter. They are different objects. That is, if a user needs to access a matrix, the matrix needs to be converted to an array object. Similarly, if a user needs to perform matrix operations on data, it needs to be converted to a matrix object beforehand.
The simplest distinction: the arrays everyone is familiar with cannot perform operations between each other after definition, but matrix objects can perform operations such as multiplication and addition.
Example:
Now take a matrix operation A*X=B as an example. Given A and X, find matrix B, and use MATLAB for verification.
1. First define a 5*10 matrix A and a vector X of dimension 10
finish
clear
/prep7
*DMAT,A,d,Alloc,5,10
*VEC,X,d,Alloc,10
*Do,i,1,5
*DO,j,1,10
A(i,j)=i+j*2
X(j)=j
*enddo
*enddo
2. Use *MULT for matrix operation
*MULT,A,,X,,B
3. View results
!First convert matrix object to array object
*export,B,APDL,B_array
Click ANSYS menu bar Parameters -> Array Parameters. Find B_array.

4. MATLAB verification, code as follows:
clear
clc
A=zeros(5,10);
X=zeros(10,1);
for i=1:5
for j=1:10
A(i,j)=i+j*2;
X(j)=j;
end
end
B=A*X;

Through the above operations, users can easily perform matrix operations in APDL without relying on external third-party software, increasing operational efficiency.
Below is a list of common APDL matrix operation functions for easy index query based on the help documentation. Different versions may have minor differences, and functions are still being refined. This article uses the 2024 version as an example.
I. Matrix Definition Related
1. *DMAT: Create dense matrix
2. *SMAT: Create sparse matrix
3. *VEC: Create vector
4. *FREE: Delete all matrices, free memory
II. Matrix Operation Commands
1. *AXPY: Matrix addition/subtraction, M2=v*M1 + w*M2
2. *COMP: Matrix compression
3. *DOT: Vector dot product
5. *FFT: Fourier transform
6. *HPROD: Hadamard vector product
7. *INIT: Matrix/vector initialization
8. *INQUIRE: Retrieve existing matrix attributes
8. *KRON: Compute Kronecker product of two matrices/vectors
9. *MERGE: Merge matrices or vectors
10. *MULT: Matrix product, M3 = M1(T1)*M2(T2).
11. *NRM: Compute norm of matrix or vector
12. *REMOVE: Matrix trimming
13. *RENAME: Matrix renaming
14. *SCAL: Matrix scaling
15. *SORT: Matrix element sorting
16. *XPL: Read APDL internal files
III. Solver Commands
1. *EIGEN: Modal solution
2. *ITENGINE: Iterative solver
3. *LSBAC: Solve
4. *LSENGINE: Create linear solver
5. *LSFACTOR: Matrix factorization
IV. Matrix Output
1. *PRINT: Matrix print output
2. *EXPORT: Export matrix data
If you find this useful, feel free to repost and share!








No comments yet