Because sparse solvers like UmfPack and SparseGeneral are the fastest for analyzing large models in OpenSees, it is reasonable to assume that these solvers must also be the best for small models, even the smallest possible model–an SDF system.
But what if you’re doing millions of SDF analyses, e.g., generating nonlinear response spectra over a database of ground motions, running Monte Carlo simulations over a large parameter set, or training a machine learning algorithm? Will the choice of solver matter for your SDF model?
There’s only one way to find out.
Suppose we analyze a linear-elastic SDF model one million times and only change the solver. The loading is a step function–we don’t need to bother with anything more for this experiment.
import openseespy.opensees as ops # Using version 3.8.0.0
import time
N = 1000000 # Number of analysis steps
dt = 0.01 # Time step
solvers = ['Diagonal','ProfileSPD','BandSPD','FullGeneral',
'BandGeneral','SparseGeneral','UmfPack']
for solver in solvers:
ops.wipe()
ops.model('basic','-ndm',1,'-ndf',1)
ops.node(0,0); ops.fix(0,1)
ops.node(1,0); ops.mass(1,1)
ops.uniaxialMaterial('Elastic',1,100)
ops.element('zeroLength',1,0,1,'-mat',1,'-dir',1)
ops.timeSeries('Constant',1)
ops.pattern('Plain',1,1)
ops.load(1,1.0)
ops.system(solver)
ops.analysis('Transient','-noWarnings')
t0 = time.time()
ops.analyze(N,dt)
t = time.time() - t0
Sure, we could have used the Linear algorithm with the factorOnce option. But the point here is for each solver to go through the zero-assemble-factorize-backsolve process a million times on an SDF system, i.e., a 1×1 matrix.
| Solver | Time (sec) |
|---|---|
| Diagonal | 1.13 |
| ProfileSPD | 1.14 |
| BandSPD | 1.30 |
| FullGeneral | 1.30 |
| BandGeneral | 1.25 |
| SparseGeneral | 2.25 |
| UmfPack | 2.29 |
As expected, the Diagonal solver is the fastest with ProfileSPD basically the same. The BandSPD, BandGeneral, and FullGeneral solvers all take a little bit longer. Perhaps surprisingly, the SparseGeneral and UmfPack solvers take the most time.
For what it’s worth, this is one of the few times where the Diagonal solver is appropriate, and likely the only time the FullGeneral solver can hold its own against other solvers.
Ultimately, each solver can handle an SDF system in nanoseconds, so what we’re really measuring here is solver overhead, not solver speed. In each analysis, the banded and sparse solvers spend a fraction of a nanosecond assessing bandwidth or sparsity of a 1×1 matrix.
And those fractions of a nanosecond add up. But, for anything more than an SDF system, the matrix factorization will dominate and banded and sparse solvers will win every time.
