source: sasview/sansmodels/src/sans/models/c_models/c_models.cpp @ 20f00bed

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 20f00bed was aaad3098, checked in by Jae Cho <jhjcho@…>, 14 years ago

pclamella removed from list until they are ready

  • Property mode set to 100644
File size: 7.7 KB
RevLine 
[af03ddd]1/** c_models
2 *
3 * Module containing all SANS model extensions
4 *
5 * @author   M.Doucet / UTK
6 */
7#include <Python.h>
8#include <parameters.hh>
[812b901]9#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
10#include "arrayobject.h"
11
[af03ddd]12
13void addCCylinderModel(PyObject *module);
[27a0771]14void addCTriaxialEllipsoidModel(PyObject *module);
[8a48713]15void addCParallelepipedModel(PyObject *module);
[0f5bc9f]16void addCSphereModel(PyObject *module);
[e096270]17void addCOnionModel(PyObject *module);
[35aface]18void addCReflModel(PyObject *module);
[c724ccd]19void addCFuzzySphereModel(PyObject *module);
[25579e8]20void addCHardsphereStructure(PyObject *module);
21void addCStickyHSStructure(PyObject *module);
[94a3f8f]22void addCSCCrystalModel(PyObject *module);
[d5b6a9d]23void addCFCCrystalModel(PyObject *module);
24void addCBCCrystalModel(PyObject *module);
[25579e8]25void addCSquareWellStructure(PyObject *module);
26void addCHayterMSAStructure(PyObject *module);
[0f5bc9f]27void addCCoreShellModel(PyObject *module);
[c724ccd]28void addCCoreFourShellModel(PyObject *module);
[0f5bc9f]29void addCCoreShellCylinderModel(PyObject *module);
30void addCEllipsoidModel(PyObject *module);
31void addCEllipticalCylinderModel(PyObject *module);
[5068697]32void addCTriaxialEllipsoidModel(PyObject *module);
33void addCFlexibleCylinderModel(PyObject *module);
[c724ccd]34void addCFlexCylEllipXModel(PyObject *module);
[5068697]35void addCStackedDisksModel(PyObject *module);
[27a0771]36void addCLamellarPSModel(PyObject *module);
37void addCLamellarPSHGModel(PyObject *module);
[aaad3098]38//void addCLamellarPCrystalModel(PyObject *module);
[eddff027]39void addCCoreShellEllipsoidModel(PyObject *module);
[5eb9154]40void addCDiamEllipFunc(PyObject *module);
41void addCDiamCylFunc(PyObject *module);
42
43//void addCOblateModel(PyObject *module);
44//void addCProlateModel(PyObject *module);
[34c3020]45void addCLamellarModel(PyObject *module);
46void addCLamellarFFHGModel(PyObject *module);
[27fea3f]47void addCHollowCylinderModel(PyObject *module);
[3d25331f]48void addCMultiShellModel(PyObject *module);
49void addCVesicleModel(PyObject *module);
50void addCBinaryHSModel(PyObject *module);
[35aface]51void addCRPAModel(PyObject *module);
[c724ccd]52void addCFractalModel(PyObject *module);
53void addCPoly_GaussCoil(PyObject *module);
[27a0771]54
[0f5bc9f]55
[af03ddd]56extern "C" {
[0f5bc9f]57        //void addCCoreShellCylinderModel(PyObject *module);
58        //void addCCoreShellModel(PyObject *module);
59        //void addCEllipsoidModel(PyObject *module);
60        //void addCEllipticalCylinderModel(PyObject *module);
[af03ddd]61        void addDisperser(PyObject *module);
62        void addCGaussian(PyObject *module);
63        void addCLorentzian(PyObject *module);
[eba9885]64        void addCLogNormal(PyObject *module);
65        void addCSchulz(PyObject *module);
[af03ddd]66}
67
68/**
69 * Delete a dispersion model object
70 */
71void del_dispersion_model(void *ptr){
72        DispersionModel * disp = static_cast<DispersionModel *>(ptr);
73        delete disp;
74        return;
75}
76
77/**
78 * Create a dispersion model as a python object
79 */
80PyObject * new_dispersion_model(PyObject *, PyObject *args) {
81        DispersionModel *disp = new DispersionModel();
82        return PyCObject_FromVoidPtr(disp, del_dispersion_model);
83}
84
85
86/**
[eba9885]87 * Delete a lognormal dispersion model object
88 */
89void del_lognormal_dispersion(void *ptr){
90        LogNormalDispersion * disp = static_cast<LogNormalDispersion *>(ptr);
91        delete disp;
92        return;
93}
94
95/**
96 * Create a lognormal dispersion model as a python object
97 */
98PyObject * new_lognormal_dispersion(PyObject *, PyObject *args) {
99        LogNormalDispersion *disp = new LogNormalDispersion();
100        return PyCObject_FromVoidPtr(disp, del_lognormal_dispersion);
101}
102
103/**
[af03ddd]104 * Delete a gaussian dispersion model object
105 */
106void del_gaussian_dispersion(void *ptr){
107        GaussianDispersion * disp = static_cast<GaussianDispersion *>(ptr);
108        delete disp;
109        return;
110}
111
112/**
113 * Create a gaussian dispersion model as a python object
114 */
115PyObject * new_gaussian_dispersion(PyObject *, PyObject *args) {
116        GaussianDispersion *disp = new GaussianDispersion();
117        return PyCObject_FromVoidPtr(disp, del_gaussian_dispersion);
118}
119
120/**
[eba9885]121 * Delete a schulz dispersion model object
122 */
123void del_schulz_dispersion(void *ptr){
124        SchulzDispersion * disp = static_cast<SchulzDispersion *>(ptr);
125        delete disp;
126        return;
127}
128/**
129 * Create a schulz dispersion model as a python object
130 */
131PyObject * new_schulz_dispersion(PyObject *, PyObject *args) {
132        SchulzDispersion *disp = new SchulzDispersion();
133        return PyCObject_FromVoidPtr(disp, del_schulz_dispersion);
134}
135
136
137/**
[af03ddd]138 * Delete an array dispersion model object
139 */
140void del_array_dispersion(void *ptr){
141        ArrayDispersion * disp = static_cast<ArrayDispersion *>(ptr);
142        delete disp;
143        return;
144}
145
146/**
147 * Create an array dispersion model as a python object
148 */
149PyObject * new_array_dispersion(PyObject *, PyObject *args) {
150        ArrayDispersion *disp = new ArrayDispersion();
151        return PyCObject_FromVoidPtr(disp, del_array_dispersion);
152}
153
154#define INVECTOR(obj,buf,len)                                                                           \
155    do { \
156        int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \
157        if (err < 0) return NULL; \
158        len /= sizeof(*buf); \
159    } while (0)
160
161/**
162 * Sets weights from a numpy array
163 */
164PyObject * set_weights(PyObject *, PyObject *args) {
165        PyObject *val_obj;
166        PyObject *wei_obj;
167        PyObject *disp;
168        Py_ssize_t nval;
169        Py_ssize_t nwei;
170        double *values;
171        double *weights;
[812b901]172    //int i;
[af03ddd]173
174        if (!PyArg_ParseTuple(args, "OOO", &disp, &val_obj, &wei_obj)) return NULL;
175        INVECTOR(val_obj, values, nval);
176        INVECTOR(wei_obj, weights, nwei);
177
178        // Sanity check
179        if(nval!=nwei) return NULL;
180
181        // Set the array pointers
182        void *temp = PyCObject_AsVoidPtr(disp);
183        DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
184        dispersion->set_weights(nval, values, weights);
185
186        return Py_BuildValue("i",1);
187}
188
189
190
191/**
192 * Define empty module
193 */
194static PyMethodDef module_methods[] = {
195        {"new_dispersion_model", (PyCFunction)new_dispersion_model     , METH_VARARGS,
196                  "Create a new DispersionModel object"},
197        {"new_gaussian_model",   (PyCFunction)new_gaussian_dispersion, METH_VARARGS,
198                  "Create a new GaussianDispersion object"},
[eba9885]199    {"new_lognormal_model",   (PyCFunction)new_lognormal_dispersion, METH_VARARGS,
200                  "Create a new LogNormalDispersion object"},
201    {"new_schulz_model",   (PyCFunction)new_schulz_dispersion, METH_VARARGS,
202                  "Create a new SchulzDispersion object"},
[af03ddd]203        {"new_array_model",      (PyCFunction)new_array_dispersion  , METH_VARARGS,
204                  "Create a new ArrayDispersion object"},
205        {"set_dispersion_weights",(PyCFunction)set_weights  , METH_VARARGS,
206                        "Create the dispersion weight arrays for an Array Dispersion object"},
207    {NULL}
208};
209
210
211#ifndef PyMODINIT_FUNC  /* declarations for DLL import/export */
212#define PyMODINIT_FUNC void
213#endif
214PyMODINIT_FUNC
215initc_models(void)
216{
217    PyObject* m;
218
219    m = Py_InitModule3("c_models", module_methods,
220                       "C extension module for SANS scattering models.");
[812b901]221        import_array();
[af03ddd]222
223        addCCylinderModel(m);
[8a48713]224        addCParallelepipedModel(m);
[af03ddd]225        addCCoreShellCylinderModel(m);
226        addCCoreShellModel(m);
[c724ccd]227        addCCoreFourShellModel(m);
[af03ddd]228        addCEllipsoidModel(m);
229        addCSphereModel(m);
[e096270]230        addCOnionModel(m);
[35aface]231        addCReflModel(m);
[c724ccd]232        addCFuzzySphereModel(m);
[25579e8]233        addCHardsphereStructure(m);
234        addCStickyHSStructure(m);
[94a3f8f]235        addCSCCrystalModel(m);
[d5b6a9d]236        addCFCCrystalModel(m);
237        addCBCCrystalModel(m);
[25579e8]238        addCSquareWellStructure(m);
239        addCHayterMSAStructure(m);
[af03ddd]240        addCEllipticalCylinderModel(m);
[5068697]241        addCTriaxialEllipsoidModel(m);
242        addCFlexibleCylinderModel(m);
[c724ccd]243        addCFlexCylEllipXModel(m);
[5068697]244        addCStackedDisksModel(m);
[27a0771]245        addCLamellarPSModel(m);
246        addCLamellarPSHGModel(m);
[aaad3098]247        //addCLamellarPCrystalModel(m);
[eddff027]248        addCCoreShellEllipsoidModel(m);
[5eb9154]249        addCDiamEllipFunc(m);
250        addCDiamCylFunc(m);
251
252//      addCOblateModel(m);
253//      addCProlateModel(m);
[34c3020]254        addCLamellarModel(m);
255        addCLamellarFFHGModel(m);
[27fea3f]256        addCHollowCylinderModel(m);
[3d25331f]257        addCMultiShellModel(m);
258        addCBinaryHSModel(m);
[af03ddd]259        addDisperser(m);
260        addCGaussian(m);
[eba9885]261        addCSchulz(m);
262        addCLogNormal(m);
[af03ddd]263        addCLorentzian(m);
[3d25331f]264        addCVesicleModel(m);
[c724ccd]265        addCPoly_GaussCoil(m);
[35aface]266        addCRPAModel(m);
[c724ccd]267        addCFractalModel(m);
[af03ddd]268}
Note: See TracBrowser for help on using the repository browser.