source: sasview/sansmodels/src/c_models/c_models.cpp @ bd26a85

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 bd26a85 was 543d1bd, checked in by Jae Cho <jhjcho@…>, 13 years ago

Added coreshellbicelle model

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