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.
calc_energy_electric
(andcalc_energy_magnetic
) are called in many places in DistributedAnalysis and currently you are supposed to transfer the result of these as a parameter likeU_E
andU_H
to for exampleget_Qdielectric_all
andget_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.