Skip to content

Core shell bifrustum prism clean - #792

Open
sara-mokhtari wants to merge 13 commits into
py-Iqabcfrom
core_shell_bifrustum_prism_clean
Open

sara-mokhtari wants to merge 13 commits into
py-Iqabcfrom
core_shell_bifrustum_prism_clean

Conversation

@sara-mokhtari

@sara-mokhtari sara-mokhtari commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #775
This model describes a core-shell particle with a bifrustum core and a prism shell. Both shapes are defined with their symmetry axis along the z-axis and centered at the origin. The bifrustum core can be rotated around the z-axis by an angle alpha (core_rotation) and translated along the z-axis by a distance z_0 (core_translation) with respect to the prism shell.

cs5sides

Depends on #781 (support for pure Python 2D models): this PR is based on py-Iqabc and targets it,
so the diff only shows the bifrustum. Once #781 is merged, I will retarget this PR to master
and merge master into this branch.

  • F(q) amplitude is given by the sum of the prism and bifrustum form factors,
    weighted by their respective scattering length densities (sld_shell, sld_core)
    and the solvent scattering length density (sld_solvent).
  • 1D: orientation average with a Fibonacci quadrature (500 points)
  • 2D: Fqabc/Iqabc with theta, phi, psi

Note for review: the model structure is inspired from mixture.py, with parameters having a prefix "core_" or "shell_" (ex: core_radius, shell_radius). The idea is to start generalizing the model. Also, prism.py was updated to be able to call directly Fqabc without flattening qa, qb, qc beforehand (important if we want to make a general core-shell model at the end).

How Has This Been Tested?

  • model_test passes
  • F(q) checked against an independent method (Debye equation with Debye calculator: https://github.com/FrederikLizakJohansen/DebyeCalculator) for different number of sides of the prism. The Debye equation is based on atomic positions while SasView model is based on analytical expressions. Not tested on experimental data yet.
core_shell_pynano core_shell_bifrustum_prism_debye

Review Checklist:

[if using the editor, use [x] in place of [ ] to check a box]

Documentation (check at least one)

  • There is nothing that needs documenting
  • Documentation changes are in this PR
  • There is an issue open for the documentation (link?)

Installers

  • There is a chance this will affect the installers, if so
    • Windows installer (GH artifact) has been tested (installed and worked)
    • MacOSX installer (GH artifact) has been tested (installed and worked)
    • Wheels installer (GH artifact) has been tested (installed and worked)

Licensing (untick if necessary)

  • The introduced changes comply with SasView license (BSD 3-Clause)

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

Note that the a axis of a prism is crossing a vertice of the polygon in the (a,b) plane.
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@sara-mokhtari

Copy link
Copy Markdown
Contributor Author

2D orientation question:

  • In the other models (ex: tetrahedron): _Iqabc uses Fqabc(qa,qb,qc, *args) without the sld and the scale factor and Iqabc is the one that uses the sld and the scale factor.

  • In the core-model, the sld are directly taken into account in the computation of Fqabc(qa, qb, qc, sld_core, sld_shell, sld_solvent, *args). So in this case, _Iqabc uses the sld. Here is how I defined the two functions:

def _Iqabc(qa, qb, qc, sld_core, sld_shell, sld_solvent, *args):
    A = Fqabc(qa, qb, qc, sld_core, sld_shell, sld_solvent, *args)  # shape (nq, npoints)
    intensity = (np.abs(A))**2  # (1e-6/Ang^2)**2 = 1e-12/Ang^4
    return intensity
def Iqabc(qa, qb, qc, sld_core, sld_shell, sld_solvent, *args):
    intensity = _Iqabc(qa, qb, qc, sld_core, sld_shell, sld_solvent, *args)
    return intensity * 10**-4

Since I do not really understand how the functions must be defined for 2D orientations (how the API works), I think this part should be carefully reviewed.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@pkienzle
pkienzle added this pull request to stack #801 November 10, 2026 15:04

@codescene-access codescene-access 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.

No quality gates enabled for this code.

See analysis details in CodeScene

Quality Gate Profile: Custom Configuration
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants