Repository navigation
Add Hall-Ross, circle jump and 3D Gaussian diffusion models - #279
Open
markbujehein wants to merge 11 commits into
Open
markbujehein wants to merge 11 commits into
markbujehein wants to merge 11 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clarify equations, parameters, and references across multiple classes.
- Introduced a new tutorial notebook for the equivalent sites on a circle model, detailing the mathematical framework and providing visualizations. - Added a tutorial for the 3D Gaussian model, explaining diffusion in a harmonic potential and including relevant plots. - Created a tutorial for jump sites with a log-normal distribution, extending the equivalent sites model to disordered environments with log-normal jump rates. - Updated mkdocs.yml to include links to the new tutorials. - Enhanced documentation in the equivalent sites circle model and jump sites log-normal distribution code to clarify model parameters and references.
Clarify diffusion model details more clearly and explicitly
Solves Ruff throwing 'useless-expression' during notebook-lint-check
Contributor
|
Label error. Requires at least 1 of: [bot] release, [scope] bug, [scope] documentation, [scope] enhancement, [scope] maintenance, [scope] significant. Found: |
markbujehein
marked this pull request as ready for review
October 26, 2026 13:38
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #279 +/- ##
===========================================
+ Coverage 98.23% 98.38% +0.14%
===========================================
Files 61 66 +5
Lines 6227 6803 +576
Branches 1039 1092 +53
===========================================
+ Hits 6117 6693 +576
Misses 57 57
Partials 53 53
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
markbujehein
marked this pull request as draft
October 26, 2026 13:51
Test that the circle, log-normal and 3D Gaussian models reject a non-float Q, and test the delta_name and delta_display_name setters of the base class. Rename the base-class test model from Toy to DummyDiffusionModel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markbujehein
marked this pull request as ready for review
October 26, 2026 14:26
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds four diffusion models, with tests and tutorials:
HallRossJumpDiffusion: jump diffusion with a Gaussian distribution of jump lengths.EquivalentSitesCircle: jumps between N equivalent sites on a circle.JumpSitesLogNormalDistribution: the circle model with a log-normal distribution of jump rates.GaussianModel3D: diffusion in an isotropic 3D harmonic well. The sum over Lorentzians is truncated, with a warning when more than 1e-3 of the weight is lost.Shared base class
The circle, log-normal and Gaussian models all describe the same kind of spectrum: an elastic line plus a set of Lorentzians at each Q. Only the physics differs, meaning how wide each Lorentzian is and how much intensity it carries. The work of turning that physics into fit components is the same every time, so it now lives in one place,
DeltaLorentzianDiffusionModelBase. It creates the delta function and the Lorentzians for each Q, gives them predictable names, links their areas and widths to the model parameters, and provides the fit targets (elastic_area,area_<j>,width_<j>). A fix or improvement to that machinery reaches all three models at once.Each model file keeps its own physics and its own parameters, including some code that is repeated between files, so that you can read one model from top to bottom without jumping between classes. The one repeated piece of physics is the circle weight formula, which appears in both circle models.
For future models, adding another "elastic line plus Lorentzians" model means writing only its physics: the widths, the EISF and the weight of each Lorentzian. The components, naming and fit targets come for free and behave the same as in the existing models. This makes sense because several models (Mantid, QENSlibrary) are are very identical and share what's now being defined in
DeltaLorentzianDiffusionModelBase.ABCMeta
The base class uses
metaclass=ABCMeta, the same pattern EasyScience Core'srelease-3.0uses for its own abstract classes (
JobBase,AnalysisBase). Without it, Python does notenforce
@abstractmethodhere, because the parent classes use the plaintypemetaclass.ABCMeta: a new model that definescalculate_EISFbut forgetscalculate_QISF_orderraises a
TypeErrornaming the missing method as soon as it is created.ModelComponenttoday: a component that forgets_evaluate_valuesiscreated without complaint and returns
Nonewhen evaluated.If Core 3.0 moves
ABCMetaonto its base classes, this declaration becomes redundant and keepsworking.
Related: