Skip to content

Bilayer support - #292

Merged
rozyczko merged 30 commits into
developfrom
bilayer
Mar 5, 2026
Merged

rozyczko merged 30 commits into
developfrom
bilayer

Conversation

@rozyczko

Copy link
Copy Markdown
Member

As requested and described by @jfkcooper this is the library implementation of bilayers in EasyReflectometryLib.

Please scrutinize docs\tutorials\simulation\bilayer.ipynb for correctness and API.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['chore', 'fix', 'bugfix', 'bug', 'enhancement', 'feature', 'dependencies', 'documentation']

@rozyczko
rozyczko requested a review from jfkcooper January 31, 2026 14:02
@rozyczko rozyczko added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] high Should be prioritized soon labels Jan 31, 2026
@rozyczko rozyczko mentioned this pull request Jan 31, 2026
@codecov

codecov Bot commented Jan 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.72932% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.57%. Comparing base (860b30c) to head (2f925b7).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/easyreflectometry/sample/assemblies/bilayer.py 91.66% 0 Missing and 11 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #292      +/-   ##
===========================================
+ Coverage    87.21%   87.57%   +0.35%     
===========================================
  Files           45       46       +1     
  Lines         2651     2784     +133     
  Branches       319      338      +19     
===========================================
+ Hits          2312     2438     +126     
+ Misses         265      261       -4     
- Partials        74       85      +11     
Flag Coverage Δ
unittests 87.57% <91.72%> (+0.35%) ⬆️

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

Files with missing lines Coverage Δ
src/easyreflectometry/sample/__init__.py 100.00% <100.00%> (ø)
src/easyreflectometry/sample/assemblies/bilayer.py 91.66% <91.66%> (ø)

... and 2 files with indirect coverage changes

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

@jfkcooper jfkcooper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Basically only one comment on the code parts, and easily rectified. I will run the notebook now and give you feedback on this, but doing it in github is not fun for notebooks, so I submit these comments now

Comment thread tests/sample/assemblies/test_bilayer.py Resolved
Comment thread tests/sample/assemblies/test_bilayer.py Resolved
@jfkcooper

Copy link
Copy Markdown
Collaborator

Notes from the notebook:

  • Depending on what the aim for the notebook is, I would remove all of the cells doing checking an printing, as they would not be interesting to a user - it would be assumed that they just work.

  • The superphase for the complete sample should be silicon. The structure should be:
    Si | SiO2 | head | tail | tail | head | water it should look something like this:

image
  • For the tail groups, I believe you have the SLD for a deuterated version of the tails, but this is not the 'normal' configuration, and I think for an exemplar notebook it is better to use the hydrogenous version.

  • For the asymmetric hydration, it isn't clear where but there seems to be a bug or something, as you would expect a difference in the curves. I would highlight the change by showing the SLD curves rather than just the reflectivity though, as this is where you can know that it is being done correctly

@jfkcooper

Copy link
Copy Markdown
Collaborator

Thinking on it, I would also use this as a way to demonstrate mutliple contrasts for the lipid model, so using H2O as the solvent and subphase as well as D2O, and then showing the SLD curves, and the reflectivity curves (and the ability to set the constraints between the two models (or however you would put the models together).

The most common use case of the lipid bilayer would be for fitting mulitple contrast (water) data.

@rozyczko

rozyczko commented Feb 2, 2026

Copy link
Copy Markdown
Member Author

Addressed the code issues and modified the notebook to reflect Jos' comments.

@rozyczko
rozyczko requested a review from jfkcooper February 2, 2026 14:17
@jfkcooper

Copy link
Copy Markdown
Collaborator

Thanks for the changes, though I just noticed a couple more things:

  • In cell 3 you solvate the head and the tail with different solvents. These should strictly always be the same solvent
  • The inner and outer headgroups are hydrated differently - but it isn't clear how this happened, or how one would set them separately ('front_head_layer' and 'back_head_layer' are not mentioned before cell 7
  • Cell 8 has the same parameter being printed as cell 6, so, not really demonstrating that the roughness is conformal.
  • I think cell 13 has some bug as the two curves should be different, but aren't
  • Same bug with cell 14
  • cell 15 - the head and tails should be solvated with the same liquid. It is also a little confusing that the tails are now a different lipid (hydrogenous rather than deuterated tail group), I would keep it consistent throughout the notebook
  • The above point is especially important in cells 18 and 19, since the two curves are not presenting the same lipid system.

Let me know if you want a chat about any of these points, and thanks again for the progress!

@henrikjacobsenfys henrikjacobsenfys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some comments and questions

@rozyczko
rozyczko changed the base branch from append_sample to develop March 5, 2026 09:41
@rozyczko
rozyczko merged commit 4f1ffd0 into develop Mar 5, 2026
27 of 29 checks passed
@rozyczko
rozyczko deleted the bilayer branch March 5, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] high Should be prioritized soon [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants