mdolab / pygeo

pyGeo provides geometric design variables and constraints suitable for gradient-based optimization.
https://mdolab-pygeo.readthedocs-hosted.com/en/latest/?badge=latest
Apache License 2.0
124 stars 55 forks source link

Sparse Jacobians for DVGeometryMulti #187

Closed sseraj closed 1 year ago

sseraj commented 1 year ago

Purpose

I changed the total Jacobian computation in DVGeometryMulti to use sparse matrices instead of dense matrices. I followed one of SciPy's recommended approaches by using lil_matrix for construction and then converting to csr_matrix for faster arithmetic. This approach required minimal changes to the code.

The memory usage was not dramatically different for the cases I tested because the Jacobian is usually not very sparse. Still, the memory used by the sparse Jacobian was about 60% of the memory used by the dense Jacobian for the largest case I tested (around 140k surface points and 270 geometric DVs).

Expected time until merged

1 week

Type of change

Testing

The current DVGeometryMulti test passes, which shows that the derivatives are still correct.

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #187 (49d6108) into main (b7f1bfb) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #187   +/-   ##
=======================================
  Coverage   64.76%   64.77%           
=======================================
  Files          47       47           
  Lines       11949    11951    +2     
=======================================
+ Hits         7739     7741    +2     
  Misses       4210     4210           
Impacted Files Coverage Δ
pygeo/parameterization/DVGeoMulti.py 91.05% <100.00%> (+0.01%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more