Don't calculate magnetic models in magnetism is not toggled. - #4072
Open
pkienzle wants to merge 1 commit into
Open
Don't calculate magnetic models in magnetism is not toggled.#4072pkienzle wants to merge 1 commit into
pkienzle wants to merge 1 commit into
Conversation
krzywon
approved these changes
Aug 5, 2026
krzywon
left a comment
Contributor
There was a problem hiding this comment.
Tested and fixes the issue. Code seems okay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Leaves the M0 values as their default (zero) when initializing the model.
Sets the magnetic parameters in the model to zero if magnetism is not active. This causes sasmodels to use Iqxy rather than Imagnetic to compute the 2D models.
This incidentally fixes the problem with a mixed magnetic and pure python model, which otherwise failed in sasmodels because the pure python model don't yet handle magnetism.
Fixes #4071
How Has This Been Tested?
Start sasview with a sphere model, toggle 2D and plot. Verify that there is no asymmetry.
Toggle magnetism and check that M0 are all zero.
Set sld_M0 to 10, set sld_mtheta to 90 and plot. Shows asymmetry.
Toggle magnetism and plot. Shows no asymmetry.
Toggle magnetism and plot. Shows asymmetry again from values stored in the magnetism widget.
Load 2d magnetic data set and send to fitting.
Toggle radius and scale fit.
Toggle magnetism, and toggle sld_M0 and sld_mphi fit.
Start the fit. Verify that radius, scale, sld_M0 and sld_mphi are being updated.
Stop the fit, toggle magnetism and plot. No asymmetry.
Save analysis as non magnetic.
Toggle magnetism and save analysis as magnetic.
Restart sasview and load nonmagnetic analysis. Plot shows no asymmetry.
Toggle magnetism and plot. Shows asymmetry.
Restart sasview and load magnetic analysis. Plot shows asymmetry.
Review Checklist:
[if using the editor, use
[x]in place of[ ]to check a box]Documentation (check at least one)
Installers
Licensing (untick if necessary)