Skip to content

Conversation

@hoogerheide
Copy link
Collaborator

Sometimes reflectivity data have features that look like they might come from small angle scattering. Usually this means the sample needs to be re-made, but there are cases where this might actually be useful data, and other cases where the sources of the small angle scattering can otherwise not be removed.

This PR is for an Experiment-like object that combines SANS and reflectivity data into a single curve, and exposes the parameters of the sasmodels SANS model as Bumps parameters. The model specification includes the SANS model name, a dictionary of parameter values, and a transverse angular resolution dtheta_l which is used to smear the SANS data.

A custom decomposition plot into I(q) and R(q) is registered as well.

@hoogerheide
Copy link
Collaborator Author

This is an example script. You can put it any dummy data for this to work.

test_sas_script.py

@hoogerheide
Copy link
Collaborator Author

This is an example script. You can put it any dummy data for this to work.

test_sas_script.py

Now look at the tiox_dopc_sas.py example in the repo

@hoogerheide
Copy link
Collaborator Author

One note on this -- the calculation is quite slow. Loading the model takes about 0.3 seconds; the DirectModel instantiation takes about 0.03 seconds, and the calculation itself is quite fast. I'm not sure why it's slow given this; is FitProblem re-created on each calculation node every time a new data point is sent?

@bmaranville
Copy link
Member

bmaranville commented Feb 3, 2026

All the mappers in bumps are designed to create workers that are set up only once per fit.
The problem is deserialized on each worker at the start of the fit, then the mapper feeds parameter vectors to the workers, which call problem.nllf(pvec) for each set of parameters.

…d setstate to support problem copying and pickling
Copy link
Member

@bmaranville bmaranville left a comment

Choose a reason for hiding this comment

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

This looks good - when we refactor the plot registry you'll have to change the register_webview_plot bit, but that's going to be a small change on this end (a bigger change on the bumps end)

@hoogerheide
Copy link
Collaborator Author

Just improved the abstraction to allow both standard SAS models as well as full integration (spherical geometry only because this is the only multi-shell model supported by sasmodels at the moment) with MolgroupsLayer objects. This allows one to calculate the small angle scattering directly from molgroups layers. Also registers the molgroups plots.

After this PR is merged I will work on a direct SAS calculator a la sasmodels.bumps_model that supports serialization and molgroups functionality.

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.

3 participants