Skip to content

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

@sasview-bot

Description

@sasview-bot

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"
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions