PlasmaPy / PlasmaPy-NEI

Non-equilibrium ionization modeling of plasma with Python
Other
7 stars 6 forks source link

Speed up calculation of adaptive time step #38

Open namurphy opened 4 years ago

namurphy commented 4 years ago

The adaptive time step calculation is, much to my surprise, slowing things down. The intention of this calculation was to find the time step that corresponds to the temperature changing to the next value in the lookup table. To do so, it uses the temperature evolution in a function and then uses a root finder from SciPy. Unexpectedly, the root finder is taking as much if not more time than the actual time advance. We'll need to optimize this calculation. In the cases of T_e being inputted as an array, we should be able to do that calculation with algebra instead of calling a root finder.

In the meantime, things run faster if you specify dt when creating an NEI object and set adapt_dt to False.