Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let the user set effective radius in P(Q)*S(Q) (Trac #780) #261

Closed
pkienzle opened this issue Mar 30, 2019 · 10 comments
Closed

let the user set effective radius in P(Q)*S(Q) (Trac #780) #261

pkienzle opened this issue Mar 30, 2019 · 10 comments

Comments

@pkienzle
Copy link
Contributor

sasmodels.product defines P(Q)*S(Q) using the effective radius from P(Q) as the radius_effective parameter in S(Q). This is not always correct, and should be under control of the user. Similarly for volfraction and VR.

Instead of hard-coding this relationship, make ER and VR available as derived parameters from the model. These parameters will only be computed if their value is requested. Models could potentially allow other derived parameters.

Use sasmodels.mixture to multiply the models. Make sure that it supports arbitrary model expressions, not just A+B.

May want to allow model constraints to be set in the model value field. When the radius_effective field is edited, the user will see =A_ER, indicating the that the ER() derived parameter from model A should be evaluated. This will save bouncing to a constraints page to indicate a simple constraint.

Migrated from http://trac.sasview.org/ticket/780

{
    "status": "new",
    "changetime": "2018-09-09T07:54:28",
    "_ts": "2018-09-09 07:54:28.363325+00:00",
    "description": "`sasmodels.product` defines `P(Q)*S(Q)` using the effective radius from `P(Q)` as the `radius_effective` parameter in `S(Q)`.  This is not always correct, and should be under control of the user.  Similarly for `volfraction` and `VR`.\n\nInstead of hard-coding this relationship, make `ER` and `VR` available as derived parameters from the model.  These parameters will only be computed if their value is requested.  Models could potentially allow other derived parameters.\n\nUse `sasmodels.mixture` to multiply the models.  Make sure that it supports arbitrary model expressions, not just A+B.\n\nMay want to allow model constraints to be set in the model value field.  When the radius_effective field is edited, the user will see `=A_ER`, indicating the that the ER() derived parameter from model A should be evaluated.  This will save bouncing to a constraints page to indicate a simple constraint.",
    "reporter": "pkienzle",
    "cc": "",
    "resolution": "",
    "workpackage": "Beta Approximation Project",
    "time": "2016-10-13T05:00:59",
    "component": "SasView",
    "summary": "let the user set effective radius in P(Q)*S(Q)",
    "priority": "major",
    "keywords": "",
    "milestone": "SasView Next Release +1",
    "owner": "",
    "type": "enhancement"
}
@butlerpd
Copy link
Member

Trac update at 2017/10/27 12:20:57: butler changed milestone from "SasView Next Release +1" to "SasView 4.3.0"

@RichardHeenan
Copy link
Contributor

Trac update at 2018/06/28 16:39:19: richardh commented:

The new qt gui has "+ symbols" on left of parameter table to expand details on polydispere radius etc, could we use the same mechanism to show constraints such as those for E_R and V_R ?

More generally are there any ideas yet for how to handle constraints in the qt gui?

@butlerpd
Copy link
Member

Trac update at 2018/06/30 18:25:22: butler changed workpackage from "SasView Bug Fixing" to "Beta Approximation Project"

@RichardHeenan
Copy link
Contributor

Trac update at 2018/07/01 19:58:53: richardh changed milestone from "SasView 4.3.0" to "SasView Next Release +1"

@RichardHeenan
Copy link
Contributor

Trac update at 2018/07/03 11:53:40: richardh commented:

Would be good for someone to explore how sasmodels.mixture etc currently add and multiply models and what happens to the flat backgrounds. In particular note that an S(Q) should never multiply a flat background.

Sometimes when we write P(Q) we mean including scale, contrast and background thus

P(Q)=scale.(delrho)^2^.<F^2^(Q)>+bkg

where, if sld difference is correct and the model is correct for the system we have

scale=phi=NV=volume_fraction

where there are N particles of volume V per unit volume of sample,

What we really need in sasview is P(Q)=scale.phi.(delrho)^2^.V.<F^2^(Q)>+bkg

where some factors of V have been shuffled around depending upon the exact definition of F(Q). Check carefully what sasview models return before adding a new calculation of <F(Q)>.

"scale" should be 1.0 if everything else is correct and I(Q) and delrho in the correct units.

bkg has to be removed or forced to zero if in danger of being multiplied by S(Q).

phi is the volume fraction parameter to be used by default along with the effective radius ER in S(Q) such that:

I(Q) = P(Q,scale,phi,ER).S(Q,phi,ER) + bkg

where it is emphasised here that "scale" should ideally be included separately in P(Q) in order to sort problems with the units of I(Q). More pragmatically, if scale is not 1.0, and our model only has a single scale and/or phi parameter, then we must let phi be set in S(Q) and not constrained to something from P(Q, thus:

I(Q) = P(Q,scale,ER).S(Q,phi,ER) + bkg

Then if the user knows what the unit fudge factor in scale is, they might want a constraint in S(Q) such that phi = constant.scale

This all requires a little thought and some testing, but the existing code is likely almost OK.

@RichardHeenan
Copy link
Contributor

Trac update at 2018/09/08 13:28:23: richardh commented:

For standard P(Q)S(Q) choices sasview 5.0 will have a menu drop down to choose the effective_radius for S(Q) for relevant P(Q) models.

effective_radius can be freely adjusting (or fixed) or constrained to either a mean curvature value or radius of sphere with same volume (as forced by sasview4) or now constrained to other P(Q) model dependent choices such as a minimum or maximum radius of the particle.

In the sasmodels beta_approx_new_R_eff branch a large number of models have had the new options included , these are currently (8 Sept 2018) being tested.

Sasview 4 calculations of ER have now been moved to .c files, the .py file for the model now contains only an index of ER types e.g. for core_shell_cylinder we have:

effective_radius_type = ["equivalent sphere","outer radius","half outer length","half min outer dimension",
                         "half max outer dimension","half outer diagonal"]

The type strings should be self explanatory.

We need to check what happens (and what is wanted) regarding polydispersity (in principle ER could perhaps be averaged over polydispersity?).

@butlerpd
Copy link
Member

Trac update at 2018/09/09 07:16:45: butler changed _comment0 from "The SasView 5.0 functionality to support beta_approx_new_R_eff is covered by JIRA issue 1052, and the feature branch is ESS_GUI_iss1052." to "1536479668363325"

@sasview-bot
Copy link

Trac update at 2018/09/09 07:16:45: tcbennun commented:

The !SasView 5.0 functionality to support beta_approx_new_R_eff is covered by JIRA issue 1052, and the feature branch is ESS_GUI_iss1052.

@pkienzle
Copy link
Contributor Author

The underlying requirement that the user have some control of the effective radius used in the model has been met. With radius_effective_mode users can either make it freely varying, or can constrain it to one of a variety of estimates defined as part of the model.

If this is sufficient, then close the ticket. If not, then reframe it to be explicitly about making the computed effective radius available to the constraints system. Given the difficulty in implementing this, and how rarely(?) it will be needed, it will be enough to tell users to copy and edit the underlying model if they need to do complicated stuff with R_eff.

@ricleal ricleal transferred this issue from SasView/sasview Apr 23, 2019
@RichardHeenan
Copy link
Contributor

Closing this ticket, as the original aim was acheived and further issues are addressed ielsewhere.

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

No branches or pull requests

4 participants