Opened 22 months ago

Last modified 20 months ago

## #1171 new enhancement

# Expose volume calculation in SasModels

Reported by: | toqduj | Owned by: | pkienzle |
---|---|---|---|

Priority: | major | Milestone: | SasView 5.0.0 |

Component: | sasmodels | Keywords: | sasmodels, mcsas |

Cc: | pkienzle | Work Package: | McSAS Integration Project |

### 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?.

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.

"

**Note:**See TracTickets for help on using tickets.

This is available in the beta_approx branch, PR #90