Changeset e2afadf in sasview for sansmodels/src/sans/models/c_models


Ignore:
Timestamp:
Aug 25, 2009 3:31:36 PM (15 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ff85cc5
Parents:
c8727c5
Message:

fixed a mistake and changed a para_name

Location:
sansmodels/src/sans/models/c_models
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_models/CHollowCylinderModel.cpp

    r870f131 re2afadf  
    9191        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000)); 
    9292        PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000)); 
     93        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",30.000000)); 
    9394        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.010000)); 
    94         PyDict_SetItemString(self->params,"shell_radius",Py_BuildValue("d",30.000000)); 
    9595        PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005)); 
    9696        // Initialize dispersion / averaging parameter dict 
     
    101101        PyDict_SetItemString(self->dispersion, "core_radius", disp_dict); 
    102102        disp_dict = PyDict_New(); 
    103         self->model->shell_radius.dispersion->accept_as_source(visitor, self->model->shell_radius.dispersion, disp_dict); 
    104         PyDict_SetItemString(self->dispersion, "shell_radius", disp_dict); 
     103        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict); 
     104        PyDict_SetItemString(self->dispersion, "radius", disp_dict); 
    105105        disp_dict = PyDict_New(); 
    106106        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict); 
     
    248248    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") ); 
    249249    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 
     250    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 
    250251    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    251     self->model->shell_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_radius") ); 
    252252    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 
    253253    // Read in dispersion parameters 
     
    256256    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    257257    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
    258     disp_dict = PyDict_GetItemString(self->dispersion, "shell_radius"); 
    259     self->model->shell_radius.dispersion->accept_as_destination(visitor, self->model->shell_radius.dispersion, disp_dict); 
     258    disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 
     259    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); 
    260260    disp_dict = PyDict_GetItemString(self->dispersion, "length"); 
    261261    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); 
     
    331331    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") ); 
    332332    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 
     333    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 
    333334    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    334     self->model->shell_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_radius") ); 
    335335    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 
    336336    // Read in dispersion parameters 
     
    339339    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    340340    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
    341     disp_dict = PyDict_GetItemString(self->dispersion, "shell_radius"); 
    342     self->model->shell_radius.dispersion->accept_as_destination(visitor, self->model->shell_radius.dispersion, disp_dict); 
     341    disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 
     342    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); 
    343343    disp_dict = PyDict_GetItemString(self->dispersion, "length"); 
    344344    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); 
     
    403403    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") ); 
    404404    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 
     405    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 
    405406    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    406     self->model->shell_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_radius") ); 
    407407    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 
    408408    // Read in dispersion parameters 
     
    411411    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    412412    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
    413     disp_dict = PyDict_GetItemString(self->dispersion, "shell_radius"); 
    414     self->model->shell_radius.dispersion->accept_as_destination(visitor, self->model->shell_radius.dispersion, disp_dict); 
     413    disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 
     414    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); 
    415415    disp_dict = PyDict_GetItemString(self->dispersion, "length"); 
    416416    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); 
     
    476476    if (!strcmp(par_name, "core_radius")) { 
    477477        self->model->core_radius.dispersion = dispersion; 
    478     } else    if (!strcmp(par_name, "shell_radius")) { 
    479         self->model->shell_radius.dispersion = dispersion; 
     478    } else    if (!strcmp(par_name, "radius")) { 
     479        self->model->radius.dispersion = dispersion; 
    480480    } else    if (!strcmp(par_name, "length")) { 
    481481        self->model->length.dispersion = dispersion; 
  • sansmodels/src/sans/models/c_models/CVesicleModel.cpp

    r870f131 re2afadf  
    8787        // Initialize parameter dictionary 
    8888        PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000006)); 
    89         PyDict_SetItemString(self->params,"core_radius",Py_BuildValue("d",100.000000)); 
    9089        PyDict_SetItemString(self->params,"thickness",Py_BuildValue("d",30.000000)); 
    9190        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 
     91        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",100.000000)); 
    9292        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 
    9393        PyDict_SetItemString(self->params,"shell_sld",Py_BuildValue("d",0.000000)); 
     
    9696        PyObject * disp_dict; 
    9797        disp_dict = PyDict_New(); 
    98         self->model->core_radius.dispersion->accept_as_source(visitor, self->model->core_radius.dispersion, disp_dict); 
    99         PyDict_SetItemString(self->dispersion, "core_radius", disp_dict); 
     98        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict); 
     99        PyDict_SetItemString(self->dispersion, "radius", disp_dict); 
    100100        disp_dict = PyDict_New(); 
    101101        self->model->thickness.dispersion->accept_as_source(visitor, self->model->thickness.dispersion, disp_dict); 
     
    233233            // Reader parameter dictionary 
    234234    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") ); 
    235     self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") ); 
    236235    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") ); 
    237236    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
     237    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 
    238238    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    239239    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") ); 
     
    241241    PyObject* disp_dict; 
    242242    DispersionVisitor* visitor = new DispersionVisitor(); 
    243     disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    244     self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
     243    disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 
     244    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); 
    245245    disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 
    246246    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); 
     
    308308            // Reader parameter dictionary 
    309309    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") ); 
    310     self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") ); 
    311310    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") ); 
    312311    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
     312    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 
    313313    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    314314    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") ); 
     
    316316    PyObject* disp_dict; 
    317317    DispersionVisitor* visitor = new DispersionVisitor(); 
    318     disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    319     self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
     318    disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 
     319    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); 
    320320    disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 
    321321    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); 
     
    372372            // Reader parameter dictionary 
    373373    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") ); 
    374     self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") ); 
    375374    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") ); 
    376375    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
     376    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 
    377377    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    378378    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") ); 
     
    380380    PyObject* disp_dict; 
    381381    DispersionVisitor* visitor = new DispersionVisitor(); 
    382     disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    383     self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
     382    disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 
     383    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); 
    384384    disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 
    385385    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); 
     
    439439        // Ugliness necessary to go from python to C 
    440440            // TODO: refactor this 
    441     if (!strcmp(par_name, "core_radius")) { 
    442         self->model->core_radius.dispersion = dispersion; 
     441    if (!strcmp(par_name, "radius")) { 
     442        self->model->radius.dispersion = dispersion; 
    443443    } else    if (!strcmp(par_name, "thickness")) { 
    444444        self->model->thickness.dispersion = dispersion; 
  • sansmodels/src/sans/models/c_models/hollowcylinder.cpp

    r9188cc1 re2afadf  
    3636        core_radius = Parameter(20.0, true); 
    3737        core_radius.set_min(0.0); 
    38         shell_radius  = Parameter(30.0, true); 
    39         shell_radius.set_min(0.0); 
     38        radius  = Parameter(30.0, true); 
     39        radius.set_min(0.0); 
    4040        length     = Parameter(400.0, true); 
    4141        length.set_min(0.0); 
     
    5757        dp[0] = scale(); 
    5858        dp[1] = core_radius(); 
    59         dp[2] = shell_radius(); 
     59        dp[2] = radius(); 
    6060        dp[3] = length(); 
    6161        dp[4] = contrast(); 
     
    6767 
    6868        // Get the dispersion points for the shell radius 
    69         vector<WeightPoint> weights_shell_radius; 
    70         shell_radius.get_weights(weights_shell_radius); 
     69        vector<WeightPoint> weights_radius; 
     70        radius.get_weights(weights_radius); 
    7171 
    7272        // Get the dispersion points for the length 
     
    8787 
    8888                        // Loop over shell radius weight points 
    89                         for(int k=0; k< (int)weights_shell_radius.size(); k++) { 
    90                                 dp[2] = weights_shell_radius[k].value; 
     89                        for(int k=0; k< (int)weights_radius.size(); k++) { 
     90                                dp[2] = weights_radius[k].value; 
    9191 
    9292                                sum += weights_core_radius[i].weight 
    9393                                        * weights_length[j].weight 
    94                                         * weights_shell_radius[k].weight 
     94                                        * weights_radius[k].weight 
    9595                                        * HollowCylinder(dp, q); 
    9696                                norm += weights_core_radius[i].weight 
    9797                                * weights_length[j].weight 
    98                                 * weights_shell_radius[k].weight; 
     98                                * weights_radius[k].weight; 
    9999                        } 
    100100                } 
     
    114114        dp.scale      = scale(); 
    115115        dp.core_radius     = core_radius(); 
    116         dp.shell_radius  = shell_radius(); 
     116        dp.radius  = radius(); 
    117117        dp.length     = length(); 
    118118        dp.contrast   = contrast(); 
     
    126126 
    127127        // Get the dispersion points for the shell radius 
    128         vector<WeightPoint> weights_shell_radius; 
    129         shell_radius.get_weights(weights_shell_radius); 
     128        vector<WeightPoint> weights_radius; 
     129        radius.get_weights(weights_radius); 
    130130 
    131131        // Get the dispersion points for the length 
     
    155155 
    156156                        // Loop over shell radius weight points 
    157                         for(int m=0; m< (int)weights_shell_radius.size(); m++) { 
    158                                 dp.shell_radius = weights_shell_radius[m].value; 
     157                        for(int m=0; m< (int)weights_radius.size(); m++) { 
     158                                dp.radius = weights_radius[m].value; 
    159159 
    160160                        // Average over theta distribution 
     
    168168                                        double _ptvalue = weights_core_radius[i].weight 
    169169                                                * weights_length[j].weight 
    170                                                 * weights_shell_radius[m].weight 
     170                                                * weights_radius[m].weight 
    171171                                                * weights_theta[k].weight 
    172172                                                * weights_phi[l].weight 
     
    179179                                        norm += weights_core_radius[i].weight 
    180180                                                * weights_length[j].weight 
    181                                                 * weights_shell_radius[m].weight 
     181                                                * weights_radius[m].weight 
    182182                                                * weights_theta[k].weight 
    183183                                                * weights_phi[l].weight; 
  • sansmodels/src/sans/models/c_models/models.hh

    rc1c29b6 re2afadf  
    494494        Parameter scale; 
    495495        Parameter core_radius; 
    496         Parameter shell_radius; 
     496        Parameter radius; 
    497497        Parameter length; 
    498498        Parameter contrast; 
     
    535535        // Model parameters 
    536536        Parameter scale; 
    537         Parameter core_radius; 
     537        Parameter radius; 
    538538        Parameter thickness; 
    539539        Parameter core_sld; 
  • sansmodels/src/sans/models/c_models/vesicle.cpp

    r9188cc1 re2afadf  
    3232VesicleModel :: VesicleModel() { 
    3333        scale      = Parameter(1.0); 
    34         core_radius     = Parameter(100.0, true); 
    35         core_radius.set_min(0.0); 
     34        radius     = Parameter(100.0, true); 
     35        radius.set_min(0.0); 
    3636        thickness  = Parameter(30.0, true); 
    3737        thickness.set_min(0.0); 
     
    5353        // Add the background after averaging 
    5454        dp[0] = scale(); 
    55         dp[1] = core_radius(); 
     55        dp[1] = radius(); 
    5656        dp[2] = thickness(); 
    5757        dp[3] = core_sld(); 
     
    6161 
    6262        // Get the dispersion points for the core radius 
    63         vector<WeightPoint> weights_core_radius; 
    64         core_radius.get_weights(weights_core_radius); 
     63        vector<WeightPoint> weights_radius; 
     64        radius.get_weights(weights_radius); 
    6565        // Get the dispersion points for the thickness 
    6666        vector<WeightPoint> weights_thickness; 
     
    7272 
    7373        // Loop over radius weight points 
    74         for(int i=0; i< (int)weights_core_radius.size(); i++) { 
    75                 dp[1] = weights_core_radius[i].value; 
    76                 for(int j=0; j< (int)weights_core_radius.size(); j++) { 
     74        for(int i=0; i< (int)weights_radius.size(); i++) { 
     75                dp[1] = weights_radius[i].value; 
     76                for(int j=0; j< (int)weights_thickness.size(); j++) { 
    7777                        dp[2] = weights_thickness[j].value; 
    78                         sum += weights_core_radius[i].weight 
     78                        sum += weights_radius[i].weight 
    7979                                * weights_thickness[j].weight * VesicleForm(dp, q); 
    80                         norm += weights_core_radius[i].weight * weights_thickness[j].weight; 
     80                        norm += weights_radius[i].weight * weights_thickness[j].weight; 
    8181                } 
    8282        } 
Note: See TracChangeset for help on using the changeset viewer.