pyEPR
pyEPR copied to clipboard
Cache calls to `calc_energy_electric` and `calc_energy_magnetic`
calc_energy_electric
(and calc_energy_magnetic
) are called in many places in DistributedAnalysis and currently you are supposed to transfer the result of these as a parameter like U_E
and U_H
to for example get_Qdielectric_all
and get_Qseam_sweep
.
It would make sense to instead just cache the values, as the inputs consist of simple strings, bools and ints. A simple lru_cache
from the standard library almost works. I think this would fail only if the Ansys simulation is changed in a way that does not invalidate the simulation solution but would change the values of the computed fields. This might be a rare case, but still unwanted behaviour.
If someone knows of a way to hash current state of Ansys or somehow check if the simulations were edited, this should be easy.