Note
Click here 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.06417131423950195 seconds
Norm of the MAPDL Solution
mm.norm(x)
1.000000000000001
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.03297615051269531 seconds
Norm of the numpy Solution
0.9999999999999996
stop mapdl
mapdl.exit()
Total running time of the script: ( 0 minutes 0.397 seconds)