Skip to content

Jump diffusion model#95

Merged
henrikjacobsenfys merged 12 commits intodevelopfrom
jump-diffusion-model
Feb 5, 2026
Merged

Jump diffusion model#95
henrikjacobsenfys merged 12 commits intodevelopfrom
jump-diffusion-model

Conversation

@henrikjacobsenfys
Copy link
Member

@henrikjacobsenfys henrikjacobsenfys commented Feb 4, 2026

Add Jump Diffusion and remove some unit options that were bugged in the Brownian diffusion. Also had Claude AI fix the weakref bug that had been driving me crazy. It's a temporary solution, but anything is better than getting these random errors that are not related to the code I've written.

Closes #78
closes #66 as irrelevant

@henrikjacobsenfys henrikjacobsenfys added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] medium Normal/default priority labels Feb 4, 2026
@henrikjacobsenfys henrikjacobsenfys marked this pull request as ready for review February 4, 2026 21:49
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@568a59a). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop      #95   +/-   ##
==========================================
  Coverage           ?   97.75%           
==========================================
  Files              ?       31           
  Lines              ?     1689           
  Branches           ?      274           
==========================================
  Hits               ?     1651           
  Misses             ?       21           
  Partials           ?       17           
Flag Coverage Δ
integration 0.00% <0.00%> (?)
unittests 97.75% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good code. Only typos and minor issues found.

@@ -1,17 +1,11 @@
# SPDX-FileCopyrightText: 2025-2026 EasyDynamics contributors <https://github.com/easyscience>
# SPDX-License-Identifier: BSD-3-Clause

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason you deleted the license header?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy/paste from old code going wrong

def create_component_collections(
self,
Q: Q_type,
component_display_name: str = 'Brownian translational diffusion',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably say "Jump translational diffusion"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above haha

Comment on lines 213 to 225
"""Create ComponentCollection components for the Brownian.

translational diffusion model at given Q values. Args:
---------- Q : Number, list, or np.ndarray
Scattering vector values.
component_display_name : str
Name of the Brownian Diffusion Lorentzian component.
Returns
-------
List[ComponentCollection]
List of ComponentCollections with Brownian Diffusion
Lorentzian components.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here s/Brownian/translational/g

Comment on lines 154 to 155
unit_conversion_factor_nominator = (
self._hbar * self.diffusion_coefficient / (self._angstrom**2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nominator -> did you mean numerator?

angstrom = DescriptorNumber('angstrom', 1e-10, unit='m')


class TestJumpTranslationalDiffusion:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing tests for test_scale_setter and test_scale_setter_raises (since they are in the Brownian tests)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the scal setter and getter to diffusion_base, now the tests are also there

except Exception as e:
raise UnitError(
f'Invalid unit: {unit}. Unit must be a string or scipp Unit and convertible to meV.' # noqa: E501
f'Invalid unit: {unit}. Unit must be a string or scipp Unitand convertible to meV.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Unitand -> Unit and

raise TypeError('Q must be a float.')

# Q is given as a float, so we need to add the units
return f'hbar * D* {Q} **2*1/(angstrom**2)/(1 + (D * t* {Q} **2/(angstrom**2)))'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the extra 1 in the expression?
Just {Q}**2 / (angstrom**2) should be fine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I had problems with it related to the bug with order of operations when dividing parameters

Copy link

@seventil seventil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just nitpicks

@@ -62,65 +57,35 @@ def __init__(
Defaults to "meV".
scale : float or Parameter, optional
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here, scale is numeric

# ------------------------------------------------------------------
# dunder methods
# ------------------------------------------------------------------

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for diffusion_coefficient and all other repr I've made so far... I'll streamline them once I know what I want, which is after the Job class :) but it's a good point!

# ------------------------------------------------------------------
# dunder methods
# ------------------------------------------------------------------

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for diffusion_coefficient and all other repr I've made so far... I'll streamline them once I know what I want, which is after the Job class :) but it's a good point!

@henrikjacobsenfys henrikjacobsenfys merged commit 88af3d9 into develop Feb 5, 2026
34 checks passed
henrikjacobsenfys added a commit that referenced this pull request Feb 6, 2026
* jump diffusion model

* fix notebook

* fix weakref?

* fix weakref?

* fix weakref???

* ...

* weakref...

* claude fixed it?

* respond to PR comments

* Move scale test to base model and add some formatting

* fix typo

* small fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] medium Normal/default priority [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants