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

Expose volume calculation in SasModels (Trac #1171) #186

Open
sasview-bot opened this issue Mar 30, 2019 · 2 comments
Open

Expose volume calculation in SasModels (Trac #1171) #186

sasview-bot opened this issue Mar 30, 2019 · 2 comments

Comments

@sasview-bot
Copy link

sasview-bot commented Mar 30, 2019

McSAS relies on the ability to weigh the contributions based on their volume in its optimisation routine. This means that we need to be able to get a volume for a given contribution from SasModels.

At the moment, the kernel can be queried for the volume of the last-calculated iteration:

kernel.result[kernel.q_input.nq]

Paul Kienzle commented on this a while back:
"
For your case (without dispersion) the form_volume is already computed by the kernel and returned as the final element in the result. You should be able to grab it using kernel.result[kernel.q_input.nq] after calculating the kernel. This is a side-effect of the current implementation and not part of the formal interface; it will not work for pure python models, but should work for C models run as dll or as OpenCL.

[...]

If we were to make this a formal interface, we would need to generalize it to the case of dispersion-weighted volume average by additionally accumulating the sum of the weights in result[nq+1], then defining self.average_volume = result[nq]/result[nq+1]. Something similar could be done in the python kernel loop.
"

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

{
    "status": "new",
    "changetime": "2018-11-15T14:55:15",
    "_ts": "2018-11-15 14:55:15.504062+00:00",
    "description": "McSAS relies on the ability to weigh the contributions based on their volume in its optimisation routine. This means that we need to be able to get a volume for a given contribution from SasModels. \n\nAt the moment, the kernel can be queried for the volume of the last-calculated iteration: \n{{{\nkernel.result[kernel.q_input.nq]\n}}}\n\n\nPaul Kienzle commented on this a while back:\n\"\nFor your case (without dispersion) the form_volume is already computed by the kernel and returned as the final element in the result.  You should be able to grab it using kernel.result[kernel.q_input.nq] after calculating the kernel.  This is a side-effect of the current implementation and not part of the formal interface; it will not work for pure python models, but should work for C models run as dll or as OpenCL.\n\n[...]\n\nIf we were to make this a formal interface, we would need to generalize it to the case of dispersion-weighted volume average by additionally accumulating the sum of the weights in result[nq+1], then defining self.average_volume = result[nq]/result[nq+1].  Something similar could be done in the python kernel loop.\n\"\n\n",
    "reporter": "toqduj",
    "cc": "pkienzle",
    "resolution": "",
    "workpackage": "McSAS Integration Project",
    "time": "2018-09-08T13:21:25",
    "component": "sasmodels",
    "summary": "Expose volume calculation in SasModels",
    "priority": "major",
    "keywords": "sasmodels, mcsas",
    "milestone": "SasView 5.0.0",
    "owner": "pkienzle",
    "type": "enhancement"
}
@pkienzle
Copy link
Contributor

Trac update at 2018/11/15 14:55:15: pkienzle commented:

This is available in the beta_approx branch, [https://github.com//pull/90 PR SasView/sasview#318]

from sasmodels.direct_model import call_Fq

F, Fsq, Reff, V, Vratio = call_Fq(kernel, pars)

@pkienzle pkienzle modified the milestones: SasView 5.0.0, sasmodels 1.0 Mar 31, 2019
@pkienzle
Copy link
Contributor

Is the call_Fq() sufficient to close this ticket?

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

3 participants