source: sasview/src/sans/models/c_extension/python_wrapper/generated/CLamellarFFHGModel.cpp @ 400155b

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 400155b was 400155b, checked in by gonzalezm, 9 years ago

Implementing request from ticket 261 - default number of bins in Annulus [Phi View] is now 36 and the first bin is now centered at 0 degrees

  • Property mode set to 100644
File size: 22.6 KB
Line 
1/**
2        This software was developed by the University of Tennessee as part of the
3        Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4        project funded by the US National Science Foundation.
5
6        If you use DANSE applications to do scientific research that leads to
7        publication, we ask that you acknowledge the use of the software with the
8        following sentence:
9
10        "This work benefited from DANSE software developed under NSF award DMR-0520547."
11
12        copyright 2008, University of Tennessee
13 */
14
15/** CLamellarFFHGModel
16 *
17 * C extension
18 *
19 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
20 *          DO NOT MODIFY THIS FILE, MODIFY src\sans\models\include\lamellarFF_HG.h
21 *          AND RE-RUN THE GENERATOR SCRIPT
22 *
23 */
24#define NO_IMPORT_ARRAY
25#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
26 
27extern "C" {
28#include <Python.h>
29#include <arrayobject.h>
30#include "structmember.h"
31#include <stdio.h>
32#include <stdlib.h>
33#include <math.h>
34#include <time.h>
35
36}
37
38#include "lamellarFF_HG.h"
39#include "dispersion_visitor.hh"
40
41/// Error object for raised exceptions
42static PyObject * CLamellarFFHGModelError = NULL;
43
44
45// Class definition
46typedef struct {
47    PyObject_HEAD
48    /// Parameters
49    PyObject * params;
50    /// Dispersion parameters
51    PyObject * dispersion;
52    /// Underlying model object
53    LamellarFFHGModel * model;
54    /// Log for unit testing
55    PyObject * log;
56} CLamellarFFHGModel;
57
58
59static void
60CLamellarFFHGModel_dealloc(CLamellarFFHGModel* self)
61{
62    Py_DECREF(self->params);
63    Py_DECREF(self->dispersion);
64    Py_DECREF(self->log);
65    delete self->model;
66    self->ob_type->tp_free((PyObject*)self);
67   
68
69}
70
71static PyObject *
72CLamellarFFHGModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
73{
74    CLamellarFFHGModel *self;
75   
76    self = (CLamellarFFHGModel *)type->tp_alloc(type, 0);
77   
78    return (PyObject *)self;
79}
80
81static int
82CLamellarFFHGModel_init(CLamellarFFHGModel *self, PyObject *args, PyObject *kwds)
83{
84    if (self != NULL) {
85       
86        // Create parameters
87        self->params = PyDict_New();
88        self->dispersion = PyDict_New();
89
90        self->model = new LamellarFFHGModel();
91
92        // Initialize parameter dictionary
93        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
94        PyDict_SetItemString(self->params,"h_thickness",Py_BuildValue("d",10.000000000000));
95        PyDict_SetItemString(self->params,"sld_tail",Py_BuildValue("d",0.000000400000));
96        PyDict_SetItemString(self->params,"sld_solvent",Py_BuildValue("d",0.000006000000));
97        PyDict_SetItemString(self->params,"t_length",Py_BuildValue("d",15.000000000000));
98        PyDict_SetItemString(self->params,"sld_head",Py_BuildValue("d",0.000003000000));
99        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
100        // Initialize dispersion / averaging parameter dict
101        DispersionVisitor* visitor = new DispersionVisitor();
102        PyObject * disp_dict;
103        disp_dict = PyDict_New();
104        self->model->t_length.dispersion->accept_as_source(visitor, self->model->t_length.dispersion, disp_dict);
105        PyDict_SetItemString(self->dispersion, "t_length", disp_dict);
106        disp_dict = PyDict_New();
107        self->model->h_thickness.dispersion->accept_as_source(visitor, self->model->h_thickness.dispersion, disp_dict);
108        PyDict_SetItemString(self->dispersion, "h_thickness", disp_dict);
109
110
111         
112        // Create empty log
113        self->log = PyDict_New();
114       
115       
116
117    }
118    return 0;
119}
120
121static char name_params[] = "params";
122static char def_params[] = "Parameters";
123static char name_dispersion[] = "dispersion";
124static char def_dispersion[] = "Dispersion parameters";
125static char name_log[] = "log";
126static char def_log[] = "Log";
127
128static PyMemberDef CLamellarFFHGModel_members[] = {
129    {name_params, T_OBJECT, offsetof(CLamellarFFHGModel, params), 0, def_params},
130        {name_dispersion, T_OBJECT, offsetof(CLamellarFFHGModel, dispersion), 0, def_dispersion},     
131    {name_log, T_OBJECT, offsetof(CLamellarFFHGModel, log), 0, def_log},
132    {NULL}  /* Sentinel */
133};
134
135/** Read double from PyObject
136    @param p PyObject
137    @return double
138*/
139double CLamellarFFHGModel_readDouble(PyObject *p) {
140    if (PyFloat_Check(p)==1) {
141        return (double)(((PyFloatObject *)(p))->ob_fval);
142    } else if (PyInt_Check(p)==1) {
143        return (double)(((PyIntObject *)(p))->ob_ival);
144    } else if (PyLong_Check(p)==1) {
145        return (double)PyLong_AsLong(p);
146    } else {
147        return 0.0;
148    }
149}
150/**
151 * Function to call to evaluate model
152 * @param args: input numpy array q[]
153 * @return: numpy array object
154 */
155 
156static PyObject *evaluateOneDim(LamellarFFHGModel* model, PyArrayObject *q){
157    PyArrayObject *result;
158   
159    // Check validity of array q , q must be of dimension 1, an array of double
160    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
161    {
162        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
163        //PyErr_SetString(PyExc_ValueError , message);
164        return NULL;
165    }
166    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
167        if (result == NULL) {
168        const char * message= "Could not create result ";
169        PyErr_SetString(PyExc_RuntimeError , message);
170                return NULL;
171        }
172#pragma omp parallel for
173         for (int i = 0; i < q->dimensions[0]; i++){
174      double q_value  = *(double *)(q->data + i*q->strides[0]);
175      double *result_value = (double *)(result->data + i*result->strides[0]);
176      *result_value =(*model)(q_value);
177        }
178    return PyArray_Return(result); 
179 }
180
181 /**
182 * Function to call to evaluate model
183 * @param args: input numpy array  [x[],y[]]
184 * @return: numpy array object
185 */
186 static PyObject * evaluateTwoDimXY( LamellarFFHGModel* model, 
187                              PyArrayObject *x, PyArrayObject *y)
188 {
189    PyArrayObject *result;
190    int x_len, y_len, dims[1];
191    //check validity of input vectors
192    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
193        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
194        || y->dimensions[0] != x->dimensions[0]){
195        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
196        PyErr_SetString(PyExc_ValueError , message); 
197        return NULL;
198    }
199   
200        if (PyArray_Check(x) && PyArray_Check(y)) {
201               
202            x_len = dims[0]= x->dimensions[0];
203        y_len = dims[0]= y->dimensions[0];
204           
205            // Make a new double matrix of same dims
206        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
207        if (result == NULL){
208            const char * message= "Could not create result ";
209        PyErr_SetString(PyExc_RuntimeError , message);
210            return NULL;
211            }
212       
213        /* Do the calculation. */
214#pragma omp parallel for
215        for (int i=0; i< x_len; i++) {
216            double x_value = *(double *)(x->data + i*x->strides[0]);
217                    double y_value = *(double *)(y->data + i*y->strides[0]);
218                        double *result_value = (double *)(result->data +
219                              i*result->strides[0]);
220                        *result_value = (*model)(x_value, y_value);
221        }           
222        return PyArray_Return(result); 
223       
224        }else{
225                    PyErr_SetString(CLamellarFFHGModelError, 
226                   "CLamellarFFHGModel.evaluateTwoDimXY couldn't run.");
227                return NULL;
228                }       
229}
230/**
231 *  evalDistribution function evaluate a model function with input vector
232 *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
233 *
234 */ 
235static PyObject * evalDistribution(CLamellarFFHGModel *self, PyObject *args){
236        PyObject *qx, *qy;
237        PyArrayObject * pars;
238        int npars ,mpars;
239       
240        // Get parameters
241       
242            // Reader parameter dictionary
243    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
244    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
245    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
246    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
247    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
248    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
249    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
250    // Read in dispersion parameters
251    PyObject* disp_dict;
252    DispersionVisitor* visitor = new DispersionVisitor();
253    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
254    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
255    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
256    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
257
258       
259        // Get input and determine whether we have to supply a 1D or 2D return value.
260        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
261            PyErr_SetString(CLamellarFFHGModelError, 
262                "CLamellarFFHGModel.evalDistribution expects a q value.");
263                return NULL;
264        }
265    // Check params
266       
267    if(PyArray_Check(pars)==1) {
268               
269            // Length of list should 1 or 2
270            npars = pars->nd; 
271            if(npars==1) {
272                // input is a numpy array
273                if (PyArray_Check(pars)) {
274                        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
275                    }
276                }else{
277                    PyErr_SetString(CLamellarFFHGModelError, 
278                   "CLamellarFFHGModel.evalDistribution expect numpy array of one dimension.");
279                return NULL;
280                }
281    }else if( PyList_Check(pars)==1) {
282        // Length of list should be 2 for I(qx,qy)
283            mpars = PyList_GET_SIZE(pars); 
284            if(mpars!=2) {
285                PyErr_SetString(CLamellarFFHGModelError, 
286                        "CLamellarFFHGModel.evalDistribution expects a list of dimension 2.");
287                return NULL;
288            }
289             qx = PyList_GET_ITEM(pars,0);
290             qy = PyList_GET_ITEM(pars,1);
291             if (PyArray_Check(qx) && PyArray_Check(qy)) {
292                 return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
293                           (PyArrayObject*)qy);
294                 }else{
295                    PyErr_SetString(CLamellarFFHGModelError, 
296                   "CLamellarFFHGModel.evalDistribution expect 2 numpy arrays in list.");
297                return NULL;
298             }
299        }
300        PyErr_SetString(CLamellarFFHGModelError, 
301                   "CLamellarFFHGModel.evalDistribution couln't be run.");
302        return NULL;
303       
304}
305
306/**
307 * Function to call to evaluate model
308 * @param args: input q or [q,phi]
309 * @return: function value
310 */
311static PyObject * run(CLamellarFFHGModel *self, PyObject *args) {
312        double q_value, phi_value;
313        PyObject* pars;
314        int npars;
315       
316        // Get parameters
317       
318            // Reader parameter dictionary
319    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
320    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
321    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
322    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
323    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
324    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
325    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
326    // Read in dispersion parameters
327    PyObject* disp_dict;
328    DispersionVisitor* visitor = new DispersionVisitor();
329    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
330    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
331    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
332    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
333
334       
335        // Get input and determine whether we have to supply a 1D or 2D return value.
336        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
337            PyErr_SetString(CLamellarFFHGModelError, 
338                "CLamellarFFHGModel.run expects a q value.");
339                return NULL;
340        }
341         
342        // Check params
343        if( PyList_Check(pars)==1) {
344               
345                // Length of list should be 2 for I(q,phi)
346            npars = PyList_GET_SIZE(pars); 
347            if(npars!=2) {
348                PyErr_SetString(CLamellarFFHGModelError, 
349                        "CLamellarFFHGModel.run expects a double or a list of dimension 2.");
350                return NULL;
351            }
352            // We have a vector q, get the q and phi values at which
353            // to evaluate I(q,phi)
354            q_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,0));
355            phi_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,1));
356            // Skip zero
357            if (q_value==0) {
358                return Py_BuildValue("d",0.0);
359            }
360                return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
361
362        } else {
363
364                // We have a scalar q, we will evaluate I(q)
365                q_value = CLamellarFFHGModel_readDouble(pars);         
366               
367                return Py_BuildValue("d",(*(self->model))(q_value));
368        }       
369}
370/**
371 * Function to call to calculate_ER
372 * @return: effective radius value
373 */
374static PyObject * calculate_ER(CLamellarFFHGModel *self) {
375
376        // Get parameters
377       
378            // Reader parameter dictionary
379    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
380    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
381    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
382    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
383    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
384    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
385    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
386    // Read in dispersion parameters
387    PyObject* disp_dict;
388    DispersionVisitor* visitor = new DispersionVisitor();
389    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
390    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
391    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
392    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
393
394               
395        return Py_BuildValue("d",(*(self->model)).calculate_ER());
396
397}
398/**
399 * Function to call to cal the ratio shell volume/ total volume
400 * @return: the ratio shell volume/ total volume
401 */
402static PyObject * calculate_VR(CLamellarFFHGModel *self) {
403
404        // Get parameters
405       
406            // Reader parameter dictionary
407    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
408    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
409    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
410    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
411    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
412    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
413    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
414    // Read in dispersion parameters
415    PyObject* disp_dict;
416    DispersionVisitor* visitor = new DispersionVisitor();
417    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
418    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
419    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
420    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
421
422               
423        return Py_BuildValue("d",(*(self->model)).calculate_VR());
424
425}
426/**
427 * Function to call to evaluate model in cartesian coordinates
428 * @param args: input q or [qx, qy]]
429 * @return: function value
430 */
431static PyObject * runXY(CLamellarFFHGModel *self, PyObject *args) {
432        double qx_value, qy_value;
433        PyObject* pars;
434        int npars;
435       
436        // Get parameters
437       
438            // Reader parameter dictionary
439    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
440    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
441    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
442    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
443    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
444    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
445    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
446    // Read in dispersion parameters
447    PyObject* disp_dict;
448    DispersionVisitor* visitor = new DispersionVisitor();
449    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
450    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
451    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
452    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
453
454       
455        // Get input and determine whether we have to supply a 1D or 2D return value.
456        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
457            PyErr_SetString(CLamellarFFHGModelError, 
458                "CLamellarFFHGModel.run expects a q value.");
459                return NULL;
460        }
461         
462        // Check params
463        if( PyList_Check(pars)==1) {
464               
465                // Length of list should be 2 for I(qx, qy))
466            npars = PyList_GET_SIZE(pars); 
467            if(npars!=2) {
468                PyErr_SetString(CLamellarFFHGModelError, 
469                        "CLamellarFFHGModel.run expects a double or a list of dimension 2.");
470                return NULL;
471            }
472            // We have a vector q, get the qx and qy values at which
473            // to evaluate I(qx,qy)
474            qx_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,0));
475            qy_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,1));
476            return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
477
478        } else {
479
480                // We have a scalar q, we will evaluate I(q)
481                qx_value = CLamellarFFHGModel_readDouble(pars);         
482               
483                return Py_BuildValue("d",(*(self->model))(qx_value));
484        }       
485}
486
487static PyObject * reset(CLamellarFFHGModel *self, PyObject *args) {
488   
489
490    return Py_BuildValue("d",0.0);
491}
492
493static PyObject * set_dispersion(CLamellarFFHGModel *self, PyObject *args) {
494        PyObject * disp;
495        const char * par_name;
496
497        if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
498            PyErr_SetString(CLamellarFFHGModelError,
499                "CLamellarFFHGModel.set_dispersion expects a DispersionModel object.");
500                return NULL;
501        }
502        void *temp = PyCObject_AsVoidPtr(disp);
503        DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
504
505
506        // Ugliness necessary to go from python to C
507            // TODO: refactor this
508    if (!strcmp(par_name, "t_length")) {
509        self->model->t_length.dispersion = dispersion;
510    } else    if (!strcmp(par_name, "h_thickness")) {
511        self->model->h_thickness.dispersion = dispersion;
512    } else {
513            PyErr_SetString(CLamellarFFHGModelError,
514                "CLamellarFFHGModel.set_dispersion expects a valid parameter name.");
515                return NULL;
516        }
517
518        DispersionVisitor* visitor = new DispersionVisitor();
519        PyObject * disp_dict = PyDict_New();
520        dispersion->accept_as_source(visitor, dispersion, disp_dict);
521        PyDict_SetItemString(self->dispersion, par_name, disp_dict);
522    return Py_BuildValue("i",1);
523}
524
525
526static PyMethodDef CLamellarFFHGModel_methods[] = {
527    {"run",      (PyCFunction)run     , METH_VARARGS,
528      "Evaluate the model at a given Q or Q, phi"},
529    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
530      "Evaluate the model at a given Q or Qx, Qy"},
531    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
532      "Evaluate the model at a given Q or Q, phi"},
533    {"calculate_VR",      (PyCFunction)calculate_VR     , METH_VARARGS,
534      "Evaluate VR"},   
535    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
536      "Evaluate the model at a given Q or Qx, Qy vector "},
537    {"reset",    (PyCFunction)reset   , METH_VARARGS,
538      "Reset pair correlation"},
539    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
540      "Set the dispersion model for a given parameter"},
541   {NULL}
542};
543
544static PyTypeObject CLamellarFFHGModelType = {
545    PyObject_HEAD_INIT(NULL)
546    0,                         /*ob_size*/
547    "CLamellarFFHGModel",             /*tp_name*/
548    sizeof(CLamellarFFHGModel),             /*tp_basicsize*/
549    0,                         /*tp_itemsize*/
550    (destructor)CLamellarFFHGModel_dealloc, /*tp_dealloc*/
551    0,                         /*tp_print*/
552    0,                         /*tp_getattr*/
553    0,                         /*tp_setattr*/
554    0,                         /*tp_compare*/
555    0,                         /*tp_repr*/
556    0,                         /*tp_as_number*/
557    0,                         /*tp_as_sequence*/
558    0,                         /*tp_as_mapping*/
559    0,                         /*tp_hash */
560    0,                         /*tp_call*/
561    0,                         /*tp_str*/
562    0,                         /*tp_getattro*/
563    0,                         /*tp_setattro*/
564    0,                         /*tp_as_buffer*/
565    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
566    "CLamellarFFHGModel objects",           /* tp_doc */
567    0,                         /* tp_traverse */
568    0,                         /* tp_clear */
569    0,                         /* tp_richcompare */
570    0,                         /* tp_weaklistoffset */
571    0,                         /* tp_iter */
572    0,                         /* tp_iternext */
573    CLamellarFFHGModel_methods,             /* tp_methods */
574    CLamellarFFHGModel_members,             /* tp_members */
575    0,                         /* tp_getset */
576    0,                         /* tp_base */
577    0,                         /* tp_dict */
578    0,                         /* tp_descr_get */
579    0,                         /* tp_descr_set */
580    0,                         /* tp_dictoffset */
581    (initproc)CLamellarFFHGModel_init,      /* tp_init */
582    0,                         /* tp_alloc */
583    CLamellarFFHGModel_new,                 /* tp_new */
584};
585
586
587//static PyMethodDef module_methods[] = {
588//    {NULL}
589//};
590
591/**
592 * Function used to add the model class to a module
593 * @param module: module to add the class to
594 */ 
595void addCLamellarFFHGModel(PyObject *module) {
596        PyObject *d;
597       
598    if (PyType_Ready(&CLamellarFFHGModelType) < 0)
599        return;
600
601    Py_INCREF(&CLamellarFFHGModelType);
602    PyModule_AddObject(module, "CLamellarFFHGModel", (PyObject *)&CLamellarFFHGModelType);
603   
604    d = PyModule_GetDict(module);
605    static char error_name[] = "CLamellarFFHGModel.error";
606    CLamellarFFHGModelError = PyErr_NewException(error_name, NULL, NULL);
607    PyDict_SetItemString(d, "CLamellarFFHGModelError", CLamellarFFHGModelError);
608}
609
Note: See TracBrowser for help on using the repository browser.