pkienzle / periodictable

Extensible periodic table for python
http://periodictable.readthedocs.org
Other
147 stars 37 forks source link

Computed decay time is incorrect #51

Open pkienzle opened 2 years ago

pkienzle commented 2 years ago

See https://github.com/scattering/activation/issues/17

pkienzle commented 1 year ago

Derivative used in https://github.com/pkienzle/periodictable/commit/e4f8ea130e6ca72f2969f8ceb7fe6673f6e867ac appears to be incorrect:

f = lambda t: sum(Ia*exp(-La*(t-To)) for Ia, La in data) - target
df = lambda t: sum(La*Ia*(To-1)*exp(-La*(t-To)) for Ia, La in data)

It is okay when To = 0, which is probably why it seems to work. This function needs a fuller review.


[correction] It is okay when t=1 since the derivative with respect to t should be:

df = lambda t: sum(-La*Ia*exp(-La*(t-To)) for Ia, La in data)

This is only used in the root-finding code. It appears to be finding the correct value despite the incorrect derivative otherwise it would be throwing a runtime error. Using the correct code should make it converge faster.

pkienzle commented 8 months ago

Even with the corrected df/dt the resulting time does not have total activation matching the target value. Need to verify that formulas for decay time and activation are consistent.

pkienzle commented 1 day ago

After further investigation, the step sizes in the fit are too tiny because the exponential. I will instead adjust the intensities to the time at the guess and fit relative to that. Then the fit ends in a few short Newton steps.