Opened 8 years ago

Last modified 8 years ago

#568 new defect

custom models should use Iq(q, ...) and Iqxy(qx, qy, ...)

Reported by: pkienzle Owned by:
Priority: minor Milestone: SasView Next Release +1
Component: SasView Keywords:
Cc: Work Package: SasView Bug Fixing

Description

The custom model editor defines functions Iq(x, pars…) instead of Iq(q, pars…).

Converting a model from python to C, which we may want to do to make it run on the GPU, the natural step is to first convert it from a python def to a string containing the C definition, so for example the quadratic

    def Iq(x, a, b, c):
        return a*x**2 + b*x +c

gets edited to

    Iq = """
        return a*x*x + b*x + c;
    """

The C string wrapper for the Iq function assumes that the first parameter is q, so this expands into

    double Iq(double q, double a, double b, double c);
    double Iq(double q, double a, double b, double c) {
        return a*x*x + b*x + c;
    }

and the variable x is not defined.

Furthermore, when moving using contributed models into future releases of sasmodels it will be convenient if they already use q instead of x so they are consistent with existing models.

Change History (5)

comment:1 Changed 8 years ago by pkienzle

  • Priority changed from major to minor

comment:2 Changed 8 years ago by pkienzle

Also, define form_volume, Iq and Iqxy before ER and VR.

When converting from python to C, the first three functions are converted, but not the last two.

comment:3 Changed 8 years ago by pkienzle

Should also use "from numpy import sqrt" at the top, and use "sqrt(qx*qx + qy*qy)" rather than "numpy.sqrt(x2 + y2)" for the Iqxy function to make the transition to C easier.

comment:4 Changed 8 years ago by pkienzle

Should not have "from math import *" since functions in math are not vectorized.

The current convention is "import numpy as np" rather than "import numpy". Following conventions makes it easier to borrow code from stack overflow, etc.

comment:5 Changed 8 years ago by butler

  • Milestone changed from SasView 4.0.0 to SasView Next Release +1

As agreed on fortnightly call of June 21, am moving all minor priority tickets to next release (+1) given the resources and time available to get this release out.

Note: See TracTickets for help on using tickets.