Changeset e2afadf in sasview for sansmodels/src/sans/models/c_models
- Timestamp:
- Aug 25, 2009 3:31:36 PM (15 years ago)
- 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
- Location:
- sansmodels/src/sans/models/c_models
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/CHollowCylinderModel.cpp
r870f131 re2afadf 91 91 PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000)); 92 92 PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000)); 93 PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",30.000000)); 93 94 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.010000)); 94 PyDict_SetItemString(self->params,"shell_radius",Py_BuildValue("d",30.000000));95 95 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005)); 96 96 // Initialize dispersion / averaging parameter dict … … 101 101 PyDict_SetItemString(self->dispersion, "core_radius", disp_dict); 102 102 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); 105 105 disp_dict = PyDict_New(); 106 106 self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict); … … 248 248 self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") ); 249 249 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 250 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 250 251 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 251 self->model->shell_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_radius") );252 252 self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 253 253 // Read in dispersion parameters … … 256 256 disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 257 257 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); 260 260 disp_dict = PyDict_GetItemString(self->dispersion, "length"); 261 261 self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); … … 331 331 self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") ); 332 332 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 333 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 333 334 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 334 self->model->shell_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_radius") );335 335 self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 336 336 // Read in dispersion parameters … … 339 339 disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 340 340 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); 343 343 disp_dict = PyDict_GetItemString(self->dispersion, "length"); 344 344 self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); … … 403 403 self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") ); 404 404 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 405 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 405 406 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 406 self->model->shell_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_radius") );407 407 self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 408 408 // Read in dispersion parameters … … 411 411 disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 412 412 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); 415 415 disp_dict = PyDict_GetItemString(self->dispersion, "length"); 416 416 self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); … … 476 476 if (!strcmp(par_name, "core_radius")) { 477 477 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; 480 480 } else if (!strcmp(par_name, "length")) { 481 481 self->model->length.dispersion = dispersion; -
sansmodels/src/sans/models/c_models/CVesicleModel.cpp
r870f131 re2afadf 87 87 // Initialize parameter dictionary 88 88 PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000006)); 89 PyDict_SetItemString(self->params,"core_radius",Py_BuildValue("d",100.000000));90 89 PyDict_SetItemString(self->params,"thickness",Py_BuildValue("d",30.000000)); 91 90 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 91 PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",100.000000)); 92 92 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 93 93 PyDict_SetItemString(self->params,"shell_sld",Py_BuildValue("d",0.000000)); … … 96 96 PyObject * disp_dict; 97 97 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); 100 100 disp_dict = PyDict_New(); 101 101 self->model->thickness.dispersion->accept_as_source(visitor, self->model->thickness.dispersion, disp_dict); … … 233 233 // Reader parameter dictionary 234 234 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") );236 235 self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") ); 237 236 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 237 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 238 238 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 239 239 self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") ); … … 241 241 PyObject* disp_dict; 242 242 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); 245 245 disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 246 246 self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); … … 308 308 // Reader parameter dictionary 309 309 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") );311 310 self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") ); 312 311 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 312 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 313 313 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 314 314 self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") ); … … 316 316 PyObject* disp_dict; 317 317 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); 320 320 disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 321 321 self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); … … 372 372 // Reader parameter dictionary 373 373 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") );375 374 self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") ); 376 375 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 376 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 377 377 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 378 378 self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") ); … … 380 380 PyObject* disp_dict; 381 381 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); 384 384 disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 385 385 self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); … … 439 439 // Ugliness necessary to go from python to C 440 440 // 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; 443 443 } else if (!strcmp(par_name, "thickness")) { 444 444 self->model->thickness.dispersion = dispersion; -
sansmodels/src/sans/models/c_models/hollowcylinder.cpp
r9188cc1 re2afadf 36 36 core_radius = Parameter(20.0, true); 37 37 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); 40 40 length = Parameter(400.0, true); 41 41 length.set_min(0.0); … … 57 57 dp[0] = scale(); 58 58 dp[1] = core_radius(); 59 dp[2] = shell_radius();59 dp[2] = radius(); 60 60 dp[3] = length(); 61 61 dp[4] = contrast(); … … 67 67 68 68 // 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); 71 71 72 72 // Get the dispersion points for the length … … 87 87 88 88 // 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; 91 91 92 92 sum += weights_core_radius[i].weight 93 93 * weights_length[j].weight 94 * weights_ shell_radius[k].weight94 * weights_radius[k].weight 95 95 * HollowCylinder(dp, q); 96 96 norm += weights_core_radius[i].weight 97 97 * weights_length[j].weight 98 * weights_ shell_radius[k].weight;98 * weights_radius[k].weight; 99 99 } 100 100 } … … 114 114 dp.scale = scale(); 115 115 dp.core_radius = core_radius(); 116 dp. shell_radius = shell_radius();116 dp.radius = radius(); 117 117 dp.length = length(); 118 118 dp.contrast = contrast(); … … 126 126 127 127 // 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); 130 130 131 131 // Get the dispersion points for the length … … 155 155 156 156 // 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; 159 159 160 160 // Average over theta distribution … … 168 168 double _ptvalue = weights_core_radius[i].weight 169 169 * weights_length[j].weight 170 * weights_ shell_radius[m].weight170 * weights_radius[m].weight 171 171 * weights_theta[k].weight 172 172 * weights_phi[l].weight … … 179 179 norm += weights_core_radius[i].weight 180 180 * weights_length[j].weight 181 * weights_ shell_radius[m].weight181 * weights_radius[m].weight 182 182 * weights_theta[k].weight 183 183 * weights_phi[l].weight; -
sansmodels/src/sans/models/c_models/models.hh
rc1c29b6 re2afadf 494 494 Parameter scale; 495 495 Parameter core_radius; 496 Parameter shell_radius;496 Parameter radius; 497 497 Parameter length; 498 498 Parameter contrast; … … 535 535 // Model parameters 536 536 Parameter scale; 537 Parameter core_radius;537 Parameter radius; 538 538 Parameter thickness; 539 539 Parameter core_sld; -
sansmodels/src/sans/models/c_models/vesicle.cpp
r9188cc1 re2afadf 32 32 VesicleModel :: VesicleModel() { 33 33 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); 36 36 thickness = Parameter(30.0, true); 37 37 thickness.set_min(0.0); … … 53 53 // Add the background after averaging 54 54 dp[0] = scale(); 55 dp[1] = core_radius();55 dp[1] = radius(); 56 56 dp[2] = thickness(); 57 57 dp[3] = core_sld(); … … 61 61 62 62 // 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); 65 65 // Get the dispersion points for the thickness 66 66 vector<WeightPoint> weights_thickness; … … 72 72 73 73 // 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++) { 77 77 dp[2] = weights_thickness[j].value; 78 sum += weights_ core_radius[i].weight78 sum += weights_radius[i].weight 79 79 * 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; 81 81 } 82 82 }
Note: See TracChangeset
for help on using the changeset viewer.