Note
Go to the end to download the full example code
Use APDLMath to Solve a Dense Matrix Linear System#
Use the APDLMath module to solve a Dense Matrix Linear System.
import time
import numpy.linalg as np
from ansys.mapdl.core import launch_mapdl
# Start MAPDL as a service and create an APDLMath object.
mapdl = launch_mapdl()
mm = mapdl.math
Allocate a Dense Matrix in the APDLMath workspace
Copy the matrices as numpy arrays before they are modified by factorization call
Solve using APDLMath
Solving a (1000 x 1000) dense linear system using MAPDL...
Elapsed time to solve the linear system using Mapdl: 0.017757177352905273 seconds
Norm of the MAPDL Solution
mm.norm(x)
1.0000000000000016
Solve the solution using numpy
Solving a (1000 x 1000) dense linear system using numpy...
Elapsed time to solve the linear system using numpy: 0.07700085639953613 seconds
Norm of the numpy Solution
0.9999999999999987
Stop mapdl#
mapdl.exit()
Total running time of the script: ( 0 minutes 0.357 seconds)