You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should we consider Anaklasis as another profile calculator?
#431
anaklasis as a third EasyReflectometry calculator backend
Question: Would it be useful to add anaklasis as a calculator backend in EasyReflectometry, alongside refnx and refl1d? Does it provide anything extra?
Recommendation: No. As a reflectivity kernel anaklasis adds nothing that refnx and refl1d do not already provide, and it brings real packaging and licence costs. Its genuinely novel parts live in the fitting layer, which EasyReflectometry would not use because it has its own parameter, constraint and fitting stack through easyscience.
Evaluation date: 2026-10-09.
1. What anaklasis is
Open-source Python 3 package with Fortran 90 extensions for specular neutron and X-ray reflectometry.
Author: Alexandros Koutsioubas (Koutsioumpas), Jülich Centre for Neutron Science.
Published in J. Appl. Cryst.54, 1857–1866 (2021), DOI 10.1107/S1600576721009262.
Three public functions in the ref module: ref.calculate, ref.compare, ref.fit.
Models are defined as nested Python lists: a system is a list of patches (models) with coverage fractions; each model is a list of layers [Re SLD, Im SLD, thickness, roughness, solvent fraction, name].
2. The reflectivity kernel compared with refnx and refl1d
Aspect
anaklasis
refnx / refl1d
Algorithm
Abelès matrix method
Abelès / Parratt, equivalent physics
Roughness
Névot–Croce damping factor
Névot–Croce, plus micro-slicing of arbitrary profiles
Absorption
Complex SLD supported
Supported
Solvent / hydration
Per-layer volume-fraction blending
Supported (refnx Slab.vfsolv, refl1d mixtures)
Resolution
Fixed 17-point midpoint rule over roughly ±3.3σ; constant dQ/Q or pointwise from 4th column
Gaussian smearing with configurable quadrature; constant or pointwise
Vectorisation
None, loops per Q point in Fortran
Vectorised C / Numba kernels
Fallback engines
Numba (30–40 % slower), pure Python (20–30x slower)
n/a
Magnetism
None in the kernel. Non-spin-flip PNR is emulated by giving each spin curve a different SLD via a per-curve parameter. Spin-flip unsupported; paper points users to GenX
refl1d: full four-channel polarised calculation, already exposed through WrapperBase.calculate_polarized
Mixed-area models
Incoherent coverage-weighted sum of patches
refnx MixedReflectModel; refl1d can do the same; trivially done at the EasyReflectometry model level
Conclusion: at the kernel level anaklasis is a strict subset of what the current backends offer, and it would most likely be slower.
3. What is actually new in anaklasis
These features:
Layer parameters as SymPy expressions in global parameters, per-curve multi-parameters and the layer index n.
Inequality constraints written as strings, e.g. '2*p1/p0>1'.
Co-refinement of several curves with shared global parameters and per-curve multi-parameters.
Uncertainty estimation by three routes: numdifftools Hessian diagonal, bootstrap (1000 refits), emcee MCMC.
Global optimisation by SciPy differential evolution with polish=True.
List-based model definition aimed at non-programmers.
EasyReflectometry already provides parameters, constraints and fitting through easyscience. Wrapping anaklasis would mean wrapping only the Fortran routine, which duplicates what refnx and refl1d already give.
4. Practical blockers
Licence: GPL-3.0. Adding it as an optional dependency of a BSD-licensed library is at best awkward.
Build: requires gfortran. Only Windows wheel is for Python 3.9. The PyPI page could not be fetched during this evaluation. The CI matrix would inherit the Fortran packaging burden.
Maintenance: single maintainer, 3 stars, 2 forks, 1 open issue. Substantive commits in September 2025, then a single "Add files via upload" on 2026-09-10.
Validation: an ORSO validation check plus regression against the package's own 1.5.2 output.
API shape: the public functions read data files and write plots and folders. A backend would have to call internal Reflectivity() helpers rather than a clean function API.
Latent correctness issues observed in the Fortran:
The reflection coefficient r is declared COMPLEX*8 (single precision) while the rest of the code is double precision.
The hydration flags handle only two of the fronting/backing combinations. When both media are flagged as solvent, the relevant indices are never set, leaving the result undefined. The same gap exists in f_RealRef, f_profilecalc and f_solventcalc.
5. Ideas worth borrowing (implement on our side, do not link anaklasis)
Expression-valued layer parameters that reference other parameters or the layer index.
Bootstrap error estimation as an alternative to MCMC.
Coverage-weighted mixed-area ("patch") models, if not already available at the EasyReflectometry model level.
Whether these are real gaps depends on what easyscience already exposes.
6. Decision
Do not add anaklasis as a calculator backend. Keep refnx and refl1d. Treat anaklasis only as a reference for fitting-layer features.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
anaklasis as a third EasyReflectometry calculator backend
Question: Would it be useful to add anaklasis as a calculator backend in EasyReflectometry, alongside refnx and refl1d? Does it provide anything extra?
Recommendation: No. As a reflectivity kernel anaklasis adds nothing that refnx and refl1d do not already provide, and it brings real packaging and licence costs. Its genuinely novel parts live in the fitting layer, which EasyReflectometry would not use because it has its own parameter, constraint and fitting stack through easyscience.
Evaluation date: 2026-10-09.
1. What anaklasis is
refmodule:ref.calculate,ref.compare,ref.fit.[Re SLD, Im SLD, thickness, roughness, solvent fraction, name].anaklasis/fortran_ref_functions.f90(~10 KB). Everything else:anaklasis/ref.py(~232 KB monolith).2. The reflectivity kernel compared with refnx and refl1d
Slab.vfsolv, refl1d mixtures)WrapperBase.calculate_polarizedMixedReflectModel; refl1d can do the same; trivially done at the EasyReflectometry model levelConclusion: at the kernel level anaklasis is a strict subset of what the current backends offer, and it would most likely be slower.
3. What is actually new in anaklasis
These features:
n.'2*p1/p0>1'.polish=True.EasyReflectometry already provides parameters, constraints and fitting through easyscience. Wrapping anaklasis would mean wrapping only the Fortran routine, which duplicates what refnx and refl1d already give.
4. Practical blockers
Reflectivity()helpers rather than a clean function API.ris declaredCOMPLEX*8(single precision) while the rest of the code is double precision.f_RealRef,f_profilecalcandf_solventcalc.5. Ideas worth borrowing (implement on our side, do not link anaklasis)
Whether these are real gaps depends on what easyscience already exposes.
6. Decision
Do not add anaklasis as a calculator backend. Keep refnx and refl1d. Treat anaklasis only as a reference for fitting-layer features.
Sources
wrapper_base.pyAll reactions