source: sasview/sansmodels/src/sans/models/c_models/CLamellarFFHGModel.cpp @ 01de557

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 01de557 was 0b082f3, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #7 Enable openmp for all models

  • Property mode set to 100644
File size: 21.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 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#include "lamellarFF_HG.h"
36}
37
38#include "models.hh"
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        self->model = new LamellarFFHGModel();
90       
91        // Initialize parameter dictionary
92        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
93        PyDict_SetItemString(self->params,"h_thickness",Py_BuildValue("d",10.000000000000));
94        PyDict_SetItemString(self->params,"sld_tail",Py_BuildValue("d",0.000000400000));
95        PyDict_SetItemString(self->params,"sld_solvent",Py_BuildValue("d",0.000006000000));
96        PyDict_SetItemString(self->params,"t_length",Py_BuildValue("d",15.000000000000));
97        PyDict_SetItemString(self->params,"sld_head",Py_BuildValue("d",0.000003000000));
98        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
99        // Initialize dispersion / averaging parameter dict
100        DispersionVisitor* visitor = new DispersionVisitor();
101        PyObject * disp_dict;
102        disp_dict = PyDict_New();
103        self->model->t_length.dispersion->accept_as_source(visitor, self->model->t_length.dispersion, disp_dict);
104        PyDict_SetItemString(self->dispersion, "t_length", disp_dict);
105        disp_dict = PyDict_New();
106        self->model->h_thickness.dispersion->accept_as_source(visitor, self->model->h_thickness.dispersion, disp_dict);
107        PyDict_SetItemString(self->dispersion, "h_thickness", disp_dict);
108
109
110         
111        // Create empty log
112        self->log = PyDict_New();
113       
114       
115
116    }
117    return 0;
118}
119
120static char name_params[] = "params";
121static char def_params[] = "Parameters";
122static char name_dispersion[] = "dispersion";
123static char def_dispersion[] = "Dispersion parameters";
124static char name_log[] = "log";
125static char def_log[] = "Log";
126
127static PyMemberDef CLamellarFFHGModel_members[] = {
128    {name_params, T_OBJECT, offsetof(CLamellarFFHGModel, params), 0, def_params},
129        {name_dispersion, T_OBJECT, offsetof(CLamellarFFHGModel, dispersion), 0, def_dispersion},     
130    {name_log, T_OBJECT, offsetof(CLamellarFFHGModel, log), 0, def_log},
131    {NULL}  /* Sentinel */
132};
133
134/** Read double from PyObject
135    @param p PyObject
136    @return double
137*/
138double CLamellarFFHGModel_readDouble(PyObject *p) {
139    if (PyFloat_Check(p)==1) {
140        return (double)(((PyFloatObject *)(p))->ob_fval);
141    } else if (PyInt_Check(p)==1) {
142        return (double)(((PyIntObject *)(p))->ob_ival);
143    } else if (PyLong_Check(p)==1) {
144        return (double)PyLong_AsLong(p);
145    } else {
146        return 0.0;
147    }
148}
149/**
150 * Function to call to evaluate model
151 * @param args: input numpy array q[]
152 * @return: numpy array object
153 */
154 
155static PyObject *evaluateOneDim(LamellarFFHGModel* model, PyArrayObject *q){
156    PyArrayObject *result;
157   
158    // Check validity of array q , q must be of dimension 1, an array of double
159    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
160    {
161        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
162        //PyErr_SetString(PyExc_ValueError , message);
163        return NULL;
164    }
165    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 
166                                                                                  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 evaluate model in cartesian coordinates
400 * @param args: input q or [qx, qy]]
401 * @return: function value
402 */
403static PyObject * runXY(CLamellarFFHGModel *self, PyObject *args) {
404        double qx_value, qy_value;
405        PyObject* pars;
406        int npars;
407       
408        // Get parameters
409       
410            // Reader parameter dictionary
411    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
412    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
413    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
414    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
415    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
416    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
417    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
418    // Read in dispersion parameters
419    PyObject* disp_dict;
420    DispersionVisitor* visitor = new DispersionVisitor();
421    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
422    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
423    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
424    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
425
426       
427        // Get input and determine whether we have to supply a 1D or 2D return value.
428        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
429            PyErr_SetString(CLamellarFFHGModelError, 
430                "CLamellarFFHGModel.run expects a q value.");
431                return NULL;
432        }
433         
434        // Check params
435        if( PyList_Check(pars)==1) {
436               
437                // Length of list should be 2 for I(qx, qy))
438            npars = PyList_GET_SIZE(pars); 
439            if(npars!=2) {
440                PyErr_SetString(CLamellarFFHGModelError, 
441                        "CLamellarFFHGModel.run expects a double or a list of dimension 2.");
442                return NULL;
443            }
444            // We have a vector q, get the qx and qy values at which
445            // to evaluate I(qx,qy)
446            qx_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,0));
447            qy_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,1));
448            return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
449
450        } else {
451
452                // We have a scalar q, we will evaluate I(q)
453                qx_value = CLamellarFFHGModel_readDouble(pars);         
454               
455                return Py_BuildValue("d",(*(self->model))(qx_value));
456        }       
457}
458
459static PyObject * reset(CLamellarFFHGModel *self, PyObject *args) {
460   
461
462    return Py_BuildValue("d",0.0);
463}
464
465static PyObject * set_dispersion(CLamellarFFHGModel *self, PyObject *args) {
466        PyObject * disp;
467        const char * par_name;
468
469        if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
470            PyErr_SetString(CLamellarFFHGModelError,
471                "CLamellarFFHGModel.set_dispersion expects a DispersionModel object.");
472                return NULL;
473        }
474        void *temp = PyCObject_AsVoidPtr(disp);
475        DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
476
477
478        // Ugliness necessary to go from python to C
479            // TODO: refactor this
480    if (!strcmp(par_name, "t_length")) {
481        self->model->t_length.dispersion = dispersion;
482    } else    if (!strcmp(par_name, "h_thickness")) {
483        self->model->h_thickness.dispersion = dispersion;
484    } else {
485            PyErr_SetString(CLamellarFFHGModelError,
486                "CLamellarFFHGModel.set_dispersion expects a valid parameter name.");
487                return NULL;
488        }
489
490        DispersionVisitor* visitor = new DispersionVisitor();
491        PyObject * disp_dict = PyDict_New();
492        dispersion->accept_as_source(visitor, dispersion, disp_dict);
493        PyDict_SetItemString(self->dispersion, par_name, disp_dict);
494    return Py_BuildValue("i",1);
495}
496
497
498static PyMethodDef CLamellarFFHGModel_methods[] = {
499    {"run",      (PyCFunction)run     , METH_VARARGS,
500      "Evaluate the model at a given Q or Q, phi"},
501    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
502      "Evaluate the model at a given Q or Qx, Qy"},
503    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
504      "Evaluate the model at a given Q or Q, phi"},
505     
506    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
507      "Evaluate the model at a given Q or Qx, Qy vector "},
508    {"reset",    (PyCFunction)reset   , METH_VARARGS,
509      "Reset pair correlation"},
510    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
511      "Set the dispersion model for a given parameter"},
512   {NULL}
513};
514
515static PyTypeObject CLamellarFFHGModelType = {
516    PyObject_HEAD_INIT(NULL)
517    0,                         /*ob_size*/
518    "CLamellarFFHGModel",             /*tp_name*/
519    sizeof(CLamellarFFHGModel),             /*tp_basicsize*/
520    0,                         /*tp_itemsize*/
521    (destructor)CLamellarFFHGModel_dealloc, /*tp_dealloc*/
522    0,                         /*tp_print*/
523    0,                         /*tp_getattr*/
524    0,                         /*tp_setattr*/
525    0,                         /*tp_compare*/
526    0,                         /*tp_repr*/
527    0,                         /*tp_as_number*/
528    0,                         /*tp_as_sequence*/
529    0,                         /*tp_as_mapping*/
530    0,                         /*tp_hash */
531    0,                         /*tp_call*/
532    0,                         /*tp_str*/
533    0,                         /*tp_getattro*/
534    0,                         /*tp_setattro*/
535    0,                         /*tp_as_buffer*/
536    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
537    "CLamellarFFHGModel objects",           /* tp_doc */
538    0,                         /* tp_traverse */
539    0,                         /* tp_clear */
540    0,                         /* tp_richcompare */
541    0,                         /* tp_weaklistoffset */
542    0,                         /* tp_iter */
543    0,                         /* tp_iternext */
544    CLamellarFFHGModel_methods,             /* tp_methods */
545    CLamellarFFHGModel_members,             /* tp_members */
546    0,                         /* tp_getset */
547    0,                         /* tp_base */
548    0,                         /* tp_dict */
549    0,                         /* tp_descr_get */
550    0,                         /* tp_descr_set */
551    0,                         /* tp_dictoffset */
552    (initproc)CLamellarFFHGModel_init,      /* tp_init */
553    0,                         /* tp_alloc */
554    CLamellarFFHGModel_new,                 /* tp_new */
555};
556
557
558//static PyMethodDef module_methods[] = {
559//    {NULL}
560//};
561
562/**
563 * Function used to add the model class to a module
564 * @param module: module to add the class to
565 */ 
566void addCLamellarFFHGModel(PyObject *module) {
567        PyObject *d;
568       
569    if (PyType_Ready(&CLamellarFFHGModelType) < 0)
570        return;
571
572    Py_INCREF(&CLamellarFFHGModelType);
573    PyModule_AddObject(module, "CLamellarFFHGModel", (PyObject *)&CLamellarFFHGModelType);
574   
575    d = PyModule_GetDict(module);
576    static char error_name[] = "CLamellarFFHGModel.error";
577    CLamellarFFHGModelError = PyErr_NewException(error_name, NULL, NULL);
578    PyDict_SetItemString(d, "CLamellarFFHGModelError", CLamellarFFHGModelError);
579}
580
Note: See TracBrowser for help on using the repository browser.