PlasmaControl / DESC

Stellarator Equilibrium and Optimization Suite
MIT License
95 stars 26 forks source link

Slow plot_qs_error possibly due to ptolemy transform with default M_booz, N_booz #414

Closed dpanici closed 1 year ago

dpanici commented 1 year ago

Plot_qs_error on a L=M=9, N=10 equilibrium is taking quite a while to run when the fB=True flag is given, and it seems a lot of this time is being spent in the ptolemy transform part of the function. Could be worth taking a look at the ptolemy_linear_transform function to see if it can be optimized

dpanici commented 1 year ago
eq = get("WISTELL-A")
%prun plot_qs_error(eq, helicity=(1, -eq.NFP), M_booz=eq.M, N_booz=eq.N, log=True, return_data=True)

running this in jupyter notebook shows that it takes 100s, but 70s of that is spent inside of ptolemy_linear_transform:

64965095 function calls (64750499 primitive calls) in 100.505 seconds
ncalls  tottime  percall  cumtime  percall filename:lineno(function)
6480   38.027    0.006   69.518    0.011 vmec_utils.py:10(ptolemy_identity_fwd)
...
20    0.062    0.003   70.028     3.501 vmec_utils.py:160(ptolemy_linear_transform)