Skip to content

Adding a pure python truncated octahedron model with Fibonacci orientation averaging #738

Merged
sara-mokhtari merged 5 commits into
masterfrom
adding_trOh_model_purePython2
Jun 3, 2026
Merged

Adding a pure python truncated octahedron model with Fibonacci orientation averaging #738
sara-mokhtari merged 5 commits into
masterfrom
adding_trOh_model_purePython2

Conversation

@pkienzle

@pkienzle pkienzle commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

Adding a pure python model for truncated octahedrons with orientation averaging using Fibonacci quadrature.

Fixes #686

Replaces #694

How Has This Been Tested?

Unit tests worked.
This model was compared with the model using C code (octahedron_truncated.c) and shows good agreement.
In general, the octahedron model was compared to an another numerical calculation : for truncated octahedrons with different sizes and truncatures, agreement was found with the Debye equation (Debye calculator: https://github.com/FrederikLizakJohansen/DebyeCalculator). The Debye equation is based on atomic positions while SasView model is based on analytical expressions.

More tests should be made on small q. Indeed, like the previous model (octahedron_truncated.c), we encouter issues when it comes to small q (q<10^-6 Angs). More precise mathematical should be used (hospital rule, etc).
Note : the fibonacci quadrature code (sasmodels/quadratures/fibonacci.py) was added to a new repository called "quadratures" because it could be also useful for other models.

Compare with gauss-legendre grid using:

python -m sasmodels.compare explore/models/truncated_octahedron_fibonacci.py,truncated_octahedron

Parameters set on the command line (e.g. radius_a=1000) will be shared between the two models.
Adjust the number of fibonacci points using npoints_fibonacci=n. Adjust the number of gaussian quadrature points using -ngauss=n (where n is zero for adaptive integration).

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)

using the Fibonacci quadrature. This quadrature provides a quasi-uniform distribution of points on the unit sphere
using the golden ratio. The only new parameter is the number of points to generate on the unit sphere.
The default value (around 400 points) provides a good balance between accuracy and computational efficiency.
It contains both the form factor for a reference orientation and the 1D form factor after orientation average (Gauss-Legendre).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since it's using the fibonacci quadrature, shouldn't we keep the fibonacci description in the documentation instead of Gauss-Legendre ?

states at the beginning that this is a pure python version using Fibonacci integration.

@marimperorclerc marimperorclerc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This version (pure python plus FIbonacci integration) is useful for comparision purposes with the truncated_octahedron model which is based on .c and .py with adaptive Gauss-Legendre integration.
Here (truncated_octahedron_fibonacci) all analytical expressions are coded in python (no .c file).

@sara-mokhtari sara-mokhtari merged commit 1f94047 into master Jun 3, 2026
26 checks passed
@sara-mokhtari sara-mokhtari deleted the adding_trOh_model_purePython2 branch June 3, 2026 13:49
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.

Pure Python truncated octahedron models

3 participants