Implement mittag_leffler model - #244
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #244 +/- ##
==========================================
Coverage ? 98.10%
==========================================
Files ? 59
Lines ? 5901
Branches ? 1011
==========================================
Hits ? 5789
Misses ? 58
Partials ? 54
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
rozyczko
left a comment
There was a problem hiding this comment.
damping can silently become 0, producing NaN at x = 0 with no exception.
_evaluate_values computes
omega = np.abs(x_vals) / width
epsilon = damping / width
modulus_squared = omega**2 + epsilon**2
...
denominator = modulus_squared * (
(modulus_squared**alpha + 1) * modulus_squared ** (-alpha / 2) + 2 * np.cos(phase)
)
return scale * numerator / (np.pi * width * denominator)diffusion_coefficient's setter only rejects < 0, not == 0.
if float(diffusion_coefficient) < 0),
and its Parameter is constructed with min=0.0, so D = 0 is a possible value, accessible from the public API.
Q has no positivity check anywhere in the validation conditionals
Suggested fix: validate the effective epsilon/modulus_squared in _evaluate_values itself, or at least reject Q = 0 in _validate_and_convert_Q/DiffusionModelBase.Q and reject diffusion_coefficient == 0 in the setter.
|
Try running the attached script to see the issue |
|
Thanks, finally found a bit of time to fix it |
Disclaimer: The code was written by Claude and looked through by me. The description below was written by me.
This implements the diffusion model that was requested at the summer school, eqs. 41 and 42 in this paper
A factor pi is missing in the equation, which is fixed here. Eq. 42 is also a special case of$\tau_R=1$ , here we allow any value of $\tau_R$ .
It is implemented as a ModelComponent for the per-Q calculation and as a DiffusionModel since in the paper$\epsilon=DQ^2$ . It is modelled after the existing DeltaLorentz diffusion model, so the only new things are the equations - all the architecture is essentially copy/pasted. (I don't think it should be put into a shared base class when we have only two models that are similar).
The tests verify numerical correctness by comparing with the Laplace transform given earlier in the paper.
The notebook reproduces several of the figures of the paper, indicating that everything works as it should.